@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.umd.js CHANGED
@@ -1084,7 +1084,7 @@
1084
1084
  dropEvent = event;
1085
1085
  if (!isDroppedFromProseMirror) {
1086
1086
  const dragFromOtherEditor = tiptapDragFromOtherEditor;
1087
- if (dragFromOtherEditor) {
1087
+ if (dragFromOtherEditor === null || dragFromOtherEditor === void 0 ? void 0 : dragFromOtherEditor.isEditable) {
1088
1088
  // setTimeout to avoid the wrong content after drop, timeout arg can't be empty or 0
1089
1089
  setTimeout(() => {
1090
1090
  const selection = dragFromOtherEditor.state.selection;
@@ -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;