@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.esm.js
CHANGED
|
@@ -1533,7 +1533,9 @@ const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch,
|
|
|
1533
1533
|
delayedFocus();
|
|
1534
1534
|
return true;
|
|
1535
1535
|
}
|
|
1536
|
-
|
|
1536
|
+
// pass through tr.doc instead of editor.state.doc
|
|
1537
|
+
// since transactions could change the editors state before this command has been run
|
|
1538
|
+
const selection = resolveFocusPosition(tr.doc, position) || editor.state.selection;
|
|
1537
1539
|
const isSameSelection = editor.state.selection.eq(selection);
|
|
1538
1540
|
if (dispatch) {
|
|
1539
1541
|
if (!isSameSelection) {
|
|
@@ -4132,6 +4134,35 @@ function markPasteRule(config) {
|
|
|
4132
4134
|
});
|
|
4133
4135
|
}
|
|
4134
4136
|
|
|
4137
|
+
// source: https://stackoverflow.com/a/6969486
|
|
4138
|
+
function escapeForRegEx(string) {
|
|
4139
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
/**
|
|
4143
|
+
* Build an paste rule that adds a node when the
|
|
4144
|
+
* matched text is pasted into it.
|
|
4145
|
+
*/
|
|
4146
|
+
function nodePasteRule(config) {
|
|
4147
|
+
return new PasteRule({
|
|
4148
|
+
find: config.find,
|
|
4149
|
+
handler({ match, chain, range }) {
|
|
4150
|
+
const attributes = callOrReturn(config.getAttributes, undefined, match);
|
|
4151
|
+
if (attributes === false || attributes === null) {
|
|
4152
|
+
return null;
|
|
4153
|
+
}
|
|
4154
|
+
if (match.input) {
|
|
4155
|
+
chain()
|
|
4156
|
+
.deleteRange(range)
|
|
4157
|
+
.insertContent({
|
|
4158
|
+
type: config.type.name,
|
|
4159
|
+
attrs: attributes,
|
|
4160
|
+
});
|
|
4161
|
+
}
|
|
4162
|
+
},
|
|
4163
|
+
});
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4135
4166
|
/**
|
|
4136
4167
|
* Build an paste rule that replaces text when the
|
|
4137
4168
|
* matched text is pasted into it.
|
|
@@ -4183,10 +4214,5 @@ class Tracker {
|
|
|
4183
4214
|
}
|
|
4184
4215
|
}
|
|
4185
4216
|
|
|
4186
|
-
|
|
4187
|
-
function escapeForRegEx(string) {
|
|
4188
|
-
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
4189
|
-
}
|
|
4190
|
-
|
|
4191
|
-
export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, defaultBlockAt, escapeForRegEx, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, inputRulesPlugin, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, pasteRulesPlugin, posToDOMRect, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
4217
|
+
export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, defaultBlockAt, escapeForRegEx, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, inputRulesPlugin, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, nodePasteRule, pasteRulesPlugin, posToDOMRect, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
4192
4218
|
//# sourceMappingURL=tiptap-core.esm.js.map
|