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