@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.umd.js
CHANGED
|
@@ -5366,6 +5366,30 @@ img.ProseMirror-separator {
|
|
|
5366
5366
|
});
|
|
5367
5367
|
}
|
|
5368
5368
|
|
|
5369
|
+
function canInsertNode(state$1, nodeType) {
|
|
5370
|
+
const { selection } = state$1;
|
|
5371
|
+
const { $from } = selection;
|
|
5372
|
+
// Special handling for NodeSelection
|
|
5373
|
+
if (selection instanceof state.NodeSelection) {
|
|
5374
|
+
const index = $from.index();
|
|
5375
|
+
const parent = $from.parent;
|
|
5376
|
+
// Can we replace the selected node with the horizontal rule?
|
|
5377
|
+
return parent.canReplaceWith(index, index + 1, nodeType);
|
|
5378
|
+
}
|
|
5379
|
+
// Default: check if we can insert at the current position
|
|
5380
|
+
let depth = $from.depth;
|
|
5381
|
+
while (depth >= 0) {
|
|
5382
|
+
const index = $from.index(depth);
|
|
5383
|
+
const parent = $from.node(depth);
|
|
5384
|
+
const match = parent.contentMatchAt(index);
|
|
5385
|
+
if (match.matchType(nodeType)) {
|
|
5386
|
+
return true;
|
|
5387
|
+
}
|
|
5388
|
+
depth -= 1;
|
|
5389
|
+
}
|
|
5390
|
+
return false;
|
|
5391
|
+
}
|
|
5392
|
+
|
|
5369
5393
|
// source: https://stackoverflow.com/a/6969486
|
|
5370
5394
|
function escapeForRegEx(string) {
|
|
5371
5395
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
@@ -5461,6 +5485,7 @@ img.ProseMirror-separator {
|
|
|
5461
5485
|
exports.PasteRule = PasteRule;
|
|
5462
5486
|
exports.Tracker = Tracker;
|
|
5463
5487
|
exports.callOrReturn = callOrReturn;
|
|
5488
|
+
exports.canInsertNode = canInsertNode;
|
|
5464
5489
|
exports.combineTransactionSteps = combineTransactionSteps;
|
|
5465
5490
|
exports.createChainableState = createChainableState;
|
|
5466
5491
|
exports.createDocument = createDocument;
|