@tiptap/core 2.1.0-rc.9 → 2.1.1
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/index.cjs +383 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +372 -98
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +383 -99
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/CommandManager.d.ts +2 -2
- package/dist/packages/core/src/Editor.d.ts +4 -4
- package/dist/packages/core/src/Extension.d.ts +7 -7
- package/dist/packages/core/src/ExtensionManager.d.ts +2 -2
- package/dist/packages/core/src/InputRule.d.ts +2 -2
- package/dist/packages/core/src/Mark.d.ts +6 -6
- package/dist/packages/core/src/Node.d.ts +5 -5
- package/dist/packages/core/src/NodeView.d.ts +3 -3
- package/dist/packages/core/src/PasteRule.d.ts +2 -2
- package/dist/packages/core/src/commands/blur.d.ts +1 -1
- package/dist/packages/core/src/commands/clearContent.d.ts +1 -1
- package/dist/packages/core/src/commands/clearNodes.d.ts +1 -1
- package/dist/packages/core/src/commands/command.d.ts +1 -1
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -1
- package/dist/packages/core/src/commands/cut.d.ts +15 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteNode.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/enter.d.ts +1 -1
- package/dist/packages/core/src/commands/exitCode.d.ts +1 -1
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +1 -1
- package/dist/packages/core/src/commands/first.d.ts +1 -1
- package/dist/packages/core/src/commands/focus.d.ts +1 -1
- package/dist/packages/core/src/commands/forEach.d.ts +1 -1
- package/dist/packages/core/src/commands/index.d.ts +53 -50
- package/dist/packages/core/src/commands/insertContent.d.ts +1 -1
- package/dist/packages/core/src/commands/insertContentAt.d.ts +1 -1
- package/dist/packages/core/src/commands/join.d.ts +1 -1
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +12 -0
- package/dist/packages/core/src/commands/joinItemForward.d.ts +12 -0
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +1 -1
- package/dist/packages/core/src/commands/lift.d.ts +1 -1
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +1 -1
- package/dist/packages/core/src/commands/liftListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -1
- package/dist/packages/core/src/commands/resetAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -1
- package/dist/packages/core/src/commands/selectAll.d.ts +1 -1
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -1
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -1
- package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -1
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -1
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -1
- package/dist/packages/core/src/commands/setContent.d.ts +1 -1
- package/dist/packages/core/src/commands/setMark.d.ts +1 -1
- package/dist/packages/core/src/commands/setMeta.d.ts +1 -1
- package/dist/packages/core/src/commands/setNode.d.ts +1 -1
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/sinkListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/splitBlock.d.ts +1 -1
- package/dist/packages/core/src/commands/splitListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleList.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleMark.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleNode.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleWrap.d.ts +1 -1
- package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -1
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -1
- package/dist/packages/core/src/commands/unsetMark.d.ts +1 -1
- package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/wrapIn.d.ts +1 -1
- package/dist/packages/core/src/commands/wrapInList.d.ts +1 -1
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
- package/dist/packages/core/src/extensions/commands.d.ts +2 -2
- package/dist/packages/core/src/extensions/editable.d.ts +1 -1
- package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
- package/dist/packages/core/src/extensions/index.d.ts +6 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
- package/dist/packages/core/src/extensions/tabindex.d.ts +1 -1
- package/dist/packages/core/src/helpers/createDocument.d.ts +1 -1
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +1 -1
- package/dist/packages/core/src/helpers/findChildren.d.ts +1 -1
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +1 -1
- package/dist/packages/core/src/helpers/findParentNode.d.ts +1 -1
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateHTML.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateJSON.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateText.d.ts +1 -1
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +1 -1
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +1 -1
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +1 -1
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +1 -1
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getSchema.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getText.d.ts +1 -1
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +1 -1
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +1 -1
- package/dist/packages/core/src/helpers/index.d.ts +51 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +1 -1
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +1 -1
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +1 -1
- package/dist/packages/core/src/helpers/isList.d.ts +1 -1
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +1 -1
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +4 -4
- package/dist/packages/core/src/index.d.ts +15 -15
- package/dist/packages/core/src/inputRules/index.d.ts +5 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +2 -2
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +22 -2
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -1
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +2 -2
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +3 -3
- package/dist/packages/core/src/pasteRules/index.d.ts +3 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +2 -2
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +2 -2
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +5 -5
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +1 -1
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
- package/dist/packages/core/src/utilities/index.d.ts +20 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/findListItemPos.d.ts +6 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/getNextListDepth.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/handleBackspace.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/handleDelete.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListBefore.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListItemAfter.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListItemBefore.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/index.d.ts +10 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/listItemHasSubList.d.ts +3 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/nextListIsDeeper.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/nextListIsHigher.d.ts +2 -0
- package/package.json +2 -2
- package/src/CommandManager.ts +4 -8
- package/src/Editor.ts +16 -16
- package/src/Extension.ts +10 -10
- package/src/ExtensionManager.ts +15 -15
- package/src/InputRule.ts +6 -6
- package/src/Mark.ts +9 -9
- package/src/Node.ts +8 -8
- package/src/NodeView.ts +8 -6
- package/src/PasteRule.ts +6 -6
- package/src/commands/blur.ts +1 -1
- package/src/commands/clearContent.ts +1 -1
- package/src/commands/clearNodes.ts +1 -1
- package/src/commands/command.ts +1 -1
- package/src/commands/createParagraphNear.ts +1 -1
- package/src/commands/cut.ts +29 -0
- package/src/commands/deleteCurrentNode.ts +1 -1
- package/src/commands/deleteNode.ts +2 -2
- package/src/commands/deleteRange.ts +1 -1
- package/src/commands/deleteSelection.ts +1 -1
- package/src/commands/enter.ts +1 -1
- package/src/commands/exitCode.ts +1 -1
- package/src/commands/extendMarkRange.ts +3 -3
- package/src/commands/first.ts +1 -1
- package/src/commands/focus.ts +4 -4
- package/src/commands/forEach.ts +1 -1
- package/src/commands/index.ts +53 -50
- package/src/commands/insertContent.ts +1 -1
- package/src/commands/insertContentAt.ts +4 -4
- package/src/commands/join.ts +1 -1
- package/src/commands/joinItemBackward.ts +36 -0
- package/src/commands/joinItemForward.ts +38 -0
- package/src/commands/keyboardShortcut.ts +3 -3
- package/src/commands/lift.ts +3 -3
- package/src/commands/liftEmptyBlock.ts +1 -1
- package/src/commands/liftListItem.ts +2 -2
- package/src/commands/newlineInCode.ts +1 -1
- package/src/commands/resetAttributes.ts +5 -5
- package/src/commands/scrollIntoView.ts +1 -1
- package/src/commands/selectAll.ts +1 -1
- package/src/commands/selectNodeBackward.ts +1 -1
- package/src/commands/selectNodeForward.ts +1 -1
- package/src/commands/selectParentNode.ts +1 -1
- package/src/commands/selectTextblockEnd.ts +1 -1
- package/src/commands/selectTextblockStart.ts +1 -1
- package/src/commands/setContent.ts +2 -2
- package/src/commands/setMark.ts +4 -4
- package/src/commands/setMeta.ts +1 -1
- package/src/commands/setNode.ts +2 -2
- package/src/commands/setNodeSelection.ts +2 -2
- package/src/commands/setTextSelection.ts +2 -2
- package/src/commands/sinkListItem.ts +2 -2
- package/src/commands/splitBlock.ts +3 -3
- package/src/commands/splitListItem.ts +3 -3
- package/src/commands/toggleList.ts +4 -4
- package/src/commands/toggleMark.ts +3 -3
- package/src/commands/toggleNode.ts +3 -3
- package/src/commands/toggleWrap.ts +3 -3
- package/src/commands/undoInputRule.ts +1 -1
- package/src/commands/unsetAllMarks.ts +1 -1
- package/src/commands/unsetMark.ts +3 -3
- package/src/commands/updateAttributes.ts +4 -4
- package/src/commands/wrapIn.ts +2 -2
- package/src/commands/wrapInList.ts +2 -2
- package/src/extensions/clipboardTextSerializer.ts +3 -3
- package/src/extensions/commands.ts +3 -3
- package/src/extensions/editable.ts +1 -1
- package/src/extensions/focusEvents.ts +1 -1
- package/src/extensions/index.ts +6 -6
- package/src/extensions/keymap.ts +7 -5
- package/src/extensions/tabindex.ts +1 -1
- package/src/helpers/createDocument.ts +2 -2
- package/src/helpers/createNodeFromContent.ts +2 -2
- package/src/helpers/findChildren.ts +1 -1
- package/src/helpers/findChildrenInRange.ts +1 -1
- package/src/helpers/findParentNode.ts +2 -2
- package/src/helpers/findParentNodeClosestToPos.ts +1 -1
- package/src/helpers/generateHTML.ts +3 -3
- package/src/helpers/generateJSON.ts +3 -3
- package/src/helpers/generateText.ts +4 -4
- package/src/helpers/getAttributes.ts +3 -3
- package/src/helpers/getAttributesFromExtensions.ts +4 -4
- package/src/helpers/getChangedRanges.ts +2 -2
- package/src/helpers/getDebugJSON.ts +1 -1
- package/src/helpers/getExtensionField.ts +1 -1
- package/src/helpers/getMarkAttributes.ts +1 -1
- package/src/helpers/getMarkRange.ts +2 -2
- package/src/helpers/getMarksBetween.ts +2 -2
- package/src/helpers/getNodeAttributes.ts +1 -1
- package/src/helpers/getRenderedAttributes.ts +2 -2
- package/src/helpers/getSchema.ts +4 -4
- package/src/helpers/getSchemaByResolvedExtensions.ts +9 -9
- package/src/helpers/getSplittedAttributes.ts +1 -1
- package/src/helpers/getText.ts +2 -2
- package/src/helpers/getTextBetween.ts +1 -1
- package/src/helpers/getTextSerializersFromSchema.ts +1 -1
- package/src/helpers/index.ts +51 -50
- package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
- package/src/helpers/isActive.ts +3 -3
- package/src/helpers/isAtEndOfNode.ts +20 -2
- package/src/helpers/isExtensionRulesEnabled.ts +1 -1
- package/src/helpers/isList.ts +5 -5
- package/src/helpers/isMarkActive.ts +3 -3
- package/src/helpers/isNodeActive.ts +3 -3
- package/src/helpers/posToDOMRect.ts +1 -1
- package/src/helpers/resolveFocusPosition.ts +2 -2
- package/src/helpers/splitExtensions.ts +4 -4
- package/src/index.ts +15 -15
- package/src/inputRules/index.ts +5 -5
- package/src/inputRules/markInputRule.ts +5 -6
- package/src/inputRules/nodeInputRule.ts +59 -6
- package/src/inputRules/textInputRule.ts +1 -1
- package/src/inputRules/textblockTypeInputRule.ts +3 -3
- package/src/inputRules/wrappingInputRule.ts +4 -4
- package/src/pasteRules/index.ts +3 -3
- package/src/pasteRules/markPasteRule.ts +4 -4
- package/src/pasteRules/nodePasteRule.ts +3 -3
- package/src/pasteRules/textPasteRule.ts +1 -1
- package/src/types.ts +5 -5
- package/src/utilities/callOrReturn.ts +2 -2
- package/src/utilities/createStyleTag.ts +3 -3
- package/src/utilities/index.ts +20 -20
- package/src/utilities/isAndroid.ts +3 -0
- package/src/utilities/mergeAttributes.ts +8 -1
- package/src/utilities/mergeDeep.ts +1 -1
- package/src/utilities/objectIncludes.ts +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -115,9 +115,6 @@
|
|
|
115
115
|
buildProps(tr, shouldDispatch = true) {
|
|
116
116
|
const { rawCommands, editor, state } = this;
|
|
117
117
|
const { view } = editor;
|
|
118
|
-
if (state.storedMarks) {
|
|
119
|
-
tr.setStoredMarks(state.storedMarks);
|
|
120
|
-
}
|
|
121
118
|
const props = {
|
|
122
119
|
tr,
|
|
123
120
|
editor,
|
|
@@ -127,7 +124,7 @@
|
|
|
127
124
|
transaction: tr,
|
|
128
125
|
}),
|
|
129
126
|
dispatch: shouldDispatch ? () => undefined : undefined,
|
|
130
|
-
chain: () => this.createChain(tr),
|
|
127
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
131
128
|
can: () => this.createCan(tr),
|
|
132
129
|
get commands() {
|
|
133
130
|
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
@@ -303,7 +300,10 @@
|
|
|
303
300
|
return;
|
|
304
301
|
}
|
|
305
302
|
if (key === 'class') {
|
|
306
|
-
|
|
303
|
+
const valueClasses = value.split(' ');
|
|
304
|
+
const existingClasses = mergedAttributes[key].split(' ');
|
|
305
|
+
const insertClasses = valueClasses.filter(valueClass => !existingClasses.includes(valueClass));
|
|
306
|
+
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ');
|
|
307
307
|
}
|
|
308
308
|
else if (key === 'style') {
|
|
309
309
|
mergedAttributes[key] = [mergedAttributes[key], value].join('; ');
|
|
@@ -1306,6 +1306,16 @@
|
|
|
1306
1306
|
return commands$1.createParagraphNear(state, dispatch);
|
|
1307
1307
|
};
|
|
1308
1308
|
|
|
1309
|
+
const cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
1310
|
+
const { state: state$1 } = editor;
|
|
1311
|
+
const contentSlice = state$1.doc.slice(originRange.from, originRange.to);
|
|
1312
|
+
tr.deleteRange(originRange.from, originRange.to);
|
|
1313
|
+
const newPos = tr.mapping.map(targetPos);
|
|
1314
|
+
tr.insert(newPos, contentSlice.content);
|
|
1315
|
+
tr.setSelection(new state.TextSelection(tr.doc.resolve(newPos - 1)));
|
|
1316
|
+
return true;
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1309
1319
|
const deleteCurrentNode = () => ({ tr, dispatch }) => {
|
|
1310
1320
|
const { selection } = tr;
|
|
1311
1321
|
const currentNode = selection.$anchor.node();
|
|
@@ -1635,7 +1645,7 @@
|
|
|
1635
1645
|
if (content.toString() === '<>') {
|
|
1636
1646
|
return true;
|
|
1637
1647
|
}
|
|
1638
|
-
let { from, to } = typeof position === 'number' ? { from: position, to: position } : position;
|
|
1648
|
+
let { from, to } = typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to };
|
|
1639
1649
|
let isOnlyTextContent = true;
|
|
1640
1650
|
let isOnlyBlockContent = true;
|
|
1641
1651
|
const nodes = isFragment(content) ? content : [content];
|
|
@@ -1697,6 +1707,40 @@
|
|
|
1697
1707
|
return commands$1.joinForward(state, dispatch);
|
|
1698
1708
|
};
|
|
1699
1709
|
|
|
1710
|
+
const joinItemBackward = () => ({ tr, state, dispatch, }) => {
|
|
1711
|
+
try {
|
|
1712
|
+
const point = transform.joinPoint(state.doc, state.selection.$from.pos, -1);
|
|
1713
|
+
if (point === null || point === undefined) {
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1716
|
+
tr.join(point, 2);
|
|
1717
|
+
if (dispatch) {
|
|
1718
|
+
dispatch(tr);
|
|
1719
|
+
}
|
|
1720
|
+
return true;
|
|
1721
|
+
}
|
|
1722
|
+
catch {
|
|
1723
|
+
return false;
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
const joinItemForward = () => ({ state, dispatch, tr, }) => {
|
|
1728
|
+
try {
|
|
1729
|
+
const point = transform.joinPoint(state.doc, state.selection.$from.pos, +1);
|
|
1730
|
+
if (point === null || point === undefined) {
|
|
1731
|
+
return false;
|
|
1732
|
+
}
|
|
1733
|
+
tr.join(point, 2);
|
|
1734
|
+
if (dispatch) {
|
|
1735
|
+
dispatch(tr);
|
|
1736
|
+
}
|
|
1737
|
+
return true;
|
|
1738
|
+
}
|
|
1739
|
+
catch (e) {
|
|
1740
|
+
return false;
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
|
|
1700
1744
|
function isMacOS() {
|
|
1701
1745
|
return typeof navigator !== 'undefined'
|
|
1702
1746
|
? /Mac/.test(navigator.platform)
|
|
@@ -1943,6 +1987,283 @@
|
|
|
1943
1987
|
return true;
|
|
1944
1988
|
};
|
|
1945
1989
|
|
|
1990
|
+
function getMarkAttributes(state, typeOrName) {
|
|
1991
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
1992
|
+
const { from, to, empty } = state.selection;
|
|
1993
|
+
const marks = [];
|
|
1994
|
+
if (empty) {
|
|
1995
|
+
if (state.storedMarks) {
|
|
1996
|
+
marks.push(...state.storedMarks);
|
|
1997
|
+
}
|
|
1998
|
+
marks.push(...state.selection.$head.marks());
|
|
1999
|
+
}
|
|
2000
|
+
else {
|
|
2001
|
+
state.doc.nodesBetween(from, to, node => {
|
|
2002
|
+
marks.push(...node.marks);
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
const mark = marks.find(markItem => markItem.type.name === type.name);
|
|
2006
|
+
if (!mark) {
|
|
2007
|
+
return {};
|
|
2008
|
+
}
|
|
2009
|
+
return { ...mark.attrs };
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
const findListItemPos = (typeOrName, state) => {
|
|
2013
|
+
const { $from } = state.selection;
|
|
2014
|
+
const nodeType = getNodeType(typeOrName, state.schema);
|
|
2015
|
+
let currentNode = null;
|
|
2016
|
+
let currentDepth = $from.depth;
|
|
2017
|
+
let currentPos = $from.pos;
|
|
2018
|
+
let targetDepth = null;
|
|
2019
|
+
while (currentDepth > 0 && targetDepth === null) {
|
|
2020
|
+
currentNode = $from.node(currentDepth);
|
|
2021
|
+
if (currentNode.type === nodeType) {
|
|
2022
|
+
targetDepth = currentDepth;
|
|
2023
|
+
}
|
|
2024
|
+
else {
|
|
2025
|
+
currentDepth -= 1;
|
|
2026
|
+
currentPos -= 1;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
if (targetDepth === null) {
|
|
2030
|
+
return null;
|
|
2031
|
+
}
|
|
2032
|
+
return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
|
|
2033
|
+
};
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* Finds the first node of a given type or name in the current selection.
|
|
2037
|
+
* @param state The editor state.
|
|
2038
|
+
* @param typeOrName The node type or name.
|
|
2039
|
+
* @param pos The position to start searching from.
|
|
2040
|
+
* @param maxDepth The maximum depth to search.
|
|
2041
|
+
* @returns The node and the depth as an array.
|
|
2042
|
+
*/
|
|
2043
|
+
const getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
|
|
2044
|
+
const $pos = state.doc.resolve(pos);
|
|
2045
|
+
let currentDepth = maxDepth;
|
|
2046
|
+
let node = null;
|
|
2047
|
+
while (currentDepth > 0 && node === null) {
|
|
2048
|
+
const currentNode = $pos.node(currentDepth);
|
|
2049
|
+
if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type.name) === typeOrName) {
|
|
2050
|
+
node = currentNode;
|
|
2051
|
+
}
|
|
2052
|
+
else {
|
|
2053
|
+
currentDepth -= 1;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
return [node, currentDepth];
|
|
2057
|
+
};
|
|
2058
|
+
|
|
2059
|
+
const getNextListDepth = (typeOrName, state) => {
|
|
2060
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
2061
|
+
if (!listItemPos) {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
|
|
2065
|
+
return depth;
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
const isAtStartOfNode = (state) => {
|
|
2069
|
+
const { $from, $to } = state.selection;
|
|
2070
|
+
if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
|
|
2071
|
+
return false;
|
|
2072
|
+
}
|
|
2073
|
+
return true;
|
|
2074
|
+
};
|
|
2075
|
+
|
|
2076
|
+
const hasListBefore = (editorState, name, parentListTypes) => {
|
|
2077
|
+
const { $anchor } = editorState.selection;
|
|
2078
|
+
const previousNodePos = Math.max(0, $anchor.pos - 2);
|
|
2079
|
+
const previousNode = editorState.doc.resolve(previousNodePos).node();
|
|
2080
|
+
if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
|
|
2081
|
+
return false;
|
|
2082
|
+
}
|
|
2083
|
+
return true;
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
const hasListItemBefore = (typeOrName, state) => {
|
|
2087
|
+
var _a;
|
|
2088
|
+
const { $anchor } = state.selection;
|
|
2089
|
+
const $targetPos = state.doc.resolve($anchor.pos - 2);
|
|
2090
|
+
if ($targetPos.index() === 0) {
|
|
2091
|
+
return false;
|
|
2092
|
+
}
|
|
2093
|
+
if (((_a = $targetPos.nodeBefore) === null || _a === void 0 ? void 0 : _a.type.name) !== typeOrName) {
|
|
2094
|
+
return false;
|
|
2095
|
+
}
|
|
2096
|
+
return true;
|
|
2097
|
+
};
|
|
2098
|
+
|
|
2099
|
+
const listItemHasSubList = (typeOrName, state, node) => {
|
|
2100
|
+
if (!node) {
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
const nodeType = getNodeType(typeOrName, state.schema);
|
|
2104
|
+
let hasSubList = false;
|
|
2105
|
+
node.descendants(child => {
|
|
2106
|
+
if (child.type === nodeType) {
|
|
2107
|
+
hasSubList = true;
|
|
2108
|
+
}
|
|
2109
|
+
});
|
|
2110
|
+
return hasSubList;
|
|
2111
|
+
};
|
|
2112
|
+
|
|
2113
|
+
const handleBackspace = (editor, name, parentListTypes) => {
|
|
2114
|
+
// this is required to still handle the undo handling
|
|
2115
|
+
if (editor.commands.undoInputRule()) {
|
|
2116
|
+
return true;
|
|
2117
|
+
}
|
|
2118
|
+
// if the current item is NOT inside a list item &
|
|
2119
|
+
// the previous item is a list (orderedList or bulletList)
|
|
2120
|
+
// move the cursor into the list and delete the current item
|
|
2121
|
+
if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
|
|
2122
|
+
const { $anchor } = editor.state.selection;
|
|
2123
|
+
const $listPos = editor.state.doc.resolve($anchor.before() - 1);
|
|
2124
|
+
const listDescendants = [];
|
|
2125
|
+
$listPos.node().descendants((node, pos) => {
|
|
2126
|
+
if (node.type.name === name) {
|
|
2127
|
+
listDescendants.push({ node, pos });
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
const lastItem = listDescendants.at(-1);
|
|
2131
|
+
if (!lastItem) {
|
|
2132
|
+
return false;
|
|
2133
|
+
}
|
|
2134
|
+
const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);
|
|
2135
|
+
return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run();
|
|
2136
|
+
}
|
|
2137
|
+
// if the cursor is not inside the current node type
|
|
2138
|
+
// do nothing and proceed
|
|
2139
|
+
if (!isNodeActive(editor.state, name)) {
|
|
2140
|
+
return false;
|
|
2141
|
+
}
|
|
2142
|
+
// if the cursor is not at the start of a node
|
|
2143
|
+
// do nothing and proceed
|
|
2144
|
+
if (!isAtStartOfNode(editor.state)) {
|
|
2145
|
+
return false;
|
|
2146
|
+
}
|
|
2147
|
+
const listItemPos = findListItemPos(name, editor.state);
|
|
2148
|
+
if (!listItemPos) {
|
|
2149
|
+
return false;
|
|
2150
|
+
}
|
|
2151
|
+
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
|
|
2152
|
+
const prevNode = $prev.node(listItemPos.depth);
|
|
2153
|
+
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);
|
|
2154
|
+
// if the previous item is a list item and doesn't have a sublist, join the list items
|
|
2155
|
+
if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {
|
|
2156
|
+
return editor.commands.joinItemBackward();
|
|
2157
|
+
}
|
|
2158
|
+
// otherwise in the end, a backspace should
|
|
2159
|
+
// always just lift the list item if
|
|
2160
|
+
// joining / merging is not possible
|
|
2161
|
+
return editor.chain().liftListItem(name).run();
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
function findParentNodeClosestToPos($pos, predicate) {
|
|
2165
|
+
for (let i = $pos.depth; i > 0; i -= 1) {
|
|
2166
|
+
const node = $pos.node(i);
|
|
2167
|
+
if (predicate(node)) {
|
|
2168
|
+
return {
|
|
2169
|
+
pos: i > 0 ? $pos.before(i) : 0,
|
|
2170
|
+
start: $pos.start(i),
|
|
2171
|
+
depth: i,
|
|
2172
|
+
node,
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
function findParentNode(predicate) {
|
|
2179
|
+
return (selection) => findParentNodeClosestToPos(selection.$from, predicate);
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
const isAtEndOfNode = (state, nodeType) => {
|
|
2183
|
+
const { $from, $to, $anchor } = state.selection;
|
|
2184
|
+
if (nodeType) {
|
|
2185
|
+
const parentNode = findParentNode(node => node.type.name === nodeType)(state.selection);
|
|
2186
|
+
if (!parentNode) {
|
|
2187
|
+
return false;
|
|
2188
|
+
}
|
|
2189
|
+
const $parentPos = state.doc.resolve(parentNode.pos + 1);
|
|
2190
|
+
if ($anchor.pos + 1 === $parentPos.end()) {
|
|
2191
|
+
return true;
|
|
2192
|
+
}
|
|
2193
|
+
return false;
|
|
2194
|
+
}
|
|
2195
|
+
if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
|
|
2196
|
+
return false;
|
|
2197
|
+
}
|
|
2198
|
+
return true;
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2201
|
+
const nextListIsDeeper = (typeOrName, state) => {
|
|
2202
|
+
const listDepth = getNextListDepth(typeOrName, state);
|
|
2203
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
2204
|
+
if (!listItemPos || !listDepth) {
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
if (listDepth > listItemPos.depth) {
|
|
2208
|
+
return true;
|
|
2209
|
+
}
|
|
2210
|
+
return false;
|
|
2211
|
+
};
|
|
2212
|
+
|
|
2213
|
+
const nextListIsHigher = (typeOrName, state) => {
|
|
2214
|
+
const listDepth = getNextListDepth(typeOrName, state);
|
|
2215
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
2216
|
+
if (!listItemPos || !listDepth) {
|
|
2217
|
+
return false;
|
|
2218
|
+
}
|
|
2219
|
+
if (listDepth < listItemPos.depth) {
|
|
2220
|
+
return true;
|
|
2221
|
+
}
|
|
2222
|
+
return false;
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
const handleDelete = (editor, name) => {
|
|
2226
|
+
// if the cursor is not inside the current node type
|
|
2227
|
+
// do nothing and proceed
|
|
2228
|
+
if (!isNodeActive(editor.state, name)) {
|
|
2229
|
+
return false;
|
|
2230
|
+
}
|
|
2231
|
+
// if the cursor is not at the end of a node
|
|
2232
|
+
// do nothing and proceed
|
|
2233
|
+
if (!isAtEndOfNode(editor.state, name)) {
|
|
2234
|
+
return false;
|
|
2235
|
+
}
|
|
2236
|
+
// check if the next node is a list with a deeper depth
|
|
2237
|
+
if (nextListIsDeeper(name, editor.state)) {
|
|
2238
|
+
return editor
|
|
2239
|
+
.chain()
|
|
2240
|
+
.focus(editor.state.selection.from + 4)
|
|
2241
|
+
.lift(name)
|
|
2242
|
+
.joinBackward()
|
|
2243
|
+
.run();
|
|
2244
|
+
}
|
|
2245
|
+
if (nextListIsHigher(name, editor.state)) {
|
|
2246
|
+
return editor.chain()
|
|
2247
|
+
.joinForward()
|
|
2248
|
+
.joinBackward()
|
|
2249
|
+
.run();
|
|
2250
|
+
}
|
|
2251
|
+
return editor.commands.joinItemForward();
|
|
2252
|
+
};
|
|
2253
|
+
|
|
2254
|
+
const hasListItemAfter = (typeOrName, state) => {
|
|
2255
|
+
var _a;
|
|
2256
|
+
const { $anchor } = state.selection;
|
|
2257
|
+
const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
|
|
2258
|
+
if ($targetPos.index() === $targetPos.parent.childCount - 1) {
|
|
2259
|
+
return false;
|
|
2260
|
+
}
|
|
2261
|
+
if (((_a = $targetPos.nodeAfter) === null || _a === void 0 ? void 0 : _a.type.name) !== typeOrName) {
|
|
2262
|
+
return false;
|
|
2263
|
+
}
|
|
2264
|
+
return true;
|
|
2265
|
+
};
|
|
2266
|
+
|
|
1946
2267
|
/**
|
|
1947
2268
|
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
1948
2269
|
*/
|
|
@@ -2004,24 +2325,6 @@
|
|
|
2004
2325
|
return nodesWithPos;
|
|
2005
2326
|
}
|
|
2006
2327
|
|
|
2007
|
-
function findParentNodeClosestToPos($pos, predicate) {
|
|
2008
|
-
for (let i = $pos.depth; i > 0; i -= 1) {
|
|
2009
|
-
const node = $pos.node(i);
|
|
2010
|
-
if (predicate(node)) {
|
|
2011
|
-
return {
|
|
2012
|
-
pos: i > 0 ? $pos.before(i) : 0,
|
|
2013
|
-
start: $pos.start(i),
|
|
2014
|
-
depth: i,
|
|
2015
|
-
node,
|
|
2016
|
-
};
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
function findParentNode(predicate) {
|
|
2022
|
-
return (selection) => findParentNodeClosestToPos(selection.$from, predicate);
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
2328
|
function getHTMLFromFragment(fragment, schema) {
|
|
2026
2329
|
const documentFragment = model.DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
2027
2330
|
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
@@ -2068,28 +2371,6 @@
|
|
|
2068
2371
|
});
|
|
2069
2372
|
}
|
|
2070
2373
|
|
|
2071
|
-
function getMarkAttributes(state, typeOrName) {
|
|
2072
|
-
const type = getMarkType(typeOrName, state.schema);
|
|
2073
|
-
const { from, to, empty } = state.selection;
|
|
2074
|
-
const marks = [];
|
|
2075
|
-
if (empty) {
|
|
2076
|
-
if (state.storedMarks) {
|
|
2077
|
-
marks.push(...state.storedMarks);
|
|
2078
|
-
}
|
|
2079
|
-
marks.push(...state.selection.$head.marks());
|
|
2080
|
-
}
|
|
2081
|
-
else {
|
|
2082
|
-
state.doc.nodesBetween(from, to, node => {
|
|
2083
|
-
marks.push(...node.marks);
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
const mark = marks.find(markItem => markItem.type.name === type.name);
|
|
2087
|
-
if (!mark) {
|
|
2088
|
-
return {};
|
|
2089
|
-
}
|
|
2090
|
-
return { ...mark.attrs };
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
2374
|
function getNodeAttributes(state, typeOrName) {
|
|
2094
2375
|
const type = getNodeType(typeOrName, state.schema);
|
|
2095
2376
|
const { from, to } = state.selection;
|
|
@@ -2261,30 +2542,6 @@
|
|
|
2261
2542
|
return marks;
|
|
2262
2543
|
}
|
|
2263
2544
|
|
|
2264
|
-
/**
|
|
2265
|
-
* Finds the first node of a given type or name in the current selection.
|
|
2266
|
-
* @param state The editor state.
|
|
2267
|
-
* @param typeOrName The node type or name.
|
|
2268
|
-
* @param pos The position to start searching from.
|
|
2269
|
-
* @param maxDepth The maximum depth to search.
|
|
2270
|
-
* @returns The node and the depth as an array.
|
|
2271
|
-
*/
|
|
2272
|
-
const getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
|
|
2273
|
-
const $pos = state.doc.resolve(pos);
|
|
2274
|
-
let currentDepth = maxDepth;
|
|
2275
|
-
let node = null;
|
|
2276
|
-
while (currentDepth > 0 && node === null) {
|
|
2277
|
-
const currentNode = $pos.node(currentDepth);
|
|
2278
|
-
if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type.name) === typeOrName) {
|
|
2279
|
-
node = currentNode;
|
|
2280
|
-
}
|
|
2281
|
-
else {
|
|
2282
|
-
currentDepth -= 1;
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
return [node, currentDepth];
|
|
2286
|
-
};
|
|
2287
|
-
|
|
2288
2545
|
function getSplittedAttributes(extensionAttributes, typeName, attributes) {
|
|
2289
2546
|
return Object.fromEntries(Object
|
|
2290
2547
|
.entries(attributes)
|
|
@@ -2375,22 +2632,6 @@
|
|
|
2375
2632
|
return false;
|
|
2376
2633
|
}
|
|
2377
2634
|
|
|
2378
|
-
const istAtEndOfNode = (state) => {
|
|
2379
|
-
const { $from, $to } = state.selection;
|
|
2380
|
-
if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
|
|
2381
|
-
return false;
|
|
2382
|
-
}
|
|
2383
|
-
return true;
|
|
2384
|
-
};
|
|
2385
|
-
|
|
2386
|
-
const isAtStartOfNode = (state) => {
|
|
2387
|
-
const { $from, $to } = state.selection;
|
|
2388
|
-
if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
|
|
2389
|
-
return false;
|
|
2390
|
-
}
|
|
2391
|
-
return true;
|
|
2392
|
-
};
|
|
2393
|
-
|
|
2394
2635
|
function isList(name, extensions) {
|
|
2395
2636
|
const { nodeExtensions } = splitExtensions(extensions);
|
|
2396
2637
|
const extension = nodeExtensions.find(item => item.name === name);
|
|
@@ -2998,6 +3239,7 @@
|
|
|
2998
3239
|
clearNodes: clearNodes,
|
|
2999
3240
|
command: command,
|
|
3000
3241
|
createParagraphNear: createParagraphNear,
|
|
3242
|
+
cut: cut,
|
|
3001
3243
|
deleteCurrentNode: deleteCurrentNode,
|
|
3002
3244
|
deleteNode: deleteNode,
|
|
3003
3245
|
deleteRange: deleteRange,
|
|
@@ -3014,6 +3256,8 @@
|
|
|
3014
3256
|
joinDown: joinDown,
|
|
3015
3257
|
joinBackward: joinBackward,
|
|
3016
3258
|
joinForward: joinForward,
|
|
3259
|
+
joinItemBackward: joinItemBackward,
|
|
3260
|
+
joinItemForward: joinItemForward,
|
|
3017
3261
|
keyboardShortcut: keyboardShortcut,
|
|
3018
3262
|
lift: lift,
|
|
3019
3263
|
liftEmptyBlock: liftEmptyBlock,
|
|
@@ -3315,8 +3559,8 @@ img.ProseMirror-separator {
|
|
|
3315
3559
|
opacity: 0
|
|
3316
3560
|
}`;
|
|
3317
3561
|
|
|
3318
|
-
function createStyleTag(style, nonce) {
|
|
3319
|
-
const tiptapStyleTag = document.querySelector(
|
|
3562
|
+
function createStyleTag(style, nonce, suffix) {
|
|
3563
|
+
const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ''}]`);
|
|
3320
3564
|
if (tiptapStyleTag !== null) {
|
|
3321
3565
|
return tiptapStyleTag;
|
|
3322
3566
|
}
|
|
@@ -3324,7 +3568,7 @@ img.ProseMirror-separator {
|
|
|
3324
3568
|
if (nonce) {
|
|
3325
3569
|
styleNode.setAttribute('nonce', nonce);
|
|
3326
3570
|
}
|
|
3327
|
-
styleNode.setAttribute(
|
|
3571
|
+
styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ''}`, '');
|
|
3328
3572
|
styleNode.innerHTML = style;
|
|
3329
3573
|
document.getElementsByTagName('head')[0].appendChild(styleNode);
|
|
3330
3574
|
return styleNode;
|
|
@@ -3701,7 +3945,6 @@ img.ProseMirror-separator {
|
|
|
3701
3945
|
const { tr } = state;
|
|
3702
3946
|
const captureGroup = match[match.length - 1];
|
|
3703
3947
|
const fullMatch = match[0];
|
|
3704
|
-
let markEnd = range.to;
|
|
3705
3948
|
if (captureGroup) {
|
|
3706
3949
|
const startSpaces = fullMatch.search(/\S/);
|
|
3707
3950
|
const textStart = range.from + fullMatch.indexOf(captureGroup);
|
|
@@ -3722,7 +3965,7 @@ img.ProseMirror-separator {
|
|
|
3722
3965
|
if (textStart > range.from) {
|
|
3723
3966
|
tr.delete(range.from + startSpaces, textStart);
|
|
3724
3967
|
}
|
|
3725
|
-
markEnd = range.from + startSpaces + captureGroup.length;
|
|
3968
|
+
const markEnd = range.from + startSpaces + captureGroup.length;
|
|
3726
3969
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
3727
3970
|
tr.removeStoredMark(config.type);
|
|
3728
3971
|
}
|
|
@@ -3737,11 +3980,14 @@ img.ProseMirror-separator {
|
|
|
3737
3980
|
function nodeInputRule(config) {
|
|
3738
3981
|
return new InputRule({
|
|
3739
3982
|
find: config.find,
|
|
3740
|
-
handler: ({ state, range, match }) => {
|
|
3983
|
+
handler: ({ state: state$1, range, match }) => {
|
|
3984
|
+
var _a, _b;
|
|
3741
3985
|
const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
|
|
3742
|
-
const { tr } = state;
|
|
3743
|
-
const start = range.from;
|
|
3986
|
+
const { tr } = state$1;
|
|
3987
|
+
const start = config.blockReplace ? range.from - 1 : range.from;
|
|
3744
3988
|
let end = range.to;
|
|
3989
|
+
const newNode = config.type.create(attributes);
|
|
3990
|
+
const { $to } = tr.selection;
|
|
3745
3991
|
if (match[1]) {
|
|
3746
3992
|
const offset = match[0].lastIndexOf(match[1]);
|
|
3747
3993
|
let matchStart = start + offset;
|
|
@@ -3755,10 +4001,33 @@ img.ProseMirror-separator {
|
|
|
3755
4001
|
const lastChar = match[0][match[0].length - 1];
|
|
3756
4002
|
tr.insertText(lastChar, start + match[0].length - 1);
|
|
3757
4003
|
// insert node from input rule
|
|
3758
|
-
tr.replaceWith(matchStart, end,
|
|
4004
|
+
tr.replaceWith(matchStart, end, newNode);
|
|
3759
4005
|
}
|
|
3760
4006
|
else if (match[0]) {
|
|
3761
|
-
tr.replaceWith(start, end,
|
|
4007
|
+
tr.replaceWith(start, end, newNode);
|
|
4008
|
+
}
|
|
4009
|
+
if (config.blockReplace && config.addExtraNewline) {
|
|
4010
|
+
if ($to.nodeAfter) {
|
|
4011
|
+
if ($to.nodeAfter.isTextblock) {
|
|
4012
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos + 1));
|
|
4013
|
+
}
|
|
4014
|
+
else if ($to.nodeAfter.isBlock) {
|
|
4015
|
+
tr.setSelection(state.NodeSelection.create(tr.doc, $to.pos));
|
|
4016
|
+
}
|
|
4017
|
+
else {
|
|
4018
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos - 1));
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
else {
|
|
4022
|
+
// add node after horizontal rule if it’s the end of the document
|
|
4023
|
+
const defaultNode = ((_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create()) || ((_b = state$1.doc.type.contentMatch.defaultType) === null || _b === void 0 ? void 0 : _b.create());
|
|
4024
|
+
if (defaultNode) {
|
|
4025
|
+
const newPos = start + newNode.nodeSize;
|
|
4026
|
+
tr.insert(newPos, defaultNode);
|
|
4027
|
+
tr.setSelection(state.TextSelection.create(tr.doc, newPos));
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
tr.scrollIntoView();
|
|
3762
4031
|
}
|
|
3763
4032
|
},
|
|
3764
4033
|
});
|
|
@@ -4010,6 +4279,10 @@ img.ProseMirror-separator {
|
|
|
4010
4279
|
}
|
|
4011
4280
|
}
|
|
4012
4281
|
|
|
4282
|
+
function isAndroid() {
|
|
4283
|
+
return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
|
|
4284
|
+
}
|
|
4285
|
+
|
|
4013
4286
|
class NodeView {
|
|
4014
4287
|
constructor(component, props, options) {
|
|
4015
4288
|
this.isDragging = false;
|
|
@@ -4150,13 +4423,14 @@ img.ProseMirror-separator {
|
|
|
4150
4423
|
if (mutation.type === 'selection') {
|
|
4151
4424
|
return false;
|
|
4152
4425
|
}
|
|
4153
|
-
// try to prevent a bug on iOS that will break node views on enter
|
|
4426
|
+
// try to prevent a bug on iOS and Android that will break node views on enter
|
|
4154
4427
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
4155
4428
|
// this will lead to a re-render of the node view on enter
|
|
4156
4429
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
4430
|
+
// see: https://github.com/ueberdosis/tiptap/issues/2534
|
|
4157
4431
|
if (this.dom.contains(mutation.target)
|
|
4158
4432
|
&& mutation.type === 'childList'
|
|
4159
|
-
&& isiOS()
|
|
4433
|
+
&& (isiOS() || isAndroid())
|
|
4160
4434
|
&& this.editor.isFocused) {
|
|
4161
4435
|
const changedNodes = [
|
|
4162
4436
|
...Array.from(mutation.addedNodes),
|
|
@@ -4343,6 +4617,7 @@ img.ProseMirror-separator {
|
|
|
4343
4617
|
exports.findChildren = findChildren;
|
|
4344
4618
|
exports.findChildrenInRange = findChildrenInRange;
|
|
4345
4619
|
exports.findDuplicates = findDuplicates;
|
|
4620
|
+
exports.findListItemPos = findListItemPos;
|
|
4346
4621
|
exports.findParentNode = findParentNode;
|
|
4347
4622
|
exports.findParentNodeClosestToPos = findParentNodeClosestToPos;
|
|
4348
4623
|
exports.fromString = fromString;
|
|
@@ -4359,6 +4634,7 @@ img.ProseMirror-separator {
|
|
|
4359
4634
|
exports.getMarkRange = getMarkRange;
|
|
4360
4635
|
exports.getMarkType = getMarkType;
|
|
4361
4636
|
exports.getMarksBetween = getMarksBetween;
|
|
4637
|
+
exports.getNextListDepth = getNextListDepth;
|
|
4362
4638
|
exports.getNodeAtPosition = getNodeAtPosition;
|
|
4363
4639
|
exports.getNodeAttributes = getNodeAttributes;
|
|
4364
4640
|
exports.getNodeType = getNodeType;
|
|
@@ -4372,9 +4648,15 @@ img.ProseMirror-separator {
|
|
|
4372
4648
|
exports.getTextBetween = getTextBetween;
|
|
4373
4649
|
exports.getTextContentFromNodes = getTextContentFromNodes;
|
|
4374
4650
|
exports.getTextSerializersFromSchema = getTextSerializersFromSchema;
|
|
4651
|
+
exports.handleBackspace = handleBackspace;
|
|
4652
|
+
exports.handleDelete = handleDelete;
|
|
4653
|
+
exports.hasListBefore = hasListBefore;
|
|
4654
|
+
exports.hasListItemAfter = hasListItemAfter;
|
|
4655
|
+
exports.hasListItemBefore = hasListItemBefore;
|
|
4375
4656
|
exports.injectExtensionAttributesToParseRule = injectExtensionAttributesToParseRule;
|
|
4376
4657
|
exports.inputRulesPlugin = inputRulesPlugin;
|
|
4377
4658
|
exports.isActive = isActive;
|
|
4659
|
+
exports.isAtEndOfNode = isAtEndOfNode;
|
|
4378
4660
|
exports.isAtStartOfNode = isAtStartOfNode;
|
|
4379
4661
|
exports.isEmptyObject = isEmptyObject;
|
|
4380
4662
|
exports.isExtensionRulesEnabled = isExtensionRulesEnabled;
|
|
@@ -4391,12 +4673,14 @@ img.ProseMirror-separator {
|
|
|
4391
4673
|
exports.isString = isString;
|
|
4392
4674
|
exports.isTextSelection = isTextSelection;
|
|
4393
4675
|
exports.isiOS = isiOS;
|
|
4394
|
-
exports.
|
|
4676
|
+
exports.listItemHasSubList = listItemHasSubList;
|
|
4395
4677
|
exports.markInputRule = markInputRule;
|
|
4396
4678
|
exports.markPasteRule = markPasteRule;
|
|
4397
4679
|
exports.mergeAttributes = mergeAttributes;
|
|
4398
4680
|
exports.mergeDeep = mergeDeep;
|
|
4399
4681
|
exports.minMax = minMax;
|
|
4682
|
+
exports.nextListIsDeeper = nextListIsDeeper;
|
|
4683
|
+
exports.nextListIsHigher = nextListIsHigher;
|
|
4400
4684
|
exports.nodeInputRule = nodeInputRule;
|
|
4401
4685
|
exports.nodePasteRule = nodePasteRule;
|
|
4402
4686
|
exports.objectIncludes = objectIncludes;
|