@miragon/value-chain-renderer 0.6.0 → 0.7.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
@@ -121,11 +121,15 @@ modeler.onContentChanged(() => save(modeler.exportText())); // canonical JSON
121
121
  ```
122
122
 
123
123
  `createCollaborativeModeler` and `createCollaborativeViewer` implement the `CollaborativeModeler`
124
- contract 1.2 (`meta.notation` `"value-chain"`): blank text opens as an empty diagram,
124
+ contract 1.3 (`meta.notation` `"value-chain"`): blank text opens as an empty diagram,
125
125
  `onContentChanged` fires for every edit and undo/redo and never for an import, view state is the
126
- diagram-js viewbox, a host's `setViewState` or fit never commits a label being typed, and the
126
+ diagram-js viewbox, a host's `setViewState` or fit never commits a label being typed, the
127
127
  `elements` surface lists steps and organizational units (name = label) with `reveal`, selection and
128
- `bounds(id)`, the live box of a step or an organizational unit in diagram coordinates. Both take
128
+ `bounds(id)`, the live box of a step or an organizational unit in diagram coordinates, and
129
+ `contentBounds()` is the live, tight box around every step, organizational unit and connection in
130
+ diagram coordinates (`undefined` while the diagram is empty): what a host that fits the view itself
131
+ fits to, as `connectDiagramJs(shell, diagram, { modeler, isEmpty })` of `@miragon/modeler-shell`
132
+ does. Label text that overflows its shape is not part of the box, as in the SVG export. Both take
129
133
  the contract's factory options `freeArea`, `fitOnImport` and `undoRedoKeys` (the viewer ignores
130
134
  the two that need editing) and the deprecated `freeRectCenter`. The browser test suite runs the
131
135
  contract's conformance kit on every law, with no case skipped and no advisory. `diagram` is the
@@ -138,7 +142,8 @@ renderer never imports the shell): `diagramMenu()` (Export as PNG, then SVG, opt
138
142
  with "Keyboard shortcuts…"), `createShortcutsDialog(shell)` (a modal `<dialog>` in the chrome's
139
143
  root, with the high-contrast and forced-colours rules of the design system; `{ fileKeys: true }`
140
144
  adds the web app's File keys, Cmd/Ctrl+O and Cmd/Ctrl+S), `svgToPng()` and
141
- `blobToBase64()` for the PNG export, and `vcBounds.contentBounds(padding)` for a host's fit.
145
+ `blobToBase64()` for the PNG export, and `vcBounds.isEmpty()`, a cheap emptiness test for the
146
+ shell's empty-file hint.
142
147
 
143
148
  ## Notation
144
149
 
@@ -1,4 +1,4 @@
1
- import { CollaborativeModeler, CollaborativeModelerOptions, ElementsSurface } from '@miragon/modeler-api';
1
+ import { CollaborativeModeler, CollaborativeModelerOptions, ElementBounds, ElementsSurface } from '@miragon/modeler-api';
2
2
  import { ModuleDeclaration } from 'didi';
3
3
  import { Point } from '@miragon/value-chain-schema-model';
4
4
  import { Modeler } from '../Modeler.js';
@@ -23,6 +23,12 @@ export interface CollaborativeValueChainOptions extends CollaborativeModelerOpti
23
23
  /** The contract surface plus the wrapped diagram for host-specific wiring. */
24
24
  export interface CollaborativeValueChainModeler extends CollaborativeModeler {
25
25
  readonly elements: ElementsSurface & Required<Pick<ElementsSurface, 'bounds'>>;
26
+ /**
27
+ * The tight box around every step, org unit and connection (waypoints included) in diagram
28
+ * coordinates, without a margin of its own; undefined while the diagram has no element. Label
29
+ * text that overflows its shape is not part of the box, as in the SVG export.
30
+ */
31
+ contentBounds(): ElementBounds | undefined;
26
32
  readonly diagram: Modeler | NavigatedViewer;
27
33
  }
28
34
  /** The editing mount (`meta.editable: true`) of the collaborative-modeler contract. */
@@ -1 +1 @@
1
- {"version":3,"file":"CollaborativeValueChain.d.ts","sourceRoot":"","sources":["../../src/collaborative/CollaborativeValueChain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAGhC,KAAK,eAAe,EAGrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAK9C,OAAO,EAIL,KAAK,KAAK,EAEX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,mFAAmF;A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O,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,8BAA+B,SAAQ,2BAA2B;IACjF,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IACpD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;CACxD;AAED,8EAA8E;AAC9E,MAAM,WAAW,8BAA+B,SAAQ,oBAAoB;IAC1E,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/E;;;;OAIG;IACH,aAAa,IAAI,aAAa,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAAC;CAC7C;AASD,uFAAuF;AACvF,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,8BAAmC,GAC3C,8BAA8B,CAUhC;AAED,+FAA+F;AAC/F,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,8BAAmC,GAC3C,8BAA8B,CAEhC"}
package/dist/index.js CHANGED
@@ -1810,29 +1810,29 @@ function Kn(e) {
1810
1810
  return e.trim() === "" ? o(Hn) : u(e);
1811
1811
  }
1812
1812
  function qn(e, t) {
1813
- let n = e.get("eventBus"), r = e.get("canvas"), i = e.get("elementRegistry"), a = e.get("selection"), o = /* @__PURE__ */ new Set(), s = !1, c = "", l = {
1813
+ let n = e.get("eventBus"), r = e.get("canvas"), i = e.get("elementRegistry"), a = e.get("selection"), o = e.get("vcBounds"), s = /* @__PURE__ */ new Set(), c = !1, l = "", u = {
1814
1814
  notation: Vn,
1815
1815
  apiVersion: Ge,
1816
1816
  editable: t
1817
1817
  };
1818
1818
  return t && n.on("commandStack.changed", () => {
1819
- for (let e of [...o]) e();
1819
+ for (let e of [...s]) e();
1820
1820
  }), {
1821
- meta: l,
1821
+ meta: u,
1822
1822
  elements: {
1823
- list: () => s ? [] : i.getAll().filter(S).map(Jn),
1823
+ list: () => c ? [] : i.getAll().filter(S).map(Jn),
1824
1824
  reveal(e) {
1825
- if (s) return !1;
1825
+ if (c) return !1;
1826
1826
  let t = i.get(e);
1827
1827
  return S(t) ? (a.select(t), r.scrollToElement(t), !0) : !1;
1828
1828
  },
1829
- selection: () => s ? [] : K(a.get()),
1829
+ selection: () => c ? [] : K(a.get()),
1830
1830
  onSelection(e) {
1831
1831
  let t = (t) => e(K(t.newSelection ?? []));
1832
1832
  return n.on("selection.changed", t), () => n.off("selection.changed", t);
1833
1833
  },
1834
1834
  bounds(e) {
1835
- if (s) return;
1835
+ if (c) return;
1836
1836
  let t = i.get(e);
1837
1837
  if (!S(t)) return;
1838
1838
  let { x: n, y: r, width: a, height: o } = t;
@@ -1849,7 +1849,7 @@ function qn(e, t) {
1849
1849
  t.appendChild(e.container), r.resized();
1850
1850
  },
1851
1851
  importText(t) {
1852
- if (s) return Promise.reject(/* @__PURE__ */ Error("The modeler was destroyed."));
1852
+ if (c) return Promise.reject(/* @__PURE__ */ Error("The modeler was destroyed."));
1853
1853
  try {
1854
1854
  let n = e.importDocument(Kn(t));
1855
1855
  return Promise.resolve({ warnings: n.map((e) => e.message) });
@@ -1858,13 +1858,13 @@ function qn(e, t) {
1858
1858
  }
1859
1859
  },
1860
1860
  exportText() {
1861
- return s ? c : d(e.exportDocument());
1861
+ return c ? l : d(e.exportDocument());
1862
1862
  },
1863
1863
  onContentChanged(e) {
1864
- return t ? (o.add(e), () => o.delete(e)) : () => void 0;
1864
+ return t ? (s.add(e), () => s.delete(e)) : () => void 0;
1865
1865
  },
1866
1866
  getViewState() {
1867
- if (!s) try {
1867
+ if (!c) try {
1868
1868
  let { x: e, y: t, width: n, height: i } = r.viewbox(), a = {
1869
1869
  x: e,
1870
1870
  y: t,
@@ -1877,21 +1877,24 @@ function qn(e, t) {
1877
1877
  }
1878
1878
  },
1879
1879
  setViewState(e) {
1880
- !s && Yn(e) && r.viewbox({
1880
+ !c && Yn(e) && r.viewbox({
1881
1881
  x: e.x,
1882
1882
  y: e.y,
1883
1883
  width: e.width,
1884
1884
  height: e.height
1885
1885
  });
1886
1886
  },
1887
+ contentBounds() {
1888
+ return c ? void 0 : o.contentBounds(0);
1889
+ },
1887
1890
  destroy() {
1888
- if (!s) {
1891
+ if (!c) {
1889
1892
  try {
1890
- c = d(e.exportDocument());
1893
+ l = d(e.exportDocument());
1891
1894
  } catch {
1892
- c = "";
1895
+ l = "";
1893
1896
  }
1894
- s = !0, o.clear(), e.destroy();
1897
+ c = !0, s.clear(), e.destroy();
1895
1898
  }
1896
1899
  }
1897
1900
  };