@tiptap/core 2.1.13 → 2.1.15
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 +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +7 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/PasteRule.d.ts +1 -1
- package/package.json +2 -2
- package/src/PasteRule.ts +4 -3
- package/src/helpers/createNodeFromContent.ts +1 -0
- package/src/helpers/getMarksBetween.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -730,11 +730,11 @@ class PasteRule {
|
|
|
730
730
|
this.handler = config.handler;
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
-
const pasteRuleMatcherHandler = (text, find) => {
|
|
733
|
+
const pasteRuleMatcherHandler = (text, find, event) => {
|
|
734
734
|
if (isRegExp(find)) {
|
|
735
735
|
return [...text.matchAll(find)];
|
|
736
736
|
}
|
|
737
|
-
const matches = find(text);
|
|
737
|
+
const matches = find(text, event);
|
|
738
738
|
if (!matches) {
|
|
739
739
|
return [];
|
|
740
740
|
}
|
|
@@ -766,7 +766,7 @@ function run(config) {
|
|
|
766
766
|
const resolvedFrom = Math.max(from, pos);
|
|
767
767
|
const resolvedTo = Math.min(to, pos + node.content.size);
|
|
768
768
|
const textToMatch = node.textBetween(resolvedFrom - pos, resolvedTo - pos, undefined, '\ufffc');
|
|
769
|
-
const matches = pasteRuleMatcherHandler(textToMatch, rule.find);
|
|
769
|
+
const matches = pasteRuleMatcherHandler(textToMatch, rule.find, pasteEvent);
|
|
770
770
|
matches.forEach(match => {
|
|
771
771
|
if (match.index === undefined) {
|
|
772
772
|
return;
|
|
@@ -1609,6 +1609,7 @@ function createNodeFromContent(content, schema, options) {
|
|
|
1609
1609
|
}
|
|
1610
1610
|
}
|
|
1611
1611
|
if (typeof content === 'string') {
|
|
1612
|
+
content = content.split('\n').map(part => part.trim()).join(''); // we need to remove new lines since the parser will add breaks
|
|
1612
1613
|
const parser = DOMParser.fromSchema(schema);
|
|
1613
1614
|
return options.slice
|
|
1614
1615
|
? parser.parseSlice(elementFromString(content), options.parseOptions).content
|
|
@@ -2307,6 +2308,9 @@ function getMarksBetween(from, to, doc) {
|
|
|
2307
2308
|
}
|
|
2308
2309
|
else {
|
|
2309
2310
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
2311
|
+
if (!node || node.nodeSize === undefined) {
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2310
2314
|
marks.push(...node.marks.map(mark => ({
|
|
2311
2315
|
from: pos,
|
|
2312
2316
|
to: pos + node.nodeSize,
|