reactive-md 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG-ch.md +11 -0
  2. package/CHANGELOG.md +11 -0
  3. package/README-ch.md +7 -7
  4. package/README-en.md +8 -8
  5. package/README.md +8 -8
  6. package/cli/build.mjs +1 -1
  7. package/cli/package.mjs +1 -0
  8. package/dist-library/authoring-DJJjKYg9.js +842 -0
  9. package/dist-library/{runtime-UiQPz5ZV.js → compiler-UyPwGzJZ.js} +5631 -5389
  10. package/dist-library/react-fizgU3i8.js +12764 -0
  11. package/dist-library/reactive-md-authoring.js +1514 -0
  12. package/dist-library/reactive-md-editor.js +577 -571
  13. package/dist-library/reactive-md-print.css +284 -0
  14. package/dist-library/reactive-md-react-unstyled.js +1 -0
  15. package/dist-library/reactive-md-react.js +1 -13208
  16. package/dist-library/reactive-md.css +1 -1
  17. package/dist-library/reactive-md.js +244 -1062
  18. package/dist-library/runtime-DXtle_6c.js +498 -0
  19. package/dist-library/types/authoring/index.d.ts +24 -0
  20. package/dist-library/types/editor/command-types.d.ts +10 -0
  21. package/dist-library/types/editor/editor-commands.d.ts +2 -2
  22. package/dist-library/types/editor/editor-i18n.d.ts +1 -1
  23. package/dist-library/types/editor/native-components.d.ts +1 -1
  24. package/dist-library/types/editor/source-authoring.d.ts +5 -3
  25. package/dist-library/types/editor/types.d.ts +5 -10
  26. package/dist-library/types/local/LocalDocumentView.d.ts +4 -2
  27. package/dist-library/types/local/authoring.d.ts +9 -5
  28. package/dist-library/types/local/diagnostics.d.ts +40 -0
  29. package/dist-library/types/local/index.d.ts +1 -0
  30. package/dist-library/types/local/math-display.d.ts +72 -0
  31. package/dist-library/types/local/math-view.d.ts +2 -0
  32. package/dist-library/types/local/options.d.ts +3 -1
  33. package/dist-library/types/local/types.d.ts +10 -0
  34. package/dist-library/types/local/worker.d.ts +3 -2
  35. package/dist-library/types/react/index.d.ts +1 -1
  36. package/dist-standalone/reactive-md-standalone.js +54 -50
  37. package/docs/author-tools-ch.md +11 -5
  38. package/docs/author-tools-en.md +11 -5
  39. package/docs/editor-ch.md +237 -235
  40. package/docs/editor-en.md +237 -235
  41. package/docs/local-integration-ch.md +392 -390
  42. package/docs/local-integration-en.md +392 -390
  43. package/docs/release-0.5.3-ch.md +25 -0
  44. package/docs/release-0.5.3-en.md +25 -0
  45. package/package.json +12 -2
@@ -0,0 +1,1514 @@
1
+ import { C as e, D as t, E as n, O as r, S as i, T as a, w as o, x as s } from "./compiler-UyPwGzJZ.js";
2
+ import { i as c, n as l, r as u, t as d } from "./authoring-DJJjKYg9.js";
3
+ // src/editor/extended-native-components.ts
4
+ var f = [
5
+ {
6
+ id: "jump",
7
+ label: "Jump and anchor",
8
+ description: "Link to a named position in this document.",
9
+ group: "action",
10
+ keywords: [
11
+ "jump",
12
+ "anchor",
13
+ "navigation"
14
+ ],
15
+ template: "<jump to=\"{{bind:destination}}\" appearance=\"button\" color=\"#2563eb\">View results</jump>\n\n<anchor id=\"{{bind:destination}}\">\n\n{{selection:Results appear here.}}"
16
+ },
17
+ {
18
+ id: "anchor",
19
+ label: "Anchor",
20
+ description: "Name a destination for document links.",
21
+ group: "layout",
22
+ keywords: [
23
+ "anchor",
24
+ "target",
25
+ "destination"
26
+ ],
27
+ template: "<anchor id=\"{{bind:destination}}\">"
28
+ },
29
+ {
30
+ id: "text",
31
+ label: "Colored text",
32
+ description: "Give selected words a foreground color.",
33
+ group: "hint",
34
+ keywords: [
35
+ "text",
36
+ "color",
37
+ "foreground"
38
+ ],
39
+ inline: !0,
40
+ template: "<text color=\"#a2273a\">{{selection:Important reminder}}</text>"
41
+ },
42
+ {
43
+ id: "section",
44
+ label: "Colored section",
45
+ description: "Apply a shared text color to several paragraphs.",
46
+ group: "layout",
47
+ keywords: [
48
+ "section",
49
+ "color",
50
+ "paragraph"
51
+ ],
52
+ template: "<section color=\"#45536f\">\n\n{{selection:Your paragraphs go here.}}\n\n</section>"
53
+ },
54
+ {
55
+ id: "multi-select",
56
+ label: "Multiple selection",
57
+ description: "Choose up to two items and read their values.",
58
+ group: "input",
59
+ keywords: [
60
+ "multiple",
61
+ "select",
62
+ "subjects",
63
+ "checkbox"
64
+ ],
65
+ template: "<multi-select bind=\"{{bind:subjects}}\" label=\"Subjects\" max-selected=\"2\">\n<option value=\"math\">Math</option>\n<option value=\"physics\">Physics</option>\n<option value=\"chemistry\">Chemistry</option>\n</multi-select>"
66
+ },
67
+ {
68
+ id: "range-slider",
69
+ label: "Interval slider",
70
+ description: "Choose the lower and upper bounds of an interval.",
71
+ group: "input",
72
+ keywords: [
73
+ "range",
74
+ "interval",
75
+ "slider",
76
+ "bounds"
77
+ ],
78
+ template: "<range-slider label=\"Interval\" bind-start=\"{{bind:low}}\" bind-end=\"{{bind:high}}\" initial-start=\"20\" initial-end=\"80\" min=\"0\" max=\"100\" step=\"1\">"
79
+ },
80
+ {
81
+ id: "coordinate",
82
+ label: "Coordinate point",
83
+ description: "Drag a point or change its two coordinates.",
84
+ group: "input",
85
+ keywords: [
86
+ "coordinate",
87
+ "point",
88
+ "drag",
89
+ "geometry"
90
+ ],
91
+ template: "<coordinate label=\"Point\" bind-x=\"{{bind:px}}\" bind-y=\"{{bind:py}}\" initial-x=\"1\" initial-y=\"2\" x-min=\"-5\" x-max=\"5\" y-min=\"-5\" y-max=\"5\">"
92
+ },
93
+ {
94
+ id: "quiz",
95
+ label: "Practice question",
96
+ description: "Check an answer and read a short explanation.",
97
+ group: "action",
98
+ keywords: [
99
+ "quiz",
100
+ "practice",
101
+ "answer",
102
+ "learn"
103
+ ],
104
+ template: "<quiz type=\"choice\" label=\"What is 2 + 3?\" answer=\"b\" explanation=\"The sum is 5.\">\n<option value=\"a\">4</option>\n<option value=\"b\">5</option>\n</quiz>"
105
+ },
106
+ {
107
+ id: "steps",
108
+ label: "Guided steps",
109
+ description: "Read instructions one step at a time.",
110
+ group: "layout",
111
+ keywords: [
112
+ "steps",
113
+ "guide",
114
+ "previous",
115
+ "next"
116
+ ],
117
+ template: "<steps label=\"Learning path\" bind=\"{{bind:lesson}}\">\n<step label=\"Observe\">\nChange a parameter.\n</step>\n<step label=\"Practice\">\nCheck an answer.\n</step>\n</steps>"
118
+ }
119
+ ], p = {
120
+ jump: {
121
+ label: "跳转与锚点",
122
+ description: "跳到当前文档中的指定位置。",
123
+ keywords: [
124
+ "跳转",
125
+ "锚点",
126
+ "导航"
127
+ ],
128
+ template: "<jump to=\"{{bind:destination}}\" appearance=\"button\" color=\"#2563eb\">查看结果</jump>\n\n<anchor id=\"{{bind:destination}}\">\n\n{{selection:结果显示在这里。}}"
129
+ },
130
+ anchor: {
131
+ label: "锚点",
132
+ description: "为文档内的跳转指定目标位置。",
133
+ keywords: [
134
+ "锚点",
135
+ "目标",
136
+ "位置"
137
+ ],
138
+ template: "<anchor id=\"{{bind:destination}}\">"
139
+ },
140
+ text: {
141
+ label: "文字颜色",
142
+ description: "为选中的局部文字指定颜色。",
143
+ keywords: [
144
+ "文字",
145
+ "颜色",
146
+ "前景"
147
+ ],
148
+ template: "<text color=\"#a2273a\">{{selection:重要提醒}}</text>"
149
+ },
150
+ section: {
151
+ label: "正文颜色",
152
+ description: "为一段或多段正文指定统一颜色。",
153
+ keywords: [
154
+ "正文",
155
+ "段落",
156
+ "颜色"
157
+ ],
158
+ template: "<section color=\"#45536f\">\n\n{{selection:在这里填写正文。}}\n\n</section>"
159
+ },
160
+ "multi-select": {
161
+ label: "多选",
162
+ description: "最多选择两个选项,公开选项值数组。",
163
+ keywords: [
164
+ "多选",
165
+ "选项",
166
+ "主题"
167
+ ],
168
+ template: "<multi-select bind=\"{{bind:subjects}}\" label=\"主题\" max-selected=\"2\">\n<option value=\"math\">数学</option>\n<option value=\"physics\">物理</option>\n<option value=\"chemistry\">化学</option>\n</multi-select>"
169
+ },
170
+ "range-slider": {
171
+ label: "区间滑块",
172
+ description: "同时选择区间的起点和终点。",
173
+ keywords: [
174
+ "区间",
175
+ "滑块",
176
+ "上下限"
177
+ ],
178
+ template: "<range-slider label=\"观察区间\" bind-start=\"{{bind:low}}\" bind-end=\"{{bind:high}}\" initial-start=\"20\" initial-end=\"80\" min=\"0\" max=\"100\" step=\"1\">"
179
+ },
180
+ coordinate: {
181
+ label: "二维坐标",
182
+ description: "拖动坐标点,或直接修改两个坐标。",
183
+ keywords: [
184
+ "坐标",
185
+ "拖动",
186
+ "几何"
187
+ ],
188
+ template: "<coordinate label=\"坐标点\" bind-x=\"{{bind:px}}\" bind-y=\"{{bind:py}}\" initial-x=\"1\" initial-y=\"2\" x-min=\"-5\" x-max=\"5\" y-min=\"-5\" y-max=\"5\">"
189
+ },
190
+ quiz: {
191
+ label: "练习题",
192
+ description: "检查答案并阅读简短解析。",
193
+ keywords: [
194
+ "练习",
195
+ "题目",
196
+ "答案"
197
+ ],
198
+ template: "<quiz type=\"choice\" label=\"2 + 3 等于多少?\" answer=\"b\" explanation=\"相加得到 5。\">\n<option value=\"a\">4</option>\n<option value=\"b\">5</option>\n</quiz>"
199
+ },
200
+ steps: {
201
+ label: "分步阅读",
202
+ description: "按顺序阅读说明,内置上一步和下一步。",
203
+ keywords: [
204
+ "步骤",
205
+ "引导",
206
+ "下一步"
207
+ ],
208
+ template: "<steps label=\"学习路线\" bind=\"{{bind:lesson}}\">\n<step label=\"观察\">\n调整参数。\n</step>\n<step label=\"练习\">\n检查答案。\n</step>\n</steps>"
209
+ }
210
+ }, m = {
211
+ en: {
212
+ boldPlaceholder: "bold text",
213
+ italicPlaceholder: "italic text",
214
+ strikePlaceholder: "strikethrough text",
215
+ inlineCodePlaceholder: "code",
216
+ linkText: "link text",
217
+ imageAlt: "example image",
218
+ codeBlockPlaceholder: "Write code here",
219
+ tableHeaders: [
220
+ "Column 1",
221
+ "Column 2",
222
+ "Column 3"
223
+ ],
224
+ tableRows: [[
225
+ "Example 1",
226
+ "Example 2",
227
+ "Example 3"
228
+ ], [
229
+ "Example 4",
230
+ "Example 5",
231
+ "Example 6"
232
+ ]]
233
+ },
234
+ zh: {
235
+ boldPlaceholder: "粗体文字",
236
+ italicPlaceholder: "斜体文字",
237
+ strikePlaceholder: "删除线文字",
238
+ inlineCodePlaceholder: "代码",
239
+ linkText: "链接文字",
240
+ imageAlt: "示意图",
241
+ codeBlockPlaceholder: "在这里写代码",
242
+ tableHeaders: [
243
+ "列 1",
244
+ "列 2",
245
+ "列 3"
246
+ ],
247
+ tableRows: [[
248
+ "示例 1",
249
+ "示例 2",
250
+ "示例 3"
251
+ ], [
252
+ "示例 4",
253
+ "示例 5",
254
+ "示例 6"
255
+ ]]
256
+ }
257
+ }, h = {
258
+ en: {
259
+ groups: {
260
+ input: "Input controls",
261
+ action: "Interactive tools",
262
+ layout: "Content layout",
263
+ data: "Data visualization",
264
+ hint: "Feedback"
265
+ },
266
+ components: {}
267
+ },
268
+ zh: {
269
+ groups: {
270
+ input: "输入控件",
271
+ action: "交互工具",
272
+ layout: "内容组织",
273
+ data: "数据可视化",
274
+ hint: "提示反馈"
275
+ },
276
+ components: {
277
+ ...p,
278
+ slider: {
279
+ label: "滑块",
280
+ description: "拖动滑块在指定范围内选择一个数值。",
281
+ keywords: [
282
+ "滑块",
283
+ "范围",
284
+ "数值",
285
+ "拖动",
286
+ "滑动"
287
+ ],
288
+ template: "<slider bind=\"{{bind:amount}}\" label=\"数量\" initial=\"10\" min=\"0\" max=\"100\" step=\"1\">"
289
+ },
290
+ number: {
291
+ label: "数字输入",
292
+ description: "输入精确数字,可限制范围和步长。",
293
+ keywords: [
294
+ "数字",
295
+ "数值",
296
+ "输入",
297
+ "步长",
298
+ "数量"
299
+ ],
300
+ template: "<number bind=\"{{bind:quantity}}\" label=\"数量\" initial=\"1\" min=\"0\" max=\"100\" step=\"1\">"
301
+ },
302
+ input: {
303
+ label: "单行文本",
304
+ description: "输入姓名、标题等单行文本。",
305
+ keywords: [
306
+ "文本",
307
+ "单行",
308
+ "输入框",
309
+ "名称",
310
+ "输入"
311
+ ],
312
+ template: "<input bind=\"{{bind:name}}\" label=\"名称\" placeholder=\"请输入名称\">"
313
+ },
314
+ textarea: {
315
+ label: "多行文本",
316
+ description: "输入说明、备注等多行文字。",
317
+ keywords: [
318
+ "文本域",
319
+ "多行",
320
+ "说明",
321
+ "备注",
322
+ "详细"
323
+ ],
324
+ template: "<textarea bind=\"{{bind:message}}\" label=\"详细说明\" placeholder=\"请输入详细说明\" rows=\"4\">"
325
+ },
326
+ toggle: {
327
+ label: "开关",
328
+ description: "在开启与关闭之间切换一个布尔选项。",
329
+ keywords: [
330
+ "开关",
331
+ "布尔",
332
+ "启用",
333
+ "切换",
334
+ "选项"
335
+ ],
336
+ template: "<toggle bind=\"{{bind:enabled}}\" label=\"启用选项\">"
337
+ },
338
+ checkbox: {
339
+ label: "复选框",
340
+ description: "勾选或取消一个布尔选项。",
341
+ keywords: [
342
+ "复选",
343
+ "勾选",
344
+ "布尔",
345
+ "确认",
346
+ "选项"
347
+ ],
348
+ template: "<checkbox bind=\"{{bind:confirmed}}\" label=\"确认选项\">"
349
+ },
350
+ date: {
351
+ label: "日期选择",
352
+ description: "选择一个日期,未选择时为空字符串。",
353
+ keywords: [
354
+ "日期",
355
+ "日历",
356
+ "时间",
357
+ "选择"
358
+ ],
359
+ template: "<date bind=\"{{bind:date}}\" label=\"选择日期\">"
360
+ },
361
+ choices: {
362
+ label: "选项卡片",
363
+ description: "从多个选项卡中选择一项。",
364
+ keywords: [
365
+ "选项",
366
+ "选择",
367
+ "卡片",
368
+ "单选",
369
+ "方案"
370
+ ],
371
+ template: "<choices bind=\"{{bind:plan}}\" label=\"选择方案\">\n<option value=\"basic\">基础版</option>\n<option value=\"pro\">专业版</option>\n</choices>"
372
+ },
373
+ counter: {
374
+ label: "计数器",
375
+ description: "通过加减按钮调整整数,并可一键重置。",
376
+ keywords: [
377
+ "计数",
378
+ "加减",
379
+ "整数",
380
+ "调整",
381
+ "重置"
382
+ ],
383
+ template: "<counter bind=\"{{bind:count}}\" label=\"计数\" initial=\"0\" min=\"0\" max=\"99\">"
384
+ },
385
+ timer: {
386
+ label: "倒计时",
387
+ description: "启动、暂停和重置一段专注计时。",
388
+ keywords: [
389
+ "计时",
390
+ "倒计时",
391
+ "专注",
392
+ "秒",
393
+ "暂停"
394
+ ],
395
+ template: "<timer bind=\"{{bind:remaining}}\" label=\"专注计时\" duration=\"60\">"
396
+ },
397
+ checklist: {
398
+ label: "任务清单",
399
+ description: "用可勾选的任务列表记录完成情况。",
400
+ keywords: [
401
+ "清单",
402
+ "任务",
403
+ "勾选",
404
+ "待办",
405
+ "完成"
406
+ ],
407
+ template: "<checklist bind=\"{{bind:done}}\" label=\"完成清单\">\n- [ ] 第一项任务\n- [ ] 第二项任务\n- [ ] 第三项任务\n</checklist>"
408
+ },
409
+ progress: {
410
+ label: "进度条",
411
+ description: "展示 0 到 100 之间的完成进度。",
412
+ keywords: [
413
+ "进度",
414
+ "完成度",
415
+ "进度条",
416
+ "百分比"
417
+ ],
418
+ template: "<progress label=\"完成进度\" value=\"{{ 40 }}\">"
419
+ },
420
+ panel: {
421
+ label: "参数面板",
422
+ description: "把一组控件包进面板,并附带恢复默认按钮。",
423
+ keywords: [
424
+ "面板",
425
+ "参数",
426
+ "重置",
427
+ "表单",
428
+ "控件"
429
+ ],
430
+ template: "<panel title=\"参数面板\">\n{{selection:示例内容}}\n</panel>"
431
+ },
432
+ card: {
433
+ label: "内容卡片",
434
+ description: "用卡片组织一段独立内容。",
435
+ keywords: [
436
+ "卡片",
437
+ "容器",
438
+ "内容",
439
+ "区块"
440
+ ],
441
+ template: "<card title=\"内容卡片\">\n{{selection:示例内容}}\n</card>"
442
+ },
443
+ if: {
444
+ label: "条件区域",
445
+ description: "只有条件为真时才显示其中内容。",
446
+ keywords: [
447
+ "条件",
448
+ "判断",
449
+ "显示",
450
+ "当"
451
+ ],
452
+ template: "<if when=\"{{ {{select:true}} }}\">\n{{selection:示例内容}}\n</if>"
453
+ },
454
+ tabs: {
455
+ label: "标签页",
456
+ description: "把内容分到多个可切换的标签页中。",
457
+ keywords: [
458
+ "标签页",
459
+ "切换",
460
+ "分组",
461
+ "选项卡"
462
+ ],
463
+ template: "<tabs label=\"内容标签页\">\n<tab label=\"标签一\">\n{{selection:示例内容}}\n</tab>\n\n<tab label=\"标签二\">\n第二个标签页的内容。\n</tab>\n</tabs>"
464
+ },
465
+ accordion: {
466
+ label: "折叠面板",
467
+ description: "把说明放进可展开和收起的条目。",
468
+ keywords: [
469
+ "折叠",
470
+ "展开",
471
+ "问答",
472
+ "手风琴",
473
+ "条目"
474
+ ],
475
+ template: "<accordion label=\"常见问题\">\n<disclosure label=\"问题一\">\n{{selection:示例内容}}\n</disclosure>\n\n<disclosure label=\"问题二\">\n第二个条目的说明。\n</disclosure>\n</accordion>"
476
+ },
477
+ chart: {
478
+ label: "柱状图",
479
+ description: "把 Markdown 表格转换成柱状图。",
480
+ keywords: [
481
+ "图表",
482
+ "柱状图",
483
+ "表格",
484
+ "数据",
485
+ "对比"
486
+ ],
487
+ template: "<chart kind=\"bar\" title=\"分类对比\" y-label=\"数值\">\n| 项目 | 数值 |\n| --- | ---: |\n| 项目甲 | 20 |\n| 项目乙 | 35 |\n</chart>"
488
+ },
489
+ table: {
490
+ label: "增强表格",
491
+ description: "带搜索、排序和分页的 Markdown 表格。",
492
+ keywords: [
493
+ "表格",
494
+ "搜索",
495
+ "排序",
496
+ "分页",
497
+ "数据"
498
+ ],
499
+ template: "<table label=\"数据表格\" page-size=\"5\">\n| 名称 | 分类 | 数值 |\n| --- | --- | ---: |\n| 项目甲 | 分类一 | 20 |\n| 项目乙 | 分类二 | 35 |\n</table>"
500
+ },
501
+ timeline: {
502
+ label: "时间轴",
503
+ description: "用表格展示任务的开始时间与时长。",
504
+ keywords: [
505
+ "时间轴",
506
+ "计划",
507
+ "时长",
508
+ "日程",
509
+ "任务"
510
+ ],
511
+ template: "<timeline title=\"任务时间轴\">\n| 事项 | 开始 | 时长 | 说明 |\n| --- | ---: | ---: | --- |\n| 准备 | 0 | 10 | 列出所需材料 |\n| 执行 | 10 | 20 | 完成主要内容 |\n| 检查 | 30 | 5 | 复核结果 |\n</timeline>"
512
+ },
513
+ diagram: {
514
+ label: "交互图解",
515
+ description: "用节点和连线展示流程,可点击查看说明。",
516
+ keywords: [
517
+ "图解",
518
+ "流程",
519
+ "节点",
520
+ "连线",
521
+ "关系图"
522
+ ],
523
+ template: "<diagram label=\"流程示意\">\n<node id=\"start\" label=\"开始\">\n流程起点。\n</node>\n\n<node id=\"process\" label=\"处理\">\n执行主要步骤。\n</node>\n\n<node id=\"end\" label=\"结束\">\n查看结果。\n</node>\n\n<edge from=\"start\" to=\"process\" label=\"进入\">\n<edge from=\"process\" to=\"end\" label=\"完成\">\n</diagram>"
524
+ },
525
+ plot: {
526
+ label: "函数曲线",
527
+ description: "用 LaTeX 公式绘制一条函数曲线。",
528
+ keywords: [
529
+ "曲线",
530
+ "函数",
531
+ "公式",
532
+ "数学",
533
+ "绘图"
534
+ ],
535
+ template: "<plot min=\"-5\" max=\"5\" label=\"函数曲线\">\n$$ y = x^2 $$\n</plot>"
536
+ },
537
+ alert: {
538
+ label: "提示框",
539
+ description: "用不同语气突出普通、成功或警告信息。",
540
+ keywords: [
541
+ "提示",
542
+ "警告",
543
+ "通知",
544
+ "信息",
545
+ "消息"
546
+ ],
547
+ template: "<alert tone=\"info\" title=\"提示\">\n{{selection:示例内容}}\n</alert>"
548
+ },
549
+ badge: {
550
+ label: "徽标",
551
+ description: "在句子里显示一个简短状态标记。",
552
+ keywords: [
553
+ "徽标",
554
+ "标签",
555
+ "状态",
556
+ "行内",
557
+ "标记"
558
+ ],
559
+ template: "<badge tone=\"success\">标签</badge>"
560
+ },
561
+ tooltip: {
562
+ label: "行内提示",
563
+ description: "为句中的词语附加悬停或聚焦说明。",
564
+ keywords: [
565
+ "提示",
566
+ "悬停",
567
+ "说明",
568
+ "行内",
569
+ "气泡"
570
+ ],
571
+ template: "<tooltip text=\"这里显示补充说明。\">悬停查看</tooltip>"
572
+ }
573
+ }
574
+ }
575
+ }, g = [
576
+ {
577
+ id: "input",
578
+ label: "Input controls"
579
+ },
580
+ {
581
+ id: "action",
582
+ label: "Interactive tools"
583
+ },
584
+ {
585
+ id: "layout",
586
+ label: "Content layout"
587
+ },
588
+ {
589
+ id: "data",
590
+ label: "Data visualization"
591
+ },
592
+ {
593
+ id: "hint",
594
+ label: "Feedback"
595
+ }
596
+ ], _ = [
597
+ ...f,
598
+ {
599
+ id: "slider",
600
+ label: "Slider",
601
+ description: "Drag the slider to choose a number within a range.",
602
+ group: "input",
603
+ keywords: [
604
+ "slider",
605
+ "range",
606
+ "number",
607
+ "drag",
608
+ "value"
609
+ ],
610
+ template: "<slider bind=\"{{bind:amount}}\" label=\"Amount\" initial=\"10\" min=\"0\" max=\"100\" step=\"1\">"
611
+ },
612
+ {
613
+ id: "number",
614
+ label: "Number input",
615
+ description: "Enter an exact number with an optional range and step.",
616
+ group: "input",
617
+ keywords: [
618
+ "number",
619
+ "numeric",
620
+ "input",
621
+ "step",
622
+ "quantity"
623
+ ],
624
+ template: "<number bind=\"{{bind:quantity}}\" label=\"Quantity\" initial=\"1\" min=\"0\" max=\"100\" step=\"1\">"
625
+ },
626
+ {
627
+ id: "input",
628
+ label: "Single-line text",
629
+ description: "Enter a name, title or other single-line text.",
630
+ group: "input",
631
+ keywords: [
632
+ "input",
633
+ "text",
634
+ "single-line",
635
+ "field",
636
+ "name"
637
+ ],
638
+ template: "<input bind=\"{{bind:name}}\" label=\"Name\" placeholder=\"Enter a name\">"
639
+ },
640
+ {
641
+ id: "textarea",
642
+ label: "Multi-line text",
643
+ description: "Enter notes, descriptions or other multi-line text.",
644
+ group: "input",
645
+ keywords: [
646
+ "textarea",
647
+ "text area",
648
+ "multi-line",
649
+ "notes",
650
+ "description"
651
+ ],
652
+ template: "<textarea bind=\"{{bind:message}}\" label=\"Details\" placeholder=\"Enter details\" rows=\"4\">"
653
+ },
654
+ {
655
+ id: "toggle",
656
+ label: "Toggle",
657
+ description: "Switch a boolean option on or off.",
658
+ group: "input",
659
+ keywords: [
660
+ "toggle",
661
+ "switch",
662
+ "boolean",
663
+ "enable",
664
+ "on"
665
+ ],
666
+ template: "<toggle bind=\"{{bind:enabled}}\" label=\"Enable option\">"
667
+ },
668
+ {
669
+ id: "checkbox",
670
+ label: "Checkbox",
671
+ description: "Check or uncheck a boolean option.",
672
+ group: "input",
673
+ keywords: [
674
+ "checkbox",
675
+ "check",
676
+ "boolean",
677
+ "confirm",
678
+ "option"
679
+ ],
680
+ template: "<checkbox bind=\"{{bind:confirmed}}\" label=\"Confirm option\">"
681
+ },
682
+ {
683
+ id: "date",
684
+ label: "Date picker",
685
+ description: "Pick a date; the value stays empty until one is chosen.",
686
+ group: "input",
687
+ keywords: [
688
+ "date",
689
+ "calendar",
690
+ "picker",
691
+ "day"
692
+ ],
693
+ template: "<date bind=\"{{bind:date}}\" label=\"Pick a date\">"
694
+ },
695
+ {
696
+ id: "choices",
697
+ label: "Choice cards",
698
+ description: "Pick one option from a set of cards.",
699
+ group: "input",
700
+ keywords: [
701
+ "choices",
702
+ "options",
703
+ "cards",
704
+ "select",
705
+ "radio"
706
+ ],
707
+ template: "<choices bind=\"{{bind:plan}}\" label=\"Choose a plan\">\n<option value=\"basic\">Basic</option>\n<option value=\"pro\">Pro</option>\n</choices>"
708
+ },
709
+ {
710
+ id: "counter",
711
+ label: "Counter",
712
+ description: "Adjust an integer with plus and minus buttons, then reset it in one click.",
713
+ group: "action",
714
+ keywords: [
715
+ "counter",
716
+ "count",
717
+ "plus",
718
+ "minus",
719
+ "integer"
720
+ ],
721
+ template: "<counter bind=\"{{bind:count}}\" label=\"Count\" initial=\"0\" min=\"0\" max=\"99\">"
722
+ },
723
+ {
724
+ id: "timer",
725
+ label: "Countdown timer",
726
+ description: "Start, pause and reset a focus timer.",
727
+ group: "action",
728
+ keywords: [
729
+ "timer",
730
+ "countdown",
731
+ "focus",
732
+ "seconds",
733
+ "pause"
734
+ ],
735
+ template: "<timer bind=\"{{bind:remaining}}\" label=\"Focus timer\" duration=\"60\">"
736
+ },
737
+ {
738
+ id: "checklist",
739
+ label: "Checklist",
740
+ description: "Track completion with a checkable task list.",
741
+ group: "action",
742
+ keywords: [
743
+ "checklist",
744
+ "tasks",
745
+ "todo",
746
+ "check",
747
+ "done"
748
+ ],
749
+ template: "<checklist bind=\"{{bind:done}}\" label=\"Task checklist\">\n- [ ] First task\n- [ ] Second task\n- [ ] Third task\n</checklist>"
750
+ },
751
+ {
752
+ id: "progress",
753
+ label: "Progress bar",
754
+ description: "Show completion from 0 to 100.",
755
+ group: "action",
756
+ keywords: [
757
+ "progress",
758
+ "completion",
759
+ "bar",
760
+ "percent"
761
+ ],
762
+ template: "<progress label=\"Progress\" value=\"{{ 40 }}\">"
763
+ },
764
+ {
765
+ id: "panel",
766
+ label: "Parameter panel",
767
+ description: "Group controls in a panel with a restore-defaults button.",
768
+ group: "layout",
769
+ keywords: [
770
+ "panel",
771
+ "parameters",
772
+ "reset",
773
+ "form",
774
+ "group"
775
+ ],
776
+ template: "<panel title=\"Parameters\">\n{{selection:Sample content}}\n</panel>"
777
+ },
778
+ {
779
+ id: "card",
780
+ label: "Content card",
781
+ description: "Organize a self-contained piece of content in a card.",
782
+ group: "layout",
783
+ keywords: [
784
+ "card",
785
+ "container",
786
+ "content",
787
+ "section"
788
+ ],
789
+ template: "<card title=\"Content card\">\n{{selection:Sample content}}\n</card>"
790
+ },
791
+ {
792
+ id: "if",
793
+ label: "Conditional section",
794
+ description: "Show the contents only when a condition is true.",
795
+ group: "layout",
796
+ keywords: [
797
+ "if",
798
+ "condition",
799
+ "when",
800
+ "show",
801
+ "visible"
802
+ ],
803
+ template: "<if when=\"{{ {{select:true}} }}\">\n{{selection:Sample content}}\n</if>"
804
+ },
805
+ {
806
+ id: "tabs",
807
+ label: "Tabs",
808
+ description: "Split content across switchable tabs.",
809
+ group: "layout",
810
+ keywords: [
811
+ "tabs",
812
+ "switch",
813
+ "sections",
814
+ "groups"
815
+ ],
816
+ template: "<tabs label=\"Content tabs\">\n<tab label=\"Tab one\">\n{{selection:Sample content}}\n</tab>\n\n<tab label=\"Tab two\">\nContent for the second tab.\n</tab>\n</tabs>"
817
+ },
818
+ {
819
+ id: "accordion",
820
+ label: "Accordion",
821
+ description: "Put notes into items that expand and collapse.",
822
+ group: "layout",
823
+ keywords: [
824
+ "accordion",
825
+ "collapse",
826
+ "expand",
827
+ "faq",
828
+ "disclosure"
829
+ ],
830
+ template: "<accordion label=\"FAQ\">\n<disclosure label=\"Question one\">\n{{selection:Sample content}}\n</disclosure>\n\n<disclosure label=\"Question two\">\nDetails for the second item.\n</disclosure>\n</accordion>"
831
+ },
832
+ {
833
+ id: "chart",
834
+ label: "Bar chart",
835
+ description: "Turn a Markdown table into a bar chart.",
836
+ group: "data",
837
+ keywords: [
838
+ "chart",
839
+ "bar",
840
+ "graph",
841
+ "table",
842
+ "data"
843
+ ],
844
+ template: "<chart kind=\"bar\" title=\"Category comparison\" y-label=\"Value\">\n| Item | Value |\n| --- | ---: |\n| Item A | 20 |\n| Item B | 35 |\n</chart>"
845
+ },
846
+ {
847
+ id: "table",
848
+ label: "Enhanced table",
849
+ description: "A Markdown table with search, sorting and paging.",
850
+ group: "data",
851
+ keywords: [
852
+ "table",
853
+ "search",
854
+ "sort",
855
+ "paging",
856
+ "data"
857
+ ],
858
+ template: "<table label=\"Data table\" page-size=\"5\">\n| Name | Category | Value |\n| --- | --- | ---: |\n| Item A | Category one | 20 |\n| Item B | Category two | 35 |\n</table>"
859
+ },
860
+ {
861
+ id: "timeline",
862
+ label: "Timeline",
863
+ description: "Show task start times and durations in a table.",
864
+ group: "data",
865
+ keywords: [
866
+ "timeline",
867
+ "schedule",
868
+ "plan",
869
+ "duration",
870
+ "gantt"
871
+ ],
872
+ template: "<timeline title=\"Task timeline\">\n| Task | Start | Duration | Notes |\n| --- | ---: | ---: | --- |\n| Prepare | 0 | 10 | List the materials |\n| Execute | 10 | 20 | Complete the main work |\n| Review | 30 | 5 | Check the results |\n</timeline>"
873
+ },
874
+ {
875
+ id: "diagram",
876
+ label: "Interactive diagram",
877
+ description: "Show a flow with nodes and edges; click a node to read its notes.",
878
+ group: "data",
879
+ keywords: [
880
+ "diagram",
881
+ "flow",
882
+ "node",
883
+ "edge",
884
+ "graph"
885
+ ],
886
+ template: "<diagram label=\"Flow overview\">\n<node id=\"start\" label=\"Start\">\nWhere the flow begins.\n</node>\n\n<node id=\"process\" label=\"Process\">\nPerform the main step.\n</node>\n\n<node id=\"end\" label=\"End\">\nReview the result.\n</node>\n\n<edge from=\"start\" to=\"process\" label=\"Proceed\">\n<edge from=\"process\" to=\"end\" label=\"Complete\">\n</diagram>"
887
+ },
888
+ {
889
+ id: "plot",
890
+ label: "Function plot",
891
+ description: "Plot a function curve from a LaTeX formula.",
892
+ group: "data",
893
+ keywords: [
894
+ "plot",
895
+ "curve",
896
+ "function",
897
+ "formula",
898
+ "latex",
899
+ "math"
900
+ ],
901
+ template: "<plot min=\"-5\" max=\"5\" label=\"Function plot\">\n$$ y = x^2 $$\n</plot>"
902
+ },
903
+ {
904
+ id: "alert",
905
+ label: "Alert",
906
+ description: "Highlight info, success or warning messages with different tones.",
907
+ group: "hint",
908
+ keywords: [
909
+ "alert",
910
+ "notice",
911
+ "warning",
912
+ "info",
913
+ "message"
914
+ ],
915
+ template: "<alert tone=\"info\" title=\"Notice\">\n{{selection:Sample content}}\n</alert>"
916
+ },
917
+ {
918
+ id: "badge",
919
+ label: "Badge",
920
+ description: "Show a short status marker inside a sentence.",
921
+ group: "hint",
922
+ keywords: [
923
+ "badge",
924
+ "label",
925
+ "status",
926
+ "inline",
927
+ "tag"
928
+ ],
929
+ inline: !0,
930
+ template: "<badge tone=\"success\">Badge</badge>"
931
+ },
932
+ {
933
+ id: "tooltip",
934
+ label: "Tooltip",
935
+ description: "Attach a hover or focus note to a word in a sentence.",
936
+ group: "hint",
937
+ keywords: [
938
+ "tooltip",
939
+ "hint",
940
+ "hover",
941
+ "focus",
942
+ "inline"
943
+ ],
944
+ inline: !0,
945
+ template: "<tooltip text=\"Extra details appear here.\">Hover to view</tooltip>"
946
+ }
947
+ ], v = /\{\{bind:([^{}]+)\}\}/g, ee = /[A-Za-z_][A-Za-z0-9_]*/g;
948
+ function y(e, t) {
949
+ let n = [...e];
950
+ for (let e of t) {
951
+ let t = e.toLowerCase();
952
+ n.some((e) => e.toLowerCase() === t) || n.push(e);
953
+ }
954
+ return n;
955
+ }
956
+ var b = g.map((e) => ({
957
+ ...e,
958
+ label: h.zh.groups[e.id]
959
+ })), te = _.map((e) => ({
960
+ ...e,
961
+ keywords: y(e.keywords, h.zh.components[e.id]?.keywords ?? [])
962
+ })), x = _.map((e) => {
963
+ let t = h.zh.components[e.id];
964
+ return t ? {
965
+ ...e,
966
+ label: t.label,
967
+ description: t.description,
968
+ keywords: y(e.keywords, t.keywords),
969
+ template: t.template
970
+ } : e;
971
+ });
972
+ function ne(e = "en") {
973
+ return e === "zh" ? {
974
+ groups: b,
975
+ components: x
976
+ } : {
977
+ groups: g,
978
+ components: te
979
+ };
980
+ }
981
+ function S(e) {
982
+ return new Set(e.match(ee) ?? []);
983
+ }
984
+ function C(e) {
985
+ let t = e.trim().replace(/[^A-Za-z0-9_]/g, "_");
986
+ return t ? /^[0-9]/.test(t) ? `_${t}` : t : "value";
987
+ }
988
+ function w(e, t) {
989
+ if (!t.has(e)) return e;
990
+ let n = 2;
991
+ for (; t.has(`${e}${n}`);) n += 1;
992
+ return `${e}${n}`;
993
+ }
994
+ function T(e, t, n) {
995
+ let r = S(t), i = /* @__PURE__ */ new Map();
996
+ return e.template.replace(v, (e, t) => {
997
+ let n = t.trim(), a = i.get(n);
998
+ if (a) return a;
999
+ let o = w(C(n), r);
1000
+ return r.add(o), i.set(n, o), o;
1001
+ });
1002
+ }
1003
+ // src/editor/editor-commands.ts
1004
+ function E(e, t) {
1005
+ return typeof e != "number" || Number.isNaN(e) ? 0 : Math.min(Math.max(Math.trunc(e), 0), t);
1006
+ }
1007
+ function D(e, t) {
1008
+ let n = E(t.start, e.length), r = E(t.end, e.length);
1009
+ return n <= r ? {
1010
+ start: n,
1011
+ end: r
1012
+ } : {
1013
+ start: r,
1014
+ end: n
1015
+ };
1016
+ }
1017
+ function O(e) {
1018
+ return m[e] ?? m.en;
1019
+ }
1020
+ function k(e, t) {
1021
+ return t <= 0 ? 0 : e.lastIndexOf("\n", t - 1) + 1;
1022
+ }
1023
+ function A(e, t) {
1024
+ let n = k(e, t.start), r = t.end > t.start && e[t.end - 1] === "\n" ? t.end - 1 : t.end, i = e.indexOf("\n", r), a = i === -1 ? e.length : i, o = [], s = n;
1025
+ for (;;) {
1026
+ let t = e.indexOf("\n", s), n = t === -1 || t > a ? a : t;
1027
+ if (o.push({
1028
+ start: s,
1029
+ end: n,
1030
+ text: e.slice(s, n)
1031
+ }), n >= a) break;
1032
+ s = n + 1;
1033
+ }
1034
+ return o;
1035
+ }
1036
+ function j(e, t, n) {
1037
+ if (n.length === 0) return {
1038
+ value: e,
1039
+ selection: t
1040
+ };
1041
+ let r = [...n].sort((e, t) => e.start - t.start), i = 0, a = r.map((e) => {
1042
+ let t = e.start + i, n = i;
1043
+ return i += e.text.length - (e.end - e.start), {
1044
+ edit: e,
1045
+ newStart: t,
1046
+ deltaBefore: n
1047
+ };
1048
+ }), o = "", s = 0;
1049
+ for (let t of a) o += e.slice(s, t.edit.start), o += t.edit.text, s = t.edit.end;
1050
+ o += e.slice(s);
1051
+ let c = (e) => {
1052
+ for (let t of a) {
1053
+ let { edit: n, newStart: r, deltaBefore: i } = t;
1054
+ if (e < n.start) return e + i;
1055
+ if (e <= n.end) {
1056
+ let t = e - n.start, i = t <= n.oldPrefixLength ? n.newPrefixLength : t + (n.newPrefixLength - n.oldPrefixLength);
1057
+ return r + Math.min(Math.max(i, 0), n.text.length);
1058
+ }
1059
+ }
1060
+ return e + i;
1061
+ };
1062
+ return {
1063
+ value: o,
1064
+ selection: {
1065
+ start: c(t.start),
1066
+ end: c(t.end)
1067
+ }
1068
+ };
1069
+ }
1070
+ function M(e, t, n, r) {
1071
+ return t === e.text ? null : {
1072
+ start: e.start,
1073
+ end: e.end,
1074
+ text: t,
1075
+ oldPrefixLength: n,
1076
+ newPrefixLength: r
1077
+ };
1078
+ }
1079
+ function N(e, t, n, r) {
1080
+ return n === "*" ? r ? e[t.start - 1] !== "*" && e[t.end] !== "*" : e[t.start - n.length - 1] !== "*" && e[t.end + n.length] !== "*" : !0;
1081
+ }
1082
+ function P(e, t, n, r) {
1083
+ let i = D(e, t), a = n.length, { start: o, end: s } = i, c = e.slice(o, s);
1084
+ if (o !== s) {
1085
+ if (c.length >= a * 2 && c.startsWith(n) && c.endsWith(n) && (n !== "*" || !c.startsWith("**") && !c.endsWith("**")) && N(e, i, n, !0)) {
1086
+ let t = c.slice(a, c.length - a);
1087
+ return {
1088
+ value: e.slice(0, o) + t + e.slice(s),
1089
+ selection: {
1090
+ start: o,
1091
+ end: o + t.length
1092
+ }
1093
+ };
1094
+ }
1095
+ let t = o - a, r = s + a;
1096
+ return t >= 0 && r <= e.length && e.slice(t, o) === n && e.slice(s, r) === n && N(e, i, n, !1) ? {
1097
+ value: e.slice(0, t) + c + e.slice(r),
1098
+ selection: {
1099
+ start: t,
1100
+ end: t + c.length
1101
+ }
1102
+ } : {
1103
+ value: e.slice(0, o) + n + c + n + e.slice(s),
1104
+ selection: {
1105
+ start: o + a,
1106
+ end: s + a
1107
+ }
1108
+ };
1109
+ }
1110
+ let l = n + r + n;
1111
+ return {
1112
+ value: e.slice(0, o) + l + e.slice(s),
1113
+ selection: {
1114
+ start: o + a,
1115
+ end: o + a + r.length
1116
+ }
1117
+ };
1118
+ }
1119
+ function re(e, t, n = "en") {
1120
+ return P(e, t, "**", O(n).boldPlaceholder);
1121
+ }
1122
+ function F(e, t, n = "en") {
1123
+ return P(e, t, "*", O(n).italicPlaceholder);
1124
+ }
1125
+ function I(e, t, n = "en") {
1126
+ return P(e, t, "~~", O(n).strikePlaceholder);
1127
+ }
1128
+ function L(e) {
1129
+ let t = 0;
1130
+ for (let n of e.match(/`+/g) ?? []) t = Math.max(t, n.length);
1131
+ return t;
1132
+ }
1133
+ function R(e, t, n) {
1134
+ let r = 0;
1135
+ for (; e[t] === "`";) r += 1, t += n;
1136
+ return r;
1137
+ }
1138
+ function ie(e, t) {
1139
+ let { start: n, end: r } = t, i = e.slice(n, r), a = R(e, n - 1, -1), o = R(e, r, 1), s = a > 0 && a === o ? {
1140
+ run: a,
1141
+ padding: 0
1142
+ } : null, c = R(e, n - 2, -1), l = R(e, r + 1, 1), u = e[n - 1] === " " && e[r] === " " && c > 0 && c === l ? {
1143
+ run: c,
1144
+ padding: 1
1145
+ } : null, d = s ?? u;
1146
+ return !d || L(i) >= d.run ? null : d;
1147
+ }
1148
+ function ae(e, t, n = "en") {
1149
+ let r = D(e, t), { start: i, end: a } = r, o = e.slice(i, a);
1150
+ if (i === a) {
1151
+ let t = O(n).inlineCodePlaceholder, r = `\`${t}\``;
1152
+ return {
1153
+ value: e.slice(0, i) + r + e.slice(a),
1154
+ selection: {
1155
+ start: i + 1,
1156
+ end: i + 1 + t.length
1157
+ }
1158
+ };
1159
+ }
1160
+ let s = R(o, 0, 1), c = R(o, o.length - 1, -1);
1161
+ if (s > 0 && s === c && o.length >= s * 2 && L(o.slice(s, o.length - s)) < s) {
1162
+ let t = o.slice(s, o.length - s);
1163
+ return t.startsWith(" ") && t.endsWith(" ") && t.trim().length > 0 && (t = t.slice(1, -1)), {
1164
+ value: e.slice(0, i) + t + e.slice(a),
1165
+ selection: {
1166
+ start: i,
1167
+ end: i + t.length
1168
+ }
1169
+ };
1170
+ }
1171
+ let l = ie(e, r);
1172
+ if (l) {
1173
+ let t = l.run + l.padding;
1174
+ return {
1175
+ value: e.slice(0, i - t) + o + e.slice(a + t),
1176
+ selection: {
1177
+ start: i - t,
1178
+ end: i - t + o.length
1179
+ }
1180
+ };
1181
+ }
1182
+ let u = "`".repeat(L(o) + 1), d = /^[` ]|[` ]$/.test(o) ? " " : "", f = u + d;
1183
+ return {
1184
+ value: e.slice(0, i) + f + o + d + u + e.slice(a),
1185
+ selection: {
1186
+ start: i + f.length,
1187
+ end: i + f.length + o.length
1188
+ }
1189
+ };
1190
+ }
1191
+ var z = /^(#{1,6})[ \t]+/;
1192
+ function oe(e, t, n) {
1193
+ let r = D(e, t), i = [];
1194
+ for (let t of A(e, r)) {
1195
+ let e = z.exec(t.text), r = e ? e[0].length : 0;
1196
+ if (n === 0 && !e) continue;
1197
+ let a = t.text.slice(r), o = n === 0 ? "" : `${"#".repeat(n)} `, s = M(t, o + a, r, o.length);
1198
+ s && i.push(s);
1199
+ }
1200
+ return j(e, r, i);
1201
+ }
1202
+ var B = /^([ \t]*)([-*+] )/, V = /^([ \t]*)(\d+[.)] )/, H = /^([ \t]*)([-*+] \[[ xX]\] )/, U = /^([ \t]*)(> ?)/;
1203
+ function W(e, t) {
1204
+ let n = t.exec(e);
1205
+ if (!n) return null;
1206
+ let r = n[1] ?? "", i = n[2] ?? "";
1207
+ return {
1208
+ indent: r,
1209
+ prefix: i,
1210
+ prefixLength: r.length + i.length
1211
+ };
1212
+ }
1213
+ function G(e) {
1214
+ let t = /^[ \t]*/.exec(e);
1215
+ return t ? t[0] : "";
1216
+ }
1217
+ function K(e, t, n, r) {
1218
+ let i = D(e, t), a = A(e, i), o = a.map((e) => n(e.text)), s = 0, c = !0;
1219
+ for (let e = 0; e < a.length; e += 1) {
1220
+ let t = a[e];
1221
+ (o[e] || t.text.trim().length > 0) && (s += 1, o[e] || (c = !1));
1222
+ }
1223
+ let l = s > 0 && c, u = [];
1224
+ for (let e = 0; e < a.length; e += 1) {
1225
+ let t = a[e], n = o[e] ?? null;
1226
+ if (l) {
1227
+ if (!n) continue;
1228
+ let e = M(t, n.indent + t.text.slice(n.prefixLength), n.prefixLength, n.indent.length);
1229
+ e && u.push(e);
1230
+ continue;
1231
+ }
1232
+ let i = n ? n.indent : G(t.text), s = t.text.slice(n ? n.prefixLength : i.length), c = r(i, e + 1), d = M(t, i + c + s, n ? n.prefixLength : i.length, i.length + c.length);
1233
+ d && u.push(d);
1234
+ }
1235
+ return j(e, i, u);
1236
+ }
1237
+ function q(e, t) {
1238
+ return K(e, t, (e) => W(e, B), () => "- ");
1239
+ }
1240
+ function se(e, t) {
1241
+ return K(e, t, (e) => W(e, V), (e, t) => `${t}. `);
1242
+ }
1243
+ function ce(e, t) {
1244
+ return K(e, t, (e) => W(e, H), () => "- [ ] ");
1245
+ }
1246
+ function le(e, t) {
1247
+ return K(e, t, (e) => W(e, U), () => "> ");
1248
+ }
1249
+ function ue(e, t) {
1250
+ let n = D(e, t);
1251
+ return j(e, n, A(e, n).map((e) => ({
1252
+ start: e.start,
1253
+ end: e.end,
1254
+ text: ` ${e.text}`,
1255
+ oldPrefixLength: 0,
1256
+ newPrefixLength: 2
1257
+ })));
1258
+ }
1259
+ function de(e) {
1260
+ if (e.startsWith(" ")) return {
1261
+ text: e.slice(1),
1262
+ removed: 1
1263
+ };
1264
+ let t = 0;
1265
+ for (; t < 2 && e[t] === " ";) t += 1;
1266
+ return {
1267
+ text: e.slice(t),
1268
+ removed: t
1269
+ };
1270
+ }
1271
+ function fe(e, t) {
1272
+ let n = D(e, t), r = [];
1273
+ for (let t of A(e, n)) {
1274
+ let e = de(t.text);
1275
+ if (e.removed === 0) continue;
1276
+ let n = M(t, e.text, e.removed, 0);
1277
+ n && r.push(n);
1278
+ }
1279
+ return j(e, n, r);
1280
+ }
1281
+ function pe(e, t, n = "en") {
1282
+ let { start: r, end: i } = D(e, t), a = e.slice(r, i), o = "https://example.com";
1283
+ if (a.length > 0) {
1284
+ let t = `[${a}](${o})`, n = r + 1 + a.length + 2;
1285
+ return {
1286
+ value: e.slice(0, r) + t + e.slice(i),
1287
+ selection: {
1288
+ start: n,
1289
+ end: n + 19
1290
+ }
1291
+ };
1292
+ }
1293
+ let s = O(n).linkText, c = `[${s}](${o})`;
1294
+ return {
1295
+ value: e.slice(0, r) + c + e.slice(i),
1296
+ selection: {
1297
+ start: r + 1,
1298
+ end: r + 1 + s.length
1299
+ }
1300
+ };
1301
+ }
1302
+ function me(e, t, n = "en") {
1303
+ let { start: r, end: i } = D(e, t), a = e.slice(r, i), o = "images/example.png";
1304
+ if (a.length > 0) {
1305
+ let t = `![${a}](${o})`, n = r + 2 + a.length + 2;
1306
+ return {
1307
+ value: e.slice(0, r) + t + e.slice(i),
1308
+ selection: {
1309
+ start: n,
1310
+ end: n + 18
1311
+ }
1312
+ };
1313
+ }
1314
+ let s = O(n).imageAlt, c = `![${s}](${o})`;
1315
+ return {
1316
+ value: e.slice(0, r) + c + e.slice(i),
1317
+ selection: {
1318
+ start: r + 2,
1319
+ end: r + 2 + s.length
1320
+ }
1321
+ };
1322
+ }
1323
+ function he(e, t, n = "en") {
1324
+ let r = D(e, t), i = e.slice(r.start, r.end), a = i.length > 0 ? i : O(n).codeBlockPlaceholder, o = "`".repeat(Math.max(3, L(a) + 1)), s = `${o}text\n`;
1325
+ return Y(e, r, `${s}${a}\n${o}`, {
1326
+ start: s.length,
1327
+ end: s.length + a.length
1328
+ });
1329
+ }
1330
+ function ge(e) {
1331
+ return [
1332
+ `| ${e.tableHeaders.join(" | ")} |`,
1333
+ `| ${e.tableHeaders.map(() => "---").join(" | ")} |`,
1334
+ ...e.tableRows.map((e) => `| ${e.join(" | ")} |`)
1335
+ ].join("\n");
1336
+ }
1337
+ function J(e, t) {
1338
+ let n = k(e, t.start), r = e.slice(n, t.start), i = e.indexOf("\n", t.end), a = i === -1 ? e.length : i, o = e.slice(t.end, a), s = "";
1339
+ if (/\S/.test(r)) s = "\n\n";
1340
+ else if (n > 0) {
1341
+ let t = k(e, n - 1);
1342
+ /\S/.test(e.slice(t, n - 1)) && (s = "\n");
1343
+ }
1344
+ return {
1345
+ prefix: s,
1346
+ suffix: /\S/.test(o) ? "\n\n" : ""
1347
+ };
1348
+ }
1349
+ function Y(e, t, n, r) {
1350
+ let { prefix: i, suffix: a } = J(e, t), o = t.start + i.length;
1351
+ return {
1352
+ value: e.slice(0, t.start) + i + n + a + e.slice(t.end),
1353
+ selection: {
1354
+ start: o + r.start,
1355
+ end: o + r.end
1356
+ }
1357
+ };
1358
+ }
1359
+ function _e(e, t, n = "en") {
1360
+ let r = D(e, t), i = O(n), a = ge(i), o = i.tableRows[0][0], s = a.indexOf(o);
1361
+ return Y(e, r, a, {
1362
+ start: s,
1363
+ end: s + o.length
1364
+ });
1365
+ }
1366
+ function ve(e, t) {
1367
+ return Y(e, D(e, t), "---", {
1368
+ start: 3,
1369
+ end: 3
1370
+ });
1371
+ }
1372
+ function ye(e, t, n) {
1373
+ let r = D(e, t), i = r.start + n.length;
1374
+ return {
1375
+ value: e.slice(0, r.start) + n + e.slice(r.end),
1376
+ selection: {
1377
+ start: i,
1378
+ end: i
1379
+ }
1380
+ };
1381
+ }
1382
+ var X = /\{\{(selection(?::[^{}]*)?|caret|select:[^{}]*)\}\}/g;
1383
+ function be(e, t) {
1384
+ let n = "", r = 0, i = null, a = null, o = null;
1385
+ X.lastIndex = 0;
1386
+ for (let s = X.exec(e); s; s = X.exec(e)) {
1387
+ let c = s.index;
1388
+ n += e.slice(r, c), r = c + s[0].length;
1389
+ let l = s[1] ?? "";
1390
+ if (l === "selection") n += t;
1391
+ else if (l.startsWith("selection:")) {
1392
+ let e = l.slice(10);
1393
+ if (t.length > 0) n += t;
1394
+ else {
1395
+ let t = n.length;
1396
+ n += e, a ||= {
1397
+ start: t,
1398
+ end: n.length
1399
+ };
1400
+ }
1401
+ } else if (l === "caret") o === null && (o = n.length);
1402
+ else if (l.startsWith("select:")) {
1403
+ let e = l.slice(7), t = n.length;
1404
+ n += e, i ||= {
1405
+ start: t,
1406
+ end: n.length
1407
+ };
1408
+ } else n += s[0];
1409
+ }
1410
+ return n += e.slice(r), {
1411
+ text: n,
1412
+ select: i,
1413
+ fallback: a,
1414
+ caret: o
1415
+ };
1416
+ }
1417
+ function xe(e, t, n, r = {}) {
1418
+ let i = D(e, t), a = be(n, e.slice(i.start, i.end)), o = r.block === !0 && a.text.length > 0 ? J(e, i) : {
1419
+ prefix: "",
1420
+ suffix: ""
1421
+ }, s = i.start + o.prefix.length, c;
1422
+ return c = a.select ? {
1423
+ start: s + a.select.start,
1424
+ end: s + a.select.end
1425
+ } : a.fallback ? {
1426
+ start: s + a.fallback.start,
1427
+ end: s + a.fallback.end
1428
+ } : a.caret === null ? {
1429
+ start: s + a.text.length,
1430
+ end: s + a.text.length
1431
+ } : {
1432
+ start: s + a.caret,
1433
+ end: s + a.caret
1434
+ }, {
1435
+ value: e.slice(0, i.start) + o.prefix + a.text + o.suffix + e.slice(i.end),
1436
+ selection: c
1437
+ };
1438
+ }
1439
+ function Z(e, t) {
1440
+ let n = [], r = 0;
1441
+ for (; r < e.length;) {
1442
+ if (e[r] !== t) {
1443
+ r += 1;
1444
+ continue;
1445
+ }
1446
+ let i = r;
1447
+ for (; e[r] === t;) r += 1;
1448
+ n.push({
1449
+ start: i,
1450
+ end: r,
1451
+ length: r - i
1452
+ });
1453
+ }
1454
+ return n;
1455
+ }
1456
+ function Q(e, t) {
1457
+ if (t === "inlineCode") return Z(e, "`");
1458
+ let n = Z(e, t === "strike" ? "~" : "*");
1459
+ return t === "italic" ? n.filter((e) => e.length % 2 == 1) : n.filter((e) => e.length >= 2);
1460
+ }
1461
+ function Se(e, t, n) {
1462
+ return e >= t ? !1 : n.some((r) => r.start === e && n.some((e) => e.end === t && e.length === r.length && e.start >= r.end));
1463
+ }
1464
+ function Ce(e, t, n) {
1465
+ return e >= t ? !1 : n.some((r) => r.end === e && n.some((e) => e.start === t && e.length === r.length && e.start >= r.end));
1466
+ }
1467
+ function we(e, t) {
1468
+ let n = 0;
1469
+ for (; n < t.length;) {
1470
+ let r = t[n], i = n + 1;
1471
+ for (; i < t.length && t[i].length !== r.length;) i += 1;
1472
+ let a = t[i];
1473
+ if (!a) n += 1;
1474
+ else {
1475
+ if (e >= r.end && e <= a.start) return !0;
1476
+ n = i + 1;
1477
+ }
1478
+ }
1479
+ return !1;
1480
+ }
1481
+ function $(e, t, n, r) {
1482
+ if (t.start !== t.end) {
1483
+ let n = Q(e, r);
1484
+ return Se(t.start, t.end, n) || Ce(t.start, t.end, n);
1485
+ }
1486
+ return we(Math.min(Math.max(t.start - n.start, 0), n.text.length), Q(n.text, r).filter((e) => e.start >= Te(n.text)));
1487
+ }
1488
+ function Te(e) {
1489
+ let t = 0;
1490
+ for (;;) {
1491
+ let n = e.slice(t), r = W(n, H) ?? W(n, B) ?? W(n, V) ?? W(n, U);
1492
+ if (!r) return t;
1493
+ t += r.prefixLength;
1494
+ }
1495
+ }
1496
+ function Ee(e) {
1497
+ return W(e, H) ? "task" : W(e, B) ? "bullet" : W(e, V) ? "ordered" : null;
1498
+ }
1499
+ function De(e, t) {
1500
+ let n = D(e, t), r = A(e, {
1501
+ start: n.start,
1502
+ end: n.start
1503
+ })[0], i = r.text, a = z.exec(i);
1504
+ return {
1505
+ headingLevel: a ? a[1].length : 0,
1506
+ bold: $(e, n, r, "bold"),
1507
+ italic: $(e, n, r, "italic"),
1508
+ strike: $(e, n, r, "strike"),
1509
+ inlineCode: $(e, n, r, "inlineCode"),
1510
+ list: Ee(i),
1511
+ quote: W(i, U) !== null
1512
+ };
1513
+ }
1514
+ export { f as EXTENDED_NATIVE_COMPONENTS, p as EXTENDED_NATIVE_COMPONENT_COPY_ZH, s as LOCAL_COMPONENTS, i as LOCAL_COMPONENT_NAMES, _ as NATIVE_COMPONENTS, x as NATIVE_COMPONENTS_ZH, g as NATIVE_COMPONENT_GROUPS, b as NATIVE_COMPONENT_GROUPS_ZH, d as analyzeLocalSource, e as closestName, l as completeLocalSource, re as formatBold, q as formatBulletList, oe as formatHeading, ae as formatInlineCode, F as formatItalic, u as formatLocalSource, se as formatOrderedList, le as formatQuote, I as formatStrike, ce as formatTaskList, o as getLocalComponent, ne as getNativeComponentCatalog, a as getPropDefault, ue as indentSelection, he as insertCodeBlock, ve as insertDivider, me as insertImage, pe as insertLink, _e as insertTable, xe as insertTemplate, ye as insertText, n as localComponentNames, fe as outdentSelection, De as readFormatState, c as renameLocalBinding, T as renderNativeSnippet, t as suggestAttribute, r as suggestComponent };