@tiptap/core 2.1.2 → 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.js CHANGED
@@ -3983,13 +3983,11 @@ function nodeInputRule(config) {
3983
3983
  return new InputRule({
3984
3984
  find: config.find,
3985
3985
  handler: ({ state, range, match }) => {
3986
- var _a, _b;
3987
3986
  const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
3988
3987
  const { tr } = state;
3989
- const start = config.blockReplace ? range.from - 1 : range.from;
3988
+ const start = range.from;
3990
3989
  let end = range.to;
3991
3990
  const newNode = config.type.create(attributes);
3992
- const { $to } = tr.selection;
3993
3991
  if (match[1]) {
3994
3992
  const offset = match[0].lastIndexOf(match[1]);
3995
3993
  let matchStart = start + offset;
@@ -4006,31 +4004,9 @@ function nodeInputRule(config) {
4006
4004
  tr.replaceWith(matchStart, end, newNode);
4007
4005
  }
4008
4006
  else if (match[0]) {
4009
- tr.replaceWith(start, end, newNode);
4010
- }
4011
- if (config.blockReplace && config.addExtraNewline) {
4012
- if ($to.nodeAfter) {
4013
- if ($to.nodeAfter.isTextblock) {
4014
- tr.setSelection(TextSelection.create(tr.doc, $to.pos + 1));
4015
- }
4016
- else if ($to.nodeAfter.isBlock) {
4017
- tr.setSelection(NodeSelection.create(tr.doc, $to.pos));
4018
- }
4019
- else {
4020
- tr.setSelection(TextSelection.create(tr.doc, $to.pos - 1));
4021
- }
4022
- }
4023
- else {
4024
- // add node after horizontal rule if it’s the end of the document
4025
- const defaultNode = ((_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create()) || ((_b = state.doc.type.contentMatch.defaultType) === null || _b === void 0 ? void 0 : _b.create());
4026
- if (defaultNode) {
4027
- const newPos = start + newNode.nodeSize;
4028
- tr.insert(newPos, defaultNode);
4029
- tr.setSelection(TextSelection.create(tr.doc, newPos));
4030
- }
4031
- }
4032
- tr.scrollIntoView();
4007
+ tr.insert(start - 1, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
4033
4008
  }
4009
+ tr.scrollIntoView();
4034
4010
  },
4035
4011
  });
4036
4012
  }