@tiptap/core 2.22.2 → 2.22.3
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 +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +25 -0
- 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/utilities/canInsertNode.ts +31 -0
- package/src/utilities/index.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -5370,6 +5370,30 @@ function markPasteRule(config) {
|
|
|
5370
5370
|
});
|
|
5371
5371
|
}
|
|
5372
5372
|
|
|
5373
|
+
function canInsertNode(state$1, nodeType) {
|
|
5374
|
+
const { selection } = state$1;
|
|
5375
|
+
const { $from } = selection;
|
|
5376
|
+
// Special handling for NodeSelection
|
|
5377
|
+
if (selection instanceof state.NodeSelection) {
|
|
5378
|
+
const index = $from.index();
|
|
5379
|
+
const parent = $from.parent;
|
|
5380
|
+
// Can we replace the selected node with the horizontal rule?
|
|
5381
|
+
return parent.canReplaceWith(index, index + 1, nodeType);
|
|
5382
|
+
}
|
|
5383
|
+
// Default: check if we can insert at the current position
|
|
5384
|
+
let depth = $from.depth;
|
|
5385
|
+
while (depth >= 0) {
|
|
5386
|
+
const index = $from.index(depth);
|
|
5387
|
+
const parent = $from.node(depth);
|
|
5388
|
+
const match = parent.contentMatchAt(index);
|
|
5389
|
+
if (match.matchType(nodeType)) {
|
|
5390
|
+
return true;
|
|
5391
|
+
}
|
|
5392
|
+
depth -= 1;
|
|
5393
|
+
}
|
|
5394
|
+
return false;
|
|
5395
|
+
}
|
|
5396
|
+
|
|
5373
5397
|
// source: https://stackoverflow.com/a/6969486
|
|
5374
5398
|
function escapeForRegEx(string) {
|
|
5375
5399
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
@@ -5465,6 +5489,7 @@ exports.NodeView = NodeView;
|
|
|
5465
5489
|
exports.PasteRule = PasteRule;
|
|
5466
5490
|
exports.Tracker = Tracker;
|
|
5467
5491
|
exports.callOrReturn = callOrReturn;
|
|
5492
|
+
exports.canInsertNode = canInsertNode;
|
|
5468
5493
|
exports.combineTransactionSteps = combineTransactionSteps;
|
|
5469
5494
|
exports.createChainableState = createChainableState;
|
|
5470
5495
|
exports.createDocument = createDocument;
|