@tiptap/core 2.1.3 → 2.1.4

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
@@ -3986,14 +3986,12 @@ function markInputRule(config) {
3986
3986
  function nodeInputRule(config) {
3987
3987
  return new InputRule({
3988
3988
  find: config.find,
3989
- handler: ({ state: state$1, range, match }) => {
3990
- var _a, _b;
3989
+ handler: ({ state, range, match }) => {
3991
3990
  const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
3992
- const { tr } = state$1;
3993
- const start = config.blockReplace ? range.from - 1 : range.from;
3991
+ const { tr } = state;
3992
+ const start = range.from;
3994
3993
  let end = range.to;
3995
3994
  const newNode = config.type.create(attributes);
3996
- const { $to } = tr.selection;
3997
3995
  if (match[1]) {
3998
3996
  const offset = match[0].lastIndexOf(match[1]);
3999
3997
  let matchStart = start + offset;
@@ -4010,31 +4008,9 @@ function nodeInputRule(config) {
4010
4008
  tr.replaceWith(matchStart, end, newNode);
4011
4009
  }
4012
4010
  else if (match[0]) {
4013
- tr.replaceWith(start, end, newNode);
4014
- }
4015
- if (config.blockReplace && config.addExtraNewline) {
4016
- if ($to.nodeAfter) {
4017
- if ($to.nodeAfter.isTextblock) {
4018
- tr.setSelection(state.TextSelection.create(tr.doc, $to.pos + 1));
4019
- }
4020
- else if ($to.nodeAfter.isBlock) {
4021
- tr.setSelection(state.NodeSelection.create(tr.doc, $to.pos));
4022
- }
4023
- else {
4024
- tr.setSelection(state.TextSelection.create(tr.doc, $to.pos - 1));
4025
- }
4026
- }
4027
- else {
4028
- // add node after horizontal rule if it’s the end of the document
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));
4034
- }
4035
- }
4036
- tr.scrollIntoView();
4011
+ tr.insert(start - 1, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
4037
4012
  }
4013
+ tr.scrollIntoView();
4038
4014
  },
4039
4015
  });
4040
4016
  }