@tiptap/core 3.2.2 → 3.3.0
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 +23 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/ExtensionManager.ts +20 -18
- package/src/PasteRule.ts +20 -3
package/dist/index.js
CHANGED
|
@@ -1914,12 +1914,17 @@ function run2(config) {
|
|
|
1914
1914
|
});
|
|
1915
1915
|
const handlers = [];
|
|
1916
1916
|
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
1917
|
-
|
|
1917
|
+
var _a, _b, _c, _d, _e;
|
|
1918
|
+
if (((_b = (_a = node.type) == null ? void 0 : _a.spec) == null ? void 0 : _b.code) || !(node.isText || node.isTextblock || node.isInline)) {
|
|
1918
1919
|
return;
|
|
1919
1920
|
}
|
|
1921
|
+
const contentSize = (_e = (_d = (_c = node.content) == null ? void 0 : _c.size) != null ? _d : node.nodeSize) != null ? _e : 0;
|
|
1920
1922
|
const resolvedFrom = Math.max(from, pos);
|
|
1921
|
-
const resolvedTo = Math.min(to, pos +
|
|
1922
|
-
|
|
1923
|
+
const resolvedTo = Math.min(to, pos + contentSize);
|
|
1924
|
+
if (resolvedFrom >= resolvedTo) {
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
const textToMatch = node.isText ? node.text || "" : node.textBetween(resolvedFrom - pos, resolvedTo - pos, void 0, "\uFFFC");
|
|
1923
1928
|
const matches = pasteRuleMatcherHandler(textToMatch, rule.find, pasteEvent);
|
|
1924
1929
|
matches.forEach((match) => {
|
|
1925
1930
|
if (match.index === void 0) {
|
|
@@ -2136,8 +2141,6 @@ var ExtensionManager = class {
|
|
|
2136
2141
|
get plugins() {
|
|
2137
2142
|
const { editor } = this;
|
|
2138
2143
|
const extensions = sortExtensions([...this.extensions].reverse());
|
|
2139
|
-
const inputRules = [];
|
|
2140
|
-
const pasteRules = [];
|
|
2141
2144
|
const allPlugins = extensions.map((extension) => {
|
|
2142
2145
|
const context = {
|
|
2143
2146
|
name: extension.name,
|
|
@@ -2168,11 +2171,23 @@ var ExtensionManager = class {
|
|
|
2168
2171
|
plugins.push(keyMapPlugin);
|
|
2169
2172
|
const addInputRules = getExtensionField(extension, "addInputRules", context);
|
|
2170
2173
|
if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
|
|
2171
|
-
|
|
2174
|
+
const rules = addInputRules();
|
|
2175
|
+
if (rules && rules.length) {
|
|
2176
|
+
const inputResult = inputRulesPlugin({
|
|
2177
|
+
editor,
|
|
2178
|
+
rules
|
|
2179
|
+
});
|
|
2180
|
+
const inputPlugins = Array.isArray(inputResult) ? inputResult : [inputResult];
|
|
2181
|
+
plugins.push(...inputPlugins);
|
|
2182
|
+
}
|
|
2172
2183
|
}
|
|
2173
2184
|
const addPasteRules = getExtensionField(extension, "addPasteRules", context);
|
|
2174
2185
|
if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
|
|
2175
|
-
|
|
2186
|
+
const rules = addPasteRules();
|
|
2187
|
+
if (rules && rules.length) {
|
|
2188
|
+
const pasteRules = pasteRulesPlugin({ editor, rules });
|
|
2189
|
+
plugins.push(...pasteRules);
|
|
2190
|
+
}
|
|
2176
2191
|
}
|
|
2177
2192
|
const addProseMirrorPlugins = getExtensionField(
|
|
2178
2193
|
extension,
|
|
@@ -2185,17 +2200,7 @@ var ExtensionManager = class {
|
|
|
2185
2200
|
}
|
|
2186
2201
|
return plugins;
|
|
2187
2202
|
}).flat();
|
|
2188
|
-
return
|
|
2189
|
-
inputRulesPlugin({
|
|
2190
|
-
editor,
|
|
2191
|
-
rules: inputRules
|
|
2192
|
-
}),
|
|
2193
|
-
...pasteRulesPlugin({
|
|
2194
|
-
editor,
|
|
2195
|
-
rules: pasteRules
|
|
2196
|
-
}),
|
|
2197
|
-
...allPlugins
|
|
2198
|
-
];
|
|
2203
|
+
return allPlugins;
|
|
2199
2204
|
}
|
|
2200
2205
|
/**
|
|
2201
2206
|
* Get all attributes from the extensions.
|