mirror of
https://github.com/any86/any-rule.git
synced 2025-07-14 15:38:58 +08:00
feat:初步添加正则图解功能
This commit is contained in:
parent
4eac7b3e8c
commit
e84a22c3a2
4038
dist/extension.js
vendored
4038
dist/extension.js
vendored
File diff suppressed because one or more lines are too long
2
dist/extension.js.map
vendored
2
dist/extension.js.map
vendored
File diff suppressed because one or more lines are too long
@ -2,13 +2,16 @@ import { ExtensionContext, CompletionItem, CompletionItemKind, languages, Dispos
|
||||
import { generateFilterString, getRulesByText } from "./utils";
|
||||
import { IRule } from "./interface";
|
||||
import { loadRules } from './loader';
|
||||
import { RegexDiagram } from './diagram/panel';
|
||||
|
||||
export class AnyRule {
|
||||
context: ExtensionContext;
|
||||
disposable: Disposable | null = null;
|
||||
rules: IRule[] | null = null;
|
||||
regexDiagram: RegexDiagram | null = null;
|
||||
constructor(context: ExtensionContext) {
|
||||
this.context = context;
|
||||
this.regexDiagram = new RegexDiagram(context);
|
||||
loadRules(context.extensionPath).then(rules => {
|
||||
this.rules = rules;
|
||||
this.load();
|
||||
|
107
src/diagram/index.html
Normal file
107
src/diagram/index.html
Normal file
File diff suppressed because one or more lines are too long
19
src/diagram/panel.ts
Normal file
19
src/diagram/panel.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { WebviewPanel, window, ViewColumn, Uri, workspace, ExtensionContext } from "vscode";
|
||||
import { join } from 'path';
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
export class RegexDiagram {
|
||||
regex: string | null = null;
|
||||
panel: WebviewPanel | null = null;
|
||||
constructor(context: ExtensionContext) {
|
||||
this.panel = window.createWebviewPanel('regexDiagram', '图解正则表达式', ViewColumn.Two, {
|
||||
enableScripts: true,
|
||||
retainContextWhenHidden: false,
|
||||
});
|
||||
console.log(join(context.extensionPath, 'src/diagram', './index.html'));
|
||||
this.panel.webview.html = readFileSync(join(context.extensionPath, 'src/diagram', './index.html')).toString();
|
||||
this.panel.webview.postMessage({
|
||||
regex: this.regex || '/aaaaab{1,3}/',
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user