@tiptap/core 2.5.5 → 2.5.6

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.js CHANGED
@@ -2814,7 +2814,7 @@ function isList(name, extensions) {
2814
2814
  }
2815
2815
 
2816
2816
  function isNodeEmpty(node) {
2817
- const defaultContent = node.type.createAndFill();
2817
+ const defaultContent = node.type.createAndFill(node.attrs);
2818
2818
  if (!defaultContent) {
2819
2819
  return false;
2820
2820
  }
@@ -3016,15 +3016,24 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
3016
3016
  if (!$from.parent.isBlock) {
3017
3017
  return false;
3018
3018
  }
3019
- if (dispatch) {
3020
- const atEnd = $to.parentOffset === $to.parent.content.size;
3021
- if (selection instanceof TextSelection) {
3022
- tr.deleteSelection();
3023
- }
3024
- const deflt = $from.depth === 0
3025
- ? undefined
3026
- : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
3027
- let types = atEnd && deflt
3019
+ const atEnd = $to.parentOffset === $to.parent.content.size;
3020
+ const deflt = $from.depth === 0
3021
+ ? undefined
3022
+ : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
3023
+ let types = atEnd && deflt
3024
+ ? [
3025
+ {
3026
+ type: deflt,
3027
+ attrs: newAttributes,
3028
+ },
3029
+ ]
3030
+ : undefined;
3031
+ let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);
3032
+ if (!types
3033
+ && !can
3034
+ && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)) {
3035
+ can = true;
3036
+ types = deflt
3028
3037
  ? [
3029
3038
  {
3030
3039
  type: deflt,
@@ -3032,21 +3041,12 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
3032
3041
  },
3033
3042
  ]
3034
3043
  : undefined;
3035
- let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);
3036
- if (!types
3037
- && !can
3038
- && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)) {
3039
- can = true;
3040
- types = deflt
3041
- ? [
3042
- {
3043
- type: deflt,
3044
- attrs: newAttributes,
3045
- },
3046
- ]
3047
- : undefined;
3048
- }
3044
+ }
3045
+ if (dispatch) {
3049
3046
  if (can) {
3047
+ if (selection instanceof TextSelection) {
3048
+ tr.deleteSelection();
3049
+ }
3050
3050
  tr.split(tr.mapping.map($from.pos), 1, types);
3051
3051
  if (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) {
3052
3052
  const first = tr.mapping.map($from.before());
@@ -3061,7 +3061,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
3061
3061
  }
3062
3062
  tr.scrollIntoView();
3063
3063
  }
3064
- return true;
3064
+ return can;
3065
3065
  };
3066
3066
 
3067
3067
  const splitListItem = typeOrName => ({ tr, state, dispatch, editor, }) => {
@@ -4167,6 +4167,9 @@ class Editor extends EventEmitter {
4167
4167
  * Creates all node views.
4168
4168
  */
4169
4169
  createNodeViews() {
4170
+ if (this.view.isDestroyed) {
4171
+ return;
4172
+ }
4170
4173
  this.view.setProps({
4171
4174
  nodeViews: this.extensionManager.nodeViews,
4172
4175
  });