@miragon/value-chain-renderer 0.5.0 → 0.6.1
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 +24 -12
- package/dist/VcBaseViewer.d.ts +12 -9
- package/dist/VcBaseViewer.d.ts.map +1 -1
- package/dist/collaborative/CollaborativeValueChain.d.ts +12 -7
- package/dist/collaborative/CollaborativeValueChain.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -10
- package/dist/index.js.map +1 -1
- package/dist/io/VcImporter.d.ts +6 -1
- package/dist/io/VcImporter.d.ts.map +1 -1
- package/dist/io/index.d.ts +1 -1
- package/dist/io/index.d.ts.map +1 -1
- package/dist/label-editing/VcLabelEditingProvider.d.ts +14 -8
- package/dist/label-editing/VcLabelEditingProvider.d.ts.map +1 -1
- package/dist/palette/VcPaletteProvider.d.ts +9 -3
- package/dist/palette/VcPaletteProvider.d.ts.map +1 -1
- package/package.json +16 -9
package/README.md
CHANGED
|
@@ -19,7 +19,9 @@ collaborative hosts.
|
|
|
19
19
|
npm install @miragon/value-chain-renderer @miragon/value-chain-schema-model
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
ESM only, for browsers and bundlers.
|
|
22
|
+
ESM only, for browsers and bundlers. `diagram-js` (^15.28.0), `didi`, `tiny-svg` and `zod` are peer
|
|
23
|
+
dependencies: an app that already has them shares its copy with the renderer, since a second
|
|
24
|
+
diagram-js or Zod breaks the dependency injection and `instanceof` checks.
|
|
23
25
|
|
|
24
26
|
## Quick start
|
|
25
27
|
|
|
@@ -62,7 +64,7 @@ loads its own stylesheet after this one.
|
|
|
62
64
|
| `NavigatedViewer` | Read-only plus zoom and pan. |
|
|
63
65
|
| `Modeler` | The full editor, plus `undo()` / `redo()` on top of the shared API. |
|
|
64
66
|
|
|
65
|
-
All three take `{ container?, width?, height?, additionalModules?,
|
|
67
|
+
All three take `{ container?, width?, height?, additionalModules?, freeArea?, fitOnImport?, undoRedoKeys? }`
|
|
66
68
|
and share `importDocument`, `exportDocument`, `saveSVG`, `fitViewport`, `clear`, `attachTo`,
|
|
67
69
|
`detach`, `destroy`, `on`/`off` and `get` (DI lookup). `additionalModules` extends the DI
|
|
68
70
|
container as in bpmn-js; the feature modules (`vcDrawModule`, `vcRulesModule`, `vcPaletteModule`,
|
|
@@ -71,16 +73,22 @@ container as in bpmn-js; the feature modules (`vcDrawModule`, `vcRulesModule`, `
|
|
|
71
73
|
- `importDocument(document)` validates the document before it touches the canvas (a rejected one
|
|
72
74
|
throws and leaves the previous diagram, its ids and its undo history as they were), erases the
|
|
73
75
|
undo history silently (no `commandStack.changed`), and fits the view: the content centred at the
|
|
74
|
-
largest zoom that shows all of it, never above 100
|
|
75
|
-
|
|
76
|
+
largest zoom that shows all of it, never above 100 % (`fitOnImport: false` leaves the view to a
|
|
77
|
+
host that fits itself). A label being typed is taken down without committing and reopened
|
|
78
|
+
afterwards on the element with the same id.
|
|
79
|
+
- A label being typed stays open across every view change, a host's fit or restore as much as a
|
|
80
|
+
wheel zoom, and moves along with its element; only Enter, leaving the text box or a click or drag
|
|
81
|
+
on the canvas commits it.
|
|
76
82
|
- `exportDocument()` writes back every key the schema does not define (vendor extensions on the
|
|
77
83
|
document, its meta, its elements and connections).
|
|
78
84
|
- New elements get random ids (`step_k3x9q2mf`, `org_…`, `sequence_…`), so two people adding an
|
|
79
85
|
element to one document at the same time never pick the same id.
|
|
80
|
-
- `
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
its label editor
|
|
86
|
+
- `freeArea`: the canvas area the host's chrome leaves free, as `{ insets: () => FreeAreaInsets }`
|
|
87
|
+
(px from the container's edges) or `{ center: () => Point | undefined }` (diagram coordinates).
|
|
88
|
+
Enter or Space on a creating palette entry places the element in its centre (default: the centre
|
|
89
|
+
of the visible canvas), selected, with the canvas focused and its label editor open.
|
|
90
|
+
`freeRectCenter` is the deprecated name of `freeArea: { center }`, accepted until the next minor
|
|
91
|
+
release; given both, `freeArea` wins.
|
|
84
92
|
- `undoRedoKeys: false` leaves Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z and Ctrl+Y unbound and unprevented, for
|
|
85
93
|
a host that owns the history (the VS Code document).
|
|
86
94
|
|
|
@@ -113,11 +121,15 @@ modeler.onContentChanged(() => save(modeler.exportText())); // canonical JSON
|
|
|
113
121
|
```
|
|
114
122
|
|
|
115
123
|
`createCollaborativeModeler` and `createCollaborativeViewer` implement the `CollaborativeModeler`
|
|
116
|
-
contract 1.
|
|
124
|
+
contract 1.2 (`meta.notation` `"value-chain"`): blank text opens as an empty diagram,
|
|
117
125
|
`onContentChanged` fires for every edit and undo/redo and never for an import, view state is the
|
|
118
|
-
diagram-js viewbox,
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
diagram-js viewbox, a host's `setViewState` or fit never commits a label being typed, and the
|
|
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
|
|
129
|
+
the contract's factory options `freeArea`, `fitOnImport` and `undoRedoKeys` (the viewer ignores
|
|
130
|
+
the two that need editing) and the deprecated `freeRectCenter`. The browser test suite runs the
|
|
131
|
+
contract's conformance kit on every law, with no case skipped and no advisory. `diagram` is the
|
|
132
|
+
wrapped `Modeler` or `NavigatedViewer` for host wiring.
|
|
121
133
|
|
|
122
134
|
## Chrome content for hosts
|
|
123
135
|
|
package/dist/VcBaseViewer.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { ModuleDeclaration } from 'didi';
|
|
2
|
+
import { CollaborativeModelerOptions } from '@miragon/modeler-api';
|
|
2
3
|
import { EventBusEventCallback } from 'diagram-js/lib/core/EventBus';
|
|
3
4
|
import { Point, ValueChainDocument } from '@miragon/value-chain-schema-model';
|
|
4
5
|
import { ImportWarning } from './io/types.js';
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* `freeArea`, `fitOnImport` and `undoRedoKeys` as `@miragon/modeler-api` 1.2 names them:
|
|
8
|
+
* `freeArea` is where Enter or Space on a creating palette entry places the element (the centre of
|
|
9
|
+
* the canvas area the host's chrome leaves free, guide §5.5; default the centre of the visible
|
|
10
|
+
* canvas), `fitOnImport: false` leaves the view after an import to the host, and
|
|
11
|
+
* `undoRedoKeys: false` leaves Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z and Ctrl+Y to a host that owns the
|
|
12
|
+
* history (the VS Code document).
|
|
13
|
+
*/
|
|
14
|
+
export interface VcViewerOptions extends CollaborativeModelerOptions {
|
|
6
15
|
/** Host element. If missing, a detached <div> is created (attach later via attachTo). */
|
|
7
16
|
container?: HTMLElement;
|
|
8
17
|
width?: number | string;
|
|
@@ -10,16 +19,10 @@ export interface VcViewerOptions {
|
|
|
10
19
|
/** Concatenated to the end of the module list (extension point). */
|
|
11
20
|
additionalModules?: ModuleDeclaration[];
|
|
12
21
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* of the visible canvas.
|
|
22
|
+
* @deprecated Use `freeArea: { center }`; accepted until the next minor release. Given both,
|
|
23
|
+
* `freeArea` wins.
|
|
16
24
|
*/
|
|
17
25
|
freeRectCenter?: (() => Point | undefined) | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Bind Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z and Ctrl+Y to the canvas undo/redo (default true). Pass
|
|
20
|
-
* false when the host owns the history (the VS Code document), so the keys reach it.
|
|
21
|
-
*/
|
|
22
|
-
undoRedoKeys?: boolean | undefined;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* DI bootstrap and lifecycle shared by Viewer/NavigatedViewer/Modeler. The diagram is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VcBaseViewer.d.ts","sourceRoot":"","sources":["../src/VcBaseViewer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,M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AAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,QAAQ,SAAO,GAAG,IAAI;IAIzF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI;IAIzE;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,kBAAkB,GAAG,aAAa,EAAE;IAmB7D,cAAc,IAAI,kBAAkB;IAIpC,OAAO,IAAI;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;IAI1B,kDAAkD;IAClD,WAAW,IAAI,IAAI;IAYnB,KAAK,IAAI,IAAI;IAKb,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAMnC,MAAM,IAAI,IAAI;IAId,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,cAAc;CAgBvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollaborativeModeler, ElementsSurface } from '@miragon/modeler-api';
|
|
1
|
+
import { CollaborativeModeler, CollaborativeModelerOptions, 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';
|
|
@@ -7,21 +7,26 @@ import { NavigatedViewer } from '../NavigatedViewer.js';
|
|
|
7
7
|
export declare const VALUE_CHAIN_NOTATION = "value-chain";
|
|
8
8
|
/** What a blank text (a file just created in the explorer) opens as. */
|
|
9
9
|
export declare const BLANK_DOCUMENT_NAME = "New value chain";
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The contract's factory options (`freeArea`, `fitOnImport`, `undoRedoKeys`, see
|
|
12
|
+
* `VcViewerOptions`) plus the renderer's own. The viewer ignores the two that need editing.
|
|
13
|
+
*/
|
|
14
|
+
export interface CollaborativeValueChainOptions extends CollaborativeModelerOptions {
|
|
11
15
|
/** Appended to the renderer's own modules (e.g. a host's chrome module). */
|
|
12
16
|
additionalModules?: ModuleDeclaration[] | undefined;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `freeArea: { center }`; accepted until the next minor release. Given both,
|
|
19
|
+
* `freeArea` wins.
|
|
20
|
+
*/
|
|
16
21
|
freeRectCenter?: (() => Point | undefined) | undefined;
|
|
17
22
|
}
|
|
18
23
|
/** The contract surface plus the wrapped diagram for host-specific wiring. */
|
|
19
24
|
export interface CollaborativeValueChainModeler extends CollaborativeModeler {
|
|
20
|
-
readonly elements: ElementsSurface
|
|
25
|
+
readonly elements: ElementsSurface & Required<Pick<ElementsSurface, 'bounds'>>;
|
|
21
26
|
readonly diagram: Modeler | NavigatedViewer;
|
|
22
27
|
}
|
|
23
28
|
/** The editing mount (`meta.editable: true`) of the collaborative-modeler contract. */
|
|
24
29
|
export declare function createCollaborativeModeler(options?: CollaborativeValueChainOptions): CollaborativeValueChainModeler;
|
|
25
30
|
/** The read-only mount (`meta.editable: false`): imports, exports and reveals, never edits. */
|
|
26
|
-
export declare function createCollaborativeViewer(options?:
|
|
31
|
+
export declare function createCollaborativeViewer(options?: CollaborativeValueChainOptions): CollaborativeValueChainModeler;
|
|
27
32
|
//# sourceMappingURL=CollaborativeValueChain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollaborativeValueChain.d.ts","sourceRoot":"","sources":["../../src/collaborative/CollaborativeValueChain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,
|
|
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;AACnF,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,wEAAwE;AACxE,eAAO,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,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.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Modeler } from './Modeler.js';
|
|
|
5
5
|
export { isOrgUnit, isStep, isVcConnection, isVcElement, isVcShape, type VcConnection, type VcShape, type VcShapeType, } from './model/di-types.js';
|
|
6
6
|
export { vcModelModule, VcElementFactory, VcDiagramElementFactory } from './model/index.js';
|
|
7
7
|
export { vcDrawModule, VcRenderer, chevronPath, chevronPathAt, ellipsePathAt, notchDepth, COLORS, COLOR_OPTIONS, FONT, } from './draw/index.js';
|
|
8
|
-
export { ioModule, VcImporter, VcExporter, saveSVG, svgToPng, blobToBase64, ROOT_ID, } from './io/index.js';
|
|
8
|
+
export { ioModule, VcImporter, VcExporter, type VcImportConfig, saveSVG, svgToPng, blobToBase64, ROOT_ID, } from './io/index.js';
|
|
9
9
|
export { vcBoundsModule, VcBounds } from './bounds/index.js';
|
|
10
10
|
export { BLANK_DOCUMENT_NAME, VALUE_CHAIN_NOTATION, createCollaborativeModeler, createCollaborativeViewer, type CollaborativeValueChainModeler, type CollaborativeValueChainOptions, } from './collaborative/index.js';
|
|
11
11
|
export type { ImportWarning, RootBusinessObject } from './io/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,SAAS,EACT,MAAM,EACN,cAAc,EACd,WAAW,EACX,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,EACV,MAAM,EACN,aAAa,EACb,IAAI,GACL,MAAM,iBAAiB,CAAC;AACzB,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B,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -168,8 +168,12 @@ var Ye = class {
|
|
|
168
168
|
this._diagram = new e({
|
|
169
169
|
canvas: { container: this._container },
|
|
170
170
|
modules: t,
|
|
171
|
-
vcPalette: {
|
|
172
|
-
|
|
171
|
+
vcPalette: {
|
|
172
|
+
freeArea: this._options.freeArea,
|
|
173
|
+
freeRectCenter: this._options.freeRectCenter
|
|
174
|
+
},
|
|
175
|
+
vcKeyboard: { undoRedoKeys: this._options.undoRedoKeys ?? !0 },
|
|
176
|
+
vcImport: { fitOnImport: this._options.fitOnImport ?? !0 }
|
|
173
177
|
});
|
|
174
178
|
}
|
|
175
179
|
return this._diagram;
|
|
@@ -496,16 +500,18 @@ var ot = {
|
|
|
496
500
|
elementRegistry;
|
|
497
501
|
eventBus;
|
|
498
502
|
vcBounds;
|
|
503
|
+
config;
|
|
499
504
|
static $inject = [
|
|
500
505
|
"canvas",
|
|
501
506
|
"elementFactory",
|
|
502
507
|
"vcElementFactory",
|
|
503
508
|
"elementRegistry",
|
|
504
509
|
"eventBus",
|
|
505
|
-
"vcBounds"
|
|
510
|
+
"vcBounds",
|
|
511
|
+
"config.vcImport"
|
|
506
512
|
];
|
|
507
|
-
constructor(e, t, n, r, i, a) {
|
|
508
|
-
this.canvas = e, this.elementFactory = t, this.vcElementFactory = n, this.elementRegistry = r, this.eventBus = i, this.vcBounds = a;
|
|
513
|
+
constructor(e, t, n, r, i, a, o) {
|
|
514
|
+
this.canvas = e, this.elementFactory = t, this.vcElementFactory = n, this.elementRegistry = r, this.eventBus = i, this.vcBounds = a, this.config = o;
|
|
509
515
|
}
|
|
510
516
|
import(e) {
|
|
511
517
|
let t = [];
|
|
@@ -534,7 +540,7 @@ var ot = {
|
|
|
534
540
|
let s = this.vcElementFactory.createConnection(a, e, o);
|
|
535
541
|
this.canvas.addConnection(s, n, i), i += 1;
|
|
536
542
|
}
|
|
537
|
-
return this.fitToContent(), this.eventBus.fire("import.render.done", {
|
|
543
|
+
return this.config?.fitOnImport !== !1 && this.fitToContent(), this.eventBus.fire("import.render.done", {
|
|
538
544
|
document: e,
|
|
539
545
|
warnings: t
|
|
540
546
|
}), t;
|
|
@@ -1221,7 +1227,7 @@ var dn = 24, fn = class {
|
|
|
1221
1227
|
};
|
|
1222
1228
|
}
|
|
1223
1229
|
placeInFreeRect(e) {
|
|
1224
|
-
let t = this.
|
|
1230
|
+
let t = this.freeAreaCentre() ?? this.visibleCentre(), n = {
|
|
1225
1231
|
x: t.x,
|
|
1226
1232
|
y: t.y
|
|
1227
1233
|
};
|
|
@@ -1229,6 +1235,19 @@ var dn = 24, fn = class {
|
|
|
1229
1235
|
let r = this.modeling.createShape(e, n, this.canvas.getRootElement());
|
|
1230
1236
|
this.selection.select(r), this.canvas.focus(), this.injector.get("directEditing", !1)?.activate(r);
|
|
1231
1237
|
}
|
|
1238
|
+
freeAreaCentre() {
|
|
1239
|
+
let e = this.config?.freeArea;
|
|
1240
|
+
return e?.center ? e.center() : e?.insets ? this.centreWithin(e.insets()) : this.config?.freeRectCenter?.();
|
|
1241
|
+
}
|
|
1242
|
+
centreWithin(e) {
|
|
1243
|
+
let { width: t, height: n } = this.canvas.getSize();
|
|
1244
|
+
if (!(t > 0 && n > 0)) return;
|
|
1245
|
+
let r = (e, t, n) => t + n < e ? t + (e - t - n) / 2 : e / 2, { x: i, y: a, scale: o } = this.canvas.viewbox();
|
|
1246
|
+
return {
|
|
1247
|
+
x: i + r(t, e.left, e.right) / o,
|
|
1248
|
+
y: a + r(n, e.top, e.bottom) / o
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1232
1251
|
visibleCentre() {
|
|
1233
1252
|
let { x: e, y: t, width: n, height: r } = this.canvas.viewbox();
|
|
1234
1253
|
return {
|
|
@@ -1494,12 +1513,11 @@ var W = {
|
|
|
1494
1513
|
}), n.on([
|
|
1495
1514
|
"element.mousedown",
|
|
1496
1515
|
"drag.init",
|
|
1497
|
-
"canvas.viewbox.changing",
|
|
1498
1516
|
"autoPlace.start",
|
|
1499
1517
|
"popupMenu.open"
|
|
1500
1518
|
], () => {
|
|
1501
1519
|
e.isActive() && e.complete();
|
|
1502
|
-
}), n.on("commandStack.changed", () => {
|
|
1520
|
+
}), n.on("canvas.viewbox.changed", () => this.followView()), n.on("commandStack.changed", () => {
|
|
1503
1521
|
e.isActive() && e.cancel();
|
|
1504
1522
|
}), n.on("diagram.destroy", 1500, () => {
|
|
1505
1523
|
clearTimeout(this.resumeTimer), this.suspended = null, e.isActive() && e.cancel();
|
|
@@ -1535,6 +1553,19 @@ var W = {
|
|
|
1535
1553
|
let r = n.ownerDocument.getSelection();
|
|
1536
1554
|
r?.selectAllChildren(n), r?.collapseToEnd();
|
|
1537
1555
|
}
|
|
1556
|
+
followView() {
|
|
1557
|
+
let e = this.directEditing._active, t = this.directEditing._textbox;
|
|
1558
|
+
if (!e || !t) return;
|
|
1559
|
+
let n = this.activate(e.element);
|
|
1560
|
+
if (!n) return;
|
|
1561
|
+
let { x: r, y: i, width: a, height: o } = n.bounds;
|
|
1562
|
+
Object.assign(t.parent.style, {
|
|
1563
|
+
left: `${r}px`,
|
|
1564
|
+
top: `${i}px`,
|
|
1565
|
+
width: `${a}px`,
|
|
1566
|
+
height: `${o}px`
|
|
1567
|
+
}), t.content.style.fontSize = n.style?.fontSize ?? "", e.context.bounds = n.bounds;
|
|
1568
|
+
}
|
|
1538
1569
|
activate(e) {
|
|
1539
1570
|
if (!S(e)) return;
|
|
1540
1571
|
let t = e, n = this.canvas.getAbsoluteBBox(t), r = this.canvas.zoom(), i = (w(t) ? 12 : at(t.width, t.height)) * r;
|
|
@@ -1760,6 +1791,7 @@ function Un(e = {}) {
|
|
|
1760
1791
|
return qn(new Bn({
|
|
1761
1792
|
...Gn(e),
|
|
1762
1793
|
undoRedoKeys: e.undoRedoKeys ?? !0,
|
|
1794
|
+
freeArea: e.freeArea,
|
|
1763
1795
|
freeRectCenter: e.freeRectCenter
|
|
1764
1796
|
}), !0);
|
|
1765
1797
|
}
|
|
@@ -1770,7 +1802,8 @@ function Gn(e) {
|
|
|
1770
1802
|
return {
|
|
1771
1803
|
width: "100%",
|
|
1772
1804
|
height: "100%",
|
|
1773
|
-
additionalModules: e.additionalModules ?? []
|
|
1805
|
+
additionalModules: e.additionalModules ?? [],
|
|
1806
|
+
fitOnImport: e.fitOnImport ?? !0
|
|
1774
1807
|
};
|
|
1775
1808
|
}
|
|
1776
1809
|
function Kn(e) {
|
|
@@ -1797,6 +1830,18 @@ function qn(e, t) {
|
|
|
1797
1830
|
onSelection(e) {
|
|
1798
1831
|
let t = (t) => e(K(t.newSelection ?? []));
|
|
1799
1832
|
return n.on("selection.changed", t), () => n.off("selection.changed", t);
|
|
1833
|
+
},
|
|
1834
|
+
bounds(e) {
|
|
1835
|
+
if (s) return;
|
|
1836
|
+
let t = i.get(e);
|
|
1837
|
+
if (!S(t)) return;
|
|
1838
|
+
let { x: n, y: r, width: a, height: o } = t;
|
|
1839
|
+
return {
|
|
1840
|
+
x: n,
|
|
1841
|
+
y: r,
|
|
1842
|
+
width: a,
|
|
1843
|
+
height: o
|
|
1844
|
+
};
|
|
1800
1845
|
}
|
|
1801
1846
|
},
|
|
1802
1847
|
diagram: e,
|