@tiptap/core 2.1.0-rc.8 → 2.1.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/index.cjs +386 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +373 -58
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +386 -58
- 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/getNodeAtPosition.d.ts +11 -0
- 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 -47
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +1 -1
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -0
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -0
- 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/getNodeAtPosition.ts +29 -0
- 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 -47
- package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
- package/src/helpers/isActive.ts +3 -3
- package/src/helpers/isAtEndOfNode.ts +29 -0
- package/src/helpers/isAtStartOfNode.ts +11 -0
- 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 +60 -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;
|
|
@@ -2958,6 +3239,7 @@
|
|
|
2958
3239
|
clearNodes: clearNodes,
|
|
2959
3240
|
command: command,
|
|
2960
3241
|
createParagraphNear: createParagraphNear,
|
|
3242
|
+
cut: cut,
|
|
2961
3243
|
deleteCurrentNode: deleteCurrentNode,
|
|
2962
3244
|
deleteNode: deleteNode,
|
|
2963
3245
|
deleteRange: deleteRange,
|
|
@@ -2974,6 +3256,8 @@
|
|
|
2974
3256
|
joinDown: joinDown,
|
|
2975
3257
|
joinBackward: joinBackward,
|
|
2976
3258
|
joinForward: joinForward,
|
|
3259
|
+
joinItemBackward: joinItemBackward,
|
|
3260
|
+
joinItemForward: joinItemForward,
|
|
2977
3261
|
keyboardShortcut: keyboardShortcut,
|
|
2978
3262
|
lift: lift,
|
|
2979
3263
|
liftEmptyBlock: liftEmptyBlock,
|
|
@@ -3275,8 +3559,8 @@ img.ProseMirror-separator {
|
|
|
3275
3559
|
opacity: 0
|
|
3276
3560
|
}`;
|
|
3277
3561
|
|
|
3278
|
-
function createStyleTag(style, nonce) {
|
|
3279
|
-
const tiptapStyleTag = document.querySelector(
|
|
3562
|
+
function createStyleTag(style, nonce, suffix) {
|
|
3563
|
+
const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ''}]`);
|
|
3280
3564
|
if (tiptapStyleTag !== null) {
|
|
3281
3565
|
return tiptapStyleTag;
|
|
3282
3566
|
}
|
|
@@ -3284,7 +3568,7 @@ img.ProseMirror-separator {
|
|
|
3284
3568
|
if (nonce) {
|
|
3285
3569
|
styleNode.setAttribute('nonce', nonce);
|
|
3286
3570
|
}
|
|
3287
|
-
styleNode.setAttribute(
|
|
3571
|
+
styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ''}`, '');
|
|
3288
3572
|
styleNode.innerHTML = style;
|
|
3289
3573
|
document.getElementsByTagName('head')[0].appendChild(styleNode);
|
|
3290
3574
|
return styleNode;
|
|
@@ -3661,7 +3945,6 @@ img.ProseMirror-separator {
|
|
|
3661
3945
|
const { tr } = state;
|
|
3662
3946
|
const captureGroup = match[match.length - 1];
|
|
3663
3947
|
const fullMatch = match[0];
|
|
3664
|
-
let markEnd = range.to;
|
|
3665
3948
|
if (captureGroup) {
|
|
3666
3949
|
const startSpaces = fullMatch.search(/\S/);
|
|
3667
3950
|
const textStart = range.from + fullMatch.indexOf(captureGroup);
|
|
@@ -3682,7 +3965,7 @@ img.ProseMirror-separator {
|
|
|
3682
3965
|
if (textStart > range.from) {
|
|
3683
3966
|
tr.delete(range.from + startSpaces, textStart);
|
|
3684
3967
|
}
|
|
3685
|
-
markEnd = range.from + startSpaces + captureGroup.length;
|
|
3968
|
+
const markEnd = range.from + startSpaces + captureGroup.length;
|
|
3686
3969
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
3687
3970
|
tr.removeStoredMark(config.type);
|
|
3688
3971
|
}
|
|
@@ -3697,11 +3980,14 @@ img.ProseMirror-separator {
|
|
|
3697
3980
|
function nodeInputRule(config) {
|
|
3698
3981
|
return new InputRule({
|
|
3699
3982
|
find: config.find,
|
|
3700
|
-
handler: ({ state, range, match }) => {
|
|
3983
|
+
handler: ({ state: state$1, range, match }) => {
|
|
3984
|
+
var _a;
|
|
3701
3985
|
const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
|
|
3702
|
-
const { tr } = state;
|
|
3703
|
-
const start = range.from;
|
|
3986
|
+
const { tr } = state$1;
|
|
3987
|
+
const start = config.blockReplace ? range.from - 1 : range.from;
|
|
3704
3988
|
let end = range.to;
|
|
3989
|
+
const newNode = config.type.create(attributes);
|
|
3990
|
+
const { $to } = tr.selection;
|
|
3705
3991
|
if (match[1]) {
|
|
3706
3992
|
const offset = match[0].lastIndexOf(match[1]);
|
|
3707
3993
|
let matchStart = start + offset;
|
|
@@ -3715,10 +4001,34 @@ img.ProseMirror-separator {
|
|
|
3715
4001
|
const lastChar = match[0][match[0].length - 1];
|
|
3716
4002
|
tr.insertText(lastChar, start + match[0].length - 1);
|
|
3717
4003
|
// insert node from input rule
|
|
3718
|
-
tr.replaceWith(matchStart, end,
|
|
4004
|
+
tr.replaceWith(matchStart, end, newNode);
|
|
3719
4005
|
}
|
|
3720
4006
|
else if (match[0]) {
|
|
3721
|
-
tr.replaceWith(start, end,
|
|
4007
|
+
tr.replaceWith(start, end, newNode);
|
|
4008
|
+
}
|
|
4009
|
+
if (config.blockReplace && config.addExtraNewline) {
|
|
4010
|
+
const posAfter = $to.end();
|
|
4011
|
+
if ($to.nodeAfter) {
|
|
4012
|
+
console.log($to.node().type.name);
|
|
4013
|
+
if ($to.nodeAfter.isTextblock) {
|
|
4014
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos + 1));
|
|
4015
|
+
}
|
|
4016
|
+
else if ($to.nodeAfter.isBlock) {
|
|
4017
|
+
tr.setSelection(state.NodeSelection.create(tr.doc, $to.pos));
|
|
4018
|
+
}
|
|
4019
|
+
else {
|
|
4020
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos));
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
else {
|
|
4024
|
+
// add node after horizontal rule if it’s the end of the document
|
|
4025
|
+
const node = (_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create();
|
|
4026
|
+
if (node) {
|
|
4027
|
+
tr.insert(posAfter, node);
|
|
4028
|
+
tr.setSelection(state.TextSelection.create(tr.doc, posAfter + 1));
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
tr.scrollIntoView();
|
|
3722
4032
|
}
|
|
3723
4033
|
},
|
|
3724
4034
|
});
|
|
@@ -3970,6 +4280,10 @@ img.ProseMirror-separator {
|
|
|
3970
4280
|
}
|
|
3971
4281
|
}
|
|
3972
4282
|
|
|
4283
|
+
function isAndroid() {
|
|
4284
|
+
return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
|
|
4285
|
+
}
|
|
4286
|
+
|
|
3973
4287
|
class NodeView {
|
|
3974
4288
|
constructor(component, props, options) {
|
|
3975
4289
|
this.isDragging = false;
|
|
@@ -4110,13 +4424,14 @@ img.ProseMirror-separator {
|
|
|
4110
4424
|
if (mutation.type === 'selection') {
|
|
4111
4425
|
return false;
|
|
4112
4426
|
}
|
|
4113
|
-
// try to prevent a bug on iOS that will break node views on enter
|
|
4427
|
+
// try to prevent a bug on iOS and Android that will break node views on enter
|
|
4114
4428
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
4115
4429
|
// this will lead to a re-render of the node view on enter
|
|
4116
4430
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
4431
|
+
// see: https://github.com/ueberdosis/tiptap/issues/2534
|
|
4117
4432
|
if (this.dom.contains(mutation.target)
|
|
4118
4433
|
&& mutation.type === 'childList'
|
|
4119
|
-
&& isiOS()
|
|
4434
|
+
&& (isiOS() || isAndroid())
|
|
4120
4435
|
&& this.editor.isFocused) {
|
|
4121
4436
|
const changedNodes = [
|
|
4122
4437
|
...Array.from(mutation.addedNodes),
|
|
@@ -4303,6 +4618,7 @@ img.ProseMirror-separator {
|
|
|
4303
4618
|
exports.findChildren = findChildren;
|
|
4304
4619
|
exports.findChildrenInRange = findChildrenInRange;
|
|
4305
4620
|
exports.findDuplicates = findDuplicates;
|
|
4621
|
+
exports.findListItemPos = findListItemPos;
|
|
4306
4622
|
exports.findParentNode = findParentNode;
|
|
4307
4623
|
exports.findParentNodeClosestToPos = findParentNodeClosestToPos;
|
|
4308
4624
|
exports.fromString = fromString;
|
|
@@ -4319,6 +4635,8 @@ img.ProseMirror-separator {
|
|
|
4319
4635
|
exports.getMarkRange = getMarkRange;
|
|
4320
4636
|
exports.getMarkType = getMarkType;
|
|
4321
4637
|
exports.getMarksBetween = getMarksBetween;
|
|
4638
|
+
exports.getNextListDepth = getNextListDepth;
|
|
4639
|
+
exports.getNodeAtPosition = getNodeAtPosition;
|
|
4322
4640
|
exports.getNodeAttributes = getNodeAttributes;
|
|
4323
4641
|
exports.getNodeType = getNodeType;
|
|
4324
4642
|
exports.getRenderedAttributes = getRenderedAttributes;
|
|
@@ -4331,9 +4649,16 @@ img.ProseMirror-separator {
|
|
|
4331
4649
|
exports.getTextBetween = getTextBetween;
|
|
4332
4650
|
exports.getTextContentFromNodes = getTextContentFromNodes;
|
|
4333
4651
|
exports.getTextSerializersFromSchema = getTextSerializersFromSchema;
|
|
4652
|
+
exports.handleBackspace = handleBackspace;
|
|
4653
|
+
exports.handleDelete = handleDelete;
|
|
4654
|
+
exports.hasListBefore = hasListBefore;
|
|
4655
|
+
exports.hasListItemAfter = hasListItemAfter;
|
|
4656
|
+
exports.hasListItemBefore = hasListItemBefore;
|
|
4334
4657
|
exports.injectExtensionAttributesToParseRule = injectExtensionAttributesToParseRule;
|
|
4335
4658
|
exports.inputRulesPlugin = inputRulesPlugin;
|
|
4336
4659
|
exports.isActive = isActive;
|
|
4660
|
+
exports.isAtEndOfNode = isAtEndOfNode;
|
|
4661
|
+
exports.isAtStartOfNode = isAtStartOfNode;
|
|
4337
4662
|
exports.isEmptyObject = isEmptyObject;
|
|
4338
4663
|
exports.isExtensionRulesEnabled = isExtensionRulesEnabled;
|
|
4339
4664
|
exports.isFunction = isFunction;
|
|
@@ -4349,11 +4674,14 @@ img.ProseMirror-separator {
|
|
|
4349
4674
|
exports.isString = isString;
|
|
4350
4675
|
exports.isTextSelection = isTextSelection;
|
|
4351
4676
|
exports.isiOS = isiOS;
|
|
4677
|
+
exports.listItemHasSubList = listItemHasSubList;
|
|
4352
4678
|
exports.markInputRule = markInputRule;
|
|
4353
4679
|
exports.markPasteRule = markPasteRule;
|
|
4354
4680
|
exports.mergeAttributes = mergeAttributes;
|
|
4355
4681
|
exports.mergeDeep = mergeDeep;
|
|
4356
4682
|
exports.minMax = minMax;
|
|
4683
|
+
exports.nextListIsDeeper = nextListIsDeeper;
|
|
4684
|
+
exports.nextListIsHigher = nextListIsHigher;
|
|
4357
4685
|
exports.nodeInputRule = nodeInputRule;
|
|
4358
4686
|
exports.nodePasteRule = nodePasteRule;
|
|
4359
4687
|
exports.objectIncludes = objectIncludes;
|