tiptap-markdown-react 0.10.1 → 0.10.3

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.
@@ -17,7 +17,12 @@ export interface AnchorRange {
17
17
  /** doc 坐标 */
18
18
  from: number;
19
19
  to: number;
20
- /** 区间当前对应的纯文本(块间用 `\n\n` 连接,与选区文本同一口径)。 */
20
+ /**
21
+ * 区间当前的纯文本。**按匹配器的口径**给出:`commentMapper` 把区间内的 text 节点
22
+ * 直接拼起来(块之间**没有分隔符**),所以这里也是 `textBetween(from, to)`(不传
23
+ * blockSeparator)。调用方拿它跟「建锚点时用的那段文本」比对——两边必须同一口径,
24
+ * 否则多块区间(表格 / 列表)会永远对不上。
25
+ */
21
26
  text: string;
22
27
  status: CommentAnchorStatus;
23
28
  }
package/dist/index.js CHANGED
@@ -3113,7 +3113,8 @@ function findRangeByAnchor(editor, anchor) {
3113
3113
  return {
3114
3114
  from: range.from,
3115
3115
  to: range.to,
3116
- text: editor.state.doc.textBetween(range.from, range.to, "\n\n"),
3116
+ // 无 blockSeparator:与 commentMapper 的 `collectText`(text 节点直接拼接)同一口径
3117
+ text: editor.state.doc.textBetween(range.from, range.to),
3117
3118
  status: result.status
3118
3119
  };
3119
3120
  }
@@ -3159,7 +3160,7 @@ function getMarkdownForRange(editor, from, to, options = {}) {
3159
3160
  const markdown2 = parts.slice(first, last + 1).join(BLOCK_SEPARATOR);
3160
3161
  if (!markdown2) return null;
3161
3162
  const at2 = first === 0 ? 0 : parts.slice(0, first).join(BLOCK_SEPARATOR).length + BLOCK_SEPARATOR.length;
3162
- return { markdown: markdown2, from: at2, to: at2 + markdown2.length };
3163
+ return { markdown: markdown2, from: at2, to: at2 + markdown2.length, docFrom: start, docTo: end };
3163
3164
  }
3164
3165
  const markdown = manager.serialize(
3165
3166
  editor.state.doc.cut(start, end).toJSON()
@@ -3167,7 +3168,7 @@ function getMarkdownForRange(editor, from, to, options = {}) {
3167
3168
  if (!markdown) return null;
3168
3169
  const at = full.indexOf(markdown);
3169
3170
  if (at < 0 || full.indexOf(markdown, at + 1) >= 0) return null;
3170
- return { markdown, from: at, to: at + markdown.length };
3171
+ return { markdown, from: at, to: at + markdown.length, docFrom: start, docTo: end };
3171
3172
  }
3172
3173
  function normalizeMarkdown(markdown) {
3173
3174
  if (!markdown) return markdown;