-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextension.ts
69 lines (61 loc) · 1.91 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from "vscode";
import { JsxDetector } from "./actions/jsx-detector";
import {
convertToClipboard,
convertInlineToComponent,
convertInlineToInline,
convertInlineToFile,
convertToFile,
pasteEvent,
} from "./commands";
export function activate(context: vscode.ExtensionContext) {
// Add code actions to detect invalid SVG code in .ts & .js
context.subscriptions.push(
vscode.languages.registerCodeActionsProvider(
["javascript", "typescript"],
new JsxDetector(),
{
providedCodeActionKinds: JsxDetector.providedCodeActionKinds,
}
)
);
// Addd code lens to detect invalid SVG code in .ts & .js
context.subscriptions.push(
vscode.languages.registerCodeLensProvider(
["javascript", "typescript"],
new JsxDetector()
)
);
// Convert selected text to component in clipboard
const convertSelectionToFile = vscode.commands.registerCommand(
"svgr.convert_selection",
convertToClipboard
);
// Listen to paste changes into a blank file
vscode.workspace.onDidChangeTextDocument(pasteEvent);
// Convert SVG file to JSX file
const convertFileToFile = vscode.commands.registerCommand(
"svgr.convert_file",
convertToFile
);
context.subscriptions.push(convertSelectionToFile);
context.subscriptions.push(convertFileToFile);
// ===============================
// Commands called by code actions
vscode.commands.registerCommand(
"svgr.qa_convert_to_component",
convertInlineToComponent
);
vscode.commands.registerCommand(
"svgr.qa_convert_to_inline",
convertInlineToInline
);
vscode.commands.registerCommand(
"svgr.qa_convert_to_file",
convertInlineToFile
);
}
// this method is called when your extension is deactivated
export function deactivate() {}