docx-vue-viewer 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.ts +62 -3
- package/dist/index.js +134 -77
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -56,6 +56,10 @@ are available from the package. Framework handles expose `load`, `save` and
|
|
|
56
56
|
framework-free lifecycle management. ProseMirror, `docx-core`, `ooxml-core` and `ooxml-ui` are regular
|
|
57
57
|
dependencies; document and layout algorithms live in OOXML core.
|
|
58
58
|
|
|
59
|
+
## Custom editor UI
|
|
60
|
+
|
|
61
|
+
To render only the controls you use, with your own design system, use the building blocks. `useViewerBuildingBlocks` returns `canvasProps` for `DocumentCanvas` plus flat `toolbarProps`, `navigationProps` and `statusProps`; the optional `Toolbar`, `PageNavigation` and `StatusBar` components consume them. The surface is read-only until you pass `canEdit: true`; a read-only surface still allows selection, keyboard navigation and copy. Hosts that relied on the former editable default must now pass `canEdit: true`. See [Building blocks](https://christophervr.github.io/ooxml/docx/building-blocks).
|
|
62
|
+
|
|
59
63
|
## Limitations
|
|
60
64
|
|
|
61
65
|
This is an early editor. It does not establish Microsoft Word layout parity or
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ 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, SurfaceHostActions, DocxEditorElement, 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';
|
|
@@ -10,6 +11,9 @@ export { DocumentFormat, detectDocumentFormat, loadDocument } from 'ooxml-core/d
|
|
|
10
11
|
declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
11
12
|
documentModel: PropType<DocumentModel>;
|
|
12
13
|
readOnly: BooleanConstructor;
|
|
14
|
+
fileName: StringConstructor;
|
|
15
|
+
reviewAuthor: StringConstructor;
|
|
16
|
+
themeColors: PropType<Partial<EditorTheme>>;
|
|
13
17
|
locale: StringConstructor;
|
|
14
18
|
theme: PropType<EditorThemeMode>;
|
|
15
19
|
showThumbnails: BooleanConstructor;
|
|
@@ -20,11 +24,16 @@ declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
20
24
|
hiddenActions: PropType<readonly RibbonActionInput[]>;
|
|
21
25
|
ribbonAddIns: PropType<readonly RibbonAddInTab[]>;
|
|
22
26
|
collaboration: PropType<DocxCollaborationOptions | null>;
|
|
27
|
+
storage: PropType<DocumentStorage | null>;
|
|
28
|
+
customization: PropType<WordCustomization | null>;
|
|
23
29
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
24
30
|
[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<{
|
|
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<{
|
|
26
32
|
documentModel: PropType<DocumentModel>;
|
|
27
33
|
readOnly: BooleanConstructor;
|
|
34
|
+
fileName: StringConstructor;
|
|
35
|
+
reviewAuthor: StringConstructor;
|
|
36
|
+
themeColors: PropType<Partial<EditorTheme>>;
|
|
28
37
|
locale: StringConstructor;
|
|
29
38
|
theme: PropType<EditorThemeMode>;
|
|
30
39
|
showThumbnails: BooleanConstructor;
|
|
@@ -35,13 +44,21 @@ declare const WordEditor: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
35
44
|
hiddenActions: PropType<readonly RibbonActionInput[]>;
|
|
36
45
|
ribbonAddIns: PropType<readonly RibbonAddInTab[]>;
|
|
37
46
|
collaboration: PropType<DocxCollaborationOptions | null>;
|
|
47
|
+
storage: PropType<DocumentStorage | null>;
|
|
48
|
+
customization: PropType<WordCustomization | null>;
|
|
38
49
|
}>> & Readonly<{
|
|
39
50
|
"onDocument-change"?: (...args: any[]) => any;
|
|
40
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;
|
|
41
57
|
"onPage-change"?: (...args: any[]) => any;
|
|
42
58
|
"onDirty-change"?: (...args: any[]) => any;
|
|
43
59
|
"onCollaboration-change"?: (...args: any[]) => any;
|
|
44
60
|
"onOffice-ribbon-add-in"?: (...args: any[]) => any;
|
|
61
|
+
"onUpdate:readOnly"?: (...args: any[]) => any;
|
|
45
62
|
}>, {
|
|
46
63
|
readOnly: boolean;
|
|
47
64
|
showThumbnails: boolean;
|
|
@@ -56,6 +73,15 @@ interface EditorProps {
|
|
|
56
73
|
locale?: EditorLocaleInput | undefined;
|
|
57
74
|
/** `light`, `dark`, or `auto` (default) to follow the OS color scheme. */
|
|
58
75
|
theme?: EditorThemeMode | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Name shown in the title bar and used by Save and Download (default `Document1.docx`). Forwarded
|
|
78
|
+
* when the prop changes, so File > Open can rename the document without being reverted.
|
|
79
|
+
*/
|
|
80
|
+
fileName?: string | undefined;
|
|
81
|
+
/** Author recorded on tracked changes and comments. Default `Author`. Forwarded when it changes. */
|
|
82
|
+
reviewAuthor?: string | undefined;
|
|
83
|
+
/** Token overrides applied as `--dve-*` custom properties. Forwarded when its values change. */
|
|
84
|
+
themeColors?: Partial<EditorTheme> | undefined;
|
|
59
85
|
/** Left rail of page thumbnails (needs Print Layout). Default false. */
|
|
60
86
|
showThumbnails?: boolean | undefined;
|
|
61
87
|
/** Ribbon visibility. Default true. */
|
|
@@ -69,6 +95,17 @@ interface EditorProps {
|
|
|
69
95
|
* Forwarded only when the object changes, so pass a stable object, not a new literal per render.
|
|
70
96
|
*/
|
|
71
97
|
collaboration?: DocxCollaborationOptions | null | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Host-owned storage: File > Save and Save As go to `storage.save()` instead of a download, and
|
|
100
|
+
* File > Open to `storage.open()` when it has one. `file-command` still fires first.
|
|
101
|
+
*/
|
|
102
|
+
storage?: DocumentStorage | null | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Host customisation (`WordCustomization`): `capabilities`, `backstage.extraPages` and
|
|
105
|
+
* `contextMenu.extraCommands`. Forwarded when the object changes, so keep it stable (memoise
|
|
106
|
+
* it); `null` or omitted restores the defaults.
|
|
107
|
+
*/
|
|
108
|
+
customization?: WordCustomization | null | undefined;
|
|
72
109
|
}
|
|
73
110
|
/** Editor callbacks; each is the framework-neutral form of one entry in `EDITOR_EVENT_NAMES`. */
|
|
74
111
|
interface EditorEventOptions {
|
|
@@ -76,6 +113,28 @@ interface EditorEventOptions {
|
|
|
76
113
|
onDocumentError?: ((error: Error) => void) | undefined;
|
|
77
114
|
onPageChange?: ((detail: PageChangeDetail) => void) | undefined;
|
|
78
115
|
onDirtyChange?: ((dirty: boolean) => void) | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* A File command (new, open, save, saveAs, export, exportText, print, share) is about to run. The
|
|
118
|
+
* event is cancelable: call `event.preventDefault()` to take the command over yourself.
|
|
119
|
+
*/
|
|
120
|
+
onFileCommand?: ((event: CustomEvent<FileCommandDetail>) => void) | undefined;
|
|
121
|
+
/** A non-fatal notice, such as a print layout that could not be produced faithfully. */
|
|
122
|
+
onDocumentWarning?: ((message: string) => void) | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* The user toggled Editing / Viewing, `readOnly` changed or a collaboration role changed.
|
|
125
|
+
* `readOnly` is the effective value. A parent that syncs the `readOnly` prop from this callback
|
|
126
|
+
* must store `detail.hostReadOnly`, never `readOnly`, or a `viewer` role lock would be
|
|
127
|
+
* written into the host's setting.
|
|
128
|
+
*/
|
|
129
|
+
onReadOnlyChange?: ((readOnly: boolean, detail: {
|
|
130
|
+
readOnly: boolean;
|
|
131
|
+
locked: boolean;
|
|
132
|
+
hostReadOnly: boolean;
|
|
133
|
+
}) => void) | undefined;
|
|
134
|
+
/** A ribbon control was activated. */
|
|
135
|
+
onRibbonAction?: ((detail: RibbonAction) => void) | undefined;
|
|
136
|
+
/** The user changed which ribbon commands are shown (File > Customize Ribbon); persist the ids. */
|
|
137
|
+
onRibbonCustomize?: ((ids: readonly string[]) => void) | undefined;
|
|
79
138
|
/** A command of a host tab (`ribbonAddIns`) was chosen. */
|
|
80
139
|
onRibbonAddIn?: ((detail: RibbonAddInCommandDetail) => void) | undefined;
|
|
81
140
|
/** Sharing started, stopped, reconnected or the people in the room changed. */
|
|
@@ -255,7 +314,7 @@ declare function useViewerBuildingBlocks(options?: MaybeRefOrGetter<BuildingBloc
|
|
|
255
314
|
} | null>;
|
|
256
315
|
loading: vue.ComputedRef<boolean>;
|
|
257
316
|
error: vue.ComputedRef<Error | null>;
|
|
258
|
-
mode: vue.ComputedRef<"
|
|
317
|
+
mode: vue.ComputedRef<"edit" | "view">;
|
|
259
318
|
};
|
|
260
319
|
declare const DocumentCanvas: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
261
320
|
mount: {
|
package/dist/index.js
CHANGED
|
@@ -21,59 +21,104 @@ var m = Object.defineProperty, h = Object.getOwnPropertyDescriptor, g = Object.g
|
|
|
21
21
|
import * as S from "ooxml-ui/docx";
|
|
22
22
|
b(x, S);
|
|
23
23
|
//#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
|
|
24
37
|
//#region packages/bindings/src/index.ts
|
|
25
|
-
var
|
|
38
|
+
var T = [
|
|
26
39
|
"documentModel",
|
|
27
40
|
"readOnly",
|
|
41
|
+
"fileName",
|
|
42
|
+
"reviewAuthor",
|
|
43
|
+
"themeColors",
|
|
28
44
|
"locale",
|
|
29
45
|
"theme",
|
|
30
46
|
"showThumbnails",
|
|
31
47
|
"showToolbar",
|
|
32
48
|
"hiddenActions",
|
|
33
49
|
"ribbonAddIns",
|
|
34
|
-
"collaboration"
|
|
35
|
-
|
|
50
|
+
"collaboration",
|
|
51
|
+
"storage",
|
|
52
|
+
"customization"
|
|
53
|
+
], E = [
|
|
36
54
|
"document-change",
|
|
37
55
|
"document-error",
|
|
56
|
+
"document-warning",
|
|
38
57
|
"page-change",
|
|
39
58
|
"dirty-change",
|
|
59
|
+
"readonly-change",
|
|
60
|
+
"file-command",
|
|
61
|
+
"ribbon-action",
|
|
62
|
+
"ribbon-customize",
|
|
40
63
|
"office-ribbon-add-in",
|
|
41
64
|
"collaboration-change"
|
|
42
65
|
];
|
|
43
|
-
function
|
|
66
|
+
function D(e, t) {
|
|
44
67
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
45
68
|
}
|
|
46
|
-
function
|
|
69
|
+
function O(e, t, n) {
|
|
47
70
|
e[n] = t[n];
|
|
48
71
|
}
|
|
49
|
-
function
|
|
72
|
+
function k(e) {
|
|
50
73
|
let t = {};
|
|
51
|
-
for (let n of
|
|
74
|
+
for (let n of T) O(t, e, n);
|
|
52
75
|
return t;
|
|
53
76
|
}
|
|
54
|
-
function
|
|
77
|
+
function A(e) {
|
|
55
78
|
return {
|
|
56
79
|
onDocumentChange: e["document-change"],
|
|
57
80
|
onDocumentError: e["document-error"],
|
|
58
81
|
onPageChange: e["page-change"],
|
|
59
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"],
|
|
60
88
|
onRibbonAddIn: e["office-ribbon-add-in"],
|
|
61
89
|
onCollaborationChange: e["collaboration-change"]
|
|
62
90
|
};
|
|
63
91
|
}
|
|
64
|
-
function
|
|
92
|
+
function j(e, t = {}, n = !1) {
|
|
65
93
|
(0, x.registerDocxEditor)();
|
|
66
94
|
let r = e.ownerDocument.createElement("docx-editor");
|
|
67
95
|
if (n && typeof r.getToolbarProps != "function") throw Error("Update ooxml-ui to use editor building blocks.");
|
|
68
96
|
r.surfaceOnly = n;
|
|
69
|
-
let i = {}, a, o, s, c = null, l = !1, u = (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
97
|
+
let i = {}, a, o, s, c = null, l = !1, u = w(), d = {
|
|
98
|
+
"document-change": (e) => {
|
|
99
|
+
o = e.detail, i.onDocumentChange?.(o);
|
|
100
|
+
},
|
|
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 = {
|
|
74
119
|
element: r,
|
|
75
120
|
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,
|
|
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);
|
|
77
122
|
},
|
|
78
123
|
load: (e) => r.load(e),
|
|
79
124
|
save: () => r.save(),
|
|
@@ -83,12 +128,12 @@ function k(e, t = {}, n = !1) {
|
|
|
83
128
|
return r.dirty;
|
|
84
129
|
},
|
|
85
130
|
destroy() {
|
|
86
|
-
l || (l = !0,
|
|
131
|
+
l || (l = !0, f(!1, E.filter((e) => e !== "collaboration-change")), c && r.stopCollaboration(), f(!1, ["collaboration-change"]), r.remove());
|
|
87
132
|
}
|
|
88
133
|
};
|
|
89
|
-
return
|
|
134
|
+
return p.update(t), e.append(r), p;
|
|
90
135
|
}
|
|
91
|
-
function
|
|
136
|
+
function M(e, t = {}) {
|
|
92
137
|
let n = (e) => ({
|
|
93
138
|
...e,
|
|
94
139
|
readOnly: e.canEdit !== !0 || e.readOnly === !0
|
|
@@ -96,7 +141,7 @@ function A(e, t = {}) {
|
|
|
96
141
|
...e.onOpenHyperlinkDialog && { onOpenHyperlinkDialog: e.onOpenHyperlinkDialog },
|
|
97
142
|
...e.onOpenFindReplace && { onOpenFindReplace: e.onOpenFindReplace },
|
|
98
143
|
...e.onOpenImagePicker && { onOpenImagePicker: e.onOpenImagePicker }
|
|
99
|
-
}), i =
|
|
144
|
+
}), i = j(e, n(t), !0), a = i.update, o = (e) => {
|
|
100
145
|
let t = r(e), n = i.element.surfaceActions;
|
|
101
146
|
[.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(t)])].some((e) => n[e] !== t[e]) && (i.element.surfaceActions = t);
|
|
102
147
|
};
|
|
@@ -112,11 +157,14 @@ function A(e, t = {}) {
|
|
|
112
157
|
}
|
|
113
158
|
//#endregion
|
|
114
159
|
//#region packages/bindings/src/vue.ts
|
|
115
|
-
var
|
|
160
|
+
var N = t({
|
|
116
161
|
name: "WordEditor",
|
|
117
162
|
props: {
|
|
118
163
|
documentModel: Object,
|
|
119
164
|
readOnly: Boolean,
|
|
165
|
+
fileName: String,
|
|
166
|
+
reviewAuthor: String,
|
|
167
|
+
themeColors: Object,
|
|
120
168
|
locale: String,
|
|
121
169
|
theme: String,
|
|
122
170
|
showThumbnails: Boolean,
|
|
@@ -126,24 +174,33 @@ var j = t({
|
|
|
126
174
|
},
|
|
127
175
|
hiddenActions: Array,
|
|
128
176
|
ribbonAddIns: Array,
|
|
129
|
-
collaboration: Object
|
|
177
|
+
collaboration: Object,
|
|
178
|
+
storage: Object,
|
|
179
|
+
customization: Object
|
|
130
180
|
},
|
|
131
|
-
emits: [...
|
|
181
|
+
emits: [...E, "update:readOnly"],
|
|
132
182
|
setup(e, { emit: t, expose: a }) {
|
|
133
183
|
let s = o(), c, u = () => ({
|
|
134
|
-
...
|
|
135
|
-
...
|
|
184
|
+
...k(e),
|
|
185
|
+
...A({
|
|
136
186
|
"document-change": (e) => t("document-change", e),
|
|
137
187
|
"document-error": (e) => t("document-error", e),
|
|
138
188
|
"page-change": (e) => t("page-change", e),
|
|
139
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),
|
|
140
197
|
"office-ribbon-add-in": (e) => t("office-ribbon-add-in", e),
|
|
141
198
|
"collaboration-change": (e) => t("collaboration-change", e)
|
|
142
199
|
})
|
|
143
200
|
});
|
|
144
201
|
return i(() => {
|
|
145
|
-
c =
|
|
146
|
-
}), l(() =>
|
|
202
|
+
c = j(s.value, u());
|
|
203
|
+
}), l(() => T.map((t) => e[t]), () => c?.update(u())), r(() => c?.destroy()), a({
|
|
147
204
|
get element() {
|
|
148
205
|
return c?.element;
|
|
149
206
|
},
|
|
@@ -167,15 +224,15 @@ var j = t({
|
|
|
167
224
|
}
|
|
168
225
|
}), () => n("div", { ref: s });
|
|
169
226
|
}
|
|
170
|
-
}),
|
|
227
|
+
}), P = /* @__PURE__ */ v({
|
|
171
228
|
detectDocumentFormat: () => d,
|
|
172
229
|
loadDocument: () => f,
|
|
173
|
-
mountEditorSurface: () =>
|
|
230
|
+
mountEditorSurface: () => M
|
|
174
231
|
});
|
|
175
|
-
b(
|
|
232
|
+
b(P, x);
|
|
176
233
|
//#endregion
|
|
177
234
|
//#region packages/bindings/src/building-blocks.ts
|
|
178
|
-
function
|
|
235
|
+
function F(e = {}) {
|
|
179
236
|
let t = e, n, r, i, a = 0, o = null, s, c = {
|
|
180
237
|
toolbarProps: null,
|
|
181
238
|
navigationProps: null,
|
|
@@ -226,7 +283,7 @@ function N(e = {}) {
|
|
|
226
283
|
}, g = () => {
|
|
227
284
|
n && t.bytes && i !== t.bytes && (i = t.bytes, h(t.bytes).catch(() => {}));
|
|
228
285
|
}, _ = (e) => {
|
|
229
|
-
e !== o && (o = e, ++a, r?.(), r = void 0, n?.destroy(), n = void 0, i = void 0, e && (n =
|
|
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());
|
|
230
287
|
};
|
|
231
288
|
return {
|
|
232
289
|
canvasProps: { mount: _ },
|
|
@@ -258,14 +315,14 @@ function N(e = {}) {
|
|
|
258
315
|
}
|
|
259
316
|
};
|
|
260
317
|
}
|
|
261
|
-
function
|
|
318
|
+
function I(e) {
|
|
262
319
|
if (!e) return;
|
|
263
320
|
let t = Reflect.get(p, "prepareOfficeUiBlock");
|
|
264
321
|
typeof t == "function" ? t(e, "toolbar", "docx") : (p.installOfficeUiTheme(e.ownerDocument), e.setAttribute("data-office-block", "toolbar"), e.setAttribute("data-office-product", "docx"));
|
|
265
322
|
}
|
|
266
323
|
//#endregion
|
|
267
324
|
//#region packages/bindings/src/controls.ts
|
|
268
|
-
var
|
|
325
|
+
var L = [
|
|
269
326
|
"Calibri",
|
|
270
327
|
"Arial",
|
|
271
328
|
"Cambria",
|
|
@@ -274,7 +331,7 @@ var F = [
|
|
|
274
331
|
"Segoe UI",
|
|
275
332
|
"Times New Roman",
|
|
276
333
|
"Verdana"
|
|
277
|
-
],
|
|
334
|
+
], R = [
|
|
278
335
|
8,
|
|
279
336
|
9,
|
|
280
337
|
10,
|
|
@@ -289,7 +346,7 @@ var F = [
|
|
|
289
346
|
36,
|
|
290
347
|
48,
|
|
291
348
|
72
|
|
292
|
-
],
|
|
349
|
+
], z = [
|
|
293
350
|
50,
|
|
294
351
|
75,
|
|
295
352
|
100,
|
|
@@ -297,7 +354,7 @@ var F = [
|
|
|
297
354
|
150,
|
|
298
355
|
200
|
|
299
356
|
];
|
|
300
|
-
function
|
|
357
|
+
function B(e, t) {
|
|
301
358
|
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
359
|
value: e,
|
|
303
360
|
label: e
|
|
@@ -307,32 +364,32 @@ function R(e, t) {
|
|
|
307
364
|
label: ""
|
|
308
365
|
}, ...r] : r;
|
|
309
366
|
}
|
|
310
|
-
var
|
|
311
|
-
function
|
|
367
|
+
var V = (e, t) => e[t] ?? t;
|
|
368
|
+
function H(e) {
|
|
312
369
|
let { labels: t } = e, n = !e.canEdit, r = (e, r, i, a) => ({
|
|
313
370
|
kind: "toggle",
|
|
314
371
|
id: e,
|
|
315
|
-
label:
|
|
372
|
+
label: V(t, r),
|
|
316
373
|
disabled: n,
|
|
317
374
|
pressed: i === null ? "mixed" : i,
|
|
318
375
|
run: () => void a()
|
|
319
376
|
}), i = (e, n, r, i) => ({
|
|
320
377
|
kind: "action",
|
|
321
378
|
id: e,
|
|
322
|
-
label:
|
|
379
|
+
label: V(t, n),
|
|
323
380
|
disabled: r,
|
|
324
381
|
run: () => void i()
|
|
325
382
|
}), a = (r, i, a) => ({
|
|
326
383
|
kind: "toggle",
|
|
327
384
|
id: r,
|
|
328
|
-
label:
|
|
385
|
+
label: V(t, i),
|
|
329
386
|
disabled: n,
|
|
330
387
|
pressed: e.alignment === null ? "mixed" : e.alignment === a,
|
|
331
388
|
run: () => void e.onAlignmentChange(a)
|
|
332
389
|
}), o = (r, i, a) => ({
|
|
333
390
|
kind: "toggle",
|
|
334
391
|
id: r,
|
|
335
|
-
label:
|
|
392
|
+
label: V(t, i),
|
|
336
393
|
disabled: n,
|
|
337
394
|
pressed: e.list === a,
|
|
338
395
|
run: () => void e.onListChange(e.list === a ? "remove" : a)
|
|
@@ -341,18 +398,18 @@ function B(e) {
|
|
|
341
398
|
[{
|
|
342
399
|
kind: "select",
|
|
343
400
|
id: "fontFamily",
|
|
344
|
-
label:
|
|
401
|
+
label: V(t, "Font"),
|
|
345
402
|
disabled: n,
|
|
346
403
|
value: e.fontFamily ?? "",
|
|
347
|
-
options:
|
|
404
|
+
options: B(L, e.fontFamily),
|
|
348
405
|
change: (t) => void e.onFontFamilyChange(t)
|
|
349
406
|
}, {
|
|
350
407
|
kind: "select",
|
|
351
408
|
id: "fontSize",
|
|
352
|
-
label:
|
|
409
|
+
label: V(t, "Font size"),
|
|
353
410
|
disabled: n,
|
|
354
411
|
value: e.fontSize === null ? "" : String(e.fontSize),
|
|
355
|
-
options: R
|
|
412
|
+
options: B(R, e.fontSize),
|
|
356
413
|
change: (t) => void e.onFontSizeChange(Number(t))
|
|
357
414
|
}],
|
|
358
415
|
[
|
|
@@ -370,13 +427,13 @@ function B(e) {
|
|
|
370
427
|
], c = [], { hyperlink: l, findReplace: u, picture: d } = e.hostWorkflows;
|
|
371
428
|
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
429
|
}
|
|
373
|
-
function
|
|
430
|
+
function U(e) {
|
|
374
431
|
let { labels: t } = e;
|
|
375
432
|
return [[
|
|
376
433
|
{
|
|
377
434
|
kind: "action",
|
|
378
435
|
id: "previousPage",
|
|
379
|
-
label:
|
|
436
|
+
label: V(t, "Previous page"),
|
|
380
437
|
disabled: !e.canGoPrevious,
|
|
381
438
|
run: () => void e.onPreviousPage()
|
|
382
439
|
},
|
|
@@ -390,28 +447,28 @@ function V(e) {
|
|
|
390
447
|
{
|
|
391
448
|
kind: "action",
|
|
392
449
|
id: "nextPage",
|
|
393
|
-
label:
|
|
450
|
+
label: V(t, "Next page"),
|
|
394
451
|
disabled: !e.canGoNext,
|
|
395
452
|
run: () => void e.onNextPage()
|
|
396
453
|
}
|
|
397
454
|
], [{
|
|
398
455
|
kind: "select",
|
|
399
456
|
id: "viewMode",
|
|
400
|
-
label:
|
|
457
|
+
label: V(t, "Layout view"),
|
|
401
458
|
disabled: !1,
|
|
402
459
|
value: e.viewMode,
|
|
403
460
|
options: [{
|
|
404
461
|
value: "draft",
|
|
405
|
-
label:
|
|
462
|
+
label: V(t, "Draft")
|
|
406
463
|
}, {
|
|
407
464
|
value: "print",
|
|
408
|
-
label:
|
|
465
|
+
label: V(t, "Print Layout")
|
|
409
466
|
}],
|
|
410
467
|
change: (t) => void e.onViewModeChange(t === "print" ? "print" : "draft")
|
|
411
468
|
}]];
|
|
412
469
|
}
|
|
413
|
-
function
|
|
414
|
-
let t =
|
|
470
|
+
function W(e) {
|
|
471
|
+
let t = B(z, e.zoom).map((e) => ({
|
|
415
472
|
value: e.value,
|
|
416
473
|
label: `${e.label}%`
|
|
417
474
|
}));
|
|
@@ -424,7 +481,7 @@ function H(e) {
|
|
|
424
481
|
}], [{
|
|
425
482
|
kind: "select",
|
|
426
483
|
id: "zoom",
|
|
427
|
-
label:
|
|
484
|
+
label: V(e.labels, "Zoom"),
|
|
428
485
|
disabled: !1,
|
|
429
486
|
value: String(e.zoom),
|
|
430
487
|
options: t,
|
|
@@ -433,8 +490,8 @@ function H(e) {
|
|
|
433
490
|
}
|
|
434
491
|
//#endregion
|
|
435
492
|
//#region packages/vue/src/building-blocks.ts
|
|
436
|
-
function
|
|
437
|
-
let n =
|
|
493
|
+
function G(t = {}) {
|
|
494
|
+
let n = F(), r = s(n.state), i = n.subscribe((e) => {
|
|
438
495
|
r.value = e;
|
|
439
496
|
});
|
|
440
497
|
return u(() => n.update(c(t))), a(() => {
|
|
@@ -450,7 +507,7 @@ function U(t = {}) {
|
|
|
450
507
|
mode: e(() => r.value.mode)
|
|
451
508
|
};
|
|
452
509
|
}
|
|
453
|
-
var
|
|
510
|
+
var K = t({
|
|
454
511
|
name: "DocumentCanvas",
|
|
455
512
|
inheritAttrs: !1,
|
|
456
513
|
props: { mount: {
|
|
@@ -470,7 +527,7 @@ var W = t({
|
|
|
470
527
|
});
|
|
471
528
|
}
|
|
472
529
|
});
|
|
473
|
-
function
|
|
530
|
+
function q(e) {
|
|
474
531
|
return e.kind === "text" ? n("span", {
|
|
475
532
|
key: e.id,
|
|
476
533
|
role: "status"
|
|
@@ -493,47 +550,47 @@ function G(e) {
|
|
|
493
550
|
onClick: e.run
|
|
494
551
|
}, e.label);
|
|
495
552
|
}
|
|
496
|
-
function
|
|
553
|
+
function J(e, t) {
|
|
497
554
|
return n("div", {
|
|
498
555
|
role: e,
|
|
499
|
-
ref: (e) =>
|
|
556
|
+
ref: (e) => I(e)
|
|
500
557
|
}, t.map((e, t) => n("span", {
|
|
501
558
|
key: t,
|
|
502
559
|
role: "group"
|
|
503
|
-
}, e.map(
|
|
560
|
+
}, e.map(q))));
|
|
504
561
|
}
|
|
505
|
-
var
|
|
562
|
+
var Y = t({
|
|
506
563
|
name: "WordToolbar",
|
|
507
564
|
props: { toolbarProps: {
|
|
508
565
|
type: Object,
|
|
509
566
|
required: !0
|
|
510
567
|
} },
|
|
511
|
-
setup: (e) => () =>
|
|
512
|
-
}),
|
|
568
|
+
setup: (e) => () => J("toolbar", H(e.toolbarProps))
|
|
569
|
+
}), X = t({
|
|
513
570
|
name: "WordPageNavigation",
|
|
514
571
|
props: { navigationProps: {
|
|
515
572
|
type: Object,
|
|
516
573
|
required: !0
|
|
517
574
|
} },
|
|
518
|
-
setup: (e) => () =>
|
|
519
|
-
}),
|
|
575
|
+
setup: (e) => () => J("group", U(e.navigationProps))
|
|
576
|
+
}), Z = t({
|
|
520
577
|
name: "WordStatusBar",
|
|
521
578
|
props: { statusProps: {
|
|
522
579
|
type: Object,
|
|
523
580
|
required: !0
|
|
524
581
|
} },
|
|
525
|
-
setup: (e) => () =>
|
|
582
|
+
setup: (e) => () => J("group", W(e.statusProps))
|
|
526
583
|
});
|
|
527
584
|
b(/* @__PURE__ */ v({
|
|
528
|
-
DocumentCanvas: () =>
|
|
529
|
-
PageNavigation: () =>
|
|
530
|
-
StatusBar: () =>
|
|
531
|
-
Toolbar: () =>
|
|
532
|
-
WordEditor: () =>
|
|
585
|
+
DocumentCanvas: () => K,
|
|
586
|
+
PageNavigation: () => X,
|
|
587
|
+
StatusBar: () => Z,
|
|
588
|
+
Toolbar: () => Y,
|
|
589
|
+
WordEditor: () => N,
|
|
533
590
|
detectDocumentFormat: () => d,
|
|
534
591
|
loadDocument: () => f,
|
|
535
|
-
mountEditorSurface: () =>
|
|
536
|
-
useViewerBuildingBlocks: () =>
|
|
537
|
-
}),
|
|
592
|
+
mountEditorSurface: () => M,
|
|
593
|
+
useViewerBuildingBlocks: () => G
|
|
594
|
+
}), P);
|
|
538
595
|
//#endregion
|
|
539
|
-
export {
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docx-vue-viewer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
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.24.0",
|
|
45
|
+
"ooxml-ui": "^1.23.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"vue": "^3.5.0"
|