@tiptap/core 3.0.0-beta.14 → 3.0.0-beta.15

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 CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  PasteRule: () => PasteRule,
34
34
  Tracker: () => Tracker,
35
35
  callOrReturn: () => callOrReturn,
36
+ canInsertNode: () => canInsertNode,
36
37
  combineTransactionSteps: () => combineTransactionSteps,
37
38
  createChainableState: () => createChainableState,
38
39
  createDocument: () => createDocument,
@@ -5060,6 +5061,29 @@ var h = (tag, attributes) => {
5060
5061
  return [tag, rest, children];
5061
5062
  };
5062
5063
 
5064
+ // src/utilities/canInsertNode.ts
5065
+ var import_state22 = require("@tiptap/pm/state");
5066
+ function canInsertNode(state, nodeType) {
5067
+ const { selection } = state;
5068
+ const { $from } = selection;
5069
+ if (selection instanceof import_state22.NodeSelection) {
5070
+ const index = $from.index();
5071
+ const parent = $from.parent;
5072
+ return parent.canReplaceWith(index, index + 1, nodeType);
5073
+ }
5074
+ let depth = $from.depth;
5075
+ while (depth >= 0) {
5076
+ const index = $from.index(depth);
5077
+ const parent = $from.node(depth);
5078
+ const match = parent.contentMatchAt(index);
5079
+ if (match.matchType(nodeType)) {
5080
+ return true;
5081
+ }
5082
+ depth -= 1;
5083
+ }
5084
+ return false;
5085
+ }
5086
+
5063
5087
  // src/utilities/escapeForRegEx.ts
5064
5088
  function escapeForRegEx(string) {
5065
5089
  return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
@@ -5129,7 +5153,7 @@ var Node3 = class _Node extends Extendable {
5129
5153
  };
5130
5154
 
5131
5155
  // src/NodeView.ts
5132
- var import_state22 = require("@tiptap/pm/state");
5156
+ var import_state23 = require("@tiptap/pm/state");
5133
5157
  var NodeView = class {
5134
5158
  constructor(component, props, options) {
5135
5159
  this.isDragging = false;
@@ -5182,7 +5206,7 @@ var NodeView = class {
5182
5206
  if (typeof pos !== "number") {
5183
5207
  return;
5184
5208
  }
5185
- const selection = import_state22.NodeSelection.create(view.state.doc, pos);
5209
+ const selection = import_state23.NodeSelection.create(view.state.doc, pos);
5186
5210
  const transaction = view.state.tr.setSelection(selection);
5187
5211
  view.dispatch(transaction);
5188
5212
  }
@@ -5208,7 +5232,7 @@ var NodeView = class {
5208
5232
  const { isEditable } = this.editor;
5209
5233
  const { isDragging } = this;
5210
5234
  const isDraggable = !!this.node.type.spec.draggable;
5211
- const isSelectable = import_state22.NodeSelection.isSelectable(this.node);
5235
+ const isSelectable = import_state23.NodeSelection.isSelectable(this.node);
5212
5236
  const isCopyEvent = event.type === "copy";
5213
5237
  const isPasteEvent = event.type === "paste";
5214
5238
  const isCutEvent = event.type === "cut";
@@ -5432,6 +5456,7 @@ var Tracker = class {
5432
5456
  PasteRule,
5433
5457
  Tracker,
5434
5458
  callOrReturn,
5459
+ canInsertNode,
5435
5460
  combineTransactionSteps,
5436
5461
  createChainableState,
5437
5462
  createDocument,