@tiptap/core 2.1.0 → 2.1.2

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
@@ -306,8 +306,8 @@ function mergeAttributes(...objects) {
306
306
  return;
307
307
  }
308
308
  if (key === 'class') {
309
- const valueClasses = value.split(' ');
310
- const existingClasses = mergedAttributes[key].split(' ');
309
+ const valueClasses = value ? value.split(' ') : [];
310
+ const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(' ') : [];
311
311
  const insertClasses = valueClasses.filter(valueClass => !existingClasses.includes(valueClass));
312
312
  mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ');
313
313
  }
@@ -3987,7 +3987,7 @@ function nodeInputRule(config) {
3987
3987
  return new InputRule({
3988
3988
  find: config.find,
3989
3989
  handler: ({ state: state$1, range, match }) => {
3990
- var _a;
3990
+ var _a, _b;
3991
3991
  const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
3992
3992
  const { tr } = state$1;
3993
3993
  const start = config.blockReplace ? range.from - 1 : range.from;
@@ -4013,9 +4013,7 @@ function nodeInputRule(config) {
4013
4013
  tr.replaceWith(start, end, newNode);
4014
4014
  }
4015
4015
  if (config.blockReplace && config.addExtraNewline) {
4016
- const posAfter = $to.end();
4017
4016
  if ($to.nodeAfter) {
4018
- console.log($to.node().type.name);
4019
4017
  if ($to.nodeAfter.isTextblock) {
4020
4018
  tr.setSelection(state.TextSelection.create(tr.doc, $to.pos + 1));
4021
4019
  }
@@ -4023,15 +4021,16 @@ function nodeInputRule(config) {
4023
4021
  tr.setSelection(state.NodeSelection.create(tr.doc, $to.pos));
4024
4022
  }
4025
4023
  else {
4026
- tr.setSelection(state.TextSelection.create(tr.doc, $to.pos));
4024
+ tr.setSelection(state.TextSelection.create(tr.doc, $to.pos - 1));
4027
4025
  }
4028
4026
  }
4029
4027
  else {
4030
4028
  // add node after horizontal rule if it’s the end of the document
4031
- const node = (_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create();
4032
- if (node) {
4033
- tr.insert(posAfter, node);
4034
- tr.setSelection(state.TextSelection.create(tr.doc, posAfter + 1));
4029
+ const defaultNode = ((_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create()) || ((_b = state$1.doc.type.contentMatch.defaultType) === null || _b === void 0 ? void 0 : _b.create());
4030
+ if (defaultNode) {
4031
+ const newPos = start + newNode.nodeSize;
4032
+ tr.insert(newPos, defaultNode);
4033
+ tr.setSelection(state.TextSelection.create(tr.doc, newPos));
4035
4034
  }
4036
4035
  }
4037
4036
  tr.scrollIntoView();