@limetech/lime-elements 38.13.2-dev.1 → 38.13.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/CHANGELOG.md +17 -2
- package/dist/cjs/limel-ai-avatar.cjs.entry.js +1 -1
- package/dist/cjs/limel-ai-avatar.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-markdown.cjs.entry.js +1 -1
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +169 -62
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
- package/dist/cjs/{markdown-parser-564adb69.js → markdown-parser-563c73db.js} +144 -386
- package/dist/cjs/{markdown-parser-564adb69.js.map → markdown-parser-563c73db.js.map} +1 -1
- package/dist/collection/components/ai-avatar/ai-avatar.css +9 -14
- package/dist/collection/components/markdown/link-markdown-plugin.js +30 -0
- package/dist/collection/components/markdown/link-markdown-plugin.js.map +1 -0
- package/dist/collection/components/markdown/markdown-parser.js +4 -4
- package/dist/collection/components/markdown/markdown-parser.js.map +1 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-commands.js +3 -42
- package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-commands.js.map +1 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link/link-mark-spec.js +33 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link/link-mark-spec.js.map +1 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/{link-plugin.js → link/link-plugin.js} +135 -22
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link/link-plugin.js.map +1 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link/utils.js +39 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link/utils.js.map +1 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +3 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js.map +1 -1
- package/dist/esm/limel-ai-avatar.entry.js +1 -1
- package/dist/esm/limel-ai-avatar.entry.js.map +1 -1
- package/dist/esm/limel-markdown.entry.js +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js +169 -62
- package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
- package/dist/esm/{markdown-parser-1c1fdedc.js → markdown-parser-41d15994.js} +144 -387
- package/dist/esm/markdown-parser-41d15994.js.map +1 -0
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-6b5d588e.entry.js +2 -0
- package/dist/lime-elements/p-6b5d588e.entry.js.map +1 -0
- package/dist/lime-elements/{p-ce152b39.entry.js → p-895ae176.entry.js} +2 -2
- package/dist/lime-elements/p-95a71e89.js +8 -0
- package/dist/lime-elements/p-95a71e89.js.map +1 -0
- package/dist/lime-elements/p-f15163c0.entry.js +2 -0
- package/dist/lime-elements/p-f15163c0.entry.js.map +1 -0
- package/dist/types/components/markdown/link-markdown-plugin.d.ts +9 -0
- package/dist/types/components/text-editor/prosemirror-adapter/menu/menu-commands.d.ts +0 -2
- package/dist/types/components/text-editor/prosemirror-adapter/plugins/link/link-mark-spec.d.ts +10 -0
- package/dist/types/components/text-editor/prosemirror-adapter/plugins/link/utils.d.ts +3 -0
- package/package.json +1 -2
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link-plugin.js.map +0 -1
- package/dist/esm/markdown-parser-1c1fdedc.js.map +0 -1
- package/dist/lime-elements/p-98478c6d.entry.js +0 -2
- package/dist/lime-elements/p-98478c6d.entry.js.map +0 -1
- package/dist/lime-elements/p-cf87519f.js +0 -8
- package/dist/lime-elements/p-cf87519f.js.map +0 -1
- package/dist/lime-elements/p-d5ac8f59.entry.js +0 -2
- package/dist/lime-elements/p-d5ac8f59.entry.js.map +0 -1
- /package/dist/lime-elements/{p-ce152b39.entry.js.map → p-895ae176.entry.js.map} +0 -0
- /package/dist/types/components/text-editor/prosemirror-adapter/plugins/{link-plugin.d.ts → link/link-plugin.d.ts} +0 -0
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
const _commonjsHelpers = require('./_commonjsHelpers-a5111d61.js');
|
|
4
4
|
|
|
5
|
+
function getLinkAttributes(url, title) {
|
|
6
|
+
if (isExternalUrl(url)) {
|
|
7
|
+
return {
|
|
8
|
+
href: url,
|
|
9
|
+
title: title,
|
|
10
|
+
target: '_blank',
|
|
11
|
+
rel: 'noopener noreferrer',
|
|
12
|
+
referrerpolicy: 'noreferrer',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
href: url,
|
|
17
|
+
title: title,
|
|
18
|
+
target: null,
|
|
19
|
+
rel: null,
|
|
20
|
+
referrerpolicy: null,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function isExternalUrl(url) {
|
|
24
|
+
try {
|
|
25
|
+
let urlObj;
|
|
26
|
+
if (isProtocolRelativeUrl(url)) {
|
|
27
|
+
urlObj = new URL(window.location.protocol + url);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
urlObj = new URL(url, window.location.origin);
|
|
31
|
+
}
|
|
32
|
+
return (urlObj.protocol.startsWith('http') &&
|
|
33
|
+
urlObj.hostname !== window.location.hostname);
|
|
34
|
+
}
|
|
35
|
+
catch (_a) {
|
|
36
|
+
// Malformed URLs → internal
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function isProtocolRelativeUrl(url) {
|
|
41
|
+
return url.startsWith('//');
|
|
42
|
+
}
|
|
43
|
+
|
|
5
44
|
// Generated using scripts/write-decode-map.ts
|
|
6
45
|
const htmlDecodeTree = new Uint16Array(
|
|
7
46
|
// prettier-ignore
|
|
@@ -3333,7 +3372,7 @@ function isUint8Array$1(value) {
|
|
|
3333
3372
|
*/
|
|
3334
3373
|
|
|
3335
3374
|
/** @type {Options} */
|
|
3336
|
-
const emptyOptions$
|
|
3375
|
+
const emptyOptions$7 = {};
|
|
3337
3376
|
|
|
3338
3377
|
/**
|
|
3339
3378
|
* Get the text content of a node or list of nodes.
|
|
@@ -3349,7 +3388,7 @@ const emptyOptions$8 = {};
|
|
|
3349
3388
|
* Serialized `value`.
|
|
3350
3389
|
*/
|
|
3351
3390
|
function toString$3(value, options) {
|
|
3352
|
-
const settings = options || emptyOptions$
|
|
3391
|
+
const settings = options || emptyOptions$7;
|
|
3353
3392
|
const includeImageAlt =
|
|
3354
3393
|
typeof settings.includeImageAlt === 'boolean'
|
|
3355
3394
|
? settings.includeImageAlt
|
|
@@ -13956,16 +13995,16 @@ const disable = {
|
|
|
13956
13995
|
};
|
|
13957
13996
|
|
|
13958
13997
|
const defaultConstructs = /*#__PURE__*/Object.freeze({
|
|
13959
|
-
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13998
|
+
__proto__: null,
|
|
13999
|
+
document: document,
|
|
14000
|
+
contentInitial: contentInitial,
|
|
14001
|
+
flowInitial: flowInitial,
|
|
14002
|
+
flow: flow,
|
|
14003
|
+
string: string,
|
|
14004
|
+
text: text$8,
|
|
14005
|
+
insideSpan: insideSpan,
|
|
14006
|
+
attentionMarkers: attentionMarkers,
|
|
14007
|
+
disable: disable
|
|
13969
14008
|
});
|
|
13970
14009
|
|
|
13971
14010
|
/**
|
|
@@ -13980,7 +14019,7 @@ const defaultConstructs = /*#__PURE__*/Object.freeze({
|
|
|
13980
14019
|
* @param {ParseOptions | null | undefined} [options]
|
|
13981
14020
|
* @returns {ParseContext}
|
|
13982
14021
|
*/
|
|
13983
|
-
function parse$
|
|
14022
|
+
function parse$6(options) {
|
|
13984
14023
|
const settings = options || {};
|
|
13985
14024
|
const constructs =
|
|
13986
14025
|
/** @type {FullNormalizedExtension} */
|
|
@@ -14332,7 +14371,7 @@ function fromMarkdown(value, encoding, options) {
|
|
|
14332
14371
|
}
|
|
14333
14372
|
return compiler(options)(
|
|
14334
14373
|
postprocess(
|
|
14335
|
-
parse$
|
|
14374
|
+
parse$6(options).document().write(preprocess()(value, encoding, true))
|
|
14336
14375
|
)
|
|
14337
14376
|
)
|
|
14338
14377
|
}
|
|
@@ -17236,11 +17275,11 @@ const convert =
|
|
|
17236
17275
|
}
|
|
17237
17276
|
|
|
17238
17277
|
if (typeof test === 'function') {
|
|
17239
|
-
return castFactory
|
|
17278
|
+
return castFactory(test)
|
|
17240
17279
|
}
|
|
17241
17280
|
|
|
17242
17281
|
if (typeof test === 'object') {
|
|
17243
|
-
return Array.isArray(test) ? anyFactory
|
|
17282
|
+
return Array.isArray(test) ? anyFactory(test) : propsFactory(test)
|
|
17244
17283
|
}
|
|
17245
17284
|
|
|
17246
17285
|
if (typeof test === 'string') {
|
|
@@ -17255,7 +17294,7 @@ const convert =
|
|
|
17255
17294
|
* @param {Array<Props | TestFunction | string>} tests
|
|
17256
17295
|
* @returns {Check}
|
|
17257
17296
|
*/
|
|
17258
|
-
function anyFactory
|
|
17297
|
+
function anyFactory(tests) {
|
|
17259
17298
|
/** @type {Array<Check>} */
|
|
17260
17299
|
const checks = [];
|
|
17261
17300
|
let index = -1;
|
|
@@ -17264,7 +17303,7 @@ function anyFactory$1(tests) {
|
|
|
17264
17303
|
checks[index] = convert(tests[index]);
|
|
17265
17304
|
}
|
|
17266
17305
|
|
|
17267
|
-
return castFactory
|
|
17306
|
+
return castFactory(any)
|
|
17268
17307
|
|
|
17269
17308
|
/**
|
|
17270
17309
|
* @this {unknown}
|
|
@@ -17290,7 +17329,7 @@ function anyFactory$1(tests) {
|
|
|
17290
17329
|
function propsFactory(check) {
|
|
17291
17330
|
const checkAsRecord = /** @type {Record<string, unknown>} */ (check);
|
|
17292
17331
|
|
|
17293
|
-
return castFactory
|
|
17332
|
+
return castFactory(all)
|
|
17294
17333
|
|
|
17295
17334
|
/**
|
|
17296
17335
|
* @param {Node} node
|
|
@@ -17319,7 +17358,7 @@ function propsFactory(check) {
|
|
|
17319
17358
|
* @returns {Check}
|
|
17320
17359
|
*/
|
|
17321
17360
|
function typeFactory(check) {
|
|
17322
|
-
return castFactory
|
|
17361
|
+
return castFactory(type)
|
|
17323
17362
|
|
|
17324
17363
|
/**
|
|
17325
17364
|
* @param {Node} node
|
|
@@ -17335,7 +17374,7 @@ function typeFactory(check) {
|
|
|
17335
17374
|
* @param {TestFunction} testFunction
|
|
17336
17375
|
* @returns {Check}
|
|
17337
17376
|
*/
|
|
17338
|
-
function castFactory
|
|
17377
|
+
function castFactory(testFunction) {
|
|
17339
17378
|
return check
|
|
17340
17379
|
|
|
17341
17380
|
/**
|
|
@@ -17666,7 +17705,7 @@ function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
|
17666
17705
|
const own$f = {}.hasOwnProperty;
|
|
17667
17706
|
|
|
17668
17707
|
/** @type {Options} */
|
|
17669
|
-
const emptyOptions$
|
|
17708
|
+
const emptyOptions$6 = {};
|
|
17670
17709
|
|
|
17671
17710
|
/**
|
|
17672
17711
|
* Create `state` from an mdast tree.
|
|
@@ -17679,7 +17718,7 @@ const emptyOptions$7 = {};
|
|
|
17679
17718
|
* `state` function.
|
|
17680
17719
|
*/
|
|
17681
17720
|
function createState(tree, options) {
|
|
17682
|
-
const settings = options || emptyOptions$
|
|
17721
|
+
const settings = options || emptyOptions$6;
|
|
17683
17722
|
/** @type {Map<string, MdastDefinition>} */
|
|
17684
17723
|
const definitionById = new Map();
|
|
17685
17724
|
/** @type {Map<string, MdastFootnoteDefinition>} */
|
|
@@ -19846,7 +19885,7 @@ function emphasisPeek$1(_, _1, state) {
|
|
|
19846
19885
|
*/
|
|
19847
19886
|
|
|
19848
19887
|
/** @type {Options} */
|
|
19849
|
-
const emptyOptions$
|
|
19888
|
+
const emptyOptions$5 = {};
|
|
19850
19889
|
|
|
19851
19890
|
/**
|
|
19852
19891
|
* Get the text content of a node or list of nodes.
|
|
@@ -19862,7 +19901,7 @@ const emptyOptions$6 = {};
|
|
|
19862
19901
|
* Serialized `value`.
|
|
19863
19902
|
*/
|
|
19864
19903
|
function toString$1(value, options) {
|
|
19865
|
-
const settings = options || emptyOptions$
|
|
19904
|
+
const settings = options || emptyOptions$5;
|
|
19866
19905
|
const includeImageAlt =
|
|
19867
19906
|
typeof settings.includeImageAlt === 'boolean'
|
|
19868
19907
|
? settings.includeImageAlt
|
|
@@ -21735,7 +21774,7 @@ function emphasisPeek(_, _1, state) {
|
|
|
21735
21774
|
*/
|
|
21736
21775
|
|
|
21737
21776
|
/** @type {Options} */
|
|
21738
|
-
const emptyOptions$
|
|
21777
|
+
const emptyOptions$4 = {};
|
|
21739
21778
|
|
|
21740
21779
|
/**
|
|
21741
21780
|
* Get the text content of a node or list of nodes.
|
|
@@ -21751,7 +21790,7 @@ const emptyOptions$5 = {};
|
|
|
21751
21790
|
* Serialized `value`.
|
|
21752
21791
|
*/
|
|
21753
21792
|
function toString(value, options) {
|
|
21754
|
-
const settings = options || emptyOptions$
|
|
21793
|
+
const settings = options || emptyOptions$4;
|
|
21755
21794
|
const includeImageAlt =
|
|
21756
21795
|
typeof settings.includeImageAlt === 'boolean'
|
|
21757
21796
|
? settings.includeImageAlt
|
|
@@ -26057,7 +26096,7 @@ function gfm(options) {
|
|
|
26057
26096
|
*/
|
|
26058
26097
|
|
|
26059
26098
|
/** @type {Options} */
|
|
26060
|
-
const emptyOptions$
|
|
26099
|
+
const emptyOptions$3 = {};
|
|
26061
26100
|
|
|
26062
26101
|
/**
|
|
26063
26102
|
* Add support GFM (autolink literals, footnotes, strikethrough, tables,
|
|
@@ -26072,7 +26111,7 @@ function remarkGfm(options) {
|
|
|
26072
26111
|
// @ts-expect-error: TS is wrong about `this`.
|
|
26073
26112
|
// eslint-disable-next-line unicorn/no-this-assignment
|
|
26074
26113
|
const self = /** @type {Processor<Root>} */ (this);
|
|
26075
|
-
const settings = options || emptyOptions$
|
|
26114
|
+
const settings = options || emptyOptions$3;
|
|
26076
26115
|
const data = self.data();
|
|
26077
26116
|
|
|
26078
26117
|
const micromarkExtensions =
|
|
@@ -26190,14 +26229,14 @@ function increment$3() {
|
|
|
26190
26229
|
}
|
|
26191
26230
|
|
|
26192
26231
|
const types$3 = /*#__PURE__*/Object.freeze({
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
|
|
26232
|
+
__proto__: null,
|
|
26233
|
+
boolean: boolean$3,
|
|
26234
|
+
booleanish: booleanish$3,
|
|
26235
|
+
overloadedBoolean: overloadedBoolean$3,
|
|
26236
|
+
number: number$4,
|
|
26237
|
+
spaceSeparated: spaceSeparated$3,
|
|
26238
|
+
commaSeparated: commaSeparated$3,
|
|
26239
|
+
commaOrSpaceSeparated: commaOrSpaceSeparated$3
|
|
26201
26240
|
});
|
|
26202
26241
|
|
|
26203
26242
|
/** @type {Array<keyof types>} */
|
|
@@ -27367,7 +27406,7 @@ const svg$6 = merge$3([xml$3, xlink$3, xmlns$3, aria$4, svg$7], 'svg');
|
|
|
27367
27406
|
* @returns {Array<string>}
|
|
27368
27407
|
* List of tokens.
|
|
27369
27408
|
*/
|
|
27370
|
-
function parse$
|
|
27409
|
+
function parse$5(value) {
|
|
27371
27410
|
/** @type {Array<string>} */
|
|
27372
27411
|
const tokens = [];
|
|
27373
27412
|
const input = String(value || '');
|
|
@@ -27491,7 +27530,7 @@ function parseSelector$1(selector, defaultTagName) {
|
|
|
27491
27530
|
* @returns {Array<string>}
|
|
27492
27531
|
* List of tokens.
|
|
27493
27532
|
*/
|
|
27494
|
-
function parse$
|
|
27533
|
+
function parse$4(value) {
|
|
27495
27534
|
const input = String(value || '').trim();
|
|
27496
27535
|
return input ? input.split(/[ \t\n\r\f]+/g) : []
|
|
27497
27536
|
}
|
|
@@ -27681,11 +27720,11 @@ function addProperty$1(schema, properties, key, value) {
|
|
|
27681
27720
|
// Handle list values.
|
|
27682
27721
|
else if (typeof value === 'string') {
|
|
27683
27722
|
if (info.spaceSeparated) {
|
|
27684
|
-
result = parse$
|
|
27723
|
+
result = parse$4(value);
|
|
27685
27724
|
} else if (info.commaSeparated) {
|
|
27686
|
-
result = parse$
|
|
27725
|
+
result = parse$5(value);
|
|
27687
27726
|
} else if (info.commaOrSpaceSeparated) {
|
|
27688
|
-
result = parse$
|
|
27727
|
+
result = parse$4(parse$5(value).join(' '));
|
|
27689
27728
|
} else {
|
|
27690
27729
|
result = parsePrimitive$1(info, info.property, value);
|
|
27691
27730
|
}
|
|
@@ -28096,7 +28135,7 @@ function one$3(state, node) {
|
|
|
28096
28135
|
// Element.
|
|
28097
28136
|
default: {
|
|
28098
28137
|
const reference = /** @type {DefaultTreeAdapterMap['element']} */ (node);
|
|
28099
|
-
result = element$
|
|
28138
|
+
result = element$5(state, reference);
|
|
28100
28139
|
return result
|
|
28101
28140
|
}
|
|
28102
28141
|
}
|
|
@@ -28136,7 +28175,7 @@ function all$4(state, nodes) {
|
|
|
28136
28175
|
* @returns {Element}
|
|
28137
28176
|
* hast node.
|
|
28138
28177
|
*/
|
|
28139
|
-
function element$
|
|
28178
|
+
function element$5(state, node) {
|
|
28140
28179
|
const schema = state.schema;
|
|
28141
28180
|
|
|
28142
28181
|
state.schema = node.namespaceURI === webNamespaces$2.svg ? svg$6 : html$8;
|
|
@@ -36039,7 +36078,7 @@ function endTagInForeignContent$1(p, token) {
|
|
|
36039
36078
|
* console.log(document.childNodes[1].tagName); //> 'html'
|
|
36040
36079
|
*```
|
|
36041
36080
|
*/
|
|
36042
|
-
function parse$
|
|
36081
|
+
function parse$3(html, options) {
|
|
36043
36082
|
return Parser$1.parse(html, options);
|
|
36044
36083
|
}
|
|
36045
36084
|
function parseFragment(fragmentContext, html, options) {
|
|
@@ -37897,7 +37936,7 @@ const formatXRe = /%x/g;
|
|
|
37897
37936
|
const fatalities = {2: true, 1: false, 0: null};
|
|
37898
37937
|
|
|
37899
37938
|
/** @type {Readonly<Options>} */
|
|
37900
|
-
const emptyOptions$
|
|
37939
|
+
const emptyOptions$2 = {};
|
|
37901
37940
|
|
|
37902
37941
|
/**
|
|
37903
37942
|
* Turn serialized HTML into a hast tree.
|
|
@@ -37910,10 +37949,10 @@ const emptyOptions$3 = {};
|
|
|
37910
37949
|
* Tree.
|
|
37911
37950
|
*/
|
|
37912
37951
|
function fromHtml(value, options) {
|
|
37913
|
-
const settings = options || emptyOptions$
|
|
37952
|
+
const settings = options || emptyOptions$2;
|
|
37914
37953
|
const onerror = settings.onerror;
|
|
37915
37954
|
const file = value instanceof VFile ? value : new VFile(value);
|
|
37916
|
-
const parseFunction = settings.fragment ? parseFragment : parse$
|
|
37955
|
+
const parseFunction = settings.fragment ? parseFragment : parse$3;
|
|
37917
37956
|
const document = String(file);
|
|
37918
37957
|
const p5Document = parseFunction(document, {
|
|
37919
37958
|
sourceCodeLocationInfo: true,
|
|
@@ -38109,316 +38148,6 @@ function rehypeParse(options) {
|
|
|
38109
38148
|
}
|
|
38110
38149
|
}
|
|
38111
38150
|
|
|
38112
|
-
/**
|
|
38113
|
-
* @typedef {import('hast').Element} Element
|
|
38114
|
-
* @typedef {import('hast').Parents} Parents
|
|
38115
|
-
*/
|
|
38116
|
-
|
|
38117
|
-
/**
|
|
38118
|
-
* Generate a check from a test.
|
|
38119
|
-
*
|
|
38120
|
-
* Useful if you’re going to test many nodes, for example when creating a
|
|
38121
|
-
* utility where something else passes a compatible test.
|
|
38122
|
-
*
|
|
38123
|
-
* The created function is a bit faster because it expects valid input only:
|
|
38124
|
-
* an `element`, `index`, and `parent`.
|
|
38125
|
-
*
|
|
38126
|
-
* @param test
|
|
38127
|
-
* A test for a specific element.
|
|
38128
|
-
* @returns
|
|
38129
|
-
* A check.
|
|
38130
|
-
*/
|
|
38131
|
-
const convertElement =
|
|
38132
|
-
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
38133
|
-
/**
|
|
38134
|
-
* @type {(
|
|
38135
|
-
* (<Condition extends TestFunction>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
|
|
38136
|
-
* (<Condition extends string>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
|
|
38137
|
-
* ((test?: null | undefined) => (element?: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
|
|
38138
|
-
* ((test?: Test) => Check)
|
|
38139
|
-
* )}
|
|
38140
|
-
*/
|
|
38141
|
-
(
|
|
38142
|
-
/**
|
|
38143
|
-
* @param {Test | null | undefined} [test]
|
|
38144
|
-
* @returns {Check}
|
|
38145
|
-
*/
|
|
38146
|
-
function (test) {
|
|
38147
|
-
if (test === null || test === undefined) {
|
|
38148
|
-
return element$5
|
|
38149
|
-
}
|
|
38150
|
-
|
|
38151
|
-
if (typeof test === 'string') {
|
|
38152
|
-
return tagNameFactory(test)
|
|
38153
|
-
}
|
|
38154
|
-
|
|
38155
|
-
// Assume array.
|
|
38156
|
-
if (typeof test === 'object') {
|
|
38157
|
-
return anyFactory(test)
|
|
38158
|
-
}
|
|
38159
|
-
|
|
38160
|
-
if (typeof test === 'function') {
|
|
38161
|
-
return castFactory(test)
|
|
38162
|
-
}
|
|
38163
|
-
|
|
38164
|
-
throw new Error('Expected function, string, or array as `test`')
|
|
38165
|
-
}
|
|
38166
|
-
);
|
|
38167
|
-
|
|
38168
|
-
/**
|
|
38169
|
-
* Handle multiple tests.
|
|
38170
|
-
*
|
|
38171
|
-
* @param {Array<TestFunction | string>} tests
|
|
38172
|
-
* @returns {Check}
|
|
38173
|
-
*/
|
|
38174
|
-
function anyFactory(tests) {
|
|
38175
|
-
/** @type {Array<Check>} */
|
|
38176
|
-
const checks = [];
|
|
38177
|
-
let index = -1;
|
|
38178
|
-
|
|
38179
|
-
while (++index < tests.length) {
|
|
38180
|
-
checks[index] = convertElement(tests[index]);
|
|
38181
|
-
}
|
|
38182
|
-
|
|
38183
|
-
return castFactory(any)
|
|
38184
|
-
|
|
38185
|
-
/**
|
|
38186
|
-
* @this {unknown}
|
|
38187
|
-
* @type {TestFunction}
|
|
38188
|
-
*/
|
|
38189
|
-
function any(...parameters) {
|
|
38190
|
-
let index = -1;
|
|
38191
|
-
|
|
38192
|
-
while (++index < checks.length) {
|
|
38193
|
-
if (checks[index].apply(this, parameters)) return true
|
|
38194
|
-
}
|
|
38195
|
-
|
|
38196
|
-
return false
|
|
38197
|
-
}
|
|
38198
|
-
}
|
|
38199
|
-
|
|
38200
|
-
/**
|
|
38201
|
-
* Turn a string into a test for an element with a certain type.
|
|
38202
|
-
*
|
|
38203
|
-
* @param {string} check
|
|
38204
|
-
* @returns {Check}
|
|
38205
|
-
*/
|
|
38206
|
-
function tagNameFactory(check) {
|
|
38207
|
-
return castFactory(tagName)
|
|
38208
|
-
|
|
38209
|
-
/**
|
|
38210
|
-
* @param {Element} element
|
|
38211
|
-
* @returns {boolean}
|
|
38212
|
-
*/
|
|
38213
|
-
function tagName(element) {
|
|
38214
|
-
return element.tagName === check
|
|
38215
|
-
}
|
|
38216
|
-
}
|
|
38217
|
-
|
|
38218
|
-
/**
|
|
38219
|
-
* Turn a custom test into a test for an element that passes that test.
|
|
38220
|
-
*
|
|
38221
|
-
* @param {TestFunction} testFunction
|
|
38222
|
-
* @returns {Check}
|
|
38223
|
-
*/
|
|
38224
|
-
function castFactory(testFunction) {
|
|
38225
|
-
return check
|
|
38226
|
-
|
|
38227
|
-
/**
|
|
38228
|
-
* @this {unknown}
|
|
38229
|
-
* @type {Check}
|
|
38230
|
-
*/
|
|
38231
|
-
function check(value, index, parent) {
|
|
38232
|
-
return Boolean(
|
|
38233
|
-
looksLikeAnElement(value) &&
|
|
38234
|
-
testFunction.call(
|
|
38235
|
-
this,
|
|
38236
|
-
value,
|
|
38237
|
-
typeof index === 'number' ? index : undefined,
|
|
38238
|
-
parent || undefined
|
|
38239
|
-
)
|
|
38240
|
-
)
|
|
38241
|
-
}
|
|
38242
|
-
}
|
|
38243
|
-
|
|
38244
|
-
/**
|
|
38245
|
-
* Make sure something is an element.
|
|
38246
|
-
*
|
|
38247
|
-
* @param {unknown} element
|
|
38248
|
-
* @returns {element is Element}
|
|
38249
|
-
*/
|
|
38250
|
-
function element$5(element) {
|
|
38251
|
-
return Boolean(
|
|
38252
|
-
element &&
|
|
38253
|
-
typeof element === 'object' &&
|
|
38254
|
-
'type' in element &&
|
|
38255
|
-
element.type === 'element' &&
|
|
38256
|
-
'tagName' in element &&
|
|
38257
|
-
typeof element.tagName === 'string'
|
|
38258
|
-
)
|
|
38259
|
-
}
|
|
38260
|
-
|
|
38261
|
-
/**
|
|
38262
|
-
* @param {unknown} value
|
|
38263
|
-
* @returns {value is Element}
|
|
38264
|
-
*/
|
|
38265
|
-
function looksLikeAnElement(value) {
|
|
38266
|
-
return (
|
|
38267
|
-
value !== null &&
|
|
38268
|
-
typeof value === 'object' &&
|
|
38269
|
-
'type' in value &&
|
|
38270
|
-
'tagName' in value
|
|
38271
|
-
)
|
|
38272
|
-
}
|
|
38273
|
-
|
|
38274
|
-
// Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
|
38275
|
-
// Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
|
38276
|
-
const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
|
|
38277
|
-
|
|
38278
|
-
// Windows paths like `c:\`
|
|
38279
|
-
const WINDOWS_PATH_REGEX = /^[a-zA-Z]:\\/;
|
|
38280
|
-
|
|
38281
|
-
function isAbsoluteUrl(url) {
|
|
38282
|
-
if (typeof url !== 'string') {
|
|
38283
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof url}\``);
|
|
38284
|
-
}
|
|
38285
|
-
|
|
38286
|
-
if (WINDOWS_PATH_REGEX.test(url)) {
|
|
38287
|
-
return false;
|
|
38288
|
-
}
|
|
38289
|
-
|
|
38290
|
-
return ABSOLUTE_URL_REGEX.test(url);
|
|
38291
|
-
}
|
|
38292
|
-
|
|
38293
|
-
/**
|
|
38294
|
-
* Parse space-separated tokens to an array of strings.
|
|
38295
|
-
*
|
|
38296
|
-
* @param {string} value
|
|
38297
|
-
* Space-separated tokens.
|
|
38298
|
-
* @returns {Array<string>}
|
|
38299
|
-
* List of tokens.
|
|
38300
|
-
*/
|
|
38301
|
-
function parse$3(value) {
|
|
38302
|
-
const input = String(value || '').trim();
|
|
38303
|
-
return input ? input.split(/[ \t\n\r\f]+/g) : []
|
|
38304
|
-
}
|
|
38305
|
-
|
|
38306
|
-
/**
|
|
38307
|
-
* @typedef {import('hast').Element} Element
|
|
38308
|
-
* @typedef {import('hast').ElementContent} ElementContent
|
|
38309
|
-
* @typedef {import('hast').Properties} Properties
|
|
38310
|
-
* @typedef {import('hast').Root} Root
|
|
38311
|
-
* @typedef {import('hast-util-is-element').Test} Test
|
|
38312
|
-
*/
|
|
38313
|
-
|
|
38314
|
-
const defaultProtocols = ['http', 'https'];
|
|
38315
|
-
const defaultRel = ['nofollow'];
|
|
38316
|
-
|
|
38317
|
-
/** @type {Options} */
|
|
38318
|
-
const emptyOptions$2 = {};
|
|
38319
|
-
|
|
38320
|
-
/**
|
|
38321
|
-
* Automatically add `rel` (and `target`?) to external links.
|
|
38322
|
-
*
|
|
38323
|
-
* ###### Notes
|
|
38324
|
-
*
|
|
38325
|
-
* You should [likely not configure `target`][css-tricks].
|
|
38326
|
-
*
|
|
38327
|
-
* You should at least set `rel` to `['nofollow']`.
|
|
38328
|
-
* When using a `target`, add `noopener` and `noreferrer` to avoid exploitation
|
|
38329
|
-
* of the `window.opener` API.
|
|
38330
|
-
*
|
|
38331
|
-
* When using a `target`, you should set `content` to adhere to accessibility
|
|
38332
|
-
* guidelines by giving users advanced warning when opening a new window.
|
|
38333
|
-
*
|
|
38334
|
-
* [css-tricks]: https://css-tricks.com/use-target_blank/
|
|
38335
|
-
*
|
|
38336
|
-
* @param {Readonly<Options> | null | undefined} [options]
|
|
38337
|
-
* Configuration (optional).
|
|
38338
|
-
* @returns
|
|
38339
|
-
* Transform.
|
|
38340
|
-
*/
|
|
38341
|
-
function rehypeExternalLinks(options) {
|
|
38342
|
-
const settings = options || emptyOptions$2;
|
|
38343
|
-
const protocols = settings.protocols || defaultProtocols;
|
|
38344
|
-
const is = convertElement(settings.test);
|
|
38345
|
-
|
|
38346
|
-
/**
|
|
38347
|
-
* Transform.
|
|
38348
|
-
*
|
|
38349
|
-
* @param {Root} tree
|
|
38350
|
-
* Tree.
|
|
38351
|
-
* @returns {undefined}
|
|
38352
|
-
* Nothing.
|
|
38353
|
-
*/
|
|
38354
|
-
return function (tree) {
|
|
38355
|
-
visit(tree, 'element', function (node, index, parent) {
|
|
38356
|
-
if (
|
|
38357
|
-
node.tagName === 'a' &&
|
|
38358
|
-
typeof node.properties.href === 'string' &&
|
|
38359
|
-
is(node, index, parent)
|
|
38360
|
-
) {
|
|
38361
|
-
const url = node.properties.href;
|
|
38362
|
-
|
|
38363
|
-
if (
|
|
38364
|
-
isAbsoluteUrl(url)
|
|
38365
|
-
? protocols.includes(url.slice(0, url.indexOf(':')))
|
|
38366
|
-
: url.startsWith('//')
|
|
38367
|
-
) {
|
|
38368
|
-
const contentRaw = createIfNeeded(settings.content, node);
|
|
38369
|
-
const content =
|
|
38370
|
-
contentRaw && !Array.isArray(contentRaw) ? [contentRaw] : contentRaw;
|
|
38371
|
-
const relRaw = createIfNeeded(settings.rel, node) || defaultRel;
|
|
38372
|
-
const rel = typeof relRaw === 'string' ? parse$3(relRaw) : relRaw;
|
|
38373
|
-
const target = createIfNeeded(settings.target, node);
|
|
38374
|
-
|
|
38375
|
-
const properties = createIfNeeded(settings.properties, node);
|
|
38376
|
-
|
|
38377
|
-
if (properties) {
|
|
38378
|
-
Object.assign(node.properties, structuredClone$1(properties));
|
|
38379
|
-
}
|
|
38380
|
-
|
|
38381
|
-
if (rel.length > 0) {
|
|
38382
|
-
node.properties.rel = [...rel];
|
|
38383
|
-
}
|
|
38384
|
-
|
|
38385
|
-
if (target) {
|
|
38386
|
-
node.properties.target = target;
|
|
38387
|
-
}
|
|
38388
|
-
|
|
38389
|
-
if (content) {
|
|
38390
|
-
const properties =
|
|
38391
|
-
createIfNeeded(settings.contentProperties, node) || {};
|
|
38392
|
-
|
|
38393
|
-
node.children.push({
|
|
38394
|
-
type: 'element',
|
|
38395
|
-
tagName: 'span',
|
|
38396
|
-
properties: structuredClone$1(properties),
|
|
38397
|
-
children: structuredClone$1(content)
|
|
38398
|
-
});
|
|
38399
|
-
}
|
|
38400
|
-
}
|
|
38401
|
-
}
|
|
38402
|
-
});
|
|
38403
|
-
}
|
|
38404
|
-
}
|
|
38405
|
-
|
|
38406
|
-
/**
|
|
38407
|
-
* Call a function to get a return value or use the value.
|
|
38408
|
-
*
|
|
38409
|
-
* @template T
|
|
38410
|
-
* Type of value.
|
|
38411
|
-
* @param {T} value
|
|
38412
|
-
* Value.
|
|
38413
|
-
* @param {Element} element
|
|
38414
|
-
* Element.
|
|
38415
|
-
* @returns {T extends Function ? ReturnType<T> : T}
|
|
38416
|
-
* Result.
|
|
38417
|
-
*/
|
|
38418
|
-
function createIfNeeded(value, element) {
|
|
38419
|
-
return typeof value === 'function' ? value(element) : value
|
|
38420
|
-
}
|
|
38421
|
-
|
|
38422
38151
|
/**
|
|
38423
38152
|
* @typedef {import('unist').Node} Node
|
|
38424
38153
|
* @typedef {import('unist').Point} Point
|
|
@@ -39417,14 +39146,14 @@ function increment$2() {
|
|
|
39417
39146
|
}
|
|
39418
39147
|
|
|
39419
39148
|
const types$2 = /*#__PURE__*/Object.freeze({
|
|
39420
|
-
|
|
39421
|
-
|
|
39422
|
-
|
|
39423
|
-
|
|
39424
|
-
|
|
39425
|
-
|
|
39426
|
-
|
|
39427
|
-
|
|
39149
|
+
__proto__: null,
|
|
39150
|
+
boolean: boolean$2,
|
|
39151
|
+
booleanish: booleanish$2,
|
|
39152
|
+
overloadedBoolean: overloadedBoolean$2,
|
|
39153
|
+
number: number$3,
|
|
39154
|
+
spaceSeparated: spaceSeparated$2,
|
|
39155
|
+
commaSeparated: commaSeparated$2,
|
|
39156
|
+
commaOrSpaceSeparated: commaOrSpaceSeparated$2
|
|
39428
39157
|
});
|
|
39429
39158
|
|
|
39430
39159
|
/** @type {Array<keyof types>} */
|
|
@@ -42763,14 +42492,14 @@ function increment$1() {
|
|
|
42763
42492
|
}
|
|
42764
42493
|
|
|
42765
42494
|
const types$1 = /*#__PURE__*/Object.freeze({
|
|
42766
|
-
|
|
42767
|
-
|
|
42768
|
-
|
|
42769
|
-
|
|
42770
|
-
|
|
42771
|
-
|
|
42772
|
-
|
|
42773
|
-
|
|
42495
|
+
__proto__: null,
|
|
42496
|
+
boolean: boolean$1,
|
|
42497
|
+
booleanish: booleanish$1,
|
|
42498
|
+
overloadedBoolean: overloadedBoolean$1,
|
|
42499
|
+
number: number$2,
|
|
42500
|
+
spaceSeparated: spaceSeparated$1,
|
|
42501
|
+
commaSeparated: commaSeparated$1,
|
|
42502
|
+
commaOrSpaceSeparated: commaOrSpaceSeparated$1
|
|
42774
42503
|
});
|
|
42775
42504
|
|
|
42776
42505
|
/** @type {Array<keyof types>} */
|
|
@@ -45025,14 +44754,14 @@ function increment() {
|
|
|
45025
44754
|
}
|
|
45026
44755
|
|
|
45027
44756
|
const types = /*#__PURE__*/Object.freeze({
|
|
45028
|
-
|
|
45029
|
-
|
|
45030
|
-
|
|
45031
|
-
|
|
45032
|
-
|
|
45033
|
-
|
|
45034
|
-
|
|
45035
|
-
|
|
44757
|
+
__proto__: null,
|
|
44758
|
+
boolean: boolean,
|
|
44759
|
+
booleanish: booleanish,
|
|
44760
|
+
overloadedBoolean: overloadedBoolean,
|
|
44761
|
+
number: number$1,
|
|
44762
|
+
spaceSeparated: spaceSeparated,
|
|
44763
|
+
commaSeparated: commaSeparated,
|
|
44764
|
+
commaOrSpaceSeparated: commaOrSpaceSeparated
|
|
45036
44765
|
});
|
|
45037
44766
|
|
|
45038
44767
|
/** @type {Array<keyof types>} */
|
|
@@ -56192,6 +55921,34 @@ function createLazyLoadImagesPlugin(lazyLoadImages = false) {
|
|
|
56192
55921
|
};
|
|
56193
55922
|
}
|
|
56194
55923
|
|
|
55924
|
+
/**
|
|
55925
|
+
* Creates a unified.js plugin that transforms link elements
|
|
55926
|
+
* to add target, rel, and referrerpolicy attributes.
|
|
55927
|
+
*
|
|
55928
|
+
* @returns A unified.js plugin function
|
|
55929
|
+
*/
|
|
55930
|
+
function createLinksPlugin() {
|
|
55931
|
+
return () => {
|
|
55932
|
+
return (tree) => {
|
|
55933
|
+
visit(tree, 'element', (node) => {
|
|
55934
|
+
var _a, _b;
|
|
55935
|
+
if (node.tagName === 'a') {
|
|
55936
|
+
const href = (_a = node.properties) === null || _a === void 0 ? void 0 : _a.href;
|
|
55937
|
+
const title = (_b = node.properties) === null || _b === void 0 ? void 0 : _b.title;
|
|
55938
|
+
if (!href) {
|
|
55939
|
+
return;
|
|
55940
|
+
}
|
|
55941
|
+
const attributes = getLinkAttributes(href, title);
|
|
55942
|
+
node.properties.target = attributes.target;
|
|
55943
|
+
node.properties.rel = attributes.rel;
|
|
55944
|
+
node.properties.referrerpolicy = attributes.referrerpolicy;
|
|
55945
|
+
}
|
|
55946
|
+
});
|
|
55947
|
+
return tree;
|
|
55948
|
+
};
|
|
55949
|
+
};
|
|
55950
|
+
}
|
|
55951
|
+
|
|
56195
55952
|
/**
|
|
56196
55953
|
* Takes a string as input and returns a new string
|
|
56197
55954
|
* where the text has been converted to HTML.
|
|
@@ -56215,8 +55972,8 @@ async function markdownToHTML(text, options) {
|
|
|
56215
55972
|
.use(remarkParse)
|
|
56216
55973
|
.use(remarkGfm)
|
|
56217
55974
|
.use(remarkRehype, { allowDangerousHtml: true })
|
|
56218
|
-
.use(rehypeExternalLinks, { target: '_blank' })
|
|
56219
55975
|
.use(rehypeRaw)
|
|
55976
|
+
.use(createLinksPlugin())
|
|
56220
55977
|
.use(rehypeSanitize, Object.assign({}, getWhiteList((_a = options === null || options === void 0 ? void 0 : options.whitelist) !== null && _a !== void 0 ? _a : [])))
|
|
56221
55978
|
.use(() => {
|
|
56222
55979
|
return (tree) => {
|
|
@@ -56253,7 +56010,7 @@ async function sanitizeHTML(html, whitelist) {
|
|
|
56253
56010
|
return file.toString();
|
|
56254
56011
|
}
|
|
56255
56012
|
function getWhiteList(allowedComponents) {
|
|
56256
|
-
var _a, _b;
|
|
56013
|
+
var _a, _b, _c;
|
|
56257
56014
|
const defaultSchemaClone = [...((_a = defaultSchema.attributes['*']) !== null && _a !== void 0 ? _a : [])];
|
|
56258
56015
|
const asteriskAttributeWhitelist = defaultSchemaClone.filter((attr) => {
|
|
56259
56016
|
return attr !== 'height';
|
|
@@ -56265,7 +56022,7 @@ function getWhiteList(allowedComponents) {
|
|
|
56265
56022
|
], attributes: Object.assign(Object.assign({}, defaultSchema.attributes), { p: [
|
|
56266
56023
|
...((_b = defaultSchema.attributes.p) !== null && _b !== void 0 ? _b : []),
|
|
56267
56024
|
['className', 'MsoNormal'],
|
|
56268
|
-
], '*': asteriskAttributeWhitelist }) });
|
|
56025
|
+
], a: [...((_c = defaultSchema.attributes.a) !== null && _c !== void 0 ? _c : []), 'referrerpolicy'], '*': asteriskAttributeWhitelist }) });
|
|
56269
56026
|
for (const component of allowedComponents) {
|
|
56270
56027
|
whitelist.attributes[component.tagName] = component.attributes;
|
|
56271
56028
|
}
|
|
@@ -56273,7 +56030,8 @@ function getWhiteList(allowedComponents) {
|
|
|
56273
56030
|
}
|
|
56274
56031
|
|
|
56275
56032
|
exports.decodeHTML = decodeHTML;
|
|
56033
|
+
exports.getLinkAttributes = getLinkAttributes;
|
|
56276
56034
|
exports.markdownToHTML = markdownToHTML;
|
|
56277
56035
|
exports.sanitizeHTML = sanitizeHTML;
|
|
56278
56036
|
|
|
56279
|
-
//# sourceMappingURL=markdown-parser-
|
|
56037
|
+
//# sourceMappingURL=markdown-parser-563c73db.js.map
|