visio-svelte-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 +1 -1
- package/dist/VisioViewer.svelte +2 -2
- package/dist/index.js +45 -79
- package/dist/index.server.js +42 -75
- package/dist/runtime.js +44 -81
- package/dist/types/packages/bindings/src/common.d.ts +11 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ npm install visio-svelte-viewer
|
|
|
46
46
|
The shared properties are `document` (a parsed `VisioDocument`, or `null` to clear),
|
|
47
47
|
`pageIndex` (zero-based), `zoom` (`1` means 100%), `showToolbar`, `ribbonAddIns` (tabs the host adds
|
|
48
48
|
after Help), `canEdit` (editing permission; the viewer is editable unless you pass `false`),
|
|
49
|
-
`collaboration` (shares the open drawing in a room while set; `null` leaves it) and `events`.
|
|
49
|
+
`readOnly` (a restriction of its own), `storage` and `customization` (host-owned save and open), `collaboration` (shares the open drawing in a room while set; `null` leaves it) and `events`.
|
|
50
50
|
The callback map uses `document-load`, `document-change` (`{ document, dirty, kind }` with kind
|
|
51
51
|
`edit`, `undo`, `redo`, `remote` or `save`), `document-error`, `page-change`, `zoom-change`,
|
|
52
52
|
`shape-select`, `selection-change`, `office-ribbon-add-in` and `collaboration-change`. File loading uses the imperative
|
package/dist/VisioViewer.svelte
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { readonly, writable } from 'svelte/store';
|
|
4
4
|
import { mountFrameworkViewer, viewerHandle, viewerOptions, viewerStateSource, type ViewerState, type MountedViewer, type ViewerProps, type VsdxSource, type VisioEdit, type VisioShapeSelection, type SvgExportOptions, type CurrentPagePrintSnapshotOptions } from './runtime.js';
|
|
5
5
|
type Props = ViewerProps & { class?: string; style?: string; 'aria-label'?: string };
|
|
6
|
-
let { document, pageIndex, zoom, showToolbar, canEdit, ribbonAddIns, collaboration, events, class: className, style, 'aria-label': ariaLabel }: Props = $props();
|
|
7
|
-
const options = $derived({ document, pageIndex, zoom, showToolbar, canEdit, ribbonAddIns, collaboration, events } satisfies Required<ViewerProps>);
|
|
6
|
+
let { document, pageIndex, zoom, showToolbar, canEdit, readOnly, ribbonAddIns, collaboration, customization, storage, events, class: className, style, 'aria-label': ariaLabel }: Props = $props();
|
|
7
|
+
const options = $derived({ document, pageIndex, zoom, showToolbar, canEdit, readOnly, ribbonAddIns, collaboration, customization, storage, events } satisfies Required<ViewerProps>);
|
|
8
8
|
let binding: MountedViewer | undefined;
|
|
9
9
|
const handle = viewerHandle(() => binding);
|
|
10
10
|
// The component owns its state store, so subscribers made before mount still see updates.
|
package/dist/index.js
CHANGED
|
@@ -3,19 +3,53 @@ import { ViewerController, createWorkerParser, mountViewer, propertyKeys } from
|
|
|
3
3
|
import "svelte/internal/disclose-version";
|
|
4
4
|
import * as $ from "svelte/internal/client";
|
|
5
5
|
import { derived, get, readonly, writable } from "svelte/store";
|
|
6
|
+
import { deferredHandle, pickProps } from "ooxml-ui/bindings";
|
|
6
7
|
import { onDestroy } from "svelte";
|
|
7
8
|
import * as officeTheme from "ooxml-ui/theme";
|
|
8
9
|
export * from "ooxml-ui/visio";
|
|
9
10
|
export * from "visio-core";
|
|
10
11
|
//#region packages/bindings/src/common.ts
|
|
12
|
+
/**
|
|
13
|
+
* The Visio binding contract. `mountViewer` (ooxml-ui/visio) forwards properties and events itself,
|
|
14
|
+
* so every property is `manual` here: `mountFrameworkViewer` sends them as revision-aware patches.
|
|
15
|
+
* Events reach native outputs through the `events` callback map (`withEventEmitter`).
|
|
16
|
+
*/
|
|
17
|
+
var VIEWER_CONTRACT = {
|
|
18
|
+
props: Object.fromEntries(propertyKeys.map((key) => [key, { forward: "manual" }])),
|
|
19
|
+
events: {},
|
|
20
|
+
handle: {
|
|
21
|
+
element: "get",
|
|
22
|
+
controller: "get",
|
|
23
|
+
load: "async",
|
|
24
|
+
createBlankDrawing: "async",
|
|
25
|
+
applyEdits: "async",
|
|
26
|
+
selectShapes: "call",
|
|
27
|
+
selectAll: "call",
|
|
28
|
+
clearSelection: "call",
|
|
29
|
+
duplicateSelection: "async",
|
|
30
|
+
copySelection: "async",
|
|
31
|
+
cutSelection: "async",
|
|
32
|
+
pasteSelection: "async",
|
|
33
|
+
replacePlainText: "async",
|
|
34
|
+
undo: "async",
|
|
35
|
+
redo: "async",
|
|
36
|
+
cancelEdit: "call",
|
|
37
|
+
exportVsdx: "call",
|
|
38
|
+
fit: "call",
|
|
39
|
+
setLayerVisibility: "call",
|
|
40
|
+
resetLayerVisibility: "call",
|
|
41
|
+
exportSvg: "call",
|
|
42
|
+
createPrintSnapshot: "call"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/** The error every lazy handle member throws before mount and after unmount. */
|
|
46
|
+
var VIEWER_HANDLE_OPTIONS = { message: "The viewer is not mounted." };
|
|
11
47
|
/** One mapping for every property and event, shared by every framework adapter. */
|
|
12
48
|
function viewerOptions(props) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
49
|
+
return {
|
|
50
|
+
events: props.events ?? {},
|
|
51
|
+
...pickProps(VIEWER_CONTRACT, props, true)
|
|
52
|
+
};
|
|
19
53
|
}
|
|
20
54
|
/**
|
|
21
55
|
* Native props are snapshots, while the browser binding accepts explicit patches. Forward only
|
|
@@ -38,6 +72,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
38
72
|
const touchedByOlderCall = [...activePatches].some((active) => key in active);
|
|
39
73
|
if (snapshot[key] !== void 0 && (snapshot[key] !== previous[key] || touchedByOlderCall)) Object.assign(patch, { [key]: snapshot[key] });
|
|
40
74
|
}
|
|
75
|
+
if (snapshot.readOnly === void 0 && previous.readOnly !== void 0) Object.assign(patch, { readOnly: false });
|
|
41
76
|
activePatches.add(patch);
|
|
42
77
|
try {
|
|
43
78
|
binding.update(patch);
|
|
@@ -56,79 +91,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
56
91
|
}
|
|
57
92
|
/** Lazy imperative methods reject both before mount and after unmount. */
|
|
58
93
|
function viewerHandle(current) {
|
|
59
|
-
|
|
60
|
-
const binding = current();
|
|
61
|
-
if (!binding) throw new Error("The viewer is not mounted.");
|
|
62
|
-
return binding;
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
get element() {
|
|
66
|
-
return requireViewer().element;
|
|
67
|
-
},
|
|
68
|
-
get controller() {
|
|
69
|
-
return requireViewer().controller;
|
|
70
|
-
},
|
|
71
|
-
async load(source) {
|
|
72
|
-
await requireViewer().load(source);
|
|
73
|
-
},
|
|
74
|
-
async createBlankDrawing(options) {
|
|
75
|
-
await requireViewer().createBlankDrawing(options);
|
|
76
|
-
},
|
|
77
|
-
async applyEdits(edits) {
|
|
78
|
-
await requireViewer().applyEdits(edits);
|
|
79
|
-
},
|
|
80
|
-
selectShapes(shapes) {
|
|
81
|
-
requireViewer().selectShapes(shapes);
|
|
82
|
-
},
|
|
83
|
-
selectAll() {
|
|
84
|
-
requireViewer().selectAll();
|
|
85
|
-
},
|
|
86
|
-
clearSelection() {
|
|
87
|
-
requireViewer().clearSelection();
|
|
88
|
-
},
|
|
89
|
-
async replacePlainText(pageId, shapeId, text) {
|
|
90
|
-
await requireViewer().replacePlainText(pageId, shapeId, text);
|
|
91
|
-
},
|
|
92
|
-
async duplicateSelection() {
|
|
93
|
-
await requireViewer().duplicateSelection();
|
|
94
|
-
},
|
|
95
|
-
async copySelection() {
|
|
96
|
-
await requireViewer().copySelection();
|
|
97
|
-
},
|
|
98
|
-
async cutSelection() {
|
|
99
|
-
await requireViewer().cutSelection();
|
|
100
|
-
},
|
|
101
|
-
async pasteSelection() {
|
|
102
|
-
await requireViewer().pasteSelection();
|
|
103
|
-
},
|
|
104
|
-
async undo() {
|
|
105
|
-
await requireViewer().undo();
|
|
106
|
-
},
|
|
107
|
-
async redo() {
|
|
108
|
-
await requireViewer().redo();
|
|
109
|
-
},
|
|
110
|
-
cancelEdit() {
|
|
111
|
-
requireViewer().cancelEdit();
|
|
112
|
-
},
|
|
113
|
-
exportVsdx() {
|
|
114
|
-
return requireViewer().exportVsdx();
|
|
115
|
-
},
|
|
116
|
-
fit() {
|
|
117
|
-
requireViewer().fit();
|
|
118
|
-
},
|
|
119
|
-
setLayerVisibility(pageId, layerId, visible) {
|
|
120
|
-
requireViewer().setLayerVisibility(pageId, layerId, visible);
|
|
121
|
-
},
|
|
122
|
-
resetLayerVisibility(pageId) {
|
|
123
|
-
requireViewer().resetLayerVisibility(pageId);
|
|
124
|
-
},
|
|
125
|
-
exportSvg(options) {
|
|
126
|
-
return requireViewer().exportSvg(options);
|
|
127
|
-
},
|
|
128
|
-
createPrintSnapshot(options) {
|
|
129
|
-
return requireViewer().createPrintSnapshot(options);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
94
|
+
return deferredHandle(VIEWER_CONTRACT.handle, current, VIEWER_HANDLE_OPTIONS);
|
|
132
95
|
}
|
|
133
96
|
function viewerStateSource(current) {
|
|
134
97
|
const controller = () => {
|
|
@@ -158,8 +121,11 @@ function VisioViewer($$anchor, $$props) {
|
|
|
158
121
|
zoom: $$props.zoom,
|
|
159
122
|
showToolbar: $$props.showToolbar,
|
|
160
123
|
canEdit: $$props.canEdit,
|
|
124
|
+
readOnly: $$props.readOnly,
|
|
161
125
|
ribbonAddIns: $$props.ribbonAddIns,
|
|
162
126
|
collaboration: $$props.collaboration,
|
|
127
|
+
customization: $$props.customization,
|
|
128
|
+
storage: $$props.storage,
|
|
163
129
|
events: $$props.events
|
|
164
130
|
}));
|
|
165
131
|
let binding;
|
package/dist/index.server.js
CHANGED
|
@@ -1,101 +1,68 @@
|
|
|
1
1
|
import * as ui from "ooxml-ui/visio";
|
|
2
|
-
import { ViewerController, createWorkerParser } from "ooxml-ui/visio";
|
|
2
|
+
import { ViewerController, createWorkerParser, propertyKeys } from "ooxml-ui/visio";
|
|
3
3
|
import * as $ from "svelte/internal/server";
|
|
4
4
|
import { derived, get, readonly, writable } from "svelte/store";
|
|
5
|
+
import { deferredHandle } from "ooxml-ui/bindings";
|
|
5
6
|
import { onDestroy } from "svelte";
|
|
6
7
|
import "ooxml-ui/theme";
|
|
7
8
|
export * from "ooxml-ui/visio";
|
|
8
9
|
export * from "visio-core";
|
|
9
10
|
//#region packages/bindings/src/common.ts
|
|
11
|
+
/**
|
|
12
|
+
* The Visio binding contract. `mountViewer` (ooxml-ui/visio) forwards properties and events itself,
|
|
13
|
+
* so every property is `manual` here: `mountFrameworkViewer` sends them as revision-aware patches.
|
|
14
|
+
* Events reach native outputs through the `events` callback map (`withEventEmitter`).
|
|
15
|
+
*/
|
|
16
|
+
var VIEWER_CONTRACT = {
|
|
17
|
+
props: Object.fromEntries(propertyKeys.map((key) => [key, { forward: "manual" }])),
|
|
18
|
+
events: {},
|
|
19
|
+
handle: {
|
|
20
|
+
element: "get",
|
|
21
|
+
controller: "get",
|
|
22
|
+
load: "async",
|
|
23
|
+
createBlankDrawing: "async",
|
|
24
|
+
applyEdits: "async",
|
|
25
|
+
selectShapes: "call",
|
|
26
|
+
selectAll: "call",
|
|
27
|
+
clearSelection: "call",
|
|
28
|
+
duplicateSelection: "async",
|
|
29
|
+
copySelection: "async",
|
|
30
|
+
cutSelection: "async",
|
|
31
|
+
pasteSelection: "async",
|
|
32
|
+
replacePlainText: "async",
|
|
33
|
+
undo: "async",
|
|
34
|
+
redo: "async",
|
|
35
|
+
cancelEdit: "call",
|
|
36
|
+
exportVsdx: "call",
|
|
37
|
+
fit: "call",
|
|
38
|
+
setLayerVisibility: "call",
|
|
39
|
+
resetLayerVisibility: "call",
|
|
40
|
+
exportSvg: "call",
|
|
41
|
+
createPrintSnapshot: "call"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/** The error every lazy handle member throws before mount and after unmount. */
|
|
45
|
+
var VIEWER_HANDLE_OPTIONS = { message: "The viewer is not mounted." };
|
|
10
46
|
/** Lazy imperative methods reject both before mount and after unmount. */
|
|
11
47
|
function viewerHandle(current) {
|
|
12
|
-
|
|
13
|
-
const binding = current();
|
|
14
|
-
if (!binding) throw new Error("The viewer is not mounted.");
|
|
15
|
-
return binding;
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
get element() {
|
|
19
|
-
return requireViewer().element;
|
|
20
|
-
},
|
|
21
|
-
get controller() {
|
|
22
|
-
return requireViewer().controller;
|
|
23
|
-
},
|
|
24
|
-
async load(source) {
|
|
25
|
-
await requireViewer().load(source);
|
|
26
|
-
},
|
|
27
|
-
async createBlankDrawing(options) {
|
|
28
|
-
await requireViewer().createBlankDrawing(options);
|
|
29
|
-
},
|
|
30
|
-
async applyEdits(edits) {
|
|
31
|
-
await requireViewer().applyEdits(edits);
|
|
32
|
-
},
|
|
33
|
-
selectShapes(shapes) {
|
|
34
|
-
requireViewer().selectShapes(shapes);
|
|
35
|
-
},
|
|
36
|
-
selectAll() {
|
|
37
|
-
requireViewer().selectAll();
|
|
38
|
-
},
|
|
39
|
-
clearSelection() {
|
|
40
|
-
requireViewer().clearSelection();
|
|
41
|
-
},
|
|
42
|
-
async replacePlainText(pageId, shapeId, text) {
|
|
43
|
-
await requireViewer().replacePlainText(pageId, shapeId, text);
|
|
44
|
-
},
|
|
45
|
-
async duplicateSelection() {
|
|
46
|
-
await requireViewer().duplicateSelection();
|
|
47
|
-
},
|
|
48
|
-
async copySelection() {
|
|
49
|
-
await requireViewer().copySelection();
|
|
50
|
-
},
|
|
51
|
-
async cutSelection() {
|
|
52
|
-
await requireViewer().cutSelection();
|
|
53
|
-
},
|
|
54
|
-
async pasteSelection() {
|
|
55
|
-
await requireViewer().pasteSelection();
|
|
56
|
-
},
|
|
57
|
-
async undo() {
|
|
58
|
-
await requireViewer().undo();
|
|
59
|
-
},
|
|
60
|
-
async redo() {
|
|
61
|
-
await requireViewer().redo();
|
|
62
|
-
},
|
|
63
|
-
cancelEdit() {
|
|
64
|
-
requireViewer().cancelEdit();
|
|
65
|
-
},
|
|
66
|
-
exportVsdx() {
|
|
67
|
-
return requireViewer().exportVsdx();
|
|
68
|
-
},
|
|
69
|
-
fit() {
|
|
70
|
-
requireViewer().fit();
|
|
71
|
-
},
|
|
72
|
-
setLayerVisibility(pageId, layerId, visible) {
|
|
73
|
-
requireViewer().setLayerVisibility(pageId, layerId, visible);
|
|
74
|
-
},
|
|
75
|
-
resetLayerVisibility(pageId) {
|
|
76
|
-
requireViewer().resetLayerVisibility(pageId);
|
|
77
|
-
},
|
|
78
|
-
exportSvg(options) {
|
|
79
|
-
return requireViewer().exportSvg(options);
|
|
80
|
-
},
|
|
81
|
-
createPrintSnapshot(options) {
|
|
82
|
-
return requireViewer().createPrintSnapshot(options);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
48
|
+
return deferredHandle(VIEWER_CONTRACT.handle, current, VIEWER_HANDLE_OPTIONS);
|
|
85
49
|
}
|
|
86
50
|
//#endregion
|
|
87
51
|
//#region packages/bindings/src/VisioViewer.svelte
|
|
88
52
|
function VisioViewer($$renderer, $$props) {
|
|
89
53
|
$$renderer.component(($$renderer) => {
|
|
90
|
-
let { document, pageIndex, zoom, showToolbar, canEdit, ribbonAddIns, collaboration, events, class: className, style, "aria-label": ariaLabel } = $$props;
|
|
54
|
+
let { document, pageIndex, zoom, showToolbar, canEdit, readOnly, ribbonAddIns, collaboration, customization, storage, events, class: className, style, "aria-label": ariaLabel } = $$props;
|
|
91
55
|
$.derived(() => ({
|
|
92
56
|
document,
|
|
93
57
|
pageIndex,
|
|
94
58
|
zoom,
|
|
95
59
|
showToolbar,
|
|
96
60
|
canEdit,
|
|
61
|
+
readOnly,
|
|
97
62
|
ribbonAddIns,
|
|
98
63
|
collaboration,
|
|
64
|
+
customization,
|
|
65
|
+
storage,
|
|
99
66
|
events
|
|
100
67
|
}));
|
|
101
68
|
let binding;
|
package/dist/runtime.js
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
import * as ui from "ooxml-ui/visio";
|
|
2
2
|
import { ViewerController, ViewerController as ViewerController$1, createWorkerParser, eventKeys, mountViewer, propertyKeys } from "ooxml-ui/visio";
|
|
3
|
+
import { deferredHandle, pickProps } from "ooxml-ui/bindings";
|
|
3
4
|
import * as officeTheme from "ooxml-ui/theme";
|
|
4
5
|
import { onDestroy } from "svelte";
|
|
5
6
|
import { derived, get, writable } from "svelte/store";
|
|
6
7
|
export * from "ooxml-ui/visio";
|
|
7
8
|
export * from "visio-core";
|
|
8
9
|
//#region packages/bindings/src/common.ts
|
|
10
|
+
/**
|
|
11
|
+
* The Visio binding contract. `mountViewer` (ooxml-ui/visio) forwards properties and events itself,
|
|
12
|
+
* so every property is `manual` here: `mountFrameworkViewer` sends them as revision-aware patches.
|
|
13
|
+
* Events reach native outputs through the `events` callback map (`withEventEmitter`).
|
|
14
|
+
*/
|
|
15
|
+
var VIEWER_CONTRACT = {
|
|
16
|
+
props: Object.fromEntries(propertyKeys.map((key) => [key, { forward: "manual" }])),
|
|
17
|
+
events: {},
|
|
18
|
+
handle: {
|
|
19
|
+
element: "get",
|
|
20
|
+
controller: "get",
|
|
21
|
+
load: "async",
|
|
22
|
+
createBlankDrawing: "async",
|
|
23
|
+
applyEdits: "async",
|
|
24
|
+
selectShapes: "call",
|
|
25
|
+
selectAll: "call",
|
|
26
|
+
clearSelection: "call",
|
|
27
|
+
duplicateSelection: "async",
|
|
28
|
+
copySelection: "async",
|
|
29
|
+
cutSelection: "async",
|
|
30
|
+
pasteSelection: "async",
|
|
31
|
+
replacePlainText: "async",
|
|
32
|
+
undo: "async",
|
|
33
|
+
redo: "async",
|
|
34
|
+
cancelEdit: "call",
|
|
35
|
+
exportVsdx: "call",
|
|
36
|
+
fit: "call",
|
|
37
|
+
setLayerVisibility: "call",
|
|
38
|
+
resetLayerVisibility: "call",
|
|
39
|
+
exportSvg: "call",
|
|
40
|
+
createPrintSnapshot: "call"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** The error every lazy handle member throws before mount and after unmount. */
|
|
44
|
+
var VIEWER_HANDLE_OPTIONS = { message: "The viewer is not mounted." };
|
|
9
45
|
/** One mapping for every property and event, shared by every framework adapter. */
|
|
10
46
|
function viewerOptions(props) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
47
|
+
return {
|
|
48
|
+
events: props.events ?? {},
|
|
49
|
+
...pickProps(VIEWER_CONTRACT, props, true)
|
|
50
|
+
};
|
|
17
51
|
}
|
|
18
52
|
/**
|
|
19
53
|
* Native props are snapshots, while the browser binding accepts explicit patches. Forward only
|
|
@@ -36,6 +70,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
36
70
|
const touchedByOlderCall = [...activePatches].some((active) => key in active);
|
|
37
71
|
if (snapshot[key] !== void 0 && (snapshot[key] !== previous[key] || touchedByOlderCall)) Object.assign(patch, { [key]: snapshot[key] });
|
|
38
72
|
}
|
|
73
|
+
if (snapshot.readOnly === void 0 && previous.readOnly !== void 0) Object.assign(patch, { readOnly: false });
|
|
39
74
|
activePatches.add(patch);
|
|
40
75
|
try {
|
|
41
76
|
binding.update(patch);
|
|
@@ -54,79 +89,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
54
89
|
}
|
|
55
90
|
/** Lazy imperative methods reject both before mount and after unmount. */
|
|
56
91
|
function viewerHandle(current) {
|
|
57
|
-
|
|
58
|
-
const binding = current();
|
|
59
|
-
if (!binding) throw new Error("The viewer is not mounted.");
|
|
60
|
-
return binding;
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
get element() {
|
|
64
|
-
return requireViewer().element;
|
|
65
|
-
},
|
|
66
|
-
get controller() {
|
|
67
|
-
return requireViewer().controller;
|
|
68
|
-
},
|
|
69
|
-
async load(source) {
|
|
70
|
-
await requireViewer().load(source);
|
|
71
|
-
},
|
|
72
|
-
async createBlankDrawing(options) {
|
|
73
|
-
await requireViewer().createBlankDrawing(options);
|
|
74
|
-
},
|
|
75
|
-
async applyEdits(edits) {
|
|
76
|
-
await requireViewer().applyEdits(edits);
|
|
77
|
-
},
|
|
78
|
-
selectShapes(shapes) {
|
|
79
|
-
requireViewer().selectShapes(shapes);
|
|
80
|
-
},
|
|
81
|
-
selectAll() {
|
|
82
|
-
requireViewer().selectAll();
|
|
83
|
-
},
|
|
84
|
-
clearSelection() {
|
|
85
|
-
requireViewer().clearSelection();
|
|
86
|
-
},
|
|
87
|
-
async replacePlainText(pageId, shapeId, text) {
|
|
88
|
-
await requireViewer().replacePlainText(pageId, shapeId, text);
|
|
89
|
-
},
|
|
90
|
-
async duplicateSelection() {
|
|
91
|
-
await requireViewer().duplicateSelection();
|
|
92
|
-
},
|
|
93
|
-
async copySelection() {
|
|
94
|
-
await requireViewer().copySelection();
|
|
95
|
-
},
|
|
96
|
-
async cutSelection() {
|
|
97
|
-
await requireViewer().cutSelection();
|
|
98
|
-
},
|
|
99
|
-
async pasteSelection() {
|
|
100
|
-
await requireViewer().pasteSelection();
|
|
101
|
-
},
|
|
102
|
-
async undo() {
|
|
103
|
-
await requireViewer().undo();
|
|
104
|
-
},
|
|
105
|
-
async redo() {
|
|
106
|
-
await requireViewer().redo();
|
|
107
|
-
},
|
|
108
|
-
cancelEdit() {
|
|
109
|
-
requireViewer().cancelEdit();
|
|
110
|
-
},
|
|
111
|
-
exportVsdx() {
|
|
112
|
-
return requireViewer().exportVsdx();
|
|
113
|
-
},
|
|
114
|
-
fit() {
|
|
115
|
-
requireViewer().fit();
|
|
116
|
-
},
|
|
117
|
-
setLayerVisibility(pageId, layerId, visible) {
|
|
118
|
-
requireViewer().setLayerVisibility(pageId, layerId, visible);
|
|
119
|
-
},
|
|
120
|
-
resetLayerVisibility(pageId) {
|
|
121
|
-
requireViewer().resetLayerVisibility(pageId);
|
|
122
|
-
},
|
|
123
|
-
exportSvg(options) {
|
|
124
|
-
return requireViewer().exportSvg(options);
|
|
125
|
-
},
|
|
126
|
-
createPrintSnapshot(options) {
|
|
127
|
-
return requireViewer().createPrintSnapshot(options);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
92
|
+
return deferredHandle(VIEWER_CONTRACT.handle, current, VIEWER_HANDLE_OPTIONS);
|
|
130
93
|
}
|
|
131
94
|
function viewerStateSource(current) {
|
|
132
95
|
const controller = () => {
|
|
@@ -151,7 +114,7 @@ function withEventEmitter(props, emit) {
|
|
|
151
114
|
const callbacks = {};
|
|
152
115
|
for (const name of eventKeys) Object.assign(callbacks, { [name]: (value) => {
|
|
153
116
|
try {
|
|
154
|
-
(props.events?.[name])?.(value);
|
|
117
|
+
return (props.events?.[name])?.(value);
|
|
155
118
|
} finally {
|
|
156
119
|
emit(name, value);
|
|
157
120
|
}
|
|
@@ -366,4 +329,4 @@ function createViewerBuildingBlocks(options = {}) {
|
|
|
366
329
|
};
|
|
367
330
|
}
|
|
368
331
|
//#endregion
|
|
369
|
-
export { TOOLBAR_GROUPS, ViewerController, buildingBlock, createBuildingBlockSession, createViewerBuildingBlocks, effectiveMode, eventKeys, mountFrameworkViewer, mountViewer, prepareDiagramBlock, propertyKeys, toolbarGroups, viewerHandle, viewerOptions, viewerStateSource, withEventEmitter };
|
|
332
|
+
export { TOOLBAR_GROUPS, VIEWER_CONTRACT, VIEWER_HANDLE_OPTIONS, ViewerController, buildingBlock, createBuildingBlockSession, createViewerBuildingBlocks, effectiveMode, eventKeys, mountFrameworkViewer, mountViewer, prepareDiagramBlock, propertyKeys, toolbarGroups, viewerHandle, viewerOptions, viewerStateSource, withEventEmitter };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mountViewer, type MountedViewer } from 'ooxml-ui/visio';
|
|
2
2
|
import type { ViewerState } from 'ooxml-ui/visio';
|
|
3
|
+
import { type BindingContract } from 'ooxml-ui/bindings';
|
|
3
4
|
import { eventKeys, propertyKeys, type ViewerCallbacks, type ViewerOptions, type ViewerProperties } from 'ooxml-ui/visio';
|
|
4
5
|
/** Framework props permit undefined; omitted values preserve the shared binding's state. */
|
|
5
6
|
export type ViewerProps = {
|
|
@@ -8,6 +9,16 @@ export type ViewerProps = {
|
|
|
8
9
|
events?: ViewerCallbacks | undefined;
|
|
9
10
|
};
|
|
10
11
|
export type ViewerHandle = Pick<MountedViewer, 'element' | 'controller' | 'load' | 'createBlankDrawing' | 'applyEdits' | 'selectShapes' | 'selectAll' | 'clearSelection' | 'duplicateSelection' | 'copySelection' | 'cutSelection' | 'pasteSelection' | 'replacePlainText' | 'undo' | 'redo' | 'cancelEdit' | 'exportVsdx' | 'fit' | 'setLayerVisibility' | 'resetLayerVisibility' | 'exportSvg' | 'createPrintSnapshot'>;
|
|
12
|
+
/**
|
|
13
|
+
* The Visio binding contract. `mountViewer` (ooxml-ui/visio) forwards properties and events itself,
|
|
14
|
+
* so every property is `manual` here: `mountFrameworkViewer` sends them as revision-aware patches.
|
|
15
|
+
* Events reach native outputs through the `events` callback map (`withEventEmitter`).
|
|
16
|
+
*/
|
|
17
|
+
export declare const VIEWER_CONTRACT: BindingContract<never, ViewerProperties, ViewerHandle>;
|
|
18
|
+
/** The error every lazy handle member throws before mount and after unmount. */
|
|
19
|
+
export declare const VIEWER_HANDLE_OPTIONS: {
|
|
20
|
+
readonly message: "The viewer is not mounted.";
|
|
21
|
+
};
|
|
11
22
|
/** One mapping for every property and event, shared by every framework adapter. */
|
|
12
23
|
export declare function viewerOptions(props: ViewerProps): ViewerOptions;
|
|
13
24
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visio-svelte-viewer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Local-first Visio viewer for svelte",
|
|
5
5
|
"homepage": "https://christophervr.github.io/ooxml/visio/",
|
|
6
6
|
"bugs": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"emf-converter": "4.21.0",
|
|
41
|
-
"ooxml-core": "^1.
|
|
42
|
-
"ooxml-ui": "^1.
|
|
41
|
+
"ooxml-core": "^1.25.0",
|
|
42
|
+
"ooxml-ui": "^1.26.0",
|
|
43
43
|
"visio-core": "^1.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|