@tiptap/core 2.0.0-beta.180 → 2.0.0-beta.181
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/packages/core/src/pasteRules/index.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +12 -0
- package/dist/tiptap-core.cjs.js +33 -6
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +33 -7
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +33 -6
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/PasteRule.ts +1 -1
- package/src/commands/focus.ts +3 -1
- package/src/extensions/focusEvents.ts +2 -2
- package/src/pasteRules/index.ts +1 -0
- package/src/pasteRules/nodePasteRule.ts +39 -0
package/dist/tiptap-core.umd.js
CHANGED
|
@@ -1531,7 +1531,9 @@
|
|
|
1531
1531
|
delayedFocus();
|
|
1532
1532
|
return true;
|
|
1533
1533
|
}
|
|
1534
|
-
|
|
1534
|
+
// pass through tr.doc instead of editor.state.doc
|
|
1535
|
+
// since transactions could change the editors state before this command has been run
|
|
1536
|
+
const selection = resolveFocusPosition(tr.doc, position) || editor.state.selection;
|
|
1535
1537
|
const isSameSelection = editor.state.selection.eq(selection);
|
|
1536
1538
|
if (dispatch) {
|
|
1537
1539
|
if (!isSameSelection) {
|
|
@@ -4130,6 +4132,35 @@ img.ProseMirror-separator {
|
|
|
4130
4132
|
});
|
|
4131
4133
|
}
|
|
4132
4134
|
|
|
4135
|
+
// source: https://stackoverflow.com/a/6969486
|
|
4136
|
+
function escapeForRegEx(string) {
|
|
4137
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
/**
|
|
4141
|
+
* Build an paste rule that adds a node when the
|
|
4142
|
+
* matched text is pasted into it.
|
|
4143
|
+
*/
|
|
4144
|
+
function nodePasteRule(config) {
|
|
4145
|
+
return new PasteRule({
|
|
4146
|
+
find: config.find,
|
|
4147
|
+
handler({ match, chain, range }) {
|
|
4148
|
+
const attributes = callOrReturn(config.getAttributes, undefined, match);
|
|
4149
|
+
if (attributes === false || attributes === null) {
|
|
4150
|
+
return null;
|
|
4151
|
+
}
|
|
4152
|
+
if (match.input) {
|
|
4153
|
+
chain()
|
|
4154
|
+
.deleteRange(range)
|
|
4155
|
+
.insertContent({
|
|
4156
|
+
type: config.type.name,
|
|
4157
|
+
attrs: attributes,
|
|
4158
|
+
});
|
|
4159
|
+
}
|
|
4160
|
+
},
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4133
4164
|
/**
|
|
4134
4165
|
* Build an paste rule that replaces text when the
|
|
4135
4166
|
* matched text is pasted into it.
|
|
@@ -4181,11 +4212,6 @@ img.ProseMirror-separator {
|
|
|
4181
4212
|
}
|
|
4182
4213
|
}
|
|
4183
4214
|
|
|
4184
|
-
// source: https://stackoverflow.com/a/6969486
|
|
4185
|
-
function escapeForRegEx(string) {
|
|
4186
|
-
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
4187
|
-
}
|
|
4188
|
-
|
|
4189
4215
|
exports.CommandManager = CommandManager;
|
|
4190
4216
|
exports.Editor = Editor;
|
|
4191
4217
|
exports.Extension = Extension;
|
|
@@ -4235,6 +4261,7 @@ img.ProseMirror-separator {
|
|
|
4235
4261
|
exports.markPasteRule = markPasteRule;
|
|
4236
4262
|
exports.mergeAttributes = mergeAttributes;
|
|
4237
4263
|
exports.nodeInputRule = nodeInputRule;
|
|
4264
|
+
exports.nodePasteRule = nodePasteRule;
|
|
4238
4265
|
exports.pasteRulesPlugin = pasteRulesPlugin;
|
|
4239
4266
|
exports.posToDOMRect = posToDOMRect;
|
|
4240
4267
|
exports.textInputRule = textInputRule;
|