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 +3 -2
- package/dist/index.d.ts +61 -8
- package/dist/index.js +215 -190
- package/package.json +3 -3
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
|
|
68
|
-
charts
|
|
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 {
|
|
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,
|
|
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
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
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
|
|
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)
|
|
11
|
+
for (var r in e) _(n, r, {
|
|
10
12
|
get: e[r],
|
|
11
13
|
enumerable: !0
|
|
12
14
|
});
|
|
13
|
-
return t ||
|
|
14
|
-
},
|
|
15
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
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 =
|
|
19
|
+
enumerable: !(r = v(t, s)) || r.enumerable
|
|
18
20
|
});
|
|
19
21
|
return e;
|
|
20
|
-
},
|
|
21
|
-
import * as
|
|
22
|
-
|
|
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/
|
|
25
|
-
var
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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) =>
|
|
79
|
-
save: () =>
|
|
80
|
-
download: (e) =>
|
|
81
|
-
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
|
|
139
|
+
return i.dirty;
|
|
84
140
|
},
|
|
85
141
|
destroy() {
|
|
86
|
-
|
|
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
|
|
145
|
+
return u.update(n), e.append(i), u;
|
|
90
146
|
}
|
|
91
|
-
function
|
|
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 =
|
|
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
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
200
|
+
C(j, w);
|
|
176
201
|
//#endregion
|
|
177
202
|
//#region packages/bindings/src/building-blocks.ts
|
|
178
|
-
function
|
|
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 =
|
|
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
|
|
286
|
+
function N(e) {
|
|
262
287
|
if (!e) return;
|
|
263
|
-
let t = Reflect.get(
|
|
264
|
-
typeof t == "function" ? t(e, "toolbar", "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
|
|
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
|
-
],
|
|
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
|
-
],
|
|
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
|
|
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
|
|
311
|
-
function
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
369
|
+
label: R(t, "Font"),
|
|
345
370
|
disabled: n,
|
|
346
371
|
value: e.fontFamily ?? "",
|
|
347
|
-
options:
|
|
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:
|
|
377
|
+
label: R(t, "Font size"),
|
|
353
378
|
disabled: n,
|
|
354
379
|
value: e.fontSize === null ? "" : String(e.fontSize),
|
|
355
|
-
options:
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
425
|
+
label: R(t, "Layout view"),
|
|
401
426
|
disabled: !1,
|
|
402
427
|
value: e.viewMode,
|
|
403
428
|
options: [{
|
|
404
429
|
value: "draft",
|
|
405
|
-
label:
|
|
430
|
+
label: R(t, "Draft")
|
|
406
431
|
}, {
|
|
407
432
|
value: "print",
|
|
408
|
-
label:
|
|
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
|
|
414
|
-
let t =
|
|
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:
|
|
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
|
|
437
|
-
let
|
|
438
|
-
|
|
461
|
+
function H(e = {}) {
|
|
462
|
+
let t = M(), n = f(t.state), r = t.subscribe((e) => {
|
|
463
|
+
n.value = e;
|
|
439
464
|
});
|
|
440
|
-
return
|
|
441
|
-
|
|
465
|
+
return h(() => t.update(p(e))), d(() => {
|
|
466
|
+
r(), t.destroy();
|
|
442
467
|
}), {
|
|
443
|
-
canvasProps:
|
|
444
|
-
handle:
|
|
445
|
-
toolbarProps:
|
|
446
|
-
navigationProps:
|
|
447
|
-
statusProps:
|
|
448
|
-
loading:
|
|
449
|
-
error:
|
|
450
|
-
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
|
|
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
|
|
462
|
-
let
|
|
463
|
-
|
|
486
|
+
let n = null, r = (t) => {
|
|
487
|
+
let r = t;
|
|
488
|
+
n !== r && (n = r, e.mount(r));
|
|
464
489
|
};
|
|
465
|
-
return
|
|
466
|
-
t(null),
|
|
467
|
-
}),
|
|
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:
|
|
494
|
+
ref: r
|
|
470
495
|
});
|
|
471
496
|
}
|
|
472
497
|
});
|
|
473
|
-
function
|
|
474
|
-
return e.kind === "text" ?
|
|
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" ?
|
|
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) =>
|
|
508
|
+
}, e.options.map((e) => u("option", {
|
|
484
509
|
key: e.value,
|
|
485
510
|
value: e.value
|
|
486
|
-
}, e.label))) :
|
|
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
|
|
497
|
-
return
|
|
521
|
+
function G(e, t) {
|
|
522
|
+
return u("div", {
|
|
498
523
|
role: e,
|
|
499
|
-
ref: (e) =>
|
|
500
|
-
}, t.map((e, t) =>
|
|
524
|
+
ref: (e) => N(e)
|
|
525
|
+
}, t.map((e, t) => u("span", {
|
|
501
526
|
key: t,
|
|
502
527
|
role: "group"
|
|
503
|
-
}, e.map(
|
|
528
|
+
}, e.map(W))));
|
|
504
529
|
}
|
|
505
|
-
var
|
|
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) => () =>
|
|
512
|
-
}),
|
|
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) => () =>
|
|
519
|
-
}),
|
|
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) => () =>
|
|
550
|
+
setup: (e) => () => G("group", V(e.statusProps))
|
|
526
551
|
});
|
|
527
|
-
|
|
528
|
-
DocumentCanvas: () =>
|
|
529
|
-
PageNavigation: () =>
|
|
530
|
-
StatusBar: () =>
|
|
531
|
-
Toolbar: () =>
|
|
532
|
-
WordEditor: () =>
|
|
533
|
-
detectDocumentFormat: () =>
|
|
534
|
-
loadDocument: () =>
|
|
535
|
-
mountEditorSurface: () =>
|
|
536
|
-
useViewerBuildingBlocks: () =>
|
|
537
|
-
}),
|
|
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 {
|
|
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.
|
|
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.
|
|
45
|
-
"ooxml-ui": "^1.
|
|
44
|
+
"ooxml-core": "^1.25.0",
|
|
45
|
+
"ooxml-ui": "^1.26.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"vue": "^3.5.0"
|