@docx-editor.dev/vue 2.21.0 → 2.21.1

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
@@ -8,60 +8,77 @@
8
8
 
9
9
  Vue 3 adapter for the docx-editor.dev editor.
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 adapter supplies Vue components and composables. 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, defer both importing and mounting the editor until the browser runs.
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