@ap666/office-word 0.1.5 → 0.1.7

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/README.md CHANGED
@@ -36,9 +36,101 @@ The package imports its own styles from the entry, so no extra CSS import is req
36
36
 
37
37
  - `modelValue?: JSONContent | null`
38
38
  - `editable?: boolean`
39
+ - `mode?: 'edit' | 'preview'`
40
+ - `outlinePlacement?: 'left' | 'right'`
41
+ - `messages?: Partial<Record<string, string>> | null`
42
+ - `enabledExportItems?: ('pdf' | 'html' | 'image' | 'print')[] | null`
43
+ - `enabledInsertMenuItems?: ('image' | 'video' | 'table' | 'local-file' | 'columns' | 'highlight-block' | 'date' | 'code-block' | 'formula' | 'blockquote' | 'emoji' | 'link' | 'divider' | 'countdown' | 'markdown-import')[] | null`
44
+ - `enabledToolbarActions?: ('blockquote')[] | null`
39
45
  - `placeholder?: string`
40
46
  - `collaboration?: RichTextEditorCollaborationOptions | null`
41
47
 
48
+ When these whitelist props are omitted, all built-in options stay enabled. Once you pass a list, only the listed items remain visible and usable.
49
+
50
+ ```vue
51
+ <RichTextEditor
52
+ v-model="content"
53
+ :enabled-export-items="['html', 'image']"
54
+ :enabled-insert-menu-items="['image', 'local-file', 'blockquote']"
55
+ :enabled-toolbar-actions="['blockquote']"
56
+ />
57
+ ```
58
+
59
+ The editor UI stays in Chinese by default. Use `messages` to override only the keys you need.
60
+
61
+ ```vue
62
+ <RichTextEditor
63
+ v-model="content"
64
+ :messages="{
65
+ 'insert.localFile': 'Attachment',
66
+ 'export.label': 'Download',
67
+ }"
68
+ />
69
+ ```
70
+
71
+ Available `messages` keys:
72
+
73
+ - `insert.label`: 插入
74
+ - `insert.section.general`: 通用
75
+ - `insert.section.apps`: 小应用
76
+ - `insert.section.external`: 外部内容
77
+ - `insert.image`: 图片
78
+ - `insert.video`: 视频
79
+ - `insert.table`: 表格
80
+ - `insert.localFile`: 本地文件
81
+ - `insert.columns`: 分栏
82
+ - `insert.highlightBlock`: 高亮块
83
+ - `insert.date`: 日期
84
+ - `insert.codeBlock`: 代码块
85
+ - `insert.formula`: 公式
86
+ - `insert.blockquote`: 引用
87
+ - `insert.emoji`: 表情符号
88
+ - `insert.link`: 超链接
89
+ - `insert.divider`: 分隔线
90
+ - `insert.countdown`: 倒计时
91
+ - `insert.markdownImport`: Markdown导入
92
+ - `export.label`: 导出
93
+ - `export.pdf`: 导出PDF
94
+ - `export.pdf.loading`: 导出PDF中...
95
+ - `export.html`: 导出HTML
96
+ - `export.html.loading`: 导出HTML中...
97
+ - `export.image`: 导出图片
98
+ - `export.image.loading`: 导出图片中...
99
+ - `print.label`: 打印
100
+ - `print.loading`: 打印中...
101
+ - `quote.apply`: 应用引用
102
+ - `quote.cancel`: 取消引用
103
+ - `quote.borderColor`: 边框颜色
104
+ - `quote.backgroundColor`: 背景颜色
105
+ - `outline.label`: 大纲
106
+ - `outline.collapse`: 收起大纲
107
+ - `outline.empty.description`: 对文档内容应用“标题”样式,即可自动生成大纲。
108
+ - `outline.empty.tip`: 点击左下角“大纲”按钮可以随时展开或收起。
109
+ - `status.wordCountUnit`: 个字
110
+ - `status.presentation.enter`: 演示
111
+ - `status.presentation.exit`: 退出演示
112
+ - `status.fullscreen.enter`: 全屏
113
+ - `status.fullscreen.exit`: 退出全屏
114
+ - `countdown.selectTime`: 请选择时间
115
+ - `countdown.settingsTitle`: 倒计时设置
116
+ - `formula.insertTitle`: 插入 LaTeX 公式
117
+
118
+ ## Preview Mode
119
+
120
+ Use `mode="preview"` to switch the component into a read-only preview shell. In preview mode, the toolbar is hidden, editing is disabled, and the outline can be placed on either side.
121
+
122
+ ```vue
123
+ <template>
124
+ <RichTextEditor
125
+ v-model="content"
126
+ mode="preview"
127
+ outline-placement="right"
128
+ />
129
+ </template>
130
+ ```
131
+
132
+ On narrow screens, preview mode automatically scales the page canvas down so the document stays readable on phones.
133
+
42
134
  ## Collaboration
43
135
 
44
136
  The same component supports both normal single-user editing and optional Yjs collaboration.
@@ -124,9 +216,29 @@ Available methods:
124
216
  - `insertImage(payload | payload[]): boolean`
125
217
  - `insertVideo(payload): boolean`
126
218
  - `insertFile(payload): boolean`
219
+ - `insertLocalFile(payload): boolean`
220
+ - `openLocalFilePicker(): void`
127
221
  - `focus(): void`
128
222
  - `getJSON(): JSONContent | null`
129
223
 
224
+ ## Local File Block
225
+
226
+ The insert menu now supports `Local File`, and the component instance also exposes local-file insertion APIs.
227
+
228
+ ```ts
229
+ editorRef.value?.insertLocalFile({
230
+ url: 'https://cdn.example.com/files/demo.txt',
231
+ name: 'demo.txt',
232
+ size: 2048,
233
+ mimeType: 'text/plain',
234
+ })
235
+ ```
236
+
237
+ Listen for local file events from the component:
238
+
239
+ - `@local-file-upload`: emitted after a local file is selected from the editor picker and inserted
240
+ - `@local-file-download`: emitted when the file card download button is clicked
241
+
130
242
  ## Export Example
131
243
 
132
244
  ```ts
@@ -0,0 +1,3 @@
1
+ import { NodeViewProps } from '@tiptap/vue-3';
2
+ declare const _default: import('vue').DefineComponent<NodeViewProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<NodeViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
3
+ export default _default;
@@ -1,5 +1,9 @@
1
1
  type __VLS_Props = {
2
2
  open: boolean;
3
+ placement: 'left' | 'right';
4
+ collapseTitle: string;
5
+ emptyDescription: string;
6
+ emptyTip: string;
3
7
  items: Array<{
4
8
  pos: number;
5
9
  level: number;
@@ -1,5 +1,5 @@
1
1
  import { JSONContent } from '@tiptap/core';
2
- import { RichTextEditorFilePayload, RichTextEditorImageExportOptions, RichTextEditorImagePayload, RichTextEditorProps, RichTextEditorVideoPayload } from '../types';
2
+ import { RichTextEditorFilePayload, RichTextEditorImageExportOptions, RichTextEditorImagePayload, RichTextEditorLocalFilePayload, RichTextEditorProps, RichTextEditorVideoPayload } from '../types';
3
3
  declare const _default: import('vue').DefineComponent<RichTextEditorProps, {
4
4
  exportPdf: () => Promise<Blob | null>;
5
5
  exportImage: (options?: RichTextEditorImageExportOptions) => Promise<Blob | null>;
@@ -7,18 +7,27 @@ declare const _default: import('vue').DefineComponent<RichTextEditorProps, {
7
7
  insertImage: (payload: RichTextEditorImagePayload | RichTextEditorImagePayload[]) => boolean;
8
8
  insertVideo: (payload: RichTextEditorVideoPayload) => boolean;
9
9
  insertFile: (payload: RichTextEditorFilePayload) => boolean;
10
+ insertLocalFile: (payload: RichTextEditorLocalFilePayload) => boolean;
11
+ openLocalFilePicker: () => void;
10
12
  focus: () => void;
11
13
  getJSON: () => JSONContent | null;
12
14
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
13
15
  change: (value: JSONContent) => any;
14
16
  "update:modelValue": (value: JSONContent) => any;
17
+ "local-file-upload": (value: RichTextEditorLocalFilePayload) => any;
18
+ "local-file-download": (value: RichTextEditorLocalFilePayload) => any;
15
19
  }, string, import('vue').PublicProps, Readonly<RichTextEditorProps> & Readonly<{
16
20
  onChange?: ((value: JSONContent) => any) | undefined;
17
21
  "onUpdate:modelValue"?: ((value: JSONContent) => any) | undefined;
22
+ "onLocal-file-upload"?: ((value: RichTextEditorLocalFilePayload) => any) | undefined;
23
+ "onLocal-file-download"?: ((value: RichTextEditorLocalFilePayload) => any) | undefined;
18
24
  }>, {
19
25
  placeholder: string;
26
+ mode: "edit" | "preview";
20
27
  editable: boolean;
21
28
  modelValue: JSONContent | null;
29
+ outlinePlacement: "left" | "right";
30
+ messages: import('..').RichTextEditorMessages | null;
22
31
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
23
32
  rootRef: HTMLDivElement;
24
33
  insertMenuRef: HTMLDivElement;
@@ -47,5 +56,6 @@ declare const _default: import('vue').DefineComponent<RichTextEditorProps, {
47
56
  countdownBubbleMenuRef: HTMLDivElement;
48
57
  countdownBubbleEditButtonRef: HTMLButtonElement;
49
58
  markdownImportInputRef: HTMLInputElement;
59
+ localFileInputRef: HTMLInputElement;
50
60
  }, HTMLDivElement>;
51
61
  export default _default;
@@ -5,6 +5,12 @@ type UseRichTextEditorOptions = {
5
5
  editable: boolean;
6
6
  placeholder: string;
7
7
  collaboration?: RichTextEditorCollaborationOptions | null;
8
+ onLocalFileDownload?: (payload: {
9
+ url: string;
10
+ name: string;
11
+ size?: number;
12
+ mimeType?: string;
13
+ }) => void;
8
14
  onUpdate: (value: JSONContent) => void;
9
15
  };
10
16
  export declare function useRichTextEditor(options: UseRichTextEditorOptions): import('vue').ShallowRef<import('@tiptap/vue-3').Editor | undefined, import('@tiptap/vue-3').Editor | undefined>;
@@ -0,0 +1,2 @@
1
+ import { Node } from '@tiptap/core';
2
+ export declare const LocalFileBlock: Node<any, any>;
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ import { default as RichTextEditor } from './components/RichTextEditor.vue';
4
4
  import { default as ScrollArea } from './components/ScrollArea.vue';
5
5
  export { OfficeColorIcon, OfficeIcon, RichTextEditor, ScrollArea };
6
6
  export { colorIconNames, monoIconNames } from './icons';
7
- export type { OfficeColorIconProps, OfficeIconProps, RichTextEditorCollaborationAwareness, RichTextEditorCollaborationDocument, RichTextEditorCollaborationOptions, RichTextEditorCollaborationProvider, RichTextEditorCollaborationUser, RichTextEditorFilePayload, RichTextEditorImageExportOptions, RichTextEditorImagePayload, RichTextEditorInstance, RichTextEditorProps, RichTextEditorVideoPayload, } from './types';
7
+ export type { OfficeColorIconProps, OfficeIconProps, RichTextEditorCollaborationAwareness, RichTextEditorCollaborationDocument, RichTextEditorCollaborationOptions, RichTextEditorCollaborationProvider, RichTextEditorCollaborationUser, RichTextEditorFilePayload, RichTextEditorExportItemKey, RichTextEditorImageExportOptions, RichTextEditorImagePayload, RichTextEditorInstance, RichTextEditorInsertMenuItemKey, RichTextEditorLocalFilePayload, RichTextEditorMessages, RichTextEditorProps, RichTextEditorToolbarActionKey, RichTextEditorVideoPayload, } from './types';
8
8
  export default RichTextEditor;