@tiptap/core 2.22.2 → 2.23.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 +26 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +26 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/utilities/canInsertNode.d.ts +4 -0
- package/dist/utilities/canInsertNode.d.ts.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/PasteRule.ts +1 -1
- package/src/utilities/canInsertNode.ts +31 -0
- package/src/utilities/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1086,7 +1086,7 @@ function pasteRulesPlugin(props) {
|
|
|
1086
1086
|
dropEvent = event;
|
|
1087
1087
|
if (!isDroppedFromProseMirror) {
|
|
1088
1088
|
const dragFromOtherEditor = tiptapDragFromOtherEditor;
|
|
1089
|
-
if (dragFromOtherEditor) {
|
|
1089
|
+
if (dragFromOtherEditor === null || dragFromOtherEditor === void 0 ? void 0 : dragFromOtherEditor.isEditable) {
|
|
1090
1090
|
// setTimeout to avoid the wrong content after drop, timeout arg can't be empty or 0
|
|
1091
1091
|
setTimeout(() => {
|
|
1092
1092
|
const selection = dragFromOtherEditor.state.selection;
|
|
@@ -5368,6 +5368,30 @@ function markPasteRule(config) {
|
|
|
5368
5368
|
});
|
|
5369
5369
|
}
|
|
5370
5370
|
|
|
5371
|
+
function canInsertNode(state, nodeType) {
|
|
5372
|
+
const { selection } = state;
|
|
5373
|
+
const { $from } = selection;
|
|
5374
|
+
// Special handling for NodeSelection
|
|
5375
|
+
if (selection instanceof NodeSelection) {
|
|
5376
|
+
const index = $from.index();
|
|
5377
|
+
const parent = $from.parent;
|
|
5378
|
+
// Can we replace the selected node with the horizontal rule?
|
|
5379
|
+
return parent.canReplaceWith(index, index + 1, nodeType);
|
|
5380
|
+
}
|
|
5381
|
+
// Default: check if we can insert at the current position
|
|
5382
|
+
let depth = $from.depth;
|
|
5383
|
+
while (depth >= 0) {
|
|
5384
|
+
const index = $from.index(depth);
|
|
5385
|
+
const parent = $from.node(depth);
|
|
5386
|
+
const match = parent.contentMatchAt(index);
|
|
5387
|
+
if (match.matchType(nodeType)) {
|
|
5388
|
+
return true;
|
|
5389
|
+
}
|
|
5390
|
+
depth -= 1;
|
|
5391
|
+
}
|
|
5392
|
+
return false;
|
|
5393
|
+
}
|
|
5394
|
+
|
|
5371
5395
|
// source: https://stackoverflow.com/a/6969486
|
|
5372
5396
|
function escapeForRegEx(string) {
|
|
5373
5397
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
@@ -5452,5 +5476,5 @@ class Tracker {
|
|
|
5452
5476
|
}
|
|
5453
5477
|
}
|
|
5454
5478
|
|
|
5455
|
-
export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodePos, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
5479
|
+
export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodePos, NodeView, PasteRule, Tracker, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
5456
5480
|
//# sourceMappingURL=index.js.map
|