@tiptap/core 2.0.0-beta.165 → 2.0.0-beta.166

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.
@@ -674,6 +674,7 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
674
674
  let { from, to } = typeof position === 'number'
675
675
  ? { from: position, to: position }
676
676
  : position;
677
+ let isOnlyTextContent = true;
677
678
  let isOnlyBlockContent = true;
678
679
  const nodes = isFragment(content)
679
680
  ? content
@@ -681,6 +682,9 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
681
682
  nodes.forEach(node => {
682
683
  // check if added node is valid
683
684
  node.check();
685
+ isOnlyTextContent = isOnlyTextContent
686
+ ? node.isText && node.marks.length === 0
687
+ : false;
684
688
  isOnlyBlockContent = isOnlyBlockContent
685
689
  ? node.isBlock
686
690
  : false;
@@ -700,7 +704,14 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
700
704
  to += 1;
701
705
  }
702
706
  }
703
- tr.replaceWith(from, to, content);
707
+ // if there is only plain text we have to use `insertText`
708
+ // because this will keep the current marks
709
+ if (isOnlyTextContent) {
710
+ tr.insertText(value, from, to);
711
+ }
712
+ else {
713
+ tr.replaceWith(from, to, content);
714
+ }
704
715
  // set cursor at end of inserted content
705
716
  if (options.updateSelection) {
706
717
  selectionToInsertionEnd(tr, tr.steps.length - 1, -1);