@agilehub/agile-editor 1.6.0 → 1.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.
@@ -1,9 +1,9 @@
1
- declare var __VLS_23: {
1
+ declare var __VLS_28: {
2
2
  nodeType: any;
3
3
  nodeAttrs: any;
4
4
  };
5
5
  type __VLS_Slots = {} & {
6
- bubble_menu?: (props: typeof __VLS_23) => any;
6
+ bubble_menu?: (props: typeof __VLS_28) => any;
7
7
  };
8
8
  declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
9
9
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -149,7 +149,8 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
149
149
  page: string;
150
150
  view: string;
151
151
  export: string;
152
- copyediting: string;
152
+ extension: string;
153
+ enhancement: string;
153
154
  };
154
155
  base: {
155
156
  align: {
@@ -412,12 +413,18 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
412
413
  mention: string;
413
414
  bookmark: {
414
415
  text: string;
416
+ title: string;
417
+ "edit-title": string;
418
+ note: string;
415
419
  set: string;
416
420
  ok: string;
421
+ confirm: string;
422
+ cancel: string;
417
423
  textName: string;
418
424
  placeholder: string;
419
425
  show: string;
420
426
  actions: string;
427
+ edit: string;
421
428
  delete: string;
422
429
  emptyError: string;
423
430
  };
@@ -1409,7 +1416,8 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
1409
1416
  page: string;
1410
1417
  view: string;
1411
1418
  export: string;
1412
- copyediting: string;
1419
+ extension: string;
1420
+ enhancement: string;
1413
1421
  };
1414
1422
  base: {
1415
1423
  align: {
@@ -1672,12 +1680,18 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
1672
1680
  mention: string;
1673
1681
  bookmark: {
1674
1682
  text: string;
1683
+ title: string;
1684
+ "edit-title": string;
1685
+ note: string;
1675
1686
  set: string;
1676
1687
  ok: string;
1688
+ confirm: string;
1689
+ cancel: string;
1677
1690
  textName: string;
1678
1691
  placeholder: string;
1679
1692
  show: string;
1680
1693
  actions: string;
1694
+ edit: string;
1681
1695
  delete: string;
1682
1696
  emptyError: string;
1683
1697
  };
@@ -2661,7 +2675,8 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
2661
2675
  page: string;
2662
2676
  view: string;
2663
2677
  export: string;
2664
- copyediting: string;
2678
+ extension: string;
2679
+ enhancement: string;
2665
2680
  };
2666
2681
  base: {
2667
2682
  align: {
@@ -2924,12 +2939,18 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
2924
2939
  mention: string;
2925
2940
  bookmark: {
2926
2941
  text: string;
2942
+ title: string;
2943
+ "edit-title": string;
2944
+ note: string;
2927
2945
  set: string;
2928
2946
  ok: string;
2947
+ confirm: string;
2948
+ cancel: string;
2929
2949
  textName: string;
2930
2950
  placeholder: string;
2931
2951
  show: string;
2932
2952
  actions: string;
2953
+ edit: string;
2933
2954
  delete: string;
2934
2955
  emptyError: string;
2935
2956
  };
@@ -3826,6 +3847,11 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
3826
3847
  * @returns 无返回值。
3827
3848
  */
3828
3849
  setReadOnly(readOnly?: boolean): void;
3850
+ /**
3851
+ * 切换内容预览模式;预览时自动只读并隐藏编辑工具栏。
3852
+ * @param preview - true 进入预览,false 返回编辑状态。
3853
+ */
3854
+ setPreview(preview?: boolean): void;
3829
3855
  print: () => void;
3830
3856
  focus: (position?: string, options?: {
3831
3857
  scrollIntoView: boolean;
@@ -3864,6 +3890,7 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
3864
3890
  saved: (...args: any[]) => void;
3865
3891
  blur: (...args: any[]) => void;
3866
3892
  focus: (...args: any[]) => void;
3893
+ drop: (...args: any[]) => void;
3867
3894
  beforeCreate: (...args: any[]) => void;
3868
3895
  created: (...args: any[]) => void;
3869
3896
  changed: (...args: any[]) => void;
@@ -3883,7 +3910,6 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
3883
3910
  "changed:locale": (...args: any[]) => void;
3884
3911
  "changed:theme": (...args: any[]) => void;
3885
3912
  "changed:skin": (...args: any[]) => void;
3886
- drop: (...args: any[]) => void;
3887
3913
  destroy: (...args: any[]) => void;
3888
3914
  }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
3889
3915
  onPrint?: (...args: any[]) => any;
@@ -3892,6 +3918,7 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
3892
3918
  onSaved?: (...args: any[]) => any;
3893
3919
  onBlur?: (...args: any[]) => any;
3894
3920
  onFocus?: (...args: any[]) => any;
3921
+ onDrop?: (...args: any[]) => any;
3895
3922
  onBeforeCreate?: (...args: any[]) => any;
3896
3923
  onCreated?: (...args: any[]) => any;
3897
3924
  onChanged?: (...args: any[]) => any;
@@ -3911,7 +3938,6 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
3911
3938
  "onChanged:locale"?: (...args: any[]) => any;
3912
3939
  "onChanged:theme"?: (...args: any[]) => any;
3913
3940
  "onChanged:skin"?: (...args: any[]) => any;
3914
- onDrop?: (...args: any[]) => any;
3915
3941
  onDestroy?: (...args: any[]) => any;
3916
3942
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3917
3943
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -0,0 +1,24 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<globalThis.ExtractPropTypes<{
2
+ dialogOnly: {
3
+ type: BooleanConstructor;
4
+ default: boolean;
5
+ };
6
+ triggerOnly: {
7
+ type: BooleanConstructor;
8
+ default: boolean;
9
+ };
10
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<globalThis.ExtractPropTypes<{
11
+ dialogOnly: {
12
+ type: BooleanConstructor;
13
+ default: boolean;
14
+ };
15
+ triggerOnly: {
16
+ type: BooleanConstructor;
17
+ default: boolean;
18
+ };
19
+ }>> & Readonly<{}>, {
20
+ dialogOnly: boolean;
21
+ triggerOnly: boolean;
22
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -184,12 +184,12 @@ declare const __VLS_export: import("vue").DefineComponent<globalThis.ExtractProp
184
184
  layout: "page" | "web";
185
185
  autoWidth: boolean;
186
186
  laserPointer: boolean;
187
+ floating: boolean;
187
188
  visible: boolean;
188
189
  zoomLevel: number;
189
190
  attach: PreviewToolbarAttach;
190
191
  minZoom: number;
191
192
  maxZoom: number;
192
- floating: boolean;
193
193
  drawingTarget: PreviewDrawingTarget;
194
194
  drawingColor: string;
195
195
  drawingWidth: number;
@@ -1,29 +1,37 @@
1
- import type { PropType } from "vue";
1
+ import type { PropType } from 'vue';
2
2
  declare var __VLS_172: {
3
3
  toolbarMode: string;
4
- }, __VLS_274: {
4
+ }, __VLS_279: {
5
5
  toolbarMode: string;
6
- }, __VLS_386: {
6
+ }, __VLS_391: {
7
7
  toolbarMode: string;
8
- }, __VLS_443: {
8
+ }, __VLS_448: {
9
9
  toolbarMode: string;
10
10
  }, __VLS_490: {
11
11
  toolbarMode: string;
12
12
  }, __VLS_492: {
13
13
  toolbarMode: string;
14
+ }, __VLS_494: {
15
+ toolbarMode: string;
16
+ }, __VLS_496: {
17
+ toolbarMode: string;
14
18
  };
15
19
  type __VLS_Slots = {} & {
16
20
  toolbar_base?: (props: typeof __VLS_172) => any;
17
21
  } & {
18
- toolbar_insert?: (props: typeof __VLS_274) => any;
22
+ toolbar_insert?: (props: typeof __VLS_279) => any;
19
23
  } & {
20
- toolbar_table?: (props: typeof __VLS_386) => any;
24
+ toolbar_table?: (props: typeof __VLS_391) => any;
21
25
  } & {
22
- toolbar_tools?: (props: typeof __VLS_443) => any;
26
+ toolbar_tools?: (props: typeof __VLS_448) => any;
23
27
  } & {
24
28
  toolbar_view?: (props: typeof __VLS_490) => any;
25
29
  } & {
26
- toolbar_copyediting?: (props: typeof __VLS_492) => any;
30
+ toolbar_review?: (props: typeof __VLS_492) => any;
31
+ } & {
32
+ toolbar_extension?: (props: typeof __VLS_494) => any;
33
+ } & {
34
+ toolbar_enhancement?: (props: typeof __VLS_496) => any;
27
35
  };
28
36
  declare const __VLS_base: import("vue").DefineComponent<globalThis.ExtractPropTypes<{
29
37
  menus: {
@@ -1,29 +1,37 @@
1
- import type { PropType } from "vue";
1
+ import type { PropType } from 'vue';
2
2
  declare var __VLS_173: {
3
3
  toolbarMode: string;
4
- }, __VLS_275: {
4
+ }, __VLS_280: {
5
5
  toolbarMode: string;
6
- }, __VLS_387: {
6
+ }, __VLS_392: {
7
7
  toolbarMode: string;
8
- }, __VLS_444: {
8
+ }, __VLS_449: {
9
9
  toolbarMode: string;
10
10
  }, __VLS_491: {
11
11
  toolbarMode: string;
12
12
  }, __VLS_493: {
13
13
  toolbarMode: string;
14
+ }, __VLS_495: {
15
+ toolbarMode: string;
16
+ }, __VLS_497: {
17
+ toolbarMode: string;
14
18
  };
15
19
  type __VLS_Slots = {} & {
16
20
  toolbar_base?: (props: typeof __VLS_173) => any;
17
21
  } & {
18
- toolbar_insert?: (props: typeof __VLS_275) => any;
22
+ toolbar_insert?: (props: typeof __VLS_280) => any;
19
23
  } & {
20
- toolbar_table?: (props: typeof __VLS_387) => any;
24
+ toolbar_table?: (props: typeof __VLS_392) => any;
21
25
  } & {
22
- toolbar_tools?: (props: typeof __VLS_444) => any;
26
+ toolbar_tools?: (props: typeof __VLS_449) => any;
23
27
  } & {
24
28
  toolbar_view?: (props: typeof __VLS_491) => any;
25
29
  } & {
26
- toolbar_copyediting?: (props: typeof __VLS_493) => any;
30
+ toolbar_review?: (props: typeof __VLS_493) => any;
31
+ } & {
32
+ toolbar_extension?: (props: typeof __VLS_495) => any;
33
+ } & {
34
+ toolbar_enhancement?: (props: typeof __VLS_497) => any;
27
35
  };
28
36
  declare const __VLS_base: import("vue").DefineComponent<globalThis.ExtractPropTypes<{
29
37
  menus: {
@@ -105,7 +105,8 @@ export declare const useI18n: () => import("vue-i18n").Composer<{
105
105
  page: string;
106
106
  view: string;
107
107
  export: string;
108
- copyediting: string;
108
+ extension: string;
109
+ enhancement: string;
109
110
  };
110
111
  base: {
111
112
  align: {
@@ -368,12 +369,18 @@ export declare const useI18n: () => import("vue-i18n").Composer<{
368
369
  mention: string;
369
370
  bookmark: {
370
371
  text: string;
372
+ title: string;
373
+ "edit-title": string;
374
+ note: string;
371
375
  set: string;
372
376
  ok: string;
377
+ confirm: string;
378
+ cancel: string;
373
379
  textName: string;
374
380
  placeholder: string;
375
381
  show: string;
376
382
  actions: string;
383
+ edit: string;
377
384
  delete: string;
378
385
  emptyError: string;
379
386
  };
@@ -1365,7 +1372,8 @@ export declare const useI18n: () => import("vue-i18n").Composer<{
1365
1372
  page: string;
1366
1373
  view: string;
1367
1374
  export: string;
1368
- copyediting: string;
1375
+ extension: string;
1376
+ enhancement: string;
1369
1377
  };
1370
1378
  base: {
1371
1379
  align: {
@@ -1628,12 +1636,18 @@ export declare const useI18n: () => import("vue-i18n").Composer<{
1628
1636
  mention: string;
1629
1637
  bookmark: {
1630
1638
  text: string;
1639
+ title: string;
1640
+ "edit-title": string;
1641
+ note: string;
1631
1642
  set: string;
1632
1643
  ok: string;
1644
+ confirm: string;
1645
+ cancel: string;
1633
1646
  textName: string;
1634
1647
  placeholder: string;
1635
1648
  show: string;
1636
1649
  actions: string;
1650
+ edit: string;
1637
1651
  delete: string;
1638
1652
  emptyError: string;
1639
1653
  };
@@ -2617,7 +2631,8 @@ export declare const useI18n: () => import("vue-i18n").Composer<{
2617
2631
  page: string;
2618
2632
  view: string;
2619
2633
  export: string;
2620
- copyediting: string;
2634
+ extension: string;
2635
+ enhancement: string;
2621
2636
  };
2622
2637
  base: {
2623
2638
  align: {
@@ -2880,12 +2895,18 @@ export declare const useI18n: () => import("vue-i18n").Composer<{
2880
2895
  mention: string;
2881
2896
  bookmark: {
2882
2897
  text: string;
2898
+ title: string;
2899
+ "edit-title": string;
2900
+ note: string;
2883
2901
  set: string;
2884
2902
  ok: string;
2903
+ confirm: string;
2904
+ cancel: string;
2885
2905
  textName: string;
2886
2906
  placeholder: string;
2887
2907
  show: string;
2888
2908
  actions: string;
2909
+ edit: string;
2889
2910
  delete: string;
2890
2911
  emptyError: string;
2891
2912
  };
@@ -1,9 +1,12 @@
1
- /**
2
- * 插件作用:提供书签标记,记录文档中的定位点。
3
- * 使用方法:注册扩展后通过书签相关命令添加或移除。
4
- * 注意事项:书签标识应保持唯一,避免定位到错误位置。
5
- */
6
1
  import { Mark } from '@tiptap/core';
2
+ /** 同时匹配编辑器书签标签和 DOCX 导入的无链接锚点书签。 */
3
+ export declare const queryBookmarkElements: (root: ParentNode) => Element[];
4
+ /** 读取书签名称,兼容 HTML 属性大小写和 DOCX 导入的 id 字段。 */
5
+ export declare const getBookmarkName: (element: Element) => string;
6
+ /** 在指定 DOM 根节点中按名称查找书签,返回首个匹配项。 */
7
+ export declare const findBookmarkElement: (root: ParentNode, bookmarkName: string) => Element;
8
+ /** 读取书签备注;导入锚点未设置备注时回退到正文文字。 */
9
+ export declare const getBookmarkNote: (element: Element) => string;
7
10
  declare const _default: Mark<{
8
11
  bookmarkName: string;
9
12
  class: string;
@@ -92,7 +92,8 @@ export declare const i18n: import("vue-i18n").I18n<{
92
92
  page: string;
93
93
  view: string;
94
94
  export: string;
95
- copyediting: string;
95
+ extension: string;
96
+ enhancement: string;
96
97
  };
97
98
  base: {
98
99
  align: {
@@ -355,12 +356,18 @@ export declare const i18n: import("vue-i18n").I18n<{
355
356
  mention: string;
356
357
  bookmark: {
357
358
  text: string;
359
+ title: string;
360
+ "edit-title": string;
361
+ note: string;
358
362
  set: string;
359
363
  ok: string;
364
+ confirm: string;
365
+ cancel: string;
360
366
  textName: string;
361
367
  placeholder: string;
362
368
  show: string;
363
369
  actions: string;
370
+ edit: string;
364
371
  delete: string;
365
372
  emptyError: string;
366
373
  };
@@ -1352,7 +1359,8 @@ export declare const i18n: import("vue-i18n").I18n<{
1352
1359
  page: string;
1353
1360
  view: string;
1354
1361
  export: string;
1355
- copyediting: string;
1362
+ extension: string;
1363
+ enhancement: string;
1356
1364
  };
1357
1365
  base: {
1358
1366
  align: {
@@ -1615,12 +1623,18 @@ export declare const i18n: import("vue-i18n").I18n<{
1615
1623
  mention: string;
1616
1624
  bookmark: {
1617
1625
  text: string;
1626
+ title: string;
1627
+ "edit-title": string;
1628
+ note: string;
1618
1629
  set: string;
1619
1630
  ok: string;
1631
+ confirm: string;
1632
+ cancel: string;
1620
1633
  textName: string;
1621
1634
  placeholder: string;
1622
1635
  show: string;
1623
1636
  actions: string;
1637
+ edit: string;
1624
1638
  delete: string;
1625
1639
  emptyError: string;
1626
1640
  };
@@ -2604,7 +2618,8 @@ export declare const i18n: import("vue-i18n").I18n<{
2604
2618
  page: string;
2605
2619
  view: string;
2606
2620
  export: string;
2607
- copyediting: string;
2621
+ extension: string;
2622
+ enhancement: string;
2608
2623
  };
2609
2624
  base: {
2610
2625
  align: {
@@ -2867,12 +2882,18 @@ export declare const i18n: import("vue-i18n").I18n<{
2867
2882
  mention: string;
2868
2883
  bookmark: {
2869
2884
  text: string;
2885
+ title: string;
2886
+ "edit-title": string;
2887
+ note: string;
2870
2888
  set: string;
2871
2889
  ok: string;
2890
+ confirm: string;
2891
+ cancel: string;
2872
2892
  textName: string;
2873
2893
  placeholder: string;
2874
2894
  show: string;
2875
2895
  actions: string;
2896
+ edit: string;
2876
2897
  delete: string;
2877
2898
  emptyError: string;
2878
2899
  };
@@ -1,10 +1,12 @@
1
1
  import type { FormattingOptions } from '../../utils/document-formatting';
2
+ export declare const additionalToolbarMenus: string[];
2
3
  declare const _default: {
3
4
  editorKey: string;
4
5
  locale: string;
5
6
  theme: string;
6
7
  skin: string;
7
8
  height: string;
9
+ preview: boolean;
8
10
  fullscreenZIndex: number;
9
11
  dicts: {
10
12
  fonts: ({
@@ -527,7 +527,7 @@ function onCreated({ editor }: { editor: Editor }): void {
527
527
  | ----------------------------------------------------------------------- | -------------------------------------------------------------------- |
528
528
  | `toolbar_base` | 开始工具栏追加业务组件 |
529
529
  | `toolbar_insert` | 插入工具栏追加业务组件,本例使用此插槽 |
530
- | `toolbar_table`、`toolbar_tools`、`toolbar_view`、`toolbar_copyediting` | 对应工具栏追加组件;所属菜单需要启用 |
530
+ | `toolbar_table`、`toolbar_tools`、`toolbar_view`、`toolbar_review` | 对应工具栏追加组件;所属菜单需要启用 |
531
531
  | `toolbar_actions` | 工具栏操作区域 |
532
532
  | `bubble_menu` | 编辑器浮动菜单中的自定义内容;受浮动菜单显示条件约束,不是常驻工具栏 |
533
533
  | `AgileMenuButton` | 菜单按钮,使用 `@menu-click` 执行操作 |
package/docs/api.md CHANGED
@@ -51,6 +51,7 @@ const slice = editor.state.doc.slice(from, to)
51
51
  | --- | --- | --- |
52
52
  | `saveContent(showMessage = true)` | `boolean` | 调用业务侧 `onSave`;只读模式不保存 |
53
53
  | `setReadOnly(readOnly = true)` | `boolean` | 动态切换只读状态 |
54
+ | `setPreview(preview = true)` | `boolean` | 动态切换内容预览模式,自动只读并隐藏工具栏 |
54
55
 
55
56
  保存回调参数和返回值见 [完整配置](./configuration.md#保存文档)。
56
57
 
@@ -86,6 +87,48 @@ editorRef.value.setPage({
86
87
  })
87
88
  ```
88
89
 
90
+ ## 书签
91
+
92
+ Word 导入的书签会保留为 `<a id="...">`,编辑器内部创建的书签会渲染为
93
+ `<bookmark bookmarkName="...">`。下面这些方法同时支持两种形式。
94
+
95
+ 编辑器界面可在“插入 → 插入书签”中新增备注书签。点击编辑区中的书签会显示
96
+ 备注、编辑和删除操作;备注型书签删除时会同时移除备注文字,导入书签或普通
97
+ 定位书签删除时只移除标记,原正文保留。
98
+
99
+ 书签正文不可直接在编辑区输入、删除、剪切或修改格式。所有变更必须通过书签
100
+ 编辑弹窗、书签删除按钮或对应的组件 API 完成。
101
+
102
+ | 方法 | 参数 | 返回值 | 说明 |
103
+ | --- | --- | --- | --- |
104
+ | `getAllBookmarks()` | 无 | `{ bookmarkRowId, bookmarkRowName, bookmarkRowText }[]` | 获取文档中的去重书签列表 |
105
+ | `focusBookmark(name)` | 书签名称 | `boolean` | 滚动到书签并移动光标 |
106
+ | `setBookmark(name)` | 书签名称 | `boolean` | 为当前选区添加书签 |
107
+ | `deleteBookmark(name)` | 书签名称 | `boolean` | 删除书签标记,保留原文字 |
108
+
109
+ ```ts
110
+ const bookmarks = editorRef.value.getAllBookmarks()
111
+
112
+ // 例如 DOCX 中的书签名可能是 bookmark-_Toc16808
113
+ editorRef.value.focusBookmark(bookmarks[0].bookmarkRowName)
114
+ ```
115
+
116
+ `bookmarkRowText` 是用于导航展示的可读文字。DOCX 导入书签会返回对应章节标题,
117
+ 例如 `第一章 养老金融的兴起与发展`。
118
+
119
+ 需要在编辑区显示书签标记时设置:
120
+
121
+ ```ts
122
+ const options = {
123
+ page: {
124
+ showBookmark: true,
125
+ },
126
+ }
127
+ ```
128
+
129
+ `showBookmark` 只控制编辑器书签标记的显示。DOCX 导入的锚点包含章节正文,
130
+ 其文字不会因关闭该选项而隐藏。
131
+
89
132
  ## Tiptap 实例
90
133
 
91
134
  | 方法 | 返回值 | 说明 |
@@ -38,6 +38,7 @@
38
38
  | `theme` | `'light'` | `'light'`、`'dark'`、`'auto'` |
39
39
  | `skin` | `'default'` | `'default'` 或 `'modern'` |
40
40
  | `height` | `'100%'` | 父容器必须具有明确高度 |
41
+ | `preview` | `false` | 内容预览模式,自动只读并隐藏编辑工具栏 |
41
42
  | `fullscreenZIndex` | `10` | 全屏层级 |
42
43
  | `dicts` | 内置字典 | 字体、颜色、字号、页面预设等 |
43
44
  | `toolbar` | 对象 | 工具栏模式、菜单和操作区 |
@@ -54,6 +55,62 @@
54
55
  | `diagrams` | 对象 | 绘图配置 |
55
56
  | `echarts` | 对象 | 图表配置 |
56
57
 
58
+ ## 内容预览
59
+
60
+ 通过顶层 `preview` 属性可以直接进入预览状态:
61
+
62
+ ```vue
63
+ <AgileEditor
64
+ :preview="true"
65
+ :document="{ content: html }"
66
+ />
67
+ ```
68
+
69
+ 开启后会自动:
70
+
71
+ - 设置编辑器为只读。
72
+ - 添加预览模式布局。
73
+ - 隐藏开始、插入、表格、工具等编辑工具栏。
74
+ - 保留阅读态气泡注释等只读交互。
75
+
76
+ 运行时可通过组件方法切换:
77
+
78
+ ```ts
79
+ editorRef.value.setPreview(true)
80
+ editorRef.value.setPreview(false)
81
+ ```
82
+
83
+ 业务端不需要再手动修改 `getPage().preview.enabled`。
84
+
85
+ 预览参数和编辑态工具配置是分开的。编辑态需要隐藏部分辅助功能时,仍通过
86
+ `document` 和 `page` 配置:
87
+
88
+ ```ts
89
+ const editorOptions = {
90
+ preview: false,
91
+ document: {
92
+ autofocus: false,
93
+ enableBubbleMenu: false,
94
+ enableBlockMenu: false,
95
+ },
96
+ page: {
97
+ showBookmark: false,
98
+ showBreakMarks: false,
99
+ showLineNumber: false,
100
+ showToc: false,
101
+ showAI: false,
102
+ },
103
+ }
104
+ ```
105
+
106
+ 这些配置只描述编辑态。`preview: true` 时编辑器会在内部派生预览状态并临时隐藏
107
+ 相关工具,但不会修改上述业务配置;调用 `setPreview(false)` 后会按原配置恢复。
108
+ 因此进入预览时只需要:
109
+
110
+ ```vue
111
+ <AgileEditor :preview="true" :document="{ content: html }" />
112
+ ```
113
+
57
114
  ## 文档参数
58
115
 
59
116
  ```js
@@ -39,7 +39,7 @@ import {
39
39
 
40
40
  `AgilePreviewToolbar` 不读取编辑器内部状态。业务侧通过 props 传入当前预览状态,并在事件中更新自己的状态:
41
41
 
42
- 该组件面向只读预览页面和预览弹框,右侧按钮用于隐藏工具栏。编辑器内置的演示模式工具栏是另一套组件,右侧按钮用于退出演示模式,两者用途和交互不同。
42
+ 该组件面向只读预览页面和预览弹框,右侧按钮用于隐藏工具栏。编辑器不再内置旧“演示模式”工具栏;业务端使用 `preview` 或 `setPreview()` 进入内容预览后,可按需组合 `AgilePreviewToolbar`。
43
43
 
44
44
  ```vue
45
45
  <template>
@@ -21,8 +21,12 @@ npm run dev
21
21
  ```
22
22
 
23
23
  - 默认端口:`9000`
24
- - Vite `base`:`/editor-demo`
25
- - 访问地址:`http://localhost:9000/editor-demo`
24
+ - Vite `base`:`/editor`
25
+ - 本机访问:`http://localhost:9000/editor`
26
+ - 局域网访问:启动后使用终端输出的 `Network` 地址,例如
27
+ `http://192.168.3.237:9000/editor`
28
+
29
+ 开发服务默认监听 `0.0.0.0`,同一局域网内的设备可直接访问 `Network` 地址。
26
30
 
27
31
  开发入口链路:
28
32