markloom 0.6.0 → 0.7.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/collab.md +25 -13
- package/dist/ai/index.cjs +5 -4
- package/dist/ai/index.d.cts +5 -5
- package/dist/ai/index.d.ts +5 -5
- package/dist/ai/index.js +4 -3
- package/dist/{chunk-KYZJIOOL.js → chunk-4Q7PAR2T.js} +3671 -904
- package/dist/chunk-75EJ4ARB.cjs +642 -0
- package/dist/{chunk-U3JZDFL4.cjs → chunk-BMPCVT3B.cjs} +2 -34
- package/dist/{chunk-VSBIMMI7.js → chunk-EFYT2223.js} +3 -35
- package/dist/chunk-HXABDVLZ.cjs +297 -0
- package/dist/{chunk-I5VK4U7J.cjs → chunk-I2LDEVLA.cjs} +434 -80
- package/dist/{chunk-YBAT343I.js → chunk-MQLRZQZL.js} +263 -119
- package/dist/chunk-OVHASRID.cjs +4279 -0
- package/dist/chunk-PCSVBPOR.cjs +40 -0
- package/dist/{chunk-TB2OY3D4.js → chunk-PSAXWBNM.js} +413 -59
- package/dist/{chunk-QEVME6ZU.cjs → chunk-PZRWTLLB.cjs} +260 -161
- package/dist/chunk-QO7JEZDB.js +4279 -0
- package/dist/{chunk-EJSFZHGT.js → chunk-WSJUXPAG.js} +18 -2
- package/dist/{chunk-ACFYBYZJ.cjs → chunk-Y4IXQFWL.cjs} +4212 -1445
- package/dist/{chunk-CGYCJORO.js → chunk-YLVSMDIO.js} +220 -121
- package/dist/chunk-ZL6WT6OY.js +297 -0
- package/dist/{client-CLYq17SW.d.ts → client-BvvyHjhh.d.ts} +57 -7
- package/dist/{client-DAth8pPq.d.cts → client-Ciy7Fa_k.d.cts} +57 -7
- package/dist/collab/index.cjs +5 -4
- package/dist/collab/index.d.cts +13 -15
- package/dist/collab/index.d.ts +13 -15
- package/dist/collab/index.js +4 -3
- package/dist/{controller-BIOO_XKJ.d.cts → controller-CHznEhAR.d.cts} +186 -27
- package/dist/{controller-6AJ36G52.d.ts → controller-DLqI8_jm.d.ts} +186 -27
- package/dist/index.cjs +69 -7
- package/dist/index.d.cts +127 -8
- package/dist/index.d.ts +127 -8
- package/dist/index.js +80 -18
- package/dist/io/index.cjs +58 -59
- package/dist/io/index.d.cts +1 -1
- package/dist/io/index.d.ts +1 -1
- package/dist/io/index.js +15 -16
- package/dist/react/index.cjs +9 -8
- package/dist/react/index.d.cts +5 -5
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +8 -7
- package/dist/{rebase-batch-DlerAcFN.d.ts → rebase-batch-CSnv8FKp.d.ts} +1 -1
- package/dist/{rebase-batch-PjENQ742.d.cts → rebase-batch-DO1ygkx9.d.cts} +1 -1
- package/dist/{types-COUweEav.d.cts → types-BkHlmUFL.d.cts} +5 -1
- package/dist/{types-COUweEav.d.ts → types-BkHlmUFL.d.ts} +5 -1
- package/dist/{versions-9mG1epfB.d.cts → versions-DNFf8zVz.d.cts} +1 -1
- package/dist/{versions-Bubyo4pt.d.ts → versions-DOkOyh2J.d.ts} +1 -1
- package/dist/view/index.cjs +215 -17
- package/dist/view/index.d.cts +82 -9
- package/dist/view/index.d.ts +82 -9
- package/dist/view/index.js +212 -14
- package/dist/view/theme.css +349 -75
- package/dist/{suggest-Bk4zLzuv.d.ts → word-count-BPw9G2Bg.d.ts} +15 -5
- package/dist/{suggest-BkGGiPKA.d.cts → word-count-DNLn1h_t.d.cts} +15 -5
- package/package.json +11 -6
- package/dist/chunk-EADZKEU4.cjs +0 -498
- package/dist/chunk-SNFF6X45.js +0 -2347
- package/dist/chunk-TWD5T4YC.cjs +0 -2347
- package/dist/chunk-ZKQSQSSM.cjs +0 -24
|
@@ -1,38 +1,330 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendText,
|
|
3
|
-
firstLeafPath,
|
|
4
3
|
insertAfter,
|
|
5
|
-
lastLeafEnd,
|
|
6
4
|
mdToDoc,
|
|
7
|
-
normalizeToLeaf,
|
|
8
5
|
pathOfId,
|
|
9
6
|
rewriteNode
|
|
10
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QO7JEZDB.js";
|
|
11
8
|
import {
|
|
9
|
+
firstLeafPath,
|
|
10
|
+
lastLeafEnd,
|
|
11
|
+
nodeAt,
|
|
12
|
+
normalizeToLeaf
|
|
13
|
+
} from "./chunk-ZL6WT6OY.js";
|
|
14
|
+
import {
|
|
15
|
+
isAiCompose,
|
|
12
16
|
isElement,
|
|
13
17
|
isText
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-WSJUXPAG.js";
|
|
19
|
+
|
|
20
|
+
// src/i18n.ts
|
|
21
|
+
var KEY = "__markloom_locale__";
|
|
22
|
+
var g = globalThis;
|
|
23
|
+
function setLocale(l) {
|
|
24
|
+
g[KEY] = l === "en" ? "en" : "zh";
|
|
25
|
+
}
|
|
26
|
+
function getLocale() {
|
|
27
|
+
return g[KEY] === "en" ? "en" : "zh";
|
|
28
|
+
}
|
|
29
|
+
var MESSAGES = {
|
|
30
|
+
// —— 块类型(斜杠菜单 / 悬停手柄 / 浮动工具条共用) ——
|
|
31
|
+
blkParagraph: ["\u6B63\u6587", "Text"],
|
|
32
|
+
blkH1: ["\u6807\u9898 1", "Heading 1"],
|
|
33
|
+
blkH2: ["\u6807\u9898 2", "Heading 2"],
|
|
34
|
+
blkH3: ["\u6807\u9898 3", "Heading 3"],
|
|
35
|
+
blkBullet: ["\u65E0\u5E8F\u5217\u8868", "Bulleted list"],
|
|
36
|
+
blkOrdered: ["\u6709\u5E8F\u5217\u8868", "Numbered list"],
|
|
37
|
+
blkTask: ["\u4EFB\u52A1\u5217\u8868", "Task list"],
|
|
38
|
+
blkQuote: ["\u5F15\u7528", "Quote"],
|
|
39
|
+
blkCallout: ["\u9AD8\u4EAE\u5757", "Callout"],
|
|
40
|
+
blkCode: ["\u4EE3\u7801\u5757", "Code block"],
|
|
41
|
+
// —— 斜杠菜单 ——
|
|
42
|
+
aiWrite: ["AI \u5199\u4F5C", "Write with AI"],
|
|
43
|
+
insTable: ["\u8868\u683C", "Table"],
|
|
44
|
+
insImage: ["\u56FE\u7247", "Image"],
|
|
45
|
+
insMath: ["\u516C\u5F0F", "Math"],
|
|
46
|
+
insAudio: ["\u97F3\u9891", "Audio"],
|
|
47
|
+
insFile: ["\u6587\u4EF6", "File"],
|
|
48
|
+
insHr: ["\u5206\u5272\u7EBF", "Divider"],
|
|
49
|
+
// —— 通用 ——
|
|
50
|
+
alignLeft: ["\u5DE6\u5BF9\u9F50", "Align left"],
|
|
51
|
+
alignCenterShort: ["\u5C45\u4E2D", "Center"],
|
|
52
|
+
alignRight: ["\u53F3\u5BF9\u9F50", "Align right"],
|
|
53
|
+
cancel: ["\u53D6\u6D88", "Cancel"],
|
|
54
|
+
ok: ["\u786E\u5B9A", "OK"],
|
|
55
|
+
confirm: ["\u786E\u8BA4", "Confirm"],
|
|
56
|
+
save: ["\u4FDD\u5B58", "Save"],
|
|
57
|
+
delete: ["\u5220\u9664", "Delete"],
|
|
58
|
+
send: ["\u53D1\u9001", "Send"],
|
|
59
|
+
apply: ["\u5E94\u7528", "Apply"],
|
|
60
|
+
insert: ["\u63D2\u5165", "Insert"],
|
|
61
|
+
comment: ["\u8BC4\u8BBA", "Comment"],
|
|
62
|
+
me: ["\u6211", "Me"],
|
|
63
|
+
// —— 浮动工具条 ——
|
|
64
|
+
bbHeading1: ["\u4E00\u7EA7\u6807\u9898", "Heading 1"],
|
|
65
|
+
bbHeading2: ["\u4E8C\u7EA7\u6807\u9898", "Heading 2"],
|
|
66
|
+
bbHeading3: ["\u4E09\u7EA7\u6807\u9898", "Heading 3"],
|
|
67
|
+
bbTask: ["\u4EFB\u52A1", "Task"],
|
|
68
|
+
bbBold: ["\u7C97\u4F53", "Bold"],
|
|
69
|
+
bbStrike: ["\u5220\u9664\u7EBF", "Strikethrough"],
|
|
70
|
+
bbItalic: ["\u659C\u4F53", "Italic"],
|
|
71
|
+
bbUnderline: ["\u4E0B\u5212\u7EBF", "Underline"],
|
|
72
|
+
bbHighlight: ["\u9AD8\u4EAE", "Highlight"],
|
|
73
|
+
mdText: ["\u6587\u672C", "text"],
|
|
74
|
+
mdSpace: ["\u7A7A\u683C", "Space"],
|
|
75
|
+
bbTextAndHeading: ["\u6B63\u6587\u4E0E\u6807\u9898", "Text and headings"],
|
|
76
|
+
bbAlignIndent: ["\u5BF9\u9F50\u4E0E\u7F29\u8FDB", "Align and indent"],
|
|
77
|
+
bbAlignCenter: ["\u5C45\u4E2D\u5BF9\u9F50", "Align center"],
|
|
78
|
+
bbIndentMore: ["\u589E\u52A0\u7F29\u8FDB", "Increase indent"],
|
|
79
|
+
bbIndentLess: ["\u51CF\u5C11\u7F29\u8FDB", "Decrease indent"],
|
|
80
|
+
bbLink: ["\u94FE\u63A5", "Link"],
|
|
81
|
+
bbInlineCode: ["\u884C\u5185\u4EE3\u7801", "Inline code"],
|
|
82
|
+
bbClear: ["\u6E05\u9664\u683C\u5F0F", "Clear formatting"],
|
|
83
|
+
bbColorHighlight: ["\u6587\u5B57\u989C\u8272\u4E0E\u9AD8\u4EAE", "Text color and highlight"],
|
|
84
|
+
bbFontColor: ["\u5B57\u4F53\u989C\u8272", "Text color"],
|
|
85
|
+
bbBgColor: ["\u80CC\u666F\u989C\u8272", "Highlight color"],
|
|
86
|
+
bbReset: ["\u6062\u590D\u9ED8\u8BA4", "Reset"],
|
|
87
|
+
bbAiContinue: ["AI \u7EED\u5199", "Continue with AI"],
|
|
88
|
+
bbContinue: ["\u7EED\u5199", "Continue"],
|
|
89
|
+
bbAiRewrite: ["AI \u6539\u5199", "Rewrite with AI"],
|
|
90
|
+
bbRewrite: ["\u6539\u5199", "Rewrite"],
|
|
91
|
+
// —— 颜色名 ——
|
|
92
|
+
colDefault: ["\u9ED8\u8BA4", "Default"],
|
|
93
|
+
colNone: ["\u65E0", "None"],
|
|
94
|
+
colGray: ["\u7070", "Gray"],
|
|
95
|
+
colDarkGray: ["\u6DF1\u7070", "Dark gray"],
|
|
96
|
+
colRed: ["\u7EA2", "Red"],
|
|
97
|
+
colOrange: ["\u6A59", "Orange"],
|
|
98
|
+
colYellow: ["\u9EC4", "Yellow"],
|
|
99
|
+
colGreen: ["\u7EFF", "Green"],
|
|
100
|
+
colBlue: ["\u84DD", "Blue"],
|
|
101
|
+
colPurple: ["\u7D2B", "Purple"],
|
|
102
|
+
colLightGray: ["\u6D45\u7070", "Light gray"],
|
|
103
|
+
colLightRed: ["\u6D45\u7EA2", "Light red"],
|
|
104
|
+
colLightOrange: ["\u6D45\u6A59", "Light orange"],
|
|
105
|
+
colLightYellow: ["\u6D45\u9EC4", "Light yellow"],
|
|
106
|
+
colLightGreen: ["\u6D45\u7EFF", "Light green"],
|
|
107
|
+
colLightBlue: ["\u6D45\u84DD", "Light blue"],
|
|
108
|
+
colLightPurple: ["\u6D45\u7D2B", "Light purple"],
|
|
109
|
+
// —— 悬停手柄 ——
|
|
110
|
+
dhMove: ["\u62D6\u62FD\u79FB\u52A8 \xB7 \u60AC\u505C\u683C\u5F0F", "Drag to move \xB7 hover for options"],
|
|
111
|
+
dhInsert: ["\u63D2\u5165\u5185\u5BB9", "Insert"],
|
|
112
|
+
dhExpand: ["\u5C55\u5F00", "Expand"],
|
|
113
|
+
dhCollapse: ["\u6298\u53E0", "Collapse"],
|
|
114
|
+
// —— 表格 ——
|
|
115
|
+
tcGrip: ["\u9009\u4E2D/\u79FB\u52A8\u8868\u683C", "Select or move table"],
|
|
116
|
+
tcInsertCol: ["\u63D2\u5165\u5217", "Insert column"],
|
|
117
|
+
tcInsertRow: ["\u63D2\u5165\u884C", "Insert row"],
|
|
118
|
+
tcColLeft: ["\u5DE6\u4FA7\u63D2\u5165\u5217", "Insert column left"],
|
|
119
|
+
tcColRight: ["\u53F3\u4FA7\u63D2\u5165\u5217", "Insert column right"],
|
|
120
|
+
tcDelCol: ["\u5220\u9664\u5217", "Delete column"],
|
|
121
|
+
tcHeaderCol: ["\u5207\u6362\u8868\u5934\u5217", "Header column"],
|
|
122
|
+
tcRowAbove: ["\u4E0A\u65B9\u63D2\u5165\u884C", "Insert row above"],
|
|
123
|
+
tcRowBelow: ["\u4E0B\u65B9\u63D2\u5165\u884C", "Insert row below"],
|
|
124
|
+
tcDelRow: ["\u5220\u9664\u884C", "Delete row"],
|
|
125
|
+
tcMerge: ["\u5408\u5E76\u5355\u5143\u683C", "Merge cells"],
|
|
126
|
+
tcSplit: ["\u62C6\u5206\u5355\u5143\u683C", "Split cell"],
|
|
127
|
+
tcBg: ["\u80CC\u666F\u8272", "Cell color"],
|
|
128
|
+
tcClearBg: ["\u6E05\u9664\u80CC\u666F", "Clear color"],
|
|
129
|
+
tcBorder: ["\u8FB9\u6846\u8272", "Border color"],
|
|
130
|
+
tcClearBorder: ["\u6E05\u9664\u8FB9\u6846", "Clear border"],
|
|
131
|
+
tcDelTable: ["\u5220\u9664\u8868\u683C", "Delete table"],
|
|
132
|
+
tcFreezeRow: ["\u51BB\u7ED3\u9996\u884C", "Freeze top row"],
|
|
133
|
+
tcUnfreezeRow: ["\u53D6\u6D88\u51BB\u7ED3\u9996\u884C", "Unfreeze top row"],
|
|
134
|
+
tcFreezeCol: ["\u51BB\u7ED3\u9996\u5217", "Freeze first column"],
|
|
135
|
+
tcUnfreezeCol: ["\u53D6\u6D88\u51BB\u7ED3\u9996\u5217", "Unfreeze first column"],
|
|
136
|
+
tcCellBgAria: ["\u5355\u5143\u683C\u80CC\u666F\u8272", "Cell color"],
|
|
137
|
+
tcCellBorderAria: ["\u5355\u5143\u683C\u8FB9\u6846\u8272", "Cell border color"],
|
|
138
|
+
// —— 图片 ——
|
|
139
|
+
imgPreview: ["\u9884\u89C8", "Preview"],
|
|
140
|
+
imgPreviewAria: ["\u9884\u89C8\u56FE\u7247", "Preview image"],
|
|
141
|
+
imgCaption: ["\u56FE\u6CE8", "Caption"],
|
|
142
|
+
imgCaptionPh: ["\u56FE\u6CE8\u2026", "Add a caption\u2026"],
|
|
143
|
+
// —— 编辑器内的弹层 ——
|
|
144
|
+
mathPh: ["E=mc^2 \u6216 \\frac{a}{b}", "E=mc^2 or \\frac{a}{b}"],
|
|
145
|
+
mathInsertAria: ["\u63D2\u5165\u516C\u5F0F", "Insert math"],
|
|
146
|
+
mathEditAria: ["\u7F16\u8F91\u516C\u5F0F", "Edit math"],
|
|
147
|
+
mathEmpty: ["\u516C\u5F0F\u4E0D\u80FD\u4E3A\u7A7A", "Enter some math first"],
|
|
148
|
+
mathClickEdit: ["\u70B9\u51FB\u7F16\u8F91\u516C\u5F0F", "Click to edit math"],
|
|
149
|
+
embed: ["\u5D4C\u5165", "Embed"],
|
|
150
|
+
embedYt: ["\u5D4C\u5165 YouTube", "Embed YouTube"],
|
|
151
|
+
embedTw: ["\u5D4C\u5165 Twitch", "Embed Twitch"],
|
|
152
|
+
embedNoLink: ["\u8BF7\u8F93\u5165\u94FE\u63A5", "Enter a link"],
|
|
153
|
+
embedBadYt: ["\u65E0\u6CD5\u8BC6\u522B YouTube \u94FE\u63A5", "That isn\u2019t a valid YouTube link"],
|
|
154
|
+
embedBadTw: ["\u65E0\u6CD5\u8BC6\u522B Twitch \u9891\u9053\u94FE\u63A5", "That isn\u2019t a valid Twitch channel link"],
|
|
155
|
+
// —— 提示框 ——
|
|
156
|
+
promptAria: ["\u8F93\u5165", "Input"],
|
|
157
|
+
promptHint: ["\u2318\u21B5 \u786E\u8BA4", "\u2318\u21B5 to confirm"],
|
|
158
|
+
linkPh: ["\u7C98\u8D34\u6216\u8F93\u5165\u94FE\u63A5", "Paste or type a link"],
|
|
159
|
+
linkAria: ["\u6DFB\u52A0\u94FE\u63A5", "Add link"],
|
|
160
|
+
// —— 目录 ——
|
|
161
|
+
tocAria: ["\u76EE\u5F55", "Outline"],
|
|
162
|
+
tocPageAria: ["\u672C\u9875\u76EE\u5F55", "On this page"],
|
|
163
|
+
tocUntitled: ["\u672A\u547D\u540D\u6807\u9898", "Untitled heading"],
|
|
164
|
+
// —— 代码块 ——
|
|
165
|
+
plainText: ["\u7EAF\u6587\u672C", "Plain text"],
|
|
166
|
+
copyCode: ["\u590D\u5236\u4EE3\u7801", "Copy code"],
|
|
167
|
+
// —— 版本 ——
|
|
168
|
+
verTitle: ["\u7248\u672C", "Versions"],
|
|
169
|
+
verEmpty: ["\u5C1A\u65E0\u5FEB\u7167 \xB7 \u2318\u21E7S", "No versions yet \xB7 \u2318\u21E7S"],
|
|
170
|
+
// —— 提及 / 日期 ——
|
|
171
|
+
profStatus: ["\u72B6\u6001", "Status"],
|
|
172
|
+
profEmail: ["\u90AE\u7BB1", "Email"],
|
|
173
|
+
calWeek: ["\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u65E5", "Mo|Tu|We|Th|Fr|Sa|Su"],
|
|
174
|
+
calMonth: ["{y}\u5E74{m}\u6708", "{name} {y}"],
|
|
175
|
+
calNow: ["\u73B0\u5728", "Now"],
|
|
176
|
+
// —— 查找替换 ——
|
|
177
|
+
searchFind: ["\u67E5\u627E", "Find"],
|
|
178
|
+
searchReplaceWith: ["\u66FF\u6362\u4E3A", "Replace with"],
|
|
179
|
+
searchPrev: ["\u4E0A\u4E00\u4E2A", "Previous"],
|
|
180
|
+
searchNext: ["\u4E0B\u4E00\u4E2A", "Next"],
|
|
181
|
+
searchReplace: ["\u66FF\u6362", "Replace"],
|
|
182
|
+
searchAll: ["\u5168\u90E8", "Replace all"],
|
|
183
|
+
close: ["\u5173\u95ED", "Close"],
|
|
184
|
+
// —— 协作 ——
|
|
185
|
+
collabUser: ["\u7528\u6237 {id}", "User {id}"],
|
|
186
|
+
collabUserCaret: ["\u7528\u6237{id}", "User {id}"],
|
|
187
|
+
collabMore: ["\u8FD8\u6709 {n} \u4EBA", "{n} more"],
|
|
188
|
+
collabConnecting: ["{name} \xB7 \u8FDE\u63A5\u4E2D\u2026", "{name} \xB7 Connecting\u2026"],
|
|
189
|
+
collabClosed: ["{name} \xB7 \u5DF2\u65AD\u5F00 \xB7 \u91CD\u8FDE\u4E2D", "{name} \xB7 Offline \xB7 Reconnecting\u2026"],
|
|
190
|
+
collabResyncing: ["{name} \xB7 \u540C\u6B65\u4E2D\u2026", "{name} \xB7 Syncing\u2026"],
|
|
191
|
+
collabConflict: ["{name} \xB7 \u540C\u6B65\u51B2\u7A81 \xB7 \u672C\u5730\u4FEE\u6539\u5DF2\u4FDD\u7559", "{name} \xB7 Sync conflict \xB7 Your changes are kept"],
|
|
192
|
+
collabAuthError: ["{name} \xB7 \u9274\u6743\u5931\u8D25", "{name} \xB7 Sign-in failed"],
|
|
193
|
+
// —— 修订 ——
|
|
194
|
+
sgTrack: ["\u8DDF\u8E2A\u4FEE\u8BA2", "Track changes"],
|
|
195
|
+
sgMarkIns: ["\u6807\u63D2\u5165", "Mark as insertion"],
|
|
196
|
+
sgMarkDel: ["\u6807\u5220\u9664", "Mark as deletion"],
|
|
197
|
+
sgCount: ["{n} \u6761", "{n} changes"],
|
|
198
|
+
sgCount1: ["{n} \u6761", "1 change"],
|
|
199
|
+
sgAccept: ["\u63A5\u53D7", "Accept"],
|
|
200
|
+
sgReject: ["\u62D2\u7EDD", "Reject"],
|
|
201
|
+
sgInsTitle: ["\u5EFA\u8BAE\u63D2\u5165", "Suggested insertion"],
|
|
202
|
+
sgDelTitle: ["\u5EFA\u8BAE\u5220\u9664", "Suggested deletion"],
|
|
203
|
+
// —— 评论栏 ——
|
|
204
|
+
cmtTitle: ["\u8BC4\u8BBA ({n})", "Comments ({n})"],
|
|
205
|
+
cmtOnlyOpen: ["\u53EA\u770B\u672A\u89E3\u51B3", "Show unresolved only"],
|
|
206
|
+
cmtShowResolved: ["\u663E\u793A\u5DF2\u89E3\u51B3", "Show resolved"],
|
|
207
|
+
cmtFilterAll: ["\u5168", "All"],
|
|
208
|
+
cmtFilterOpen: ["\u5F00", "Unresolved"],
|
|
209
|
+
cmtCollapse: ["\u6536\u8D77", "Collapse"],
|
|
210
|
+
cmtAddPh: ["\u6DFB\u52A0\u8BC4\u8BBA\u2026", "Add a comment\u2026"],
|
|
211
|
+
cmtNone: ["\u6682\u65E0\u8BC4\u8BBA", "No comments"],
|
|
212
|
+
cmtNoneOpen: ["\u6682\u65E0\u672A\u89E3\u51B3\u8BC4\u8BBA", "No unresolved comments"],
|
|
213
|
+
cmtResolved: ["\u5DF2\u89E3\u51B3", "Resolved"],
|
|
214
|
+
cmtReopen: ["\u91CD\u65B0\u6253\u5F00", "Reopen"],
|
|
215
|
+
cmtResolve: ["\u89E3\u51B3", "Resolve"],
|
|
216
|
+
cmtReplyPh: ["\u56DE\u590D\u2026", "Reply\u2026"],
|
|
217
|
+
cmtReplies: ["{n} \u6761\u56DE\u590D", "{n} more replies"],
|
|
218
|
+
cmtReply1: ["{n} \u6761\u56DE\u590D", "{n} more reply"],
|
|
219
|
+
// —— 文档内 AI 块 ——
|
|
220
|
+
aiGenerating: ["\u751F\u6210\u4E2D", "Generating"],
|
|
221
|
+
aiPending: ["\u5F85\u786E\u8BA4", "Review"],
|
|
222
|
+
aiFailed: ["\u5931\u8D25", "Failed"],
|
|
223
|
+
aiStop: ["\u505C\u6B62", "Stop"],
|
|
224
|
+
aiStopTitle: ["\u505C\u6B62\u751F\u6210", "Stop generating"],
|
|
225
|
+
aiOriginal: ["\u539F\u6587", "Original"],
|
|
226
|
+
aiPhRewrite: ["\u63CF\u8FF0\u600E\u4E48\u6539\u2026\uFF08\u56DE\u8F66\u751F\u6210\uFF09", "Describe the change\u2026 (Enter to generate)"],
|
|
227
|
+
aiPhWrite: ["\u8F93\u5165\u6307\u4EE4\uFF0C\u56DE\u8F66\u751F\u6210\u2026", "Tell AI what to write\u2026 (Enter to generate)"],
|
|
228
|
+
aiGenerate: ["\u751F\u6210", "Generate"],
|
|
229
|
+
aiNewline: ["\u6362\u884C", "new line"],
|
|
230
|
+
aiStart: ["\u5F00\u59CB\u751F\u6210", "Start generating"],
|
|
231
|
+
aiWritten: ["\u6B63\u6587\u5DF2\u5199\u5165 {n} \u5B57\u2026", "{n} characters written\u2026"],
|
|
232
|
+
aiWriting: ["\u6B63\u5728\u5199\u5165\u6B63\u6587\u2026", "Writing\u2026"],
|
|
233
|
+
aiReview: ["{n} \u5B57\u5DF2\u5199\u5165 \xB7 \u786E\u8BA4\u63D0\u4EA4 / \u4E22\u5F03\u64A4\u56DE", "{n} characters written \xB7 Accept or undo"],
|
|
234
|
+
aiReviewNoCount: ["\u4E0B\u65B9\u6DE1\u5316\u6587\u5B57\u5DF2\u5728\u6587\u6863\u4E2D", "The faded text below is already in your note"],
|
|
235
|
+
aiRetry: ["\u91CD\u8BD5", "Retry"],
|
|
236
|
+
aiRetryTitle: ["\u64A4\u56DE\u5E76\u91CD\u65B0\u751F\u6210", "Undo and try again"],
|
|
237
|
+
aiUndo: ["\u64A4\u56DE", "Undo"],
|
|
238
|
+
aiUndoTitle: ["\u6574\u7B14\u64A4\u56DE(undo)", "Undo everything AI wrote"],
|
|
239
|
+
aiAccept: ["\u786E\u8BA4", "Accept"],
|
|
240
|
+
aiAcceptTitle: ["\u63D0\u4EA4\u4E8B\u52A1", "Keep what AI wrote"],
|
|
241
|
+
aiFailHint: ["\u751F\u6210\u5931\u8D25", "Something went wrong"],
|
|
242
|
+
aiRegenTitle: ["\u91CD\u65B0\u751F\u6210", "Try again"],
|
|
243
|
+
aiDiscard: ["\u4E22\u5F03", "Discard"],
|
|
244
|
+
aiErrNoCursor: ["\u8BF7\u5148\u628A\u5149\u6807\u653E\u5728\u4E00\u6BB5\u6587\u5B57\u91CC", "Click in a paragraph first"],
|
|
245
|
+
aiErrNoText: ["\u5F53\u524D\u6BB5\u6CA1\u6709\u53EF\u6539\u5199\u7684\u6587\u5B57", "This paragraph has no text to rewrite"],
|
|
246
|
+
aiErrNoConfig: ["AI \u672A\u914D\u7F6E:\u8BF7\u8BBE\u7F6E ai.provider \u6216 ai.endpoint", "AI isn\u2019t set up: set ai.provider or ai.endpoint"],
|
|
247
|
+
// —— 渲染杂项 ——
|
|
248
|
+
fnBack: ["\u56DE\u5230\u5F15\u7528\u5904", "Back to reference"],
|
|
249
|
+
fnMissing: ["\u6CA1\u6709\u8FD9\u6761\u811A\u6CE8\u7684\u5B9A\u4E49", "This footnote has no text"],
|
|
250
|
+
fnEmpty: ["(\u7A7A\u811A\u6CE8)", "(empty footnote)"],
|
|
251
|
+
taskDone: ["\u5DF2\u5B8C\u6210", "Done"],
|
|
252
|
+
taskTodo: ["\u672A\u5B8C\u6210", "Not done"],
|
|
253
|
+
diagramEdit: ["\u70B9\u51FB\u7F16\u8F91\u6E90\u7801", "Click to edit source"],
|
|
254
|
+
diagramError: ["\u56FE\u753B\u4E0D\u51FA\u6765:{msg}", "Couldn\u2019t draw this diagram: {msg}"],
|
|
255
|
+
frontMatter: ["\u5143\u6570\u636E", "Metadata"]
|
|
256
|
+
};
|
|
257
|
+
function t(key, params) {
|
|
258
|
+
const pair = MESSAGES[key];
|
|
259
|
+
const s = getLocale() === "en" ? pair[1] : pair[0];
|
|
260
|
+
if (!params)
|
|
261
|
+
return s;
|
|
262
|
+
return s.replace(/\{(\w+)\}/g, (m, k) => k in params ? String(params[k]) : m);
|
|
263
|
+
}
|
|
15
264
|
|
|
16
265
|
// src/view/selection.ts
|
|
17
266
|
function rootEl(root) {
|
|
18
267
|
return root.querySelector(".markloom-doc") ?? root;
|
|
19
268
|
}
|
|
20
|
-
function
|
|
21
|
-
const n =
|
|
22
|
-
if (n === 0)
|
|
23
|
-
return null;
|
|
24
|
-
const first = doc.children[0];
|
|
25
|
-
const last = doc.children[n - 1];
|
|
26
|
-
if (!isElement(first) || !isElement(last))
|
|
269
|
+
function nodeExtent(doc, nodePath = []) {
|
|
270
|
+
const n = nodePath.length === 0 ? doc : nodeAt(doc, nodePath);
|
|
271
|
+
if (!isElement(n) || n.children.length === 0)
|
|
27
272
|
return null;
|
|
28
273
|
return {
|
|
29
|
-
anchor: { path: normalizeToLeaf(doc, [
|
|
30
|
-
head: { path: normalizeToLeaf(doc, [
|
|
274
|
+
anchor: { path: normalizeToLeaf(doc, [...nodePath, ...firstLeafPath(n), 0]) },
|
|
275
|
+
head: { path: normalizeToLeaf(doc, [...nodePath, ...lastLeafEnd(n)]) }
|
|
31
276
|
};
|
|
32
277
|
}
|
|
278
|
+
function docExtent(doc) {
|
|
279
|
+
return nodeExtent(doc, []);
|
|
280
|
+
}
|
|
281
|
+
var SELECT_UNIT_TYPES = ["code", "quote"];
|
|
282
|
+
function isSelectUnitType(type) {
|
|
283
|
+
return SELECT_UNIT_TYPES.includes(type);
|
|
284
|
+
}
|
|
285
|
+
function isSelectUnit(n) {
|
|
286
|
+
return isElement(n) && isSelectUnitType(n.type);
|
|
287
|
+
}
|
|
288
|
+
function isProgressiveSelectUnit(n) {
|
|
289
|
+
if (isSelectUnit(n))
|
|
290
|
+
return true;
|
|
291
|
+
return isElement(n) && (n.type === "table_cell" || n.type === "table");
|
|
292
|
+
}
|
|
293
|
+
function progressiveUnitPaths(doc, caretPath) {
|
|
294
|
+
const out = [];
|
|
295
|
+
for (let depth = caretPath.length - 2; depth >= 1; depth--) {
|
|
296
|
+
const p = caretPath.slice(0, depth);
|
|
297
|
+
if (isProgressiveSelectUnit(nodeAt(doc, p)))
|
|
298
|
+
out.push(p);
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
302
|
+
function selectUnitPath(doc, caretPath) {
|
|
303
|
+
return progressiveUnitPaths(doc, caretPath)[0] ?? null;
|
|
304
|
+
}
|
|
33
305
|
function selectionCovers(sel, extent) {
|
|
34
306
|
return pathEq(sel.anchor.path, extent.anchor.path) && pathEq(sel.head.path, extent.head.path) || pathEq(sel.anchor.path, extent.head.path) && pathEq(sel.head.path, extent.anchor.path);
|
|
35
307
|
}
|
|
308
|
+
function pathUnderUnit(path, unitPath) {
|
|
309
|
+
return unitPath.every((s, i) => path[i] === s);
|
|
310
|
+
}
|
|
311
|
+
function selectionInUnit(sel, unitPath) {
|
|
312
|
+
return pathUnderUnit(sel.anchor.path, unitPath) && pathUnderUnit(sel.head.path, unitPath);
|
|
313
|
+
}
|
|
314
|
+
function expandSelectAll(doc, sel) {
|
|
315
|
+
const whole = docExtent(doc);
|
|
316
|
+
if (!sel)
|
|
317
|
+
return whole;
|
|
318
|
+
const chain = progressiveUnitPaths(doc, sel.head.path);
|
|
319
|
+
for (const unit of chain) {
|
|
320
|
+
if (!selectionInUnit(sel, unit))
|
|
321
|
+
continue;
|
|
322
|
+
const extent = nodeExtent(doc, unit);
|
|
323
|
+
if (extent && !selectionCovers(sel, extent))
|
|
324
|
+
return extent;
|
|
325
|
+
}
|
|
326
|
+
return whole;
|
|
327
|
+
}
|
|
36
328
|
function pathEq(a, b) {
|
|
37
329
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
38
330
|
}
|
|
@@ -44,7 +336,7 @@ function pointToDom(root, doc, pos) {
|
|
|
44
336
|
for (let i = 0; i < path.length - 1; i++) {
|
|
45
337
|
if (!domNode)
|
|
46
338
|
return null;
|
|
47
|
-
const child =
|
|
339
|
+
const child = childAt(domNode, path[i]);
|
|
48
340
|
if (!child)
|
|
49
341
|
return null;
|
|
50
342
|
domNode = child;
|
|
@@ -61,7 +353,7 @@ function domToPoint(root, doc, container, domOffset) {
|
|
|
61
353
|
const structural = node instanceof HTMLElement && node.nodeType !== 3 && !closestLeaf(node);
|
|
62
354
|
if (structural) {
|
|
63
355
|
const kids = elementChildren(node);
|
|
64
|
-
const at =
|
|
356
|
+
const at = childAt(node, domOffset);
|
|
65
357
|
if (at) {
|
|
66
358
|
node = deepestText(at) ?? at;
|
|
67
359
|
charOffset = 0;
|
|
@@ -86,7 +378,7 @@ function domToPoint(root, doc, container, domOffset) {
|
|
|
86
378
|
if (node instanceof HTMLElement && (node.dataset.blockId !== void 0 || node.dataset.leaf !== void 0)) {
|
|
87
379
|
const sp = structuralParent(node);
|
|
88
380
|
if (sp)
|
|
89
|
-
segs.unshift(
|
|
381
|
+
segs.unshift(childIndex(sp, node));
|
|
90
382
|
}
|
|
91
383
|
node = parent;
|
|
92
384
|
}
|
|
@@ -153,18 +445,52 @@ var TRANSPARENT = /* @__PURE__ */ new Set(["TBODY", "TR", "THEAD", "TFOOT", "COL
|
|
|
153
445
|
function isTransparent(el) {
|
|
154
446
|
return TRANSPARENT.has(el.tagName) || el.dataset.pass !== void 0;
|
|
155
447
|
}
|
|
156
|
-
|
|
157
|
-
|
|
448
|
+
var BIG = 256;
|
|
449
|
+
var structureEpoch = 0;
|
|
450
|
+
var childCache = /* @__PURE__ */ new WeakMap();
|
|
451
|
+
function invalidateStructure(keep) {
|
|
452
|
+
const saved = keep ? childCache.get(keep) : void 0;
|
|
453
|
+
structureEpoch++;
|
|
454
|
+
if (keep && saved && keep.children.length === saved.n)
|
|
455
|
+
childCache.set(keep, { ...saved, epoch: structureEpoch });
|
|
456
|
+
}
|
|
457
|
+
function scanChildren(el, out) {
|
|
158
458
|
for (const c of el.children) {
|
|
159
459
|
if (!(c instanceof HTMLElement))
|
|
160
460
|
continue;
|
|
161
|
-
if (c.
|
|
461
|
+
if (c.hasAttribute("data-block-id") || c.hasAttribute("data-leaf"))
|
|
162
462
|
out.push(c);
|
|
163
463
|
else if (isTransparent(c))
|
|
164
|
-
|
|
464
|
+
scanChildren(c, out);
|
|
165
465
|
}
|
|
466
|
+
}
|
|
467
|
+
function scanFresh(el) {
|
|
468
|
+
const out = [];
|
|
469
|
+
scanChildren(el, out);
|
|
470
|
+
const n = el.children.length;
|
|
471
|
+
if (n >= BIG)
|
|
472
|
+
childCache.set(el, { epoch: structureEpoch, n, kids: out });
|
|
166
473
|
return out;
|
|
167
474
|
}
|
|
475
|
+
function elementChildren(el) {
|
|
476
|
+
const n = el.children.length;
|
|
477
|
+
if (n >= BIG) {
|
|
478
|
+
const hit = childCache.get(el);
|
|
479
|
+
if (hit && hit.epoch === structureEpoch && hit.n === n)
|
|
480
|
+
return hit.kids;
|
|
481
|
+
}
|
|
482
|
+
return scanFresh(el);
|
|
483
|
+
}
|
|
484
|
+
function childAt(el, i) {
|
|
485
|
+
const c = elementChildren(el)[i];
|
|
486
|
+
if (c && !el.contains(c))
|
|
487
|
+
return scanFresh(el)[i];
|
|
488
|
+
return c;
|
|
489
|
+
}
|
|
490
|
+
function childIndex(el, node) {
|
|
491
|
+
const i = elementChildren(el).indexOf(node);
|
|
492
|
+
return i >= 0 ? i : scanFresh(el).indexOf(node);
|
|
493
|
+
}
|
|
168
494
|
function structuralParent(node) {
|
|
169
495
|
let p = node.parentElement;
|
|
170
496
|
while (p && isTransparent(p))
|
|
@@ -212,9 +538,9 @@ function zwspFreeLen(s) {
|
|
|
212
538
|
}
|
|
213
539
|
function offsetWithinLeaf(leaf, target, domOffset) {
|
|
214
540
|
let acc = 0;
|
|
215
|
-
for (const
|
|
216
|
-
const s =
|
|
217
|
-
if (
|
|
541
|
+
for (const t2 of leafTextNodes(leaf)) {
|
|
542
|
+
const s = t2.textContent ?? "";
|
|
543
|
+
if (t2 === target)
|
|
218
544
|
return acc + zwspFreeLen(s.slice(0, domOffset));
|
|
219
545
|
acc += zwspFreeLen(s);
|
|
220
546
|
}
|
|
@@ -223,17 +549,17 @@ function offsetWithinLeaf(leaf, target, domOffset) {
|
|
|
223
549
|
function locateInLeaf(leaf, charOff) {
|
|
224
550
|
const texts = leafTextNodes(leaf);
|
|
225
551
|
if (texts.length === 0) {
|
|
226
|
-
const
|
|
227
|
-
return { node:
|
|
552
|
+
const t2 = deepestText(leaf);
|
|
553
|
+
return { node: t2 ?? leaf, offset: 0 };
|
|
228
554
|
}
|
|
229
555
|
let off = Math.max(0, charOff);
|
|
230
556
|
let prev = null;
|
|
231
|
-
for (const
|
|
232
|
-
const s =
|
|
557
|
+
for (const t2 of texts) {
|
|
558
|
+
const s = t2.textContent ?? "";
|
|
233
559
|
const len = zwspFreeLen(s);
|
|
234
560
|
if (s === "\n") {
|
|
235
561
|
if (off === 0)
|
|
236
|
-
return prev ?? { node:
|
|
562
|
+
return prev ?? { node: t2, offset: 1 };
|
|
237
563
|
off -= len;
|
|
238
564
|
continue;
|
|
239
565
|
}
|
|
@@ -245,9 +571,9 @@ function locateInLeaf(leaf, charOff) {
|
|
|
245
571
|
seen++;
|
|
246
572
|
if (len === 0)
|
|
247
573
|
dom = s.length;
|
|
248
|
-
return { node:
|
|
574
|
+
return { node: t2, offset: dom };
|
|
249
575
|
}
|
|
250
|
-
prev = { node:
|
|
576
|
+
prev = { node: t2, offset: s.length };
|
|
251
577
|
off -= len;
|
|
252
578
|
}
|
|
253
579
|
return prev ?? { node: texts[texts.length - 1], offset: texts[texts.length - 1].textContent?.length ?? 0 };
|
|
@@ -279,7 +605,7 @@ function emptyLike(block) {
|
|
|
279
605
|
return { type: "heading", id: block.id, attrs: { ...block.attrs }, children: [{ text: "" }] };
|
|
280
606
|
if (block.type === "code")
|
|
281
607
|
return { type: "code", id: block.id, attrs: { ...block.attrs }, children: [{ text: "" }] };
|
|
282
|
-
if (block.type === "quote"
|
|
608
|
+
if (block.type === "quote") {
|
|
283
609
|
return {
|
|
284
610
|
type: block.type,
|
|
285
611
|
id: block.id,
|
|
@@ -293,7 +619,7 @@ function streamTargetId(doc, blockId) {
|
|
|
293
619
|
const b = doc.children.find((c) => !isText(c) && c.id === blockId);
|
|
294
620
|
if (!b)
|
|
295
621
|
return blockId;
|
|
296
|
-
if (b.type === "quote"
|
|
622
|
+
if (b.type === "quote") {
|
|
297
623
|
const inner = b.children.find((c) => !isText(c) && c.type === "paragraph");
|
|
298
624
|
if (inner?.id)
|
|
299
625
|
return inner.id;
|
|
@@ -361,13 +687,13 @@ function precedingPlainText(doc, blockIdx) {
|
|
|
361
687
|
const b = doc.children[i];
|
|
362
688
|
if (isText(b) || !b.id)
|
|
363
689
|
continue;
|
|
364
|
-
if (b.type === "image" || b.type === "table" || b.type === "embed" || b.type === "raw" || b
|
|
690
|
+
if (b.type === "image" || b.type === "table" || b.type === "embed" || b.type === "raw" || isAiCompose(b))
|
|
365
691
|
continue;
|
|
366
692
|
if (b.attrs?.aiDraft)
|
|
367
693
|
continue;
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
370
|
-
parts.push(
|
|
694
|
+
const t2 = blockPlainText(doc, b.id);
|
|
695
|
+
if (t2.trim())
|
|
696
|
+
parts.push(t2);
|
|
371
697
|
}
|
|
372
698
|
return parts.join("\n\n");
|
|
373
699
|
}
|
|
@@ -448,7 +774,7 @@ var MarkloomAi = class {
|
|
|
448
774
|
return;
|
|
449
775
|
const bid = focusBlockId(ed);
|
|
450
776
|
if (!bid) {
|
|
451
|
-
this.opts.onError?.("
|
|
777
|
+
this.opts.onError?.(t("aiErrNoCursor"));
|
|
452
778
|
return;
|
|
453
779
|
}
|
|
454
780
|
const doc = ed.doc;
|
|
@@ -456,33 +782,31 @@ var MarkloomAi = class {
|
|
|
456
782
|
if (idx < 0)
|
|
457
783
|
return;
|
|
458
784
|
const cur = doc.children[idx];
|
|
459
|
-
if (cur
|
|
785
|
+
if (isAiCompose(cur))
|
|
460
786
|
return;
|
|
461
787
|
if (mode === "rewrite") {
|
|
462
788
|
if (!blockPlainText(doc, bid).trim()) {
|
|
463
|
-
this.opts.onError?.("
|
|
789
|
+
this.opts.onError?.(t("aiErrNoText"));
|
|
464
790
|
return;
|
|
465
791
|
}
|
|
466
792
|
const seed = blockPlainText(doc, bid);
|
|
467
793
|
const id2 = newAiId();
|
|
468
|
-
const promptId2 = newAiId();
|
|
469
794
|
ed.dispatch(
|
|
470
795
|
[{
|
|
471
796
|
kind: "replaceNode",
|
|
472
797
|
path: [idx],
|
|
473
798
|
node: {
|
|
474
|
-
type: "
|
|
799
|
+
type: "paragraph",
|
|
475
800
|
id: id2,
|
|
476
|
-
attrs: { status: "compose", mode: "rewrite", seed },
|
|
477
|
-
children: [{
|
|
801
|
+
attrs: { aiCompose: true, status: "compose", mode: "rewrite", seed },
|
|
802
|
+
children: [{ text: "" }]
|
|
478
803
|
}
|
|
479
804
|
}],
|
|
480
|
-
{ anchor: { path: [idx, 0, 0
|
|
805
|
+
{ anchor: { path: [idx, 0, 0] }, head: { path: [idx, 0, 0] } }
|
|
481
806
|
);
|
|
482
807
|
return;
|
|
483
808
|
}
|
|
484
809
|
const id = newAiId();
|
|
485
|
-
const promptId = newAiId();
|
|
486
810
|
ed.dispatch(
|
|
487
811
|
[{
|
|
488
812
|
kind: "spliceChildren",
|
|
@@ -490,13 +814,13 @@ var MarkloomAi = class {
|
|
|
490
814
|
at: idx + 1,
|
|
491
815
|
remove: 0,
|
|
492
816
|
insert: [{
|
|
493
|
-
type: "
|
|
817
|
+
type: "paragraph",
|
|
494
818
|
id,
|
|
495
|
-
attrs: { status: "compose", mode: "continue" },
|
|
496
|
-
children: [{
|
|
819
|
+
attrs: { aiCompose: true, status: "compose", mode: "continue" },
|
|
820
|
+
children: [{ text: "" }]
|
|
497
821
|
}]
|
|
498
822
|
}],
|
|
499
|
-
{ anchor: { path: [idx + 1, 0, 0
|
|
823
|
+
{ anchor: { path: [idx + 1, 0, 0] }, head: { path: [idx + 1, 0, 0] } }
|
|
500
824
|
);
|
|
501
825
|
}
|
|
502
826
|
openFromSlash(blockIdx, query) {
|
|
@@ -505,20 +829,19 @@ var MarkloomAi = class {
|
|
|
505
829
|
return;
|
|
506
830
|
const instruction = aiInstructionFromQuery(query);
|
|
507
831
|
const id = newAiId();
|
|
508
|
-
const promptId = newAiId();
|
|
509
832
|
const off = instruction.length;
|
|
510
833
|
ed.dispatch(
|
|
511
834
|
[{
|
|
512
835
|
kind: "replaceNode",
|
|
513
836
|
path: [blockIdx],
|
|
514
837
|
node: {
|
|
515
|
-
type: "
|
|
838
|
+
type: "paragraph",
|
|
516
839
|
id,
|
|
517
|
-
attrs: { status: "compose", mode: "continue" },
|
|
518
|
-
children: [{
|
|
840
|
+
attrs: { aiCompose: true, status: "compose", mode: "continue" },
|
|
841
|
+
children: [{ text: instruction }]
|
|
519
842
|
}
|
|
520
843
|
}],
|
|
521
|
-
{ anchor: { path: [blockIdx, 0,
|
|
844
|
+
{ anchor: { path: [blockIdx, 0, off] }, head: { path: [blockIdx, 0, off] } }
|
|
522
845
|
);
|
|
523
846
|
}
|
|
524
847
|
/**
|
|
@@ -609,10 +932,10 @@ var MarkloomAi = class {
|
|
|
609
932
|
docPreview: ctxBody.slice(0, 4e3),
|
|
610
933
|
signal: ac.signal
|
|
611
934
|
},
|
|
612
|
-
(
|
|
935
|
+
(t2) => {
|
|
613
936
|
if (this.streamingId !== blockId)
|
|
614
937
|
return;
|
|
615
|
-
this.pendingMd +=
|
|
938
|
+
this.pendingMd += t2;
|
|
616
939
|
if (!this.raf) {
|
|
617
940
|
this.raf = requestAnimationFrame(() => {
|
|
618
941
|
this.raf = 0;
|
|
@@ -775,7 +1098,7 @@ var MarkloomAi = class {
|
|
|
775
1098
|
if (!path)
|
|
776
1099
|
return null;
|
|
777
1100
|
const node = path.reduce((n, i) => n.children[i], ed.doc);
|
|
778
|
-
if (!node || isText(node) || node
|
|
1101
|
+
if (!node || isText(node) || !isAiCompose(node))
|
|
779
1102
|
return null;
|
|
780
1103
|
return { path, node };
|
|
781
1104
|
}
|
|
@@ -961,6 +1284,9 @@ function collectText2(n) {
|
|
|
961
1284
|
|
|
962
1285
|
// src/ai/stream.ts
|
|
963
1286
|
function defaultSystem(action) {
|
|
1287
|
+
if (getLocale() === "en") {
|
|
1288
|
+
return action === "rewrite" ? "You are a note-rewriting assistant. Rewrite the given text. Keep the meaning, make it clearer and smoother; no explanations, no heading prefix, no markdown code fences; output the rewritten plain text only (simple line breaks allowed). Reply in the language of the text." : "You are a note-continuation assistant. Continue naturally from the existing context. Same style, no repetition, no explanations, no heading prefix; output the continuation as plain text only (simple line breaks allowed). Reply in the language of the context.";
|
|
1289
|
+
}
|
|
964
1290
|
if (action === "rewrite") {
|
|
965
1291
|
return [
|
|
966
1292
|
"\u4F60\u662F\u7B14\u8BB0\u6539\u5199\u52A9\u624B\u3002\u6839\u636E\u7528\u6237\u7ED9\u51FA\u7684\u539F\u6587,\u8F93\u51FA\u6539\u5199\u540E\u7684\u6B63\u6587\u3002",
|
|
@@ -977,6 +1303,21 @@ function defaultSystem(action) {
|
|
|
977
1303
|
function userPrompt(action, context, docPreview) {
|
|
978
1304
|
const ctx = (context || "").slice(0, 8e3);
|
|
979
1305
|
const prev = (docPreview || "").slice(0, 4e3);
|
|
1306
|
+
if (getLocale() === "en") {
|
|
1307
|
+
if (action === "rewrite")
|
|
1308
|
+
return `Rewrite the following:
|
|
1309
|
+
|
|
1310
|
+
${ctx}`;
|
|
1311
|
+
return [
|
|
1312
|
+
prev && prev !== ctx ? `Document excerpt:
|
|
1313
|
+
${prev}
|
|
1314
|
+
|
|
1315
|
+
` : "",
|
|
1316
|
+
`Continue after this text:
|
|
1317
|
+
|
|
1318
|
+
${ctx}`
|
|
1319
|
+
].join("");
|
|
1320
|
+
}
|
|
980
1321
|
if (action === "rewrite")
|
|
981
1322
|
return `\u8BF7\u6539\u5199\u4EE5\u4E0B\u5185\u5BB9:
|
|
982
1323
|
|
|
@@ -1082,7 +1423,7 @@ function createAiStream(cfg) {
|
|
|
1082
1423
|
return;
|
|
1083
1424
|
}
|
|
1084
1425
|
if (!provider)
|
|
1085
|
-
throw new Error("
|
|
1426
|
+
throw new Error(t("aiErrNoConfig"));
|
|
1086
1427
|
const url = completionsUrl(provider.host);
|
|
1087
1428
|
const res = await fetch(url, {
|
|
1088
1429
|
method: "POST",
|
|
@@ -1109,13 +1450,26 @@ function createAiStream(cfg) {
|
|
|
1109
1450
|
}
|
|
1110
1451
|
|
|
1111
1452
|
export {
|
|
1453
|
+
setLocale,
|
|
1454
|
+
getLocale,
|
|
1455
|
+
MESSAGES,
|
|
1456
|
+
t,
|
|
1112
1457
|
rootEl,
|
|
1458
|
+
nodeExtent,
|
|
1113
1459
|
docExtent,
|
|
1460
|
+
SELECT_UNIT_TYPES,
|
|
1461
|
+
isSelectUnitType,
|
|
1462
|
+
isSelectUnit,
|
|
1463
|
+
isProgressiveSelectUnit,
|
|
1464
|
+
progressiveUnitPaths,
|
|
1465
|
+
selectUnitPath,
|
|
1114
1466
|
selectionCovers,
|
|
1467
|
+
expandSelectAll,
|
|
1115
1468
|
pointToDom,
|
|
1116
1469
|
domToPoint,
|
|
1117
1470
|
readSelection,
|
|
1118
1471
|
writeSelection,
|
|
1472
|
+
invalidateStructure,
|
|
1119
1473
|
elementChildren,
|
|
1120
1474
|
focusBlockId,
|
|
1121
1475
|
blockPlainText,
|