@tiptap/core 2.5.9 → 2.6.1
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 +24 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +24 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/Editor.d.ts +4 -0
- package/dist/packages/core/src/Extension.d.ts +4 -3
- package/dist/packages/core/src/Mark.d.ts +4 -3
- package/dist/packages/core/src/Node.d.ts +4 -3
- package/dist/packages/core/src/commands/setMeta.d.ts +2 -1
- package/dist/packages/core/src/commands/splitListItem.d.ts +2 -1
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +2 -1
- package/package.json +3 -3
- package/src/Editor.ts +6 -0
- package/src/Extension.ts +4 -3
- package/src/Mark.ts +4 -3
- package/src/Node.ts +4 -3
- package/src/commands/setMeta.ts +3 -1
- package/src/commands/splitListItem.ts +27 -17
- package/src/pasteRules/nodePasteRule.ts +14 -5
package/dist/index.cjs
CHANGED
|
@@ -3110,7 +3110,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state: state$1, dispatc
|
|
|
3110
3110
|
return can;
|
|
3111
3111
|
};
|
|
3112
3112
|
|
|
3113
|
-
const splitListItem = typeOrName => ({ tr, state: state$1, dispatch, editor, }) => {
|
|
3113
|
+
const splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state: state$1, dispatch, editor, }) => {
|
|
3114
3114
|
var _a;
|
|
3115
3115
|
const type = getNodeType(typeOrName, state$1.schema);
|
|
3116
3116
|
const { $from, $to } = state$1.selection;
|
|
@@ -3146,7 +3146,10 @@ const splitListItem = typeOrName => ({ tr, state: state$1, dispatch, editor, })
|
|
|
3146
3146
|
// eslint-disable-next-line
|
|
3147
3147
|
const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;
|
|
3148
3148
|
// Add a second list item with an empty default start node
|
|
3149
|
-
const newNextTypeAttributes =
|
|
3149
|
+
const newNextTypeAttributes = {
|
|
3150
|
+
...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
|
|
3151
|
+
...overrideAttrs,
|
|
3152
|
+
};
|
|
3150
3153
|
const nextType = ((_a = type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.createAndFill(newNextTypeAttributes)) || undefined;
|
|
3151
3154
|
wrap = wrap.append(model.Fragment.from(type.createAndFill(null, nextType) || undefined));
|
|
3152
3155
|
const start = $from.before($from.depth - (depthBefore - 1));
|
|
@@ -3168,8 +3171,14 @@ const splitListItem = typeOrName => ({ tr, state: state$1, dispatch, editor, })
|
|
|
3168
3171
|
return true;
|
|
3169
3172
|
}
|
|
3170
3173
|
const nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
|
|
3171
|
-
const newTypeAttributes =
|
|
3172
|
-
|
|
3174
|
+
const newTypeAttributes = {
|
|
3175
|
+
...getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs),
|
|
3176
|
+
...overrideAttrs,
|
|
3177
|
+
};
|
|
3178
|
+
const newNextTypeAttributes = {
|
|
3179
|
+
...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
|
|
3180
|
+
...overrideAttrs,
|
|
3181
|
+
};
|
|
3173
3182
|
tr.delete($from.pos, $to.pos);
|
|
3174
3183
|
const types = nextType
|
|
3175
3184
|
? [
|
|
@@ -3971,6 +3980,10 @@ class Editor extends EventEmitter {
|
|
|
3971
3980
|
constructor(options = {}) {
|
|
3972
3981
|
super();
|
|
3973
3982
|
this.isFocused = false;
|
|
3983
|
+
/**
|
|
3984
|
+
* The editor is considered initialized after the `create` event has been emitted.
|
|
3985
|
+
*/
|
|
3986
|
+
this.isInitialized = false;
|
|
3974
3987
|
this.extensionStorage = {};
|
|
3975
3988
|
this.options = {
|
|
3976
3989
|
element: document.createElement('div'),
|
|
@@ -4021,6 +4034,7 @@ class Editor extends EventEmitter {
|
|
|
4021
4034
|
}
|
|
4022
4035
|
this.commands.focus(this.options.autofocus);
|
|
4023
4036
|
this.emit('create', { editor: this });
|
|
4037
|
+
this.isInitialized = true;
|
|
4024
4038
|
}, 0);
|
|
4025
4039
|
}
|
|
4026
4040
|
/**
|
|
@@ -4988,14 +5002,16 @@ function nodePasteRule(config) {
|
|
|
4988
5002
|
find: config.find,
|
|
4989
5003
|
handler({ match, chain, range, pasteEvent, }) {
|
|
4990
5004
|
const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
|
|
5005
|
+
const content = callOrReturn(config.getContent, undefined, attributes);
|
|
4991
5006
|
if (attributes === false || attributes === null) {
|
|
4992
5007
|
return null;
|
|
4993
5008
|
}
|
|
5009
|
+
const node = { type: config.type.name, attrs: attributes };
|
|
5010
|
+
if (content) {
|
|
5011
|
+
node.content = content;
|
|
5012
|
+
}
|
|
4994
5013
|
if (match.input) {
|
|
4995
|
-
chain().deleteRange(range).insertContentAt(range.from,
|
|
4996
|
-
type: config.type.name,
|
|
4997
|
-
attrs: attributes,
|
|
4998
|
-
});
|
|
5014
|
+
chain().deleteRange(range).insertContentAt(range.from, node);
|
|
4999
5015
|
}
|
|
5000
5016
|
},
|
|
5001
5017
|
});
|