@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 +9 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +9 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/inputRules/nodeInputRule.ts +7 -8
- package/src/utilities/mergeAttributes.ts +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -300,8 +300,8 @@
|
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
302
|
if (key === 'class') {
|
|
303
|
-
const valueClasses = value.split(' ');
|
|
304
|
-
const existingClasses = mergedAttributes[key].split(' ');
|
|
303
|
+
const valueClasses = value ? value.split(' ') : [];
|
|
304
|
+
const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(' ') : [];
|
|
305
305
|
const insertClasses = valueClasses.filter(valueClass => !existingClasses.includes(valueClass));
|
|
306
306
|
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ');
|
|
307
307
|
}
|
|
@@ -3981,7 +3981,7 @@ img.ProseMirror-separator {
|
|
|
3981
3981
|
return new InputRule({
|
|
3982
3982
|
find: config.find,
|
|
3983
3983
|
handler: ({ state: state$1, range, match }) => {
|
|
3984
|
-
var _a;
|
|
3984
|
+
var _a, _b;
|
|
3985
3985
|
const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
|
|
3986
3986
|
const { tr } = state$1;
|
|
3987
3987
|
const start = config.blockReplace ? range.from - 1 : range.from;
|
|
@@ -4007,9 +4007,7 @@ img.ProseMirror-separator {
|
|
|
4007
4007
|
tr.replaceWith(start, end, newNode);
|
|
4008
4008
|
}
|
|
4009
4009
|
if (config.blockReplace && config.addExtraNewline) {
|
|
4010
|
-
const posAfter = $to.end();
|
|
4011
4010
|
if ($to.nodeAfter) {
|
|
4012
|
-
console.log($to.node().type.name);
|
|
4013
4011
|
if ($to.nodeAfter.isTextblock) {
|
|
4014
4012
|
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos + 1));
|
|
4015
4013
|
}
|
|
@@ -4017,15 +4015,16 @@ img.ProseMirror-separator {
|
|
|
4017
4015
|
tr.setSelection(state.NodeSelection.create(tr.doc, $to.pos));
|
|
4018
4016
|
}
|
|
4019
4017
|
else {
|
|
4020
|
-
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos));
|
|
4018
|
+
tr.setSelection(state.TextSelection.create(tr.doc, $to.pos - 1));
|
|
4021
4019
|
}
|
|
4022
4020
|
}
|
|
4023
4021
|
else {
|
|
4024
4022
|
// add node after horizontal rule if it’s the end of the document
|
|
4025
|
-
const
|
|
4026
|
-
if (
|
|
4027
|
-
|
|
4028
|
-
tr.
|
|
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));
|
|
4029
4028
|
}
|
|
4030
4029
|
}
|
|
4031
4030
|
tr.scrollIntoView();
|