@@ -2,97 +2,13 @@ import type { ExtensionContext, TextDocument } from 'vscode';
2
2
import { MarkdownString , OverviewRulerLane , Range , window , workspace } from 'vscode' ;
3
3
import { disposeSettingListener , initialSetting } from './settings' ;
4
4
import { Log } from './log' ;
5
- import { EXT_NAME , mockDocument } from './constant' ;
5
+ import { EXT_NAME , baseHTMLContent , mockDocument } from './constant' ;
6
6
import { svg64 } from './svg64' ;
7
7
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
8
// @ts -expect-error
9
9
import Regexper from './regexp-visualizer/js/regexper.js' ;
10
10
11
- mockDocument . body . innerHTML = `
12
- <div id="regexp-render"><svg></svg></div>
13
- <script type="text/html" id="svg-container-base">
14
- <div class="svg">
15
- <svg
16
- xmlns="http://www.w3.org/2000/svg"
17
- xmlns:cc="http://creativecommons.org/ns#"
18
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
19
- version="1.1">
20
- <defs>
21
- <style type="text/css">svg {
22
- background-color: #fff; }
23
-
24
- .root text,
25
- .root tspan {
26
- font: 12px Arial; }
27
-
28
- .root path {
29
- fill-opacity: 0;
30
- stroke-width: 2px;
31
- stroke: #000; }
32
-
33
- .root circle {
34
- fill: #6b6659;
35
- stroke-width: 2px;
36
- stroke: #000; }
37
-
38
- .anchor text, .any-character text {
39
- fill: #fff; }
40
-
41
- .anchor rect, .any-character rect {
42
- fill: #6b6659; }
43
-
44
- .escape text, .charset-escape text, .literal text {
45
- fill: #000; }
46
-
47
- .escape rect, .charset-escape rect {
48
- fill: #bada55; }
49
-
50
- .literal rect {
51
- fill: #dae9e5; }
52
-
53
- .charset .charset-box {
54
- fill: #cbcbba; }
55
-
56
- .subexp .subexp-label tspan,
57
- .charset .charset-label tspan,
58
- .match-fragment .repeat-label tspan {
59
- font-size: 10px; }
60
-
61
- .repeat-label {
62
- cursor: help; }
63
-
64
- .subexp .subexp-label tspan,
65
- .charset .charset-label tspan {
66
- dominant-baseline: text-after-edge; }
67
-
68
- .subexp .subexp-box {
69
- stroke: #908c83;
70
- stroke-dasharray: 6,2;
71
- stroke-width: 2px;
72
- fill-opacity: 0; }
73
-
74
- .quote {
75
- fill: #908c83; }
76
- </style>
77
- </defs>
78
- <metadata>
79
- <rdf:RDF>
80
- <cc:License rdf:about="http://creativecommons.org/licenses/by/3.0/">
81
- <cc:permits rdf:resource="http://creativecommons.org/ns#Reproduction" />
82
- <cc:permits rdf:resource="http://creativecommons.org/ns#Distribution" />
83
- <cc:requires rdf:resource="http://creativecommons.org/ns#Notice" />
84
- <cc:requires rdf:resource="http://creativecommons.org/ns#Attribution" />
85
- <cc:permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
86
- </cc:License>
87
- </rdf:RDF>
88
- </metadata>
89
- </svg>
90
- </div>
91
- <div class="progress">
92
- <div style="width:0;"></div>
93
- </div>
94
- </script>
95
- ` ;
11
+ mockDocument . body . innerHTML = baseHTMLContent ;
96
12
interface RegexMatch {
97
13
document : TextDocument
98
14
regex : RegExp
@@ -147,7 +63,7 @@ export function activate(context: ExtensionContext) {
147
63
148
64
const regexper = new Regexper ( mockDocument . body ) ;
149
65
150
- await regexper . showExpression ( regexStr . slice ( 1 , - 1 ) ) ;
66
+ await regexper . showExpression ( regexStr ) ;
151
67
152
68
const svgParentContainer = regexper . svgContainer . querySelector ( 'svg' ) ;
153
69
@@ -158,7 +74,7 @@ export function activate(context: ExtensionContext) {
158
74
159
75
const result = base64SVGStr ;
160
76
161
- const dom = `<img src="${ result } " />` ;
77
+ const dom = `<img src="${ result } " /><br/>[Open in the browser](https://regexper.com/# ${ encodeURIComponent ( regexStr ) } ) ` ;
162
78
const message = new MarkdownString ( dom ) ;
163
79
164
80
message . isTrusted = true ;
0 commit comments