@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.cjs +5 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -27
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +5 -29
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -10
- package/package.json +2 -2
- package/src/inputRules/nodeInputRule.ts +6 -40
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
|
|
3984
|
-
var _a, _b;
|
|
3983
|
+
handler: ({ state, range, match }) => {
|
|
3985
3984
|
const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
|
|
3986
|
-
const { tr } = state
|
|
3987
|
-
const start =
|
|
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.
|
|
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
|
}
|