@pod-os/contacts 0.3.0 → 0.4.0-rc.20fe2f1.0

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 (128) hide show
  1. package/dist/cjs/{chunk.5JY5FUCG-BJJbNIiG.js → chunk.5JY5FUCG-BDpED7an.js} +2 -2
  2. package/dist/cjs/{chunk.HVTXQL7M-C6x_EQ24.js → chunk.HVTXQL7M-CkQwB4ew.js} +4 -4
  3. package/dist/cjs/{chunk.URTPIBTY-BiNv2Ckb.js → chunk.URTPIBTY-De5L-27M.js} +3 -3
  4. package/dist/cjs/{chunk.XQ2OKYYA-CDJtWcvs.js → chunk.XQ2OKYYA-CZfHjZJv.js} +4 -4
  5. package/dist/cjs/{chunk.YHLNUJ7P-CoQhYOM2.js → chunk.YHLNUJ7P-C7S3ShkT.js} +1 -1
  6. package/dist/cjs/chunk.ZGGPD2XJ-DGjeHZ7b.js +5 -0
  7. package/dist/cjs/{class-map-CyEFRZYn.js → class-map-D_80IxYF.js} +1 -1
  8. package/dist/cjs/contacts.cjs.js +2 -2
  9. package/dist/cjs/{if-defined-TQmAS6tz.js → if-defined-BNj5GZso.js} +1 -1
  10. package/dist/cjs/{index-DdRXU5II.js → index-BiY-p204.js} +62 -20
  11. package/dist/cjs/{index-CpATWk39.js → index-D8Y89icW.js} +1 -1
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/pos-add-literal-value_3.cjs.entry.js +6 -6
  14. package/dist/cjs/pos-add-new-thing_7.cjs.entry.js +9 -9
  15. package/dist/cjs/pos-app-browser.cjs.entry.js +2 -2
  16. package/dist/cjs/pos-app-dashboard_6.cjs.entry.js +3 -3
  17. package/dist/cjs/pos-app-document-viewer.cjs.entry.js +1 -1
  18. package/dist/cjs/pos-app-generic.cjs.entry.js +1 -1
  19. package/dist/cjs/pos-app-image-viewer.cjs.entry.js +1 -1
  20. package/dist/cjs/pos-app-ldp-container.cjs.entry.js +1 -1
  21. package/dist/cjs/pos-app-rdf-document.cjs.entry.js +1 -1
  22. package/dist/cjs/pos-app_24.cjs.entry.js +9 -9
  23. package/dist/cjs/pos-attachments.cjs.entry.js +1 -1
  24. package/dist/cjs/pos-container-contents.cjs.entry.js +1 -1
  25. package/dist/cjs/pos-container-item_3.cjs.entry.js +6 -6
  26. package/dist/cjs/pos-description_2.cjs.entry.js +1 -1
  27. package/dist/cjs/pos-document.cjs.entry.js +6 -6
  28. package/dist/cjs/pos-list.cjs.entry.js +1 -1
  29. package/dist/cjs/pos-make-findable_2.cjs.entry.js +7 -7
  30. package/dist/cjs/pos-markdown-document.cjs.entry.js +413 -123
  31. package/dist/cjs/pos-new-thing-form.cjs.entry.js +1 -1
  32. package/dist/cjs/pos-predicate.cjs.entry.js +6 -6
  33. package/dist/cjs/pos-relations_2.cjs.entry.js +1 -1
  34. package/dist/cjs/pos-select-term.cjs.entry.js +1 -1
  35. package/dist/cjs/pos-subjects.cjs.entry.js +1 -1
  36. package/dist/cjs/pos-tool-attachments.cjs.entry.js +1 -1
  37. package/dist/cjs/pos-tool-select.cjs.entry.js +3 -3
  38. package/dist/cjs/pos-value.cjs.entry.js +1 -1
  39. package/dist/cjs/{session-kBhmup9r.js → session-CW2xZDbl.js} +1 -1
  40. package/dist/cjs/{settings-CpwCCkhx.js → settings-D2bZj29K.js} +1 -1
  41. package/dist/collection/collection-manifest.json +1 -1
  42. package/dist/components/pos-markdown-document2.js +1 -1
  43. package/dist/contacts/contacts.esm.js +1 -1
  44. package/dist/contacts/{p-78715d17.entry.js → p-11dd66c9.entry.js} +1 -1
  45. package/dist/contacts/{p-6d4ec7e5.entry.js → p-1943a383.entry.js} +1 -1
  46. package/dist/contacts/{p-46f8861e.entry.js → p-3c4fada1.entry.js} +1 -1
  47. package/dist/contacts/{p-ce6b4a9a.entry.js → p-3c6684c3.entry.js} +1 -1
  48. package/dist/contacts/{p-c4a1c42a.entry.js → p-4c02d7b7.entry.js} +1 -1
  49. package/dist/contacts/p-4da8f636.entry.js +1 -0
  50. package/dist/contacts/{p-84fdbc1a.entry.js → p-58ce4289.entry.js} +1 -1
  51. package/dist/contacts/{p-C1XsyD29.js → p-5RplWyqs.js} +1 -1
  52. package/dist/contacts/{p-649e7365.entry.js → p-5ae55c52.entry.js} +1 -1
  53. package/dist/contacts/{p-40b2d792.entry.js → p-5df07840.entry.js} +1 -1
  54. package/dist/contacts/{p-92fcdd59.entry.js → p-63e52cba.entry.js} +1 -1
  55. package/dist/contacts/{p-76382e6a.entry.js → p-6f9152d8.entry.js} +1 -1
  56. package/dist/contacts/p-7a60ece3.entry.js +1 -0
  57. package/dist/contacts/{p-a9d03996.entry.js → p-7aded942.entry.js} +1 -1
  58. package/dist/contacts/{p-7a01c820.entry.js → p-7cf756ed.entry.js} +1 -1
  59. package/dist/contacts/{p-c89722f1.entry.js → p-908587ff.entry.js} +1 -1
  60. package/dist/contacts/{p-a629ae72.entry.js → p-9f34648a.entry.js} +1 -1
  61. package/dist/contacts/{p-B0_xZCeV.js → p-B3jnBMMO.js} +3 -3
  62. package/dist/contacts/{p-C8LPXtIR.js → p-BvR_sP9G.js} +1 -1
  63. package/dist/contacts/{p-Bug_w-vi.js → p-C36YDIjT.js} +1 -1
  64. package/dist/contacts/{p-BXdS2klL.js → p-CzUN2DJY.js} +4 -4
  65. package/dist/contacts/p-D8UlKjrD.js +1 -0
  66. package/dist/contacts/{p-BXcFVJku.js → p-Dq6SRSqM.js} +2 -2
  67. package/dist/contacts/{p-DScSUBy-.js → p-Dunlf3Z7.js} +1 -1
  68. package/dist/contacts/{p-BkeypvMo.js → p-VfX5yLuQ.js} +7 -7
  69. package/dist/contacts/{p-SrdKoY3I.js → p-_eHMN8WS.js} +1 -1
  70. package/dist/contacts/{p-7f565d49.entry.js → p-a0da8fbf.entry.js} +1 -1
  71. package/dist/contacts/{p-d510fa6c.entry.js → p-a52ee32d.entry.js} +5 -5
  72. package/dist/contacts/{p-7d796ba8.entry.js → p-bbb51116.entry.js} +8 -8
  73. package/dist/contacts/{p-4ef3891c.entry.js → p-be0458af.entry.js} +1 -1
  74. package/dist/contacts/{p-ecf8719a.entry.js → p-be2bfaf2.entry.js} +1 -1
  75. package/dist/contacts/{p-D_nUMgR-.js → p-bf6nCqHq.js} +1 -1
  76. package/dist/contacts/{p-ae43e046.entry.js → p-c9d40209.entry.js} +1 -1
  77. package/dist/contacts/{p-f8517ff2.entry.js → p-d762c42d.entry.js} +1 -1
  78. package/dist/contacts/{p-26248da8.entry.js → p-dc6b0fb2.entry.js} +1 -1
  79. package/dist/contacts/{p-68gi0rt1.js → p-dsdWvqdi.js} +3 -3
  80. package/dist/contacts/{p-c306d8ca.entry.js → p-f403a62e.entry.js} +1 -1
  81. package/dist/contacts/p-feaa607e.entry.js +1 -0
  82. package/dist/esm/{chunk.5JY5FUCG-B58l5Mdn.js → chunk.5JY5FUCG-CPET0g0y.js} +2 -2
  83. package/dist/esm/{chunk.HVTXQL7M-DXJDg6h_.js → chunk.HVTXQL7M-Bo9_AX3Z.js} +4 -4
  84. package/dist/esm/{chunk.URTPIBTY-C1YI_wtI.js → chunk.URTPIBTY-Cec1N58N.js} +3 -3
  85. package/dist/esm/{chunk.XQ2OKYYA-B0surOUs.js → chunk.XQ2OKYYA-CdgFL-s-.js} +4 -4
  86. package/dist/esm/{chunk.YHLNUJ7P-B10Qbx9i.js → chunk.YHLNUJ7P-nIbF6vRN.js} +1 -1
  87. package/dist/esm/chunk.ZGGPD2XJ-BsTqrynL.js +3 -0
  88. package/dist/esm/{class-map-DcKoKhP0.js → class-map-BnsoOzsP.js} +1 -1
  89. package/dist/esm/contacts.js +3 -3
  90. package/dist/esm/{if-defined-TtuUo8or.js → if-defined-CmT83CRs.js} +1 -1
  91. package/dist/esm/{index-D4tjvI9D.js → index-CkwiZvFT.js} +1 -1
  92. package/dist/esm/{index-DScSUBy-.js → index-Dunlf3Z7.js} +61 -19
  93. package/dist/esm/loader.js +2 -2
  94. package/dist/esm/pos-add-literal-value_3.entry.js +6 -6
  95. package/dist/esm/pos-add-new-thing_7.entry.js +9 -9
  96. package/dist/esm/pos-app-browser.entry.js +2 -2
  97. package/dist/esm/pos-app-dashboard_6.entry.js +3 -3
  98. package/dist/esm/pos-app-document-viewer.entry.js +1 -1
  99. package/dist/esm/pos-app-generic.entry.js +1 -1
  100. package/dist/esm/pos-app-image-viewer.entry.js +1 -1
  101. package/dist/esm/pos-app-ldp-container.entry.js +1 -1
  102. package/dist/esm/pos-app-rdf-document.entry.js +1 -1
  103. package/dist/esm/pos-app_24.entry.js +9 -9
  104. package/dist/esm/pos-attachments.entry.js +1 -1
  105. package/dist/esm/pos-container-contents.entry.js +1 -1
  106. package/dist/esm/pos-container-item_3.entry.js +6 -6
  107. package/dist/esm/pos-description_2.entry.js +1 -1
  108. package/dist/esm/pos-document.entry.js +6 -6
  109. package/dist/esm/pos-list.entry.js +1 -1
  110. package/dist/esm/pos-make-findable_2.entry.js +7 -7
  111. package/dist/esm/pos-markdown-document.entry.js +413 -123
  112. package/dist/esm/pos-new-thing-form.entry.js +1 -1
  113. package/dist/esm/pos-predicate.entry.js +6 -6
  114. package/dist/esm/pos-relations_2.entry.js +1 -1
  115. package/dist/esm/pos-select-term.entry.js +1 -1
  116. package/dist/esm/pos-subjects.entry.js +1 -1
  117. package/dist/esm/pos-tool-attachments.entry.js +1 -1
  118. package/dist/esm/pos-tool-select.entry.js +3 -3
  119. package/dist/esm/pos-value.entry.js +1 -1
  120. package/dist/esm/{session-CtUoUtdF.js → session-VqDg66f5.js} +1 -1
  121. package/dist/esm/{settings-Cnw1mSJw.js → settings-CbiYsH1V.js} +1 -1
  122. package/package.json +3 -3
  123. package/dist/cjs/chunk.ZGGPD2XJ-C--tZiyf.js +0 -5
  124. package/dist/contacts/p-5e11ce90.entry.js +0 -1
  125. package/dist/contacts/p-8bc26fd9.entry.js +0 -1
  126. package/dist/contacts/p-Bk6kpzHk.js +0 -1
  127. package/dist/contacts/p-a3082900.entry.js +0 -1
  128. package/dist/esm/chunk.ZGGPD2XJ-CxH68zCl.js +0 -3
@@ -1,7 +1,7 @@
1
- import { r as registerInstance, c as createEvent, h as h$1 } from './index-DScSUBy-.js';
1
+ import { r as registerInstance, c as createEvent, h as h$1 } from './index-Dunlf3Z7.js';
2
2
  import { r as requireFilter, a as requireNot, b as requireRaceWith, d as requireArgsOrArgArray, e as requireAudit, f as requireAuditTime, g as requireBuffer, h as requireBufferCount, i as requireBufferTime, j as requireBufferToggle, k as requireBufferWhen, l as requireCatchError, m as requireCombineAll, n as requireCombineLatestAll, o as requireCombineLatest, p as requireCombineLatestWith, q as requireConcat, s as requireConcatAll, t as requireConcatMap, u as requireConcatMapTo, v as requireConcatWith, w as requireConnect, x as requireCount, y as requireDebounce, z as requireDebounceTime, A as requireDefaultIfEmpty, B as requireDelay, C as requireDelayWhen, D as requireDematerialize, E as requireDistinct, F as requireDistinctUntilChanged, G as requireDistinctUntilKeyChanged, H as requireElementAt, I as requireEndWith, J as requireEvery, K as requireExhaust, L as requireExhaustAll, M as requireExhaustMap, N as requireExpand, O as requireFinalize, P as requireFind, Q as requireFindIndex, R as requireFirst, S as requireGroupBy, T as requireIgnoreElements, U as requireIsEmpty, V as requireLast, W as requireMap, X as requireMapTo, Y as requireMaterialize, Z as requireMax, _ as requireMerge, $ as requireMergeAll, a0 as requireFlatMap, a1 as requireMergeMap, a2 as requireMergeMapTo, a3 as requireMergeScan, a4 as requireMergeWith, a5 as requireMin, a6 as requireMulticast, a7 as requireObserveOn, a8 as requireOnErrorResumeNextWith, a9 as requirePairwise, aa as requirePluck, ab as requirePublish, ac as requirePublishBehavior, ad as requirePublishLast, ae as requirePublishReplay, af as requireReduce, ag as requireRepeat, ah as requireRepeatWhen, ai as requireRetry, aj as requireRetryWhen, ak as requireRefCount, al as requireSample, am as requireSampleTime, an as requireScan, ao as requireSequenceEqual, ap as requireShare, aq as requireShareReplay, ar as requireSingle, as as requireSkip, at as requireSkipLast, au as requireSkipUntil, av as requireSkipWhile, aw as requireStartWith, ax as requireSubscribeOn, ay as requireSwitchAll, az as requireSwitchMap, aA as requireSwitchMapTo, aB as requireSwitchScan, aC as requireTake, aD as requireTakeLast, aE as requireTakeUntil, aF as requireTakeWhile, aG as requireTap, aH as requireThrottle, aI as requireThrottleTime, aJ as requireThrowIfEmpty, aK as requireTimeInterval, aL as requireTimeout, aM as requireTimeoutWith, aN as requireTimestamp, aO as requireToArray, aP as requireWindow, aQ as requireWindowCount, aR as requireWindowTime, aS as requireWindowToggle, aT as requireWindowWhen, aU as requireWithLatestFrom, aV as requireZip, aW as requireZipAll, aX as requireZipWith, c as cjsExports } from './index-vFMstSdt.js';
3
- import './chunk.ZGGPD2XJ-CxH68zCl.js';
4
- import './chunk.YHLNUJ7P-B10Qbx9i.js';
3
+ import './chunk.ZGGPD2XJ-BsTqrynL.js';
4
+ import './chunk.YHLNUJ7P-nIbF6vRN.js';
5
5
 
6
6
  // ::- Persistent data structure representing an ordered mapping from
7
7
  // strings to values, with some convenient update methods.
@@ -13879,7 +13879,6 @@ function isMarkInSet(marks, type, attributes = {}) {
13879
13879
  return !!findMarkInSet(marks, type, attributes);
13880
13880
  }
13881
13881
  function getMarkRange($pos, type, attributes) {
13882
- var _a;
13883
13882
  if (!$pos || !type) {
13884
13883
  return;
13885
13884
  }
@@ -13890,7 +13889,12 @@ function getMarkRange($pos, type, attributes) {
13890
13889
  if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
13891
13890
  return;
13892
13891
  }
13893
- attributes = attributes || ((_a = start.node.marks[0]) == null ? void 0 : _a.attrs);
13892
+ if (!attributes) {
13893
+ const firstMark = start.node.marks.find((mark2) => mark2.type === type);
13894
+ if (firstMark) {
13895
+ attributes = firstMark.attrs;
13896
+ }
13897
+ }
13894
13898
  const mark = findMarkInSet([...start.node.marks], type, attributes);
13895
13899
  if (!mark) {
13896
13900
  return;
@@ -13925,7 +13929,7 @@ function getMarkType(nameOrType, schema) {
13925
13929
  }
13926
13930
 
13927
13931
  // src/commands/extendMarkRange.ts
13928
- var extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
13932
+ var extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
13929
13933
  const type = getMarkType(typeOrName, state.schema);
13930
13934
  const { doc, selection } = tr;
13931
13935
  const { $from, from, to } = selection;
@@ -14260,7 +14264,7 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
14260
14264
  const fromSelectionAtStart = $from.parentOffset === 0;
14261
14265
  const isTextSelection2 = $fromNode.isText || $fromNode.isTextblock;
14262
14266
  const hasContent = $fromNode.content.size > 0;
14263
- if (fromSelectionAtStart && isTextSelection2 && hasContent) {
14267
+ if (fromSelectionAtStart && isTextSelection2 && hasContent && isOnlyBlockContent) {
14264
14268
  from = Math.max(0, from - 1);
14265
14269
  }
14266
14270
  tr.replaceWith(from, to, newContent);
@@ -14818,6 +14822,67 @@ function getAttributesFromExtensions(extensions) {
14818
14822
  }
14819
14823
 
14820
14824
  // src/utilities/mergeAttributes.ts
14825
+ function splitStyleDeclarations(styles) {
14826
+ const result = [];
14827
+ let current = "";
14828
+ let inSingleQuote = false;
14829
+ let inDoubleQuote = false;
14830
+ let parenDepth = 0;
14831
+ const length = styles.length;
14832
+ for (let i = 0; i < length; i += 1) {
14833
+ const char = styles[i];
14834
+ if (char === "'" && !inDoubleQuote) {
14835
+ inSingleQuote = !inSingleQuote;
14836
+ current += char;
14837
+ continue;
14838
+ }
14839
+ if (char === '"' && !inSingleQuote) {
14840
+ inDoubleQuote = !inDoubleQuote;
14841
+ current += char;
14842
+ continue;
14843
+ }
14844
+ if (!inSingleQuote && !inDoubleQuote) {
14845
+ if (char === "(") {
14846
+ parenDepth += 1;
14847
+ current += char;
14848
+ continue;
14849
+ }
14850
+ if (char === ")" && parenDepth > 0) {
14851
+ parenDepth -= 1;
14852
+ current += char;
14853
+ continue;
14854
+ }
14855
+ if (char === ";" && parenDepth === 0) {
14856
+ result.push(current);
14857
+ current = "";
14858
+ continue;
14859
+ }
14860
+ }
14861
+ current += char;
14862
+ }
14863
+ if (current) {
14864
+ result.push(current);
14865
+ }
14866
+ return result;
14867
+ }
14868
+ function parseStyleEntries(styles) {
14869
+ const pairs = [];
14870
+ const declarations = splitStyleDeclarations(styles || "");
14871
+ const numDeclarations = declarations.length;
14872
+ for (let i = 0; i < numDeclarations; i += 1) {
14873
+ const declaration = declarations[i];
14874
+ const firstColonIndex = declaration.indexOf(":");
14875
+ if (firstColonIndex === -1) {
14876
+ continue;
14877
+ }
14878
+ const property = declaration.slice(0, firstColonIndex).trim();
14879
+ const value = declaration.slice(firstColonIndex + 1).trim();
14880
+ if (property && value) {
14881
+ pairs.push([property, value]);
14882
+ }
14883
+ }
14884
+ return pairs;
14885
+ }
14821
14886
  function mergeAttributes(...objects) {
14822
14887
  return objects.filter((item) => !!item).reduce((items, item) => {
14823
14888
  const mergedAttributes = { ...items };
@@ -14833,17 +14898,7 @@ function mergeAttributes(...objects) {
14833
14898
  const insertClasses = valueClasses.filter((valueClass) => !existingClasses.includes(valueClass));
14834
14899
  mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
14835
14900
  } else if (key === "style") {
14836
- const newStyles = value ? value.split(";").map((style2) => style2.trim()).filter(Boolean) : [];
14837
- const existingStyles = mergedAttributes[key] ? mergedAttributes[key].split(";").map((style2) => style2.trim()).filter(Boolean) : [];
14838
- const styleMap = /* @__PURE__ */ new Map();
14839
- existingStyles.forEach((style2) => {
14840
- const [property, val] = style2.split(":").map((part) => part.trim());
14841
- styleMap.set(property, val);
14842
- });
14843
- newStyles.forEach((style2) => {
14844
- const [property, val] = style2.split(":").map((part) => part.trim());
14845
- styleMap.set(property, val);
14846
- });
14901
+ const styleMap = new Map([...parseStyleEntries(mergedAttributes[key]), ...parseStyleEntries(value)]);
14847
14902
  mergedAttributes[key] = Array.from(styleMap.entries()).map(([property, val]) => `${property}: ${val}`).join("; ");
14848
14903
  } else {
14849
14904
  mergedAttributes[key] = value;
@@ -15441,7 +15496,7 @@ function isNodeEmpty(node, {
15441
15496
  return true;
15442
15497
  }
15443
15498
  if (node.isText) {
15444
- return /^\s*$/m.test((_a = node.text) != null ? _a : "");
15499
+ return !/\S/.test((_a = node.text) != null ? _a : "");
15445
15500
  }
15446
15501
  }
15447
15502
  if (node.isText) {
@@ -15837,6 +15892,16 @@ var joinListForwards = (tr, listType) => {
15837
15892
  tr.join(after);
15838
15893
  return true;
15839
15894
  };
15895
+ function createInnerSelectionForWholeDocList(tr) {
15896
+ const doc = tr.doc;
15897
+ const list = doc.firstChild;
15898
+ if (!list) {
15899
+ return null;
15900
+ }
15901
+ const $start = doc.resolve(1);
15902
+ const $end = doc.resolve(list.nodeSize - 1);
15903
+ return TextSelection.between($start, $end);
15904
+ }
15840
15905
  var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr, state, dispatch, chain, commands, can }) => {
15841
15906
  const { extensions, splittableMarks } = editor.extensionManager;
15842
15907
  const listType = getNodeType(listTypeOrName, state.schema);
@@ -15849,13 +15914,35 @@ var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) =>
15849
15914
  return false;
15850
15915
  }
15851
15916
  const parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);
15852
- if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {
15853
- if (parentList.node.type === listType) {
15917
+ const isAllSelection = selection.from === 0 && selection.to === state.doc.content.size;
15918
+ const topLevelNodes = state.doc.content.content;
15919
+ const soleTopLevelNode = topLevelNodes.length === 1 ? topLevelNodes[0] : null;
15920
+ const allSelectionList = isAllSelection && soleTopLevelNode && isList(soleTopLevelNode.type.name, extensions) ? {
15921
+ node: soleTopLevelNode,
15922
+ pos: 0} : null;
15923
+ const currentList = parentList != null ? parentList : allSelectionList;
15924
+ const isInsideExistingList = !!parentList && range.depth >= 1 && range.depth - parentList.depth <= 1;
15925
+ const hasWholeDocSelectedList = !!allSelectionList;
15926
+ if ((isInsideExistingList || hasWholeDocSelectedList) && currentList) {
15927
+ if (currentList.node.type === listType) {
15928
+ if (isAllSelection && hasWholeDocSelectedList) {
15929
+ return chain().command(({ tr: trx, dispatch: disp }) => {
15930
+ const nextSelection = createInnerSelectionForWholeDocList(trx);
15931
+ if (!nextSelection) {
15932
+ return false;
15933
+ }
15934
+ trx.setSelection(nextSelection);
15935
+ if (disp) {
15936
+ disp(trx);
15937
+ }
15938
+ return true;
15939
+ }).liftListItem(itemType).run();
15940
+ }
15854
15941
  return commands.liftListItem(itemType);
15855
15942
  }
15856
- if (isList(parentList.node.type.name, extensions) && listType.validContent(parentList.node.content) && dispatch) {
15943
+ if (isList(currentList.node.type.name, extensions) && listType.validContent(currentList.node.content)) {
15857
15944
  return chain().command(() => {
15858
- tr.setNodeMarkup(parentList.pos, listType);
15945
+ tr.setNodeMarkup(currentList.pos, listType);
15859
15946
  return true;
15860
15947
  }).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
15861
15948
  }
@@ -17140,7 +17227,7 @@ var Delete = Extension.create({
17140
17227
  const newEnd = mapping.slice(index).map(step.to);
17141
17228
  const oldStart = mapping.invert().map(newStart, -1);
17142
17229
  const oldEnd = mapping.invert().map(newEnd);
17143
- const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
17230
+ const foundBeforeMark = newStart > 0 ? (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark)) : false;
17144
17231
  const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
17145
17232
  this.editor.emit("delete", {
17146
17233
  type: "mark",
@@ -18638,7 +18725,7 @@ var ResizableNodeView = class {
18638
18725
  const element = document.createElement("div");
18639
18726
  element.dataset.resizeContainer = "";
18640
18727
  element.dataset.node = this.node.type.name;
18641
- element.style.display = "flex";
18728
+ element.style.display = this.node.type.isInline ? "inline-flex" : "flex";
18642
18729
  if (this.classNames.container) {
18643
18730
  element.className = this.classNames.container;
18644
18731
  }
@@ -18978,6 +19065,14 @@ function canInsertNode(state, nodeType) {
18978
19065
  return false;
18979
19066
  }
18980
19067
 
19068
+ // src/utilities/htmlEntities.ts
19069
+ function decodeHtmlEntities(text) {
19070
+ return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
19071
+ }
19072
+ function encodeHtmlEntities(text) {
19073
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
19074
+ }
19075
+
18981
19076
  // src/utilities/markdown/index.ts
18982
19077
  var markdown_exports = {};
18983
19078
  __export$1(markdown_exports, {
@@ -19454,17 +19549,21 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
19454
19549
  const prefix = typeof prefixOrGenerator === "function" ? prefixOrGenerator(ctx) : prefixOrGenerator;
19455
19550
  const [content, ...children] = node.content;
19456
19551
  const mainContent = h2.renderChildren([content]);
19457
- const output = [`${prefix}${mainContent}`];
19552
+ let output = `${prefix}${mainContent}`;
19458
19553
  if (children && children.length > 0) {
19459
- children.forEach((child) => {
19460
- const childContent = h2.renderChildren([child]);
19461
- if (childContent) {
19462
- const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : "").join("\n");
19463
- output.push(indentedChild);
19554
+ children.forEach((child, index) => {
19555
+ var _a, _b;
19556
+ const childContent = (_b = (_a = h2.renderChild) == null ? void 0 : _a.call(h2, child, index + 1)) != null ? _b : h2.renderChildren([child]);
19557
+ if (childContent !== void 0 && childContent !== null) {
19558
+ const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : h2.indent("")).join("\n");
19559
+ output += child.type === "paragraph" ? `
19560
+
19561
+ ${indentedChild}` : `
19562
+ ${indentedChild}`;
19464
19563
  }
19465
19564
  });
19466
19565
  }
19467
- return output.join("\n");
19566
+ return output;
19468
19567
  }
19469
19568
 
19470
19569
  // src/MarkView.ts
@@ -19560,7 +19659,10 @@ function markPasteRule(config) {
19560
19659
  }
19561
19660
  markEnd = range.from + startSpaces + captureGroup.length;
19562
19661
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
19563
- tr.removeStoredMark(config.type);
19662
+ const isMatchAtEndOfText = match.index !== void 0 && match.input !== void 0 && match.index + match[0].length >= match.input.length;
19663
+ if (!isMatchAtEndOfText) {
19664
+ tr.removeStoredMark(config.type);
19665
+ }
19564
19666
  }
19565
19667
  }
19566
19668
  });
@@ -19672,13 +19774,13 @@ function findMarksToCloseAtEnd(activeMarks, currentMarks, nextNode, markSetsEqua
19672
19774
  if (isLastNode || nextNodeHasNoMarks || nextNodeHasDifferentMarks) {
19673
19775
  if (nextNode && nextNode.type === "text" && nextNode.marks) {
19674
19776
  const nextMarks = new Map(nextNode.marks.map((mark) => [mark.type, mark]));
19675
- Array.from(activeMarks.keys()).forEach((markType) => {
19777
+ Array.from(activeMarks.keys()).reverse().forEach((markType) => {
19676
19778
  if (!nextMarks.has(markType)) {
19677
19779
  marksToCloseAtEnd.push(markType);
19678
19780
  }
19679
19781
  });
19680
19782
  } else if (isLastNode || nextNodeHasNoMarks) {
19681
- marksToCloseAtEnd.push(...Array.from(activeMarks.keys()));
19783
+ marksToCloseAtEnd.push(...Array.from(activeMarks.keys()).reverse());
19682
19784
  }
19683
19785
  }
19684
19786
  return marksToCloseAtEnd;
@@ -19731,12 +19833,14 @@ var MarkdownManager = class {
19731
19833
  * @param options.extensions An array of Tiptap extensions to register for markdown parsing and rendering.
19732
19834
  */
19733
19835
  constructor(options) {
19836
+ this.activeParseLexer = null;
19734
19837
  this.baseExtensions = [];
19735
19838
  this.extensions = [];
19839
+ /** Set of extension names whose `code` spec property is truthy (nodes and marks). */
19840
+ this.codeTypes = /* @__PURE__ */ new Set();
19736
19841
  this.lastParseResult = null;
19737
19842
  var _a, _b, _c, _d, _e;
19738
19843
  this.markedInstance = (_a = options == null ? void 0 : options.marked) != null ? _a : g;
19739
- this.lexer = new this.markedInstance.Lexer();
19740
19844
  this.indentStyle = (_c = (_b = options == null ? void 0 : options.indentation) == null ? void 0 : _b.style) != null ? _c : "space";
19741
19845
  this.indentSize = (_e = (_d = options == null ? void 0 : options.indentation) == null ? void 0 : _d.size) != null ? _e : 2;
19742
19846
  this.baseExtensions = (options == null ? void 0 : options.extensions) || [];
@@ -19748,9 +19852,8 @@ var MarkdownManager = class {
19748
19852
  if (options == null ? void 0 : options.extensions) {
19749
19853
  this.baseExtensions = options.extensions;
19750
19854
  const flattened = flattenExtensions(options.extensions);
19751
- flattened.forEach((ext) => this.registerExtension(ext, false));
19855
+ flattened.forEach((ext) => this.registerExtension(ext));
19752
19856
  }
19753
- this.lexer = new this.markedInstance.Lexer();
19754
19857
  }
19755
19858
  /** Returns the underlying marked instance. */
19756
19859
  get instance() {
@@ -19773,22 +19876,28 @@ var MarkdownManager = class {
19773
19876
  * `markdownName`, `parseMarkdown`, `renderMarkdown` and `priority` from the
19774
19877
  * extension config (using the same resolution used across the codebase).
19775
19878
  */
19776
- registerExtension(extension, recreateLexer = true) {
19879
+ registerExtension(extension) {
19777
19880
  var _a, _b;
19778
19881
  this.extensions.push(extension);
19882
+ const isCode = callOrReturn(getExtensionField(extension, "code"));
19779
19883
  const name = extension.name;
19884
+ if (isCode) {
19885
+ this.codeTypes.add(name);
19886
+ }
19780
19887
  const tokenName = getExtensionField(extension, "markdownTokenName") || name;
19781
19888
  const parseMarkdown = getExtensionField(extension, "parseMarkdown");
19782
19889
  const renderMarkdown = getExtensionField(extension, "renderMarkdown");
19783
19890
  const tokenizer = getExtensionField(extension, "markdownTokenizer");
19784
19891
  const markdownCfg = (_a = getExtensionField(extension, "markdownOptions")) != null ? _a : null;
19785
19892
  const isIndenting = (_b = markdownCfg == null ? void 0 : markdownCfg.indentsContent) != null ? _b : false;
19893
+ const htmlReopen = markdownCfg == null ? void 0 : markdownCfg.htmlReopen;
19786
19894
  const spec = {
19787
19895
  tokenName,
19788
19896
  nodeName: name,
19789
19897
  parseMarkdown,
19790
19898
  renderMarkdown,
19791
19899
  isIndenting,
19900
+ htmlReopen,
19792
19901
  tokenizer
19793
19902
  };
19794
19903
  if (tokenName && parseMarkdown) {
@@ -19803,11 +19912,21 @@ var MarkdownManager = class {
19803
19912
  }
19804
19913
  if (tokenizer && this.hasMarked()) {
19805
19914
  this.registerTokenizer(tokenizer);
19806
- if (recreateLexer) {
19807
- this.lexer = new this.markedInstance.Lexer();
19808
- }
19809
19915
  }
19810
19916
  }
19917
+ createLexer() {
19918
+ return new this.markedInstance.Lexer();
19919
+ }
19920
+ createTokenizerHelpers(lexer) {
19921
+ return {
19922
+ inlineTokens: (src) => lexer.inlineTokens(src),
19923
+ blockTokens: (src) => lexer.blockTokens(src)
19924
+ };
19925
+ }
19926
+ tokenizeInline(src) {
19927
+ var _a;
19928
+ return ((_a = this.activeParseLexer) != null ? _a : this.createLexer()).inlineTokens(src);
19929
+ }
19811
19930
  /**
19812
19931
  * Register a custom tokenizer with marked.js for parsing non-standard markdown syntax.
19813
19932
  */
@@ -19816,20 +19935,12 @@ var MarkdownManager = class {
19816
19935
  return;
19817
19936
  }
19818
19937
  const { name, start, level = "inline", tokenize } = tokenizer;
19819
- const tokenizeInline = (src) => {
19820
- return this.lexer.inlineTokens(src);
19821
- };
19822
- const tokenizeBlock = (src) => {
19823
- return this.lexer.blockTokens(src);
19824
- };
19825
- const helper = {
19826
- inlineTokens: tokenizeInline,
19827
- blockTokens: tokenizeBlock
19828
- };
19938
+ const createTokenizerHelpers = this.createTokenizerHelpers.bind(this);
19939
+ const createLexer = this.createLexer.bind(this);
19829
19940
  let startCb;
19830
19941
  if (!start) {
19831
19942
  startCb = (src) => {
19832
- const result = tokenize(src, [], helper);
19943
+ const result = tokenize(src, [], this.createTokenizerHelpers(this.createLexer()));
19833
19944
  if (result && result.raw) {
19834
19945
  const index = src.indexOf(result.raw);
19835
19946
  return index;
@@ -19843,7 +19954,8 @@ var MarkdownManager = class {
19843
19954
  name,
19844
19955
  level,
19845
19956
  start: startCb,
19846
- tokenizer: (src, tokens) => {
19957
+ tokenizer(src, tokens) {
19958
+ const helper = this.lexer ? createTokenizerHelpers(this.lexer) : createTokenizerHelpers(createLexer());
19847
19959
  const result = tokenize(src, tokens, helper);
19848
19960
  if (result && result.type) {
19849
19961
  return {
@@ -19916,23 +20028,65 @@ var MarkdownManager = class {
19916
20028
  if (!this.hasMarked()) {
19917
20029
  throw new Error("No marked instance available for parsing");
19918
20030
  }
19919
- const tokens = this.markedInstance.lexer(markdown);
19920
- const content = this.parseTokens(tokens);
19921
- return {
19922
- type: "doc",
19923
- content
19924
- };
20031
+ const previousParseLexer = this.activeParseLexer;
20032
+ const parseLexer = this.createLexer();
20033
+ this.activeParseLexer = parseLexer;
20034
+ try {
20035
+ const tokens = parseLexer.lex(markdown);
20036
+ const content = this.parseTokens(tokens, true);
20037
+ return {
20038
+ type: "doc",
20039
+ content
20040
+ };
20041
+ } finally {
20042
+ this.activeParseLexer = previousParseLexer;
20043
+ }
19925
20044
  }
19926
20045
  /**
19927
20046
  * Convert an array of marked tokens into Tiptap JSON nodes using registered extension handlers.
19928
20047
  */
19929
- parseTokens(tokens) {
19930
- return tokens.map((token) => this.parseToken(token)).filter((parsed) => parsed !== null).flatMap((parsed) => Array.isArray(parsed) ? parsed : [parsed]);
20048
+ parseTokens(tokens, parseImplicitEmptyParagraphs = false) {
20049
+ const nonSpaceTokenIndexes = tokens.reduce((indexes, token, index) => {
20050
+ if (token.type !== "space") {
20051
+ indexes.push(index);
20052
+ }
20053
+ return indexes;
20054
+ }, []);
20055
+ let previousNonSpaceTokenIndex = -1;
20056
+ let nextNonSpaceTokenPointer = 0;
20057
+ return tokens.flatMap((token, index) => {
20058
+ var _a;
20059
+ while (nextNonSpaceTokenPointer < nonSpaceTokenIndexes.length && nonSpaceTokenIndexes[nextNonSpaceTokenPointer] < index) {
20060
+ previousNonSpaceTokenIndex = nonSpaceTokenIndexes[nextNonSpaceTokenPointer];
20061
+ nextNonSpaceTokenPointer += 1;
20062
+ }
20063
+ if (parseImplicitEmptyParagraphs && token.type === "space") {
20064
+ const nextNonSpaceTokenIndex = (_a = nonSpaceTokenIndexes[nextNonSpaceTokenPointer]) != null ? _a : -1;
20065
+ return this.createImplicitEmptyParagraphsFromSpace(token, previousNonSpaceTokenIndex, nextNonSpaceTokenIndex);
20066
+ }
20067
+ const parsed = this.parseToken(token, parseImplicitEmptyParagraphs);
20068
+ if (parsed === null) {
20069
+ return [];
20070
+ }
20071
+ return Array.isArray(parsed) ? parsed : [parsed];
20072
+ });
20073
+ }
20074
+ createImplicitEmptyParagraphsFromSpace(token, previousNonSpaceTokenIndex, nextNonSpaceTokenIndex) {
20075
+ const separatorCount = this.countParagraphSeparators(token.raw || "");
20076
+ if (separatorCount === 0) {
20077
+ return [];
20078
+ }
20079
+ const isBoundarySpace = previousNonSpaceTokenIndex === -1 || nextNonSpaceTokenIndex === -1;
20080
+ const emptyParagraphCount = Math.max(separatorCount - (isBoundarySpace ? 0 : 1), 0);
20081
+ return Array.from({ length: emptyParagraphCount }, () => ({ type: "paragraph", content: [] }));
20082
+ }
20083
+ countParagraphSeparators(raw) {
20084
+ return (raw.replace(/\r\n/g, "\n").match(/\n\n/g) || []).length;
19931
20085
  }
19932
20086
  /**
19933
20087
  * Parse a single token into Tiptap JSON using the appropriate registered handler.
19934
20088
  */
19935
- parseToken(token) {
20089
+ parseToken(token, parseImplicitEmptyParagraphs = false) {
19936
20090
  if (!token.type) {
19937
20091
  return null;
19938
20092
  }
@@ -19958,7 +20112,7 @@ var MarkdownManager = class {
19958
20112
  this.lastParseResult = null;
19959
20113
  return toReturn;
19960
20114
  }
19961
- return this.parseFallbackToken(token);
20115
+ return this.parseFallbackToken(token, parseImplicitEmptyParagraphs);
19962
20116
  }
19963
20117
  /**
19964
20118
  * Parse a list token, handling mixed bullet and task list items by splitting them into separate lists.
@@ -20017,7 +20171,7 @@ var MarkdownManager = class {
20017
20171
  indentLevel,
20018
20172
  checked: checked != null ? checked : false,
20019
20173
  text: mainContent,
20020
- tokens: this.lexer.inlineTokens(mainContent),
20174
+ tokens: this.tokenizeInline(mainContent),
20021
20175
  nestedTokens
20022
20176
  };
20023
20177
  }
@@ -20086,6 +20240,7 @@ var MarkdownManager = class {
20086
20240
  return {
20087
20241
  parseInline: (tokens) => this.parseInlineTokens(tokens),
20088
20242
  parseChildren: (tokens) => this.parseTokens(tokens),
20243
+ parseBlockChildren: (tokens) => this.parseTokens(tokens, true),
20089
20244
  createTextNode: (text, marks) => {
20090
20245
  const node = {
20091
20246
  type: "text",
@@ -20130,7 +20285,7 @@ var MarkdownManager = class {
20130
20285
  if (token.type === "text") {
20131
20286
  result.push({
20132
20287
  type: "text",
20133
- text: token.text || ""
20288
+ text: decodeHtmlEntities(token.text || "")
20134
20289
  });
20135
20290
  } else if (token.type === "html") {
20136
20291
  const raw = ((_b = (_a = token.raw) != null ? _a : token.text) != null ? _b : "").toString();
@@ -20244,7 +20399,7 @@ var MarkdownManager = class {
20244
20399
  /**
20245
20400
  * Fallback parsing for common tokens when no specific handler is registered.
20246
20401
  */
20247
- parseFallbackToken(token) {
20402
+ parseFallbackToken(token, parseImplicitEmptyParagraphs = false) {
20248
20403
  switch (token.type) {
20249
20404
  case "paragraph":
20250
20405
  return {
@@ -20260,7 +20415,7 @@ var MarkdownManager = class {
20260
20415
  case "text":
20261
20416
  return {
20262
20417
  type: "text",
20263
- text: token.text || ""
20418
+ text: decodeHtmlEntities(token.text || "")
20264
20419
  };
20265
20420
  case "html":
20266
20421
  return this.parseHTMLToken(token);
@@ -20268,7 +20423,7 @@ var MarkdownManager = class {
20268
20423
  return null;
20269
20424
  default:
20270
20425
  if (token.tokens) {
20271
- return this.parseTokens(token.tokens);
20426
+ return this.parseTokens(token.tokens, parseImplicitEmptyParagraphs);
20272
20427
  }
20273
20428
  return null;
20274
20429
  }
@@ -20315,10 +20470,18 @@ var MarkdownManager = class {
20315
20470
  throw new Error(`Failed to parse HTML in markdown: ${error}`);
20316
20471
  }
20317
20472
  }
20318
- renderNodeToMarkdown(node, parentNode, index = 0, level = 0) {
20473
+ /**
20474
+ * Encode HTML entities in text unless the node is inside a code context
20475
+ * (code mark or code-block parent) where literal characters should be preserved.
20476
+ */
20477
+ encodeTextForMarkdown(text, node, parentNode) {
20478
+ const isInsideCode = (parentNode == null ? void 0 : parentNode.type) != null && this.codeTypes.has(parentNode.type) || (node.marks || []).some((m) => this.codeTypes.has(typeof m === "string" ? m : m.type));
20479
+ return isInsideCode ? text : encodeHtmlEntities(text);
20480
+ }
20481
+ renderNodeToMarkdown(node, parentNode, index = 0, level = 0, meta = {}) {
20319
20482
  var _a;
20320
20483
  if (node.type === "text") {
20321
- return node.text || "";
20484
+ return this.encodeTextForMarkdown(node.text || "", node, parentNode);
20322
20485
  }
20323
20486
  if (!node.type) {
20324
20487
  return "";
@@ -20327,6 +20490,7 @@ var MarkdownManager = class {
20327
20490
  if (!handler) {
20328
20491
  return "";
20329
20492
  }
20493
+ const previousNode = Array.isArray(parentNode == null ? void 0 : parentNode.content) && index > 0 ? parentNode.content[index - 1] : void 0;
20330
20494
  const helpers = {
20331
20495
  renderChildren: (nodes, separator) => {
20332
20496
  const childLevel = handler.isIndenting ? level + 1 : level;
@@ -20335,6 +20499,10 @@ var MarkdownManager = class {
20335
20499
  }
20336
20500
  return this.renderNodes(nodes, node, separator || "", index, childLevel);
20337
20501
  },
20502
+ renderChild: (childNode, childIndex) => {
20503
+ const childLevel = handler.isIndenting ? level + 1 : level;
20504
+ return this.renderNodeToMarkdown(childNode, node, childIndex, childLevel);
20505
+ },
20338
20506
  indent: (content) => {
20339
20507
  return this.indentString + content;
20340
20508
  },
@@ -20344,8 +20512,10 @@ var MarkdownManager = class {
20344
20512
  index,
20345
20513
  level,
20346
20514
  parentType: parentNode == null ? void 0 : parentNode.type,
20515
+ previousNode,
20347
20516
  meta: {
20348
- parentAttrs: parentNode == null ? void 0 : parentNode.attrs
20517
+ parentAttrs: parentNode == null ? void 0 : parentNode.attrs,
20518
+ ...meta
20349
20519
  }
20350
20520
  };
20351
20521
  const rendered = ((_a = handler.renderMarkdown) == null ? void 0 : _a.call(handler, node, helpers, context)) || "";
@@ -20371,34 +20541,44 @@ var MarkdownManager = class {
20371
20541
  renderNodesWithMarkBoundaries(nodes, parentNode, separator = "", level = 0) {
20372
20542
  const result = [];
20373
20543
  const activeMarks = /* @__PURE__ */ new Map();
20544
+ const reopenWithHtmlOnNextOpen = /* @__PURE__ */ new Set();
20545
+ const markOpeningModes = /* @__PURE__ */ new Map();
20374
20546
  nodes.forEach((node, i) => {
20375
20547
  const nextNode = i < nodes.length - 1 ? nodes[i + 1] : null;
20376
20548
  if (!node.type) {
20377
20549
  return;
20378
20550
  }
20379
20551
  if (node.type === "text") {
20380
- let textContent = node.text || "";
20552
+ let textContent = this.encodeTextForMarkdown(node.text || "", node, parentNode);
20381
20553
  const currentMarks = new Map((node.marks || []).map((mark) => [mark.type, mark]));
20382
20554
  const marksToOpen = findMarksToOpen(activeMarks, currentMarks);
20383
20555
  const marksToClose = findMarksToClose(currentMarks, nextNode);
20556
+ const activeMarksClosingHere = marksToClose.filter((markType) => activeMarks.has(markType));
20557
+ const hasCrossedBoundary = activeMarksClosingHere.length > 0 && marksToOpen.length > 0;
20384
20558
  let middleTrailingWhitespace = "";
20385
- if (marksToClose.length > 0) {
20559
+ if (marksToClose.length > 0 && !hasCrossedBoundary) {
20386
20560
  const middleTrailingMatch = textContent.match(/(\s+)$/);
20387
20561
  if (middleTrailingMatch) {
20388
20562
  middleTrailingWhitespace = middleTrailingMatch[1];
20389
20563
  textContent = textContent.slice(0, -middleTrailingWhitespace.length);
20390
20564
  }
20391
20565
  }
20392
- marksToClose.forEach((markType) => {
20393
- const mark = currentMarks.get(markType);
20394
- const closeMarkdown = this.getMarkClosing(markType, mark);
20395
- if (closeMarkdown) {
20396
- textContent += closeMarkdown;
20397
- }
20398
- if (activeMarks.has(markType)) {
20399
- activeMarks.delete(markType);
20400
- }
20401
- });
20566
+ if (!hasCrossedBoundary) {
20567
+ marksToClose.forEach((markType) => {
20568
+ if (!activeMarks.has(markType)) {
20569
+ return;
20570
+ }
20571
+ const mark = currentMarks.get(markType);
20572
+ const closeMarkdown = this.getMarkClosing(markType, mark, markOpeningModes.get(markType));
20573
+ if (closeMarkdown) {
20574
+ textContent += closeMarkdown;
20575
+ }
20576
+ if (activeMarks.has(markType)) {
20577
+ activeMarks.delete(markType);
20578
+ markOpeningModes.delete(markType);
20579
+ }
20580
+ });
20581
+ }
20402
20582
  let leadingWhitespace = "";
20403
20583
  if (marksToOpen.length > 0) {
20404
20584
  const leadingMatch = textContent.match(/^(\s+)/);
@@ -20408,21 +20588,37 @@ var MarkdownManager = class {
20408
20588
  }
20409
20589
  }
20410
20590
  marksToOpen.forEach(({ type, mark }) => {
20411
- const openMarkdown = this.getMarkOpening(type, mark);
20591
+ const openingMode = reopenWithHtmlOnNextOpen.has(type) ? "html" : "markdown";
20592
+ const openMarkdown = this.getMarkOpening(type, mark, openingMode);
20412
20593
  if (openMarkdown) {
20413
20594
  textContent = openMarkdown + textContent;
20414
20595
  }
20415
- if (!marksToClose.includes(type)) {
20416
- activeMarks.set(type, mark);
20417
- }
20596
+ markOpeningModes.set(type, openingMode);
20597
+ reopenWithHtmlOnNextOpen.delete(type);
20418
20598
  });
20599
+ if (!hasCrossedBoundary) {
20600
+ marksToOpen.slice().reverse().forEach(({ type, mark }) => {
20601
+ activeMarks.set(type, mark);
20602
+ });
20603
+ }
20419
20604
  textContent = leadingWhitespace + textContent;
20420
- const marksToCloseAtEnd = findMarksToCloseAtEnd(
20421
- activeMarks,
20422
- currentMarks,
20423
- nextNode,
20424
- this.markSetsEqual.bind(this)
20425
- );
20605
+ let marksToCloseAtEnd;
20606
+ if (hasCrossedBoundary) {
20607
+ const nextMarkTypes = new Set(((nextNode == null ? void 0 : nextNode.marks) || []).map((mark) => mark.type));
20608
+ marksToOpen.forEach(({ type }) => {
20609
+ if (nextMarkTypes.has(type) && this.getHtmlReopenTags(type)) {
20610
+ reopenWithHtmlOnNextOpen.add(type);
20611
+ }
20612
+ });
20613
+ marksToCloseAtEnd = [
20614
+ ...marksToOpen.map((m) => m.type),
20615
+ // inner (opened here) — close first
20616
+ ...activeMarksClosingHere
20617
+ // outer (were active before) — close last
20618
+ ];
20619
+ } else {
20620
+ marksToCloseAtEnd = findMarksToCloseAtEnd(activeMarks, currentMarks, nextNode, this.markSetsEqual.bind(this));
20621
+ }
20426
20622
  let trailingWhitespace = "";
20427
20623
  if (marksToCloseAtEnd.length > 0) {
20428
20624
  const trailingMatch = textContent.match(/(\s+)$/);
@@ -20432,21 +20628,32 @@ var MarkdownManager = class {
20432
20628
  }
20433
20629
  }
20434
20630
  marksToCloseAtEnd.forEach((markType) => {
20435
- const mark = activeMarks.get(markType);
20436
- const closeMarkdown = this.getMarkClosing(markType, mark);
20631
+ var _a;
20632
+ const mark = (_a = activeMarks.get(markType)) != null ? _a : currentMarks.get(markType);
20633
+ const closeMarkdown = this.getMarkClosing(markType, mark, markOpeningModes.get(markType));
20437
20634
  if (closeMarkdown) {
20438
20635
  textContent += closeMarkdown;
20439
20636
  }
20440
20637
  activeMarks.delete(markType);
20638
+ markOpeningModes.delete(markType);
20441
20639
  });
20442
20640
  textContent += trailingWhitespace;
20443
20641
  textContent += middleTrailingWhitespace;
20444
20642
  result.push(textContent);
20445
20643
  } else {
20446
20644
  const marksToReopen = new Map(activeMarks);
20447
- const beforeMarkdown = closeMarksBeforeNode(activeMarks, this.getMarkClosing.bind(this));
20645
+ const openingModesToReopen = new Map(markOpeningModes);
20646
+ const beforeMarkdown = closeMarksBeforeNode(activeMarks, (markType, mark) => {
20647
+ return this.getMarkClosing(markType, mark, markOpeningModes.get(markType));
20648
+ });
20649
+ markOpeningModes.clear();
20448
20650
  const nodeContent = this.renderNodeToMarkdown(node, parentNode, i, level);
20449
- const afterMarkdown = node.type === "hardBreak" ? "" : reopenMarksAfterNode(marksToReopen, activeMarks, this.getMarkOpening.bind(this));
20651
+ const afterMarkdown = node.type === "hardBreak" ? "" : reopenMarksAfterNode(marksToReopen, activeMarks, (markType, mark) => {
20652
+ var _a;
20653
+ const openingMode = (_a = openingModesToReopen.get(markType)) != null ? _a : "markdown";
20654
+ markOpeningModes.set(markType, openingMode);
20655
+ return this.getMarkOpening(markType, mark, openingMode);
20656
+ });
20450
20657
  result.push(beforeMarkdown + nodeContent + afterMarkdown);
20451
20658
  }
20452
20659
  });
@@ -20455,7 +20662,11 @@ var MarkdownManager = class {
20455
20662
  /**
20456
20663
  * Get the opening markdown syntax for a mark type.
20457
20664
  */
20458
- getMarkOpening(markType, mark) {
20665
+ getMarkOpening(markType, mark, openingMode = "markdown") {
20666
+ var _a;
20667
+ if (openingMode === "html") {
20668
+ return ((_a = this.getHtmlReopenTags(markType)) == null ? void 0 : _a.open) || "";
20669
+ }
20459
20670
  const handlers = this.getHandlersForNodeType(markType);
20460
20671
  const handler = handlers.length > 0 ? handlers[0] : void 0;
20461
20672
  if (!handler || !handler.renderMarkdown) {
@@ -20472,6 +20683,7 @@ var MarkdownManager = class {
20472
20683
  syntheticNode,
20473
20684
  {
20474
20685
  renderChildren: () => placeholder,
20686
+ renderChild: () => placeholder,
20475
20687
  indent: (content) => content,
20476
20688
  wrapInBlock: (prefix, content) => prefix + content
20477
20689
  },
@@ -20486,7 +20698,11 @@ var MarkdownManager = class {
20486
20698
  /**
20487
20699
  * Get the closing markdown syntax for a mark type.
20488
20700
  */
20489
- getMarkClosing(markType, mark) {
20701
+ getMarkClosing(markType, mark, openingMode = "markdown") {
20702
+ var _a;
20703
+ if (openingMode === "html") {
20704
+ return ((_a = this.getHtmlReopenTags(markType)) == null ? void 0 : _a.close) || "";
20705
+ }
20490
20706
  const handlers = this.getHandlersForNodeType(markType);
20491
20707
  const handler = handlers.length > 0 ? handlers[0] : void 0;
20492
20708
  if (!handler || !handler.renderMarkdown) {
@@ -20503,6 +20719,7 @@ var MarkdownManager = class {
20503
20719
  syntheticNode,
20504
20720
  {
20505
20721
  renderChildren: () => placeholder,
20722
+ renderChild: () => placeholder,
20506
20723
  indent: (content) => content,
20507
20724
  wrapInBlock: (prefix, content) => prefix + content
20508
20725
  },
@@ -20515,6 +20732,15 @@ var MarkdownManager = class {
20515
20732
  throw new Error(`Failed to get mark closing for ${markType}: ${err}`);
20516
20733
  }
20517
20734
  }
20735
+ /**
20736
+ * Returns the inline HTML tags an extension exposes for overlap-boundary
20737
+ * reopen handling, if that mark explicitly opted into HTML reopen mode.
20738
+ */
20739
+ getHtmlReopenTags(markType) {
20740
+ const handlers = this.getHandlersForNodeType(markType);
20741
+ const handler = handlers.length > 0 ? handlers[0] : void 0;
20742
+ return handler == null ? void 0 : handler.htmlReopen;
20743
+ }
20518
20744
  /**
20519
20745
  * Check if two mark sets are equal.
20520
20746
  */
@@ -20657,7 +20883,9 @@ var Blockquote = Node3.create({
20657
20883
  return /* @__PURE__ */ h("blockquote", { ...mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), children: /* @__PURE__ */ h("slot", {}) });
20658
20884
  },
20659
20885
  parseMarkdown: (token, helpers) => {
20660
- return helpers.createNode("blockquote", void 0, helpers.parseChildren(token.tokens || []));
20886
+ var _a;
20887
+ const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
20888
+ return helpers.createNode("blockquote", void 0, parseBlockChildren(token.tokens || []));
20661
20889
  },
20662
20890
  renderMarkdown: (node, h) => {
20663
20891
  if (!node.content) {
@@ -20665,8 +20893,9 @@ var Blockquote = Node3.create({
20665
20893
  }
20666
20894
  const prefix = ">";
20667
20895
  const result = [];
20668
- node.content.forEach((child) => {
20669
- const childContent = h.renderChildren([child]);
20896
+ node.content.forEach((child, index) => {
20897
+ var _a, _b;
20898
+ const childContent = (_b = (_a = h.renderChild) == null ? void 0 : _a.call(h, child, index)) != null ? _b : h.renderChildren([child]);
20670
20899
  const lines = childContent.split("\n");
20671
20900
  const linesWithPrefix = lines.map((line) => {
20672
20901
  if (line.trim() === "") {
@@ -20746,6 +20975,12 @@ var Bold = Mark.create({
20746
20975
  parseMarkdown: (token, helpers) => {
20747
20976
  return helpers.applyMark("bold", helpers.parseInline(token.tokens || []));
20748
20977
  },
20978
+ markdownOptions: {
20979
+ htmlReopen: {
20980
+ open: "<strong>",
20981
+ close: "</strong>"
20982
+ }
20983
+ },
20749
20984
  renderMarkdown: (node, h) => {
20750
20985
  return `**${h.renderChildren(node)}**`;
20751
20986
  },
@@ -20926,8 +21161,8 @@ var CodeBlock = Node3.create({
20926
21161
  },
20927
21162
  markdownTokenName: "code",
20928
21163
  parseMarkdown: (token, helpers) => {
20929
- var _a;
20930
- if (((_a = token.raw) == null ? void 0 : _a.startsWith("```")) === false && token.codeBlockStyle !== "indented") {
21164
+ var _a, _b;
21165
+ if (((_a = token.raw) == null ? void 0 : _a.startsWith("```")) === false && ((_b = token.raw) == null ? void 0 : _b.startsWith("~~~")) === false && token.codeBlockStyle !== "indented") {
20931
21166
  return [];
20932
21167
  }
20933
21168
  return helpers.createNode(
@@ -21455,6 +21690,12 @@ var Italic = Mark.create({
21455
21690
  parseMarkdown: (token, helpers) => {
21456
21691
  return helpers.applyMark("italic", helpers.parseInline(token.tokens || []));
21457
21692
  },
21693
+ markdownOptions: {
21694
+ htmlReopen: {
21695
+ open: "<em>",
21696
+ close: "</em>"
21697
+ }
21698
+ },
21458
21699
  renderMarkdown: (node, h) => {
21459
21700
  return `*${h.renderChildren(node)}*`;
21460
21701
  },
@@ -23758,14 +23999,16 @@ var ListItem = Node3.create({
23758
23999
  },
23759
24000
  markdownTokenName: "list_item",
23760
24001
  parseMarkdown: (token, helpers) => {
24002
+ var _a;
23761
24003
  if (token.type !== "list_item") {
23762
24004
  return [];
23763
24005
  }
24006
+ const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
23764
24007
  let content = [];
23765
24008
  if (token.tokens && token.tokens.length > 0) {
23766
24009
  const hasParagraphTokens = token.tokens.some((t) => t.type === "paragraph");
23767
24010
  if (hasParagraphTokens) {
23768
- content = helpers.parseChildren(token.tokens);
24011
+ content = parseBlockChildren(token.tokens);
23769
24012
  } else {
23770
24013
  const firstToken = token.tokens[0];
23771
24014
  if (firstToken && firstToken.type === "text" && firstToken.tokens && firstToken.tokens.length > 0) {
@@ -23778,11 +24021,11 @@ var ListItem = Node3.create({
23778
24021
  ];
23779
24022
  if (token.tokens.length > 1) {
23780
24023
  const remainingTokens = token.tokens.slice(1);
23781
- const additionalContent = helpers.parseChildren(remainingTokens);
24024
+ const additionalContent = parseBlockChildren(remainingTokens);
23782
24025
  content.push(...additionalContent);
23783
24026
  }
23784
24027
  } else {
23785
- content = helpers.parseChildren(token.tokens);
24028
+ content = parseBlockChildren(token.tokens);
23786
24029
  }
23787
24030
  }
23788
24031
  }
@@ -24087,6 +24330,36 @@ var ListKeymap = Extension.create({
24087
24330
  // src/ordered-list/utils.ts
24088
24331
  var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
24089
24332
  var INDENTED_LINE_REGEX = /^\s/;
24333
+ function isBlockContentLine(line) {
24334
+ const trimmedLine = line.trimStart();
24335
+ return /^[-+*]\s+/.test(trimmedLine) || /^\d+\.\s+/.test(trimmedLine) || /^>\s?/.test(trimmedLine) || /^```/.test(trimmedLine) || /^~~~/.test(trimmedLine);
24336
+ }
24337
+ function splitItemContent(contentLines) {
24338
+ const paragraphLines = [];
24339
+ const blockLines = [];
24340
+ let reachedBlockBoundary = false;
24341
+ contentLines.forEach((line) => {
24342
+ if (reachedBlockBoundary) {
24343
+ blockLines.push(line);
24344
+ return;
24345
+ }
24346
+ if (line.trim() === "") {
24347
+ reachedBlockBoundary = true;
24348
+ blockLines.push(line);
24349
+ return;
24350
+ }
24351
+ if (paragraphLines.length > 0 && isBlockContentLine(line)) {
24352
+ reachedBlockBoundary = true;
24353
+ blockLines.push(line);
24354
+ return;
24355
+ }
24356
+ paragraphLines.push(line);
24357
+ });
24358
+ return {
24359
+ paragraphLines,
24360
+ blockLines
24361
+ };
24362
+ }
24090
24363
  function collectOrderedListItems(lines) {
24091
24364
  const listItems = [];
24092
24365
  let currentLineIndex = 0;
@@ -24099,9 +24372,10 @@ function collectOrderedListItems(lines) {
24099
24372
  }
24100
24373
  const [, indent, number, content] = match;
24101
24374
  const indentLevel = indent.length;
24102
- let itemContent = content;
24375
+ const itemContentLines = [content];
24103
24376
  let nextLineIndex = currentLineIndex + 1;
24104
24377
  const itemLines = [line];
24378
+ let sawBlankLine = false;
24105
24379
  while (nextLineIndex < lines.length) {
24106
24380
  const nextLine = lines[nextLineIndex];
24107
24381
  const nextMatch = nextLine.match(ORDERED_LIST_ITEM_REGEX);
@@ -24110,21 +24384,27 @@ function collectOrderedListItems(lines) {
24110
24384
  }
24111
24385
  if (nextLine.trim() === "") {
24112
24386
  itemLines.push(nextLine);
24113
- itemContent += "\n";
24387
+ itemContentLines.push("");
24388
+ sawBlankLine = true;
24114
24389
  nextLineIndex += 1;
24115
24390
  } else if (nextLine.match(INDENTED_LINE_REGEX)) {
24116
24391
  itemLines.push(nextLine);
24117
- itemContent += `
24118
- ${nextLine.slice(indentLevel + 2)}`;
24392
+ itemContentLines.push(nextLine.slice(indentLevel + 2));
24119
24393
  nextLineIndex += 1;
24120
24394
  } else {
24121
- break;
24395
+ if (sawBlankLine) {
24396
+ break;
24397
+ }
24398
+ itemLines.push(nextLine);
24399
+ itemContentLines.push(nextLine);
24400
+ nextLineIndex += 1;
24122
24401
  }
24123
24402
  }
24124
24403
  listItems.push({
24125
24404
  indent: indentLevel,
24126
24405
  number: parseInt(number, 10),
24127
- content: itemContent.trim(),
24406
+ content: itemContentLines.join("\n").trim(),
24407
+ contentLines: itemContentLines,
24128
24408
  raw: itemLines.join("\n")
24129
24409
  });
24130
24410
  consumed = nextLineIndex;
@@ -24133,14 +24413,13 @@ ${nextLine.slice(indentLevel + 2)}`;
24133
24413
  return [listItems, consumed];
24134
24414
  }
24135
24415
  function buildNestedStructure(items, baseIndent, lexer) {
24136
- var _a;
24137
24416
  const result = [];
24138
24417
  let currentIndex = 0;
24139
24418
  while (currentIndex < items.length) {
24140
24419
  const item = items[currentIndex];
24141
24420
  if (item.indent === baseIndent) {
24142
- const contentLines = item.content.split("\n");
24143
- const mainText = ((_a = contentLines[0]) == null ? void 0 : _a.trim()) || "";
24421
+ const { paragraphLines, blockLines } = splitItemContent(item.contentLines);
24422
+ const mainText = paragraphLines.join("\n").trim();
24144
24423
  const tokens = [];
24145
24424
  if (mainText) {
24146
24425
  tokens.push({
@@ -24149,7 +24428,7 @@ function buildNestedStructure(items, baseIndent, lexer) {
24149
24428
  tokens: lexer.inlineTokens(mainText)
24150
24429
  });
24151
24430
  }
24152
- const additionalContent = contentLines.slice(1).join("\n").trim();
24431
+ const additionalContent = blockLines.join("\n").trim();
24153
24432
  if (additionalContent) {
24154
24433
  const blockTokens = lexer.blockTokens(additionalContent);
24155
24434
  tokens.push(...blockTokens);
@@ -24726,18 +25005,22 @@ var Paragraph = Node3.create({
24726
25005
  return helpers.parseChildren([tokens[0]]);
24727
25006
  }
24728
25007
  const content = helpers.parseInline(tokens);
24729
- if (content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
25008
+ const hasExplicitEmptyParagraphMarker = tokens.length === 1 && tokens[0].type === "text" && (tokens[0].raw === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].text === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].raw === NBSP_CHAR || tokens[0].text === NBSP_CHAR);
25009
+ if (hasExplicitEmptyParagraphMarker && content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
24730
25010
  return helpers.createNode("paragraph", void 0, []);
24731
25011
  }
24732
25012
  return helpers.createNode("paragraph", void 0, content);
24733
25013
  },
24734
- renderMarkdown: (node, h) => {
25014
+ renderMarkdown: (node, h, ctx) => {
25015
+ var _a, _b;
24735
25016
  if (!node) {
24736
25017
  return "";
24737
25018
  }
24738
25019
  const content = Array.isArray(node.content) ? node.content : [];
24739
25020
  if (content.length === 0) {
24740
- return EMPTY_PARAGRAPH_MARKDOWN;
25021
+ const previousContent = Array.isArray((_a = ctx == null ? void 0 : ctx.previousNode) == null ? void 0 : _a.content) ? ctx.previousNode.content : [];
25022
+ const previousNodeIsEmptyParagraph = ((_b = ctx == null ? void 0 : ctx.previousNode) == null ? void 0 : _b.type) === "paragraph" && previousContent.length === 0;
25023
+ return previousNodeIsEmptyParagraph ? EMPTY_PARAGRAPH_MARKDOWN : "";
24741
25024
  }
24742
25025
  return h.renderChildren(content);
24743
25026
  },
@@ -25869,7 +26152,7 @@ function history(config = {}) {
25869
26152
  beforeinput(view, e) {
25870
26153
  let inputType = e.inputType;
25871
26154
  let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
25872
- if (!command)
26155
+ if (!command || !view.editable)
25873
26156
  return false;
25874
26157
  e.preventDefault();
25875
26158
  return command(view.state, view.dispatch);
@@ -26120,6 +26403,9 @@ Extension.create({
26120
26403
  doc.descendants((node, pos) => {
26121
26404
  const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
26122
26405
  const isEmpty = !node.isLeaf && isNodeEmpty(node);
26406
+ if (!node.type.isTextblock) {
26407
+ return this.options.includeChildren;
26408
+ }
26123
26409
  if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
26124
26410
  const classes = [this.options.emptyNodeClass];
26125
26411
  if (isEmptyDoc) {
@@ -26173,6 +26459,7 @@ Extension.create({
26173
26459
  ];
26174
26460
  }
26175
26461
  });
26462
+ var skipTrailingNodeMeta = "skipTrailingNode";
26176
26463
  function nodeEqualsType({ types, node }) {
26177
26464
  return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
26178
26465
  }
@@ -26192,11 +26479,14 @@ var TrailingNode = Extension.create({
26192
26479
  return [
26193
26480
  new Plugin({
26194
26481
  key: plugin,
26195
- appendTransaction: (_, __, state) => {
26482
+ appendTransaction: (transactions, __, state) => {
26196
26483
  const { doc, tr, schema } = state;
26197
26484
  const shouldInsertNodeAtEnd = plugin.getState(state);
26198
26485
  const endPosition = doc.content.size;
26199
26486
  const type = schema.nodes[defaultNode];
26487
+ if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
26488
+ return;
26489
+ }
26200
26490
  if (!shouldInsertNodeAtEnd) {
26201
26491
  return;
26202
26492
  }