tiptap-markdown-react 1.3.0 → 1.3.2
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/{ReportContent-Cb67MCs9.js → ReportContent-Bc5q1bYp.js} +16 -13
- package/dist/{ReportContent-Cb67MCs9.js.map → ReportContent-Bc5q1bYp.js.map} +1 -1
- package/dist/{ReportContentWithCharts-B-K-EiAG.js → ReportContentWithCharts-DJO3xs88.js} +114 -35
- package/dist/ReportContentWithCharts-DJO3xs88.js.map +1 -0
- package/dist/{extractToc-H9otRa3G.js → extractToc-DiI2437D.js} +2 -2
- package/dist/{extractToc-H9otRa3G.js.map → extractToc-DiI2437D.js.map} +1 -1
- package/dist/index.js +6 -6
- package/dist/quoteHighlight/matchQuote.d.ts +38 -0
- package/dist/quoteHighlight/types.d.ts +57 -0
- package/dist/reader.js +2 -2
- package/dist/server.js +4 -4
- package/dist/style-inline.css +374 -361
- package/dist/style.css +374 -361
- package/package.json +1 -1
- package/dist/ReportContentWithCharts-B-K-EiAG.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Markdown, MarkdownManager } from "@tiptap/markdown";
|
|
3
|
-
import { g as getLocaleBundle, S as SearchIcon, d as ChevronUpIcon, e as ChevronDownIcon, X as XIcon, h as ReplaceIcon, i as ReplaceAllIcon, j as renderOrUpdateChart, k as destroyChart, l as CheckIcon, T as TrashIcon, n as CopyIcon, o as ChevronsUpDownIcon, G as GripIcon, E as EraserIcon, D as DownloadIcon, u as useIsMobile, K as KeyboardIcon, p as EditorToc, I as ImagePreviewHost, q as sameTocItems$1, A as AlignRightIcon, t as AlignCenterIcon, v as AlignLeftIcon, w as CropIcon, x as CaptionsIcon, y as ExpandIcon, z as requestImagePreview, B as RotateCcwIcon, F as ExternalLinkIcon, H as TableDeleteIcon, J as ColumnBeforeIcon, L as ColumnAfterIcon, M as ColumnDeleteIcon, N as RowBeforeIcon, O as RowAfterIcon, P as RowDeleteIcon, U as UndoIcon, Q as RedoIcon, V as BoldIcon, W as ItalicIcon, Y as UnderlineIcon, Z as StrikethroughIcon, _ as CodeIcon, $ as LinkIcon, a0 as ImageIcon, a1 as DetailsIcon, a2 as AlignJustifyIcon, a3 as IndentIncreaseIcon, a4 as IndentDecreaseIcon, a5 as LineHeightIcon, a6 as ListUnorderedIcon, a7 as ListOrderedIcon, a8 as ListChecksIcon } from "./ReportContentWithCharts-
|
|
4
|
-
import { C, a9, aa, a, ab, ac, ad, ae, b, c, af, ag, ah, f, m, r, s } from "./ReportContentWithCharts-
|
|
3
|
+
import { g as getLocaleBundle, S as SearchIcon, d as ChevronUpIcon, e as ChevronDownIcon, X as XIcon, h as ReplaceIcon, i as ReplaceAllIcon, j as renderOrUpdateChart, k as destroyChart, l as CheckIcon, T as TrashIcon, n as CopyIcon, o as ChevronsUpDownIcon, G as GripIcon, E as EraserIcon, D as DownloadIcon, u as useIsMobile, K as KeyboardIcon, p as EditorToc, I as ImagePreviewHost, q as sameTocItems$1, A as AlignRightIcon, t as AlignCenterIcon, v as AlignLeftIcon, w as CropIcon, x as CaptionsIcon, y as ExpandIcon, z as requestImagePreview, B as RotateCcwIcon, F as ExternalLinkIcon, H as TableDeleteIcon, J as ColumnBeforeIcon, L as ColumnAfterIcon, M as ColumnDeleteIcon, N as RowBeforeIcon, O as RowAfterIcon, P as RowDeleteIcon, U as UndoIcon, Q as RedoIcon, V as BoldIcon, W as ItalicIcon, Y as UnderlineIcon, Z as StrikethroughIcon, _ as CodeIcon, $ as LinkIcon, a0 as ImageIcon, a1 as DetailsIcon, a2 as AlignJustifyIcon, a3 as IndentIncreaseIcon, a4 as IndentDecreaseIcon, a5 as LineHeightIcon, a6 as ListUnorderedIcon, a7 as ListOrderedIcon, a8 as ListChecksIcon } from "./ReportContentWithCharts-DJO3xs88.js";
|
|
4
|
+
import { C, a9, aa, a, ab, ac, ad, ae, b, c, af, ag, ah, f, m, r, s } from "./ReportContentWithCharts-DJO3xs88.js";
|
|
5
5
|
import { jsx, jsxs, Fragment as Fragment$2 } from "react/jsx-runtime";
|
|
6
6
|
import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
|
|
7
7
|
import FindAndReplace, { FindAndReplacePluginKey, createSearchRegex } from "@tiptap/extension-find-and-replace";
|
|
@@ -14,10 +14,10 @@ import { NodeViewWrapper, ReactNodeViewRenderer, useEditorState, ReactRenderer,
|
|
|
14
14
|
import { Extension, Node as Node$1, mergeAttributes } from "@tiptap/core";
|
|
15
15
|
import { createPortal } from "react-dom";
|
|
16
16
|
import { useState, useEffect, useCallback, useRef, useMemo, useSyncExternalStore, useLayoutEffect, forwardRef, useId, useImperativeHandle, Fragment as Fragment$1, useContext, createContext } from "react";
|
|
17
|
-
import { q as normalizeImageAlign, l as normalizeImageCrop, m as cropImageBox, e as enrichMarkdownCitations, o as styles$e, i as imageMarkdownTokenizer, c as imageParseMarkdown, d as imageRenderMarkdown, f as imageNodeHtml, g as imageFigureParseRule, h as imageCropAttribute, j as imageCaptionAttribute, k as imageAlignAttribute, r as normalizeImageCaption } from "./ReportContent-
|
|
18
|
-
import { R, a as a2, b as b2, s as s2 } from "./ReportContent-
|
|
19
|
-
import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, p as prepareChartMarkdown, j as reportChart, f as CommentMark, b as baseExtensions, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, a as pureCodeBlock, c as pureImage, n as renderMathInto, o as readCurrentNumberingFormat, q as subscribeMathClick, t as applyNumberingFormat, N as NUMBERING_FORMAT_IDS, u as NUMBERING_FORMAT_LABELS, v as NUMBERING_FORMAT_PREVIEWS, d as pureChart } from "./extractToc-
|
|
20
|
-
import { P, g, e, s as s3 } from "./extractToc-
|
|
17
|
+
import { q as normalizeImageAlign, l as normalizeImageCrop, m as cropImageBox, e as enrichMarkdownCitations, o as styles$e, i as imageMarkdownTokenizer, c as imageParseMarkdown, d as imageRenderMarkdown, f as imageNodeHtml, g as imageFigureParseRule, h as imageCropAttribute, j as imageCaptionAttribute, k as imageAlignAttribute, r as normalizeImageCaption } from "./ReportContent-Bc5q1bYp.js";
|
|
18
|
+
import { R, a as a2, b as b2, s as s2 } from "./ReportContent-Bc5q1bYp.js";
|
|
19
|
+
import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, p as prepareChartMarkdown, j as reportChart, f as CommentMark, b as baseExtensions, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, a as pureCodeBlock, c as pureImage, n as renderMathInto, o as readCurrentNumberingFormat, q as subscribeMathClick, t as applyNumberingFormat, N as NUMBERING_FORMAT_IDS, u as NUMBERING_FORMAT_LABELS, v as NUMBERING_FORMAT_PREVIEWS, d as pureChart } from "./extractToc-DiI2437D.js";
|
|
20
|
+
import { P, g, e, s as s3 } from "./extractToc-DiI2437D.js";
|
|
21
21
|
import { Slice, Fragment } from "@tiptap/pm/model";
|
|
22
22
|
import { PluginKey, Plugin, Selection, TextSelection, NodeSelection } from "@tiptap/pm/state";
|
|
23
23
|
import { DecorationSet, Decoration } from "@tiptap/pm/view";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 在一段文本里定位划线引用。
|
|
3
|
+
*
|
|
4
|
+
* 阅读页的锚点有时对照的是 markdown 原文,有时对照的是渲染后的 DOM 文本。
|
|
5
|
+
* 两边先去掉 markdown 记号和全部空白,再比对,命中后映射回原文偏移。
|
|
6
|
+
* 规则与宿主阅读页 `matchSegmentInText` 一致:exact → 前后文消歧 → 前 20 字降级。
|
|
7
|
+
*/
|
|
8
|
+
interface NormalizedText {
|
|
9
|
+
norm: string;
|
|
10
|
+
map: number[];
|
|
11
|
+
}
|
|
12
|
+
export declare function normalizeWithMap(raw: string): NormalizedText;
|
|
13
|
+
/** exact 整段对不上时,退化匹配开头多少字。 */
|
|
14
|
+
export declare const PREFIX_FALLBACK_LEN = 20;
|
|
15
|
+
export type MatchState = 'matched' | 'ambiguous' | 'outdated';
|
|
16
|
+
export type MatchVia = 'full' | 'context' | 'prefix';
|
|
17
|
+
export interface MatchHit {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SegmentMatchResult {
|
|
22
|
+
hits: MatchHit[];
|
|
23
|
+
state: MatchState;
|
|
24
|
+
via: MatchVia;
|
|
25
|
+
}
|
|
26
|
+
export interface MatchableSegment {
|
|
27
|
+
prefix?: string;
|
|
28
|
+
exact: string;
|
|
29
|
+
suffix?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 在 fullText 里定位一个引用段。
|
|
33
|
+
* 1. 归一空间里扫 exact:一处 → matched;多处用 prefix/suffix 打分
|
|
34
|
+
* 2. 一处都没有 → 退化匹配 exact 开头
|
|
35
|
+
* 3. 仍然没有 → outdated
|
|
36
|
+
*/
|
|
37
|
+
export declare function matchSegmentInText(fullText: string, seg: MatchableSegment): SegmentMatchResult;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 划线锚点的一段引用。存库格式(ref_content 编解码)留在宿主;
|
|
4
|
+
* 组件只吃已经解开的 prefix / exact / suffix。
|
|
5
|
+
*/
|
|
6
|
+
export interface QuoteSegment {
|
|
7
|
+
prefix?: string;
|
|
8
|
+
exact: string;
|
|
9
|
+
suffix?: string;
|
|
10
|
+
}
|
|
11
|
+
/** 一条划线。id 由宿主定,点击和滚动都用它。 */
|
|
12
|
+
export interface QuoteHighlightItem {
|
|
13
|
+
id: string;
|
|
14
|
+
segments: QuoteSegment[];
|
|
15
|
+
}
|
|
16
|
+
/** 这条划线在当前正文里还能不能对上。 */
|
|
17
|
+
export type QuoteHighlightState = 'matched' | 'ambiguous' | 'outdated';
|
|
18
|
+
/** 从正文选区切出来的引用,宿主拿去存成自己的留言锚点。 */
|
|
19
|
+
export interface TextQuote {
|
|
20
|
+
prefix: string;
|
|
21
|
+
exact: string;
|
|
22
|
+
suffix: string;
|
|
23
|
+
}
|
|
24
|
+
/** 选区引用 + 视口位置。宿主用 rect 放自己的「留言」按钮。 */
|
|
25
|
+
export interface TextSelectionQuote {
|
|
26
|
+
quote: TextQuote;
|
|
27
|
+
rect: {
|
|
28
|
+
top: number;
|
|
29
|
+
left: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface QuoteHighlightController {
|
|
35
|
+
/** 把视口滚到这条划线的第一处。对不上时什么都不做。 */
|
|
36
|
+
scrollTo: (id: string) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface QuoteHighlightProps {
|
|
39
|
+
/**
|
|
40
|
+
* 要画在正文上的划线。不传则不画、也不监听点击。
|
|
41
|
+
* 留言正文、列表、输入框都由宿主自己管。
|
|
42
|
+
*/
|
|
43
|
+
highlights?: QuoteHighlightItem[];
|
|
44
|
+
/** 加深这一条(例如用户在留言列表里点了引用)。 */
|
|
45
|
+
activeHighlightId?: string | null;
|
|
46
|
+
/** 点中已划线的文字。 */
|
|
47
|
+
onHighlightClick?: (id: string) => void;
|
|
48
|
+
/** 每条划线的定位结果,宿主用来标「未定位」。 */
|
|
49
|
+
onHighlightStates?: (states: Record<string, QuoteHighlightState>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* 用户在正文里划出一段非空选区时给出引用和位置;选区塌缩时给 null。
|
|
52
|
+
* 组件不弹出按钮、不创建留言。
|
|
53
|
+
*/
|
|
54
|
+
onTextSelect?: (selection: TextSelectionQuote | null) => void;
|
|
55
|
+
/** 命令式滚动。 */
|
|
56
|
+
highlightRef?: RefObject<QuoteHighlightController | null>;
|
|
57
|
+
}
|
package/dist/reader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { C, a, R, b, c, f, m, r, s } from "./ReportContentWithCharts-
|
|
3
|
-
import { a as a2, e, b as b2 } from "./ReportContent-
|
|
2
|
+
import { C, a, R, b, c, f, m, r, s } from "./ReportContentWithCharts-DJO3xs88.js";
|
|
3
|
+
import { a as a2, e, b as b2 } from "./ReportContent-Bc5q1bYp.js";
|
|
4
4
|
export {
|
|
5
5
|
C as ChartMount,
|
|
6
6
|
a as CitationInteractive,
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as stabilizeMarkdown, p as prepareChartMarkdown, b as baseExtensions, a as pureCodeBlock, c as pureImage, d as pureChart, C as CitationRef, m as makeTocGetId, r as renderMathElementHtml, e as extractToc } from "./extractToc-
|
|
2
|
-
import { f, g, l, h, i, j } from "./extractToc-
|
|
3
|
-
import { a as applyCitationSources } from "./ReportContent-
|
|
4
|
-
import { R, e, s } from "./ReportContent-
|
|
1
|
+
import { s as stabilizeMarkdown, p as prepareChartMarkdown, b as baseExtensions, a as pureCodeBlock, c as pureImage, d as pureChart, C as CitationRef, m as makeTocGetId, r as renderMathElementHtml, e as extractToc } from "./extractToc-DiI2437D.js";
|
|
2
|
+
import { f, g, l, h, i, j } from "./extractToc-DiI2437D.js";
|
|
3
|
+
import { a as applyCitationSources } from "./ReportContent-Bc5q1bYp.js";
|
|
4
|
+
import { R, e, s } from "./ReportContent-Bc5q1bYp.js";
|
|
5
5
|
import { TableOfContents, generateTocIds } from "@tiptap/extension-table-of-contents";
|
|
6
6
|
import { MarkdownManager } from "@tiptap/markdown";
|
|
7
7
|
import { renderToHTMLString } from "@tiptap/static-renderer";
|