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