visio-svelte-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 +17 -5
- package/dist/VisioViewer.svelte +2 -2
- package/dist/index.js +4 -0
- package/dist/index.server.js +4 -1
- package/dist/runtime.js +2 -1
- package/dist/types/packages/bindings/src/building-blocks.d.ts +1 -1
- package/dist/types/packages/svelte/src/building-blocks.d.ts +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -45,22 +45,34 @@ npm install visio-svelte-viewer
|
|
|
45
45
|
|
|
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
|
-
after Help)
|
|
49
|
-
|
|
50
|
-
`
|
|
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`.
|
|
50
|
+
The callback map uses `document-load`, `document-change` (`{ document, dirty, kind }` with kind
|
|
51
|
+
`edit`, `undo`, `redo`, `remote` or `save`), `document-error`, `page-change`, `zoom-change`,
|
|
52
|
+
`shape-select`, `selection-change`, `office-ribbon-add-in` and `collaboration-change`. File loading uses the imperative
|
|
51
53
|
`load(File | Blob | Uint8Array | ArrayBuffer)` handle; `document` is not a file URL.
|
|
52
54
|
Provide a height for the viewer host. Mount and load files in the browser.
|
|
53
55
|
|
|
54
56
|
The handle supports `fit()`, `replacePlainText(pageId, shapeId, text)`,
|
|
55
57
|
`applyEdits(edits)`, `undo()`, `redo()` and `exportVsdx()`.
|
|
56
58
|
`exportVsdx()` returns `{ bytes, dirty, diagnostics }`; saving or downloading those
|
|
57
|
-
bytes is the application's responsibility
|
|
59
|
+
bytes is the application's responsibility, and `handle.controller.markClean()` declares them saved.
|
|
60
|
+
Sharing state is on the handle's element: `collaborationState`, `reconnectCollaboration()` and
|
|
61
|
+
`stopCollaboration()`. Load original bytes through `load()`
|
|
58
62
|
to enable source-backed editing and export. Handles are usable after mount.
|
|
59
63
|
|
|
60
64
|
Every viewer package includes the same browser UI and re-exports the
|
|
61
65
|
`visio-core` document API. Parsing and editing belong to `ooxml-core/visio`;
|
|
62
66
|
framework bindings only manage lifecycle, properties and events.
|
|
63
67
|
|
|
68
|
+
## Compose your own UI
|
|
69
|
+
|
|
70
|
+
To build a custom diagram UI instead of mounting the whole viewer, use the building blocks: `createViewerBuildingBlocks`, `DiagramCanvas`, `Toolbar`, `PageNavigation`, `Inspector` and `ShapesPane`. The factory returns readable stores
|
|
71
|
+
for the flat `toolbarProps` (page, zoom, selection, search, enabled flags and callbacks), `mode`,
|
|
72
|
+
`loading`/`error` and `markClean()`. Hosts pass `canEdit` (read-only until `true`) and optional
|
|
73
|
+
`onOpenSettings`/`onOpenShareDialog`/`onOpenPageSetup`/`onOpenFile` callbacks for dialogs they own.
|
|
74
|
+
See [composable building blocks](https://github.com/ChristopherVR/ooxml/blob/main/viewers/visio/docs/building-blocks.md).
|
|
75
|
+
|
|
64
76
|
## Limitations
|
|
65
77
|
|
|
66
78
|
Rendering and editing are beta features. Supported text and geometry edits are
|
|
@@ -70,7 +82,7 @@ Files stay in the browser unless your application sends them elsewhere.
|
|
|
70
82
|
|
|
71
83
|
## Documentation
|
|
72
84
|
|
|
73
|
-
[Viewer guide](https://christophervr.github.io/ooxml/visio/
|
|
85
|
+
[Viewer guide](https://christophervr.github.io/ooxml/visio/) |
|
|
74
86
|
[Demo](https://christophervr.github.io/ooxml/visio/demo/) |
|
|
75
87
|
[Source](https://github.com/ChristopherVR/ooxml/tree/main/viewers/visio)
|
|
76
88
|
|
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
|
@@ -38,6 +38,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
38
38
|
const touchedByOlderCall = [...activePatches].some((active) => key in active);
|
|
39
39
|
if (snapshot[key] !== void 0 && (snapshot[key] !== previous[key] || touchedByOlderCall)) Object.assign(patch, { [key]: snapshot[key] });
|
|
40
40
|
}
|
|
41
|
+
if (snapshot.readOnly === void 0 && previous.readOnly !== void 0) Object.assign(patch, { readOnly: false });
|
|
41
42
|
activePatches.add(patch);
|
|
42
43
|
try {
|
|
43
44
|
binding.update(patch);
|
|
@@ -158,8 +159,11 @@ function VisioViewer($$anchor, $$props) {
|
|
|
158
159
|
zoom: $$props.zoom,
|
|
159
160
|
showToolbar: $$props.showToolbar,
|
|
160
161
|
canEdit: $$props.canEdit,
|
|
162
|
+
readOnly: $$props.readOnly,
|
|
161
163
|
ribbonAddIns: $$props.ribbonAddIns,
|
|
162
164
|
collaboration: $$props.collaboration,
|
|
165
|
+
customization: $$props.customization,
|
|
166
|
+
storage: $$props.storage,
|
|
163
167
|
events: $$props.events
|
|
164
168
|
}));
|
|
165
169
|
let binding;
|
package/dist/index.server.js
CHANGED
|
@@ -87,15 +87,18 @@ function viewerHandle(current) {
|
|
|
87
87
|
//#region packages/bindings/src/VisioViewer.svelte
|
|
88
88
|
function VisioViewer($$renderer, $$props) {
|
|
89
89
|
$$renderer.component(($$renderer) => {
|
|
90
|
-
let { document, pageIndex, zoom, showToolbar, canEdit, ribbonAddIns, collaboration, events, class: className, style, "aria-label": ariaLabel } = $$props;
|
|
90
|
+
let { document, pageIndex, zoom, showToolbar, canEdit, readOnly, ribbonAddIns, collaboration, customization, storage, events, class: className, style, "aria-label": ariaLabel } = $$props;
|
|
91
91
|
$.derived(() => ({
|
|
92
92
|
document,
|
|
93
93
|
pageIndex,
|
|
94
94
|
zoom,
|
|
95
95
|
showToolbar,
|
|
96
96
|
canEdit,
|
|
97
|
+
readOnly,
|
|
97
98
|
ribbonAddIns,
|
|
98
99
|
collaboration,
|
|
100
|
+
customization,
|
|
101
|
+
storage,
|
|
99
102
|
events
|
|
100
103
|
}));
|
|
101
104
|
let binding;
|
package/dist/runtime.js
CHANGED
|
@@ -36,6 +36,7 @@ function mountFrameworkViewer(container, initial) {
|
|
|
36
36
|
const touchedByOlderCall = [...activePatches].some((active) => key in active);
|
|
37
37
|
if (snapshot[key] !== void 0 && (snapshot[key] !== previous[key] || touchedByOlderCall)) Object.assign(patch, { [key]: snapshot[key] });
|
|
38
38
|
}
|
|
39
|
+
if (snapshot.readOnly === void 0 && previous.readOnly !== void 0) Object.assign(patch, { readOnly: false });
|
|
39
40
|
activePatches.add(patch);
|
|
40
41
|
try {
|
|
41
42
|
binding.update(patch);
|
|
@@ -151,7 +152,7 @@ function withEventEmitter(props, emit) {
|
|
|
151
152
|
const callbacks = {};
|
|
152
153
|
for (const name of eventKeys) Object.assign(callbacks, { [name]: (value) => {
|
|
153
154
|
try {
|
|
154
|
-
(props.events?.[name])?.(value);
|
|
155
|
+
return (props.events?.[name])?.(value);
|
|
155
156
|
} finally {
|
|
156
157
|
emit(name, value);
|
|
157
158
|
}
|
|
@@ -26,7 +26,7 @@ export declare function createBuildingBlockSession(initial?: BuildingBlockOption
|
|
|
26
26
|
mount(node: HTMLElement | null): void;
|
|
27
27
|
/** Flat control props; pass the framework's latest options so callbacks stay current. */
|
|
28
28
|
toolbar(latest?: BuildingBlockOptions): {
|
|
29
|
-
labels: Readonly<Record<"Arc" | "Copy" | "Cut" | "Delete" | "Duplicate" | "Ellipse" | "Find" | "Fit to Window" | "Freeform" | "Group" | "Line" | "Next Result" | "Open" | "Options" | "Page" | "Page Setup" | "Paste" | "Pencil" | "Pointer Tool" | "Previous Result" | "Rectangle" | "Redo" | "Shapes" | "Share" | "Undo" | "Ungroup" | "Zoom In" | "Zoom Out", string>>;
|
|
29
|
+
labels: Readonly<Record<"Arc" | "Connector" | "Copy" | "Cut" | "Delete" | "Duplicate" | "Ellipse" | "Find" | "Fit to Window" | "Freeform" | "Group" | "Line" | "Next Result" | "Open" | "Options" | "Page" | "Page Setup" | "Paste" | "Pencil" | "Pointer Tool" | "Previous Result" | "Rectangle" | "Redo" | "Shapes" | "Share" | "Text" | "Undo" | "Ungroup" | "Zoom In" | "Zoom Out", string>>;
|
|
30
30
|
mode: ui.DiagramMode;
|
|
31
31
|
canEdit: boolean;
|
|
32
32
|
pageIndex: number;
|
|
@@ -7,7 +7,7 @@ export declare function createViewerBuildingBlocks(options?: BuildingBlockOption
|
|
|
7
7
|
subscribe: (this: void, run: import("svelte/store").Subscriber<import("ooxml-ui/visio").ViewerState>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
8
8
|
};
|
|
9
9
|
toolbarProps: Readable<{
|
|
10
|
-
labels: Readonly<Record<"Arc" | "Copy" | "Cut" | "Delete" | "Duplicate" | "Ellipse" | "Find" | "Fit to Window" | "Freeform" | "Group" | "Line" | "Next Result" | "Open" | "Options" | "Page" | "Page Setup" | "Paste" | "Pencil" | "Pointer Tool" | "Previous Result" | "Rectangle" | "Redo" | "Shapes" | "Share" | "Undo" | "Ungroup" | "Zoom In" | "Zoom Out", string>>;
|
|
10
|
+
labels: Readonly<Record<"Arc" | "Connector" | "Copy" | "Cut" | "Delete" | "Duplicate" | "Ellipse" | "Find" | "Fit to Window" | "Freeform" | "Group" | "Line" | "Next Result" | "Open" | "Options" | "Page" | "Page Setup" | "Paste" | "Pencil" | "Pointer Tool" | "Previous Result" | "Rectangle" | "Redo" | "Shapes" | "Share" | "Text" | "Undo" | "Ungroup" | "Zoom In" | "Zoom Out", string>>;
|
|
11
11
|
mode: import("ooxml-ui/visio").DiagramMode;
|
|
12
12
|
canEdit: boolean;
|
|
13
13
|
pageIndex: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visio-svelte-viewer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Local-first Visio viewer for svelte",
|
|
5
5
|
"homepage": "https://christophervr.github.io/ooxml/visio/",
|
|
6
6
|
"bugs": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"emf-converter": "4.21.0",
|
|
41
|
-
"ooxml-core": "^1.
|
|
42
|
-
"ooxml-ui": "^1.
|
|
43
|
-
"visio-core": "^1.0.
|
|
41
|
+
"ooxml-core": "^1.24.0",
|
|
42
|
+
"ooxml-ui": "^1.23.0",
|
|
43
|
+
"visio-core": "^1.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"svelte": "^5.0.0"
|