@tiptap/core 2.1.0-rc.1 → 2.1.0-rc.11
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 +96 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +94 -32
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +96 -31
- 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 +8 -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 +51 -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/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 +50 -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 +2 -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/index.d.ts +20 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
- package/package.json +2 -2
- package/src/CommandManager.ts +4 -8
- package/src/Editor.ts +24 -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 +27 -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 +51 -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/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 +5 -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 +50 -47
- package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
- package/src/helpers/isActive.ts +3 -3
- package/src/helpers/isAtEndOfNode.ts +11 -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 +3 -3
- 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/index.ts +20 -20
- package/src/utilities/isAndroid.ts +3 -0
- 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]) => {
|
|
@@ -1306,6 +1303,19 @@
|
|
|
1306
1303
|
return commands$1.createParagraphNear(state, dispatch);
|
|
1307
1304
|
};
|
|
1308
1305
|
|
|
1306
|
+
const cut = (originRange, targetPos) => ({ editor }) => {
|
|
1307
|
+
const { state } = editor;
|
|
1308
|
+
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
1309
|
+
return editor
|
|
1310
|
+
.chain()
|
|
1311
|
+
.deleteRange(originRange)
|
|
1312
|
+
.command(({ commands, tr }) => {
|
|
1313
|
+
return commands.insertContentAt(tr.mapping.map(targetPos), contentSlice.content.toJSON());
|
|
1314
|
+
})
|
|
1315
|
+
.focus()
|
|
1316
|
+
.run();
|
|
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];
|
|
@@ -1943,6 +1953,28 @@
|
|
|
1943
1953
|
return true;
|
|
1944
1954
|
};
|
|
1945
1955
|
|
|
1956
|
+
function getMarkAttributes(state, typeOrName) {
|
|
1957
|
+
const type = getMarkType(typeOrName, state.schema);
|
|
1958
|
+
const { from, to, empty } = state.selection;
|
|
1959
|
+
const marks = [];
|
|
1960
|
+
if (empty) {
|
|
1961
|
+
if (state.storedMarks) {
|
|
1962
|
+
marks.push(...state.storedMarks);
|
|
1963
|
+
}
|
|
1964
|
+
marks.push(...state.selection.$head.marks());
|
|
1965
|
+
}
|
|
1966
|
+
else {
|
|
1967
|
+
state.doc.nodesBetween(from, to, node => {
|
|
1968
|
+
marks.push(...node.marks);
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
const mark = marks.find(markItem => markItem.type.name === type.name);
|
|
1972
|
+
if (!mark) {
|
|
1973
|
+
return {};
|
|
1974
|
+
}
|
|
1975
|
+
return { ...mark.attrs };
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1946
1978
|
/**
|
|
1947
1979
|
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
1948
1980
|
*/
|
|
@@ -2068,28 +2100,6 @@
|
|
|
2068
2100
|
});
|
|
2069
2101
|
}
|
|
2070
2102
|
|
|
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
2103
|
function getNodeAttributes(state, typeOrName) {
|
|
2094
2104
|
const type = getNodeType(typeOrName, state.schema);
|
|
2095
2105
|
const { from, to } = state.selection;
|
|
@@ -2261,6 +2271,30 @@
|
|
|
2261
2271
|
return marks;
|
|
2262
2272
|
}
|
|
2263
2273
|
|
|
2274
|
+
/**
|
|
2275
|
+
* Finds the first node of a given type or name in the current selection.
|
|
2276
|
+
* @param state The editor state.
|
|
2277
|
+
* @param typeOrName The node type or name.
|
|
2278
|
+
* @param pos The position to start searching from.
|
|
2279
|
+
* @param maxDepth The maximum depth to search.
|
|
2280
|
+
* @returns The node and the depth as an array.
|
|
2281
|
+
*/
|
|
2282
|
+
const getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
|
|
2283
|
+
const $pos = state.doc.resolve(pos);
|
|
2284
|
+
let currentDepth = maxDepth;
|
|
2285
|
+
let node = null;
|
|
2286
|
+
while (currentDepth > 0 && node === null) {
|
|
2287
|
+
const currentNode = $pos.node(currentDepth);
|
|
2288
|
+
if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type.name) === typeOrName) {
|
|
2289
|
+
node = currentNode;
|
|
2290
|
+
}
|
|
2291
|
+
else {
|
|
2292
|
+
currentDepth -= 1;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
return [node, currentDepth];
|
|
2296
|
+
};
|
|
2297
|
+
|
|
2264
2298
|
function getSplittedAttributes(extensionAttributes, typeName, attributes) {
|
|
2265
2299
|
return Object.fromEntries(Object
|
|
2266
2300
|
.entries(attributes)
|
|
@@ -2351,6 +2385,22 @@
|
|
|
2351
2385
|
return false;
|
|
2352
2386
|
}
|
|
2353
2387
|
|
|
2388
|
+
const istAtEndOfNode = (state) => {
|
|
2389
|
+
const { $from, $to } = state.selection;
|
|
2390
|
+
if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
|
|
2391
|
+
return false;
|
|
2392
|
+
}
|
|
2393
|
+
return true;
|
|
2394
|
+
};
|
|
2395
|
+
|
|
2396
|
+
const isAtStartOfNode = (state) => {
|
|
2397
|
+
const { $from, $to } = state.selection;
|
|
2398
|
+
if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
|
|
2399
|
+
return false;
|
|
2400
|
+
}
|
|
2401
|
+
return true;
|
|
2402
|
+
};
|
|
2403
|
+
|
|
2354
2404
|
function isList(name, extensions) {
|
|
2355
2405
|
const { nodeExtensions } = splitExtensions(extensions);
|
|
2356
2406
|
const extension = nodeExtensions.find(item => item.name === name);
|
|
@@ -2958,6 +3008,7 @@
|
|
|
2958
3008
|
clearNodes: clearNodes,
|
|
2959
3009
|
command: command,
|
|
2960
3010
|
createParagraphNear: createParagraphNear,
|
|
3011
|
+
cut: cut,
|
|
2961
3012
|
deleteCurrentNode: deleteCurrentNode,
|
|
2962
3013
|
deleteNode: deleteNode,
|
|
2963
3014
|
deleteRange: deleteRange,
|
|
@@ -3491,6 +3542,7 @@ img.ProseMirror-separator {
|
|
|
3491
3542
|
});
|
|
3492
3543
|
this.view.updateState(newState);
|
|
3493
3544
|
this.createNodeViews();
|
|
3545
|
+
this.prependClass();
|
|
3494
3546
|
// Let’s store the editor instance in the DOM element.
|
|
3495
3547
|
// So we’ll have access to it for tests.
|
|
3496
3548
|
const dom = this.view.dom;
|
|
@@ -3504,6 +3556,12 @@ img.ProseMirror-separator {
|
|
|
3504
3556
|
nodeViews: this.extensionManager.nodeViews,
|
|
3505
3557
|
});
|
|
3506
3558
|
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Prepend class name to element.
|
|
3561
|
+
*/
|
|
3562
|
+
prependClass() {
|
|
3563
|
+
this.view.dom.className = `tiptap ${this.view.dom.className}`;
|
|
3564
|
+
}
|
|
3507
3565
|
captureTransaction(fn) {
|
|
3508
3566
|
this.isCapturingTransaction = true;
|
|
3509
3567
|
fn();
|
|
@@ -3654,7 +3712,6 @@ img.ProseMirror-separator {
|
|
|
3654
3712
|
const { tr } = state;
|
|
3655
3713
|
const captureGroup = match[match.length - 1];
|
|
3656
3714
|
const fullMatch = match[0];
|
|
3657
|
-
let markEnd = range.to;
|
|
3658
3715
|
if (captureGroup) {
|
|
3659
3716
|
const startSpaces = fullMatch.search(/\S/);
|
|
3660
3717
|
const textStart = range.from + fullMatch.indexOf(captureGroup);
|
|
@@ -3675,7 +3732,7 @@ img.ProseMirror-separator {
|
|
|
3675
3732
|
if (textStart > range.from) {
|
|
3676
3733
|
tr.delete(range.from + startSpaces, textStart);
|
|
3677
3734
|
}
|
|
3678
|
-
markEnd = range.from + startSpaces + captureGroup.length;
|
|
3735
|
+
const markEnd = range.from + startSpaces + captureGroup.length;
|
|
3679
3736
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
3680
3737
|
tr.removeStoredMark(config.type);
|
|
3681
3738
|
}
|
|
@@ -3963,6 +4020,10 @@ img.ProseMirror-separator {
|
|
|
3963
4020
|
}
|
|
3964
4021
|
}
|
|
3965
4022
|
|
|
4023
|
+
function isAndroid() {
|
|
4024
|
+
return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
|
|
4025
|
+
}
|
|
4026
|
+
|
|
3966
4027
|
class NodeView {
|
|
3967
4028
|
constructor(component, props, options) {
|
|
3968
4029
|
this.isDragging = false;
|
|
@@ -4103,13 +4164,14 @@ img.ProseMirror-separator {
|
|
|
4103
4164
|
if (mutation.type === 'selection') {
|
|
4104
4165
|
return false;
|
|
4105
4166
|
}
|
|
4106
|
-
// try to prevent a bug on iOS that will break node views on enter
|
|
4167
|
+
// try to prevent a bug on iOS and Android that will break node views on enter
|
|
4107
4168
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
4108
4169
|
// this will lead to a re-render of the node view on enter
|
|
4109
4170
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
4171
|
+
// see: https://github.com/ueberdosis/tiptap/issues/2534
|
|
4110
4172
|
if (this.dom.contains(mutation.target)
|
|
4111
4173
|
&& mutation.type === 'childList'
|
|
4112
|
-
&& isiOS()
|
|
4174
|
+
&& (isiOS() || isAndroid())
|
|
4113
4175
|
&& this.editor.isFocused) {
|
|
4114
4176
|
const changedNodes = [
|
|
4115
4177
|
...Array.from(mutation.addedNodes),
|
|
@@ -4312,6 +4374,7 @@ img.ProseMirror-separator {
|
|
|
4312
4374
|
exports.getMarkRange = getMarkRange;
|
|
4313
4375
|
exports.getMarkType = getMarkType;
|
|
4314
4376
|
exports.getMarksBetween = getMarksBetween;
|
|
4377
|
+
exports.getNodeAtPosition = getNodeAtPosition;
|
|
4315
4378
|
exports.getNodeAttributes = getNodeAttributes;
|
|
4316
4379
|
exports.getNodeType = getNodeType;
|
|
4317
4380
|
exports.getRenderedAttributes = getRenderedAttributes;
|
|
@@ -4327,6 +4390,7 @@ img.ProseMirror-separator {
|
|
|
4327
4390
|
exports.injectExtensionAttributesToParseRule = injectExtensionAttributesToParseRule;
|
|
4328
4391
|
exports.inputRulesPlugin = inputRulesPlugin;
|
|
4329
4392
|
exports.isActive = isActive;
|
|
4393
|
+
exports.isAtStartOfNode = isAtStartOfNode;
|
|
4330
4394
|
exports.isEmptyObject = isEmptyObject;
|
|
4331
4395
|
exports.isExtensionRulesEnabled = isExtensionRulesEnabled;
|
|
4332
4396
|
exports.isFunction = isFunction;
|
|
@@ -4342,6 +4406,7 @@ img.ProseMirror-separator {
|
|
|
4342
4406
|
exports.isString = isString;
|
|
4343
4407
|
exports.isTextSelection = isTextSelection;
|
|
4344
4408
|
exports.isiOS = isiOS;
|
|
4409
|
+
exports.istAtEndOfNode = istAtEndOfNode;
|
|
4345
4410
|
exports.markInputRule = markInputRule;
|
|
4346
4411
|
exports.markPasteRule = markPasteRule;
|
|
4347
4412
|
exports.mergeAttributes = mergeAttributes;
|