visio-solid-viewer 1.1.0 → 1.1.2
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/index.js +41 -79
- package/dist/index.server.js +41 -79
- package/dist/types/packages/bindings/src/common.d.ts +11 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ export function Diagram() {
|
|
|
59
59
|
The shared properties are `document` (a parsed `VisioDocument`, or `null` to clear),
|
|
60
60
|
`pageIndex` (zero-based), `zoom` (`1` means 100%), `showToolbar`, `ribbonAddIns` (tabs the host adds
|
|
61
61
|
after Help), `canEdit` (editing permission; the viewer is editable unless you pass `false`),
|
|
62
|
-
`collaboration` (shares the open drawing in a room while set; `null` leaves it) and `events`.
|
|
62
|
+
`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`.
|
|
63
63
|
The callback map uses `document-load`, `document-change` (`{ document, dirty, kind }` with kind
|
|
64
64
|
`edit`, `undo`, `redo`, `remote` or `save`), `document-error`, `page-change`, `zoom-change`,
|
|
65
65
|
`shape-select`, `selection-change`, `office-ribbon-add-in` and `collaboration-change`. File loading uses the imperative
|
package/dist/index.js
CHANGED
|
@@ -2,18 +2,52 @@ import * as ui from "ooxml-ui/visio";
|
|
|
2
2
|
import { ViewerController, createWorkerParser, mountViewer, propertyKeys } from "ooxml-ui/visio";
|
|
3
3
|
import { className, createComponent, delegateEvents, effect, insert, setAttribute, style, template, use } from "solid-js/web";
|
|
4
4
|
import { For, Index, Match, Switch, createEffect, createMemo, createSignal, onCleanup, onMount } from "solid-js";
|
|
5
|
+
import { deferredHandle, pickProps } from "ooxml-ui/bindings";
|
|
5
6
|
import * as officeTheme from "ooxml-ui/theme";
|
|
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
|
|
@@ -55,79 +89,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
55
89
|
}
|
|
56
90
|
/** Lazy imperative methods reject both before mount and after unmount. */
|
|
57
91
|
function viewerHandle(current) {
|
|
58
|
-
|
|
59
|
-
const binding = current();
|
|
60
|
-
if (!binding) throw new Error("The viewer is not mounted.");
|
|
61
|
-
return binding;
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
get element() {
|
|
65
|
-
return requireViewer().element;
|
|
66
|
-
},
|
|
67
|
-
get controller() {
|
|
68
|
-
return requireViewer().controller;
|
|
69
|
-
},
|
|
70
|
-
async load(source) {
|
|
71
|
-
await requireViewer().load(source);
|
|
72
|
-
},
|
|
73
|
-
async createBlankDrawing(options) {
|
|
74
|
-
await requireViewer().createBlankDrawing(options);
|
|
75
|
-
},
|
|
76
|
-
async applyEdits(edits) {
|
|
77
|
-
await requireViewer().applyEdits(edits);
|
|
78
|
-
},
|
|
79
|
-
selectShapes(shapes) {
|
|
80
|
-
requireViewer().selectShapes(shapes);
|
|
81
|
-
},
|
|
82
|
-
selectAll() {
|
|
83
|
-
requireViewer().selectAll();
|
|
84
|
-
},
|
|
85
|
-
clearSelection() {
|
|
86
|
-
requireViewer().clearSelection();
|
|
87
|
-
},
|
|
88
|
-
async replacePlainText(pageId, shapeId, text) {
|
|
89
|
-
await requireViewer().replacePlainText(pageId, shapeId, text);
|
|
90
|
-
},
|
|
91
|
-
async duplicateSelection() {
|
|
92
|
-
await requireViewer().duplicateSelection();
|
|
93
|
-
},
|
|
94
|
-
async copySelection() {
|
|
95
|
-
await requireViewer().copySelection();
|
|
96
|
-
},
|
|
97
|
-
async cutSelection() {
|
|
98
|
-
await requireViewer().cutSelection();
|
|
99
|
-
},
|
|
100
|
-
async pasteSelection() {
|
|
101
|
-
await requireViewer().pasteSelection();
|
|
102
|
-
},
|
|
103
|
-
async undo() {
|
|
104
|
-
await requireViewer().undo();
|
|
105
|
-
},
|
|
106
|
-
async redo() {
|
|
107
|
-
await requireViewer().redo();
|
|
108
|
-
},
|
|
109
|
-
cancelEdit() {
|
|
110
|
-
requireViewer().cancelEdit();
|
|
111
|
-
},
|
|
112
|
-
exportVsdx() {
|
|
113
|
-
return requireViewer().exportVsdx();
|
|
114
|
-
},
|
|
115
|
-
fit() {
|
|
116
|
-
requireViewer().fit();
|
|
117
|
-
},
|
|
118
|
-
setLayerVisibility(pageId, layerId, visible) {
|
|
119
|
-
requireViewer().setLayerVisibility(pageId, layerId, visible);
|
|
120
|
-
},
|
|
121
|
-
resetLayerVisibility(pageId) {
|
|
122
|
-
requireViewer().resetLayerVisibility(pageId);
|
|
123
|
-
},
|
|
124
|
-
exportSvg(options) {
|
|
125
|
-
return requireViewer().exportSvg(options);
|
|
126
|
-
},
|
|
127
|
-
createPrintSnapshot(options) {
|
|
128
|
-
return requireViewer().createPrintSnapshot(options);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
92
|
+
return deferredHandle(VIEWER_CONTRACT.handle, current, VIEWER_HANDLE_OPTIONS);
|
|
131
93
|
}
|
|
132
94
|
function viewerStateSource(current) {
|
|
133
95
|
const controller = () => {
|
package/dist/index.server.js
CHANGED
|
@@ -2,18 +2,52 @@ import * as ui from "ooxml-ui/visio";
|
|
|
2
2
|
import { ViewerController, createWorkerParser, mountViewer, propertyKeys } from "ooxml-ui/visio";
|
|
3
3
|
import { createComponent, escape, ssr, ssrAttribute, ssrHydrationKey, ssrStyle } from "solid-js/web";
|
|
4
4
|
import { For, Index, Match, Switch, createEffect, createMemo, createSignal, onCleanup, onMount } from "solid-js";
|
|
5
|
+
import { deferredHandle, pickProps } from "ooxml-ui/bindings";
|
|
5
6
|
import "ooxml-ui/theme";
|
|
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
|
|
@@ -55,79 +89,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
55
89
|
}
|
|
56
90
|
/** Lazy imperative methods reject both before mount and after unmount. */
|
|
57
91
|
function viewerHandle(current) {
|
|
58
|
-
|
|
59
|
-
const binding = current();
|
|
60
|
-
if (!binding) throw new Error("The viewer is not mounted.");
|
|
61
|
-
return binding;
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
get element() {
|
|
65
|
-
return requireViewer().element;
|
|
66
|
-
},
|
|
67
|
-
get controller() {
|
|
68
|
-
return requireViewer().controller;
|
|
69
|
-
},
|
|
70
|
-
async load(source) {
|
|
71
|
-
await requireViewer().load(source);
|
|
72
|
-
},
|
|
73
|
-
async createBlankDrawing(options) {
|
|
74
|
-
await requireViewer().createBlankDrawing(options);
|
|
75
|
-
},
|
|
76
|
-
async applyEdits(edits) {
|
|
77
|
-
await requireViewer().applyEdits(edits);
|
|
78
|
-
},
|
|
79
|
-
selectShapes(shapes) {
|
|
80
|
-
requireViewer().selectShapes(shapes);
|
|
81
|
-
},
|
|
82
|
-
selectAll() {
|
|
83
|
-
requireViewer().selectAll();
|
|
84
|
-
},
|
|
85
|
-
clearSelection() {
|
|
86
|
-
requireViewer().clearSelection();
|
|
87
|
-
},
|
|
88
|
-
async replacePlainText(pageId, shapeId, text) {
|
|
89
|
-
await requireViewer().replacePlainText(pageId, shapeId, text);
|
|
90
|
-
},
|
|
91
|
-
async duplicateSelection() {
|
|
92
|
-
await requireViewer().duplicateSelection();
|
|
93
|
-
},
|
|
94
|
-
async copySelection() {
|
|
95
|
-
await requireViewer().copySelection();
|
|
96
|
-
},
|
|
97
|
-
async cutSelection() {
|
|
98
|
-
await requireViewer().cutSelection();
|
|
99
|
-
},
|
|
100
|
-
async pasteSelection() {
|
|
101
|
-
await requireViewer().pasteSelection();
|
|
102
|
-
},
|
|
103
|
-
async undo() {
|
|
104
|
-
await requireViewer().undo();
|
|
105
|
-
},
|
|
106
|
-
async redo() {
|
|
107
|
-
await requireViewer().redo();
|
|
108
|
-
},
|
|
109
|
-
cancelEdit() {
|
|
110
|
-
requireViewer().cancelEdit();
|
|
111
|
-
},
|
|
112
|
-
exportVsdx() {
|
|
113
|
-
return requireViewer().exportVsdx();
|
|
114
|
-
},
|
|
115
|
-
fit() {
|
|
116
|
-
requireViewer().fit();
|
|
117
|
-
},
|
|
118
|
-
setLayerVisibility(pageId, layerId, visible) {
|
|
119
|
-
requireViewer().setLayerVisibility(pageId, layerId, visible);
|
|
120
|
-
},
|
|
121
|
-
resetLayerVisibility(pageId) {
|
|
122
|
-
requireViewer().resetLayerVisibility(pageId);
|
|
123
|
-
},
|
|
124
|
-
exportSvg(options) {
|
|
125
|
-
return requireViewer().exportSvg(options);
|
|
126
|
-
},
|
|
127
|
-
createPrintSnapshot(options) {
|
|
128
|
-
return requireViewer().createPrintSnapshot(options);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
92
|
+
return deferredHandle(VIEWER_CONTRACT.handle, current, VIEWER_HANDLE_OPTIONS);
|
|
131
93
|
}
|
|
132
94
|
function viewerStateSource(current) {
|
|
133
95
|
const controller = () => {
|
|
@@ -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-solid-viewer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Local-first Visio viewer for solid",
|
|
5
5
|
"homepage": "https://christophervr.github.io/ooxml/visio/",
|
|
6
6
|
"bugs": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"emf-converter": "4.
|
|
35
|
-
"ooxml-core": "^1.
|
|
36
|
-
"ooxml-ui": "^1.
|
|
34
|
+
"emf-converter": "4.23.1",
|
|
35
|
+
"ooxml-core": "^1.28.0",
|
|
36
|
+
"ooxml-ui": "^1.29.0",
|
|
37
37
|
"visio-core": "^1.0.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|