wikiparser-node 1.4.2 → 1.4.3
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/dist/addon/table.js +5 -1
- package/dist/base.d.ts +6 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -3
- package/dist/lib/element.d.ts +3 -2
- package/dist/lib/element.js +20 -13
- package/dist/lib/node.js +13 -10
- package/dist/lib/text.js +3 -3
- package/dist/lib/title.js +4 -12
- package/dist/mixin/attributesParent.d.ts +32 -2
- package/dist/mixin/attributesParent.js +14 -25
- package/dist/mixin/fixed.d.ts +2 -1
- package/dist/mixin/fixed.js +3 -1
- package/dist/mixin/flagsParent.d.ts +28 -17
- package/dist/mixin/flagsParent.js +12 -25
- package/dist/mixin/magicLinkParent.d.ts +14 -8
- package/dist/mixin/magicLinkParent.js +7 -8
- package/dist/mixin/singleLine.d.ts +2 -1
- package/dist/mixin/singleLine.js +3 -2
- package/dist/mixin/sol.d.ts +2 -4
- package/dist/mixin/sol.js +8 -6
- package/dist/mixin/syntax.d.ts +5 -2
- package/dist/mixin/syntax.js +14 -18
- package/dist/parser/links.js +1 -3
- package/dist/src/arg.d.ts +4 -4
- package/dist/src/arg.js +4 -4
- package/dist/src/attribute.d.ts +9 -7
- package/dist/src/attribute.js +271 -218
- package/dist/src/attributes.d.ts +3 -3
- package/dist/src/attributes.js +0 -1
- package/dist/src/converter.d.ts +7 -2
- package/dist/src/converter.js +113 -64
- package/dist/src/converterFlags.d.ts +5 -5
- package/dist/src/converterFlags.js +0 -1
- package/dist/src/converterRule.d.ts +5 -5
- package/dist/src/converterRule.js +0 -1
- package/dist/src/extLink.d.ts +7 -2
- package/dist/src/extLink.js +159 -110
- package/dist/src/gallery.d.ts +5 -5
- package/dist/src/gallery.js +0 -1
- package/dist/src/heading.d.ts +8 -8
- package/dist/src/heading.js +172 -125
- package/dist/src/html.d.ts +8 -5
- package/dist/src/html.js +263 -214
- package/dist/src/imageParameter.d.ts +2 -2
- package/dist/src/imageParameter.js +1 -0
- package/dist/src/imagemap.d.ts +5 -5
- package/dist/src/imagemap.js +4 -10
- package/dist/src/imagemapLink.d.ts +7 -4
- package/dist/src/imagemapLink.js +75 -26
- package/dist/src/index.js +3 -4
- package/dist/src/link/base.d.ts +2 -2
- package/dist/src/link/base.js +1 -4
- package/dist/src/link/file.d.ts +1 -1
- package/dist/src/link/file.js +0 -1
- package/dist/src/link/galleryImage.d.ts +2 -1
- package/dist/src/link/galleryImage.js +136 -88
- package/dist/src/link/index.js +0 -1
- package/dist/src/magicLink.d.ts +11 -3
- package/dist/src/magicLink.js +170 -120
- package/dist/src/nested.d.ts +5 -5
- package/dist/src/nested.js +1 -0
- package/dist/src/nowiki/base.d.ts +6 -2
- package/dist/src/nowiki/base.js +79 -28
- package/dist/src/nowiki/comment.d.ts +0 -2
- package/dist/src/nowiki/comment.js +0 -9
- package/dist/src/nowiki/doubleUnderscore.js +88 -38
- package/dist/src/nowiki/hr.d.ts +1 -4
- package/dist/src/nowiki/hr.js +53 -4
- package/dist/src/nowiki/index.d.ts +2 -2
- package/dist/src/nowiki/index.js +1 -0
- package/dist/src/nowiki/list.d.ts +1 -4
- package/dist/src/nowiki/list.js +88 -39
- package/dist/src/nowiki/listBase.d.ts +1 -1
- package/dist/src/nowiki/listBase.js +52 -2
- package/dist/src/nowiki/quote.d.ts +3 -3
- package/dist/src/nowiki/quote.js +102 -54
- package/dist/src/paramTag/index.d.ts +5 -5
- package/dist/src/paramTag/index.js +2 -1
- package/dist/src/parameter.d.ts +11 -8
- package/dist/src/parameter.js +225 -176
- package/dist/src/pre.d.ts +5 -5
- package/dist/src/pre.js +1 -0
- package/dist/src/syntax.d.ts +6 -0
- package/dist/src/syntax.js +74 -23
- package/dist/src/table/base.d.ts +6 -3
- package/dist/src/table/base.js +100 -49
- package/dist/src/table/index.d.ts +6 -3
- package/dist/src/table/index.js +5 -9
- package/dist/src/table/td.d.ts +9 -5
- package/dist/src/table/td.js +270 -217
- package/dist/src/table/tr.d.ts +4 -4
- package/dist/src/table/tr.js +1 -0
- package/dist/src/tagPair/ext.d.ts +6 -3
- package/dist/src/tagPair/ext.js +168 -118
- package/dist/src/tagPair/include.d.ts +2 -4
- package/dist/src/tagPair/include.js +0 -8
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/index.js +115 -66
- package/dist/src/transclude.d.ts +3 -3
- package/dist/src/transclude.js +4 -9
- package/dist/util/debug.js +0 -2
- package/package.json +3 -3
package/dist/src/imagemapLink.js
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.ImagemapLinkToken = void 0;
|
|
4
38
|
const constants_1 = require("../util/constants");
|
|
@@ -13,32 +47,47 @@ const extLink_1 = require("./extLink");
|
|
|
13
47
|
* `<imagemap>`内的链接
|
|
14
48
|
* @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
|
|
15
49
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
let ImagemapLinkToken = (() => {
|
|
51
|
+
let _classDecorators = [fixed_1.fixedToken, singleLine_1.singleLine];
|
|
52
|
+
let _classDescriptor;
|
|
53
|
+
let _classExtraInitializers = [];
|
|
54
|
+
let _classThis;
|
|
55
|
+
let _classSuper = index_2.Token;
|
|
56
|
+
var ImagemapLinkToken = class extends _classSuper {
|
|
57
|
+
static { _classThis = this; }
|
|
58
|
+
static {
|
|
59
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
60
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
61
|
+
ImagemapLinkToken = _classThis = _classDescriptor.value;
|
|
62
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
63
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
64
|
+
}
|
|
65
|
+
type = 'imagemap-link';
|
|
66
|
+
/** 内外链接 */
|
|
67
|
+
get link() {
|
|
68
|
+
return this.childNodes[1].link;
|
|
69
|
+
}
|
|
70
|
+
set link(link) {
|
|
71
|
+
this.childNodes[1].link = link;
|
|
72
|
+
}
|
|
73
|
+
/* NOT FOR BROWSER END */
|
|
74
|
+
/**
|
|
75
|
+
* @param pre 链接前的文本
|
|
76
|
+
* @param linkStuff 内外链接
|
|
77
|
+
* @param post 链接后的文本
|
|
78
|
+
*/
|
|
79
|
+
constructor(pre, linkStuff, post, config = index_1.default.getConfig(), accum = []) {
|
|
80
|
+
super(undefined, config, accum);
|
|
81
|
+
this.append(pre, linkStuff.length === 2
|
|
82
|
+
// @ts-expect-error abstract class
|
|
83
|
+
? new index_3.LinkToken(...linkStuff, config, accum)
|
|
84
|
+
// @ts-expect-error abstract class
|
|
85
|
+
: new extLink_1.ExtLinkToken(...linkStuff, config, accum),
|
|
37
86
|
// @ts-expect-error abstract class
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
87
|
+
new noinclude_1.NoincludeToken(post, config, accum));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return ImagemapLinkToken = _classThis;
|
|
91
|
+
})();
|
|
43
92
|
exports.ImagemapLinkToken = ImagemapLinkToken;
|
|
44
93
|
constants_1.classes['ImagemapLinkToken'] = __filename;
|
package/dist/src/index.js
CHANGED
|
@@ -86,10 +86,9 @@ class Token extends element_1.AstElement {
|
|
|
86
86
|
}
|
|
87
87
|
this.#config = config;
|
|
88
88
|
this.#accum = accum;
|
|
89
|
+
accum.push(this);
|
|
89
90
|
/* NOT FOR BROWSER */
|
|
90
91
|
this.setAttribute('acceptable', acceptable);
|
|
91
|
-
/* NOT FOR BROWSER END */
|
|
92
|
-
accum.push(this);
|
|
93
92
|
}
|
|
94
93
|
/** @private */
|
|
95
94
|
parseOnce(n = this.#stage, include = false) {
|
|
@@ -302,8 +301,6 @@ class Token extends element_1.AstElement {
|
|
|
302
301
|
return (this.constructor === Token);
|
|
303
302
|
case 'config':
|
|
304
303
|
return structuredClone(this.#config);
|
|
305
|
-
case 'accum':
|
|
306
|
-
return this.#accum;
|
|
307
304
|
case 'include': {
|
|
308
305
|
if (this.#include !== undefined) {
|
|
309
306
|
return this.#include;
|
|
@@ -311,6 +308,8 @@ class Token extends element_1.AstElement {
|
|
|
311
308
|
const root = this.getRootNode();
|
|
312
309
|
return (root !== this && root.getAttribute('include'));
|
|
313
310
|
}
|
|
311
|
+
case 'accum':
|
|
312
|
+
return this.#accum;
|
|
314
313
|
/* NOT FOR BROWSER */
|
|
315
314
|
case 'stage':
|
|
316
315
|
return this.#stage;
|
package/dist/src/link/base.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ export declare abstract class LinkBaseToken extends Token {
|
|
|
12
12
|
type: 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image';
|
|
13
13
|
readonly name: string;
|
|
14
14
|
readonly childNodes: readonly [AtomToken, ...Token[]];
|
|
15
|
-
abstract get children(): [AtomToken, ...Token[]];
|
|
16
15
|
abstract get firstChild(): AtomToken;
|
|
17
|
-
abstract get firstElementChild(): AtomToken;
|
|
18
16
|
abstract get lastChild(): Token;
|
|
17
|
+
abstract get children(): [AtomToken, ...Token[]];
|
|
18
|
+
abstract get firstElementChild(): AtomToken;
|
|
19
19
|
abstract get lastElementChild(): Token;
|
|
20
20
|
/** 完整链接 */
|
|
21
21
|
get link(): string | Title;
|
package/dist/src/link/base.js
CHANGED
|
@@ -16,7 +16,6 @@ class LinkBaseToken extends index_2.Token {
|
|
|
16
16
|
#bracket = true;
|
|
17
17
|
#delimiter;
|
|
18
18
|
#title;
|
|
19
|
-
/* NOT FOR BROWSER */
|
|
20
19
|
/** 完整链接 */
|
|
21
20
|
get link() {
|
|
22
21
|
return this.#title;
|
|
@@ -61,13 +60,11 @@ class LinkBaseToken extends index_2.Token {
|
|
|
61
60
|
/** @private */
|
|
62
61
|
afterBuild() {
|
|
63
62
|
this.#title = this.getTitle();
|
|
64
|
-
/* NOT FOR BROWSER */
|
|
65
|
-
this.setAttribute('name', this.#title.title);
|
|
66
|
-
/* NOT FOR BROWSER END */
|
|
67
63
|
if (this.#delimiter.includes('\0')) {
|
|
68
64
|
this.#delimiter = this.buildFromStr(this.#delimiter, constants_1.BuildMethod.String);
|
|
69
65
|
}
|
|
70
66
|
/* NOT FOR BROWSER */
|
|
67
|
+
this.setAttribute('name', this.#title.title);
|
|
71
68
|
const /** @implements */ linkListener = (e, data) => {
|
|
72
69
|
const { prevTarget } = e;
|
|
73
70
|
if (prevTarget?.type === 'link-target') {
|
package/dist/src/link/file.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare abstract class FileToken extends LinkBaseToken {
|
|
|
12
12
|
#private;
|
|
13
13
|
readonly type: 'file' | 'gallery-image' | 'imagemap-image';
|
|
14
14
|
readonly childNodes: readonly [AtomToken, ...ImageParameterToken[]];
|
|
15
|
-
abstract get children(): [AtomToken, ...ImageParameterToken[]];
|
|
16
15
|
abstract get lastChild(): AtomToken | ImageParameterToken;
|
|
16
|
+
abstract get children(): [AtomToken, ...ImageParameterToken[]];
|
|
17
17
|
abstract get lastElementChild(): AtomToken | ImageParameterToken;
|
|
18
18
|
/** 图片链接 */
|
|
19
19
|
get link(): string | Title;
|
package/dist/src/link/file.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import Parser from '../../index';
|
|
2
2
|
import { Token } from '../index';
|
|
3
|
+
import { FileToken } from './file';
|
|
3
4
|
import type { Title } from '../../lib/title';
|
|
4
5
|
import type { LintError } from '../../base';
|
|
5
6
|
import type { AtomToken, ImageParameterToken } from '../../internal';
|
|
6
7
|
declare type GalleryTypes = 'gallery' | 'imagemap';
|
|
7
|
-
|
|
8
|
+
/** 图库图片 */
|
|
8
9
|
export declare abstract class GalleryImageToken extends FileToken {
|
|
9
10
|
#private;
|
|
10
11
|
type: `${GalleryTypes}-image`;
|
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.GalleryImageToken = void 0;
|
|
4
38
|
const lint_1 = require("../../util/lint");
|
|
@@ -10,100 +44,114 @@ const index_2 = require("../index");
|
|
|
10
44
|
const file_1 = require("./file");
|
|
11
45
|
const imageParameter_1 = require("../imageParameter");
|
|
12
46
|
/** 图库图片 */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @param link 图片文件名
|
|
28
|
-
* @param text 图片参数
|
|
29
|
-
*/
|
|
30
|
-
constructor(type, link, text, config = index_1.default.getConfig(), accum = []) {
|
|
31
|
-
let token;
|
|
32
|
-
if (text !== undefined) {
|
|
33
|
-
token = new index_2.Token(text, config, accum);
|
|
34
|
-
token.type = 'plain';
|
|
35
|
-
for (let n = 1; n < constants_1.MAX_STAGE; n++) {
|
|
36
|
-
token.parseOnce();
|
|
37
|
-
}
|
|
38
|
-
accum.splice(accum.indexOf(token), 1);
|
|
47
|
+
let GalleryImageToken = (() => {
|
|
48
|
+
let _classDecorators = [singleLine_1.singleLine];
|
|
49
|
+
let _classDescriptor;
|
|
50
|
+
let _classExtraInitializers = [];
|
|
51
|
+
let _classThis;
|
|
52
|
+
let _classSuper = file_1.FileToken;
|
|
53
|
+
var GalleryImageToken = class extends _classSuper {
|
|
54
|
+
static { _classThis = this; }
|
|
55
|
+
static {
|
|
56
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
57
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
58
|
+
GalleryImageToken = _classThis = _classDescriptor.value;
|
|
59
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
60
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
39
61
|
}
|
|
40
|
-
super(link, token?.toString(), config, accum);
|
|
41
|
-
this.setAttribute('bracket', false);
|
|
42
|
-
this.type = `${type}-image`;
|
|
43
|
-
}
|
|
44
|
-
/** @private */
|
|
45
|
-
getTitle() {
|
|
46
|
-
const imagemap = this.type === 'imagemap-image';
|
|
47
|
-
return this.normalizeTitle(String(this.firstChild), imagemap ? 0 : 6, true, !imagemap);
|
|
48
|
-
}
|
|
49
|
-
/** @private */
|
|
50
|
-
getAttribute(key) {
|
|
51
|
-
return key === 'padding' ? 0 : super.getAttribute(key);
|
|
52
|
-
}
|
|
53
|
-
/** @override */
|
|
54
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
55
|
-
const errors = super.lint(start), { ns,
|
|
56
62
|
/* NOT FOR BROWSER */
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/** 图片链接 */
|
|
64
|
+
get link() {
|
|
65
|
+
return this.type === 'imagemap-image' ? '' : super.link;
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const name = String(prevTarget), title = this.getTitle(), { interwiki, ns, valid } = title;
|
|
80
|
-
if (!valid) {
|
|
81
|
-
(0, debug_1.undo)(e, data);
|
|
82
|
-
throw new Error(`非法的图片文件名:${name}`);
|
|
67
|
+
set link(value) {
|
|
68
|
+
if (this.type !== 'imagemap-image') {
|
|
69
|
+
super.link = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/* NOT FOR BROWSER END */
|
|
73
|
+
/**
|
|
74
|
+
* @param type 图片类型
|
|
75
|
+
* @param link 图片文件名
|
|
76
|
+
* @param text 图片参数
|
|
77
|
+
*/
|
|
78
|
+
constructor(type, link, text, config = index_1.default.getConfig(), accum = []) {
|
|
79
|
+
let token;
|
|
80
|
+
if (text !== undefined) {
|
|
81
|
+
token = new index_2.Token(text, config, accum);
|
|
82
|
+
token.type = 'plain';
|
|
83
|
+
for (let n = 1; n < constants_1.MAX_STAGE; n++) {
|
|
84
|
+
token.parseOnce();
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
accum.splice(accum.indexOf(token), 1);
|
|
87
|
+
}
|
|
88
|
+
super(link, token?.toString(), config, accum);
|
|
89
|
+
this.setAttribute('bracket', false);
|
|
90
|
+
this.type = `${type}-image`;
|
|
91
|
+
}
|
|
92
|
+
/** @private */
|
|
93
|
+
getTitle() {
|
|
94
|
+
const imagemap = this.type === 'imagemap-image';
|
|
95
|
+
return this.normalizeTitle(String(this.firstChild), imagemap ? 0 : 6, true, !imagemap);
|
|
96
|
+
}
|
|
97
|
+
/** @private */
|
|
98
|
+
getAttribute(key) {
|
|
99
|
+
return key === 'padding' ? 0 : super.getAttribute(key);
|
|
100
|
+
}
|
|
101
|
+
/** @override */
|
|
102
|
+
lint(start = this.getAbsoluteIndex()) {
|
|
103
|
+
const errors = super.lint(start), { ns, interwiki } = this.getAttribute('title');
|
|
104
|
+
if (interwiki || ns !== 6) {
|
|
105
|
+
errors.push((0, lint_1.generateForSelf)(this, { start }, 'invalid gallery image'));
|
|
106
|
+
}
|
|
107
|
+
return errors;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 设置`#title`
|
|
111
|
+
* @param title Title对象
|
|
112
|
+
*/
|
|
113
|
+
#setName(title) {
|
|
114
|
+
this.setAttribute('title', title);
|
|
115
|
+
/* NOT FOR BROWSER */
|
|
116
|
+
this.setAttribute('name', title.title);
|
|
117
|
+
}
|
|
118
|
+
/** @private */
|
|
119
|
+
afterBuild() {
|
|
120
|
+
this.#setName(this.getTitle());
|
|
121
|
+
/* NOT FOR BROWSER */
|
|
122
|
+
const /** @implements */ linkListener = (e, data) => {
|
|
123
|
+
const { prevTarget } = e;
|
|
124
|
+
if (prevTarget?.type === 'link-target') {
|
|
125
|
+
const name = String(prevTarget), title = this.getTitle(), { interwiki, ns, valid } = title;
|
|
126
|
+
if (!valid) {
|
|
127
|
+
(0, debug_1.undo)(e, data);
|
|
128
|
+
throw new Error(`非法的图片文件名:${name}`);
|
|
129
|
+
}
|
|
130
|
+
else if (interwiki || ns !== 6) {
|
|
131
|
+
(0, debug_1.undo)(e, data);
|
|
132
|
+
throw new Error(`图片链接不可更改命名空间:${name}`);
|
|
133
|
+
}
|
|
134
|
+
this.#setName(title);
|
|
87
135
|
}
|
|
88
|
-
|
|
136
|
+
};
|
|
137
|
+
this.addEventListener(['remove', 'insert', 'replace', 'text'], linkListener);
|
|
138
|
+
}
|
|
139
|
+
/* NOT FOR BROWSER */
|
|
140
|
+
/**
|
|
141
|
+
* @override
|
|
142
|
+
* @param token 待插入的子节点
|
|
143
|
+
* @param i 插入位置
|
|
144
|
+
* @throws `RangeError` 不可插入多余子节点
|
|
145
|
+
* @throws `TypeError` 不可插入文本节点
|
|
146
|
+
*/
|
|
147
|
+
insertAt(child, i) {
|
|
148
|
+
if (this.type === 'gallery-image' && child.type === 'image-parameter' && !imageParameter_1.galleryParams.has(child.name)) {
|
|
149
|
+
child.setAttribute('name', 'invalid');
|
|
89
150
|
}
|
|
90
|
-
|
|
91
|
-
this.addEventListener(['remove', 'insert', 'replace', 'text'], linkListener);
|
|
92
|
-
}
|
|
93
|
-
/* NOT FOR BROWSER */
|
|
94
|
-
/**
|
|
95
|
-
* @override
|
|
96
|
-
* @param token 待插入的子节点
|
|
97
|
-
* @param i 插入位置
|
|
98
|
-
* @throws `RangeError` 不可插入多余子节点
|
|
99
|
-
* @throws `TypeError` 不可插入文本节点
|
|
100
|
-
*/
|
|
101
|
-
insertAt(child, i) {
|
|
102
|
-
if (this.type === 'gallery-image' && child.type === 'image-parameter' && !imageParameter_1.galleryParams.has(child.name)) {
|
|
103
|
-
child.setAttribute('name', 'invalid');
|
|
151
|
+
return super.insertAt(child, i);
|
|
104
152
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
153
|
+
};
|
|
154
|
+
return GalleryImageToken = _classThis;
|
|
155
|
+
})();
|
|
108
156
|
exports.GalleryImageToken = GalleryImageToken;
|
|
109
157
|
constants_1.classes['GalleryImageToken'] = __filename;
|
package/dist/src/link/index.js
CHANGED
|
@@ -10,7 +10,6 @@ const base_1 = require("./base");
|
|
|
10
10
|
*/
|
|
11
11
|
class LinkToken extends base_1.LinkBaseToken {
|
|
12
12
|
type = 'link';
|
|
13
|
-
/* NOT FOR BROWSER */
|
|
14
13
|
/** 链接显示文字 */
|
|
15
14
|
get innerText() {
|
|
16
15
|
return this.length > 1 ? this.lastChild.text() : this.firstChild.text().replace(/^\s*:/u, '');
|
package/dist/src/magicLink.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import Parser from '../index';
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import type { LintError } from '../base';
|
|
4
|
+
import type { SyntaxBase } from '../mixin/syntax';
|
|
4
5
|
import type { AstText, CommentToken, IncludeToken, NoincludeToken, TranscludeToken, AstNodes } from '../internal';
|
|
6
|
+
/** NOT FOR BROWSER */
|
|
7
|
+
export interface MagicLinkToken extends SyntaxBase {
|
|
8
|
+
}
|
|
9
|
+
/** NOT FOR BROWSER END */
|
|
10
|
+
/**
|
|
11
|
+
* 自由外链
|
|
12
|
+
* @classdesc `{childNodes: ...AstText|CommentToken|IncludeToken|NoincludeToken}`
|
|
13
|
+
*/
|
|
5
14
|
export declare abstract class MagicLinkToken extends Token {
|
|
6
15
|
type: 'free-ext-link' | 'ext-link-url';
|
|
7
16
|
readonly childNodes: readonly (AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken)[];
|
|
8
|
-
abstract get children(): (CommentToken | IncludeToken | NoincludeToken | TranscludeToken)[];
|
|
9
17
|
abstract get firstChild(): AstText | TranscludeToken;
|
|
10
|
-
abstract get firstElementChild(): CommentToken | IncludeToken | NoincludeToken | TranscludeToken | undefined;
|
|
11
18
|
abstract get lastChild(): AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken;
|
|
19
|
+
abstract get children(): (CommentToken | IncludeToken | NoincludeToken | TranscludeToken)[];
|
|
20
|
+
abstract get firstElementChild(): CommentToken | IncludeToken | NoincludeToken | TranscludeToken | undefined;
|
|
12
21
|
abstract get lastElementChild(): CommentToken | IncludeToken | NoincludeToken | TranscludeToken | undefined;
|
|
13
22
|
/** 协议 */
|
|
14
23
|
get protocol(): string | undefined;
|
|
@@ -48,4 +57,3 @@ export declare abstract class MagicLinkToken extends Token {
|
|
|
48
57
|
/** 转义 `=` */
|
|
49
58
|
escape(): void;
|
|
50
59
|
}
|
|
51
|
-
export {};
|