@codingame/monaco-vscode-markdown-language-features-default-extension 34.1.3 → 35.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +78 -11
- package/package.json +2 -2
- package/resources/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/resources/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/resources/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/resources/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/resources/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/resources/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/resources/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/resources/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/resources/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/resources/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/resources/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/resources/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/resources/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/resources/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/resources/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/resources/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/resources/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/resources/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/resources/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/resources/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/resources/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/resources/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/resources/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/resources/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/resources/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/resources/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/resources/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/resources/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/resources/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/resources/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/resources/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/resources/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/resources/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/resources/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/resources/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/resources/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/resources/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/resources/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/resources/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/resources/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/resources/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/resources/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/resources/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/resources/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/resources/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/resources/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/resources/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/resources/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/resources/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/resources/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/resources/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/resources/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/resources/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/resources/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/resources/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/resources/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/resources/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/resources/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/resources/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/resources/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/resources/editor.css.txt +1 -0
- package/resources/editor.js +3446 -0
- package/resources/editor.ts +128 -0
- package/resources/extension.js +192 -179
- package/resources/extension.js.map +4 -4
- package/resources/index.js +1 -1
- package/resources/index2.js +21 -22
- package/resources/markdownEditor.css.txt +22 -0
- package/resources/package.json +1 -1
- package/resources/serverWorkerMain.js +297 -250
- package/resources/syntaxHighlighter.ts +216 -0
- package/resources/tsconfig.json +1 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import { EditorController, EditorModel, EditorView, GutterMarker, OffsetRange, StringEdit, StringValue, findNodeOffsetById, taskCheckboxRange } from '@vscode/markdown-editor';
|
|
7
|
+
import { Disposable, autorun } from '@vscode/markdown-editor/observables';
|
|
8
|
+
import mermaid from 'mermaid';
|
|
9
|
+
import 'katex/dist/katex.min.css';
|
|
10
|
+
import '@vscode/markdown-editor/editor.css';
|
|
11
|
+
import '@vscode/markdown-editor/themes/vscode.css';
|
|
12
|
+
import './markdownEditor.css';
|
|
13
|
+
import { WebviewSyntaxHighlighter } from './syntaxHighlighter';
|
|
14
|
+
|
|
15
|
+
interface VsCodeApi {
|
|
16
|
+
postMessage(message: unknown): void;
|
|
17
|
+
getState(): unknown;
|
|
18
|
+
setState(state: unknown): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare function acquireVsCodeApi(): VsCodeApi;
|
|
22
|
+
|
|
23
|
+
class Editor extends Disposable {
|
|
24
|
+
readonly model = new EditorModel();
|
|
25
|
+
isUpdatingFromExtension = false;
|
|
26
|
+
#mermaidCounter = 0;
|
|
27
|
+
#initialized = false;
|
|
28
|
+
|
|
29
|
+
readonly #vscode = acquireVsCodeApi();
|
|
30
|
+
readonly #syntaxHighlighter = new WebviewSyntaxHighlighter((message) => this.#vscode.postMessage(message));
|
|
31
|
+
|
|
32
|
+
constructor(host: HTMLElement) {
|
|
33
|
+
super();
|
|
34
|
+
|
|
35
|
+
mermaid.initialize({ startOnLoad: false, theme: 'default' });
|
|
36
|
+
|
|
37
|
+
window.addEventListener('message', (event) => {
|
|
38
|
+
const message = event.data;
|
|
39
|
+
if (this.#syntaxHighlighter.handleMessage(message)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
switch (message.type) {
|
|
43
|
+
case 'init': {
|
|
44
|
+
if (!this.#initialized) {
|
|
45
|
+
this.#initialized = true;
|
|
46
|
+
this.#createView(host, !!message.readonly);
|
|
47
|
+
this.model.sourceText.set(new StringValue(message.content), undefined);
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case 'update': {
|
|
52
|
+
this.isUpdatingFromExtension = true;
|
|
53
|
+
this.model.sourceText.set(new StringValue(message.content), undefined);
|
|
54
|
+
this.isUpdatingFromExtension = false;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'gutterMarkers': {
|
|
58
|
+
const markers: GutterMarker[] = message.markers.map((marker: { start: number; endExclusive: number; type: GutterMarker['type'] }) => ({
|
|
59
|
+
range: OffsetRange.fromTo(marker.start, marker.endExclusive),
|
|
60
|
+
type: marker.type,
|
|
61
|
+
}));
|
|
62
|
+
this.model.gutterMarkers.set(markers, undefined);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this.#vscode.postMessage({ type: 'ready' });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#createView(host: HTMLElement, readonly: boolean): void {
|
|
72
|
+
const model = this.model;
|
|
73
|
+
|
|
74
|
+
const view = this._register(new EditorView(model, {
|
|
75
|
+
classNames: ['md-theme-vscode'],
|
|
76
|
+
syntaxHighlighter: this.#syntaxHighlighter,
|
|
77
|
+
onToggleCheckbox: (item, newChecked) => {
|
|
78
|
+
if (readonly) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const doc = model.document.get();
|
|
82
|
+
const itemOffset = findNodeOffsetById(doc, item);
|
|
83
|
+
if (itemOffset === undefined) { return; }
|
|
84
|
+
const range = taskCheckboxRange(item);
|
|
85
|
+
if (!range) { return; }
|
|
86
|
+
model.applyEdit(
|
|
87
|
+
StringEdit.replace(
|
|
88
|
+
range.delta(itemOffset),
|
|
89
|
+
newChecked ? '[x]' : '[ ]'
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
renderCustomCodeBlock: (language, content) => {
|
|
94
|
+
if (language !== 'mermaid') {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const div = document.createElement('div');
|
|
98
|
+
div.className = 'md-mermaid';
|
|
99
|
+
const id = `mermaid-${this.#mermaidCounter++}`;
|
|
100
|
+
mermaid
|
|
101
|
+
.render(id, content)
|
|
102
|
+
.then(({ svg }) => {
|
|
103
|
+
div.innerHTML = svg;
|
|
104
|
+
})
|
|
105
|
+
.catch(() => {
|
|
106
|
+
div.textContent = content;
|
|
107
|
+
});
|
|
108
|
+
return div;
|
|
109
|
+
},
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
this._register(new EditorController(model, view));
|
|
113
|
+
host.appendChild(view.element);
|
|
114
|
+
|
|
115
|
+
if (!readonly) {
|
|
116
|
+
let firstTime = true;
|
|
117
|
+
this._register(autorun((reader) => {
|
|
118
|
+
const text = reader.readObservable(this.model.sourceText).value;
|
|
119
|
+
if (!this.isUpdatingFromExtension && !firstTime) {
|
|
120
|
+
this.#vscode.postMessage({ type: 'edit', content: text });
|
|
121
|
+
}
|
|
122
|
+
firstTime = false;
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
new Editor(document.getElementById('editor')!);
|