visio-svelte-viewer 0.1.1 → 0.3.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/dist/VisioViewer.svelte +10 -2
- package/dist/VisioViewer.svelte.d.ts +3 -2
- package/dist/assets/{edit-worker-DRgXgRud.js → edit-worker-CZbtTOr4.js} +473 -137
- package/dist/assets/{parse-worker-B8EBQQpD.js → parse-worker-BEaLqUCJ.js} +7287 -82
- package/dist/index.js +888 -171
- package/dist/index.server.js +864 -169
- package/dist/runtime.js +877 -172
- package/dist/types/packages/bindings/src/common.d.ts +11 -0
- package/dist/types/src/office-ui.d.ts +2 -0
- package/dist/types/src/ribbon-action.d.ts +34 -0
- package/dist/types/src/ribbon-home.d.ts +6 -0
- package/dist/types/src/ribbon-parts.d.ts +20 -0
- package/dist/types/src/ribbon-router.d.ts +17 -0
- package/dist/types/src/ribbon-view.d.ts +2 -0
- package/dist/types/src/ribbon.d.ts +6 -0
- package/dist/types/src/status-bar.d.ts +7 -0
- package/dist/types/src/styles/index.d.ts +5 -0
- package/dist/types/src/styles.d.ts +1 -1
- package/dist/types/src/viewer-chrome.d.ts +11 -2
- package/dist/types/src/viewer-commands.d.ts +31 -0
- package/dist/types/src/viewer-draw-tool.d.ts +17 -0
- package/dist/types/src/viewer-input.d.ts +4 -2
- package/dist/types/src/viewer-search.d.ts +2 -1
- package/package.json +4 -3
package/dist/VisioViewer.svelte
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { readonly, writable } from 'svelte/store';
|
|
3
|
+
import { mountFrameworkViewer, viewerHandle, viewerOptions, viewerStateSource, type ViewerState, type MountedViewer, type ViewerProps, type VsdxSource, type VisioEdit, type SvgExportOptions, type CurrentPagePrintSnapshotOptions } from './runtime.js';
|
|
3
4
|
type Props = ViewerProps & { class?: string; style?: string };
|
|
4
5
|
let { document, pageIndex, zoom, showToolbar, events, class: className, style }: Props = $props();
|
|
5
6
|
const options = $derived({ document, pageIndex, zoom, showToolbar, events } satisfies Required<ViewerProps>);
|
|
6
7
|
let binding: MountedViewer | undefined;
|
|
7
8
|
const handle = viewerHandle(() => binding);
|
|
9
|
+
// The component owns its state store, so subscribers made before mount still see updates.
|
|
10
|
+
const state = writable<ViewerState | null>(null);
|
|
8
11
|
function attach(host: HTMLElement, props: ViewerProps) {
|
|
9
12
|
const mounted = mountFrameworkViewer(host, viewerOptions(props));
|
|
10
13
|
binding = mounted;
|
|
14
|
+
const source = viewerStateSource(() => mounted);
|
|
15
|
+
state.set(source.getSnapshot());
|
|
16
|
+
const stop = source.subscribe(() => state.set(source.getSnapshot()));
|
|
11
17
|
return {
|
|
12
18
|
update(next: ViewerProps) { mounted.update(viewerOptions(next)); },
|
|
13
|
-
destroy() { binding = undefined; mounted.destroy(); },
|
|
19
|
+
destroy() { stop(); state.set(null); binding = undefined; mounted.destroy(); },
|
|
14
20
|
};
|
|
15
21
|
}
|
|
22
|
+
/** Reactive viewer state as a Svelte store: `const state = viewer.getState()`, then `$state`. */
|
|
23
|
+
export function getState() { return readonly(state); }
|
|
16
24
|
export function getHandle() { return handle; }
|
|
17
25
|
export function load(source: VsdxSource) { return handle.load(source); }
|
|
18
26
|
export function applyEdits(edits: readonly VisioEdit[]) { return handle.applyEdits(edits); }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Component } from 'svelte';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Readable } from 'svelte/store';
|
|
3
|
+
import type { ViewerProps, ViewerHandle, ViewerState } from './types/packages/bindings/src/common.js';
|
|
4
|
+
declare const VisioViewer: Component<ViewerProps & { class?: string; style?: string }, Pick<ViewerHandle, 'load' | 'replacePlainText' | 'applyEdits' | 'undo' | 'redo' | 'cancelEdit' | 'exportVsdx' | 'fit' | 'setLayerVisibility' | 'resetLayerVisibility' | 'exportSvg' | 'createPrintSnapshot'> & { getHandle(): ViewerHandle; getState(): Readable<ViewerState | null> }>;
|
|
4
5
|
export default VisioViewer;
|