tiptap-markdown-react 0.17.1 → 0.18.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/labels.d.ts CHANGED
@@ -25,7 +25,18 @@ export interface ToolbarLabels {
25
25
  superscript: string;
26
26
  subscript: string;
27
27
  link: string;
28
+ /**
29
+ * 链接浮层输入框的占位与无障碍名(原 `window.prompt` 的提示语,现在落到输入框上)。
30
+ */
28
31
  linkPrompt: string;
32
+ /** 链接浮层「应用」按钮的 title / aria-label。 */
33
+ linkApply: string;
34
+ /** 链接浮层「在新窗口打开」按钮的 title / aria-label。 */
35
+ linkOpen: string;
36
+ /** 链接浮层「移除链接」按钮的 title / aria-label。 */
37
+ linkRemove: string;
38
+ /** 链接浮层:地址被编辑器拒绝时的提示(落在输入框 title 上)。 */
39
+ linkInvalid: string;
29
40
  image: string;
30
41
  imageUploadFailed: string;
31
42
  /** Markdown 文件导入失败(与图片上传共用 onError 回调时,便于宿主区分文案)。 */
@@ -49,11 +60,29 @@ export interface ToolbarLabels {
49
60
  orderedList: string;
50
61
  taskList: string;
51
62
  more: string;
63
+ /**
64
+ * 工具栏的搜索入口(放大镜按钮,落在 More 之后):title 与 aria-label。
65
+ * 只在宿主传了 `onSearch` 时才渲染——它只是入口,条子本身归编辑器
66
+ * (`<MarkdownWysiwygEditor>`),点击后由宿主调 `handle.openFind()`。
67
+ */
68
+ search: string;
52
69
  codeBlock: string;
53
70
  hr: string;
54
71
  /** 导入下拉里的 Markdown 项。 */
55
72
  importMarkdown: string;
56
73
  tableInsert: string;
74
+ /** 行手柄的 title / aria-label(鼠标悬停单元格时出现在行的左缘)。 */
75
+ tableRowMenu: string;
76
+ /** 列手柄的 title / aria-label(悬停时出现在表格上方、对齐该列)。 */
77
+ tableColumnMenu: string;
78
+ /** 表格菜单:清空选中行 / 列 / 单元格矩形里的内容(保留单元格与表头)。 */
79
+ tableClearContent: string;
80
+ /** 表格菜单:把选中单元格的样式属性复位(列宽、对齐等;不动合并结构)。 */
81
+ tableResetCellStyles: string;
82
+ /** 表格底边 `+` 手柄(末尾追加一行)的 title / aria-label。 */
83
+ tableAppendRow: string;
84
+ /** 表格右边 `+` 手柄(末尾追加一列)的 title / aria-label。 */
85
+ tableAppendColumn: string;
57
86
  /** 网格选择器底部尺寸文案,如 "3 × 4"。参数顺序:列、行。 */
58
87
  tableSizeSelected: (cols: number, rows: number) => string;
59
88
  tableAddColumnBefore: string;
@@ -152,6 +181,17 @@ export interface ShortcutLabels {
152
181
  findReplace: string;
153
182
  }
154
183
  export declare const defaultShortcutLabels: ShortcutLabels;
184
+ /** 链接编辑浮层(`<LinkPopover>`)文案。 */
185
+ export interface LinkPopoverLabels {
186
+ /** 输入框占位与无障碍名,也是浮层的 aria-label。 */
187
+ field: string;
188
+ apply: string;
189
+ open: string;
190
+ remove: string;
191
+ /** 地址被编辑器拒绝时的提示(落在输入框 title 上)。 */
192
+ invalid: string;
193
+ }
194
+ export declare const defaultLinkPopoverLabels: LinkPopoverLabels;
155
195
  export interface ColorPaletteLabels {
156
196
  none: string;
157
197
  theme: string;
@@ -197,7 +237,7 @@ export interface FindLabels {
197
237
  caseSensitive: string;
198
238
  wholeWord: string;
199
239
  useRegex: string;
200
- /** 计数文案。无结果时 current 传 0。 */
240
+ /** 计数文案。无结果时 current 传 0;有结果但还没定位到某一条(currentIndex 为 null)时也是 0。 */
201
241
  counter: (current: number, total: number) => string;
202
242
  /** 正则模式下模式非法(RE2 不支持 lookaround / backreference 等,见官方扩展)。 */
203
243
  invalidRegex: string;
@@ -0,0 +1,45 @@
1
+ import { Editor } from '@tiptap/react';
2
+ /** 链接可编辑吗:只读态、或当前选区不允许套 link mark(例如整块选中)时为 false。 */
3
+ export declare function canSetLink(editor: Editor | null | undefined): boolean;
4
+ /** 光标 / 选区是否落在链接里。 */
5
+ export declare function isLinkActive(editor: Editor | null | undefined): boolean;
6
+ /** 读当前链接的 href(不在链接里时是空串)。 */
7
+ export declare function readLinkHref(editor: Editor | null | undefined): string;
8
+ /**
9
+ * 把用户输入整理成要存进 href 的值。
10
+ *
11
+ * 原样保留:空、站内相对地址(`/docs`、`#sec`、`?q=1`)、已带协议的(`https:`、`mailto:`)。
12
+ * 补协议:裸域名(`example.com`、`example.com/a`)与主机:端口(`localhost:3000`)——补的是
13
+ * 扩展配置的 `defaultProtocol`,与 Tiptap 自动链接同一套,避免手打和粘贴落到不同地址。
14
+ */
15
+ export declare function normalizeLinkHref(editor: Editor, raw: string): string;
16
+ /**
17
+ * 应用链接:把地址套到**整条**链接(或选区)上;选区为空且原本不在链接里时,把地址当文本插进去。
18
+ * 返回扩展是否接受了这个地址——`setLink` 会走 Tiptap 的 `isAllowedUri`。
19
+ *
20
+ * 两处与官方那版不同,都是单测逼出来的:
21
+ * 1. 先 `can().setLink()` 干跑一遍。官方把 `insertContent` 挂在失败的 `setLink` 后面直接
22
+ * `run()`,结果是地址被拒时正文仍被改(链接文字被换成那个地址)。
23
+ * 2. 「当文本插入」的判据是「选区为空**且光标不在已有链接里**」。官方只看选区是否为空,
24
+ * 于是「光标在链接里、改一个地址」会把整条链接的文字替换成地址——而这正是这个浮层的主用途。
25
+ */
26
+ export declare function applyLink(editor: Editor | null | undefined, raw: string): boolean;
27
+ /** 移除链接:范围同样扩到整条,并挡住自动链接立刻加回来。 */
28
+ export declare function removeLink(editor: Editor | null | undefined): boolean;
29
+ /**
30
+ * 把待打开的地址解析成绝对地址;解析不了、或协议不在白名单里时返回 `'#'` 表示「别打开」。
31
+ *
32
+ * 与官方 `sanitizeUrl(inputUrl, baseUrl)` 同语义:先按 base 解析成绝对地址(相对地址因此也
33
+ * 能用),再查协议白名单。调用方拿到 `'#'` 就不开新窗口。
34
+ */
35
+ export declare function sanitizeLinkUrl(input: string, baseUrl: string): string;
36
+ /**
37
+ * 打开地址(新窗口 + `noopener,noreferrer`)。空输入或非法地址都不开窗——调用方在此之前
38
+ * 已经用 `sanitizeLinkUrl` 判过一次,这里再判一次是为了让这个入口单独用也安全。
39
+ */
40
+ export declare function openLinkUrl(input: string, baseUrl: string): boolean;
41
+ /** 输入框的回车是否该当作「应用」(输入法组合中的回车是提交候选词,放行)。 */
42
+ export declare function isApplyKey(event: {
43
+ key: string;
44
+ nativeEvent: Pick<KeyboardEvent, 'isComposing' | 'keyCode'>;
45
+ }): boolean;
@@ -0,0 +1 @@
1
+ export {};