wikiparser-node 1.16.1 → 1.16.2
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/bundle/bundle.es7.js +26 -29
- package/data/signatures.json +82 -4
- package/dist/addon/table.js +9 -3
- package/dist/addon/token.js +73 -90
- package/dist/addon/transclude.js +3 -3
- package/dist/base.d.mts +10 -2
- package/dist/base.d.ts +10 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +6 -6
- package/dist/lib/attributes.d.ts +24 -0
- package/dist/lib/attributes.js +67 -0
- package/dist/lib/element.js +9 -9
- package/dist/lib/lsp.d.ts +16 -2
- package/dist/lib/lsp.js +159 -148
- package/dist/lib/node.d.ts +2 -0
- package/dist/lib/node.js +93 -50
- package/dist/lib/ranges.d.ts +4 -8
- package/dist/lib/ranges.js +12 -19
- package/dist/lib/text.js +6 -4
- package/dist/lib/title.js +3 -1
- package/dist/parser/braces.js +3 -3
- package/dist/parser/commentAndExt.js +2 -3
- package/dist/parser/hrAndDoubleUnderscore.js +1 -2
- package/dist/parser/links.js +1 -2
- package/dist/parser/magicLinks.js +4 -2
- package/dist/parser/selector.js +37 -30
- package/dist/src/html.js +6 -4
- package/dist/src/imageParameter.js +12 -13
- package/dist/src/imagemap.js +3 -3
- package/dist/src/index.d.ts +23 -19
- package/dist/src/index.js +74 -48
- package/dist/src/link/file.js +1 -2
- package/dist/src/magicLink.js +8 -6
- package/dist/src/nested.js +4 -1
- package/dist/src/nowiki/index.js +3 -3
- package/dist/src/nowiki/list.js +1 -1
- package/dist/src/redirect.js +1 -2
- package/dist/src/table/index.js +10 -4
- package/dist/src/table/td.js +47 -55
- package/dist/src/transclude.js +5 -5
- package/dist/util/constants.js +2 -0
- package/dist/util/debug.js +14 -18
- package/dist/util/html.js +2 -0
- package/dist/util/lint.js +24 -4
- package/dist/util/string.js +9 -5
- package/extensions/es7/base.js +22 -4
- package/extensions/es7/lint.js +20 -11
- package/extensions/typings.d.ts +1 -2
- package/package.json +4 -3
- package/bundle/bundle.lsp.js +0 -42
- package/bundle/bundle.min.js +0 -38
- package/extensions/dist/base.js +0 -268
- package/extensions/dist/codejar.js +0 -56
- package/extensions/dist/editor.js +0 -159
- package/extensions/dist/highlight.js +0 -30
- package/extensions/dist/lint.js +0 -72
- package/extensions/dist/lsp.js +0 -67
- package/extensions/dist/test-page.js +0 -89
- package/extensions/editor.css +0 -59
- package/extensions/ui.css +0 -162
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _Printer_instances, _Printer_id, _Printer_preview, _Printer_textbox, _Printer_root, _Printer_viewportChanged, _Printer_running, _Printer_ticks, _Printer_tick, _Printer_exec, _Printer_paint, _Printer_coarsePrint, _Printer_finePrint;
|
|
14
|
-
class Printer {
|
|
15
|
-
constructor(preview, textbox, include) {
|
|
16
|
-
_Printer_instances.add(this);
|
|
17
|
-
_Printer_id.set(this, void 0);
|
|
18
|
-
_Printer_preview.set(this, void 0);
|
|
19
|
-
_Printer_textbox.set(this, void 0);
|
|
20
|
-
_Printer_root.set(this, void 0);
|
|
21
|
-
_Printer_viewportChanged.set(this, void 0);
|
|
22
|
-
_Printer_running.set(this, void 0);
|
|
23
|
-
_Printer_ticks.set(this, void 0);
|
|
24
|
-
__classPrivateFieldSet(this, _Printer_id, wikiparse.id++, "f");
|
|
25
|
-
__classPrivateFieldSet(this, _Printer_preview, preview, "f");
|
|
26
|
-
__classPrivateFieldSet(this, _Printer_textbox, textbox, "f");
|
|
27
|
-
__classPrivateFieldSet(this, _Printer_root, [], "f");
|
|
28
|
-
__classPrivateFieldSet(this, _Printer_viewportChanged, false, "f");
|
|
29
|
-
this.include = Boolean(include);
|
|
30
|
-
__classPrivateFieldSet(this, _Printer_ticks, [0, undefined], "f");
|
|
31
|
-
}
|
|
32
|
-
queue(delay, method) {
|
|
33
|
-
const [state] = __classPrivateFieldGet(this, _Printer_ticks, "f");
|
|
34
|
-
if (delay === 0 || state <= 0 || method === 0 || __classPrivateFieldGet(this, _Printer_ticks, "f")[1] !== 0) {
|
|
35
|
-
__classPrivateFieldSet(this, _Printer_ticks, [delay, method], "f");
|
|
36
|
-
if (delay === 0) {
|
|
37
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_exec).call(this, method);
|
|
38
|
-
}
|
|
39
|
-
else if (state <= 0) {
|
|
40
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_tick).call(this);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
_Printer_id = new WeakMap(), _Printer_preview = new WeakMap(), _Printer_textbox = new WeakMap(), _Printer_root = new WeakMap(), _Printer_viewportChanged = new WeakMap(), _Printer_running = new WeakMap(), _Printer_ticks = new WeakMap(), _Printer_instances = new WeakSet(), _Printer_tick = function _Printer_tick() {
|
|
46
|
-
setTimeout(() => {
|
|
47
|
-
const [t, method] = __classPrivateFieldGet(this, _Printer_ticks, "f");
|
|
48
|
-
if (t > 0) {
|
|
49
|
-
__classPrivateFieldGet(this, _Printer_ticks, "f")[0] -= 500;
|
|
50
|
-
if (t <= 500) {
|
|
51
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_exec).call(this, method);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_tick).call(this);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}, 500);
|
|
58
|
-
}, _Printer_exec = function _Printer_exec(method) {
|
|
59
|
-
if (method === 0) {
|
|
60
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_coarsePrint).call(this);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_finePrint).call(this);
|
|
64
|
-
}
|
|
65
|
-
}, _Printer_paint = function _Printer_paint() {
|
|
66
|
-
__classPrivateFieldGet(this, _Printer_preview, "f").innerHTML = `<span class="wpb-root">${__classPrivateFieldGet(this, _Printer_root, "f").map(([, , printed]) => printed).join('')}</span> `;
|
|
67
|
-
__classPrivateFieldGet(this, _Printer_preview, "f").scrollTop = __classPrivateFieldGet(this, _Printer_textbox, "f").scrollTop;
|
|
68
|
-
__classPrivateFieldGet(this, _Printer_preview, "f").classList.remove('active');
|
|
69
|
-
__classPrivateFieldGet(this, _Printer_textbox, "f").style.color = 'transparent';
|
|
70
|
-
}, _Printer_coarsePrint = async function _Printer_coarsePrint() {
|
|
71
|
-
if (__classPrivateFieldGet(this, _Printer_running, "f")) {
|
|
72
|
-
return __classPrivateFieldGet(this, _Printer_running, "f");
|
|
73
|
-
}
|
|
74
|
-
const { include } = this, { value } = __classPrivateFieldGet(this, _Printer_textbox, "f"), parsed = await wikiparse.print(value, include, 2, __classPrivateFieldGet(this, _Printer_id, "f"));
|
|
75
|
-
if (this.include !== include || __classPrivateFieldGet(this, _Printer_textbox, "f").value !== value) {
|
|
76
|
-
__classPrivateFieldSet(this, _Printer_running, undefined, "f");
|
|
77
|
-
__classPrivateFieldSet(this, _Printer_running, __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_coarsePrint).call(this), "f");
|
|
78
|
-
return __classPrivateFieldGet(this, _Printer_running, "f");
|
|
79
|
-
}
|
|
80
|
-
__classPrivateFieldSet(this, _Printer_root, parsed, "f");
|
|
81
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_paint).call(this);
|
|
82
|
-
__classPrivateFieldSet(this, _Printer_running, undefined, "f");
|
|
83
|
-
__classPrivateFieldSet(this, _Printer_running, __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_finePrint).call(this), "f");
|
|
84
|
-
return __classPrivateFieldGet(this, _Printer_running, "f");
|
|
85
|
-
}, _Printer_finePrint = async function _Printer_finePrint() {
|
|
86
|
-
if (__classPrivateFieldGet(this, _Printer_running, "f")) {
|
|
87
|
-
__classPrivateFieldSet(this, _Printer_viewportChanged, true, "f");
|
|
88
|
-
return __classPrivateFieldGet(this, _Printer_running, "f");
|
|
89
|
-
}
|
|
90
|
-
__classPrivateFieldSet(this, _Printer_viewportChanged, false, "f");
|
|
91
|
-
const { include } = this, { value } = __classPrivateFieldGet(this, _Printer_textbox, "f"), { scrollHeight, offsetHeight: parentHeight, scrollTop, children } = __classPrivateFieldGet(this, _Printer_preview, "f");
|
|
92
|
-
let text = value, start = 0, end = __classPrivateFieldGet(this, _Printer_root, "f").length;
|
|
93
|
-
if (scrollHeight > parentHeight) {
|
|
94
|
-
const childNodes = [...children[0].childNodes], headings = childNodes.filter(({ className }) => className === 'wpb-heading'), { length } = headings;
|
|
95
|
-
if (length > 0) {
|
|
96
|
-
let i = headings.findIndex(({ offsetTop, offsetHeight }) => offsetTop + offsetHeight > scrollTop);
|
|
97
|
-
i = i === -1 ? length : i;
|
|
98
|
-
let j = headings.slice(i).findIndex(({ offsetTop }) => offsetTop >= scrollTop + parentHeight);
|
|
99
|
-
j = j === -1 ? length : i + j;
|
|
100
|
-
start = i ? childNodes.indexOf(headings[i - 1]) : 0;
|
|
101
|
-
while (i <= j && __classPrivateFieldGet(this, _Printer_root, "f")[start][0] === Infinity) {
|
|
102
|
-
start = childNodes.indexOf(headings[i++]);
|
|
103
|
-
}
|
|
104
|
-
end = j === length ? end : childNodes.indexOf(headings[j]);
|
|
105
|
-
while (i <= j && __classPrivateFieldGet(this, _Printer_root, "f")[end - 1][0] === Infinity) {
|
|
106
|
-
end = childNodes.indexOf(headings[--j]);
|
|
107
|
-
}
|
|
108
|
-
text = __classPrivateFieldGet(this, _Printer_root, "f").slice(start, end).map(([, str]) => str).join('');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (start === end) {
|
|
112
|
-
__classPrivateFieldSet(this, _Printer_running, undefined, "f");
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
const parsed = await wikiparse.print(text, include, undefined, __classPrivateFieldGet(this, _Printer_id, "f"));
|
|
116
|
-
if (this.include === include && __classPrivateFieldGet(this, _Printer_textbox, "f").value === value) {
|
|
117
|
-
__classPrivateFieldGet(this, _Printer_root, "f").splice(start, end - start, ...parsed);
|
|
118
|
-
__classPrivateFieldGet(this, _Printer_instances, "m", _Printer_paint).call(this);
|
|
119
|
-
__classPrivateFieldSet(this, _Printer_running, undefined, "f");
|
|
120
|
-
if (__classPrivateFieldGet(this, _Printer_viewportChanged, "f")) {
|
|
121
|
-
__classPrivateFieldSet(this, _Printer_running, __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_finePrint).call(this), "f");
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
__classPrivateFieldSet(this, _Printer_running, undefined, "f");
|
|
126
|
-
__classPrivateFieldSet(this, _Printer_running, __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_coarsePrint).call(this), "f");
|
|
127
|
-
}
|
|
128
|
-
return __classPrivateFieldGet(this, _Printer_running, "f");
|
|
129
|
-
};
|
|
130
|
-
const edit = (textbox, include) => {
|
|
131
|
-
if (!(textbox instanceof HTMLTextAreaElement)) {
|
|
132
|
-
throw new TypeError('wikiparse.edit方法仅可用于textarea元素!');
|
|
133
|
-
}
|
|
134
|
-
const preview = document.createElement('div'), container = document.createElement('div'), printer = new Printer(preview, textbox, include);
|
|
135
|
-
preview.id = 'wikiPretty';
|
|
136
|
-
preview.classList.add('wikiparser', 'active');
|
|
137
|
-
container.className = 'wikiparse-container';
|
|
138
|
-
textbox.replaceWith(container);
|
|
139
|
-
textbox.classList.add('wikiparsed');
|
|
140
|
-
container.append(preview, textbox);
|
|
141
|
-
textbox.addEventListener('input', e => {
|
|
142
|
-
if (!e.isComposing) {
|
|
143
|
-
printer.queue(2000, 0);
|
|
144
|
-
}
|
|
145
|
-
textbox.style.color = '';
|
|
146
|
-
preview.classList.add('active');
|
|
147
|
-
});
|
|
148
|
-
textbox.addEventListener('scroll', () => {
|
|
149
|
-
if (preview.scrollHeight > preview.offsetHeight && !preview.classList.contains('active')) {
|
|
150
|
-
preview.scrollTop = textbox.scrollTop;
|
|
151
|
-
printer.queue(500, 1);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
printer.queue(0, 0);
|
|
155
|
-
return printer;
|
|
156
|
-
};
|
|
157
|
-
wikiparse.Printer = Printer;
|
|
158
|
-
wikiparse.edit = edit;
|
|
159
|
-
})();
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
"use strict";
|
|
3
|
-
const highlight = async (ele, include, linenums, start) => {
|
|
4
|
-
if (ele.classList.contains('wikiparser')) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
let { innerText } = ele;
|
|
8
|
-
if (innerText.endsWith('\n')) {
|
|
9
|
-
innerText = innerText.slice(0, -1);
|
|
10
|
-
}
|
|
11
|
-
innerText || (innerText = ' ');
|
|
12
|
-
const html = `<span class="wpb-root">${(await wikiparse.print(innerText, include)).map(([, , printed]) => printed).join('')}</span>`;
|
|
13
|
-
ele.classList.add('wikiparser');
|
|
14
|
-
ele.tabIndex = 0;
|
|
15
|
-
ele.innerHTML = html;
|
|
16
|
-
if (linenums) {
|
|
17
|
-
wikiparse.lineNumbers(ele.firstChild, start);
|
|
18
|
-
}
|
|
19
|
-
ele.addEventListener('keydown', e => {
|
|
20
|
-
if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
const range = document.createRange(), selection = getSelection();
|
|
23
|
-
range.selectNodeContents(ele.firstChild);
|
|
24
|
-
selection.removeAllRanges();
|
|
25
|
-
selection.addRange(range);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
wikiparse.highlight = highlight;
|
|
30
|
-
})();
|
package/extensions/dist/lint.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _Linter_instances, _Linter_id, _Linter_wikitext, _Linter_running, _Linter_lint;
|
|
14
|
-
class Linter {
|
|
15
|
-
constructor(include) {
|
|
16
|
-
_Linter_instances.add(this);
|
|
17
|
-
_Linter_id.set(this, void 0);
|
|
18
|
-
_Linter_wikitext.set(this, void 0);
|
|
19
|
-
_Linter_running.set(this, void 0);
|
|
20
|
-
__classPrivateFieldSet(this, _Linter_id, wikiparse.id++, "f");
|
|
21
|
-
this.include = Boolean(include);
|
|
22
|
-
}
|
|
23
|
-
queue(wikitext) {
|
|
24
|
-
var _a;
|
|
25
|
-
__classPrivateFieldSet(this, _Linter_wikitext, wikitext, "f");
|
|
26
|
-
__classPrivateFieldSet(this, _Linter_running, (_a = __classPrivateFieldGet(this, _Linter_running, "f")) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _Linter_instances, "m", _Linter_lint).call(this, wikitext), "f");
|
|
27
|
-
return __classPrivateFieldGet(this, _Linter_running, "f");
|
|
28
|
-
}
|
|
29
|
-
async codemirror(wikitext) {
|
|
30
|
-
return (await this.queue(wikitext))
|
|
31
|
-
.map(({ startIndex, endIndex, severity, message, rule, fix, suggestions = [] }) => ({
|
|
32
|
-
source: 'WikiLint',
|
|
33
|
-
from: startIndex,
|
|
34
|
-
to: endIndex,
|
|
35
|
-
severity,
|
|
36
|
-
rule,
|
|
37
|
-
message: `${message} (${rule})`,
|
|
38
|
-
actions: [
|
|
39
|
-
...fix ? [{ name: `Fix: ${fix.desc}`, fix }] : [],
|
|
40
|
-
...suggestions.map(suggestion => ({ name: `Suggestion: ${suggestion.desc}`, fix: suggestion })),
|
|
41
|
-
].map(({ name, fix: { range: [from, to], text } }) => ({
|
|
42
|
-
name,
|
|
43
|
-
apply(view) {
|
|
44
|
-
view.dispatch({ changes: { from, to, insert: text } });
|
|
45
|
-
},
|
|
46
|
-
})),
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
async monaco(wikitext) {
|
|
50
|
-
return (await this.queue(wikitext)).map(({ startLine, startCol, endLine, endCol, severity, message, rule }) => ({
|
|
51
|
-
source: `WikiLint(${rule})`,
|
|
52
|
-
startLineNumber: startLine + 1,
|
|
53
|
-
startColumn: startCol + 1,
|
|
54
|
-
endLineNumber: endLine + 1,
|
|
55
|
-
endColumn: endCol + 1,
|
|
56
|
-
severity: severity === 'error' ? 8 : 4,
|
|
57
|
-
rule,
|
|
58
|
-
message,
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
_Linter_id = new WeakMap(), _Linter_wikitext = new WeakMap(), _Linter_running = new WeakMap(), _Linter_instances = new WeakSet(), _Linter_lint = async function _Linter_lint(wikitext) {
|
|
63
|
-
const { include } = this, errors = await wikiparse.lint(wikitext, include, __classPrivateFieldGet(this, _Linter_id, "f"));
|
|
64
|
-
if (this.include === include && __classPrivateFieldGet(this, _Linter_wikitext, "f") === wikitext) {
|
|
65
|
-
__classPrivateFieldSet(this, _Linter_running, undefined, "f");
|
|
66
|
-
return errors;
|
|
67
|
-
}
|
|
68
|
-
__classPrivateFieldSet(this, _Linter_running, __classPrivateFieldGet(this, _Linter_instances, "m", _Linter_lint).call(this, __classPrivateFieldGet(this, _Linter_wikitext, "f")), "f");
|
|
69
|
-
return __classPrivateFieldGet(this, _Linter_running, "f");
|
|
70
|
-
};
|
|
71
|
-
wikiparse.Linter = Linter;
|
|
72
|
-
})();
|
package/extensions/dist/lsp.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _LanguageService_id;
|
|
14
|
-
let data;
|
|
15
|
-
class LanguageService {
|
|
16
|
-
constructor() {
|
|
17
|
-
_LanguageService_id.set(this, void 0);
|
|
18
|
-
__classPrivateFieldSet(this, _LanguageService_id, wikiparse.id++, "f");
|
|
19
|
-
data !== null && data !== void 0 ? data : (data = (async () => (await fetch(`${wikiparse.CDN}/data/signatures.json`)).json())());
|
|
20
|
-
(async () => {
|
|
21
|
-
wikiparse.provide('data', __classPrivateFieldGet(this, _LanguageService_id, "f"), await data);
|
|
22
|
-
})();
|
|
23
|
-
}
|
|
24
|
-
destroy() {
|
|
25
|
-
wikiparse.provide('destroy', __classPrivateFieldGet(this, _LanguageService_id, "f"));
|
|
26
|
-
}
|
|
27
|
-
provideColorPresentations(color) {
|
|
28
|
-
return wikiparse.provide('colorPresentations', __classPrivateFieldGet(this, _LanguageService_id, "f"), color);
|
|
29
|
-
}
|
|
30
|
-
provideDocumentColors(text) {
|
|
31
|
-
return wikiparse.provide('documentColors', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.1, text);
|
|
32
|
-
}
|
|
33
|
-
provideFoldingRanges(text) {
|
|
34
|
-
return wikiparse.provide('foldingRanges', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.2, text);
|
|
35
|
-
}
|
|
36
|
-
provideLinks(text) {
|
|
37
|
-
return wikiparse.provide('links', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.3, text);
|
|
38
|
-
}
|
|
39
|
-
provideCompletionItems(text, position) {
|
|
40
|
-
return wikiparse
|
|
41
|
-
.provide('completionItems', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.4, text, position);
|
|
42
|
-
}
|
|
43
|
-
provideReferences(text, position) {
|
|
44
|
-
return wikiparse
|
|
45
|
-
.provide('references', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.5, text, position);
|
|
46
|
-
}
|
|
47
|
-
provideDefinition(text, position) {
|
|
48
|
-
return wikiparse
|
|
49
|
-
.provide('definition', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.6, text, position);
|
|
50
|
-
}
|
|
51
|
-
resolveRenameLocation(text, position) {
|
|
52
|
-
return wikiparse.provide('renameLocation', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.7, text, position);
|
|
53
|
-
}
|
|
54
|
-
provideRenameEdits(text, position, newName) {
|
|
55
|
-
return wikiparse
|
|
56
|
-
.provide('renameEdits', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.8, text, position, newName);
|
|
57
|
-
}
|
|
58
|
-
provideDiagnostics(wikitext) {
|
|
59
|
-
return wikiparse.provide('diagnostics', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.9, wikitext);
|
|
60
|
-
}
|
|
61
|
-
provideHover(text, position) {
|
|
62
|
-
return wikiparse.provide('hover', __classPrivateFieldGet(this, _LanguageService_id, "f") + 0.05, text, position);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
_LanguageService_id = new WeakMap();
|
|
66
|
-
wikiparse.LanguageService = LanguageService;
|
|
67
|
-
})();
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
"use strict";
|
|
3
|
-
(async () => {
|
|
4
|
-
const tests = await (await fetch('./test/parserTests.json')).json(), key = 'wikiparser-node-done', dones = new Set(JSON.parse(localStorage.getItem(key))), isGH = location.hostname.endsWith('.github.io'), isIframe = self !== top, select = document.querySelector('select'), btn = document.querySelector('button'), pre = document.querySelector('pre'), container = document.getElementById('frame'), container1 = document.getElementById('frame1'), container2 = document.getElementById('frame2');
|
|
5
|
-
Parser.config = await (await fetch('./config/default.json')).json();
|
|
6
|
-
wikiparse.print = (wikitext, include, stage) => {
|
|
7
|
-
const printed = Parser.parse(wikitext, include, stage).print();
|
|
8
|
-
return Promise.resolve([[stage !== null && stage !== void 0 ? stage : Infinity, wikitext, printed]]);
|
|
9
|
-
};
|
|
10
|
-
wikiparse.highlight(pre, false, true);
|
|
11
|
-
btn.disabled = !select.value;
|
|
12
|
-
if (!isGH) {
|
|
13
|
-
btn.style.display = '';
|
|
14
|
-
}
|
|
15
|
-
let optgroup;
|
|
16
|
-
for (const [i, { desc, wikitext, html }] of tests.entries()) {
|
|
17
|
-
if (wikitext === undefined) {
|
|
18
|
-
optgroup = document.createElement('optgroup');
|
|
19
|
-
optgroup.label = desc;
|
|
20
|
-
select.append(optgroup);
|
|
21
|
-
}
|
|
22
|
-
else if ((isIframe || html !== undefined) && (isGH || !dones.has(desc))) {
|
|
23
|
-
const option = document.createElement('option');
|
|
24
|
-
option.value = String(i);
|
|
25
|
-
option.textContent = desc;
|
|
26
|
-
optgroup.append(option);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
select.addEventListener('change', () => {
|
|
30
|
-
const { wikitext, html, render, desc } = tests[Number(select.value)];
|
|
31
|
-
pre.textContent = wikitext;
|
|
32
|
-
pre.classList.remove('wikiparser');
|
|
33
|
-
container.removeAttribute('data-source');
|
|
34
|
-
if (html === undefined) {
|
|
35
|
-
container.style.display = 'none';
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
container.style.display = '';
|
|
39
|
-
container1.innerHTML = html;
|
|
40
|
-
container2.innerHTML = render !== null && render !== void 0 ? render : '';
|
|
41
|
-
}
|
|
42
|
-
wikiparse.highlight(pre, false, true);
|
|
43
|
-
select.selectedOptions[0].disabled = true;
|
|
44
|
-
btn.disabled = false;
|
|
45
|
-
history.replaceState(null, '', `#${encodeURIComponent(desc)}`);
|
|
46
|
-
dispatchEvent(new Event('casechange'));
|
|
47
|
-
});
|
|
48
|
-
btn.addEventListener('click', () => {
|
|
49
|
-
dones.add(tests[Number(select.value)].desc);
|
|
50
|
-
localStorage.setItem(key, JSON.stringify([...dones]));
|
|
51
|
-
while (select.selectedOptions[0].disabled) {
|
|
52
|
-
select.selectedIndex++;
|
|
53
|
-
}
|
|
54
|
-
select.dispatchEvent(new Event('change'));
|
|
55
|
-
});
|
|
56
|
-
container.addEventListener('click', e => {
|
|
57
|
-
e.preventDefault();
|
|
58
|
-
}, { capture: true });
|
|
59
|
-
container.addEventListener('dblclick', e => {
|
|
60
|
-
e.preventDefault();
|
|
61
|
-
if (container.dataset['source']) {
|
|
62
|
-
container.removeAttribute('data-source');
|
|
63
|
-
container1.innerHTML = container1.textContent;
|
|
64
|
-
container2.innerHTML = container2.textContent;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
container.dataset['source'] = '1';
|
|
68
|
-
const pre1 = document.createElement('pre'), pre2 = document.createElement('pre'), code1 = document.createElement('code'), code2 = document.createElement('code');
|
|
69
|
-
code1.textContent = container1.innerHTML;
|
|
70
|
-
code2.textContent = container2.innerHTML;
|
|
71
|
-
pre1.className = 'language-html';
|
|
72
|
-
pre2.className = 'language-html';
|
|
73
|
-
pre1.append(code1);
|
|
74
|
-
pre2.append(code2);
|
|
75
|
-
container1.replaceChildren(pre1);
|
|
76
|
-
container2.replaceChildren(pre2);
|
|
77
|
-
Prism.highlightAllUnder(container);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
addEventListener('hashchange', () => {
|
|
81
|
-
const hash = decodeURIComponent(location.hash.slice(1)), i = tests.findIndex(({ desc }) => desc === hash);
|
|
82
|
-
if (i !== -1) {
|
|
83
|
-
select.value = String(i);
|
|
84
|
-
select.dispatchEvent(new Event('change'));
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
dispatchEvent(new Event('hashchange'));
|
|
88
|
-
})();
|
|
89
|
-
})();
|
package/extensions/editor.css
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
.wikiparsed {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: block;
|
|
4
|
-
box-sizing: border-box;
|
|
5
|
-
width: 100%;
|
|
6
|
-
resize: vertical;
|
|
7
|
-
font-family: monospace;
|
|
8
|
-
background: none !important;
|
|
9
|
-
caret-color: #000;
|
|
10
|
-
}
|
|
11
|
-
#wikiPretty {
|
|
12
|
-
position: absolute;
|
|
13
|
-
inset: 0;
|
|
14
|
-
-webkit-user-select: none;
|
|
15
|
-
user-select: none;
|
|
16
|
-
}
|
|
17
|
-
#wikiPretty + .wikiparsed, #wikiPretty {
|
|
18
|
-
outline: none;
|
|
19
|
-
border: 1.5px solid #dedede !important;
|
|
20
|
-
border-radius: 0;
|
|
21
|
-
padding: .4em;
|
|
22
|
-
line-height: 1.4 !important;
|
|
23
|
-
font-size: inherit;
|
|
24
|
-
tab-size: 4;
|
|
25
|
-
overflow-y: auto;
|
|
26
|
-
word-break: normal;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* compromise for font-weight: bold */
|
|
30
|
-
.wpb-ext, .wpb-html,
|
|
31
|
-
.wpb-arg,
|
|
32
|
-
.wpb-template,
|
|
33
|
-
.wpb-magic-word,
|
|
34
|
-
.wpb-heading-title,
|
|
35
|
-
.wpb-table, .wpb-tr, .wpb-td,
|
|
36
|
-
.wpb-double-underscore, .wpb-hr, .wpb-quote, .wpb-list, .wpb-dd, .wpb-redirect-syntax,
|
|
37
|
-
.wpb-converter {
|
|
38
|
-
-webkit-text-stroke-width: .1ex;
|
|
39
|
-
}
|
|
40
|
-
.wpb-table-inter,
|
|
41
|
-
.wpb-hidden, .wpb-noinclude, .wpb-include, .wpb-comment, .wpb-attr-dirty,
|
|
42
|
-
.wpb-ext-attrs, .wpb-html-attrs,
|
|
43
|
-
.wpb-ext-inner,
|
|
44
|
-
.wpb-arg-default,
|
|
45
|
-
.wpb-invoke-module, .wpb-invoke-function,
|
|
46
|
-
.wpb-parameter,
|
|
47
|
-
.wpb-table-attrs,
|
|
48
|
-
.wpb-td-inner,
|
|
49
|
-
.wpb-converter-rule {
|
|
50
|
-
-webkit-text-stroke-width: 0;
|
|
51
|
-
}
|
|
52
|
-
#wikiPretty span {
|
|
53
|
-
font-weight: normal;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#wikiPretty.active span {
|
|
57
|
-
color: transparent;
|
|
58
|
-
background: none;
|
|
59
|
-
}
|
package/extensions/ui.css
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
.wikiparse-container {
|
|
2
|
-
position: relative;
|
|
3
|
-
-webkit-text-size-adjust: none;
|
|
4
|
-
}
|
|
5
|
-
.wikiparser {
|
|
6
|
-
white-space: pre-wrap;
|
|
7
|
-
overflow-wrap: break-word;
|
|
8
|
-
word-break: break-all;
|
|
9
|
-
font-family: monospace;
|
|
10
|
-
border: 1.5px solid #dedede;
|
|
11
|
-
background-color: #fff;
|
|
12
|
-
}
|
|
13
|
-
/* wikiparse.highlight或wikiparse.codejar */
|
|
14
|
-
.wikiparser.wikiparse-container {
|
|
15
|
-
padding: 4px 0;
|
|
16
|
-
overflow-y: auto;
|
|
17
|
-
}
|
|
18
|
-
.wikiparse-container > .wpb-root {
|
|
19
|
-
padding: 0 6px;
|
|
20
|
-
display: block;
|
|
21
|
-
position: relative;
|
|
22
|
-
overflow-y: hidden !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.wikiparser-line-numbers {
|
|
26
|
-
position: absolute;
|
|
27
|
-
top: 0;
|
|
28
|
-
left: 0;
|
|
29
|
-
display: inline-block;
|
|
30
|
-
background-color: #f5f5f5;
|
|
31
|
-
color: #6c6c6c;
|
|
32
|
-
border-right: 1px solid #ddd;
|
|
33
|
-
padding: 4px 0;
|
|
34
|
-
}
|
|
35
|
-
.wikiparser-line-numbers > span {
|
|
36
|
-
display: inline-block;
|
|
37
|
-
width: calc(100% - .5ch);
|
|
38
|
-
text-align: right;
|
|
39
|
-
}
|
|
40
|
-
.wikiparser-sizer {
|
|
41
|
-
position: absolute;
|
|
42
|
-
top: 0;
|
|
43
|
-
left: 0;
|
|
44
|
-
right: 0;
|
|
45
|
-
visibility: hidden;
|
|
46
|
-
z-index: -1;
|
|
47
|
-
padding: 0 6px;
|
|
48
|
-
}
|
|
49
|
-
.wpb-root[contenteditable] > .wikiparser-sizer {
|
|
50
|
-
overflow-y: scroll;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.wpb-table-inter {
|
|
54
|
-
color: #d73333;
|
|
55
|
-
font-weight: normal;
|
|
56
|
-
text-decoration: underline wavy 1px;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.wpb-hidden, .wpb-noinclude, .wpb-include, .wpb-comment, .wpb-attr-dirty {
|
|
60
|
-
color: #7b8c8f;
|
|
61
|
-
font-weight: normal;
|
|
62
|
-
font-style: italic;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.wpb-ext, .wpb-html {
|
|
66
|
-
color: #14866d;
|
|
67
|
-
font-weight: bold;
|
|
68
|
-
}
|
|
69
|
-
.wpb-ext-attrs, .wpb-html-attrs {
|
|
70
|
-
font-weight: normal;
|
|
71
|
-
}
|
|
72
|
-
.wpb-ext-attr > .wpb-attr-value, .wpb-html-attr > .wpb-attr-value {
|
|
73
|
-
color: #179b1c;
|
|
74
|
-
}
|
|
75
|
-
.wpb-ext-inner {
|
|
76
|
-
color: initial;
|
|
77
|
-
font-weight: normal;
|
|
78
|
-
background-color: rgba(0, 0, 0, .03);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.wpb-arg {
|
|
82
|
-
color: #ac6600;
|
|
83
|
-
font-weight: bold;
|
|
84
|
-
}
|
|
85
|
-
.wpb-arg-default {
|
|
86
|
-
color: #ad9300;
|
|
87
|
-
font-weight: normal;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.wpb-template {
|
|
91
|
-
color: #80c;
|
|
92
|
-
font-weight: bold;
|
|
93
|
-
background-color: rgba(119, 0, 170, .03);
|
|
94
|
-
}
|
|
95
|
-
.wpb-magic-word {
|
|
96
|
-
color: #a11;
|
|
97
|
-
font-weight: bold;
|
|
98
|
-
background-color: rgba(170, 17, 17, .03);
|
|
99
|
-
}
|
|
100
|
-
.wpb-invoke-module, .wpb-invoke-function {
|
|
101
|
-
color: #bf3e13;
|
|
102
|
-
font-weight: normal;
|
|
103
|
-
}
|
|
104
|
-
.wpb-parameter {
|
|
105
|
-
font-weight: normal;
|
|
106
|
-
}
|
|
107
|
-
.wpb-template > .wpb-parameter,
|
|
108
|
-
.wpb-invoke-function ~ .wpb-parameter {
|
|
109
|
-
color: #b0c;
|
|
110
|
-
}
|
|
111
|
-
.wpb-parameter-value {
|
|
112
|
-
color: initial;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.wpb-heading, .wpb-image-parameter {
|
|
116
|
-
color: #0076dd;
|
|
117
|
-
}
|
|
118
|
-
.wpb-heading-title {
|
|
119
|
-
color: initial;
|
|
120
|
-
font-weight: bold;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.wpb-table, .wpb-tr, .wpb-td {
|
|
124
|
-
color: #d08;
|
|
125
|
-
font-weight: bold;
|
|
126
|
-
}
|
|
127
|
-
.wpb-table-attrs {
|
|
128
|
-
font-weight: normal;
|
|
129
|
-
}
|
|
130
|
-
.wpb-table-attr > .wpb-attr-value {
|
|
131
|
-
color: #f500d4;
|
|
132
|
-
}
|
|
133
|
-
.wpb-td-inner {
|
|
134
|
-
color: initial;
|
|
135
|
-
font-weight: normal;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.wpb-double-underscore, .wpb-hr, .wpb-quote, .wpb-list, .wpb-dd, .wpb-redirect-syntax {
|
|
139
|
-
color: #0076dd;
|
|
140
|
-
font-weight: bold;
|
|
141
|
-
background-color: #eee;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.wpb-link, .wpb-category, .wpb-file, .wpb-gallery-image, .wpb-imagemap-image, .wpb-redirect-target,
|
|
145
|
-
.wpb-ext-link, .wpb-free-ext-link, .wpb-magic-link {
|
|
146
|
-
color: #000aaa;
|
|
147
|
-
background-color: rgba(34, 17, 153, .03);
|
|
148
|
-
}
|
|
149
|
-
.wpb-link-text, .wpb-image-caption, .wpb-ext-link-text {
|
|
150
|
-
color: initial;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.wpb-converter {
|
|
154
|
-
color: #b68;
|
|
155
|
-
font-weight: bold;
|
|
156
|
-
}
|
|
157
|
-
.wpb-converter-rule {
|
|
158
|
-
font-weight: normal;
|
|
159
|
-
}
|
|
160
|
-
.wpb-converter-rule-from, .wpb-converter-rule-to, .wpb-converter-noconvert {
|
|
161
|
-
color: initial;
|
|
162
|
-
}
|