@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 CHANGED
@@ -734,11 +734,11 @@ class PasteRule {
734
734
  this.handler = config.handler;
735
735
  }
736
736
  }
737
- const pasteRuleMatcherHandler = (text, find) => {
737
+ const pasteRuleMatcherHandler = (text, find, event) => {
738
738
  if (isRegExp(find)) {
739
739
  return [...text.matchAll(find)];
740
740
  }
741
- const matches = find(text);
741
+ const matches = find(text, event);
742
742
  if (!matches) {
743
743
  return [];
744
744
  }
@@ -770,7 +770,7 @@ function run(config) {
770
770
  const resolvedFrom = Math.max(from, pos);
771
771
  const resolvedTo = Math.min(to, pos + node.content.size);
772
772
  const textToMatch = node.textBetween(resolvedFrom - pos, resolvedTo - pos, undefined, '\ufffc');
773
- const matches = pasteRuleMatcherHandler(textToMatch, rule.find);
773
+ const matches = pasteRuleMatcherHandler(textToMatch, rule.find, pasteEvent);
774
774
  matches.forEach(match => {
775
775
  if (match.index === undefined) {
776
776
  return;
@@ -1613,6 +1613,7 @@ function createNodeFromContent(content, schema, options) {
1613
1613
  }
1614
1614
  }
1615
1615
  if (typeof content === 'string') {
1616
+ content = content.split('\n').map(part => part.trim()).join(''); // we need to remove new lines since the parser will add breaks
1616
1617
  const parser = model.DOMParser.fromSchema(schema);
1617
1618
  return options.slice
1618
1619
  ? parser.parseSlice(elementFromString(content), options.parseOptions).content
@@ -2311,6 +2312,9 @@ function getMarksBetween(from, to, doc) {
2311
2312
  }
2312
2313
  else {
2313
2314
  doc.nodesBetween(from, to, (node, pos) => {
2315
+ if (!node || node.nodeSize === undefined) {
2316
+ return;
2317
+ }
2314
2318
  marks.push(...node.marks.map(mark => ({
2315
2319
  from: pos,
2316
2320
  to: pos + node.nodeSize,