@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.
- package/dist/cjs/{chunk.5JY5FUCG-BJJbNIiG.js → chunk.5JY5FUCG-BDpED7an.js} +2 -2
- package/dist/cjs/{chunk.HVTXQL7M-C6x_EQ24.js → chunk.HVTXQL7M-CkQwB4ew.js} +4 -4
- package/dist/cjs/{chunk.URTPIBTY-BiNv2Ckb.js → chunk.URTPIBTY-De5L-27M.js} +3 -3
- package/dist/cjs/{chunk.XQ2OKYYA-CDJtWcvs.js → chunk.XQ2OKYYA-CZfHjZJv.js} +4 -4
- package/dist/cjs/{chunk.YHLNUJ7P-CoQhYOM2.js → chunk.YHLNUJ7P-C7S3ShkT.js} +1 -1
- package/dist/cjs/chunk.ZGGPD2XJ-DGjeHZ7b.js +5 -0
- package/dist/cjs/{class-map-CyEFRZYn.js → class-map-D_80IxYF.js} +1 -1
- package/dist/cjs/contacts.cjs.js +2 -2
- package/dist/cjs/{if-defined-TQmAS6tz.js → if-defined-BNj5GZso.js} +1 -1
- package/dist/cjs/{index-DdRXU5II.js → index-BiY-p204.js} +62 -20
- package/dist/cjs/{index-CpATWk39.js → index-D8Y89icW.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pos-add-literal-value_3.cjs.entry.js +6 -6
- package/dist/cjs/pos-add-new-thing_7.cjs.entry.js +9 -9
- package/dist/cjs/pos-app-browser.cjs.entry.js +2 -2
- package/dist/cjs/pos-app-dashboard_6.cjs.entry.js +3 -3
- package/dist/cjs/pos-app-document-viewer.cjs.entry.js +1 -1
- package/dist/cjs/pos-app-generic.cjs.entry.js +1 -1
- package/dist/cjs/pos-app-image-viewer.cjs.entry.js +1 -1
- package/dist/cjs/pos-app-ldp-container.cjs.entry.js +1 -1
- package/dist/cjs/pos-app-rdf-document.cjs.entry.js +1 -1
- package/dist/cjs/pos-app_24.cjs.entry.js +9 -9
- package/dist/cjs/pos-attachments.cjs.entry.js +1 -1
- package/dist/cjs/pos-container-contents.cjs.entry.js +1 -1
- package/dist/cjs/pos-container-item_3.cjs.entry.js +6 -6
- package/dist/cjs/pos-description_2.cjs.entry.js +1 -1
- package/dist/cjs/pos-document.cjs.entry.js +6 -6
- package/dist/cjs/pos-list.cjs.entry.js +1 -1
- package/dist/cjs/pos-make-findable_2.cjs.entry.js +7 -7
- package/dist/cjs/pos-markdown-document.cjs.entry.js +413 -123
- package/dist/cjs/pos-new-thing-form.cjs.entry.js +1 -1
- package/dist/cjs/pos-predicate.cjs.entry.js +6 -6
- package/dist/cjs/pos-relations_2.cjs.entry.js +1 -1
- package/dist/cjs/pos-select-term.cjs.entry.js +1 -1
- package/dist/cjs/pos-subjects.cjs.entry.js +1 -1
- package/dist/cjs/pos-tool-attachments.cjs.entry.js +1 -1
- package/dist/cjs/pos-tool-select.cjs.entry.js +3 -3
- package/dist/cjs/pos-value.cjs.entry.js +1 -1
- package/dist/cjs/{session-kBhmup9r.js → session-CW2xZDbl.js} +1 -1
- package/dist/cjs/{settings-CpwCCkhx.js → settings-D2bZj29K.js} +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/components/pos-markdown-document2.js +1 -1
- package/dist/contacts/contacts.esm.js +1 -1
- package/dist/contacts/{p-78715d17.entry.js → p-11dd66c9.entry.js} +1 -1
- package/dist/contacts/{p-6d4ec7e5.entry.js → p-1943a383.entry.js} +1 -1
- package/dist/contacts/{p-46f8861e.entry.js → p-3c4fada1.entry.js} +1 -1
- package/dist/contacts/{p-ce6b4a9a.entry.js → p-3c6684c3.entry.js} +1 -1
- package/dist/contacts/{p-c4a1c42a.entry.js → p-4c02d7b7.entry.js} +1 -1
- package/dist/contacts/p-4da8f636.entry.js +1 -0
- package/dist/contacts/{p-84fdbc1a.entry.js → p-58ce4289.entry.js} +1 -1
- package/dist/contacts/{p-C1XsyD29.js → p-5RplWyqs.js} +1 -1
- package/dist/contacts/{p-649e7365.entry.js → p-5ae55c52.entry.js} +1 -1
- package/dist/contacts/{p-40b2d792.entry.js → p-5df07840.entry.js} +1 -1
- package/dist/contacts/{p-92fcdd59.entry.js → p-63e52cba.entry.js} +1 -1
- package/dist/contacts/{p-76382e6a.entry.js → p-6f9152d8.entry.js} +1 -1
- package/dist/contacts/p-7a60ece3.entry.js +1 -0
- package/dist/contacts/{p-a9d03996.entry.js → p-7aded942.entry.js} +1 -1
- package/dist/contacts/{p-7a01c820.entry.js → p-7cf756ed.entry.js} +1 -1
- package/dist/contacts/{p-c89722f1.entry.js → p-908587ff.entry.js} +1 -1
- package/dist/contacts/{p-a629ae72.entry.js → p-9f34648a.entry.js} +1 -1
- package/dist/contacts/{p-B0_xZCeV.js → p-B3jnBMMO.js} +3 -3
- package/dist/contacts/{p-C8LPXtIR.js → p-BvR_sP9G.js} +1 -1
- package/dist/contacts/{p-Bug_w-vi.js → p-C36YDIjT.js} +1 -1
- package/dist/contacts/{p-BXdS2klL.js → p-CzUN2DJY.js} +4 -4
- package/dist/contacts/p-D8UlKjrD.js +1 -0
- package/dist/contacts/{p-BXcFVJku.js → p-Dq6SRSqM.js} +2 -2
- package/dist/contacts/{p-DScSUBy-.js → p-Dunlf3Z7.js} +1 -1
- package/dist/contacts/{p-BkeypvMo.js → p-VfX5yLuQ.js} +7 -7
- package/dist/contacts/{p-SrdKoY3I.js → p-_eHMN8WS.js} +1 -1
- package/dist/contacts/{p-7f565d49.entry.js → p-a0da8fbf.entry.js} +1 -1
- package/dist/contacts/{p-d510fa6c.entry.js → p-a52ee32d.entry.js} +5 -5
- package/dist/contacts/{p-7d796ba8.entry.js → p-bbb51116.entry.js} +8 -8
- package/dist/contacts/{p-4ef3891c.entry.js → p-be0458af.entry.js} +1 -1
- package/dist/contacts/{p-ecf8719a.entry.js → p-be2bfaf2.entry.js} +1 -1
- package/dist/contacts/{p-D_nUMgR-.js → p-bf6nCqHq.js} +1 -1
- package/dist/contacts/{p-ae43e046.entry.js → p-c9d40209.entry.js} +1 -1
- package/dist/contacts/{p-f8517ff2.entry.js → p-d762c42d.entry.js} +1 -1
- package/dist/contacts/{p-26248da8.entry.js → p-dc6b0fb2.entry.js} +1 -1
- package/dist/contacts/{p-68gi0rt1.js → p-dsdWvqdi.js} +3 -3
- package/dist/contacts/{p-c306d8ca.entry.js → p-f403a62e.entry.js} +1 -1
- package/dist/contacts/p-feaa607e.entry.js +1 -0
- package/dist/esm/{chunk.5JY5FUCG-B58l5Mdn.js → chunk.5JY5FUCG-CPET0g0y.js} +2 -2
- package/dist/esm/{chunk.HVTXQL7M-DXJDg6h_.js → chunk.HVTXQL7M-Bo9_AX3Z.js} +4 -4
- package/dist/esm/{chunk.URTPIBTY-C1YI_wtI.js → chunk.URTPIBTY-Cec1N58N.js} +3 -3
- package/dist/esm/{chunk.XQ2OKYYA-B0surOUs.js → chunk.XQ2OKYYA-CdgFL-s-.js} +4 -4
- package/dist/esm/{chunk.YHLNUJ7P-B10Qbx9i.js → chunk.YHLNUJ7P-nIbF6vRN.js} +1 -1
- package/dist/esm/chunk.ZGGPD2XJ-BsTqrynL.js +3 -0
- package/dist/esm/{class-map-DcKoKhP0.js → class-map-BnsoOzsP.js} +1 -1
- package/dist/esm/contacts.js +3 -3
- package/dist/esm/{if-defined-TtuUo8or.js → if-defined-CmT83CRs.js} +1 -1
- package/dist/esm/{index-D4tjvI9D.js → index-CkwiZvFT.js} +1 -1
- package/dist/esm/{index-DScSUBy-.js → index-Dunlf3Z7.js} +61 -19
- package/dist/esm/loader.js +2 -2
- package/dist/esm/pos-add-literal-value_3.entry.js +6 -6
- package/dist/esm/pos-add-new-thing_7.entry.js +9 -9
- package/dist/esm/pos-app-browser.entry.js +2 -2
- package/dist/esm/pos-app-dashboard_6.entry.js +3 -3
- package/dist/esm/pos-app-document-viewer.entry.js +1 -1
- package/dist/esm/pos-app-generic.entry.js +1 -1
- package/dist/esm/pos-app-image-viewer.entry.js +1 -1
- package/dist/esm/pos-app-ldp-container.entry.js +1 -1
- package/dist/esm/pos-app-rdf-document.entry.js +1 -1
- package/dist/esm/pos-app_24.entry.js +9 -9
- package/dist/esm/pos-attachments.entry.js +1 -1
- package/dist/esm/pos-container-contents.entry.js +1 -1
- package/dist/esm/pos-container-item_3.entry.js +6 -6
- package/dist/esm/pos-description_2.entry.js +1 -1
- package/dist/esm/pos-document.entry.js +6 -6
- package/dist/esm/pos-list.entry.js +1 -1
- package/dist/esm/pos-make-findable_2.entry.js +7 -7
- package/dist/esm/pos-markdown-document.entry.js +413 -123
- package/dist/esm/pos-new-thing-form.entry.js +1 -1
- package/dist/esm/pos-predicate.entry.js +6 -6
- package/dist/esm/pos-relations_2.entry.js +1 -1
- package/dist/esm/pos-select-term.entry.js +1 -1
- package/dist/esm/pos-subjects.entry.js +1 -1
- package/dist/esm/pos-tool-attachments.entry.js +1 -1
- package/dist/esm/pos-tool-select.entry.js +3 -3
- package/dist/esm/pos-value.entry.js +1 -1
- package/dist/esm/{session-CtUoUtdF.js → session-VqDg66f5.js} +1 -1
- package/dist/esm/{settings-Cnw1mSJw.js → settings-CbiYsH1V.js} +1 -1
- package/package.json +3 -3
- package/dist/cjs/chunk.ZGGPD2XJ-C--tZiyf.js +0 -5
- package/dist/contacts/p-5e11ce90.entry.js +0 -1
- package/dist/contacts/p-8bc26fd9.entry.js +0 -1
- package/dist/contacts/p-Bk6kpzHk.js +0 -1
- package/dist/contacts/p-a3082900.entry.js +0 -1
- package/dist/esm/chunk.ZGGPD2XJ-CxH68zCl.js +0 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$1 = require('./index-
|
|
3
|
+
var index$1 = require('./index-BiY-p204.js');
|
|
4
4
|
var index = require('./index-DlHQ3blV.js');
|
|
5
|
-
require('./chunk.ZGGPD2XJ-
|
|
6
|
-
require('./chunk.YHLNUJ7P-
|
|
5
|
+
require('./chunk.ZGGPD2XJ-DGjeHZ7b.js');
|
|
6
|
+
require('./chunk.YHLNUJ7P-C7S3ShkT.js');
|
|
7
7
|
|
|
8
8
|
// ::- Persistent data structure representing an ordered mapping from
|
|
9
9
|
// strings to values, with some convenient update methods.
|
|
@@ -13881,7 +13881,6 @@ function isMarkInSet(marks, type, attributes = {}) {
|
|
|
13881
13881
|
return !!findMarkInSet(marks, type, attributes);
|
|
13882
13882
|
}
|
|
13883
13883
|
function getMarkRange($pos, type, attributes) {
|
|
13884
|
-
var _a;
|
|
13885
13884
|
if (!$pos || !type) {
|
|
13886
13885
|
return;
|
|
13887
13886
|
}
|
|
@@ -13892,7 +13891,12 @@ function getMarkRange($pos, type, attributes) {
|
|
|
13892
13891
|
if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
|
|
13893
13892
|
return;
|
|
13894
13893
|
}
|
|
13895
|
-
|
|
13894
|
+
if (!attributes) {
|
|
13895
|
+
const firstMark = start.node.marks.find((mark2) => mark2.type === type);
|
|
13896
|
+
if (firstMark) {
|
|
13897
|
+
attributes = firstMark.attrs;
|
|
13898
|
+
}
|
|
13899
|
+
}
|
|
13896
13900
|
const mark = findMarkInSet([...start.node.marks], type, attributes);
|
|
13897
13901
|
if (!mark) {
|
|
13898
13902
|
return;
|
|
@@ -13927,7 +13931,7 @@ function getMarkType(nameOrType, schema) {
|
|
|
13927
13931
|
}
|
|
13928
13932
|
|
|
13929
13933
|
// src/commands/extendMarkRange.ts
|
|
13930
|
-
var extendMarkRange = (typeOrName, attributes
|
|
13934
|
+
var extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
|
|
13931
13935
|
const type = getMarkType(typeOrName, state.schema);
|
|
13932
13936
|
const { doc, selection } = tr;
|
|
13933
13937
|
const { $from, from, to } = selection;
|
|
@@ -14262,7 +14266,7 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
14262
14266
|
const fromSelectionAtStart = $from.parentOffset === 0;
|
|
14263
14267
|
const isTextSelection2 = $fromNode.isText || $fromNode.isTextblock;
|
|
14264
14268
|
const hasContent = $fromNode.content.size > 0;
|
|
14265
|
-
if (fromSelectionAtStart && isTextSelection2 && hasContent) {
|
|
14269
|
+
if (fromSelectionAtStart && isTextSelection2 && hasContent && isOnlyBlockContent) {
|
|
14266
14270
|
from = Math.max(0, from - 1);
|
|
14267
14271
|
}
|
|
14268
14272
|
tr.replaceWith(from, to, newContent);
|
|
@@ -14820,6 +14824,67 @@ function getAttributesFromExtensions(extensions) {
|
|
|
14820
14824
|
}
|
|
14821
14825
|
|
|
14822
14826
|
// src/utilities/mergeAttributes.ts
|
|
14827
|
+
function splitStyleDeclarations(styles) {
|
|
14828
|
+
const result = [];
|
|
14829
|
+
let current = "";
|
|
14830
|
+
let inSingleQuote = false;
|
|
14831
|
+
let inDoubleQuote = false;
|
|
14832
|
+
let parenDepth = 0;
|
|
14833
|
+
const length = styles.length;
|
|
14834
|
+
for (let i = 0; i < length; i += 1) {
|
|
14835
|
+
const char = styles[i];
|
|
14836
|
+
if (char === "'" && !inDoubleQuote) {
|
|
14837
|
+
inSingleQuote = !inSingleQuote;
|
|
14838
|
+
current += char;
|
|
14839
|
+
continue;
|
|
14840
|
+
}
|
|
14841
|
+
if (char === '"' && !inSingleQuote) {
|
|
14842
|
+
inDoubleQuote = !inDoubleQuote;
|
|
14843
|
+
current += char;
|
|
14844
|
+
continue;
|
|
14845
|
+
}
|
|
14846
|
+
if (!inSingleQuote && !inDoubleQuote) {
|
|
14847
|
+
if (char === "(") {
|
|
14848
|
+
parenDepth += 1;
|
|
14849
|
+
current += char;
|
|
14850
|
+
continue;
|
|
14851
|
+
}
|
|
14852
|
+
if (char === ")" && parenDepth > 0) {
|
|
14853
|
+
parenDepth -= 1;
|
|
14854
|
+
current += char;
|
|
14855
|
+
continue;
|
|
14856
|
+
}
|
|
14857
|
+
if (char === ";" && parenDepth === 0) {
|
|
14858
|
+
result.push(current);
|
|
14859
|
+
current = "";
|
|
14860
|
+
continue;
|
|
14861
|
+
}
|
|
14862
|
+
}
|
|
14863
|
+
current += char;
|
|
14864
|
+
}
|
|
14865
|
+
if (current) {
|
|
14866
|
+
result.push(current);
|
|
14867
|
+
}
|
|
14868
|
+
return result;
|
|
14869
|
+
}
|
|
14870
|
+
function parseStyleEntries(styles) {
|
|
14871
|
+
const pairs = [];
|
|
14872
|
+
const declarations = splitStyleDeclarations(styles || "");
|
|
14873
|
+
const numDeclarations = declarations.length;
|
|
14874
|
+
for (let i = 0; i < numDeclarations; i += 1) {
|
|
14875
|
+
const declaration = declarations[i];
|
|
14876
|
+
const firstColonIndex = declaration.indexOf(":");
|
|
14877
|
+
if (firstColonIndex === -1) {
|
|
14878
|
+
continue;
|
|
14879
|
+
}
|
|
14880
|
+
const property = declaration.slice(0, firstColonIndex).trim();
|
|
14881
|
+
const value = declaration.slice(firstColonIndex + 1).trim();
|
|
14882
|
+
if (property && value) {
|
|
14883
|
+
pairs.push([property, value]);
|
|
14884
|
+
}
|
|
14885
|
+
}
|
|
14886
|
+
return pairs;
|
|
14887
|
+
}
|
|
14823
14888
|
function mergeAttributes(...objects) {
|
|
14824
14889
|
return objects.filter((item) => !!item).reduce((items, item) => {
|
|
14825
14890
|
const mergedAttributes = { ...items };
|
|
@@ -14835,17 +14900,7 @@ function mergeAttributes(...objects) {
|
|
|
14835
14900
|
const insertClasses = valueClasses.filter((valueClass) => !existingClasses.includes(valueClass));
|
|
14836
14901
|
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
|
|
14837
14902
|
} else if (key === "style") {
|
|
14838
|
-
const
|
|
14839
|
-
const existingStyles = mergedAttributes[key] ? mergedAttributes[key].split(";").map((style2) => style2.trim()).filter(Boolean) : [];
|
|
14840
|
-
const styleMap = /* @__PURE__ */ new Map();
|
|
14841
|
-
existingStyles.forEach((style2) => {
|
|
14842
|
-
const [property, val] = style2.split(":").map((part) => part.trim());
|
|
14843
|
-
styleMap.set(property, val);
|
|
14844
|
-
});
|
|
14845
|
-
newStyles.forEach((style2) => {
|
|
14846
|
-
const [property, val] = style2.split(":").map((part) => part.trim());
|
|
14847
|
-
styleMap.set(property, val);
|
|
14848
|
-
});
|
|
14903
|
+
const styleMap = new Map([...parseStyleEntries(mergedAttributes[key]), ...parseStyleEntries(value)]);
|
|
14849
14904
|
mergedAttributes[key] = Array.from(styleMap.entries()).map(([property, val]) => `${property}: ${val}`).join("; ");
|
|
14850
14905
|
} else {
|
|
14851
14906
|
mergedAttributes[key] = value;
|
|
@@ -15443,7 +15498,7 @@ function isNodeEmpty(node, {
|
|
|
15443
15498
|
return true;
|
|
15444
15499
|
}
|
|
15445
15500
|
if (node.isText) {
|
|
15446
|
-
return
|
|
15501
|
+
return !/\S/.test((_a = node.text) != null ? _a : "");
|
|
15447
15502
|
}
|
|
15448
15503
|
}
|
|
15449
15504
|
if (node.isText) {
|
|
@@ -15839,6 +15894,16 @@ var joinListForwards = (tr, listType) => {
|
|
|
15839
15894
|
tr.join(after);
|
|
15840
15895
|
return true;
|
|
15841
15896
|
};
|
|
15897
|
+
function createInnerSelectionForWholeDocList(tr) {
|
|
15898
|
+
const doc = tr.doc;
|
|
15899
|
+
const list = doc.firstChild;
|
|
15900
|
+
if (!list) {
|
|
15901
|
+
return null;
|
|
15902
|
+
}
|
|
15903
|
+
const $start = doc.resolve(1);
|
|
15904
|
+
const $end = doc.resolve(list.nodeSize - 1);
|
|
15905
|
+
return TextSelection.between($start, $end);
|
|
15906
|
+
}
|
|
15842
15907
|
var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr, state, dispatch, chain, commands, can }) => {
|
|
15843
15908
|
const { extensions, splittableMarks } = editor.extensionManager;
|
|
15844
15909
|
const listType = getNodeType(listTypeOrName, state.schema);
|
|
@@ -15851,13 +15916,35 @@ var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) =>
|
|
|
15851
15916
|
return false;
|
|
15852
15917
|
}
|
|
15853
15918
|
const parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);
|
|
15854
|
-
|
|
15855
|
-
|
|
15919
|
+
const isAllSelection = selection.from === 0 && selection.to === state.doc.content.size;
|
|
15920
|
+
const topLevelNodes = state.doc.content.content;
|
|
15921
|
+
const soleTopLevelNode = topLevelNodes.length === 1 ? topLevelNodes[0] : null;
|
|
15922
|
+
const allSelectionList = isAllSelection && soleTopLevelNode && isList(soleTopLevelNode.type.name, extensions) ? {
|
|
15923
|
+
node: soleTopLevelNode,
|
|
15924
|
+
pos: 0} : null;
|
|
15925
|
+
const currentList = parentList != null ? parentList : allSelectionList;
|
|
15926
|
+
const isInsideExistingList = !!parentList && range.depth >= 1 && range.depth - parentList.depth <= 1;
|
|
15927
|
+
const hasWholeDocSelectedList = !!allSelectionList;
|
|
15928
|
+
if ((isInsideExistingList || hasWholeDocSelectedList) && currentList) {
|
|
15929
|
+
if (currentList.node.type === listType) {
|
|
15930
|
+
if (isAllSelection && hasWholeDocSelectedList) {
|
|
15931
|
+
return chain().command(({ tr: trx, dispatch: disp }) => {
|
|
15932
|
+
const nextSelection = createInnerSelectionForWholeDocList(trx);
|
|
15933
|
+
if (!nextSelection) {
|
|
15934
|
+
return false;
|
|
15935
|
+
}
|
|
15936
|
+
trx.setSelection(nextSelection);
|
|
15937
|
+
if (disp) {
|
|
15938
|
+
disp(trx);
|
|
15939
|
+
}
|
|
15940
|
+
return true;
|
|
15941
|
+
}).liftListItem(itemType).run();
|
|
15942
|
+
}
|
|
15856
15943
|
return commands.liftListItem(itemType);
|
|
15857
15944
|
}
|
|
15858
|
-
if (isList(
|
|
15945
|
+
if (isList(currentList.node.type.name, extensions) && listType.validContent(currentList.node.content)) {
|
|
15859
15946
|
return chain().command(() => {
|
|
15860
|
-
tr.setNodeMarkup(
|
|
15947
|
+
tr.setNodeMarkup(currentList.pos, listType);
|
|
15861
15948
|
return true;
|
|
15862
15949
|
}).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
|
|
15863
15950
|
}
|
|
@@ -17142,7 +17229,7 @@ var Delete = Extension.create({
|
|
|
17142
17229
|
const newEnd = mapping.slice(index).map(step.to);
|
|
17143
17230
|
const oldStart = mapping.invert().map(newStart, -1);
|
|
17144
17231
|
const oldEnd = mapping.invert().map(newEnd);
|
|
17145
|
-
const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
|
|
17232
|
+
const foundBeforeMark = newStart > 0 ? (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark)) : false;
|
|
17146
17233
|
const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
|
|
17147
17234
|
this.editor.emit("delete", {
|
|
17148
17235
|
type: "mark",
|
|
@@ -18640,7 +18727,7 @@ var ResizableNodeView = class {
|
|
|
18640
18727
|
const element = document.createElement("div");
|
|
18641
18728
|
element.dataset.resizeContainer = "";
|
|
18642
18729
|
element.dataset.node = this.node.type.name;
|
|
18643
|
-
element.style.display = "flex";
|
|
18730
|
+
element.style.display = this.node.type.isInline ? "inline-flex" : "flex";
|
|
18644
18731
|
if (this.classNames.container) {
|
|
18645
18732
|
element.className = this.classNames.container;
|
|
18646
18733
|
}
|
|
@@ -18980,6 +19067,14 @@ function canInsertNode(state, nodeType) {
|
|
|
18980
19067
|
return false;
|
|
18981
19068
|
}
|
|
18982
19069
|
|
|
19070
|
+
// src/utilities/htmlEntities.ts
|
|
19071
|
+
function decodeHtmlEntities(text) {
|
|
19072
|
+
return text.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
|
|
19073
|
+
}
|
|
19074
|
+
function encodeHtmlEntities(text) {
|
|
19075
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
19076
|
+
}
|
|
19077
|
+
|
|
18983
19078
|
// src/utilities/markdown/index.ts
|
|
18984
19079
|
var markdown_exports = {};
|
|
18985
19080
|
__export$1(markdown_exports, {
|
|
@@ -19456,17 +19551,21 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
|
|
|
19456
19551
|
const prefix = typeof prefixOrGenerator === "function" ? prefixOrGenerator(ctx) : prefixOrGenerator;
|
|
19457
19552
|
const [content, ...children] = node.content;
|
|
19458
19553
|
const mainContent = h2.renderChildren([content]);
|
|
19459
|
-
|
|
19554
|
+
let output = `${prefix}${mainContent}`;
|
|
19460
19555
|
if (children && children.length > 0) {
|
|
19461
|
-
children.forEach((child) => {
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
-
|
|
19465
|
-
|
|
19556
|
+
children.forEach((child, index) => {
|
|
19557
|
+
var _a, _b;
|
|
19558
|
+
const childContent = (_b = (_a = h2.renderChild) == null ? void 0 : _a.call(h2, child, index + 1)) != null ? _b : h2.renderChildren([child]);
|
|
19559
|
+
if (childContent !== void 0 && childContent !== null) {
|
|
19560
|
+
const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : h2.indent("")).join("\n");
|
|
19561
|
+
output += child.type === "paragraph" ? `
|
|
19562
|
+
|
|
19563
|
+
${indentedChild}` : `
|
|
19564
|
+
${indentedChild}`;
|
|
19466
19565
|
}
|
|
19467
19566
|
});
|
|
19468
19567
|
}
|
|
19469
|
-
return output
|
|
19568
|
+
return output;
|
|
19470
19569
|
}
|
|
19471
19570
|
|
|
19472
19571
|
// src/MarkView.ts
|
|
@@ -19562,7 +19661,10 @@ function markPasteRule(config) {
|
|
|
19562
19661
|
}
|
|
19563
19662
|
markEnd = range.from + startSpaces + captureGroup.length;
|
|
19564
19663
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
19565
|
-
|
|
19664
|
+
const isMatchAtEndOfText = match.index !== void 0 && match.input !== void 0 && match.index + match[0].length >= match.input.length;
|
|
19665
|
+
if (!isMatchAtEndOfText) {
|
|
19666
|
+
tr.removeStoredMark(config.type);
|
|
19667
|
+
}
|
|
19566
19668
|
}
|
|
19567
19669
|
}
|
|
19568
19670
|
});
|
|
@@ -19674,13 +19776,13 @@ function findMarksToCloseAtEnd(activeMarks, currentMarks, nextNode, markSetsEqua
|
|
|
19674
19776
|
if (isLastNode || nextNodeHasNoMarks || nextNodeHasDifferentMarks) {
|
|
19675
19777
|
if (nextNode && nextNode.type === "text" && nextNode.marks) {
|
|
19676
19778
|
const nextMarks = new Map(nextNode.marks.map((mark) => [mark.type, mark]));
|
|
19677
|
-
Array.from(activeMarks.keys()).forEach((markType) => {
|
|
19779
|
+
Array.from(activeMarks.keys()).reverse().forEach((markType) => {
|
|
19678
19780
|
if (!nextMarks.has(markType)) {
|
|
19679
19781
|
marksToCloseAtEnd.push(markType);
|
|
19680
19782
|
}
|
|
19681
19783
|
});
|
|
19682
19784
|
} else if (isLastNode || nextNodeHasNoMarks) {
|
|
19683
|
-
marksToCloseAtEnd.push(...Array.from(activeMarks.keys()));
|
|
19785
|
+
marksToCloseAtEnd.push(...Array.from(activeMarks.keys()).reverse());
|
|
19684
19786
|
}
|
|
19685
19787
|
}
|
|
19686
19788
|
return marksToCloseAtEnd;
|
|
@@ -19733,12 +19835,14 @@ var MarkdownManager = class {
|
|
|
19733
19835
|
* @param options.extensions An array of Tiptap extensions to register for markdown parsing and rendering.
|
|
19734
19836
|
*/
|
|
19735
19837
|
constructor(options) {
|
|
19838
|
+
this.activeParseLexer = null;
|
|
19736
19839
|
this.baseExtensions = [];
|
|
19737
19840
|
this.extensions = [];
|
|
19841
|
+
/** Set of extension names whose `code` spec property is truthy (nodes and marks). */
|
|
19842
|
+
this.codeTypes = /* @__PURE__ */ new Set();
|
|
19738
19843
|
this.lastParseResult = null;
|
|
19739
19844
|
var _a, _b, _c, _d, _e;
|
|
19740
19845
|
this.markedInstance = (_a = options == null ? void 0 : options.marked) != null ? _a : g;
|
|
19741
|
-
this.lexer = new this.markedInstance.Lexer();
|
|
19742
19846
|
this.indentStyle = (_c = (_b = options == null ? void 0 : options.indentation) == null ? void 0 : _b.style) != null ? _c : "space";
|
|
19743
19847
|
this.indentSize = (_e = (_d = options == null ? void 0 : options.indentation) == null ? void 0 : _d.size) != null ? _e : 2;
|
|
19744
19848
|
this.baseExtensions = (options == null ? void 0 : options.extensions) || [];
|
|
@@ -19750,9 +19854,8 @@ var MarkdownManager = class {
|
|
|
19750
19854
|
if (options == null ? void 0 : options.extensions) {
|
|
19751
19855
|
this.baseExtensions = options.extensions;
|
|
19752
19856
|
const flattened = flattenExtensions(options.extensions);
|
|
19753
|
-
flattened.forEach((ext) => this.registerExtension(ext
|
|
19857
|
+
flattened.forEach((ext) => this.registerExtension(ext));
|
|
19754
19858
|
}
|
|
19755
|
-
this.lexer = new this.markedInstance.Lexer();
|
|
19756
19859
|
}
|
|
19757
19860
|
/** Returns the underlying marked instance. */
|
|
19758
19861
|
get instance() {
|
|
@@ -19775,22 +19878,28 @@ var MarkdownManager = class {
|
|
|
19775
19878
|
* `markdownName`, `parseMarkdown`, `renderMarkdown` and `priority` from the
|
|
19776
19879
|
* extension config (using the same resolution used across the codebase).
|
|
19777
19880
|
*/
|
|
19778
|
-
registerExtension(extension
|
|
19881
|
+
registerExtension(extension) {
|
|
19779
19882
|
var _a, _b;
|
|
19780
19883
|
this.extensions.push(extension);
|
|
19884
|
+
const isCode = callOrReturn(getExtensionField(extension, "code"));
|
|
19781
19885
|
const name = extension.name;
|
|
19886
|
+
if (isCode) {
|
|
19887
|
+
this.codeTypes.add(name);
|
|
19888
|
+
}
|
|
19782
19889
|
const tokenName = getExtensionField(extension, "markdownTokenName") || name;
|
|
19783
19890
|
const parseMarkdown = getExtensionField(extension, "parseMarkdown");
|
|
19784
19891
|
const renderMarkdown = getExtensionField(extension, "renderMarkdown");
|
|
19785
19892
|
const tokenizer = getExtensionField(extension, "markdownTokenizer");
|
|
19786
19893
|
const markdownCfg = (_a = getExtensionField(extension, "markdownOptions")) != null ? _a : null;
|
|
19787
19894
|
const isIndenting = (_b = markdownCfg == null ? void 0 : markdownCfg.indentsContent) != null ? _b : false;
|
|
19895
|
+
const htmlReopen = markdownCfg == null ? void 0 : markdownCfg.htmlReopen;
|
|
19788
19896
|
const spec = {
|
|
19789
19897
|
tokenName,
|
|
19790
19898
|
nodeName: name,
|
|
19791
19899
|
parseMarkdown,
|
|
19792
19900
|
renderMarkdown,
|
|
19793
19901
|
isIndenting,
|
|
19902
|
+
htmlReopen,
|
|
19794
19903
|
tokenizer
|
|
19795
19904
|
};
|
|
19796
19905
|
if (tokenName && parseMarkdown) {
|
|
@@ -19805,11 +19914,21 @@ var MarkdownManager = class {
|
|
|
19805
19914
|
}
|
|
19806
19915
|
if (tokenizer && this.hasMarked()) {
|
|
19807
19916
|
this.registerTokenizer(tokenizer);
|
|
19808
|
-
if (recreateLexer) {
|
|
19809
|
-
this.lexer = new this.markedInstance.Lexer();
|
|
19810
|
-
}
|
|
19811
19917
|
}
|
|
19812
19918
|
}
|
|
19919
|
+
createLexer() {
|
|
19920
|
+
return new this.markedInstance.Lexer();
|
|
19921
|
+
}
|
|
19922
|
+
createTokenizerHelpers(lexer) {
|
|
19923
|
+
return {
|
|
19924
|
+
inlineTokens: (src) => lexer.inlineTokens(src),
|
|
19925
|
+
blockTokens: (src) => lexer.blockTokens(src)
|
|
19926
|
+
};
|
|
19927
|
+
}
|
|
19928
|
+
tokenizeInline(src) {
|
|
19929
|
+
var _a;
|
|
19930
|
+
return ((_a = this.activeParseLexer) != null ? _a : this.createLexer()).inlineTokens(src);
|
|
19931
|
+
}
|
|
19813
19932
|
/**
|
|
19814
19933
|
* Register a custom tokenizer with marked.js for parsing non-standard markdown syntax.
|
|
19815
19934
|
*/
|
|
@@ -19818,20 +19937,12 @@ var MarkdownManager = class {
|
|
|
19818
19937
|
return;
|
|
19819
19938
|
}
|
|
19820
19939
|
const { name, start, level = "inline", tokenize } = tokenizer;
|
|
19821
|
-
const
|
|
19822
|
-
|
|
19823
|
-
};
|
|
19824
|
-
const tokenizeBlock = (src) => {
|
|
19825
|
-
return this.lexer.blockTokens(src);
|
|
19826
|
-
};
|
|
19827
|
-
const helper = {
|
|
19828
|
-
inlineTokens: tokenizeInline,
|
|
19829
|
-
blockTokens: tokenizeBlock
|
|
19830
|
-
};
|
|
19940
|
+
const createTokenizerHelpers = this.createTokenizerHelpers.bind(this);
|
|
19941
|
+
const createLexer = this.createLexer.bind(this);
|
|
19831
19942
|
let startCb;
|
|
19832
19943
|
if (!start) {
|
|
19833
19944
|
startCb = (src) => {
|
|
19834
|
-
const result = tokenize(src, [],
|
|
19945
|
+
const result = tokenize(src, [], this.createTokenizerHelpers(this.createLexer()));
|
|
19835
19946
|
if (result && result.raw) {
|
|
19836
19947
|
const index = src.indexOf(result.raw);
|
|
19837
19948
|
return index;
|
|
@@ -19845,7 +19956,8 @@ var MarkdownManager = class {
|
|
|
19845
19956
|
name,
|
|
19846
19957
|
level,
|
|
19847
19958
|
start: startCb,
|
|
19848
|
-
tokenizer
|
|
19959
|
+
tokenizer(src, tokens) {
|
|
19960
|
+
const helper = this.lexer ? createTokenizerHelpers(this.lexer) : createTokenizerHelpers(createLexer());
|
|
19849
19961
|
const result = tokenize(src, tokens, helper);
|
|
19850
19962
|
if (result && result.type) {
|
|
19851
19963
|
return {
|
|
@@ -19918,23 +20030,65 @@ var MarkdownManager = class {
|
|
|
19918
20030
|
if (!this.hasMarked()) {
|
|
19919
20031
|
throw new Error("No marked instance available for parsing");
|
|
19920
20032
|
}
|
|
19921
|
-
const
|
|
19922
|
-
const
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
|
|
20033
|
+
const previousParseLexer = this.activeParseLexer;
|
|
20034
|
+
const parseLexer = this.createLexer();
|
|
20035
|
+
this.activeParseLexer = parseLexer;
|
|
20036
|
+
try {
|
|
20037
|
+
const tokens = parseLexer.lex(markdown);
|
|
20038
|
+
const content = this.parseTokens(tokens, true);
|
|
20039
|
+
return {
|
|
20040
|
+
type: "doc",
|
|
20041
|
+
content
|
|
20042
|
+
};
|
|
20043
|
+
} finally {
|
|
20044
|
+
this.activeParseLexer = previousParseLexer;
|
|
20045
|
+
}
|
|
19927
20046
|
}
|
|
19928
20047
|
/**
|
|
19929
20048
|
* Convert an array of marked tokens into Tiptap JSON nodes using registered extension handlers.
|
|
19930
20049
|
*/
|
|
19931
|
-
parseTokens(tokens) {
|
|
19932
|
-
|
|
20050
|
+
parseTokens(tokens, parseImplicitEmptyParagraphs = false) {
|
|
20051
|
+
const nonSpaceTokenIndexes = tokens.reduce((indexes, token, index) => {
|
|
20052
|
+
if (token.type !== "space") {
|
|
20053
|
+
indexes.push(index);
|
|
20054
|
+
}
|
|
20055
|
+
return indexes;
|
|
20056
|
+
}, []);
|
|
20057
|
+
let previousNonSpaceTokenIndex = -1;
|
|
20058
|
+
let nextNonSpaceTokenPointer = 0;
|
|
20059
|
+
return tokens.flatMap((token, index) => {
|
|
20060
|
+
var _a;
|
|
20061
|
+
while (nextNonSpaceTokenPointer < nonSpaceTokenIndexes.length && nonSpaceTokenIndexes[nextNonSpaceTokenPointer] < index) {
|
|
20062
|
+
previousNonSpaceTokenIndex = nonSpaceTokenIndexes[nextNonSpaceTokenPointer];
|
|
20063
|
+
nextNonSpaceTokenPointer += 1;
|
|
20064
|
+
}
|
|
20065
|
+
if (parseImplicitEmptyParagraphs && token.type === "space") {
|
|
20066
|
+
const nextNonSpaceTokenIndex = (_a = nonSpaceTokenIndexes[nextNonSpaceTokenPointer]) != null ? _a : -1;
|
|
20067
|
+
return this.createImplicitEmptyParagraphsFromSpace(token, previousNonSpaceTokenIndex, nextNonSpaceTokenIndex);
|
|
20068
|
+
}
|
|
20069
|
+
const parsed = this.parseToken(token, parseImplicitEmptyParagraphs);
|
|
20070
|
+
if (parsed === null) {
|
|
20071
|
+
return [];
|
|
20072
|
+
}
|
|
20073
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
20074
|
+
});
|
|
20075
|
+
}
|
|
20076
|
+
createImplicitEmptyParagraphsFromSpace(token, previousNonSpaceTokenIndex, nextNonSpaceTokenIndex) {
|
|
20077
|
+
const separatorCount = this.countParagraphSeparators(token.raw || "");
|
|
20078
|
+
if (separatorCount === 0) {
|
|
20079
|
+
return [];
|
|
20080
|
+
}
|
|
20081
|
+
const isBoundarySpace = previousNonSpaceTokenIndex === -1 || nextNonSpaceTokenIndex === -1;
|
|
20082
|
+
const emptyParagraphCount = Math.max(separatorCount - (isBoundarySpace ? 0 : 1), 0);
|
|
20083
|
+
return Array.from({ length: emptyParagraphCount }, () => ({ type: "paragraph", content: [] }));
|
|
20084
|
+
}
|
|
20085
|
+
countParagraphSeparators(raw) {
|
|
20086
|
+
return (raw.replace(/\r\n/g, "\n").match(/\n\n/g) || []).length;
|
|
19933
20087
|
}
|
|
19934
20088
|
/**
|
|
19935
20089
|
* Parse a single token into Tiptap JSON using the appropriate registered handler.
|
|
19936
20090
|
*/
|
|
19937
|
-
parseToken(token) {
|
|
20091
|
+
parseToken(token, parseImplicitEmptyParagraphs = false) {
|
|
19938
20092
|
if (!token.type) {
|
|
19939
20093
|
return null;
|
|
19940
20094
|
}
|
|
@@ -19960,7 +20114,7 @@ var MarkdownManager = class {
|
|
|
19960
20114
|
this.lastParseResult = null;
|
|
19961
20115
|
return toReturn;
|
|
19962
20116
|
}
|
|
19963
|
-
return this.parseFallbackToken(token);
|
|
20117
|
+
return this.parseFallbackToken(token, parseImplicitEmptyParagraphs);
|
|
19964
20118
|
}
|
|
19965
20119
|
/**
|
|
19966
20120
|
* Parse a list token, handling mixed bullet and task list items by splitting them into separate lists.
|
|
@@ -20019,7 +20173,7 @@ var MarkdownManager = class {
|
|
|
20019
20173
|
indentLevel,
|
|
20020
20174
|
checked: checked != null ? checked : false,
|
|
20021
20175
|
text: mainContent,
|
|
20022
|
-
tokens: this.
|
|
20176
|
+
tokens: this.tokenizeInline(mainContent),
|
|
20023
20177
|
nestedTokens
|
|
20024
20178
|
};
|
|
20025
20179
|
}
|
|
@@ -20088,6 +20242,7 @@ var MarkdownManager = class {
|
|
|
20088
20242
|
return {
|
|
20089
20243
|
parseInline: (tokens) => this.parseInlineTokens(tokens),
|
|
20090
20244
|
parseChildren: (tokens) => this.parseTokens(tokens),
|
|
20245
|
+
parseBlockChildren: (tokens) => this.parseTokens(tokens, true),
|
|
20091
20246
|
createTextNode: (text, marks) => {
|
|
20092
20247
|
const node = {
|
|
20093
20248
|
type: "text",
|
|
@@ -20132,7 +20287,7 @@ var MarkdownManager = class {
|
|
|
20132
20287
|
if (token.type === "text") {
|
|
20133
20288
|
result.push({
|
|
20134
20289
|
type: "text",
|
|
20135
|
-
text: token.text || ""
|
|
20290
|
+
text: decodeHtmlEntities(token.text || "")
|
|
20136
20291
|
});
|
|
20137
20292
|
} else if (token.type === "html") {
|
|
20138
20293
|
const raw = ((_b = (_a = token.raw) != null ? _a : token.text) != null ? _b : "").toString();
|
|
@@ -20246,7 +20401,7 @@ var MarkdownManager = class {
|
|
|
20246
20401
|
/**
|
|
20247
20402
|
* Fallback parsing for common tokens when no specific handler is registered.
|
|
20248
20403
|
*/
|
|
20249
|
-
parseFallbackToken(token) {
|
|
20404
|
+
parseFallbackToken(token, parseImplicitEmptyParagraphs = false) {
|
|
20250
20405
|
switch (token.type) {
|
|
20251
20406
|
case "paragraph":
|
|
20252
20407
|
return {
|
|
@@ -20262,7 +20417,7 @@ var MarkdownManager = class {
|
|
|
20262
20417
|
case "text":
|
|
20263
20418
|
return {
|
|
20264
20419
|
type: "text",
|
|
20265
|
-
text: token.text || ""
|
|
20420
|
+
text: decodeHtmlEntities(token.text || "")
|
|
20266
20421
|
};
|
|
20267
20422
|
case "html":
|
|
20268
20423
|
return this.parseHTMLToken(token);
|
|
@@ -20270,7 +20425,7 @@ var MarkdownManager = class {
|
|
|
20270
20425
|
return null;
|
|
20271
20426
|
default:
|
|
20272
20427
|
if (token.tokens) {
|
|
20273
|
-
return this.parseTokens(token.tokens);
|
|
20428
|
+
return this.parseTokens(token.tokens, parseImplicitEmptyParagraphs);
|
|
20274
20429
|
}
|
|
20275
20430
|
return null;
|
|
20276
20431
|
}
|
|
@@ -20317,10 +20472,18 @@ var MarkdownManager = class {
|
|
|
20317
20472
|
throw new Error(`Failed to parse HTML in markdown: ${error}`);
|
|
20318
20473
|
}
|
|
20319
20474
|
}
|
|
20320
|
-
|
|
20475
|
+
/**
|
|
20476
|
+
* Encode HTML entities in text unless the node is inside a code context
|
|
20477
|
+
* (code mark or code-block parent) where literal characters should be preserved.
|
|
20478
|
+
*/
|
|
20479
|
+
encodeTextForMarkdown(text, node, parentNode) {
|
|
20480
|
+
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));
|
|
20481
|
+
return isInsideCode ? text : encodeHtmlEntities(text);
|
|
20482
|
+
}
|
|
20483
|
+
renderNodeToMarkdown(node, parentNode, index = 0, level = 0, meta = {}) {
|
|
20321
20484
|
var _a;
|
|
20322
20485
|
if (node.type === "text") {
|
|
20323
|
-
return node.text || "";
|
|
20486
|
+
return this.encodeTextForMarkdown(node.text || "", node, parentNode);
|
|
20324
20487
|
}
|
|
20325
20488
|
if (!node.type) {
|
|
20326
20489
|
return "";
|
|
@@ -20329,6 +20492,7 @@ var MarkdownManager = class {
|
|
|
20329
20492
|
if (!handler) {
|
|
20330
20493
|
return "";
|
|
20331
20494
|
}
|
|
20495
|
+
const previousNode = Array.isArray(parentNode == null ? void 0 : parentNode.content) && index > 0 ? parentNode.content[index - 1] : void 0;
|
|
20332
20496
|
const helpers = {
|
|
20333
20497
|
renderChildren: (nodes, separator) => {
|
|
20334
20498
|
const childLevel = handler.isIndenting ? level + 1 : level;
|
|
@@ -20337,6 +20501,10 @@ var MarkdownManager = class {
|
|
|
20337
20501
|
}
|
|
20338
20502
|
return this.renderNodes(nodes, node, separator || "", index, childLevel);
|
|
20339
20503
|
},
|
|
20504
|
+
renderChild: (childNode, childIndex) => {
|
|
20505
|
+
const childLevel = handler.isIndenting ? level + 1 : level;
|
|
20506
|
+
return this.renderNodeToMarkdown(childNode, node, childIndex, childLevel);
|
|
20507
|
+
},
|
|
20340
20508
|
indent: (content) => {
|
|
20341
20509
|
return this.indentString + content;
|
|
20342
20510
|
},
|
|
@@ -20346,8 +20514,10 @@ var MarkdownManager = class {
|
|
|
20346
20514
|
index,
|
|
20347
20515
|
level,
|
|
20348
20516
|
parentType: parentNode == null ? void 0 : parentNode.type,
|
|
20517
|
+
previousNode,
|
|
20349
20518
|
meta: {
|
|
20350
|
-
parentAttrs: parentNode == null ? void 0 : parentNode.attrs
|
|
20519
|
+
parentAttrs: parentNode == null ? void 0 : parentNode.attrs,
|
|
20520
|
+
...meta
|
|
20351
20521
|
}
|
|
20352
20522
|
};
|
|
20353
20523
|
const rendered = ((_a = handler.renderMarkdown) == null ? void 0 : _a.call(handler, node, helpers, context)) || "";
|
|
@@ -20373,34 +20543,44 @@ var MarkdownManager = class {
|
|
|
20373
20543
|
renderNodesWithMarkBoundaries(nodes, parentNode, separator = "", level = 0) {
|
|
20374
20544
|
const result = [];
|
|
20375
20545
|
const activeMarks = /* @__PURE__ */ new Map();
|
|
20546
|
+
const reopenWithHtmlOnNextOpen = /* @__PURE__ */ new Set();
|
|
20547
|
+
const markOpeningModes = /* @__PURE__ */ new Map();
|
|
20376
20548
|
nodes.forEach((node, i) => {
|
|
20377
20549
|
const nextNode = i < nodes.length - 1 ? nodes[i + 1] : null;
|
|
20378
20550
|
if (!node.type) {
|
|
20379
20551
|
return;
|
|
20380
20552
|
}
|
|
20381
20553
|
if (node.type === "text") {
|
|
20382
|
-
let textContent = node.text || "";
|
|
20554
|
+
let textContent = this.encodeTextForMarkdown(node.text || "", node, parentNode);
|
|
20383
20555
|
const currentMarks = new Map((node.marks || []).map((mark) => [mark.type, mark]));
|
|
20384
20556
|
const marksToOpen = findMarksToOpen(activeMarks, currentMarks);
|
|
20385
20557
|
const marksToClose = findMarksToClose(currentMarks, nextNode);
|
|
20558
|
+
const activeMarksClosingHere = marksToClose.filter((markType) => activeMarks.has(markType));
|
|
20559
|
+
const hasCrossedBoundary = activeMarksClosingHere.length > 0 && marksToOpen.length > 0;
|
|
20386
20560
|
let middleTrailingWhitespace = "";
|
|
20387
|
-
if (marksToClose.length > 0) {
|
|
20561
|
+
if (marksToClose.length > 0 && !hasCrossedBoundary) {
|
|
20388
20562
|
const middleTrailingMatch = textContent.match(/(\s+)$/);
|
|
20389
20563
|
if (middleTrailingMatch) {
|
|
20390
20564
|
middleTrailingWhitespace = middleTrailingMatch[1];
|
|
20391
20565
|
textContent = textContent.slice(0, -middleTrailingWhitespace.length);
|
|
20392
20566
|
}
|
|
20393
20567
|
}
|
|
20394
|
-
|
|
20395
|
-
|
|
20396
|
-
|
|
20397
|
-
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20402
|
-
|
|
20403
|
-
|
|
20568
|
+
if (!hasCrossedBoundary) {
|
|
20569
|
+
marksToClose.forEach((markType) => {
|
|
20570
|
+
if (!activeMarks.has(markType)) {
|
|
20571
|
+
return;
|
|
20572
|
+
}
|
|
20573
|
+
const mark = currentMarks.get(markType);
|
|
20574
|
+
const closeMarkdown = this.getMarkClosing(markType, mark, markOpeningModes.get(markType));
|
|
20575
|
+
if (closeMarkdown) {
|
|
20576
|
+
textContent += closeMarkdown;
|
|
20577
|
+
}
|
|
20578
|
+
if (activeMarks.has(markType)) {
|
|
20579
|
+
activeMarks.delete(markType);
|
|
20580
|
+
markOpeningModes.delete(markType);
|
|
20581
|
+
}
|
|
20582
|
+
});
|
|
20583
|
+
}
|
|
20404
20584
|
let leadingWhitespace = "";
|
|
20405
20585
|
if (marksToOpen.length > 0) {
|
|
20406
20586
|
const leadingMatch = textContent.match(/^(\s+)/);
|
|
@@ -20410,21 +20590,37 @@ var MarkdownManager = class {
|
|
|
20410
20590
|
}
|
|
20411
20591
|
}
|
|
20412
20592
|
marksToOpen.forEach(({ type, mark }) => {
|
|
20413
|
-
const
|
|
20593
|
+
const openingMode = reopenWithHtmlOnNextOpen.has(type) ? "html" : "markdown";
|
|
20594
|
+
const openMarkdown = this.getMarkOpening(type, mark, openingMode);
|
|
20414
20595
|
if (openMarkdown) {
|
|
20415
20596
|
textContent = openMarkdown + textContent;
|
|
20416
20597
|
}
|
|
20417
|
-
|
|
20418
|
-
|
|
20419
|
-
}
|
|
20598
|
+
markOpeningModes.set(type, openingMode);
|
|
20599
|
+
reopenWithHtmlOnNextOpen.delete(type);
|
|
20420
20600
|
});
|
|
20601
|
+
if (!hasCrossedBoundary) {
|
|
20602
|
+
marksToOpen.slice().reverse().forEach(({ type, mark }) => {
|
|
20603
|
+
activeMarks.set(type, mark);
|
|
20604
|
+
});
|
|
20605
|
+
}
|
|
20421
20606
|
textContent = leadingWhitespace + textContent;
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20607
|
+
let marksToCloseAtEnd;
|
|
20608
|
+
if (hasCrossedBoundary) {
|
|
20609
|
+
const nextMarkTypes = new Set(((nextNode == null ? void 0 : nextNode.marks) || []).map((mark) => mark.type));
|
|
20610
|
+
marksToOpen.forEach(({ type }) => {
|
|
20611
|
+
if (nextMarkTypes.has(type) && this.getHtmlReopenTags(type)) {
|
|
20612
|
+
reopenWithHtmlOnNextOpen.add(type);
|
|
20613
|
+
}
|
|
20614
|
+
});
|
|
20615
|
+
marksToCloseAtEnd = [
|
|
20616
|
+
...marksToOpen.map((m) => m.type),
|
|
20617
|
+
// inner (opened here) — close first
|
|
20618
|
+
...activeMarksClosingHere
|
|
20619
|
+
// outer (were active before) — close last
|
|
20620
|
+
];
|
|
20621
|
+
} else {
|
|
20622
|
+
marksToCloseAtEnd = findMarksToCloseAtEnd(activeMarks, currentMarks, nextNode, this.markSetsEqual.bind(this));
|
|
20623
|
+
}
|
|
20428
20624
|
let trailingWhitespace = "";
|
|
20429
20625
|
if (marksToCloseAtEnd.length > 0) {
|
|
20430
20626
|
const trailingMatch = textContent.match(/(\s+)$/);
|
|
@@ -20434,21 +20630,32 @@ var MarkdownManager = class {
|
|
|
20434
20630
|
}
|
|
20435
20631
|
}
|
|
20436
20632
|
marksToCloseAtEnd.forEach((markType) => {
|
|
20437
|
-
|
|
20438
|
-
const
|
|
20633
|
+
var _a;
|
|
20634
|
+
const mark = (_a = activeMarks.get(markType)) != null ? _a : currentMarks.get(markType);
|
|
20635
|
+
const closeMarkdown = this.getMarkClosing(markType, mark, markOpeningModes.get(markType));
|
|
20439
20636
|
if (closeMarkdown) {
|
|
20440
20637
|
textContent += closeMarkdown;
|
|
20441
20638
|
}
|
|
20442
20639
|
activeMarks.delete(markType);
|
|
20640
|
+
markOpeningModes.delete(markType);
|
|
20443
20641
|
});
|
|
20444
20642
|
textContent += trailingWhitespace;
|
|
20445
20643
|
textContent += middleTrailingWhitespace;
|
|
20446
20644
|
result.push(textContent);
|
|
20447
20645
|
} else {
|
|
20448
20646
|
const marksToReopen = new Map(activeMarks);
|
|
20449
|
-
const
|
|
20647
|
+
const openingModesToReopen = new Map(markOpeningModes);
|
|
20648
|
+
const beforeMarkdown = closeMarksBeforeNode(activeMarks, (markType, mark) => {
|
|
20649
|
+
return this.getMarkClosing(markType, mark, markOpeningModes.get(markType));
|
|
20650
|
+
});
|
|
20651
|
+
markOpeningModes.clear();
|
|
20450
20652
|
const nodeContent = this.renderNodeToMarkdown(node, parentNode, i, level);
|
|
20451
|
-
const afterMarkdown = node.type === "hardBreak" ? "" : reopenMarksAfterNode(marksToReopen, activeMarks,
|
|
20653
|
+
const afterMarkdown = node.type === "hardBreak" ? "" : reopenMarksAfterNode(marksToReopen, activeMarks, (markType, mark) => {
|
|
20654
|
+
var _a;
|
|
20655
|
+
const openingMode = (_a = openingModesToReopen.get(markType)) != null ? _a : "markdown";
|
|
20656
|
+
markOpeningModes.set(markType, openingMode);
|
|
20657
|
+
return this.getMarkOpening(markType, mark, openingMode);
|
|
20658
|
+
});
|
|
20452
20659
|
result.push(beforeMarkdown + nodeContent + afterMarkdown);
|
|
20453
20660
|
}
|
|
20454
20661
|
});
|
|
@@ -20457,7 +20664,11 @@ var MarkdownManager = class {
|
|
|
20457
20664
|
/**
|
|
20458
20665
|
* Get the opening markdown syntax for a mark type.
|
|
20459
20666
|
*/
|
|
20460
|
-
getMarkOpening(markType, mark) {
|
|
20667
|
+
getMarkOpening(markType, mark, openingMode = "markdown") {
|
|
20668
|
+
var _a;
|
|
20669
|
+
if (openingMode === "html") {
|
|
20670
|
+
return ((_a = this.getHtmlReopenTags(markType)) == null ? void 0 : _a.open) || "";
|
|
20671
|
+
}
|
|
20461
20672
|
const handlers = this.getHandlersForNodeType(markType);
|
|
20462
20673
|
const handler = handlers.length > 0 ? handlers[0] : void 0;
|
|
20463
20674
|
if (!handler || !handler.renderMarkdown) {
|
|
@@ -20474,6 +20685,7 @@ var MarkdownManager = class {
|
|
|
20474
20685
|
syntheticNode,
|
|
20475
20686
|
{
|
|
20476
20687
|
renderChildren: () => placeholder,
|
|
20688
|
+
renderChild: () => placeholder,
|
|
20477
20689
|
indent: (content) => content,
|
|
20478
20690
|
wrapInBlock: (prefix, content) => prefix + content
|
|
20479
20691
|
},
|
|
@@ -20488,7 +20700,11 @@ var MarkdownManager = class {
|
|
|
20488
20700
|
/**
|
|
20489
20701
|
* Get the closing markdown syntax for a mark type.
|
|
20490
20702
|
*/
|
|
20491
|
-
getMarkClosing(markType, mark) {
|
|
20703
|
+
getMarkClosing(markType, mark, openingMode = "markdown") {
|
|
20704
|
+
var _a;
|
|
20705
|
+
if (openingMode === "html") {
|
|
20706
|
+
return ((_a = this.getHtmlReopenTags(markType)) == null ? void 0 : _a.close) || "";
|
|
20707
|
+
}
|
|
20492
20708
|
const handlers = this.getHandlersForNodeType(markType);
|
|
20493
20709
|
const handler = handlers.length > 0 ? handlers[0] : void 0;
|
|
20494
20710
|
if (!handler || !handler.renderMarkdown) {
|
|
@@ -20505,6 +20721,7 @@ var MarkdownManager = class {
|
|
|
20505
20721
|
syntheticNode,
|
|
20506
20722
|
{
|
|
20507
20723
|
renderChildren: () => placeholder,
|
|
20724
|
+
renderChild: () => placeholder,
|
|
20508
20725
|
indent: (content) => content,
|
|
20509
20726
|
wrapInBlock: (prefix, content) => prefix + content
|
|
20510
20727
|
},
|
|
@@ -20517,6 +20734,15 @@ var MarkdownManager = class {
|
|
|
20517
20734
|
throw new Error(`Failed to get mark closing for ${markType}: ${err}`);
|
|
20518
20735
|
}
|
|
20519
20736
|
}
|
|
20737
|
+
/**
|
|
20738
|
+
* Returns the inline HTML tags an extension exposes for overlap-boundary
|
|
20739
|
+
* reopen handling, if that mark explicitly opted into HTML reopen mode.
|
|
20740
|
+
*/
|
|
20741
|
+
getHtmlReopenTags(markType) {
|
|
20742
|
+
const handlers = this.getHandlersForNodeType(markType);
|
|
20743
|
+
const handler = handlers.length > 0 ? handlers[0] : void 0;
|
|
20744
|
+
return handler == null ? void 0 : handler.htmlReopen;
|
|
20745
|
+
}
|
|
20520
20746
|
/**
|
|
20521
20747
|
* Check if two mark sets are equal.
|
|
20522
20748
|
*/
|
|
@@ -20659,7 +20885,9 @@ var Blockquote = Node3.create({
|
|
|
20659
20885
|
return /* @__PURE__ */ h("blockquote", { ...mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), children: /* @__PURE__ */ h("slot", {}) });
|
|
20660
20886
|
},
|
|
20661
20887
|
parseMarkdown: (token, helpers) => {
|
|
20662
|
-
|
|
20888
|
+
var _a;
|
|
20889
|
+
const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
|
|
20890
|
+
return helpers.createNode("blockquote", void 0, parseBlockChildren(token.tokens || []));
|
|
20663
20891
|
},
|
|
20664
20892
|
renderMarkdown: (node, h) => {
|
|
20665
20893
|
if (!node.content) {
|
|
@@ -20667,8 +20895,9 @@ var Blockquote = Node3.create({
|
|
|
20667
20895
|
}
|
|
20668
20896
|
const prefix = ">";
|
|
20669
20897
|
const result = [];
|
|
20670
|
-
node.content.forEach((child) => {
|
|
20671
|
-
|
|
20898
|
+
node.content.forEach((child, index) => {
|
|
20899
|
+
var _a, _b;
|
|
20900
|
+
const childContent = (_b = (_a = h.renderChild) == null ? void 0 : _a.call(h, child, index)) != null ? _b : h.renderChildren([child]);
|
|
20672
20901
|
const lines = childContent.split("\n");
|
|
20673
20902
|
const linesWithPrefix = lines.map((line) => {
|
|
20674
20903
|
if (line.trim() === "") {
|
|
@@ -20748,6 +20977,12 @@ var Bold = Mark.create({
|
|
|
20748
20977
|
parseMarkdown: (token, helpers) => {
|
|
20749
20978
|
return helpers.applyMark("bold", helpers.parseInline(token.tokens || []));
|
|
20750
20979
|
},
|
|
20980
|
+
markdownOptions: {
|
|
20981
|
+
htmlReopen: {
|
|
20982
|
+
open: "<strong>",
|
|
20983
|
+
close: "</strong>"
|
|
20984
|
+
}
|
|
20985
|
+
},
|
|
20751
20986
|
renderMarkdown: (node, h) => {
|
|
20752
20987
|
return `**${h.renderChildren(node)}**`;
|
|
20753
20988
|
},
|
|
@@ -20928,8 +21163,8 @@ var CodeBlock = Node3.create({
|
|
|
20928
21163
|
},
|
|
20929
21164
|
markdownTokenName: "code",
|
|
20930
21165
|
parseMarkdown: (token, helpers) => {
|
|
20931
|
-
var _a;
|
|
20932
|
-
if (((_a = token.raw) == null ? void 0 : _a.startsWith("```")) === false && token.codeBlockStyle !== "indented") {
|
|
21166
|
+
var _a, _b;
|
|
21167
|
+
if (((_a = token.raw) == null ? void 0 : _a.startsWith("```")) === false && ((_b = token.raw) == null ? void 0 : _b.startsWith("~~~")) === false && token.codeBlockStyle !== "indented") {
|
|
20933
21168
|
return [];
|
|
20934
21169
|
}
|
|
20935
21170
|
return helpers.createNode(
|
|
@@ -21457,6 +21692,12 @@ var Italic = Mark.create({
|
|
|
21457
21692
|
parseMarkdown: (token, helpers) => {
|
|
21458
21693
|
return helpers.applyMark("italic", helpers.parseInline(token.tokens || []));
|
|
21459
21694
|
},
|
|
21695
|
+
markdownOptions: {
|
|
21696
|
+
htmlReopen: {
|
|
21697
|
+
open: "<em>",
|
|
21698
|
+
close: "</em>"
|
|
21699
|
+
}
|
|
21700
|
+
},
|
|
21460
21701
|
renderMarkdown: (node, h) => {
|
|
21461
21702
|
return `*${h.renderChildren(node)}*`;
|
|
21462
21703
|
},
|
|
@@ -23760,14 +24001,16 @@ var ListItem = Node3.create({
|
|
|
23760
24001
|
},
|
|
23761
24002
|
markdownTokenName: "list_item",
|
|
23762
24003
|
parseMarkdown: (token, helpers) => {
|
|
24004
|
+
var _a;
|
|
23763
24005
|
if (token.type !== "list_item") {
|
|
23764
24006
|
return [];
|
|
23765
24007
|
}
|
|
24008
|
+
const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
|
|
23766
24009
|
let content = [];
|
|
23767
24010
|
if (token.tokens && token.tokens.length > 0) {
|
|
23768
24011
|
const hasParagraphTokens = token.tokens.some((t) => t.type === "paragraph");
|
|
23769
24012
|
if (hasParagraphTokens) {
|
|
23770
|
-
content =
|
|
24013
|
+
content = parseBlockChildren(token.tokens);
|
|
23771
24014
|
} else {
|
|
23772
24015
|
const firstToken = token.tokens[0];
|
|
23773
24016
|
if (firstToken && firstToken.type === "text" && firstToken.tokens && firstToken.tokens.length > 0) {
|
|
@@ -23780,11 +24023,11 @@ var ListItem = Node3.create({
|
|
|
23780
24023
|
];
|
|
23781
24024
|
if (token.tokens.length > 1) {
|
|
23782
24025
|
const remainingTokens = token.tokens.slice(1);
|
|
23783
|
-
const additionalContent =
|
|
24026
|
+
const additionalContent = parseBlockChildren(remainingTokens);
|
|
23784
24027
|
content.push(...additionalContent);
|
|
23785
24028
|
}
|
|
23786
24029
|
} else {
|
|
23787
|
-
content =
|
|
24030
|
+
content = parseBlockChildren(token.tokens);
|
|
23788
24031
|
}
|
|
23789
24032
|
}
|
|
23790
24033
|
}
|
|
@@ -24089,6 +24332,36 @@ var ListKeymap = Extension.create({
|
|
|
24089
24332
|
// src/ordered-list/utils.ts
|
|
24090
24333
|
var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
|
|
24091
24334
|
var INDENTED_LINE_REGEX = /^\s/;
|
|
24335
|
+
function isBlockContentLine(line) {
|
|
24336
|
+
const trimmedLine = line.trimStart();
|
|
24337
|
+
return /^[-+*]\s+/.test(trimmedLine) || /^\d+\.\s+/.test(trimmedLine) || /^>\s?/.test(trimmedLine) || /^```/.test(trimmedLine) || /^~~~/.test(trimmedLine);
|
|
24338
|
+
}
|
|
24339
|
+
function splitItemContent(contentLines) {
|
|
24340
|
+
const paragraphLines = [];
|
|
24341
|
+
const blockLines = [];
|
|
24342
|
+
let reachedBlockBoundary = false;
|
|
24343
|
+
contentLines.forEach((line) => {
|
|
24344
|
+
if (reachedBlockBoundary) {
|
|
24345
|
+
blockLines.push(line);
|
|
24346
|
+
return;
|
|
24347
|
+
}
|
|
24348
|
+
if (line.trim() === "") {
|
|
24349
|
+
reachedBlockBoundary = true;
|
|
24350
|
+
blockLines.push(line);
|
|
24351
|
+
return;
|
|
24352
|
+
}
|
|
24353
|
+
if (paragraphLines.length > 0 && isBlockContentLine(line)) {
|
|
24354
|
+
reachedBlockBoundary = true;
|
|
24355
|
+
blockLines.push(line);
|
|
24356
|
+
return;
|
|
24357
|
+
}
|
|
24358
|
+
paragraphLines.push(line);
|
|
24359
|
+
});
|
|
24360
|
+
return {
|
|
24361
|
+
paragraphLines,
|
|
24362
|
+
blockLines
|
|
24363
|
+
};
|
|
24364
|
+
}
|
|
24092
24365
|
function collectOrderedListItems(lines) {
|
|
24093
24366
|
const listItems = [];
|
|
24094
24367
|
let currentLineIndex = 0;
|
|
@@ -24101,9 +24374,10 @@ function collectOrderedListItems(lines) {
|
|
|
24101
24374
|
}
|
|
24102
24375
|
const [, indent, number, content] = match;
|
|
24103
24376
|
const indentLevel = indent.length;
|
|
24104
|
-
|
|
24377
|
+
const itemContentLines = [content];
|
|
24105
24378
|
let nextLineIndex = currentLineIndex + 1;
|
|
24106
24379
|
const itemLines = [line];
|
|
24380
|
+
let sawBlankLine = false;
|
|
24107
24381
|
while (nextLineIndex < lines.length) {
|
|
24108
24382
|
const nextLine = lines[nextLineIndex];
|
|
24109
24383
|
const nextMatch = nextLine.match(ORDERED_LIST_ITEM_REGEX);
|
|
@@ -24112,21 +24386,27 @@ function collectOrderedListItems(lines) {
|
|
|
24112
24386
|
}
|
|
24113
24387
|
if (nextLine.trim() === "") {
|
|
24114
24388
|
itemLines.push(nextLine);
|
|
24115
|
-
|
|
24389
|
+
itemContentLines.push("");
|
|
24390
|
+
sawBlankLine = true;
|
|
24116
24391
|
nextLineIndex += 1;
|
|
24117
24392
|
} else if (nextLine.match(INDENTED_LINE_REGEX)) {
|
|
24118
24393
|
itemLines.push(nextLine);
|
|
24119
|
-
|
|
24120
|
-
${nextLine.slice(indentLevel + 2)}`;
|
|
24394
|
+
itemContentLines.push(nextLine.slice(indentLevel + 2));
|
|
24121
24395
|
nextLineIndex += 1;
|
|
24122
24396
|
} else {
|
|
24123
|
-
|
|
24397
|
+
if (sawBlankLine) {
|
|
24398
|
+
break;
|
|
24399
|
+
}
|
|
24400
|
+
itemLines.push(nextLine);
|
|
24401
|
+
itemContentLines.push(nextLine);
|
|
24402
|
+
nextLineIndex += 1;
|
|
24124
24403
|
}
|
|
24125
24404
|
}
|
|
24126
24405
|
listItems.push({
|
|
24127
24406
|
indent: indentLevel,
|
|
24128
24407
|
number: parseInt(number, 10),
|
|
24129
|
-
content:
|
|
24408
|
+
content: itemContentLines.join("\n").trim(),
|
|
24409
|
+
contentLines: itemContentLines,
|
|
24130
24410
|
raw: itemLines.join("\n")
|
|
24131
24411
|
});
|
|
24132
24412
|
consumed = nextLineIndex;
|
|
@@ -24135,14 +24415,13 @@ ${nextLine.slice(indentLevel + 2)}`;
|
|
|
24135
24415
|
return [listItems, consumed];
|
|
24136
24416
|
}
|
|
24137
24417
|
function buildNestedStructure(items, baseIndent, lexer) {
|
|
24138
|
-
var _a;
|
|
24139
24418
|
const result = [];
|
|
24140
24419
|
let currentIndex = 0;
|
|
24141
24420
|
while (currentIndex < items.length) {
|
|
24142
24421
|
const item = items[currentIndex];
|
|
24143
24422
|
if (item.indent === baseIndent) {
|
|
24144
|
-
const
|
|
24145
|
-
const mainText = (
|
|
24423
|
+
const { paragraphLines, blockLines } = splitItemContent(item.contentLines);
|
|
24424
|
+
const mainText = paragraphLines.join("\n").trim();
|
|
24146
24425
|
const tokens = [];
|
|
24147
24426
|
if (mainText) {
|
|
24148
24427
|
tokens.push({
|
|
@@ -24151,7 +24430,7 @@ function buildNestedStructure(items, baseIndent, lexer) {
|
|
|
24151
24430
|
tokens: lexer.inlineTokens(mainText)
|
|
24152
24431
|
});
|
|
24153
24432
|
}
|
|
24154
|
-
const additionalContent =
|
|
24433
|
+
const additionalContent = blockLines.join("\n").trim();
|
|
24155
24434
|
if (additionalContent) {
|
|
24156
24435
|
const blockTokens = lexer.blockTokens(additionalContent);
|
|
24157
24436
|
tokens.push(...blockTokens);
|
|
@@ -24728,18 +25007,22 @@ var Paragraph = Node3.create({
|
|
|
24728
25007
|
return helpers.parseChildren([tokens[0]]);
|
|
24729
25008
|
}
|
|
24730
25009
|
const content = helpers.parseInline(tokens);
|
|
24731
|
-
|
|
25010
|
+
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);
|
|
25011
|
+
if (hasExplicitEmptyParagraphMarker && content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
|
|
24732
25012
|
return helpers.createNode("paragraph", void 0, []);
|
|
24733
25013
|
}
|
|
24734
25014
|
return helpers.createNode("paragraph", void 0, content);
|
|
24735
25015
|
},
|
|
24736
|
-
renderMarkdown: (node, h) => {
|
|
25016
|
+
renderMarkdown: (node, h, ctx) => {
|
|
25017
|
+
var _a, _b;
|
|
24737
25018
|
if (!node) {
|
|
24738
25019
|
return "";
|
|
24739
25020
|
}
|
|
24740
25021
|
const content = Array.isArray(node.content) ? node.content : [];
|
|
24741
25022
|
if (content.length === 0) {
|
|
24742
|
-
|
|
25023
|
+
const previousContent = Array.isArray((_a = ctx == null ? void 0 : ctx.previousNode) == null ? void 0 : _a.content) ? ctx.previousNode.content : [];
|
|
25024
|
+
const previousNodeIsEmptyParagraph = ((_b = ctx == null ? void 0 : ctx.previousNode) == null ? void 0 : _b.type) === "paragraph" && previousContent.length === 0;
|
|
25025
|
+
return previousNodeIsEmptyParagraph ? EMPTY_PARAGRAPH_MARKDOWN : "";
|
|
24743
25026
|
}
|
|
24744
25027
|
return h.renderChildren(content);
|
|
24745
25028
|
},
|
|
@@ -25871,7 +26154,7 @@ function history(config = {}) {
|
|
|
25871
26154
|
beforeinput(view, e) {
|
|
25872
26155
|
let inputType = e.inputType;
|
|
25873
26156
|
let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
|
|
25874
|
-
if (!command)
|
|
26157
|
+
if (!command || !view.editable)
|
|
25875
26158
|
return false;
|
|
25876
26159
|
e.preventDefault();
|
|
25877
26160
|
return command(view.state, view.dispatch);
|
|
@@ -26122,6 +26405,9 @@ Extension.create({
|
|
|
26122
26405
|
doc.descendants((node, pos) => {
|
|
26123
26406
|
const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
|
|
26124
26407
|
const isEmpty = !node.isLeaf && isNodeEmpty(node);
|
|
26408
|
+
if (!node.type.isTextblock) {
|
|
26409
|
+
return this.options.includeChildren;
|
|
26410
|
+
}
|
|
26125
26411
|
if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
|
|
26126
26412
|
const classes = [this.options.emptyNodeClass];
|
|
26127
26413
|
if (isEmptyDoc) {
|
|
@@ -26175,6 +26461,7 @@ Extension.create({
|
|
|
26175
26461
|
];
|
|
26176
26462
|
}
|
|
26177
26463
|
});
|
|
26464
|
+
var skipTrailingNodeMeta = "skipTrailingNode";
|
|
26178
26465
|
function nodeEqualsType({ types, node }) {
|
|
26179
26466
|
return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
|
|
26180
26467
|
}
|
|
@@ -26194,11 +26481,14 @@ var TrailingNode = Extension.create({
|
|
|
26194
26481
|
return [
|
|
26195
26482
|
new Plugin({
|
|
26196
26483
|
key: plugin,
|
|
26197
|
-
appendTransaction: (
|
|
26484
|
+
appendTransaction: (transactions, __, state) => {
|
|
26198
26485
|
const { doc, tr, schema } = state;
|
|
26199
26486
|
const shouldInsertNodeAtEnd = plugin.getState(state);
|
|
26200
26487
|
const endPosition = doc.content.size;
|
|
26201
26488
|
const type = schema.nodes[defaultNode];
|
|
26489
|
+
if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
|
|
26490
|
+
return;
|
|
26491
|
+
}
|
|
26202
26492
|
if (!shouldInsertNodeAtEnd) {
|
|
26203
26493
|
return;
|
|
26204
26494
|
}
|