@tiptap/core 2.0.0-beta.134 → 2.0.0-beta.138

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.
@@ -643,6 +643,9 @@ function selectionToInsertionEnd(tr, startLen, bias) {
643
643
  tr.setSelection(Selection.near(tr.doc.resolve(end), bias));
644
644
  }
645
645
 
646
+ const isFragment = (nodeOrFragment) => {
647
+ return nodeOrFragment.toString().startsWith('<');
648
+ };
646
649
  const insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) => {
647
650
  if (dispatch) {
648
651
  options = {
@@ -664,7 +667,10 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
664
667
  ? { from: position, to: position }
665
668
  : position;
666
669
  let isOnlyBlockContent = true;
667
- content.forEach(node => {
670
+ const nodes = isFragment(content)
671
+ ? content
672
+ : [content];
673
+ nodes.forEach(node => {
668
674
  isOnlyBlockContent = isOnlyBlockContent
669
675
  ? node.isBlock
670
676
  : false;
@@ -675,10 +681,10 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
675
681
  // replace an empty paragraph by an inserted image
676
682
  // instead of inserting the image below the paragraph
677
683
  if (from === to && isOnlyBlockContent) {
678
- const $from = tr.doc.resolve(from);
679
- const isEmptyTextBlock = $from.parent.isTextblock
680
- && !$from.parent.type.spec.code
681
- && !$from.parent.textContent;
684
+ const { parent } = tr.doc.resolve(from);
685
+ const isEmptyTextBlock = parent.isTextblock
686
+ && !parent.type.spec.code
687
+ && !parent.childCount;
682
688
  if (isEmptyTextBlock) {
683
689
  from -= 1;
684
690
  to += 1;
@@ -1907,12 +1913,6 @@ function isActive(state, name, attributes = {}) {
1907
1913
  return false;
1908
1914
  }
1909
1915
 
1910
- function removeElement(element) {
1911
- if (element === null || element === void 0 ? void 0 : element.parentNode) {
1912
- element.parentNode.removeChild(element);
1913
- }
1914
- }
1915
-
1916
1916
  function getHTMLFromFragment(fragment, schema) {
1917
1917
  const documentFragment = DOMSerializer
1918
1918
  .fromSchema(schema)
@@ -3333,7 +3333,6 @@ class Editor extends EventEmitter {
3333
3333
  this.view.destroy();
3334
3334
  }
3335
3335
  this.removeAllListeners();
3336
- removeElement(this.css);
3337
3336
  }
3338
3337
  /**
3339
3338
  * Check if the editor is already destroyed.