@miragon/value-chain-renderer 0.4.0 → 0.6.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.
Files changed (69) hide show
  1. package/README.md +102 -12
  2. package/dist/Modeler.d.ts +4 -1
  3. package/dist/Modeler.d.ts.map +1 -1
  4. package/dist/VcBaseViewer.d.ts +24 -3
  5. package/dist/VcBaseViewer.d.ts.map +1 -1
  6. package/dist/bounds/VcBounds.d.ts +17 -0
  7. package/dist/bounds/VcBounds.d.ts.map +1 -0
  8. package/dist/bounds/index.d.ts +5 -0
  9. package/dist/bounds/index.d.ts.map +1 -0
  10. package/dist/collaborative/CollaborativeValueChain.d.ts +32 -0
  11. package/dist/collaborative/CollaborativeValueChain.d.ts.map +1 -0
  12. package/dist/collaborative/index.d.ts +2 -0
  13. package/dist/collaborative/index.d.ts.map +1 -0
  14. package/dist/context-pad/VcContextPadProvider.d.ts +3 -1
  15. package/dist/context-pad/VcContextPadProvider.d.ts.map +1 -1
  16. package/dist/diagram-menu/ShortcutsDialog.d.ts +27 -0
  17. package/dist/diagram-menu/ShortcutsDialog.d.ts.map +1 -0
  18. package/dist/diagram-menu/index.d.ts +7 -0
  19. package/dist/diagram-menu/index.d.ts.map +1 -0
  20. package/dist/diagram-menu/menu.d.ts +44 -0
  21. package/dist/diagram-menu/menu.d.ts.map +1 -0
  22. package/dist/diagram-menu/shortcuts.d.ts +41 -0
  23. package/dist/diagram-menu/shortcuts.d.ts.map +1 -0
  24. package/dist/draw/VcRenderer.d.ts +10 -1
  25. package/dist/draw/VcRenderer.d.ts.map +1 -1
  26. package/dist/draw/icons.d.ts +4 -7
  27. package/dist/draw/icons.d.ts.map +1 -1
  28. package/dist/draw/lucide.d.ts +31 -0
  29. package/dist/draw/lucide.d.ts.map +1 -0
  30. package/dist/draw/styles.d.ts +11 -5
  31. package/dist/draw/styles.d.ts.map +1 -1
  32. package/dist/index.d.ts +8 -4
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1274 -520
  35. package/dist/index.js.map +1 -1
  36. package/dist/io/VcExporter.d.ts +6 -5
  37. package/dist/io/VcExporter.d.ts.map +1 -1
  38. package/dist/io/VcImporter.d.ts +21 -3
  39. package/dist/io/VcImporter.d.ts.map +1 -1
  40. package/dist/io/index.d.ts +2 -1
  41. package/dist/io/index.d.ts.map +1 -1
  42. package/dist/io/png.d.ts +8 -0
  43. package/dist/io/png.d.ts.map +1 -0
  44. package/dist/io/saveSvg.d.ts +5 -5
  45. package/dist/io/saveSvg.d.ts.map +1 -1
  46. package/dist/io/types.d.ts +6 -1
  47. package/dist/io/types.d.ts.map +1 -1
  48. package/dist/keyboard/VcEditorActions.d.ts +5 -1
  49. package/dist/keyboard/VcEditorActions.d.ts.map +1 -1
  50. package/dist/keyboard/VcKeyboardBindings.d.ts +14 -2
  51. package/dist/keyboard/VcKeyboardBindings.d.ts.map +1 -1
  52. package/dist/keyboard/index.d.ts +2 -2
  53. package/dist/keyboard/index.d.ts.map +1 -1
  54. package/dist/label-editing/VcLabelEditingProvider.d.ts +46 -5
  55. package/dist/label-editing/VcLabelEditingProvider.d.ts.map +1 -1
  56. package/dist/label-editing/index.d.ts +1 -1
  57. package/dist/label-editing/index.d.ts.map +1 -1
  58. package/dist/model/VcDiagramElementFactory.d.ts +4 -4
  59. package/dist/model/VcDiagramElementFactory.d.ts.map +1 -1
  60. package/dist/palette/VcPaletteProvider.d.ts +41 -5
  61. package/dist/palette/VcPaletteProvider.d.ts.map +1 -1
  62. package/dist/palette/index.d.ts +1 -1
  63. package/dist/palette/index.d.ts.map +1 -1
  64. package/dist/read-only/VcReadOnly.d.ts +25 -0
  65. package/dist/read-only/VcReadOnly.d.ts.map +1 -0
  66. package/dist/read-only/index.d.ts +5 -0
  67. package/dist/read-only/index.d.ts.map +1 -0
  68. package/dist/value-chain.css +1 -1
  69. package/package.json +16 -8
@@ -1,16 +1,17 @@
1
1
  import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
2
- import { default as Canvas } from 'diagram-js/lib/core/Canvas';
3
2
  import { ValueChainDocument } from '@miragon/value-chain-schema-model';
4
3
  /**
5
4
  * Rebuilds a schema-model document from the live diagram. The diagram-js element
6
- * properties are the source of truth; businessObject only backfills fields the UI
7
- * cannot edit (currently: `link`).
5
+ * properties are the source of truth; businessObject backfills what the UI cannot edit:
6
+ * a step's `link` and every field beyond the schema (vendor extensions), which the
7
+ * export writes back unchanged.
8
8
  */
9
9
  export default class VcExporter {
10
10
  private readonly elementRegistry;
11
- private readonly canvas;
12
11
  static $inject: string[];
13
- constructor(elementRegistry: ElementRegistry, canvas: Canvas);
12
+ constructor(elementRegistry: ElementRegistry);
14
13
  export(): ValueChainDocument;
14
+ /** Read without `canvas.getRootElement()`, which would create an implicit root before import. */
15
+ private rootData;
15
16
  }
16
17
  //# sourceMappingURL=VcExporter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VcExporter.d.ts","sourceRoot":"","sources":["../../src/io/VcExporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAC;AAI3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,MAAM,CAAC,OAAO,WAAiC;gBAG5B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM;IAGjC,MAAM,IAAI,kBAAkB;CA6D7B"}
1
+ {"version":3,"file":"VcExporter.d.ts","sourceRoot":"","sources":["../../src/io/VcExporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAC;AAI3C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAGjB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAF5C,MAAM,CAAC,OAAO,WAAuB;gBAER,eAAe,EAAE,eAAe;IAE7D,MAAM,IAAI,kBAAkB;IAmE5B,iGAAiG;IACjG,OAAO,CAAC,QAAQ;CAKjB"}
@@ -3,10 +3,15 @@ import { default as ElementFactory } from 'diagram-js/lib/core/ElementFactory';
3
3
  import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
4
4
  import { default as EventBus } from 'diagram-js/lib/core/EventBus';
5
5
  import { ValueChainDocument } from '@miragon/value-chain-schema-model';
6
+ import { default as VcBounds } from '../bounds/VcBounds.js';
6
7
  import { default as VcElementFactory } from '../model/VcElementFactory.js';
7
8
  import { ImportWarning } from './types.js';
9
+ export interface VcImportConfig {
10
+ /** Fit the view to the content after every import (default true); false leaves it to the host. */
11
+ fitOnImport?: boolean | undefined;
12
+ }
8
13
  /**
9
- * Renders a value chain document onto the canvas. Deliberately bypasses the command
14
+ * Renders a validated value chain document onto the canvas. Deliberately bypasses the command
10
15
  * stack — importing must not create undo entries.
11
16
  */
12
17
  export default class VcImporter {
@@ -15,11 +20,24 @@ export default class VcImporter {
15
20
  private readonly vcElementFactory;
16
21
  private readonly elementRegistry;
17
22
  private readonly eventBus;
23
+ private readonly vcBounds;
24
+ private readonly config;
18
25
  static $inject: string[];
19
- constructor(canvas: Canvas, elementFactory: ElementFactory, vcElementFactory: VcElementFactory, elementRegistry: ElementRegistry, eventBus: EventBus);
26
+ constructor(canvas: Canvas, elementFactory: ElementFactory, vcElementFactory: VcElementFactory, elementRegistry: ElementRegistry, eventBus: EventBus, vcBounds: VcBounds, config: VcImportConfig | undefined);
20
27
  import(document: ValueChainDocument): ImportWarning[];
21
28
  /** Removes all imported elements and document meta, tolerating elements already gone. */
22
29
  clear(): void;
23
- private ensureRoot;
30
+ /**
31
+ * The diagram's root, created on the first import. Any other root goes: diagram-js creates an
32
+ * implicit one whenever something asks for the root before the first import (an export, a
33
+ * palette create), and it would otherwise stay behind in the registry.
34
+ */
35
+ private diagramRoot;
36
+ /**
37
+ * Centres the content at the largest zoom that shows all of it, never above 100% (guide §5.9),
38
+ * so the same document always opens in the same view; an empty diagram shows its origin at
39
+ * 100%. Hosts with chrome of their own refit with their insets afterwards.
40
+ */
41
+ private fitToContent;
24
42
  }
25
43
  //# sourceMappingURL=VcImporter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VcImporter.d.ts","sourceRoot":"","sources":["../../src/io/VcImporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,cAAc,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAW,KAAK,aAAa,EAA2B,MAAM,YAAY,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAP3B,MAAM,CAAC,OAAO,WAAmF;gBAG9E,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ;IAGrC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,aAAa,EAAE;IAuCrD,yFAAyF;IACzF,KAAK,IAAI,IAAI;IAmBb,OAAO,CAAC,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IG;IACH,OAAO,CAAC,WAAW;IAcnB;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAqBrB"}
@@ -1,8 +1,9 @@
1
1
  import { ModuleDeclaration } from 'didi';
2
2
  /** Document import/export between schema-model and the canvas. */
3
3
  export declare const ioModule: ModuleDeclaration;
4
- export { default as VcImporter } from './VcImporter.js';
4
+ export { default as VcImporter, type VcImportConfig } from './VcImporter.js';
5
5
  export { default as VcExporter } from './VcExporter.js';
6
6
  export { saveSVG } from './saveSvg.js';
7
+ export { svgToPng, blobToBase64 } from './png.js';
7
8
  export { ROOT_ID, type ImportWarning, type RootBusinessObject } from './types.js';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,kEAAkE;AAClE,eAAO,MAAM,QAAQ,EAAE,iBAGtB,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAK9C,kEAAkE;AAClE,eAAO,MAAM,QAAQ,EAAE,iBAItB,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Rasterizes an exported SVG (`saveSVG`) to a PNG at `scale` × its size, on the diagram's white
3
+ * fill, so a PNG looks like the SVG in every viewer and stays light in every mode.
4
+ */
5
+ export declare function svgToPng(svg: string, scale?: number): Promise<Blob>;
6
+ /** Blob -> Base64 (without the data-URL prefix), e.g. to post it to a VS Code extension host. */
7
+ export declare function blobToBase64(blob: Blob): Promise<string>;
8
+ //# sourceMappingURL=png.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../../src/io/png.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BpE;AAQD,iGAAiG;AACjG,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxD"}
@@ -1,11 +1,11 @@
1
1
  import { default as Canvas } from 'diagram-js/lib/core/Canvas';
2
- import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
2
+ import { default as VcBounds } from '../bounds/VcBounds.js';
3
3
  /**
4
- * Standalone SVG export: clones the live SVG, sets a viewBox around the diagram
5
- * contents and strips the pan/zoom transform. Fonts are SVG presentation attributes,
6
- * so the result renders identically outside the editor.
4
+ * Standalone SVG export: clones the live SVG, sets a viewBox around the diagram contents and
5
+ * strips the pan/zoom transform. Fonts and colours are SVG presentation attributes, so the
6
+ * result renders identically outside the editor and stays light in every mode.
7
7
  */
8
- export declare function saveSVG(canvas: Canvas, elementRegistry: ElementRegistry): {
8
+ export declare function saveSVG(canvas: Canvas, bounds: Pick<VcBounds, 'contentBounds'>): {
9
9
  svg: string;
10
10
  };
11
11
  //# sourceMappingURL=saveSvg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveSvg.d.ts","sourceRoot":"","sources":["../../src/io/saveSvg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AAOvE;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CA8BzF"}
1
+ {"version":3,"file":"saveSvg.d.ts","sourceRoot":"","sources":["../../src/io/saveSvg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAUlD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CA4BhG"}
@@ -1,10 +1,15 @@
1
+ /** The id of the canvas root; the schema reserves it (RESERVED_IDS), so no element can take it. */
1
2
  export declare const ROOT_ID = "vc-root";
2
3
  export interface ImportWarning {
3
4
  message: string;
4
5
  connectionId?: string;
5
6
  }
6
- /** Document-level metadata kept on the root element while editing. */
7
+ /** Document-level data kept on the root element while editing. */
7
8
  export interface RootBusinessObject {
8
9
  name: string;
10
+ /** The document's fields beyond the schema, written back on export. */
11
+ extensions?: Record<string, unknown>;
12
+ /** The meta fields beyond the schema, written back on export. */
13
+ metaExtensions?: Record<string, unknown>;
9
14
  }
10
15
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/io/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/io/types.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C"}
@@ -1,6 +1,10 @@
1
1
  import { default as EventBus } from 'diagram-js/lib/core/EventBus';
2
2
  import { Injector } from 'didi';
3
- /** Registers the tool/editing actions the keyboard bindings and app chrome rely on. */
3
+ /**
4
+ * Registers the tool, editing and selection actions the keyboard bindings and hosts rely on.
5
+ * Under the edit lock (`vcReadOnly`) the space tool, the connect tool and the label editor stay
6
+ * shut; the hand, the lasso and select all keep working.
7
+ */
4
8
  export default class VcEditorActions {
5
9
  static $inject: string[];
6
10
  constructor(eventBus: EventBus, injector: Injector);
@@ -1 +1 @@
1
- {"version":3,"file":"VcEditorActions.d.ts","sourceRoot":"","sources":["../../src/keyboard/VcEditorActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAUrC,uFAAuF;AACvF,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,MAAM,CAAC,OAAO,WAA4B;gBAE9B,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;CAgCnD"}
1
+ {"version":3,"file":"VcEditorActions.d.ts","sourceRoot":"","sources":["../../src/keyboard/VcEditorActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAerC;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,MAAM,CAAC,OAAO,WAA4B;gBAE9B,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;CAuDnD"}
@@ -1,11 +1,23 @@
1
1
  import { default as KeyboardBindings } from 'diagram-js/lib/features/keyboard/KeyboardBindings';
2
+ import { default as EventBus } from 'diagram-js/lib/core/EventBus';
2
3
  import { default as Keyboard } from 'diagram-js/lib/features/keyboard/Keyboard';
3
4
  import { default as EditorActions } from 'diagram-js/lib/features/editor-actions/EditorActions';
5
+ export interface VcKeyboardConfig {
6
+ /**
7
+ * Bind Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z and Ctrl+Y to the canvas command stack (default true). A
8
+ * host that owns the history (the VS Code document) passes false, so the keys reach it.
9
+ */
10
+ undoRedoKeys?: boolean | undefined;
11
+ }
4
12
  /**
5
- * Default diagram-js bindings (undo/redo/copy/paste/zoom/delete) plus the bpmn.io
6
- * single-key tool shortcuts: H hand, L lasso, S space, C connect, E direct editing.
13
+ * Default diagram-js bindings (undo/redo/copy/paste/zoom/delete) plus the single-key tool
14
+ * shortcuts L lasso, H hand, S space, C connect, E label editing, and Cmd/Ctrl+A for select all.
15
+ * The keyboard listens on the focused canvas only.
7
16
  */
8
17
  export default class VcKeyboardBindings extends KeyboardBindings {
18
+ static $inject: string[];
19
+ private readonly undoRedoKeys;
20
+ constructor(eventBus: EventBus, keyboard: Keyboard, config: VcKeyboardConfig | undefined);
9
21
  registerBindings(keyboard: Keyboard, editorActions: EditorActions): void;
10
22
  }
11
23
  //# sourceMappingURL=VcKeyboardBindings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VcKeyboardBindings.d.ts","sourceRoot":"","sources":["../../src/keyboard/VcKeyboardBindings.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,mDAAmD,CAAC;AAEjF,OAAO,KAAK,QAAQ,MAAM,2CAA2C,CAAC;AACtE,OAAO,KAAK,aAAa,MAAM,sDAAsD,CAAC;AAMtF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,gBAAgB;IACrD,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,GAAG,IAAI;CA0BlF"}
1
+ {"version":3,"file":"VcKeyboardBindings.d.ts","sourceRoot":"","sources":["../../src/keyboard/VcKeyboardBindings.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,mDAAmD,CAAC;AAEjF,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,2CAA2C,CAAC;AACtE,OAAO,KAAK,aAAa,MAAM,sDAAsD,CAAC;AAMtF,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAID;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,gBAAgB;IAC9D,OAAgB,OAAO,WAAiD;IAExE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;gBAE3B,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,GAAG,SAAS;IAK/E,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,GAAG,IAAI;CA8ClF"}
@@ -1,6 +1,6 @@
1
1
  import { ModuleDeclaration } from 'didi';
2
- /** Overrides the stock `keyboardBindings` with the bpmn.io-style tool shortcuts. */
2
+ /** Overrides the stock `keyboardBindings` with the tool shortcuts and select all. */
3
3
  export declare const vcKeyboardModule: ModuleDeclaration;
4
- export { default as VcKeyboardBindings } from './VcKeyboardBindings.js';
4
+ export { default as VcKeyboardBindings, type VcKeyboardConfig } from './VcKeyboardBindings.js';
5
5
  export { default as VcEditorActions } from './VcEditorActions.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keyboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAM9C,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,EAAE,iBAK9B,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keyboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAM9C,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,EAAE,iBAK9B,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,13 +1,25 @@
1
1
  import { default as Canvas } from 'diagram-js/lib/core/Canvas';
2
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
2
3
  import { default as EventBus } from 'diagram-js/lib/core/EventBus';
3
4
  import { Element } from 'diagram-js/lib/model/Types';
5
+ import { VcShape } from '../model/di-types.js';
4
6
  import { default as VcModeling } from '../modeling/VcModeling.js';
5
7
  interface DirectEditingLike {
6
8
  registerProvider(provider: unknown): void;
7
- activate(element: Element): void;
9
+ activate(element: Element): boolean;
8
10
  isActive(element?: Element): boolean;
9
11
  complete(): void;
10
12
  cancel(): void;
13
+ getValue(): string;
14
+ /** diagram-js-direct-editing internals: the edit open right now and its text box. */
15
+ _active?: {
16
+ element: Element;
17
+ context: EditingContext;
18
+ } | null;
19
+ _textbox?: {
20
+ parent: HTMLElement;
21
+ content: HTMLElement;
22
+ };
11
23
  }
12
24
  interface EditingContext {
13
25
  bounds: {
@@ -20,17 +32,46 @@ interface EditingContext {
20
32
  style?: Record<string, string>;
21
33
  options?: Record<string, unknown>;
22
34
  }
35
+ /** A label edit open right now: the element and the text typed so far, not yet committed. */
36
+ export interface OpenLabelEdit {
37
+ element: VcShape;
38
+ text: string;
39
+ }
23
40
  /**
24
- * In-place label editing via diagram-js-direct-editing, bpmn.io style: double click
25
- * (or E) opens a centered text box over the chevron's label area; editing commits
26
- * through the command stack (undoable).
41
+ * In-place label editing via diagram-js-direct-editing: double click (or E) opens a centered
42
+ * text box over the shape's label area; editing commits through the command stack (undoable).
43
+ * Only the user's own gestures commit (Enter, leaving the text box, a click or drag on the
44
+ * canvas); a view change keeps the edit open and moves the text box along. An import takes an open
45
+ * edit down without committing it and reopens it on the element with the same id, with the typed
46
+ * text, when the imported diagram still has that element.
27
47
  */
28
48
  export default class VcLabelEditingProvider {
29
49
  private readonly directEditing;
30
50
  private readonly canvas;
31
51
  private readonly vcModeling;
52
+ private readonly elementRegistry;
32
53
  static $inject: string[];
33
- constructor(directEditing: DirectEditingLike, canvas: Canvas, eventBus: EventBus, vcModeling: VcModeling);
54
+ private suspended;
55
+ private resumeTimer;
56
+ constructor(directEditing: DirectEditingLike, canvas: Canvas, eventBus: EventBus, vcModeling: VcModeling, elementRegistry: ElementRegistry);
57
+ /** The edit open right now, or undefined. */
58
+ openEdit(): OpenLabelEdit | undefined;
59
+ /**
60
+ * Takes an open edit down WITHOUT committing it, for an import that replaces the diagram: its
61
+ * element is about to be removed, and a later commit would apply the typed text to a detached
62
+ * shape. Hosts re-import remote states while the user types; `resumeAfterImport` brings the
63
+ * editor back with the typed text.
64
+ */
65
+ suspend(): void;
66
+ /**
67
+ * Reopens a suspended edit on the element with the same id, if the imported diagram still has
68
+ * it. Deferred to the next task, so the text box opens in the view and selection the host
69
+ * restores around the import.
70
+ */
71
+ resumeAfterImport(): void;
72
+ private resume;
73
+ /** Puts the open text box over its element again in the current view, with the typed text. */
74
+ private followView;
34
75
  activate(element: Element): EditingContext | undefined;
35
76
  update(element: Element, newText: string): void;
36
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"VcLabelEditingProvider.d.ts","sourceRoot":"","sources":["../../src/label-editing/VcLabelEditingProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAI1D,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AAExD,UAAU,iBAAiB;IACzB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACrC,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,M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UAAU;IAsBlB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS;IAoCtD,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;CAGhD"}
@@ -1,4 +1,4 @@
1
1
  import { ModuleDeclaration } from 'didi';
2
2
  export declare const vcLabelEditingModule: ModuleDeclaration;
3
- export { default as VcLabelEditingProvider } from './VcLabelEditingProvider.js';
3
+ export { default as VcLabelEditingProvider, type OpenLabelEdit } from './VcLabelEditingProvider.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/label-editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,eAAO,MAAM,oBAAoB,EAAE,iBAIlC,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/label-editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,eAAO,MAAM,oBAAoB,EAAE,iBAIlC,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC"}
@@ -2,14 +2,14 @@ import { default as ElementFactory } from 'diagram-js/lib/core/ElementFactory';
2
2
  import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
3
3
  import { Connection, Label, Root, Shape } from 'diagram-js/lib/model/Types';
4
4
  /**
5
- * Replaces the stock elementFactory: generated ids are probed against the element
6
- * registry, so interactively created elements never collide with ids that came in
7
- * through document import (the stock factory's counter restarts at 0 per instance).
5
+ * Replaces the stock elementFactory: an element created on the canvas gets a random id (for
6
+ * example `step_k3x9q2mf`), probed against the element registry. Two people editing one document
7
+ * at the same time thus never create two elements with the same id, which a per-instance counter
8
+ * (`shape_1` on both sides) would.
8
9
  */
9
10
  export default class VcDiagramElementFactory extends ElementFactory {
10
11
  private readonly elementRegistry;
11
12
  static $inject: string[];
12
- private readonly counters;
13
13
  constructor(elementRegistry: ElementRegistry);
14
14
  create(type: 'root', attrs?: Partial<Root>): Root;
15
15
  create(type: 'shape', attrs?: Partial<Shape>): Shape;
@@ -1 +1 @@
1
- {"version":3,"file":"VcDiagramElementFactory.d.ts","sourceRoot":"","sources":["../../src/model/VcDiagramElementFactory.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,cAAc;IAKrD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJ5C,MAAM,CAAC,OAAO,WAAuB;IAErC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;gBAEzB,eAAe,EAAE,eAAe;IAIpD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IACjD,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK;IACpD,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;IACnE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK;IAkB7D,OAAO,CAAC,QAAQ;CAUjB"}
1
+ {"version":3,"file":"VcDiagramElementFactory.d.ts","sourceRoot":"","sources":["../../src/model/VcDiagramElementFactory.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAmBjF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,cAAc;IAGrD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAF5C,MAAM,CAAC,OAAO,WAAuB;gBAER,eAAe,EAAE,eAAe;IAIpD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IACjD,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK;IACpD,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;IACnE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK;IAkB7D,OAAO,CAAC,QAAQ;CASjB"}
@@ -1,21 +1,37 @@
1
+ import { default as Canvas } from 'diagram-js/lib/core/Canvas';
2
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
1
3
  import { default as Palette } from 'diagram-js/lib/features/palette/Palette';
2
4
  import { default as Create } from 'diagram-js/lib/features/create/Create';
3
5
  import { default as HandTool } from 'diagram-js/lib/features/hand-tool/HandTool';
4
6
  import { default as LassoTool } from 'diagram-js/lib/features/lasso-tool/LassoTool';
5
7
  import { default as SpaceTool } from 'diagram-js/lib/features/space-tool/SpaceTool';
6
8
  import { default as GlobalConnect } from 'diagram-js/lib/features/global-connect/GlobalConnect';
9
+ import { default as Modeling } from 'diagram-js/lib/features/modeling/Modeling';
10
+ import { default as Selection } from 'diagram-js/lib/features/selection/Selection';
11
+ import { FreeArea } from '@miragon/modeler-api';
12
+ import { Point } from '@miragon/value-chain-schema-model';
7
13
  import { default as VcElementFactory } from '../model/VcElementFactory.js';
8
14
  interface PaletteEntry {
9
15
  group: string;
10
16
  html?: string;
11
- separator?: boolean;
12
17
  title?: string;
18
+ shortcut?: string;
13
19
  action?: Record<string, (event: Event) => void>;
14
20
  }
21
+ export interface VcPaletteConfig {
22
+ /**
23
+ * The canvas area the host's chrome leaves free: Enter or Space on a creating entry places the
24
+ * element in its centre (guide §5.5). Without it, or while its centre is undefined, the element
25
+ * lands in the centre of the visible canvas.
26
+ */
27
+ freeArea?: FreeArea | undefined;
28
+ /** @deprecated Use `freeArea: { center }`. Given both, `freeArea` wins. */
29
+ freeRectCenter?: (() => Point | undefined) | undefined;
30
+ }
15
31
  /**
16
- * bpmn.io-style palette: tools on top (hand, lasso, space, global connect),
17
- * then the create entries. Tool entry keys must end in `-tool` and use the
18
- * group `tools` so the active tool gets highlighted.
32
+ * Tools first (Lasso, Hand, Space, Connect), then the creating entries. Tool entry keys end in
33
+ * `-tool` in the group `tools`, so the active tool gets highlighted. Titles and shortcuts are
34
+ * separate fields, so a tooltip shows the key as a chip.
19
35
  */
20
36
  export default class VcPaletteProvider {
21
37
  private readonly create;
@@ -24,9 +40,29 @@ export default class VcPaletteProvider {
24
40
  private readonly lassoTool;
25
41
  private readonly spaceTool;
26
42
  private readonly globalConnect;
43
+ private readonly canvas;
44
+ private readonly modeling;
45
+ private readonly selection;
46
+ private readonly elementRegistry;
47
+ private readonly injector;
48
+ private readonly config;
27
49
  static $inject: string[];
28
- constructor(palette: Palette, create: Create, factory: VcElementFactory, handTool: HandTool, lassoTool: LassoTool, spaceTool: SpaceTool, globalConnect: GlobalConnect);
50
+ constructor(palette: Palette, create: Create, factory: VcElementFactory, handTool: HandTool, lassoTool: LassoTool, spaceTool: SpaceTool, globalConnect: GlobalConnect, canvas: Canvas, modeling: Modeling, selection: Selection, elementRegistry: ElementRegistry, injector: {
51
+ get<T>(name: string, strict?: boolean): T | null;
52
+ }, config: VcPaletteConfig | undefined);
29
53
  getPaletteEntries(): Record<string, PaletteEntry>;
54
+ /**
55
+ * Enter or Space on a creating entry (guide §5.5): diagram-js's create follows the pointer and
56
+ * never ends without one, so the element goes straight to the centre of the free rectangle,
57
+ * selected, with the focus on the canvas and its label editor open.
58
+ */
59
+ private placeInFreeRect;
60
+ private freeAreaCentre;
61
+ /** The centre of the container without `insets`, in diagram coordinates, as a fit centres. */
62
+ private centreWithin;
63
+ private visibleCentre;
64
+ private centreTaken;
65
+ private editLock;
30
66
  }
31
67
  export {};
32
68
  //# sourceMappingURL=VcPaletteProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VcPaletteProvider.d.ts","sourceRoot":"","sources":["../../src/palette/VcPaletteProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yCAAyC,CAAC;AAEnE,OAAO,KAAK,MAAM,MAAM,uCAAuC,CAAC;AAChE,OAAO,KAAK,QAAQ,MAAM,4CAA4C,CAAC;AACvE,OAAO,KAAK,SAAS,MAAM,8CAA8C,CAAC;AAC1E,OAAO,KAAK,SAAS,MAAM,8CAA8C,CAAC;AAC1E,OAAO,KAAK,aAAa,MAAM,sDAAsD,CAAC;AAEtF,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAGjE,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;CACjD;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAalC,OAAO,CAAC,QAAQ,CAAC,MAAM;I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AC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,IAAI,CAAA;KAAE,EAC9D,MAAM,EAAE,eAAe,GAAG,SAAS;IAKtD,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IA6DjD;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,cAAc;IAOtB,8FAA8F;IAC9F,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,QAAQ;CAGjB"}
@@ -1,4 +1,4 @@
1
1
  import { ModuleDeclaration } from 'didi';
2
2
  export declare const vcPaletteModule: ModuleDeclaration;
3
- export { default as VcPaletteProvider } from './VcPaletteProvider.js';
3
+ export { default as VcPaletteProvider, type VcPaletteConfig } from './VcPaletteProvider.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/palette/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAS9C,eAAO,MAAM,eAAe,EAAE,iBAW7B,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/palette/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAS9C,eAAO,MAAM,eAAe,EAAE,iBAW7B,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { default as RuleProvider } from 'diagram-js/lib/features/rules/RuleProvider';
2
+ import { default as EventBus } from 'diagram-js/lib/core/EventBus';
3
+ import { Injector } from 'didi';
4
+ /** Fired with `{ readOnly }` whenever the lock changes. */
5
+ export declare const READ_ONLY_CHANGED_EVENT = "valueChain.readOnly.changed";
6
+ /**
7
+ * Locks every edit on the canvas while the document behind it cannot be saved from the canvas
8
+ * (an invalid file in an IDE host, guide §13.5): the rules veto move, resize, create, connect,
9
+ * reconnect, waypoints, delete, align and distribute; paste, the label editor and the context pad
10
+ * stay shut, and the editing keys and tools check `isReadOnly()`. Selection, lasso, hand, zoom,
11
+ * copy and export keep working.
12
+ */
13
+ export default class VcReadOnly extends RuleProvider {
14
+ private readonly bus;
15
+ private readonly injector;
16
+ static $inject: string[];
17
+ private readOnly;
18
+ constructor(bus: EventBus, injector: Injector);
19
+ init(): void;
20
+ isReadOnly(): boolean;
21
+ setReadOnly(readOnly: boolean): void;
22
+ /** What was already under way when the lock arrived must not land on the locked canvas. */
23
+ private interruptEdits;
24
+ }
25
+ //# sourceMappingURL=VcReadOnly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcReadOnly.d.ts","sourceRoot":"","sources":["../../src/read-only/VcReadOnly.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,4CAA4C,CAAC;AACtE,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,2DAA2D;AAC3D,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AA6BrE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,YAAY;IAMhD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAN3B,OAAgB,OAAO,WAA4B;IAEnD,OAAO,CAAC,QAAQ,CAAS;gBAGN,GAAG,EAAE,QAAQ,EACb,QAAQ,EAAE,QAAQ;IAS5B,IAAI,IAAI,IAAI;IAIrB,UAAU,IAAI,OAAO;IAIrB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAWpC,2FAA2F;IAC3F,OAAO,CAAC,cAAc;CAOvB"}
@@ -0,0 +1,5 @@
1
+ import { ModuleDeclaration } from 'didi';
2
+ /** The canvas edit lock (an invalid file in an IDE host). */
3
+ export declare const vcReadOnlyModule: ModuleDeclaration;
4
+ export { default as VcReadOnly, READ_ONLY_CHANGED_EVENT } from './VcReadOnly.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/read-only/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,EAAE,iBAI9B,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC"}