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