@tiptap/core 2.22.1 → 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.umd.js CHANGED
@@ -4210,6 +4210,10 @@
4210
4210
  const isBlock = node.isBlock && !node.isTextblock;
4211
4211
  const isNonTextAtom = node.isAtom && !node.isText;
4212
4212
  const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);
4213
+ // Check if targetPos is within valid document range
4214
+ if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
4215
+ return;
4216
+ }
4213
4217
  const $pos = this.resolvedPos.doc.resolve(targetPos);
4214
4218
  if (!isBlock && $pos.depth <= this.depth) {
4215
4219
  return;
@@ -5362,6 +5366,30 @@ img.ProseMirror-separator {
5362
5366
  });
5363
5367
  }
5364
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
+
5365
5393
  // source: https://stackoverflow.com/a/6969486
5366
5394
  function escapeForRegEx(string) {
5367
5395
  return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
@@ -5457,6 +5485,7 @@ img.ProseMirror-separator {
5457
5485
  exports.PasteRule = PasteRule;
5458
5486
  exports.Tracker = Tracker;
5459
5487
  exports.callOrReturn = callOrReturn;
5488
+ exports.canInsertNode = canInsertNode;
5460
5489
  exports.combineTransactionSteps = combineTransactionSteps;
5461
5490
  exports.createChainableState = createChainableState;
5462
5491
  exports.createDocument = createDocument;