docx-vue-viewer 1.1.0 → 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
@@ -3,11 +3,15 @@ import { PropType, MaybeRefOrGetter } from 'vue';
3
3
  import { DocumentModel } from 'docx-core';
4
4
  export * from 'docx-core';
5
5
  import { DocumentStorage } from 'ooxml-core/embedding';
6
- import { EditorTheme, EditorThemeMode, RibbonActionInput, RibbonAddInTab, DocxCollaborationOptions, WordCustomization, EditorLocaleInput, PageChangeDetail, FileCommandDetail, RibbonAction, RibbonAddInCommandDetail, DocxCollaborationState, SurfaceHostActions, DocxEditorElement, WordListState, WordAlignment, WordListChoice, WordNavigationProps, WordStatusProps, WordToolbarProps } from 'ooxml-ui/docx';
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';
7
7
  export * from 'ooxml-ui/docx';
8
8
  export { WordNavigationProps, WordStatusProps, WordToolbarProps } from 'ooxml-ui/docx';
9
9
  export { DocumentFormat, detectDocumentFormat, loadDocument } from 'ooxml-core/docx/load';
10
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
+ */
11
15
  declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
12
16
  documentModel: PropType<DocumentModel>;
13
17
  readOnly: BooleanConstructor;
@@ -28,7 +32,7 @@ declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
28
32
  customization: PropType<WordCustomization | null>;
29
33
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
30
34
  [key: string]: any;
31
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("document-change" | "document-error" | "document-warning" | "readonly-change" | "ribbon-action" | "ribbon-customize" | "file-command" | "page-change" | "dirty-change" | "collaboration-change" | "office-ribbon-add-in" | "update:readOnly")[], "document-change" | "document-error" | "document-warning" | "readonly-change" | "ribbon-action" | "ribbon-customize" | "file-command" | "page-change" | "dirty-change" | "collaboration-change" | "office-ribbon-add-in" | "update:readOnly", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
35
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, string[], string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
32
36
  documentModel: PropType<DocumentModel>;
33
37
  readOnly: BooleanConstructor;
34
38
  fileName: StringConstructor;
@@ -47,18 +51,7 @@ declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
47
51
  storage: PropType<DocumentStorage | null>;
48
52
  customization: PropType<WordCustomization | null>;
49
53
  }>> & Readonly<{
50
- "onDocument-change"?: (...args: any[]) => any;
51
- "onDocument-error"?: (...args: any[]) => any;
52
- "onDocument-warning"?: (...args: any[]) => any;
53
- "onReadonly-change"?: (...args: any[]) => any;
54
- "onRibbon-action"?: (...args: any[]) => any;
55
- "onRibbon-customize"?: (...args: any[]) => any;
56
- "onFile-command"?: (...args: any[]) => any;
57
- "onPage-change"?: (...args: any[]) => any;
58
- "onDirty-change"?: (...args: any[]) => any;
59
- "onCollaboration-change"?: (...args: any[]) => any;
60
- "onOffice-ribbon-add-in"?: (...args: any[]) => any;
61
- "onUpdate:readOnly"?: (...args: any[]) => any;
54
+ [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
62
55
  }>, {
63
56
  readOnly: boolean;
64
57
  showThumbnails: boolean;
@@ -152,6 +145,7 @@ interface EditorHandle {
152
145
  markClean(): void;
153
146
  readonly dirty: boolean;
154
147
  }
148
+
155
149
  interface EditorBinding extends EditorHandle {
156
150
  update(options: EditorOptions): void;
157
151
  destroy(): void;
@@ -314,7 +308,7 @@ declare function useViewerBuildingBlocks(options?: MaybeRefOrGetter<BuildingBloc
314
308
  } | null>;
315
309
  loading: vue.ComputedRef<boolean>;
316
310
  error: vue.ComputedRef<Error | null>;
317
- mode: vue.ComputedRef<"edit" | "view">;
311
+ mode: vue.ComputedRef<"view" | "edit">;
318
312
  };
319
313
  declare const DocumentCanvas: vue.DefineComponent<vue.ExtractPropTypes<{
320
314
  mount: {
package/dist/index.js CHANGED
@@ -1,56 +1,30 @@
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/forwarding.ts
25
- function C(e, t) {
26
- if (e === t) return !0;
27
- let n = { ...e }, r = { ...t }, i = Object.keys(n);
28
- return i.length === Object.keys(r).length && i.every((e) => n[e] === r[e]);
29
- }
30
- function w() {
31
- let e = /* @__PURE__ */ new Map();
32
- return function(t, n, r = Object.is) {
33
- return e.has(t) && r(e.get(t), n) ? !1 : (e.set(t, n), !0);
34
- };
35
- }
36
- //#endregion
37
- //#region packages/bindings/src/index.ts
38
- var T = [
39
- "documentModel",
40
- "readOnly",
41
- "fileName",
42
- "reviewAuthor",
43
- "themeColors",
44
- "locale",
45
- "theme",
46
- "showThumbnails",
47
- "showToolbar",
48
- "hiddenActions",
49
- "ribbonAddIns",
50
- "collaboration",
51
- "storage",
52
- "customization"
53
- ], E = [
26
+ //#region packages/bindings/src/contract.ts
27
+ var E = [
54
28
  "document-change",
55
29
  "document-error",
56
30
  "document-warning",
@@ -62,78 +36,115 @@ var T = [
62
36
  "ribbon-customize",
63
37
  "office-ribbon-add-in",
64
38
  "collaboration-change"
65
- ];
66
- function D(e, t) {
67
- return e.length === t.length && e.every((e, n) => e === t[n]);
68
- }
69
- function O(e, t, n) {
70
- e[n] = t[n];
71
- }
72
- function k(e) {
73
- let t = {};
74
- for (let n of T) O(t, e, n);
75
- return t;
76
- }
77
- function A(e) {
78
- return {
79
- onDocumentChange: e["document-change"],
80
- onDocumentError: e["document-error"],
81
- onPageChange: e["page-change"],
82
- onDirtyChange: e["dirty-change"],
83
- onFileCommand: e["file-command"],
84
- onDocumentWarning: e["document-warning"],
85
- onReadOnlyChange: e["readonly-change"],
86
- onRibbonAction: e["ribbon-action"],
87
- onRibbonCustomize: e["ribbon-customize"],
88
- onRibbonAddIn: e["office-ribbon-add-in"],
89
- onCollaborationChange: e["collaboration-change"]
90
- };
91
- }
92
- function j(e, t = {}, n = !1) {
93
- (0, x.registerDocxEditor)();
94
- let r = e.ownerDocument.createElement("docx-editor");
95
- if (n && typeof r.getToolbarProps != "function") throw Error("Update ooxml-ui to use editor building blocks.");
96
- r.surfaceOnly = n;
97
- let i = {}, a, o, s, c = null, l = !1, u = w(), d = {
98
- "document-change": (e) => {
99
- o = e.detail, i.onDocumentChange?.(o);
39
+ ], D = {
40
+ props: {
41
+ locale: {
42
+ forward: "always",
43
+ fallback: "en"
100
44
  },
101
- "document-error": (e) => i.onDocumentError?.(e.detail),
102
- "document-warning": (e) => i.onDocumentWarning?.(e.detail),
103
- "page-change": (e) => i.onPageChange?.(e.detail),
104
- "dirty-change": (e) => i.onDirtyChange?.(e.detail),
105
- "readonly-change": (e) => i.onReadOnlyChange?.(e.detail.readOnly, e.detail),
106
- "file-command": (e) => i.onFileCommand?.(e),
107
- "ribbon-action": (e) => i.onRibbonAction?.(e.detail),
108
- "ribbon-customize": (e) => i.onRibbonCustomize?.(e.detail),
109
- "office-ribbon-add-in": (e) => i.onRibbonAddIn?.(e.detail),
110
- "collaboration-change": (e) => i.onCollaborationChange?.(e.detail)
111
- }, f = (e, t = E) => {
112
- for (let n of t) {
113
- let t = d[n];
114
- e ? r.addEventListener(n, t) : r.removeEventListener(n, t);
115
- }
116
- };
117
- f(!0);
118
- let p = {
119
- element: r,
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,
120
131
  update(e) {
121
- l || (i = e, r.locale = e.locale ?? "en", u("readOnly", e.readOnly ?? !1) && (r.readOnly = e.readOnly ?? !1), e.fileName !== void 0 && u("fileName", e.fileName) && (r.fileName = e.fileName), e.reviewAuthor !== void 0 && u("reviewAuthor", e.reviewAuthor) && (r.reviewAuthor = e.reviewAuthor), e.themeColors !== void 0 && u("themeColors", e.themeColors, C) && (r.themeColors = { ...e.themeColors }), r.theme = e.theme ?? "auto", r.showThumbnails = e.showThumbnails ?? !1, r.showToolbar = e.showToolbar ?? !0, D(r.hiddenActions, (0, x.normalizeRibbonActions)(e.hiddenActions ?? []).ids) || (r.hiddenActions = e.hiddenActions ?? []), e.ribbonAddIns !== s && (r.ribbonAddIns = e.ribbonAddIns ?? []), s = e.ribbonAddIns, u("customization", e.customization ?? null) && (r.customization = e.customization ?? null), u("storage", e.storage ?? null) && (r.storage = e.storage ?? void 0), (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);
122
133
  },
123
- load: (e) => r.load(e),
124
- save: () => r.save(),
125
- download: (e) => r.download(e),
126
- markClean: () => r.markClean(),
134
+ load: (e) => i.load(e),
135
+ save: () => i.save(),
136
+ download: (e) => i.download(e),
137
+ markClean: () => i.markClean(),
127
138
  get dirty() {
128
- return r.dirty;
139
+ return i.dirty;
129
140
  },
130
141
  destroy() {
131
- l || (l = !0, f(!1, E.filter((e) => e !== "collaboration-change")), c && r.stopCollaboration(), f(!1, ["collaboration-change"]), r.remove());
142
+ c || (c = !0, l.unlisten(E.filter((e) => e !== "collaboration-change")), l.sent("collaboration") && i.stopCollaboration(), l.unlisten(), i.remove());
132
143
  }
133
144
  };
134
- return p.update(t), e.append(r), p;
145
+ return u.update(n), e.append(i), u;
135
146
  }
136
- function M(e, t = {}) {
147
+ function k(e, t = {}) {
137
148
  let n = (e) => ({
138
149
  ...e,
139
150
  readOnly: e.canEdit !== !0 || e.readOnly === !0
@@ -141,7 +152,7 @@ function M(e, t = {}) {
141
152
  ...e.onOpenHyperlinkDialog && { onOpenHyperlinkDialog: e.onOpenHyperlinkDialog },
142
153
  ...e.onOpenFindReplace && { onOpenFindReplace: e.onOpenFindReplace },
143
154
  ...e.onOpenImagePicker && { onOpenImagePicker: e.onOpenImagePicker }
144
- }), i = j(e, n(t), !0), a = i.update, o = (e) => {
155
+ }), i = O(e, n(t), !0), a = i.update, o = (e) => {
145
156
  let t = r(e), n = i.element.surfaceActions;
146
157
  [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(t)])].some((e) => n[e] !== t[e]) && (i.element.surfaceActions = t);
147
158
  };
@@ -157,7 +168,7 @@ function M(e, t = {}) {
157
168
  }
158
169
  //#endregion
159
170
  //#region packages/bindings/src/vue.ts
160
- var N = t({
171
+ var A = e({
161
172
  name: "WordEditor",
162
173
  props: {
163
174
  documentModel: Object,
@@ -178,61 +189,18 @@ var N = t({
178
189
  storage: Object,
179
190
  customization: Object
180
191
  },
181
- emits: [...E, "update:readOnly"],
182
- setup(e, { emit: t, expose: a }) {
183
- let s = o(), c, u = () => ({
184
- ...k(e),
185
- ...A({
186
- "document-change": (e) => t("document-change", e),
187
- "document-error": (e) => t("document-error", e),
188
- "page-change": (e) => t("page-change", e),
189
- "dirty-change": (e) => t("dirty-change", e),
190
- "file-command": (e) => t("file-command", e),
191
- "document-warning": (e) => t("document-warning", e),
192
- "readonly-change": (n, r) => {
193
- t("readonly-change", n, r), r.hostReadOnly !== e.readOnly && t("update:readOnly", r.hostReadOnly);
194
- },
195
- "ribbon-action": (e) => t("ribbon-action", e),
196
- "ribbon-customize": (e) => t("ribbon-customize", e),
197
- "office-ribbon-add-in": (e) => t("office-ribbon-add-in", e),
198
- "collaboration-change": (e) => t("collaboration-change", e)
199
- })
200
- });
201
- return i(() => {
202
- c = j(s.value, u());
203
- }), l(() => T.map((t) => e[t]), () => c?.update(u())), r(() => c?.destroy()), a({
204
- get element() {
205
- return c?.element;
206
- },
207
- async load(e) {
208
- if (!c) throw Error("Editor is not mounted");
209
- await c.load(e);
210
- },
211
- async save() {
212
- if (!c) throw Error("Editor is not mounted");
213
- return c.save();
214
- },
215
- async download(e) {
216
- if (!c) throw Error("Editor is not mounted");
217
- await c.download(e);
218
- },
219
- markClean() {
220
- c?.markClean();
221
- },
222
- get dirty() {
223
- return c?.dirty ?? !1;
224
- }
225
- }), () => n("div", { ref: s });
226
- }
227
- }), P = /* @__PURE__ */ v({
228
- detectDocumentFormat: () => d,
229
- loadDocument: () => f,
230
- mountEditorSurface: () => M
192
+ contract: D,
193
+ handle: D.handle,
194
+ mount: O
195
+ }), j = /* @__PURE__ */ x({
196
+ detectDocumentFormat: () => o,
197
+ loadDocument: () => s,
198
+ mountEditorSurface: () => k
231
199
  });
232
- b(P, x);
200
+ C(j, w);
233
201
  //#endregion
234
202
  //#region packages/bindings/src/building-blocks.ts
235
- function F(e = {}) {
203
+ function M(e = {}) {
236
204
  let t = e, n, r, i, a = 0, o = null, s, c = {
237
205
  toolbarProps: null,
238
206
  navigationProps: null,
@@ -283,7 +251,7 @@ function F(e = {}) {
283
251
  }, g = () => {
284
252
  n && t.bytes && i !== t.bytes && (i = t.bytes, h(t.bytes).catch(() => {}));
285
253
  }, _ = (e) => {
286
- e !== o && (o = e, ++a, r?.(), r = void 0, n?.destroy(), n = void 0, i = void 0, e && (n = M(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());
287
255
  };
288
256
  return {
289
257
  canvasProps: { mount: _ },
@@ -315,14 +283,14 @@ function F(e = {}) {
315
283
  }
316
284
  };
317
285
  }
318
- function I(e) {
286
+ function N(e) {
319
287
  if (!e) return;
320
- let t = Reflect.get(p, "prepareOfficeUiBlock");
321
- 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"));
322
290
  }
323
291
  //#endregion
324
292
  //#region packages/bindings/src/controls.ts
325
- var L = [
293
+ var P = [
326
294
  "Calibri",
327
295
  "Arial",
328
296
  "Cambria",
@@ -331,7 +299,7 @@ var L = [
331
299
  "Segoe UI",
332
300
  "Times New Roman",
333
301
  "Verdana"
334
- ], R = [
302
+ ], F = [
335
303
  8,
336
304
  9,
337
305
  10,
@@ -346,7 +314,7 @@ var L = [
346
314
  36,
347
315
  48,
348
316
  72
349
- ], z = [
317
+ ], I = [
350
318
  50,
351
319
  75,
352
320
  100,
@@ -354,7 +322,7 @@ var L = [
354
322
  150,
355
323
  200
356
324
  ];
357
- function B(e, t) {
325
+ function L(e, t) {
358
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) => ({
359
327
  value: e,
360
328
  label: e
@@ -364,32 +332,32 @@ function B(e, t) {
364
332
  label: ""
365
333
  }, ...r] : r;
366
334
  }
367
- var V = (e, t) => e[t] ?? t;
368
- function H(e) {
335
+ var R = (e, t) => e[t] ?? t;
336
+ function z(e) {
369
337
  let { labels: t } = e, n = !e.canEdit, r = (e, r, i, a) => ({
370
338
  kind: "toggle",
371
339
  id: e,
372
- label: V(t, r),
340
+ label: R(t, r),
373
341
  disabled: n,
374
342
  pressed: i === null ? "mixed" : i,
375
343
  run: () => void a()
376
344
  }), i = (e, n, r, i) => ({
377
345
  kind: "action",
378
346
  id: e,
379
- label: V(t, n),
347
+ label: R(t, n),
380
348
  disabled: r,
381
349
  run: () => void i()
382
350
  }), a = (r, i, a) => ({
383
351
  kind: "toggle",
384
352
  id: r,
385
- label: V(t, i),
353
+ label: R(t, i),
386
354
  disabled: n,
387
355
  pressed: e.alignment === null ? "mixed" : e.alignment === a,
388
356
  run: () => void e.onAlignmentChange(a)
389
357
  }), o = (r, i, a) => ({
390
358
  kind: "toggle",
391
359
  id: r,
392
- label: V(t, i),
360
+ label: R(t, i),
393
361
  disabled: n,
394
362
  pressed: e.list === a,
395
363
  run: () => void e.onListChange(e.list === a ? "remove" : a)
@@ -398,18 +366,18 @@ function H(e) {
398
366
  [{
399
367
  kind: "select",
400
368
  id: "fontFamily",
401
- label: V(t, "Font"),
369
+ label: R(t, "Font"),
402
370
  disabled: n,
403
371
  value: e.fontFamily ?? "",
404
- options: B(L, e.fontFamily),
372
+ options: L(P, e.fontFamily),
405
373
  change: (t) => void e.onFontFamilyChange(t)
406
374
  }, {
407
375
  kind: "select",
408
376
  id: "fontSize",
409
- label: V(t, "Font size"),
377
+ label: R(t, "Font size"),
410
378
  disabled: n,
411
379
  value: e.fontSize === null ? "" : String(e.fontSize),
412
- options: B(R, e.fontSize),
380
+ options: L(F, e.fontSize),
413
381
  change: (t) => void e.onFontSizeChange(Number(t))
414
382
  }],
415
383
  [
@@ -427,13 +395,13 @@ function H(e) {
427
395
  ], c = [], { hyperlink: l, findReplace: u, picture: d } = e.hostWorkflows;
428
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;
429
397
  }
430
- function U(e) {
398
+ function B(e) {
431
399
  let { labels: t } = e;
432
400
  return [[
433
401
  {
434
402
  kind: "action",
435
403
  id: "previousPage",
436
- label: V(t, "Previous page"),
404
+ label: R(t, "Previous page"),
437
405
  disabled: !e.canGoPrevious,
438
406
  run: () => void e.onPreviousPage()
439
407
  },
@@ -447,28 +415,28 @@ function U(e) {
447
415
  {
448
416
  kind: "action",
449
417
  id: "nextPage",
450
- label: V(t, "Next page"),
418
+ label: R(t, "Next page"),
451
419
  disabled: !e.canGoNext,
452
420
  run: () => void e.onNextPage()
453
421
  }
454
422
  ], [{
455
423
  kind: "select",
456
424
  id: "viewMode",
457
- label: V(t, "Layout view"),
425
+ label: R(t, "Layout view"),
458
426
  disabled: !1,
459
427
  value: e.viewMode,
460
428
  options: [{
461
429
  value: "draft",
462
- label: V(t, "Draft")
430
+ label: R(t, "Draft")
463
431
  }, {
464
432
  value: "print",
465
- label: V(t, "Print Layout")
433
+ label: R(t, "Print Layout")
466
434
  }],
467
435
  change: (t) => void e.onViewModeChange(t === "print" ? "print" : "draft")
468
436
  }]];
469
437
  }
470
- function W(e) {
471
- let t = B(z, e.zoom).map((e) => ({
438
+ function V(e) {
439
+ let t = L(I, e.zoom).map((e) => ({
472
440
  value: e.value,
473
441
  label: `${e.label}%`
474
442
  }));
@@ -481,7 +449,7 @@ function W(e) {
481
449
  }], [{
482
450
  kind: "select",
483
451
  id: "zoom",
484
- label: V(e.labels, "Zoom"),
452
+ label: R(e.labels, "Zoom"),
485
453
  disabled: !1,
486
454
  value: String(e.zoom),
487
455
  options: t,
@@ -490,24 +458,24 @@ function W(e) {
490
458
  }
491
459
  //#endregion
492
460
  //#region packages/vue/src/building-blocks.ts
493
- function G(t = {}) {
494
- let n = F(), r = s(n.state), i = n.subscribe((e) => {
495
- r.value = e;
461
+ function H(e = {}) {
462
+ let t = M(), n = f(t.state), r = t.subscribe((e) => {
463
+ n.value = e;
496
464
  });
497
- return u(() => n.update(c(t))), a(() => {
498
- i(), n.destroy();
465
+ return h(() => t.update(p(e))), d(() => {
466
+ r(), t.destroy();
499
467
  }), {
500
- canvasProps: n.canvasProps,
501
- handle: n.handle,
502
- toolbarProps: e(() => r.value.toolbarProps),
503
- navigationProps: e(() => r.value.navigationProps),
504
- statusProps: e(() => r.value.statusProps),
505
- loading: e(() => r.value.loading),
506
- error: e(() => r.value.error),
507
- 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)
508
476
  };
509
477
  }
510
- var K = t({
478
+ var U = l({
511
479
  name: "DocumentCanvas",
512
480
  inheritAttrs: !1,
513
481
  props: { mount: {
@@ -515,32 +483,32 @@ var K = t({
515
483
  required: !0
516
484
  } },
517
485
  setup(e, { attrs: t }) {
518
- let r = null, i = (t) => {
519
- let n = t;
520
- 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));
521
489
  };
522
- return l(() => e.mount, (e, t) => {
523
- t(null), r && e(r);
524
- }), 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", {
525
493
  ...t,
526
- ref: i
494
+ ref: r
527
495
  });
528
496
  }
529
497
  });
530
- function q(e) {
531
- return e.kind === "text" ? n("span", {
498
+ function W(e) {
499
+ return e.kind === "text" ? u("span", {
532
500
  key: e.id,
533
501
  role: "status"
534
- }, e.text) : e.kind === "select" ? n("select", {
502
+ }, e.text) : e.kind === "select" ? u("select", {
535
503
  key: e.id,
536
504
  "aria-label": e.label,
537
505
  disabled: e.disabled,
538
506
  value: e.value,
539
507
  onChange: (t) => e.change(t.target.value)
540
- }, e.options.map((e) => n("option", {
508
+ }, e.options.map((e) => u("option", {
541
509
  key: e.value,
542
510
  value: e.value
543
- }, e.label))) : n("button", {
511
+ }, e.label))) : u("button", {
544
512
  key: e.id,
545
513
  type: "button",
546
514
  "aria-label": e.label,
@@ -550,47 +518,47 @@ function q(e) {
550
518
  onClick: e.run
551
519
  }, e.label);
552
520
  }
553
- function J(e, t) {
554
- return n("div", {
521
+ function G(e, t) {
522
+ return u("div", {
555
523
  role: e,
556
- ref: (e) => I(e)
557
- }, t.map((e, t) => n("span", {
524
+ ref: (e) => N(e)
525
+ }, t.map((e, t) => u("span", {
558
526
  key: t,
559
527
  role: "group"
560
- }, e.map(q))));
528
+ }, e.map(W))));
561
529
  }
562
- var Y = t({
530
+ var K = l({
563
531
  name: "WordToolbar",
564
532
  props: { toolbarProps: {
565
533
  type: Object,
566
534
  required: !0
567
535
  } },
568
- setup: (e) => () => J("toolbar", H(e.toolbarProps))
569
- }), X = t({
536
+ setup: (e) => () => G("toolbar", z(e.toolbarProps))
537
+ }), q = l({
570
538
  name: "WordPageNavigation",
571
539
  props: { navigationProps: {
572
540
  type: Object,
573
541
  required: !0
574
542
  } },
575
- setup: (e) => () => J("group", U(e.navigationProps))
576
- }), Z = t({
543
+ setup: (e) => () => G("group", B(e.navigationProps))
544
+ }), J = l({
577
545
  name: "WordStatusBar",
578
546
  props: { statusProps: {
579
547
  type: Object,
580
548
  required: !0
581
549
  } },
582
- setup: (e) => () => J("group", W(e.statusProps))
550
+ setup: (e) => () => G("group", V(e.statusProps))
583
551
  });
584
- b(/* @__PURE__ */ v({
585
- DocumentCanvas: () => K,
586
- PageNavigation: () => X,
587
- StatusBar: () => Z,
588
- Toolbar: () => Y,
589
- WordEditor: () => N,
590
- detectDocumentFormat: () => d,
591
- loadDocument: () => f,
592
- mountEditorSurface: () => M,
593
- useViewerBuildingBlocks: () => G
594
- }), P);
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);
595
563
  //#endregion
596
- export { K as DocumentCanvas, X as PageNavigation, Z as StatusBar, Y as Toolbar, N as WordEditor, d as detectDocumentFormat, f as loadDocument, M as mountEditorSurface, G 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.1.0",
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.24.0",
45
- "ooxml-ui": "^1.23.0"
44
+ "ooxml-core": "^1.25.0",
45
+ "ooxml-ui": "^1.26.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "vue": "^3.5.0"