visio-angular-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 CHANGED
@@ -52,22 +52,34 @@ export class DiagramComponent {
52
52
 
53
53
  The shared properties are `document` (a parsed `VisioDocument`, or `null` to clear),
54
54
  `pageIndex` (zero-based), `zoom` (`1` means 100%), `showToolbar`, `ribbonAddIns` (tabs the host adds
55
- after Help) and `events`.
56
- The callback map uses `document-load`, `document-change`, `document-error`,
57
- `page-change`, `zoom-change` and `shape-select`. File loading uses the imperative
55
+ after Help), `canEdit` (editing permission; the viewer is editable unless you pass `false`),
56
+ `collaboration` (shares the open drawing in a room while set; `null` leaves it) and `events`.
57
+ The callback map uses `document-load`, `document-change` (`{ document, dirty, kind }` with kind
58
+ `edit`, `undo`, `redo`, `remote` or `save`), `document-error`, `page-change`, `zoom-change`,
59
+ `shape-select`, `selection-change`, `office-ribbon-add-in` and `collaboration-change`. File loading uses the imperative
58
60
  `load(File | Blob | Uint8Array | ArrayBuffer)` handle; `document` is not a file URL.
59
61
  Provide a height for the viewer host. Mount and load files in the browser.
60
62
 
61
63
  The handle supports `fit()`, `replacePlainText(pageId, shapeId, text)`,
62
64
  `applyEdits(edits)`, `undo()`, `redo()` and `exportVsdx()`.
63
65
  `exportVsdx()` returns `{ bytes, dirty, diagnostics }`; saving or downloading those
64
- bytes is the application's responsibility. Load original bytes through `load()`
66
+ bytes is the application's responsibility, and `handle.controller.markClean()` declares them saved.
67
+ Sharing state is on the handle's element: `collaborationState`, `reconnectCollaboration()` and
68
+ `stopCollaboration()`. Load original bytes through `load()`
65
69
  to enable source-backed editing and export. Handles are usable after mount.
66
70
 
67
71
  Every viewer package includes the same browser UI and re-exports the
68
72
  `visio-core` document API. Parsing and editing belong to `ooxml-core/visio`;
69
73
  framework bindings only manage lifecycle, properties and events.
70
74
 
75
+ ## Compose your own UI
76
+
77
+ To build a custom diagram UI instead of mounting the whole viewer, use the building blocks: `createViewerBuildingBlocks` and the `ViewerBuildingBlocks` class, with the standalone `DiagramCanvasComponent`, `ToolbarComponent`, `PageNavigationComponent`, `InspectorComponent` and `ShapesPaneComponent`. They expose signals
78
+ for the flat `toolbarProps` (page, zoom, selection, search, enabled flags and callbacks), `mode`,
79
+ `loading`/`error` and `markClean()`. Hosts pass `canEdit` (read-only until `true`) and optional
80
+ `onOpenSettings`/`onOpenShareDialog`/`onOpenPageSetup`/`onOpenFile` callbacks for dialogs they own.
81
+ See [composable building blocks](https://github.com/ChristopherVR/ooxml/blob/main/viewers/visio/docs/building-blocks.md).
82
+
71
83
  ## Limitations
72
84
 
73
85
  Rendering and editing are beta features. Supported text and geometry edits are
@@ -77,7 +89,7 @@ Files stay in the browser unless your application sends them elsewhere.
77
89
 
78
90
  ## Documentation
79
91
 
80
- [Viewer guide](https://christophervr.github.io/ooxml/visio/docs/) |
92
+ [Viewer guide](https://christophervr.github.io/ooxml/visio/) |
81
93
  [Demo](https://christophervr.github.io/ooxml/visio/demo/) |
82
94
  [Source](https://github.com/ChristopherVR/ooxml/tree/main/viewers/visio)
83
95
 
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ function mountFrameworkViewer(container, initial) {
35
35
  const touchedByOlderCall = [...activePatches].some((active) => key in active);
36
36
  if (snapshot[key] !== void 0 && (snapshot[key] !== previous[key] || touchedByOlderCall)) Object.assign(patch, { [key]: snapshot[key] });
37
37
  }
38
+ if (snapshot.readOnly === void 0 && previous.readOnly !== void 0) Object.assign(patch, { readOnly: false });
38
39
  activePatches.add(patch);
39
40
  try {
40
41
  binding.update(patch);
@@ -150,7 +151,7 @@ function withEventEmitter(props, emit) {
150
151
  const callbacks = {};
151
152
  for (const name of eventKeys) Object.assign(callbacks, { [name]: (value) => {
152
153
  try {
153
- (props.events?.[name])?.(value);
154
+ return (props.events?.[name])?.(value);
154
155
  } finally {
155
156
  emit(name, value);
156
157
  }
@@ -181,6 +182,7 @@ var VisioViewerComponent = class VisioViewerComponent {
181
182
  this.selectionChange = new EventEmitter();
182
183
  this.ribbonAddIn = new EventEmitter();
183
184
  this.collaborationChange = new EventEmitter();
185
+ this.fileCommand = new EventEmitter();
184
186
  this.host = inject(ElementRef);
185
187
  this.handle = viewerHandle(() => this.binding);
186
188
  this.stopState = () => {};
@@ -195,7 +197,8 @@ var VisioViewerComponent = class VisioViewerComponent {
195
197
  "shape-select": this.shapeSelect,
196
198
  "selection-change": this.selectionChange,
197
199
  "office-ribbon-add-in": this.ribbonAddIn,
198
- "collaboration-change": this.collaborationChange
200
+ "collaboration-change": this.collaborationChange,
201
+ "file-command": this.fileCommand
199
202
  };
200
203
  }
201
204
  options() {
@@ -292,8 +295,11 @@ __decorate([Input()], VisioViewerComponent.prototype, "pageIndex", void 0);
292
295
  __decorate([Input()], VisioViewerComponent.prototype, "zoom", void 0);
293
296
  __decorate([Input()], VisioViewerComponent.prototype, "showToolbar", void 0);
294
297
  __decorate([Input()], VisioViewerComponent.prototype, "canEdit", void 0);
298
+ __decorate([Input()], VisioViewerComponent.prototype, "readOnly", void 0);
295
299
  __decorate([Input()], VisioViewerComponent.prototype, "ribbonAddIns", void 0);
296
300
  __decorate([Input()], VisioViewerComponent.prototype, "collaboration", void 0);
301
+ __decorate([Input()], VisioViewerComponent.prototype, "storage", void 0);
302
+ __decorate([Input()], VisioViewerComponent.prototype, "customization", void 0);
297
303
  __decorate([Input()], VisioViewerComponent.prototype, "events", void 0);
298
304
  __decorate([Output()], VisioViewerComponent.prototype, "documentLoad", void 0);
299
305
  __decorate([Output()], VisioViewerComponent.prototype, "documentChange", void 0);
@@ -304,6 +310,7 @@ __decorate([Output()], VisioViewerComponent.prototype, "shapeSelect", void 0);
304
310
  __decorate([Output()], VisioViewerComponent.prototype, "selectionChange", void 0);
305
311
  __decorate([Output()], VisioViewerComponent.prototype, "ribbonAddIn", void 0);
306
312
  __decorate([Output()], VisioViewerComponent.prototype, "collaborationChange", void 0);
313
+ __decorate([Output()], VisioViewerComponent.prototype, "fileCommand", void 0);
307
314
  VisioViewerComponent = __decorate([Component({
308
315
  selector: "visio-viewer-host",
309
316
  standalone: true,
@@ -8,7 +8,7 @@ export declare class ViewerBuildingBlocks {
8
8
  readonly state: import("@angular/core").Signal<import("ooxml-ui/visio").ViewerState>;
9
9
  private readonly latest;
10
10
  readonly toolbarProps: import("@angular/core").Signal<{
11
- 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>>;
11
+ 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>>;
12
12
  mode: import("ooxml-ui/visio").DiagramMode;
13
13
  canEdit: boolean;
14
14
  pageIndex: number;
@@ -7,8 +7,11 @@ export declare class VisioViewerComponent implements AfterViewInit, OnChanges, O
7
7
  zoom?: number;
8
8
  showToolbar?: boolean;
9
9
  canEdit?: boolean;
10
+ readOnly?: boolean;
10
11
  ribbonAddIns?: ViewerProperties['ribbonAddIns'];
11
12
  collaboration?: ViewerProperties['collaboration'];
13
+ storage?: ViewerProperties['storage'];
14
+ customization?: ViewerProperties['customization'];
12
15
  events?: ViewerCallbacks;
13
16
  documentLoad: EventEmitter<import("visio-core").VisioDocument>;
14
17
  documentChange: EventEmitter<{
@@ -23,6 +26,8 @@ export declare class VisioViewerComponent implements AfterViewInit, OnChanges, O
23
26
  selectionChange: EventEmitter<readonly VisioShapeSelection[]>;
24
27
  ribbonAddIn: EventEmitter<import("ooxml-core/ribbon").RibbonAddInCommandDetail>;
25
28
  collaborationChange: EventEmitter<import("ooxml-core/collab").CollaborationState>;
29
+ /** Notification only: to cancel a File command, return false from `events['file-command']`. */
30
+ fileCommand: EventEmitter<import("ooxml-core/embedding").FileCommandDetail<import("ooxml-core/embedding").VisioFileCommand>>;
26
31
  private readonly host;
27
32
  private binding;
28
33
  private readonly handle;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visio-angular-viewer",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Local-first Visio viewer for angular",
5
5
  "homepage": "https://christophervr.github.io/ooxml/visio/",
6
6
  "bugs": {
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "emf-converter": "4.21.0",
34
- "ooxml-core": "^1.22.0",
35
- "ooxml-ui": "^1.21.0",
36
- "visio-core": "^1.0.0"
34
+ "ooxml-core": "^1.24.0",
35
+ "ooxml-ui": "^1.23.0",
36
+ "visio-core": "^1.0.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@angular/compiler": "^22.2.3",