@ap666/office-word 0.1.5 → 0.1.6

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,41 @@ 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
+ - `enabledExportItems?: ('pdf' | 'html' | 'image' | 'print')[] | null`
42
+ - `enabledInsertMenuItems?: ('image' | 'video' | 'table' | 'local-file' | 'columns' | 'highlight-block' | 'date' | 'code-block' | 'formula' | 'blockquote' | 'emoji' | 'link' | 'divider' | 'countdown' | 'markdown-import')[] | null`
43
+ - `enabledToolbarActions?: ('blockquote')[] | null`
39
44
  - `placeholder?: string`
40
45
  - `collaboration?: RichTextEditorCollaborationOptions | null`
41
46
 
47
+ 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.
48
+
49
+ ```vue
50
+ <RichTextEditor
51
+ v-model="content"
52
+ :enabled-export-items="['html', 'image']"
53
+ :enabled-insert-menu-items="['image', 'local-file', 'blockquote']"
54
+ :enabled-toolbar-actions="['blockquote']"
55
+ />
56
+ ```
57
+
58
+ ## Preview Mode
59
+
60
+ 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.
61
+
62
+ ```vue
63
+ <template>
64
+ <RichTextEditor
65
+ v-model="content"
66
+ mode="preview"
67
+ outline-placement="right"
68
+ />
69
+ </template>
70
+ ```
71
+
72
+ On narrow screens, preview mode automatically scales the page canvas down so the document stays readable on phones.
73
+
42
74
  ## Collaboration
43
75
 
44
76
  The same component supports both normal single-user editing and optional Yjs collaboration.
@@ -124,9 +156,29 @@ Available methods:
124
156
  - `insertImage(payload | payload[]): boolean`
125
157
  - `insertVideo(payload): boolean`
126
158
  - `insertFile(payload): boolean`
159
+ - `insertLocalFile(payload): boolean`
160
+ - `openLocalFilePicker(): void`
127
161
  - `focus(): void`
128
162
  - `getJSON(): JSONContent | null`
129
163
 
164
+ ## Local File Block
165
+
166
+ The insert menu now supports `Local File`, and the component instance also exposes local-file insertion APIs.
167
+
168
+ ```ts
169
+ editorRef.value?.insertLocalFile({
170
+ url: 'https://cdn.example.com/files/demo.txt',
171
+ name: 'demo.txt',
172
+ size: 2048,
173
+ mimeType: 'text/plain',
174
+ })
175
+ ```
176
+
177
+ Listen for local file events from the component:
178
+
179
+ - `@local-file-upload`: emitted after a local file is selected from the editor picker and inserted
180
+ - `@local-file-download`: emitted when the file card download button is clicked
181
+
130
182
  ## Export Example
131
183
 
132
184
  ```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,6 @@
1
1
  type __VLS_Props = {
2
2
  open: boolean;
3
+ placement: 'left' | 'right';
3
4
  items: Array<{
4
5
  pos: number;
5
6
  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,26 @@ 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";
22
30
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
23
31
  rootRef: HTMLDivElement;
24
32
  insertMenuRef: HTMLDivElement;
@@ -47,5 +55,6 @@ declare const _default: import('vue').DefineComponent<RichTextEditorProps, {
47
55
  countdownBubbleMenuRef: HTMLDivElement;
48
56
  countdownBubbleEditButtonRef: HTMLButtonElement;
49
57
  markdownImportInputRef: HTMLInputElement;
58
+ localFileInputRef: HTMLInputElement;
50
59
  }, HTMLDivElement>;
51
60
  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, RichTextEditorProps, RichTextEditorToolbarActionKey, RichTextEditorVideoPayload, } from './types';
8
8
  export default RichTextEditor;