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
|
@@ -4,35 +4,327 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkOVHASRIDcjs = require('./chunk-OVHASRID.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
var _chunkTWD5T4YCcjs = require('./chunk-TWD5T4YC.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
var _chunkHXABDVLZcjs = require('./chunk-HXABDVLZ.cjs');
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkPCSVBPORcjs = require('./chunk-PCSVBPOR.cjs');
|
|
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 _nullishCoalesce(root.querySelector(".markloom-doc"), () => ( root));
|
|
19
268
|
}
|
|
20
|
-
function
|
|
21
|
-
const n = doc.
|
|
22
|
-
if (n === 0)
|
|
23
|
-
return null;
|
|
24
|
-
const first = doc.children[0];
|
|
25
|
-
const last = doc.children[n - 1];
|
|
26
|
-
if (!_chunkZKQSQSSMcjs.isElement.call(void 0, first) || !_chunkZKQSQSSMcjs.isElement.call(void 0, last))
|
|
269
|
+
function nodeExtent(doc, nodePath = []) {
|
|
270
|
+
const n = nodePath.length === 0 ? doc : _chunkHXABDVLZcjs.nodeAt.call(void 0, doc, nodePath);
|
|
271
|
+
if (!_chunkPCSVBPORcjs.isElement.call(void 0, n) || n.children.length === 0)
|
|
27
272
|
return null;
|
|
28
273
|
return {
|
|
29
|
-
anchor: { path:
|
|
30
|
-
head: { path:
|
|
274
|
+
anchor: { path: _chunkHXABDVLZcjs.normalizeToLeaf.call(void 0, doc, [...nodePath, ..._chunkHXABDVLZcjs.firstLeafPath.call(void 0, n), 0]) },
|
|
275
|
+
head: { path: _chunkHXABDVLZcjs.normalizeToLeaf.call(void 0, doc, [...nodePath, ..._chunkHXABDVLZcjs.lastLeafEnd.call(void 0, 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 _chunkPCSVBPORcjs.isElement.call(void 0, n) && isSelectUnitType(n.type);
|
|
287
|
+
}
|
|
288
|
+
function isProgressiveSelectUnit(n) {
|
|
289
|
+
if (isSelectUnit(n))
|
|
290
|
+
return true;
|
|
291
|
+
return _chunkPCSVBPORcjs.isElement.call(void 0, 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(_chunkHXABDVLZcjs.nodeAt.call(void 0, doc, p)))
|
|
298
|
+
out.push(p);
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
302
|
+
function selectUnitPath(doc, caretPath) {
|
|
303
|
+
return _nullishCoalesce(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 = _nullishCoalesce(deepestText(at), () => ( at));
|
|
67
359
|
charOffset = 0;
|
|
@@ -86,13 +378,13 @@ 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
|
}
|
|
93
385
|
if (segs.length === 0)
|
|
94
386
|
return null;
|
|
95
|
-
return { path:
|
|
387
|
+
return { path: _chunkHXABDVLZcjs.normalizeToLeaf.call(void 0, doc, segs.concat(charOffset)) };
|
|
96
388
|
}
|
|
97
389
|
function readSelection(root, doc) {
|
|
98
390
|
const sel = root.ownerDocument.getSelection();
|
|
@@ -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 = _nullishCoalesce(
|
|
217
|
-
if (
|
|
541
|
+
for (const t2 of leafTextNodes(leaf)) {
|
|
542
|
+
const s = _nullishCoalesce(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: _nullishCoalesce(
|
|
552
|
+
const t2 = deepestText(leaf);
|
|
553
|
+
return { node: _nullishCoalesce(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 = _nullishCoalesce(
|
|
557
|
+
for (const t2 of texts) {
|
|
558
|
+
const s = _nullishCoalesce(t2.textContent, () => ( ""));
|
|
233
559
|
const len = zwspFreeLen(s);
|
|
234
560
|
if (s === "\n") {
|
|
235
561
|
if (off === 0)
|
|
236
|
-
return _nullishCoalesce(prev, () => ( { node:
|
|
562
|
+
return _nullishCoalesce(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 _nullishCoalesce(prev, () => ( { node: texts[texts.length - 1], offset: _nullishCoalesce(_optionalChain([texts, 'access', _7 => _7[texts.length - 1], 'access', _8 => _8.textContent, 'optionalAccess', _9 => _9.length]), () => ( 0)) }));
|
|
@@ -259,18 +585,18 @@ function focusBlockId(ed) {
|
|
|
259
585
|
const sel = readSelection(ed.root, ed.doc);
|
|
260
586
|
const idx = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _12 => _12.head, 'access', _13 => _13.path, 'access', _14 => _14[0]]), () => ( Math.max(0, ed.doc.children.length - 1)));
|
|
261
587
|
const b = ed.doc.children[idx];
|
|
262
|
-
if (!b ||
|
|
588
|
+
if (!b || _chunkPCSVBPORcjs.isText.call(void 0, b) || !b.id)
|
|
263
589
|
return null;
|
|
264
590
|
return b.id;
|
|
265
591
|
}
|
|
266
592
|
function blockPlainText(doc, blockId) {
|
|
267
|
-
const b = doc.children.find((c) => !
|
|
593
|
+
const b = doc.children.find((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === blockId);
|
|
268
594
|
if (!b)
|
|
269
595
|
return "";
|
|
270
596
|
return collectText(b);
|
|
271
597
|
}
|
|
272
598
|
function collectText(n) {
|
|
273
|
-
if (
|
|
599
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, n))
|
|
274
600
|
return n.text;
|
|
275
601
|
return n.children.map(collectText).join("");
|
|
276
602
|
}
|
|
@@ -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,
|
|
@@ -290,11 +616,11 @@ function emptyLike(block) {
|
|
|
290
616
|
return { type: "paragraph", id: block.id, attrs: block.attrs ? { ...block.attrs } : void 0, children: [{ text: "" }] };
|
|
291
617
|
}
|
|
292
618
|
function streamTargetId(doc, blockId) {
|
|
293
|
-
const b = doc.children.find((c) => !
|
|
619
|
+
const b = doc.children.find((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === blockId);
|
|
294
620
|
if (!b)
|
|
295
621
|
return blockId;
|
|
296
|
-
if (b.type === "quote"
|
|
297
|
-
const inner = b.children.find((c) => !
|
|
622
|
+
if (b.type === "quote") {
|
|
623
|
+
const inner = b.children.find((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.type === "paragraph");
|
|
298
624
|
if (_optionalChain([inner, 'optionalAccess', _15 => _15.id]))
|
|
299
625
|
return inner.id;
|
|
300
626
|
}
|
|
@@ -316,16 +642,16 @@ function startAiWrite(ed, mode, blockId) {
|
|
|
316
642
|
if (mode === "continue") {
|
|
317
643
|
const id = newId();
|
|
318
644
|
const empty = { type: "paragraph", id, children: [{ text: "" }] };
|
|
319
|
-
ed.dispatch([
|
|
645
|
+
ed.dispatch([_chunkOVHASRIDcjs.insertAfter.call(void 0, doc, focus, [empty])]);
|
|
320
646
|
targetId = id;
|
|
321
647
|
} else {
|
|
322
|
-
const block = doc.children.find((c) => !
|
|
648
|
+
const block = doc.children.find((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === focus);
|
|
323
649
|
if (!block)
|
|
324
650
|
throw new Error(`block not found: ${focus}`);
|
|
325
651
|
if (block.type === "table" || block.type === "image" || block.type === "embed" || block.type === "raw")
|
|
326
652
|
throw new Error(`cannot rewrite ${block.type}`);
|
|
327
653
|
const cleared = emptyLike(block);
|
|
328
|
-
ed.dispatch([
|
|
654
|
+
ed.dispatch([_chunkOVHASRIDcjs.rewriteNode.call(void 0, doc, focus, cleared)]);
|
|
329
655
|
targetId = streamTargetId(ed.doc, focus);
|
|
330
656
|
}
|
|
331
657
|
opened = true;
|
|
@@ -334,7 +660,7 @@ function startAiWrite(ed, mode, blockId) {
|
|
|
334
660
|
if (!alive || !text)
|
|
335
661
|
return;
|
|
336
662
|
setup();
|
|
337
|
-
const step =
|
|
663
|
+
const step = _chunkOVHASRIDcjs.appendText.call(void 0, ed.doc, targetId, text);
|
|
338
664
|
ed.dispatchStream([step]);
|
|
339
665
|
};
|
|
340
666
|
const finish = () => {
|
|
@@ -359,15 +685,15 @@ function precedingPlainText(doc, blockIdx) {
|
|
|
359
685
|
const parts = [];
|
|
360
686
|
for (let i = 0; i < blockIdx && i < doc.children.length; i++) {
|
|
361
687
|
const b = doc.children[i];
|
|
362
|
-
if (
|
|
688
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, b) || !b.id)
|
|
363
689
|
continue;
|
|
364
|
-
if (b.type === "image" || b.type === "table" || b.type === "embed" || b.type === "raw" ||
|
|
690
|
+
if (b.type === "image" || b.type === "table" || b.type === "embed" || b.type === "raw" || _chunkPCSVBPORcjs.isAiCompose.call(void 0, b))
|
|
365
691
|
continue;
|
|
366
692
|
if (_optionalChain([b, 'access', _16 => _16.attrs, 'optionalAccess', _17 => _17.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,41 +774,39 @@ var MarkloomAi = (_class = class {
|
|
|
448
774
|
return;
|
|
449
775
|
const bid = focusBlockId(ed);
|
|
450
776
|
if (!bid) {
|
|
451
|
-
_optionalChain([this, 'access', _29 => _29.opts, 'access', _30 => _30.onError, 'optionalCall', _31 => _31("
|
|
777
|
+
_optionalChain([this, 'access', _29 => _29.opts, 'access', _30 => _30.onError, 'optionalCall', _31 => _31(t("aiErrNoCursor"))]);
|
|
452
778
|
return;
|
|
453
779
|
}
|
|
454
780
|
const doc = ed.doc;
|
|
455
|
-
const idx = doc.children.findIndex((c) => !
|
|
781
|
+
const idx = doc.children.findIndex((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === bid);
|
|
456
782
|
if (idx < 0)
|
|
457
783
|
return;
|
|
458
784
|
const cur = doc.children[idx];
|
|
459
|
-
if (
|
|
785
|
+
if (_chunkPCSVBPORcjs.isAiCompose.call(void 0, cur))
|
|
460
786
|
return;
|
|
461
787
|
if (mode === "rewrite") {
|
|
462
788
|
if (!blockPlainText(doc, bid).trim()) {
|
|
463
|
-
_optionalChain([this, 'access', _32 => _32.opts, 'access', _33 => _33.onError, 'optionalCall', _34 => _34("
|
|
789
|
+
_optionalChain([this, 'access', _32 => _32.opts, 'access', _33 => _33.onError, 'optionalCall', _34 => _34(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 = 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 = 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 = 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;
|
|
@@ -661,7 +984,7 @@ var MarkloomAi = (_class = class {
|
|
|
661
984
|
const steps = [];
|
|
662
985
|
for (let i = 0; i < doc.children.length; i++) {
|
|
663
986
|
const c = doc.children[i];
|
|
664
|
-
if (
|
|
987
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, c) || _optionalChain([c, 'access', _61 => _61.attrs, 'optionalAccess', _62 => _62.aiFrom]) !== blockId)
|
|
665
988
|
continue;
|
|
666
989
|
const attrs = { ..._nullishCoalesce(c.attrs, () => ( {})) };
|
|
667
990
|
delete attrs.aiDraft;
|
|
@@ -677,12 +1000,12 @@ var MarkloomAi = (_class = class {
|
|
|
677
1000
|
next.attrs = clean;
|
|
678
1001
|
steps.push({ kind: "replaceNode", path: [i], node: next });
|
|
679
1002
|
}
|
|
680
|
-
const aiIdx0 = doc.children.findIndex((c) => !
|
|
1003
|
+
const aiIdx0 = doc.children.findIndex((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === blockId);
|
|
681
1004
|
if (aiIdx0 >= 0)
|
|
682
1005
|
steps.push({ kind: "spliceChildren", path: [], at: aiIdx0, remove: 1, insert: [] });
|
|
683
1006
|
if (!steps.length)
|
|
684
1007
|
return;
|
|
685
|
-
const firstDraft = doc.children.findIndex((c) => !
|
|
1008
|
+
const firstDraft = doc.children.findIndex((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && _optionalChain([c, 'access', _63 => _63.attrs, 'optionalAccess', _64 => _64.aiFrom]) === blockId);
|
|
686
1009
|
let caretAt = firstDraft >= 0 ? firstDraft : Math.max(0, aiIdx0);
|
|
687
1010
|
if (firstDraft > aiIdx0)
|
|
688
1011
|
caretAt = firstDraft - 1;
|
|
@@ -731,7 +1054,7 @@ var MarkloomAi = (_class = class {
|
|
|
731
1054
|
const idxs = draftIndices(doc, blockId);
|
|
732
1055
|
for (let i = idxs.length - 1; i >= 0; i--)
|
|
733
1056
|
steps.push({ kind: "spliceChildren", path: [], at: idxs[i], remove: 1, insert: [] });
|
|
734
|
-
let aiIdx = doc.children.findIndex((c) => !
|
|
1057
|
+
let aiIdx = doc.children.findIndex((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === blockId);
|
|
735
1058
|
let shift = 0;
|
|
736
1059
|
for (const i of idxs) {
|
|
737
1060
|
if (i < aiIdx)
|
|
@@ -771,11 +1094,11 @@ var MarkloomAi = (_class = class {
|
|
|
771
1094
|
this.txBlockId = null;
|
|
772
1095
|
}
|
|
773
1096
|
findAi(ed, blockId) {
|
|
774
|
-
const path =
|
|
1097
|
+
const path = _chunkOVHASRIDcjs.pathOfId.call(void 0, ed.doc, blockId);
|
|
775
1098
|
if (!path)
|
|
776
1099
|
return null;
|
|
777
1100
|
const node = path.reduce((n, i) => n.children[i], ed.doc);
|
|
778
|
-
if (!node ||
|
|
1101
|
+
if (!node || _chunkPCSVBPORcjs.isText.call(void 0, node) || !_chunkPCSVBPORcjs.isAiCompose.call(void 0, node))
|
|
779
1102
|
return null;
|
|
780
1103
|
return { path, node };
|
|
781
1104
|
}
|
|
@@ -799,7 +1122,7 @@ var MarkloomAi = (_class = class {
|
|
|
799
1122
|
paintMd(ed, blockId, md, streaming) {
|
|
800
1123
|
const doc = ed.doc;
|
|
801
1124
|
const idxs = draftIndices(doc, blockId);
|
|
802
|
-
const aiIdx = doc.children.findIndex((c) => !
|
|
1125
|
+
const aiIdx = doc.children.findIndex((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c) && c.id === blockId);
|
|
803
1126
|
const at = idxs.length ? idxs[0] : aiIdx >= 0 ? aiIdx + 1 : -1;
|
|
804
1127
|
if (at < 0)
|
|
805
1128
|
return;
|
|
@@ -829,7 +1152,7 @@ var MarkloomAi = (_class = class {
|
|
|
829
1152
|
const src = streaming ? softCloseMd(raw) : raw;
|
|
830
1153
|
let blocks;
|
|
831
1154
|
try {
|
|
832
|
-
const tops =
|
|
1155
|
+
const tops = _chunkOVHASRIDcjs.mdToDoc.call(void 0, src).children.filter((c) => !_chunkPCSVBPORcjs.isText.call(void 0, c));
|
|
833
1156
|
blocks = tops.map((c, i) => stampDraft(c, blockId, `${blockId}_d${i}`, streaming && i === tops.length - 1));
|
|
834
1157
|
} catch (e3) {
|
|
835
1158
|
blocks = [{
|
|
@@ -918,7 +1241,7 @@ function softCloseMd(md) {
|
|
|
918
1241
|
}
|
|
919
1242
|
function stampDraft(node, aiFrom, id, streamTail = false) {
|
|
920
1243
|
const kids = node.children.map((c, i) => {
|
|
921
|
-
if (
|
|
1244
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, c))
|
|
922
1245
|
return c;
|
|
923
1246
|
return stampInner(c, `${id}_${i}`);
|
|
924
1247
|
});
|
|
@@ -929,7 +1252,7 @@ function stampDraft(node, aiFrom, id, streamTail = false) {
|
|
|
929
1252
|
}
|
|
930
1253
|
function stampInner(node, id) {
|
|
931
1254
|
const kids = node.children.map((c, i) => {
|
|
932
|
-
if (
|
|
1255
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, c))
|
|
933
1256
|
return c;
|
|
934
1257
|
return stampInner(c, `${id}_${i}`);
|
|
935
1258
|
});
|
|
@@ -944,7 +1267,7 @@ function draftIndices(doc, aiId) {
|
|
|
944
1267
|
const out = [];
|
|
945
1268
|
for (let i = 0; i < doc.children.length; i++) {
|
|
946
1269
|
const c = doc.children[i];
|
|
947
|
-
if (!
|
|
1270
|
+
if (!_chunkPCSVBPORcjs.isText.call(void 0, c) && _optionalChain([c, 'access', _71 => _71.attrs, 'optionalAccess', _72 => _72.aiFrom]) === aiId)
|
|
948
1271
|
out.push(i);
|
|
949
1272
|
}
|
|
950
1273
|
return out;
|
|
@@ -954,13 +1277,16 @@ function promptText(ai) {
|
|
|
954
1277
|
return p ? collectText2(p) : "";
|
|
955
1278
|
}
|
|
956
1279
|
function collectText2(n) {
|
|
957
|
-
if (
|
|
1280
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, n))
|
|
958
1281
|
return n.text;
|
|
959
1282
|
return n.children.map(collectText2).join("");
|
|
960
1283
|
}
|
|
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",
|
|
@@ -1124,4 +1465,17 @@ function createAiStream(cfg) {
|
|
|
1124
1465
|
|
|
1125
1466
|
|
|
1126
1467
|
|
|
1127
|
-
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
exports.setLocale = setLocale; exports.getLocale = getLocale; exports.MESSAGES = MESSAGES; exports.t = t; exports.rootEl = rootEl; exports.nodeExtent = nodeExtent; exports.docExtent = docExtent; exports.SELECT_UNIT_TYPES = SELECT_UNIT_TYPES; exports.isSelectUnitType = isSelectUnitType; exports.isSelectUnit = isSelectUnit; exports.isProgressiveSelectUnit = isProgressiveSelectUnit; exports.progressiveUnitPaths = progressiveUnitPaths; exports.selectUnitPath = selectUnitPath; exports.selectionCovers = selectionCovers; exports.expandSelectAll = expandSelectAll; exports.pointToDom = pointToDom; exports.domToPoint = domToPoint; exports.readSelection = readSelection; exports.writeSelection = writeSelection; exports.invalidateStructure = invalidateStructure; exports.elementChildren = elementChildren; exports.focusBlockId = focusBlockId; exports.blockPlainText = blockPlainText; exports.startAiWrite = startAiWrite; exports.precedingPlainText = precedingPlainText; exports.aiInstructionFromQuery = aiInstructionFromQuery; exports.MarkloomAi = MarkloomAi; exports.createAiStream = createAiStream;
|