@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.cjs
CHANGED
|
@@ -121,9 +121,6 @@ class CommandManager {
|
|
|
121
121
|
buildProps(tr, shouldDispatch = true) {
|
|
122
122
|
const { rawCommands, editor, state } = this;
|
|
123
123
|
const { view } = editor;
|
|
124
|
-
if (state.storedMarks) {
|
|
125
|
-
tr.setStoredMarks(state.storedMarks);
|
|
126
|
-
}
|
|
127
124
|
const props = {
|
|
128
125
|
tr,
|
|
129
126
|
editor,
|
|
@@ -133,7 +130,7 @@ class CommandManager {
|
|
|
133
130
|
transaction: tr,
|
|
134
131
|
}),
|
|
135
132
|
dispatch: shouldDispatch ? () => undefined : undefined,
|
|
136
|
-
chain: () => this.createChain(tr),
|
|
133
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
137
134
|
can: () => this.createCan(tr),
|
|
138
135
|
get commands() {
|
|
139
136
|
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
@@ -309,7 +306,10 @@ function mergeAttributes(...objects) {
|
|
|
309
306
|
return;
|
|
310
307
|
}
|
|
311
308
|
if (key === 'class') {
|
|
312
|
-
|
|
309
|
+
const valueClasses = value.split(' ');
|
|
310
|
+
const existingClasses = mergedAttributes[key].split(' ');
|
|
311
|
+
const insertClasses = valueClasses.filter(valueClass => !existingClasses.includes(valueClass));
|
|
312
|
+
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ');
|
|
313
313
|
}
|
|
314
314
|
else if (key === 'style') {
|
|
315
315
|
mergedAttributes[key] = [mergedAttributes[key], value].join('; ');
|
|
@@ -1312,6 +1312,16 @@ const createParagraphNear = () => ({ state, dispatch }) => {
|
|
|
1312
1312
|
return commands$1.createParagraphNear(state, dispatch);
|
|
1313
1313
|
};
|
|
1314
1314
|
|
|
1315
|
+
const cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
1316
|
+
const { state: state$1 } = editor;
|
|
1317
|
+
const contentSlice = state$1.doc.slice(originRange.from, originRange.to);
|
|
1318
|
+
tr.deleteRange(originRange.from, originRange.to);
|
|
1319
|
+
const newPos = tr.mapping.map(targetPos);
|
|
1320
|
+
tr.insert(newPos, contentSlice.content);
|
|
1321
|
+
tr.setSelection(new state.TextSelection(tr.doc.resolve(newPos - 1)));
|
|
1322
|
+
return true;
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1315
1325
|
const deleteCurrentNode = () => ({ tr, dispatch }) => {
|
|
1316
1326
|
const { selection } = tr;
|
|
1317
1327
|
const currentNode = selection.$anchor.node();
|
|
@@ -1641,7 +1651,7 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
|
|
|
1641
1651
|
if (content.toString() === '<>') {
|
|
1642
1652
|
return true;
|
|
1643
1653
|
}
|
|
1644
|
-
let { from, to } = typeof position === 'number' ? { from: position, to: position } : position;
|
|
1654
|
+
let { from, to } = typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to };
|
|
1645
1655
|
let isOnlyTextContent = true;
|
|
1646
1656
|
let isOnlyBlockContent = true;
|
|
1647
1657
|
const nodes = isFragment(content) ? content : [content];
|
|
@@ -1703,6 +1713,40 @@ const joinForward = () => ({ state, dispatch }) => {
|
|
|
1703
1713
|
return commands$1.joinForward(state, dispatch);
|
|
1704
1714
|
};
|
|
1705
1715
|
|
|
1716
|
+
const joinItemBackward = () => ({ tr, state, dispatch, }) => {
|
|
1717
|
+
try {
|
|
1718
|
+
const point = transform.joinPoint(state.doc, state.selection.$from.pos, -1);
|
|
1719
|
+
if (point === null || point === undefined) {
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1722
|
+
tr.join(point, 2);
|
|
1723
|
+
if (dispatch) {
|
|
1724
|
+
dispatch(tr);
|
|
1725
|
+
}
|
|
1726
|
+
return true;
|
|
1727
|
+
}
|
|
1728
|
+
catch {
|
|
1729
|
+
return false;
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
|
|
1733
|
+
const joinItemForward = () => ({ state, dispatch, tr, }) => {
|
|
1734
|
+
try {
|
|
1735
|
+
const point = transform.joinPoint(state.doc, state.selection.$from.pos, +1);
|
|
1736
|
+
if (point === null || point === undefined) {
|
|
1737
|
+
return false;
|
|
1738
|
+
}
|
|
1739
|
+
tr.join(point, 2);
|
|
1740
|
+
if (dispatch) {
|
|
1741
|
+
dispatch(tr);
|
|
1742
|
+
}
|
|
1743
|
+
return true;
|
|
1744
|
+
}
|
|
1745
|
+
catch (e) {
|
|
1746
|
+
return false;
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
|
|
1706
1750
|
function isMacOS() {
|
|
1707
1751
|
return typeof navigator !== 'undefined'
|
|
1708
1752
|
? /Mac/.test(navigator.platform)
|
|
@@ -1949,6 +1993,283 @@ const setContent = (content, emitUpdate = false, parseOptions = {}) => ({ tr, ed
|
|
|
1949
1993
|
return true;
|
|
1950
1994
|
};
|
|
1951
1995
|
|
|
1996
|
+
function getMarkAttributes(state, typeOrName) {
|
|
1997
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
1998
|
+
const { from, to, empty } = state.selection;
|
|
1999
|
+
const marks = [];
|
|
2000
|
+
if (empty) {
|
|
2001
|
+
if (state.storedMarks) {
|
|
2002
|
+
marks.push(...state.storedMarks);
|
|
2003
|
+
}
|
|
2004
|
+
marks.push(...state.selection.$head.marks());
|
|
2005
|
+
}
|
|
2006
|
+
else {
|
|
2007
|
+
state.doc.nodesBetween(from, to, node => {
|
|
2008
|
+
marks.push(...node.marks);
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
const mark = marks.find(markItem => markItem.type.name === type.name);
|
|
2012
|
+
if (!mark) {
|
|
2013
|
+
return {};
|
|
2014
|
+
}
|
|
2015
|
+
return { ...mark.attrs };
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
const findListItemPos = (typeOrName, state) => {
|
|
2019
|
+
const { $from } = state.selection;
|
|
2020
|
+
const nodeType = getNodeType(typeOrName, state.schema);
|
|
2021
|
+
let currentNode = null;
|
|
2022
|
+
let currentDepth = $from.depth;
|
|
2023
|
+
let currentPos = $from.pos;
|
|
2024
|
+
let targetDepth = null;
|
|
2025
|
+
while (currentDepth > 0 && targetDepth === null) {
|
|
2026
|
+
currentNode = $from.node(currentDepth);
|
|
2027
|
+
if (currentNode.type === nodeType) {
|
|
2028
|
+
targetDepth = currentDepth;
|
|
2029
|
+
}
|
|
2030
|
+
else {
|
|
2031
|
+
currentDepth -= 1;
|
|
2032
|
+
currentPos -= 1;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
if (targetDepth === null) {
|
|
2036
|
+
return null;
|
|
2037
|
+
}
|
|
2038
|
+
return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
/**
|
|
2042
|
+
* Finds the first node of a given type or name in the current selection.
|
|
2043
|
+
* @param state The editor state.
|
|
2044
|
+
* @param typeOrName The node type or name.
|
|
2045
|
+
* @param pos The position to start searching from.
|
|
2046
|
+
* @param maxDepth The maximum depth to search.
|
|
2047
|
+
* @returns The node and the depth as an array.
|
|
2048
|
+
*/
|
|
2049
|
+
const getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
|
|
2050
|
+
const $pos = state.doc.resolve(pos);
|
|
2051
|
+
let currentDepth = maxDepth;
|
|
2052
|
+
let node = null;
|
|
2053
|
+
while (currentDepth > 0 && node === null) {
|
|
2054
|
+
const currentNode = $pos.node(currentDepth);
|
|
2055
|
+
if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type.name) === typeOrName) {
|
|
2056
|
+
node = currentNode;
|
|
2057
|
+
}
|
|
2058
|
+
else {
|
|
2059
|
+
currentDepth -= 1;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return [node, currentDepth];
|
|
2063
|
+
};
|
|
2064
|
+
|
|
2065
|
+
const getNextListDepth = (typeOrName, state) => {
|
|
2066
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
2067
|
+
if (!listItemPos) {
|
|
2068
|
+
return false;
|
|
2069
|
+
}
|
|
2070
|
+
const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
|
|
2071
|
+
return depth;
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
const isAtStartOfNode = (state) => {
|
|
2075
|
+
const { $from, $to } = state.selection;
|
|
2076
|
+
if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
|
|
2077
|
+
return false;
|
|
2078
|
+
}
|
|
2079
|
+
return true;
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2082
|
+
const hasListBefore = (editorState, name, parentListTypes) => {
|
|
2083
|
+
const { $anchor } = editorState.selection;
|
|
2084
|
+
const previousNodePos = Math.max(0, $anchor.pos - 2);
|
|
2085
|
+
const previousNode = editorState.doc.resolve(previousNodePos).node();
|
|
2086
|
+
if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
|
|
2087
|
+
return false;
|
|
2088
|
+
}
|
|
2089
|
+
return true;
|
|
2090
|
+
};
|
|
2091
|
+
|
|
2092
|
+
const hasListItemBefore = (typeOrName, state) => {
|
|
2093
|
+
var _a;
|
|
2094
|
+
const { $anchor } = state.selection;
|
|
2095
|
+
const $targetPos = state.doc.resolve($anchor.pos - 2);
|
|
2096
|
+
if ($targetPos.index() === 0) {
|
|
2097
|
+
return false;
|
|
2098
|
+
}
|
|
2099
|
+
if (((_a = $targetPos.nodeBefore) === null || _a === void 0 ? void 0 : _a.type.name) !== typeOrName) {
|
|
2100
|
+
return false;
|
|
2101
|
+
}
|
|
2102
|
+
return true;
|
|
2103
|
+
};
|
|
2104
|
+
|
|
2105
|
+
const listItemHasSubList = (typeOrName, state, node) => {
|
|
2106
|
+
if (!node) {
|
|
2107
|
+
return false;
|
|
2108
|
+
}
|
|
2109
|
+
const nodeType = getNodeType(typeOrName, state.schema);
|
|
2110
|
+
let hasSubList = false;
|
|
2111
|
+
node.descendants(child => {
|
|
2112
|
+
if (child.type === nodeType) {
|
|
2113
|
+
hasSubList = true;
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
return hasSubList;
|
|
2117
|
+
};
|
|
2118
|
+
|
|
2119
|
+
const handleBackspace = (editor, name, parentListTypes) => {
|
|
2120
|
+
// this is required to still handle the undo handling
|
|
2121
|
+
if (editor.commands.undoInputRule()) {
|
|
2122
|
+
return true;
|
|
2123
|
+
}
|
|
2124
|
+
// if the current item is NOT inside a list item &
|
|
2125
|
+
// the previous item is a list (orderedList or bulletList)
|
|
2126
|
+
// move the cursor into the list and delete the current item
|
|
2127
|
+
if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
|
|
2128
|
+
const { $anchor } = editor.state.selection;
|
|
2129
|
+
const $listPos = editor.state.doc.resolve($anchor.before() - 1);
|
|
2130
|
+
const listDescendants = [];
|
|
2131
|
+
$listPos.node().descendants((node, pos) => {
|
|
2132
|
+
if (node.type.name === name) {
|
|
2133
|
+
listDescendants.push({ node, pos });
|
|
2134
|
+
}
|
|
2135
|
+
});
|
|
2136
|
+
const lastItem = listDescendants.at(-1);
|
|
2137
|
+
if (!lastItem) {
|
|
2138
|
+
return false;
|
|
2139
|
+
}
|
|
2140
|
+
const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);
|
|
2141
|
+
return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run();
|
|
2142
|
+
}
|
|
2143
|
+
// if the cursor is not inside the current node type
|
|
2144
|
+
// do nothing and proceed
|
|
2145
|
+
if (!isNodeActive(editor.state, name)) {
|
|
2146
|
+
return false;
|
|
2147
|
+
}
|
|
2148
|
+
// if the cursor is not at the start of a node
|
|
2149
|
+
// do nothing and proceed
|
|
2150
|
+
if (!isAtStartOfNode(editor.state)) {
|
|
2151
|
+
return false;
|
|
2152
|
+
}
|
|
2153
|
+
const listItemPos = findListItemPos(name, editor.state);
|
|
2154
|
+
if (!listItemPos) {
|
|
2155
|
+
return false;
|
|
2156
|
+
}
|
|
2157
|
+
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
|
|
2158
|
+
const prevNode = $prev.node(listItemPos.depth);
|
|
2159
|
+
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);
|
|
2160
|
+
// if the previous item is a list item and doesn't have a sublist, join the list items
|
|
2161
|
+
if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {
|
|
2162
|
+
return editor.commands.joinItemBackward();
|
|
2163
|
+
}
|
|
2164
|
+
// otherwise in the end, a backspace should
|
|
2165
|
+
// always just lift the list item if
|
|
2166
|
+
// joining / merging is not possible
|
|
2167
|
+
return editor.chain().liftListItem(name).run();
|
|
2168
|
+
};
|
|
2169
|
+
|
|
2170
|
+
function findParentNodeClosestToPos($pos, predicate) {
|
|
2171
|
+
for (let i = $pos.depth; i > 0; i -= 1) {
|
|
2172
|
+
const node = $pos.node(i);
|
|
2173
|
+
if (predicate(node)) {
|
|
2174
|
+
return {
|
|
2175
|
+
pos: i > 0 ? $pos.before(i) : 0,
|
|
2176
|
+
start: $pos.start(i),
|
|
2177
|
+
depth: i,
|
|
2178
|
+
node,
|
|
2179
|
+
};
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
function findParentNode(predicate) {
|
|
2185
|
+
return (selection) => findParentNodeClosestToPos(selection.$from, predicate);
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
const isAtEndOfNode = (state, nodeType) => {
|
|
2189
|
+
const { $from, $to, $anchor } = state.selection;
|
|
2190
|
+
if (nodeType) {
|
|
2191
|
+
const parentNode = findParentNode(node => node.type.name === nodeType)(state.selection);
|
|
2192
|
+
if (!parentNode) {
|
|
2193
|
+
return false;
|
|
2194
|
+
}
|
|
2195
|
+
const $parentPos = state.doc.resolve(parentNode.pos + 1);
|
|
2196
|
+
if ($anchor.pos + 1 === $parentPos.end()) {
|
|
2197
|
+
return true;
|
|
2198
|
+
}
|
|
2199
|
+
return false;
|
|
2200
|
+
}
|
|
2201
|
+
if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
|
|
2202
|
+
return false;
|
|
2203
|
+
}
|
|
2204
|
+
return true;
|
|
2205
|
+
};
|
|
2206
|
+
|
|
2207
|
+
const nextListIsDeeper = (typeOrName, state) => {
|
|
2208
|
+
const listDepth = getNextListDepth(typeOrName, state);
|
|
2209
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
2210
|
+
if (!listItemPos || !listDepth) {
|
|
2211
|
+
return false;
|
|
2212
|
+
}
|
|
2213
|
+
if (listDepth > listItemPos.depth) {
|
|
2214
|
+
return true;
|
|
2215
|
+
}
|
|
2216
|
+
return false;
|
|
2217
|
+
};
|
|
2218
|
+
|
|
2219
|
+
const nextListIsHigher = (typeOrName, state) => {
|
|
2220
|
+
const listDepth = getNextListDepth(typeOrName, state);
|
|
2221
|
+
const listItemPos = findListItemPos(typeOrName, state);
|
|
2222
|
+
if (!listItemPos || !listDepth) {
|
|
2223
|
+
return false;
|
|
2224
|
+
}
|
|
2225
|
+
if (listDepth < listItemPos.depth) {
|
|
2226
|
+
return true;
|
|
2227
|
+
}
|
|
2228
|
+
return false;
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
const handleDelete = (editor, name) => {
|
|
2232
|
+
// if the cursor is not inside the current node type
|
|
2233
|
+
// do nothing and proceed
|
|
2234
|
+
if (!isNodeActive(editor.state, name)) {
|
|
2235
|
+
return false;
|
|
2236
|
+
}
|
|
2237
|
+
// if the cursor is not at the end of a node
|
|
2238
|
+
// do nothing and proceed
|
|
2239
|
+
if (!isAtEndOfNode(editor.state, name)) {
|
|
2240
|
+
return false;
|
|
2241
|
+
}
|
|
2242
|
+
// check if the next node is a list with a deeper depth
|
|
2243
|
+
if (nextListIsDeeper(name, editor.state)) {
|
|
2244
|
+
return editor
|
|
2245
|
+
.chain()
|
|
2246
|
+
.focus(editor.state.selection.from + 4)
|
|
2247
|
+
.lift(name)
|
|
2248
|
+
.joinBackward()
|
|
2249
|
+
.run();
|
|
2250
|
+
}
|
|
2251
|
+
if (nextListIsHigher(name, editor.state)) {
|
|
2252
|
+
return editor.chain()
|
|
2253
|
+
.joinForward()
|
|
2254
|
+
.joinBackward()
|
|
2255
|
+
.run();
|
|
2256
|
+
}
|
|
2257
|
+
return editor.commands.joinItemForward();
|
|
2258
|
+
};
|
|
2259
|
+
|
|
2260
|
+
const hasListItemAfter = (typeOrName, state) => {
|
|
2261
|
+
var _a;
|
|
2262
|
+
const { $anchor } = state.selection;
|
|
2263
|
+
const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
|
|
2264
|
+
if ($targetPos.index() === $targetPos.parent.childCount - 1) {
|
|
2265
|
+
return false;
|
|
2266
|
+
}
|
|
2267
|
+
if (((_a = $targetPos.nodeAfter) === null || _a === void 0 ? void 0 : _a.type.name) !== typeOrName) {
|
|
2268
|
+
return false;
|
|
2269
|
+
}
|
|
2270
|
+
return true;
|
|
2271
|
+
};
|
|
2272
|
+
|
|
1952
2273
|
/**
|
|
1953
2274
|
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
1954
2275
|
*/
|
|
@@ -2010,24 +2331,6 @@ function findChildrenInRange(node, range, predicate) {
|
|
|
2010
2331
|
return nodesWithPos;
|
|
2011
2332
|
}
|
|
2012
2333
|
|
|
2013
|
-
function findParentNodeClosestToPos($pos, predicate) {
|
|
2014
|
-
for (let i = $pos.depth; i > 0; i -= 1) {
|
|
2015
|
-
const node = $pos.node(i);
|
|
2016
|
-
if (predicate(node)) {
|
|
2017
|
-
return {
|
|
2018
|
-
pos: i > 0 ? $pos.before(i) : 0,
|
|
2019
|
-
start: $pos.start(i),
|
|
2020
|
-
depth: i,
|
|
2021
|
-
node,
|
|
2022
|
-
};
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
function findParentNode(predicate) {
|
|
2028
|
-
return (selection) => findParentNodeClosestToPos(selection.$from, predicate);
|
|
2029
|
-
}
|
|
2030
|
-
|
|
2031
2334
|
function getHTMLFromFragment(fragment, schema) {
|
|
2032
2335
|
const documentFragment = model.DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
2033
2336
|
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
@@ -2074,28 +2377,6 @@ function generateText(doc, extensions, options) {
|
|
|
2074
2377
|
});
|
|
2075
2378
|
}
|
|
2076
2379
|
|
|
2077
|
-
function getMarkAttributes(state, typeOrName) {
|
|
2078
|
-
const type = getMarkType(typeOrName, state.schema);
|
|
2079
|
-
const { from, to, empty } = state.selection;
|
|
2080
|
-
const marks = [];
|
|
2081
|
-
if (empty) {
|
|
2082
|
-
if (state.storedMarks) {
|
|
2083
|
-
marks.push(...state.storedMarks);
|
|
2084
|
-
}
|
|
2085
|
-
marks.push(...state.selection.$head.marks());
|
|
2086
|
-
}
|
|
2087
|
-
else {
|
|
2088
|
-
state.doc.nodesBetween(from, to, node => {
|
|
2089
|
-
marks.push(...node.marks);
|
|
2090
|
-
});
|
|
2091
|
-
}
|
|
2092
|
-
const mark = marks.find(markItem => markItem.type.name === type.name);
|
|
2093
|
-
if (!mark) {
|
|
2094
|
-
return {};
|
|
2095
|
-
}
|
|
2096
|
-
return { ...mark.attrs };
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
2380
|
function getNodeAttributes(state, typeOrName) {
|
|
2100
2381
|
const type = getNodeType(typeOrName, state.schema);
|
|
2101
2382
|
const { from, to } = state.selection;
|
|
@@ -2964,6 +3245,7 @@ var commands = /*#__PURE__*/Object.freeze({
|
|
|
2964
3245
|
clearNodes: clearNodes,
|
|
2965
3246
|
command: command,
|
|
2966
3247
|
createParagraphNear: createParagraphNear,
|
|
3248
|
+
cut: cut,
|
|
2967
3249
|
deleteCurrentNode: deleteCurrentNode,
|
|
2968
3250
|
deleteNode: deleteNode,
|
|
2969
3251
|
deleteRange: deleteRange,
|
|
@@ -2980,6 +3262,8 @@ var commands = /*#__PURE__*/Object.freeze({
|
|
|
2980
3262
|
joinDown: joinDown,
|
|
2981
3263
|
joinBackward: joinBackward,
|
|
2982
3264
|
joinForward: joinForward,
|
|
3265
|
+
joinItemBackward: joinItemBackward,
|
|
3266
|
+
joinItemForward: joinItemForward,
|
|
2983
3267
|
keyboardShortcut: keyboardShortcut,
|
|
2984
3268
|
lift: lift,
|
|
2985
3269
|
liftEmptyBlock: liftEmptyBlock,
|
|
@@ -3281,8 +3565,8 @@ img.ProseMirror-separator {
|
|
|
3281
3565
|
opacity: 0
|
|
3282
3566
|
}`;
|
|
3283
3567
|
|
|
3284
|
-
function createStyleTag(style, nonce) {
|
|
3285
|
-
const tiptapStyleTag = document.querySelector(
|
|
3568
|
+
function createStyleTag(style, nonce, suffix) {
|
|
3569
|
+
const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ''}]`);
|
|
3286
3570
|
if (tiptapStyleTag !== null) {
|
|
3287
3571
|
return tiptapStyleTag;
|
|
3288
3572
|
}
|
|
@@ -3290,7 +3574,7 @@ function createStyleTag(style, nonce) {
|
|
|
3290
3574
|
if (nonce) {
|
|
3291
3575
|
styleNode.setAttribute('nonce', nonce);
|
|
3292
3576
|
}
|
|
3293
|
-
styleNode.setAttribute(
|
|
3577
|
+
styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ''}`, '');
|
|
3294
3578
|
styleNode.innerHTML = style;
|
|
3295
3579
|
document.getElementsByTagName('head')[0].appendChild(styleNode);
|
|
3296
3580
|
return styleNode;
|
|
@@ -3667,7 +3951,6 @@ function markInputRule(config) {
|
|
|
3667
3951
|
const { tr } = state;
|
|
3668
3952
|
const captureGroup = match[match.length - 1];
|
|
3669
3953
|
const fullMatch = match[0];
|
|
3670
|
-
let markEnd = range.to;
|
|
3671
3954
|
if (captureGroup) {
|
|
3672
3955
|
const startSpaces = fullMatch.search(/\S/);
|
|
3673
3956
|
const textStart = range.from + fullMatch.indexOf(captureGroup);
|
|
@@ -3688,7 +3971,7 @@ function markInputRule(config) {
|
|
|
3688
3971
|
if (textStart > range.from) {
|
|
3689
3972
|
tr.delete(range.from + startSpaces, textStart);
|
|
3690
3973
|
}
|
|
3691
|
-
markEnd = range.from + startSpaces + captureGroup.length;
|
|
3974
|
+
const markEnd = range.from + startSpaces + captureGroup.length;
|
|
3692
3975
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
3693
3976
|
tr.removeStoredMark(config.type);
|
|
3694
3977
|
}
|
|
@@ -3703,11 +3986,14 @@ function markInputRule(config) {
|
|
|
3703
3986
|
function nodeInputRule(config) {
|
|
3704
3987
|
return new InputRule({
|
|
3705
3988
|
find: config.find,
|
|
3706
|
-
handler: ({ state, range, match }) => {
|
|
3989
|
+
handler: ({ state: state$1, range, match }) => {
|
|
3990
|
+
var _a;
|
|
3707
3991
|
const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
|
|
3708
|
-
const { tr } = state;
|
|
3709
|
-
const start = range.from;
|
|
3992
|
+
const { tr } = state$1;
|
|
3993
|
+
const start = config.blockReplace ? range.from - 1 : range.from;
|
|
3710
3994
|
let end = range.to;
|
|
3995
|
+
const newNode = config.type.create(attributes);
|
|
3996
|
+
const { $to } = tr.selection;
|
|
3711
3997
|
if (match[1]) {
|
|
3712
3998
|
const offset = match[0].lastIndexOf(match[1]);
|
|
3713
3999
|
let matchStart = start + offset;
|
|
@@ -3721,10 +4007,34 @@ function nodeInputRule(config) {
|
|
|
3721
4007
|
const lastChar = match[0][match[0].length - 1];
|
|
3722
4008
|
tr.insertText(lastChar, start + match[0].length - 1);
|
|
3723
4009
|
// insert node from input rule
|
|
3724
|
-
tr.replaceWith(matchStart, end,
|
|
4010
|
+
tr.replaceWith(matchStart, end, newNode);
|
|
3725
4011
|
}
|
|
3726
4012
|
else if (match[0]) {
|
|
3727
|
-
tr.replaceWith(start, end,
|
|
4013
|
+
tr.replaceWith(start, end, newNode);
|
|
4014
|
+
}
|
|
4015
|
+
if (config.blockReplace && config.addExtraNewline) {
|
|
4016
|
+
const posAfter = $to.end();
|
|
4017
|
+
if ($to.nodeAfter) {
|
|
4018
|
+
console.log($to.node().type.name);
|
|
4019
|
+
if ($to.nodeAfter.isTextblock) {
|
|
4020
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos + 1));
|
|
4021
|
+
}
|
|
4022
|
+
else if ($to.nodeAfter.isBlock) {
|
|
4023
|
+
tr.setSelection(state.NodeSelection.create(tr.doc, $to.pos));
|
|
4024
|
+
}
|
|
4025
|
+
else {
|
|
4026
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos));
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
else {
|
|
4030
|
+
// add node after horizontal rule if it’s the end of the document
|
|
4031
|
+
const node = (_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create();
|
|
4032
|
+
if (node) {
|
|
4033
|
+
tr.insert(posAfter, node);
|
|
4034
|
+
tr.setSelection(state.TextSelection.create(tr.doc, posAfter + 1));
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
tr.scrollIntoView();
|
|
3728
4038
|
}
|
|
3729
4039
|
},
|
|
3730
4040
|
});
|
|
@@ -3976,6 +4286,10 @@ class Node {
|
|
|
3976
4286
|
}
|
|
3977
4287
|
}
|
|
3978
4288
|
|
|
4289
|
+
function isAndroid() {
|
|
4290
|
+
return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
|
|
4291
|
+
}
|
|
4292
|
+
|
|
3979
4293
|
class NodeView {
|
|
3980
4294
|
constructor(component, props, options) {
|
|
3981
4295
|
this.isDragging = false;
|
|
@@ -4116,13 +4430,14 @@ class NodeView {
|
|
|
4116
4430
|
if (mutation.type === 'selection') {
|
|
4117
4431
|
return false;
|
|
4118
4432
|
}
|
|
4119
|
-
// try to prevent a bug on iOS that will break node views on enter
|
|
4433
|
+
// try to prevent a bug on iOS and Android that will break node views on enter
|
|
4120
4434
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
4121
4435
|
// this will lead to a re-render of the node view on enter
|
|
4122
4436
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
4437
|
+
// see: https://github.com/ueberdosis/tiptap/issues/2534
|
|
4123
4438
|
if (this.dom.contains(mutation.target)
|
|
4124
4439
|
&& mutation.type === 'childList'
|
|
4125
|
-
&& isiOS()
|
|
4440
|
+
&& (isiOS() || isAndroid())
|
|
4126
4441
|
&& this.editor.isFocused) {
|
|
4127
4442
|
const changedNodes = [
|
|
4128
4443
|
...Array.from(mutation.addedNodes),
|
|
@@ -4309,6 +4624,7 @@ exports.extensions = extensions;
|
|
|
4309
4624
|
exports.findChildren = findChildren;
|
|
4310
4625
|
exports.findChildrenInRange = findChildrenInRange;
|
|
4311
4626
|
exports.findDuplicates = findDuplicates;
|
|
4627
|
+
exports.findListItemPos = findListItemPos;
|
|
4312
4628
|
exports.findParentNode = findParentNode;
|
|
4313
4629
|
exports.findParentNodeClosestToPos = findParentNodeClosestToPos;
|
|
4314
4630
|
exports.fromString = fromString;
|
|
@@ -4325,6 +4641,8 @@ exports.getMarkAttributes = getMarkAttributes;
|
|
|
4325
4641
|
exports.getMarkRange = getMarkRange;
|
|
4326
4642
|
exports.getMarkType = getMarkType;
|
|
4327
4643
|
exports.getMarksBetween = getMarksBetween;
|
|
4644
|
+
exports.getNextListDepth = getNextListDepth;
|
|
4645
|
+
exports.getNodeAtPosition = getNodeAtPosition;
|
|
4328
4646
|
exports.getNodeAttributes = getNodeAttributes;
|
|
4329
4647
|
exports.getNodeType = getNodeType;
|
|
4330
4648
|
exports.getRenderedAttributes = getRenderedAttributes;
|
|
@@ -4337,9 +4655,16 @@ exports.getText = getText;
|
|
|
4337
4655
|
exports.getTextBetween = getTextBetween;
|
|
4338
4656
|
exports.getTextContentFromNodes = getTextContentFromNodes;
|
|
4339
4657
|
exports.getTextSerializersFromSchema = getTextSerializersFromSchema;
|
|
4658
|
+
exports.handleBackspace = handleBackspace;
|
|
4659
|
+
exports.handleDelete = handleDelete;
|
|
4660
|
+
exports.hasListBefore = hasListBefore;
|
|
4661
|
+
exports.hasListItemAfter = hasListItemAfter;
|
|
4662
|
+
exports.hasListItemBefore = hasListItemBefore;
|
|
4340
4663
|
exports.injectExtensionAttributesToParseRule = injectExtensionAttributesToParseRule;
|
|
4341
4664
|
exports.inputRulesPlugin = inputRulesPlugin;
|
|
4342
4665
|
exports.isActive = isActive;
|
|
4666
|
+
exports.isAtEndOfNode = isAtEndOfNode;
|
|
4667
|
+
exports.isAtStartOfNode = isAtStartOfNode;
|
|
4343
4668
|
exports.isEmptyObject = isEmptyObject;
|
|
4344
4669
|
exports.isExtensionRulesEnabled = isExtensionRulesEnabled;
|
|
4345
4670
|
exports.isFunction = isFunction;
|
|
@@ -4355,11 +4680,14 @@ exports.isRegExp = isRegExp;
|
|
|
4355
4680
|
exports.isString = isString;
|
|
4356
4681
|
exports.isTextSelection = isTextSelection;
|
|
4357
4682
|
exports.isiOS = isiOS;
|
|
4683
|
+
exports.listItemHasSubList = listItemHasSubList;
|
|
4358
4684
|
exports.markInputRule = markInputRule;
|
|
4359
4685
|
exports.markPasteRule = markPasteRule;
|
|
4360
4686
|
exports.mergeAttributes = mergeAttributes;
|
|
4361
4687
|
exports.mergeDeep = mergeDeep;
|
|
4362
4688
|
exports.minMax = minMax;
|
|
4689
|
+
exports.nextListIsDeeper = nextListIsDeeper;
|
|
4690
|
+
exports.nextListIsHigher = nextListIsHigher;
|
|
4363
4691
|
exports.nodeInputRule = nodeInputRule;
|
|
4364
4692
|
exports.nodePasteRule = nodePasteRule;
|
|
4365
4693
|
exports.objectIncludes = objectIncludes;
|