docx-vue-viewer 1.0.1 → 1.1.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
@@ -64,8 +64,9 @@ To render only the controls you use, with your own design system, use the buildi
64
64
 
65
65
  This is an early editor. It does not establish Microsoft Word layout parity or
66
66
  lossless saving for unsupported features. Legacy DOC support is limited to
67
- main-body text with constrained paragraph edits. SmartArt is display-only and
68
- charts render as placeholders.
67
+ main-body text with constrained paragraph edits. SmartArt nodes, text and layout can be edited
68
+ (drawn with an approximate layout until Word lays them out again) and charts can be inserted, edited and resized (chartex charts stay
69
+ read-only).
69
70
 
70
71
  ## Documentation
71
72
 
package/dist/index.d.ts CHANGED
@@ -2,14 +2,22 @@ import * as vue from 'vue';
2
2
  import { PropType, MaybeRefOrGetter } from 'vue';
3
3
  import { DocumentModel } from 'docx-core';
4
4
  export * from 'docx-core';
5
- import { EditorThemeMode, RibbonActionInput, RibbonAddInTab, DocxCollaborationOptions, EditorLocaleInput, PageChangeDetail, RibbonAddInCommandDetail, DocxCollaborationState, SurfaceHostActions, DocxEditorElement, WordListState, WordAlignment, WordListChoice, WordNavigationProps, WordStatusProps, WordToolbarProps } from 'ooxml-ui/docx';
5
+ import { DocumentStorage } from 'ooxml-core/embedding';
6
+ import { EditorTheme, EditorThemeMode, RibbonActionInput, RibbonAddInTab, DocxCollaborationOptions, WordCustomization, EditorLocaleInput, PageChangeDetail, FileCommandDetail, RibbonAction, RibbonAddInCommandDetail, DocxCollaborationState, DocxEditorElement, SurfaceHostActions, WordListState, WordAlignment, WordListChoice, WordNavigationProps, WordStatusProps, WordToolbarProps } from 'ooxml-ui/docx';
6
7
  export * from 'ooxml-ui/docx';
7
8
  export { WordNavigationProps, WordStatusProps, WordToolbarProps } from 'ooxml-ui/docx';
8
9
  export { DocumentFormat, detectDocumentFormat, loadDocument } from 'ooxml-core/docx/load';
9
10
 
11
+ /**
12
+ * Kebab-case emits for every editor event, `v-model:readOnly` (the host's switch, never a role
13
+ * lock) and the handle on the template ref, all generated from `EDITOR_CONTRACT`.
14
+ */
10
15
  declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
11
16
  documentModel: PropType<DocumentModel>;
12
17
  readOnly: BooleanConstructor;
18
+ fileName: StringConstructor;
19
+ reviewAuthor: StringConstructor;
20
+ themeColors: PropType<Partial<EditorTheme>>;
13
21
  locale: StringConstructor;
14
22
  theme: PropType<EditorThemeMode>;
15
23
  showThumbnails: BooleanConstructor;
@@ -20,11 +28,16 @@ declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
20
28
  hiddenActions: PropType<readonly RibbonActionInput[]>;
21
29
  ribbonAddIns: PropType<readonly RibbonAddInTab[]>;
22
30
  collaboration: PropType<DocxCollaborationOptions | null>;
31
+ storage: PropType<DocumentStorage | null>;
32
+ customization: PropType<WordCustomization | null>;
23
33
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
24
34
  [key: string]: any;
25
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("document-change" | "document-error" | "page-change" | "dirty-change" | "collaboration-change" | "office-ribbon-add-in")[], "document-change" | "document-error" | "page-change" | "dirty-change" | "collaboration-change" | "office-ribbon-add-in", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
35
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, string[], string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
26
36
  documentModel: PropType<DocumentModel>;
27
37
  readOnly: BooleanConstructor;
38
+ fileName: StringConstructor;
39
+ reviewAuthor: StringConstructor;
40
+ themeColors: PropType<Partial<EditorTheme>>;
28
41
  locale: StringConstructor;
29
42
  theme: PropType<EditorThemeMode>;
30
43
  showThumbnails: BooleanConstructor;
@@ -35,13 +48,10 @@ declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
35
48
  hiddenActions: PropType<readonly RibbonActionInput[]>;
36
49
  ribbonAddIns: PropType<readonly RibbonAddInTab[]>;
37
50
  collaboration: PropType<DocxCollaborationOptions | null>;
51
+ storage: PropType<DocumentStorage | null>;
52
+ customization: PropType<WordCustomization | null>;
38
53
  }>> & Readonly<{
39
- "onDocument-change"?: (...args: any[]) => any;
40
- "onDocument-error"?: (...args: any[]) => any;
41
- "onPage-change"?: (...args: any[]) => any;
42
- "onDirty-change"?: (...args: any[]) => any;
43
- "onCollaboration-change"?: (...args: any[]) => any;
44
- "onOffice-ribbon-add-in"?: (...args: any[]) => any;
54
+ [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
45
55
  }>, {
46
56
  readOnly: boolean;
47
57
  showThumbnails: boolean;
@@ -56,6 +66,15 @@ interface EditorProps {
56
66
  locale?: EditorLocaleInput | undefined;
57
67
  /** `light`, `dark`, or `auto` (default) to follow the OS color scheme. */
58
68
  theme?: EditorThemeMode | undefined;
69
+ /**
70
+ * Name shown in the title bar and used by Save and Download (default `Document1.docx`). Forwarded
71
+ * when the prop changes, so File > Open can rename the document without being reverted.
72
+ */
73
+ fileName?: string | undefined;
74
+ /** Author recorded on tracked changes and comments. Default `Author`. Forwarded when it changes. */
75
+ reviewAuthor?: string | undefined;
76
+ /** Token overrides applied as `--dve-*` custom properties. Forwarded when its values change. */
77
+ themeColors?: Partial<EditorTheme> | undefined;
59
78
  /** Left rail of page thumbnails (needs Print Layout). Default false. */
60
79
  showThumbnails?: boolean | undefined;
61
80
  /** Ribbon visibility. Default true. */
@@ -69,6 +88,17 @@ interface EditorProps {
69
88
  * Forwarded only when the object changes, so pass a stable object, not a new literal per render.
70
89
  */
71
90
  collaboration?: DocxCollaborationOptions | null | undefined;
91
+ /**
92
+ * Host-owned storage: File > Save and Save As go to `storage.save()` instead of a download, and
93
+ * File > Open to `storage.open()` when it has one. `file-command` still fires first.
94
+ */
95
+ storage?: DocumentStorage | null | undefined;
96
+ /**
97
+ * Host customisation (`WordCustomization`): `capabilities`, `backstage.extraPages` and
98
+ * `contextMenu.extraCommands`. Forwarded when the object changes, so keep it stable (memoise
99
+ * it); `null` or omitted restores the defaults.
100
+ */
101
+ customization?: WordCustomization | null | undefined;
72
102
  }
73
103
  /** Editor callbacks; each is the framework-neutral form of one entry in `EDITOR_EVENT_NAMES`. */
74
104
  interface EditorEventOptions {
@@ -76,6 +106,28 @@ interface EditorEventOptions {
76
106
  onDocumentError?: ((error: Error) => void) | undefined;
77
107
  onPageChange?: ((detail: PageChangeDetail) => void) | undefined;
78
108
  onDirtyChange?: ((dirty: boolean) => void) | undefined;
109
+ /**
110
+ * A File command (new, open, save, saveAs, export, exportText, print, share) is about to run. The
111
+ * event is cancelable: call `event.preventDefault()` to take the command over yourself.
112
+ */
113
+ onFileCommand?: ((event: CustomEvent<FileCommandDetail>) => void) | undefined;
114
+ /** A non-fatal notice, such as a print layout that could not be produced faithfully. */
115
+ onDocumentWarning?: ((message: string) => void) | undefined;
116
+ /**
117
+ * The user toggled Editing / Viewing, `readOnly` changed or a collaboration role changed.
118
+ * `readOnly` is the effective value. A parent that syncs the `readOnly` prop from this callback
119
+ * must store `detail.hostReadOnly`, never `readOnly`, or a `viewer` role lock would be
120
+ * written into the host's setting.
121
+ */
122
+ onReadOnlyChange?: ((readOnly: boolean, detail: {
123
+ readOnly: boolean;
124
+ locked: boolean;
125
+ hostReadOnly: boolean;
126
+ }) => void) | undefined;
127
+ /** A ribbon control was activated. */
128
+ onRibbonAction?: ((detail: RibbonAction) => void) | undefined;
129
+ /** The user changed which ribbon commands are shown (File > Customize Ribbon); persist the ids. */
130
+ onRibbonCustomize?: ((ids: readonly string[]) => void) | undefined;
79
131
  /** A command of a host tab (`ribbonAddIns`) was chosen. */
80
132
  onRibbonAddIn?: ((detail: RibbonAddInCommandDetail) => void) | undefined;
81
133
  /** Sharing started, stopped, reconnected or the people in the room changed. */
@@ -93,6 +145,7 @@ interface EditorHandle {
93
145
  markClean(): void;
94
146
  readonly dirty: boolean;
95
147
  }
148
+
96
149
  interface EditorBinding extends EditorHandle {
97
150
  update(options: EditorOptions): void;
98
151
  destroy(): void;
package/dist/index.js CHANGED
@@ -1,94 +1,150 @@
1
- import { computed as e, defineComponent as t, h as n, onBeforeUnmount as r, onMounted as i, onScopeDispose as a, ref as o, shallowRef as s, toValue as c, watch as l, watchEffect as u } from "vue";
2
- import { detectDocumentFormat as d, loadDocument as f } from "ooxml-core/docx/load";
3
- import * as p from "ooxml-ui/theme";
1
+ import { defineVueBinding as e } from "ooxml-ui/bindings/vue";
2
+ import { bindElement as t, eventArgs as n, readOnlyChange as r, sameList as i, shallowEqual as a } from "ooxml-ui/bindings";
3
+ import { detectDocumentFormat as o, loadDocument as s } from "ooxml-core/docx/load";
4
+ import { computed as c, defineComponent as l, h as u, onScopeDispose as d, shallowRef as f, toValue as p, watch as m, watchEffect as h } from "vue";
5
+ import * as g from "ooxml-ui/theme";
4
6
  export * from "ooxml-ui/docx";
5
7
  export * from "docx-core";
6
8
  //#region \0rolldown/runtime.js
7
- var m = Object.defineProperty, h = Object.getOwnPropertyDescriptor, g = Object.getOwnPropertyNames, _ = Object.prototype.hasOwnProperty, v = (e, t) => {
9
+ var _ = Object.defineProperty, v = Object.getOwnPropertyDescriptor, y = Object.getOwnPropertyNames, b = Object.prototype.hasOwnProperty, x = (e, t) => {
8
10
  let n = {};
9
- for (var r in e) m(n, r, {
11
+ for (var r in e) _(n, r, {
10
12
  get: e[r],
11
13
  enumerable: !0
12
14
  });
13
- return t || m(n, Symbol.toStringTag, { value: "Module" }), n;
14
- }, y = (e, t, n, r) => {
15
- if (t && typeof t == "object" || typeof t == "function") for (var i = g(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !_.call(e, s) && s !== n && m(e, s, {
15
+ return t || _(n, Symbol.toStringTag, { value: "Module" }), n;
16
+ }, S = (e, t, n, r) => {
17
+ if (t && typeof t == "object" || typeof t == "function") for (var i = y(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !b.call(e, s) && s !== n && _(e, s, {
16
18
  get: ((e) => t[e]).bind(null, s),
17
- enumerable: !(r = h(t, s)) || r.enumerable
19
+ enumerable: !(r = v(t, s)) || r.enumerable
18
20
  });
19
21
  return e;
20
- }, b = (e, t, n) => (y(e, t, "default"), n && y(n, t, "default")), x = /* @__PURE__ */ v({});
21
- import * as S from "ooxml-ui/docx";
22
- b(x, S);
22
+ }, C = (e, t, n) => (S(e, t, "default"), n && S(n, t, "default")), w = /* @__PURE__ */ x({});
23
+ import * as T from "ooxml-ui/docx";
24
+ C(w, T);
23
25
  //#endregion
24
- //#region packages/bindings/src/index.ts
25
- var C = [
26
- "documentModel",
27
- "readOnly",
28
- "locale",
29
- "theme",
30
- "showThumbnails",
31
- "showToolbar",
32
- "hiddenActions",
33
- "ribbonAddIns",
34
- "collaboration"
35
- ], w = [
26
+ //#region packages/bindings/src/contract.ts
27
+ var E = [
36
28
  "document-change",
37
29
  "document-error",
30
+ "document-warning",
38
31
  "page-change",
39
32
  "dirty-change",
33
+ "readonly-change",
34
+ "file-command",
35
+ "ribbon-action",
36
+ "ribbon-customize",
40
37
  "office-ribbon-add-in",
41
38
  "collaboration-change"
42
- ];
43
- function T(e, t) {
44
- return e.length === t.length && e.every((e, n) => e === t[n]);
45
- }
46
- function E(e, t, n) {
47
- e[n] = t[n];
48
- }
49
- function D(e) {
50
- let t = {};
51
- for (let n of C) E(t, e, n);
52
- return t;
53
- }
54
- function O(e) {
55
- return {
56
- onDocumentChange: e["document-change"],
57
- onDocumentError: e["document-error"],
58
- onPageChange: e["page-change"],
59
- onDirtyChange: e["dirty-change"],
60
- onRibbonAddIn: e["office-ribbon-add-in"],
61
- onCollaborationChange: e["collaboration-change"]
62
- };
63
- }
64
- function k(e, t = {}, n = !1) {
65
- (0, x.registerDocxEditor)();
66
- let r = e.ownerDocument.createElement("docx-editor");
67
- if (n && typeof r.getToolbarProps != "function") throw Error("Update ooxml-ui to use editor building blocks.");
68
- r.surfaceOnly = n;
69
- let i = {}, a, o, s, c = null, l = !1, u = (e) => {
70
- o = e.detail, i.onDocumentChange?.(o);
71
- }, d = (e) => i.onDocumentError?.(e.detail), f = (e) => i.onPageChange?.(e.detail), p = (e) => i.onDirtyChange?.(e.detail), m = (e) => i.onRibbonAddIn?.(e.detail), h = (e) => i.onCollaborationChange?.(e.detail);
72
- r.addEventListener("document-change", u), r.addEventListener("document-error", d), r.addEventListener("page-change", f), r.addEventListener("dirty-change", p), r.addEventListener("office-ribbon-add-in", m), r.addEventListener("collaboration-change", h);
73
- let g = {
74
- element: r,
39
+ ], D = {
40
+ props: {
41
+ locale: {
42
+ forward: "always",
43
+ fallback: "en"
44
+ },
45
+ readOnly: {
46
+ forward: "changed",
47
+ fallback: !1
48
+ },
49
+ fileName: { forward: "defined" },
50
+ reviewAuthor: { forward: "defined" },
51
+ themeColors: {
52
+ forward: "defined",
53
+ same: a,
54
+ apply: (e, t) => e.themeColors = { ...t }
55
+ },
56
+ theme: {
57
+ forward: "always",
58
+ fallback: "auto"
59
+ },
60
+ showThumbnails: {
61
+ forward: "always",
62
+ fallback: !1
63
+ },
64
+ showToolbar: {
65
+ forward: "always",
66
+ fallback: !0
67
+ },
68
+ hiddenActions: {
69
+ forward: "always",
70
+ apply: (e, t) => {
71
+ i(e.hiddenActions, (0, w.normalizeRibbonActions)(t ?? []).ids) || (e.hiddenActions = t ?? []);
72
+ }
73
+ },
74
+ ribbonAddIns: {
75
+ forward: "changed",
76
+ initial: void 0,
77
+ apply: (e, t) => e.ribbonAddIns = t ?? []
78
+ },
79
+ customization: {
80
+ forward: "changed",
81
+ fallback: null
82
+ },
83
+ storage: {
84
+ forward: "changed",
85
+ fallback: null,
86
+ apply: (e, t) => e.storage = t ?? void 0
87
+ },
88
+ collaboration: {
89
+ forward: "changed",
90
+ fallback: null,
91
+ initial: null
92
+ },
93
+ documentModel: { forward: "manual" }
94
+ },
95
+ events: {
96
+ "document-change": { option: "onDocumentChange" },
97
+ "document-error": { option: "onDocumentError" },
98
+ "document-warning": { option: "onDocumentWarning" },
99
+ "page-change": { option: "onPageChange" },
100
+ "dirty-change": { option: "onDirtyChange" },
101
+ "readonly-change": r,
102
+ "file-command": {
103
+ option: "onFileCommand",
104
+ args: n.event
105
+ },
106
+ "ribbon-action": { option: "onRibbonAction" },
107
+ "ribbon-customize": { option: "onRibbonCustomize" },
108
+ "office-ribbon-add-in": { option: "onRibbonAddIn" },
109
+ "collaboration-change": { option: "onCollaborationChange" }
110
+ },
111
+ handle: {
112
+ element: "get",
113
+ load: "async",
114
+ save: "async",
115
+ download: "async",
116
+ markClean: "optional-call",
117
+ dirty: { fallback: !1 }
118
+ }
119
+ };
120
+ //#endregion
121
+ //#region packages/bindings/src/index.ts
122
+ function O(e, n = {}, r = !1) {
123
+ (0, w.registerDocxEditor)();
124
+ let i = e.ownerDocument.createElement("docx-editor");
125
+ if (r && typeof i.getToolbarProps != "function") throw Error("Update ooxml-ui to use editor building blocks.");
126
+ i.surfaceOnly = r;
127
+ let a = {}, o, s, c = !1, l = t(i, D, () => a, { onEvent: (e, t) => {
128
+ e === "document-change" && (s = t.detail);
129
+ } }), u = {
130
+ element: i,
75
131
  update(e) {
76
- l || (i = e, r.locale = e.locale ?? "en", r.readOnly = e.readOnly ?? !1, r.theme = e.theme ?? "auto", r.showThumbnails = e.showThumbnails ?? !1, r.showToolbar = e.showToolbar ?? !0, T(r.hiddenActions, (0, x.normalizeRibbonActions)(e.hiddenActions ?? []).ids) || (r.hiddenActions = e.hiddenActions ?? []), e.ribbonAddIns !== s && (r.ribbonAddIns = e.ribbonAddIns ?? []), s = e.ribbonAddIns, (e.collaboration ?? null) !== c && (c = e.collaboration ?? null, r.collaboration = c), e.documentModel && e.documentModel !== a && e.documentModel !== o && (r.documentModel = e.documentModel), a = e.documentModel);
132
+ c || (a = e, l.update(e), e.documentModel && e.documentModel !== o && e.documentModel !== s && (i.documentModel = e.documentModel), o = e.documentModel);
77
133
  },
78
- load: (e) => r.load(e),
79
- save: () => r.save(),
80
- download: (e) => r.download(e),
81
- markClean: () => r.markClean(),
134
+ load: (e) => i.load(e),
135
+ save: () => i.save(),
136
+ download: (e) => i.download(e),
137
+ markClean: () => i.markClean(),
82
138
  get dirty() {
83
- return r.dirty;
139
+ return i.dirty;
84
140
  },
85
141
  destroy() {
86
- l || (l = !0, r.removeEventListener("document-change", u), r.removeEventListener("document-error", d), r.removeEventListener("page-change", f), r.removeEventListener("dirty-change", p), r.removeEventListener("office-ribbon-add-in", m), c && r.stopCollaboration(), r.removeEventListener("collaboration-change", h), r.remove());
142
+ c || (c = !0, l.unlisten(E.filter((e) => e !== "collaboration-change")), l.sent("collaboration") && i.stopCollaboration(), l.unlisten(), i.remove());
87
143
  }
88
144
  };
89
- return g.update(t), e.append(r), g;
145
+ return u.update(n), e.append(i), u;
90
146
  }
91
- function A(e, t = {}) {
147
+ function k(e, t = {}) {
92
148
  let n = (e) => ({
93
149
  ...e,
94
150
  readOnly: e.canEdit !== !0 || e.readOnly === !0
@@ -96,7 +152,7 @@ function A(e, t = {}) {
96
152
  ...e.onOpenHyperlinkDialog && { onOpenHyperlinkDialog: e.onOpenHyperlinkDialog },
97
153
  ...e.onOpenFindReplace && { onOpenFindReplace: e.onOpenFindReplace },
98
154
  ...e.onOpenImagePicker && { onOpenImagePicker: e.onOpenImagePicker }
99
- }), i = k(e, n(t), !0), a = i.update, o = (e) => {
155
+ }), i = O(e, n(t), !0), a = i.update, o = (e) => {
100
156
  let t = r(e), n = i.element.surfaceActions;
101
157
  [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(t)])].some((e) => n[e] !== t[e]) && (i.element.surfaceActions = t);
102
158
  };
@@ -112,11 +168,14 @@ function A(e, t = {}) {
112
168
  }
113
169
  //#endregion
114
170
  //#region packages/bindings/src/vue.ts
115
- var j = t({
171
+ var A = e({
116
172
  name: "WordEditor",
117
173
  props: {
118
174
  documentModel: Object,
119
175
  readOnly: Boolean,
176
+ fileName: String,
177
+ reviewAuthor: String,
178
+ themeColors: Object,
120
179
  locale: String,
121
180
  theme: String,
122
181
  showThumbnails: Boolean,
@@ -126,56 +185,22 @@ var j = t({
126
185
  },
127
186
  hiddenActions: Array,
128
187
  ribbonAddIns: Array,
129
- collaboration: Object
188
+ collaboration: Object,
189
+ storage: Object,
190
+ customization: Object
130
191
  },
131
- emits: [...w],
132
- setup(e, { emit: t, expose: a }) {
133
- let s = o(), c, u = () => ({
134
- ...D(e),
135
- ...O({
136
- "document-change": (e) => t("document-change", e),
137
- "document-error": (e) => t("document-error", e),
138
- "page-change": (e) => t("page-change", e),
139
- "dirty-change": (e) => t("dirty-change", e),
140
- "office-ribbon-add-in": (e) => t("office-ribbon-add-in", e),
141
- "collaboration-change": (e) => t("collaboration-change", e)
142
- })
143
- });
144
- return i(() => {
145
- c = k(s.value, u());
146
- }), l(() => C.map((t) => e[t]), () => c?.update(u())), r(() => c?.destroy()), a({
147
- get element() {
148
- return c?.element;
149
- },
150
- async load(e) {
151
- if (!c) throw Error("Editor is not mounted");
152
- await c.load(e);
153
- },
154
- async save() {
155
- if (!c) throw Error("Editor is not mounted");
156
- return c.save();
157
- },
158
- async download(e) {
159
- if (!c) throw Error("Editor is not mounted");
160
- await c.download(e);
161
- },
162
- markClean() {
163
- c?.markClean();
164
- },
165
- get dirty() {
166
- return c?.dirty ?? !1;
167
- }
168
- }), () => n("div", { ref: s });
169
- }
170
- }), M = /* @__PURE__ */ v({
171
- detectDocumentFormat: () => d,
172
- loadDocument: () => f,
173
- mountEditorSurface: () => A
192
+ contract: D,
193
+ handle: D.handle,
194
+ mount: O
195
+ }), j = /* @__PURE__ */ x({
196
+ detectDocumentFormat: () => o,
197
+ loadDocument: () => s,
198
+ mountEditorSurface: () => k
174
199
  });
175
- b(M, x);
200
+ C(j, w);
176
201
  //#endregion
177
202
  //#region packages/bindings/src/building-blocks.ts
178
- function N(e = {}) {
203
+ function M(e = {}) {
179
204
  let t = e, n, r, i, a = 0, o = null, s, c = {
180
205
  toolbarProps: null,
181
206
  navigationProps: null,
@@ -226,7 +251,7 @@ function N(e = {}) {
226
251
  }, g = () => {
227
252
  n && t.bytes && i !== t.bytes && (i = t.bytes, h(t.bytes).catch(() => {}));
228
253
  }, _ = (e) => {
229
- e !== o && (o = e, ++a, r?.(), r = void 0, n?.destroy(), n = void 0, i = void 0, e && (n = A(e, p()), r = n.subscribe(f)), f(), g());
254
+ e !== o && (o = e, ++a, r?.(), r = void 0, n?.destroy(), n = void 0, i = void 0, e && (n = k(e, p()), r = n.subscribe(f)), f(), g());
230
255
  };
231
256
  return {
232
257
  canvasProps: { mount: _ },
@@ -258,14 +283,14 @@ function N(e = {}) {
258
283
  }
259
284
  };
260
285
  }
261
- function P(e) {
286
+ function N(e) {
262
287
  if (!e) return;
263
- let t = Reflect.get(p, "prepareOfficeUiBlock");
264
- typeof t == "function" ? t(e, "toolbar", "docx") : (p.installOfficeUiTheme(e.ownerDocument), e.setAttribute("data-office-block", "toolbar"), e.setAttribute("data-office-product", "docx"));
288
+ let t = Reflect.get(g, "prepareOfficeUiBlock");
289
+ typeof t == "function" ? t(e, "toolbar", "docx") : (g.installOfficeUiTheme(e.ownerDocument), e.setAttribute("data-office-block", "toolbar"), e.setAttribute("data-office-product", "docx"));
265
290
  }
266
291
  //#endregion
267
292
  //#region packages/bindings/src/controls.ts
268
- var F = [
293
+ var P = [
269
294
  "Calibri",
270
295
  "Arial",
271
296
  "Cambria",
@@ -274,7 +299,7 @@ var F = [
274
299
  "Segoe UI",
275
300
  "Times New Roman",
276
301
  "Verdana"
277
- ], I = [
302
+ ], F = [
278
303
  8,
279
304
  9,
280
305
  10,
@@ -289,7 +314,7 @@ var F = [
289
314
  36,
290
315
  48,
291
316
  72
292
- ], L = [
317
+ ], I = [
293
318
  50,
294
319
  75,
295
320
  100,
@@ -297,7 +322,7 @@ var F = [
297
322
  150,
298
323
  200
299
324
  ];
300
- function R(e, t) {
325
+ function L(e, t) {
301
326
  let n = typeof e[0] == "number", r = (t === null || e.includes(t) ? [...e] : [...e, t]).map(String).sort((e, t) => n ? Number(e) - Number(t) : e.localeCompare(t)).map((e) => ({
302
327
  value: e,
303
328
  label: e
@@ -307,32 +332,32 @@ function R(e, t) {
307
332
  label: ""
308
333
  }, ...r] : r;
309
334
  }
310
- var z = (e, t) => e[t] ?? t;
311
- function B(e) {
335
+ var R = (e, t) => e[t] ?? t;
336
+ function z(e) {
312
337
  let { labels: t } = e, n = !e.canEdit, r = (e, r, i, a) => ({
313
338
  kind: "toggle",
314
339
  id: e,
315
- label: z(t, r),
340
+ label: R(t, r),
316
341
  disabled: n,
317
342
  pressed: i === null ? "mixed" : i,
318
343
  run: () => void a()
319
344
  }), i = (e, n, r, i) => ({
320
345
  kind: "action",
321
346
  id: e,
322
- label: z(t, n),
347
+ label: R(t, n),
323
348
  disabled: r,
324
349
  run: () => void i()
325
350
  }), a = (r, i, a) => ({
326
351
  kind: "toggle",
327
352
  id: r,
328
- label: z(t, i),
353
+ label: R(t, i),
329
354
  disabled: n,
330
355
  pressed: e.alignment === null ? "mixed" : e.alignment === a,
331
356
  run: () => void e.onAlignmentChange(a)
332
357
  }), o = (r, i, a) => ({
333
358
  kind: "toggle",
334
359
  id: r,
335
- label: z(t, i),
360
+ label: R(t, i),
336
361
  disabled: n,
337
362
  pressed: e.list === a,
338
363
  run: () => void e.onListChange(e.list === a ? "remove" : a)
@@ -341,18 +366,18 @@ function B(e) {
341
366
  [{
342
367
  kind: "select",
343
368
  id: "fontFamily",
344
- label: z(t, "Font"),
369
+ label: R(t, "Font"),
345
370
  disabled: n,
346
371
  value: e.fontFamily ?? "",
347
- options: R(F, e.fontFamily),
372
+ options: L(P, e.fontFamily),
348
373
  change: (t) => void e.onFontFamilyChange(t)
349
374
  }, {
350
375
  kind: "select",
351
376
  id: "fontSize",
352
- label: z(t, "Font size"),
377
+ label: R(t, "Font size"),
353
378
  disabled: n,
354
379
  value: e.fontSize === null ? "" : String(e.fontSize),
355
- options: R(I, e.fontSize),
380
+ options: L(F, e.fontSize),
356
381
  change: (t) => void e.onFontSizeChange(Number(t))
357
382
  }],
358
383
  [
@@ -370,13 +395,13 @@ function B(e) {
370
395
  ], c = [], { hyperlink: l, findReplace: u, picture: d } = e.hostWorkflows;
371
396
  return l && c.push(i("link", "Insert link", !e.canInsertLink, e.openHyperlinkDialog)), u && c.push(i("find", "Find", !e.canFindReplace, e.openFindReplace)), d && c.push(i("picture", "Insert picture", !e.canInsertPicture, e.openImagePicker)), c.length && s.push(c), s;
372
397
  }
373
- function V(e) {
398
+ function B(e) {
374
399
  let { labels: t } = e;
375
400
  return [[
376
401
  {
377
402
  kind: "action",
378
403
  id: "previousPage",
379
- label: z(t, "Previous page"),
404
+ label: R(t, "Previous page"),
380
405
  disabled: !e.canGoPrevious,
381
406
  run: () => void e.onPreviousPage()
382
407
  },
@@ -390,28 +415,28 @@ function V(e) {
390
415
  {
391
416
  kind: "action",
392
417
  id: "nextPage",
393
- label: z(t, "Next page"),
418
+ label: R(t, "Next page"),
394
419
  disabled: !e.canGoNext,
395
420
  run: () => void e.onNextPage()
396
421
  }
397
422
  ], [{
398
423
  kind: "select",
399
424
  id: "viewMode",
400
- label: z(t, "Layout view"),
425
+ label: R(t, "Layout view"),
401
426
  disabled: !1,
402
427
  value: e.viewMode,
403
428
  options: [{
404
429
  value: "draft",
405
- label: z(t, "Draft")
430
+ label: R(t, "Draft")
406
431
  }, {
407
432
  value: "print",
408
- label: z(t, "Print Layout")
433
+ label: R(t, "Print Layout")
409
434
  }],
410
435
  change: (t) => void e.onViewModeChange(t === "print" ? "print" : "draft")
411
436
  }]];
412
437
  }
413
- function H(e) {
414
- let t = R(L, e.zoom).map((e) => ({
438
+ function V(e) {
439
+ let t = L(I, e.zoom).map((e) => ({
415
440
  value: e.value,
416
441
  label: `${e.label}%`
417
442
  }));
@@ -424,7 +449,7 @@ function H(e) {
424
449
  }], [{
425
450
  kind: "select",
426
451
  id: "zoom",
427
- label: z(e.labels, "Zoom"),
452
+ label: R(e.labels, "Zoom"),
428
453
  disabled: !1,
429
454
  value: String(e.zoom),
430
455
  options: t,
@@ -433,24 +458,24 @@ function H(e) {
433
458
  }
434
459
  //#endregion
435
460
  //#region packages/vue/src/building-blocks.ts
436
- function U(t = {}) {
437
- let n = N(), r = s(n.state), i = n.subscribe((e) => {
438
- r.value = e;
461
+ function H(e = {}) {
462
+ let t = M(), n = f(t.state), r = t.subscribe((e) => {
463
+ n.value = e;
439
464
  });
440
- return u(() => n.update(c(t))), a(() => {
441
- i(), n.destroy();
465
+ return h(() => t.update(p(e))), d(() => {
466
+ r(), t.destroy();
442
467
  }), {
443
- canvasProps: n.canvasProps,
444
- handle: n.handle,
445
- toolbarProps: e(() => r.value.toolbarProps),
446
- navigationProps: e(() => r.value.navigationProps),
447
- statusProps: e(() => r.value.statusProps),
448
- loading: e(() => r.value.loading),
449
- error: e(() => r.value.error),
450
- mode: e(() => r.value.mode)
468
+ canvasProps: t.canvasProps,
469
+ handle: t.handle,
470
+ toolbarProps: c(() => n.value.toolbarProps),
471
+ navigationProps: c(() => n.value.navigationProps),
472
+ statusProps: c(() => n.value.statusProps),
473
+ loading: c(() => n.value.loading),
474
+ error: c(() => n.value.error),
475
+ mode: c(() => n.value.mode)
451
476
  };
452
477
  }
453
- var W = t({
478
+ var U = l({
454
479
  name: "DocumentCanvas",
455
480
  inheritAttrs: !1,
456
481
  props: { mount: {
@@ -458,32 +483,32 @@ var W = t({
458
483
  required: !0
459
484
  } },
460
485
  setup(e, { attrs: t }) {
461
- let r = null, i = (t) => {
462
- let n = t;
463
- r !== n && (r = n, e.mount(n));
486
+ let n = null, r = (t) => {
487
+ let r = t;
488
+ n !== r && (n = r, e.mount(r));
464
489
  };
465
- return l(() => e.mount, (e, t) => {
466
- t(null), r && e(r);
467
- }), a(() => e.mount(null)), () => n("div", {
490
+ return m(() => e.mount, (e, t) => {
491
+ t(null), n && e(n);
492
+ }), d(() => e.mount(null)), () => u("div", {
468
493
  ...t,
469
- ref: i
494
+ ref: r
470
495
  });
471
496
  }
472
497
  });
473
- function G(e) {
474
- return e.kind === "text" ? n("span", {
498
+ function W(e) {
499
+ return e.kind === "text" ? u("span", {
475
500
  key: e.id,
476
501
  role: "status"
477
- }, e.text) : e.kind === "select" ? n("select", {
502
+ }, e.text) : e.kind === "select" ? u("select", {
478
503
  key: e.id,
479
504
  "aria-label": e.label,
480
505
  disabled: e.disabled,
481
506
  value: e.value,
482
507
  onChange: (t) => e.change(t.target.value)
483
- }, e.options.map((e) => n("option", {
508
+ }, e.options.map((e) => u("option", {
484
509
  key: e.value,
485
510
  value: e.value
486
- }, e.label))) : n("button", {
511
+ }, e.label))) : u("button", {
487
512
  key: e.id,
488
513
  type: "button",
489
514
  "aria-label": e.label,
@@ -493,47 +518,47 @@ function G(e) {
493
518
  onClick: e.run
494
519
  }, e.label);
495
520
  }
496
- function K(e, t) {
497
- return n("div", {
521
+ function G(e, t) {
522
+ return u("div", {
498
523
  role: e,
499
- ref: (e) => P(e)
500
- }, t.map((e, t) => n("span", {
524
+ ref: (e) => N(e)
525
+ }, t.map((e, t) => u("span", {
501
526
  key: t,
502
527
  role: "group"
503
- }, e.map(G))));
528
+ }, e.map(W))));
504
529
  }
505
- var q = t({
530
+ var K = l({
506
531
  name: "WordToolbar",
507
532
  props: { toolbarProps: {
508
533
  type: Object,
509
534
  required: !0
510
535
  } },
511
- setup: (e) => () => K("toolbar", B(e.toolbarProps))
512
- }), J = t({
536
+ setup: (e) => () => G("toolbar", z(e.toolbarProps))
537
+ }), q = l({
513
538
  name: "WordPageNavigation",
514
539
  props: { navigationProps: {
515
540
  type: Object,
516
541
  required: !0
517
542
  } },
518
- setup: (e) => () => K("group", V(e.navigationProps))
519
- }), Y = t({
543
+ setup: (e) => () => G("group", B(e.navigationProps))
544
+ }), J = l({
520
545
  name: "WordStatusBar",
521
546
  props: { statusProps: {
522
547
  type: Object,
523
548
  required: !0
524
549
  } },
525
- setup: (e) => () => K("group", H(e.statusProps))
550
+ setup: (e) => () => G("group", V(e.statusProps))
526
551
  });
527
- b(/* @__PURE__ */ v({
528
- DocumentCanvas: () => W,
529
- PageNavigation: () => J,
530
- StatusBar: () => Y,
531
- Toolbar: () => q,
532
- WordEditor: () => j,
533
- detectDocumentFormat: () => d,
534
- loadDocument: () => f,
535
- mountEditorSurface: () => A,
536
- useViewerBuildingBlocks: () => U
537
- }), M);
552
+ C(/* @__PURE__ */ x({
553
+ DocumentCanvas: () => U,
554
+ PageNavigation: () => q,
555
+ StatusBar: () => J,
556
+ Toolbar: () => K,
557
+ WordEditor: () => A,
558
+ detectDocumentFormat: () => o,
559
+ loadDocument: () => s,
560
+ mountEditorSurface: () => k,
561
+ useViewerBuildingBlocks: () => H
562
+ }), j);
538
563
  //#endregion
539
- export { W as DocumentCanvas, J as PageNavigation, Y as StatusBar, q as Toolbar, j as WordEditor, d as detectDocumentFormat, f as loadDocument, A as mountEditorSurface, U as useViewerBuildingBlocks };
564
+ export { U as DocumentCanvas, q as PageNavigation, J as StatusBar, K as Toolbar, A as WordEditor, o as detectDocumentFormat, s as loadDocument, k as mountEditorSurface, H as useViewerBuildingBlocks };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-vue-viewer",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Vue 3 component for the DOCX editor. Self-contained: includes the editor, layout engine and legacy .doc reader.",
5
5
  "keywords": [
6
6
  "doc",
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "docx-core": "^0.3.0",
44
- "ooxml-core": "^1.23.0",
45
- "ooxml-ui": "^1.22.0"
44
+ "ooxml-core": "^1.25.0",
45
+ "ooxml-ui": "^1.26.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "vue": "^3.5.0"