wikiparser-node 1.13.1-b → 1.13.1
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/config/.schema.json +203 -0
- package/config/default.json +32 -31
- package/config/enwiki.json +829 -15
- package/config/llwiki.json +56 -21
- package/config/moegirl.json +65 -21
- package/config/zhwiki.json +498 -32
- package/dist/addon/table.js +494 -0
- package/dist/addon/token.js +392 -0
- package/dist/addon/transclude.js +184 -0
- package/dist/base.d.ts +110 -0
- package/dist/base.js +67 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +279 -0
- package/dist/internal.d.ts +47 -0
- package/dist/lib/element.d.ts +125 -0
- package/dist/lib/element.js +364 -0
- package/dist/lib/node.d.ts +173 -0
- package/dist/lib/node.js +478 -0
- package/dist/lib/range.d.ts +105 -0
- package/dist/lib/range.js +406 -0
- package/dist/lib/ranges.d.ts +28 -0
- package/dist/lib/ranges.js +126 -0
- package/dist/lib/rect.d.ts +18 -0
- package/dist/lib/rect.js +36 -0
- package/dist/lib/text.d.ts +58 -0
- package/dist/lib/text.js +414 -0
- package/dist/lib/title.d.ts +49 -0
- package/dist/lib/title.js +251 -0
- package/dist/mixin/attributesParent.d.ts +49 -0
- package/dist/mixin/attributesParent.js +80 -0
- package/dist/mixin/fixed.d.ts +5 -0
- package/dist/mixin/fixed.js +32 -0
- package/dist/mixin/flagsParent.d.ts +43 -0
- package/dist/mixin/flagsParent.js +64 -0
- package/dist/mixin/hidden.d.ts +7 -0
- package/dist/mixin/hidden.js +39 -0
- package/dist/mixin/magicLinkParent.d.ts +19 -0
- package/dist/mixin/magicLinkParent.js +43 -0
- package/dist/mixin/singleLine.d.ts +5 -0
- package/dist/mixin/singleLine.js +25 -0
- package/dist/mixin/sol.d.ts +6 -0
- package/dist/mixin/sol.js +45 -0
- package/dist/mixin/syntax.d.ts +8 -0
- package/dist/mixin/syntax.js +46 -0
- package/dist/parser/braces.js +152 -0
- package/dist/parser/commentAndExt.js +84 -0
- package/dist/parser/converter.js +41 -0
- package/dist/parser/externalLinks.js +39 -0
- package/dist/parser/hrAndDoubleUnderscore.js +44 -0
- package/dist/parser/html.js +40 -0
- package/dist/parser/links.js +103 -0
- package/dist/parser/list.js +116 -0
- package/dist/parser/magicLinks.js +55 -0
- package/dist/parser/quotes.js +69 -0
- package/dist/parser/redirect.js +28 -0
- package/dist/parser/selector.js +443 -0
- package/dist/parser/table.js +125 -0
- package/dist/src/arg.d.ts +49 -0
- package/dist/src/arg.js +220 -0
- package/dist/src/atom.d.ts +14 -0
- package/dist/src/atom.js +54 -0
- package/dist/src/attribute.d.ts +64 -0
- package/dist/src/attribute.js +482 -0
- package/dist/src/attributes.d.ts +103 -0
- package/dist/src/attributes.js +383 -0
- package/dist/src/converter.d.ts +28 -0
- package/dist/src/converter.js +153 -0
- package/dist/src/converterFlags.d.ts +80 -0
- package/dist/src/converterFlags.js +241 -0
- package/dist/src/converterRule.d.ts +71 -0
- package/dist/src/converterRule.js +218 -0
- package/dist/src/extLink.d.ts +36 -0
- package/dist/src/extLink.js +223 -0
- package/dist/src/gallery.d.ts +51 -0
- package/dist/src/gallery.js +166 -0
- package/dist/src/heading.d.ts +44 -0
- package/dist/src/heading.js +222 -0
- package/dist/src/hidden.d.ts +9 -0
- package/dist/src/hidden.js +82 -0
- package/dist/src/html.d.ts +61 -0
- package/dist/src/html.js +344 -0
- package/dist/src/imageParameter.d.ts +60 -0
- package/dist/src/imageParameter.js +262 -0
- package/dist/src/imagemap.d.ts +47 -0
- package/dist/src/imagemap.js +148 -0
- package/dist/src/imagemapLink.d.ts +35 -0
- package/dist/src/imagemapLink.js +99 -0
- package/dist/src/index.d.ts +136 -0
- package/dist/src/index.js +790 -0
- package/dist/src/link/base.d.ts +52 -0
- package/dist/src/link/base.js +258 -0
- package/dist/src/link/category.d.ts +22 -0
- package/dist/src/link/category.js +36 -0
- package/dist/src/link/file.d.ts +102 -0
- package/dist/src/link/file.js +345 -0
- package/dist/src/link/galleryImage.d.ts +29 -0
- package/dist/src/link/galleryImage.js +133 -0
- package/dist/src/link/index.d.ts +39 -0
- package/dist/src/link/index.js +100 -0
- package/dist/src/link/redirectTarget.d.ts +27 -0
- package/dist/src/link/redirectTarget.js +71 -0
- package/dist/src/magicLink.d.ts +57 -0
- package/dist/src/magicLink.js +261 -0
- package/dist/src/nested.d.ts +40 -0
- package/dist/src/nested.js +108 -0
- package/dist/src/nowiki/base.d.ts +28 -0
- package/dist/src/nowiki/base.js +90 -0
- package/dist/src/nowiki/comment.d.ts +14 -0
- package/dist/src/nowiki/comment.js +123 -0
- package/dist/src/nowiki/dd.d.ts +8 -0
- package/dist/src/nowiki/dd.js +74 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
- package/dist/src/nowiki/doubleUnderscore.js +101 -0
- package/dist/src/nowiki/hr.d.ts +5 -0
- package/dist/src/nowiki/hr.js +72 -0
- package/dist/src/nowiki/index.d.ts +14 -0
- package/dist/src/nowiki/index.js +30 -0
- package/dist/src/nowiki/list.d.ts +5 -0
- package/dist/src/nowiki/list.js +67 -0
- package/dist/src/nowiki/listBase.d.ts +23 -0
- package/dist/src/nowiki/listBase.js +100 -0
- package/dist/src/nowiki/noinclude.d.ts +6 -0
- package/dist/src/nowiki/noinclude.js +77 -0
- package/dist/src/nowiki/quote.d.ts +14 -0
- package/dist/src/nowiki/quote.js +149 -0
- package/dist/src/onlyinclude.d.ts +13 -0
- package/dist/src/onlyinclude.js +60 -0
- package/dist/src/paramTag/index.d.ts +28 -0
- package/dist/src/paramTag/index.js +80 -0
- package/dist/src/paramTag/inputbox.d.ts +8 -0
- package/dist/src/paramTag/inputbox.js +38 -0
- package/dist/src/parameter.d.ts +60 -0
- package/dist/src/parameter.js +267 -0
- package/dist/src/pre.d.ts +28 -0
- package/dist/src/pre.js +70 -0
- package/dist/src/redirect.d.ts +30 -0
- package/dist/src/redirect.js +128 -0
- package/dist/src/syntax.d.ts +15 -0
- package/dist/src/syntax.js +87 -0
- package/dist/src/table/base.d.ts +28 -0
- package/dist/src/table/base.js +81 -0
- package/dist/src/table/index.d.ts +230 -0
- package/dist/src/table/index.js +506 -0
- package/dist/src/table/td.d.ts +72 -0
- package/dist/src/table/td.js +375 -0
- package/dist/src/table/tr.d.ts +30 -0
- package/dist/src/table/tr.js +61 -0
- package/dist/src/table/trBase.d.ts +49 -0
- package/dist/src/table/trBase.js +165 -0
- package/dist/src/tagPair/ext.d.ts +29 -0
- package/dist/src/tagPair/ext.js +229 -0
- package/dist/src/tagPair/include.d.ts +33 -0
- package/dist/src/tagPair/include.js +145 -0
- package/dist/src/tagPair/index.d.ts +23 -0
- package/dist/src/tagPair/index.js +130 -0
- package/dist/src/transclude.d.ts +159 -0
- package/dist/src/transclude.js +598 -0
- package/dist/util/constants.js +26 -0
- package/dist/util/debug.js +95 -0
- package/dist/util/diff.js +83 -0
- package/dist/util/html.js +146 -0
- package/dist/util/lint.js +32 -0
- package/dist/util/string.js +107 -0
- package/errors/README +3 -0
- package/package.json +21 -28
- package/printed/README +3 -0
- package/bundle/bundle.min.js +0 -37
- package/extensions/dist/base.js +0 -163
- package/extensions/dist/codejar.js +0 -53
- package/extensions/dist/editor.js +0 -159
- package/extensions/dist/highlight.js +0 -30
- package/extensions/dist/lint.js +0 -72
- 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: [rootNode] } = __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 = [...rootNode.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 = window.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 }] : [],
|
|
40
|
-
...suggestions.map(suggestion => ({ name: 'suggestion', 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/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
|
-
}
|