@docx-editor.dev/vue 2.21.0 → 2.22.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/README.md CHANGED
@@ -6,62 +6,79 @@
6
6
 
7
7
  # @docx-editor.dev/vue
8
8
 
9
- Vue 3 adapter for the docx-editor.dev editor.
9
+ Use Vue 3 components and composables to open, edit, and save DOCX files.
10
10
 
11
- It is a thin renderer over the editor contract in `@docx-editor.dev/core`. It supplies the DOM host, constructs the editor with `createEditor`, and paints the engine's positioned display list. All editing, querying, and geometry go through the `Editor` facade. The adapter holds no editing-engine state of its own.
11
+ The shared engine handles document state, editing, layout, and rendering.
12
12
 
13
13
  ## Install
14
14
 
15
+ Install the adapter and its required engine peer:
16
+
15
17
  ```bash
16
18
  npm install @docx-editor.dev/vue @docx-editor.dev/core
17
19
  ```
18
20
 
19
- ## Quickstart
21
+ ## Quick start
22
+
23
+ Import the stylesheet once and give the editor a container with a defined height:
20
24
 
21
25
  ```vue
22
26
  <script setup lang="ts">
23
27
  import { DocxEditor } from '@docx-editor.dev/vue';
28
+ import '@docx-editor.dev/vue/styles.css';
24
29
  </script>
25
30
 
26
31
  <template>
27
- <DocxEditor :document="docxBytes" />
32
+ <div style="height: 100vh">
33
+ <DocxEditor document="blank" />
34
+ </div>
28
35
  </template>
29
36
  ```
30
37
 
31
- `<DocxEditor>` is the full packaged editor. When you need your own chrome, compose `DocxEditorRoot`, `DocxEditorViewport`, and `DocxEditorContent`, then add toolbar, menu, and navigation parts from the same package root.
38
+ To open a file, pass its `ArrayBuffer` or `Uint8Array` as `:document`.
32
39
 
33
40
  ## Composition API
34
41
 
42
+ Compose the editor root, viewport, and content when you need your own interface. Put custom controls inside the root:
43
+
35
44
  ```vue
36
45
  <script setup lang="ts">
37
- import {
38
- DocxEditorRoot,
39
- DocxEditorViewport,
40
- DocxEditorContent,
41
- DocxEditorToolbar,
42
- useEditorCommand,
43
- } from '@docx-editor.dev/vue';
44
-
45
- const bold = useEditorCommand('text.bold');
46
+ import { DocxEditorRoot, DocxEditorViewport, DocxEditorContent } from '@docx-editor.dev/vue';
47
+ import '@docx-editor.dev/vue/styles.css';
48
+ import BoldButton from './BoldButton.vue';
46
49
  </script>
47
50
 
48
51
  <template>
49
- <DocxEditorRoot :document="docxBytes">
50
- <DocxEditorToolbar>
51
- <button @mousedown.prevent :disabled="!bold.isEnabled" @click="bold.execute()">Bold</button>
52
- </DocxEditorToolbar>
53
- <DocxEditorViewport>
52
+ <DocxEditorRoot document="blank">
53
+ <BoldButton />
54
+ <DocxEditorViewport style="height: 80vh">
54
55
  <DocxEditorContent />
55
56
  </DocxEditorViewport>
56
57
  </DocxEditorRoot>
57
58
  </template>
58
59
  ```
59
60
 
60
- Every composable the packaged chrome uses is public: `useDocxEditor`, `useEditorState`, `useEditorCommand`, `useEditorEvent`, `useFontFamily`, and the rest on the package root.
61
+ Define the button in `BoldButton.vue`. Composables must run in a descendant of `DocxEditorRoot` to access its editor. Destructure computed refs so Vue unwraps them in the template:
62
+
63
+ ```vue
64
+ <script setup lang="ts">
65
+ import { useEditorCommand } from '@docx-editor.dev/vue';
66
+
67
+ const { execute, isEnabled, isActive } = useEditorCommand('text.bold');
68
+ </script>
69
+
70
+ <template>
71
+ <button @mousedown.prevent :disabled="!isEnabled" :aria-pressed="isActive" @click="execute()">
72
+ Bold
73
+ </button>
74
+ </template>
75
+ ```
76
+
77
+ The package also exports `useDocxEditor`, `useEditorState`, `useEditorEvent`, and `useFontFamily`.
61
78
 
62
79
  ## SSR and Nuxt
63
80
 
64
- The editor is client-only. On the server, `DocxEditorRoot` skips instance creation. Mount the editor inside `<ClientOnly>` or load it with `defineAsyncComponent`.
81
+ The editor requires browser APIs. For Nuxt, mount it inside `<ClientOnly>` and use a `.client.vue` component for its imports. For other server-rendered applications, import and mount the editor in the browser.
65
82
 
66
83
  The Nuxt module remains a private workspace package. External applications should follow the [Nuxt guide](https://www.docx-editor.dev/docs/2.x/frameworks/nuxt).
67
84
 
@@ -72,6 +89,20 @@ The Nuxt module remains a private workspace package. External applications shoul
72
89
  - [Composables reference](https://www.docx-editor.dev/docs/2.x/vue/composables)
73
90
  - Live demo: `bun run dev:vue` in the monorepo (`examples/vue`)
74
91
 
92
+ ## Export Markdown and PDF
93
+
94
+ The adapter does not install either converter. Install only the formats your application uses.
95
+
96
+ Configure `menu.exporters` to enable **File > Export** with the conversion packages. Markdown downloads as one continuous document. PDF conversion requires a Node.js server. Missing converter handlers show an error with setup instructions. See [Export Markdown and PDF](https://www.docx-editor.dev/docs/2.x/guides/export).
97
+
98
+ **File > Print** uses the same PDF handler and opens the browser print dialog. Press Ctrl+P, or Cmd+P on macOS. See [Print documents](https://www.docx-editor.dev/docs/2.x/guides/print).
99
+
100
+ ## Accept server updates
101
+
102
+ Use `createDocumentRefresh(editor)` to accept complete DOCX results from your server. The controller preserves the editor instance and scroll position. Each accepted file resets selection and undo history. Results after local edits and collaborative sessions are refused.
103
+
104
+ For highlights, change navigation, and recovery, see [Document refresh API](https://www.docx-editor.dev/docs/2.x/guides/document-refresh).
105
+
75
106
  ## License
76
107
 
77
108
  Apache-2.0