@d3-polytree/editor 0.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/dist/index.cjs ADDED
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Editor: () => Editor,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_interactive_viewer = require("@d3-polytree/interactive-viewer");
28
+ var import_viewer = require("@d3-polytree/viewer");
29
+ var import_core = require("@d3-polytree/core");
30
+ var import_properties_panel = require("@d3-polytree/properties-panel");
31
+ var INITIAL_DIAGRAM = '<?xml version="1.0" encoding="UTF-8"?><pfdn:diagram xmlns:pfdn="http://pfdn" xmlns="http://pfdn"><settings author="No Author" name="No Name Diagram" status="1"><zoom><offset x="0" y="0" /><scale>1</scale></zoom><grid /></settings><node id="node_1" label="label_1" status="1"><position x="20" y="100" /></node><label id="label_1" fontSize="12" isReadOnly="true" status="1"><position x="33" y="140" /><text>Node 1</text></label></pfdn:diagram>';
32
+ var _Editor = class _Editor extends import_interactive_viewer.InteractiveViewer {
33
+ constructor() {
34
+ super(...arguments);
35
+ /** The document a fresh editor opens with (used by {@link createDiagram}). */
36
+ this.initialDiagram = INITIAL_DIAGRAM;
37
+ }
38
+ /** (Re)open the initial diagram. */
39
+ createDiagram() {
40
+ return this.importDiagram(this.initialDiagram);
41
+ }
42
+ getModules() {
43
+ return [
44
+ ...import_interactive_viewer.InteractiveViewer.interactionModules,
45
+ ..._Editor.editionModules,
46
+ ...import_viewer.Viewer.modules
47
+ ];
48
+ }
49
+ /** Create a node (and its associated label) at an optional position. */
50
+ createNode(parameters = {}) {
51
+ return this.get("modellingNodes").create(parameters);
52
+ }
53
+ /** Select an element by definition (e.g. to prepare a delete). */
54
+ select(definition) {
55
+ const element = this.get("drawingRegistry").get(definition.id);
56
+ if (element) {
57
+ this.get("selection").select(element, definition);
58
+ }
59
+ }
60
+ /** Delete the current selection (cascading to associated labels). */
61
+ deleteSelected() {
62
+ this.get("selection").deleteSelected();
63
+ }
64
+ };
65
+ /** Editing modules on top of the interaction layer. */
66
+ _Editor.editionModules = [
67
+ import_core.dragModule,
68
+ import_core.modellingModule,
69
+ import_core.exportingModule,
70
+ import_core.localStorageModule,
71
+ import_core.uploadModule,
72
+ import_core.paletteModule,
73
+ import_core.resizeElementModule,
74
+ // the properties panel (registers a side tab; side-tabs + search-panel are
75
+ // inherited from InteractiveViewer)
76
+ import_properties_panel.entryFactoryModule,
77
+ import_properties_panel.pfdnPropertiesProviderModule,
78
+ import_properties_panel.propertiesPanelModule
79
+ ];
80
+ var Editor = _Editor;
81
+ var index_default = Editor;
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ Editor
85
+ });
86
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @d3-polytree/editor — create and modify polytree diagrams.\n *\n * Extends the {@link InteractiveViewer} with the editing layer: element\n * dragging plus the modelling create/save/delete flows. Element creation is\n * exposed programmatically here; the palette toolbar UI is layered on next.\n */\nimport { InteractiveViewer, type InteractiveViewerOptions } from '@d3-polytree/interactive-viewer';\nimport { Viewer } from '@d3-polytree/viewer';\nimport {\n dragModule,\n modellingModule,\n exportingModule,\n localStorageModule,\n uploadModule,\n paletteModule,\n resizeElementModule,\n type DiagramModule,\n type DrawingRegistry,\n type ModellingNodes,\n type ModellingModelElement,\n type CreateParameters,\n type Selection\n} from '@d3-polytree/core';\nimport {\n entryFactoryModule,\n pfdnPropertiesProviderModule,\n propertiesPanelModule\n} from '@d3-polytree/properties-panel';\n\n/** The document a fresh editor opens with. */\nconst INITIAL_DIAGRAM =\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' +\n '<pfdn:diagram xmlns:pfdn=\"http://pfdn\" xmlns=\"http://pfdn\">' +\n '<settings author=\"No Author\" name=\"No Name Diagram\" status=\"1\">' +\n '<zoom><offset x=\"0\" y=\"0\" /><scale>1</scale></zoom><grid />' +\n '</settings>' +\n '<node id=\"node_1\" label=\"label_1\" status=\"1\"><position x=\"20\" y=\"100\" /></node>' +\n '<label id=\"label_1\" fontSize=\"12\" isReadOnly=\"true\" status=\"1\">' +\n '<position x=\"33\" y=\"140\" /><text>Node 1</text></label>' +\n '</pfdn:diagram>';\n\nexport type EditorOptions = InteractiveViewerOptions;\n\nexport class Editor extends InteractiveViewer {\n /** Editing modules on top of the interaction layer. */\n static readonly editionModules: readonly DiagramModule[] = [\n dragModule as DiagramModule,\n modellingModule as DiagramModule,\n exportingModule as DiagramModule,\n localStorageModule as DiagramModule,\n uploadModule as DiagramModule,\n paletteModule as DiagramModule,\n resizeElementModule as DiagramModule,\n // the properties panel (registers a side tab; side-tabs + search-panel are\n // inherited from InteractiveViewer)\n entryFactoryModule as DiagramModule,\n pfdnPropertiesProviderModule as DiagramModule,\n propertiesPanelModule as DiagramModule\n ];\n\n /** The document a fresh editor opens with (used by {@link createDiagram}). */\n initialDiagram = INITIAL_DIAGRAM;\n\n /** (Re)open the initial diagram. */\n createDiagram(): Promise<void> {\n return this.importDiagram(this.initialDiagram);\n }\n\n getModules(): readonly DiagramModule[] {\n // interaction + editing features first (they subscribe / swap the layer),\n // then the drawers\n return [\n ...InteractiveViewer.interactionModules,\n ...Editor.editionModules,\n ...Viewer.modules\n ];\n }\n\n /** Create a node (and its associated label) at an optional position. */\n createNode(parameters: CreateParameters = {}): ModellingModelElement {\n return this.get<ModellingNodes>('modellingNodes').create(parameters);\n }\n\n /** Select an element by definition (e.g. to prepare a delete). */\n select(definition: ModellingModelElement): void {\n const element = this.get<DrawingRegistry>('drawingRegistry').get(definition.id as string);\n if (element) {\n this.get<Selection>('selection').select(element, definition);\n }\n }\n\n /** Delete the current selection (cascading to associated labels). */\n deleteSelected(): void {\n this.get<Selection>('selection').deleteSelected();\n }\n}\n\nexport default Editor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,gCAAiE;AACjE,oBAAuB;AACvB,kBAcO;AACP,8BAIO;AAGP,IAAM,kBACJ;AAYK,IAAM,UAAN,MAAM,gBAAe,4CAAkB;AAAA,EAAvC;AAAA;AAkBL;AAAA,0BAAiB;AAAA;AAAA;AAAA,EAGjB,gBAA+B;AAC7B,WAAO,KAAK,cAAc,KAAK,cAAc;AAAA,EAC/C;AAAA,EAEA,aAAuC;AAGrC,WAAO;AAAA,MACL,GAAG,4CAAkB;AAAA,MACrB,GAAG,QAAO;AAAA,MACV,GAAG,qBAAO;AAAA,IACZ;AAAA,EACF;AAAA;AAAA,EAGA,WAAW,aAA+B,CAAC,GAA0B;AACnE,WAAO,KAAK,IAAoB,gBAAgB,EAAE,OAAO,UAAU;AAAA,EACrE;AAAA;AAAA,EAGA,OAAO,YAAyC;AAC9C,UAAM,UAAU,KAAK,IAAqB,iBAAiB,EAAE,IAAI,WAAW,EAAY;AACxF,QAAI,SAAS;AACX,WAAK,IAAe,WAAW,EAAE,OAAO,SAAS,UAAU;AAAA,IAC7D;AAAA,EACF;AAAA;AAAA,EAGA,iBAAuB;AACrB,SAAK,IAAe,WAAW,EAAE,eAAe;AAAA,EAClD;AACF;AAAA;AApDa,QAEK,iBAA2C;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AACF;AAfK,IAAM,SAAN;AAsDP,IAAO,gBAAQ;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { InteractiveViewer, InteractiveViewerOptions } from '@d3-polytree/interactive-viewer';
2
+ import { DiagramModule, CreateParameters, ModellingModelElement } from '@d3-polytree/core';
3
+
4
+ /**
5
+ * @d3-polytree/editor — create and modify polytree diagrams.
6
+ *
7
+ * Extends the {@link InteractiveViewer} with the editing layer: element
8
+ * dragging plus the modelling create/save/delete flows. Element creation is
9
+ * exposed programmatically here; the palette toolbar UI is layered on next.
10
+ */
11
+
12
+ type EditorOptions = InteractiveViewerOptions;
13
+ declare class Editor extends InteractiveViewer {
14
+ /** Editing modules on top of the interaction layer. */
15
+ static readonly editionModules: readonly DiagramModule[];
16
+ /** The document a fresh editor opens with (used by {@link createDiagram}). */
17
+ initialDiagram: string;
18
+ /** (Re)open the initial diagram. */
19
+ createDiagram(): Promise<void>;
20
+ getModules(): readonly DiagramModule[];
21
+ /** Create a node (and its associated label) at an optional position. */
22
+ createNode(parameters?: CreateParameters): ModellingModelElement;
23
+ /** Select an element by definition (e.g. to prepare a delete). */
24
+ select(definition: ModellingModelElement): void;
25
+ /** Delete the current selection (cascading to associated labels). */
26
+ deleteSelected(): void;
27
+ }
28
+
29
+ export { Editor, type EditorOptions, Editor as default };
@@ -0,0 +1,29 @@
1
+ import { InteractiveViewer, InteractiveViewerOptions } from '@d3-polytree/interactive-viewer';
2
+ import { DiagramModule, CreateParameters, ModellingModelElement } from '@d3-polytree/core';
3
+
4
+ /**
5
+ * @d3-polytree/editor — create and modify polytree diagrams.
6
+ *
7
+ * Extends the {@link InteractiveViewer} with the editing layer: element
8
+ * dragging plus the modelling create/save/delete flows. Element creation is
9
+ * exposed programmatically here; the palette toolbar UI is layered on next.
10
+ */
11
+
12
+ type EditorOptions = InteractiveViewerOptions;
13
+ declare class Editor extends InteractiveViewer {
14
+ /** Editing modules on top of the interaction layer. */
15
+ static readonly editionModules: readonly DiagramModule[];
16
+ /** The document a fresh editor opens with (used by {@link createDiagram}). */
17
+ initialDiagram: string;
18
+ /** (Re)open the initial diagram. */
19
+ createDiagram(): Promise<void>;
20
+ getModules(): readonly DiagramModule[];
21
+ /** Create a node (and its associated label) at an optional position. */
22
+ createNode(parameters?: CreateParameters): ModellingModelElement;
23
+ /** Select an element by definition (e.g. to prepare a delete). */
24
+ select(definition: ModellingModelElement): void;
25
+ /** Delete the current selection (cascading to associated labels). */
26
+ deleteSelected(): void;
27
+ }
28
+
29
+ export { Editor, type EditorOptions, Editor as default };
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ // src/index.ts
2
+ import { InteractiveViewer } from "@d3-polytree/interactive-viewer";
3
+ import { Viewer } from "@d3-polytree/viewer";
4
+ import {
5
+ dragModule,
6
+ modellingModule,
7
+ exportingModule,
8
+ localStorageModule,
9
+ uploadModule,
10
+ paletteModule,
11
+ resizeElementModule
12
+ } from "@d3-polytree/core";
13
+ import {
14
+ entryFactoryModule,
15
+ pfdnPropertiesProviderModule,
16
+ propertiesPanelModule
17
+ } from "@d3-polytree/properties-panel";
18
+ var INITIAL_DIAGRAM = '<?xml version="1.0" encoding="UTF-8"?><pfdn:diagram xmlns:pfdn="http://pfdn" xmlns="http://pfdn"><settings author="No Author" name="No Name Diagram" status="1"><zoom><offset x="0" y="0" /><scale>1</scale></zoom><grid /></settings><node id="node_1" label="label_1" status="1"><position x="20" y="100" /></node><label id="label_1" fontSize="12" isReadOnly="true" status="1"><position x="33" y="140" /><text>Node 1</text></label></pfdn:diagram>';
19
+ var _Editor = class _Editor extends InteractiveViewer {
20
+ constructor() {
21
+ super(...arguments);
22
+ /** The document a fresh editor opens with (used by {@link createDiagram}). */
23
+ this.initialDiagram = INITIAL_DIAGRAM;
24
+ }
25
+ /** (Re)open the initial diagram. */
26
+ createDiagram() {
27
+ return this.importDiagram(this.initialDiagram);
28
+ }
29
+ getModules() {
30
+ return [
31
+ ...InteractiveViewer.interactionModules,
32
+ ..._Editor.editionModules,
33
+ ...Viewer.modules
34
+ ];
35
+ }
36
+ /** Create a node (and its associated label) at an optional position. */
37
+ createNode(parameters = {}) {
38
+ return this.get("modellingNodes").create(parameters);
39
+ }
40
+ /** Select an element by definition (e.g. to prepare a delete). */
41
+ select(definition) {
42
+ const element = this.get("drawingRegistry").get(definition.id);
43
+ if (element) {
44
+ this.get("selection").select(element, definition);
45
+ }
46
+ }
47
+ /** Delete the current selection (cascading to associated labels). */
48
+ deleteSelected() {
49
+ this.get("selection").deleteSelected();
50
+ }
51
+ };
52
+ /** Editing modules on top of the interaction layer. */
53
+ _Editor.editionModules = [
54
+ dragModule,
55
+ modellingModule,
56
+ exportingModule,
57
+ localStorageModule,
58
+ uploadModule,
59
+ paletteModule,
60
+ resizeElementModule,
61
+ // the properties panel (registers a side tab; side-tabs + search-panel are
62
+ // inherited from InteractiveViewer)
63
+ entryFactoryModule,
64
+ pfdnPropertiesProviderModule,
65
+ propertiesPanelModule
66
+ ];
67
+ var Editor = _Editor;
68
+ var index_default = Editor;
69
+ export {
70
+ Editor,
71
+ index_default as default
72
+ };
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @d3-polytree/editor — create and modify polytree diagrams.\n *\n * Extends the {@link InteractiveViewer} with the editing layer: element\n * dragging plus the modelling create/save/delete flows. Element creation is\n * exposed programmatically here; the palette toolbar UI is layered on next.\n */\nimport { InteractiveViewer, type InteractiveViewerOptions } from '@d3-polytree/interactive-viewer';\nimport { Viewer } from '@d3-polytree/viewer';\nimport {\n dragModule,\n modellingModule,\n exportingModule,\n localStorageModule,\n uploadModule,\n paletteModule,\n resizeElementModule,\n type DiagramModule,\n type DrawingRegistry,\n type ModellingNodes,\n type ModellingModelElement,\n type CreateParameters,\n type Selection\n} from '@d3-polytree/core';\nimport {\n entryFactoryModule,\n pfdnPropertiesProviderModule,\n propertiesPanelModule\n} from '@d3-polytree/properties-panel';\n\n/** The document a fresh editor opens with. */\nconst INITIAL_DIAGRAM =\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' +\n '<pfdn:diagram xmlns:pfdn=\"http://pfdn\" xmlns=\"http://pfdn\">' +\n '<settings author=\"No Author\" name=\"No Name Diagram\" status=\"1\">' +\n '<zoom><offset x=\"0\" y=\"0\" /><scale>1</scale></zoom><grid />' +\n '</settings>' +\n '<node id=\"node_1\" label=\"label_1\" status=\"1\"><position x=\"20\" y=\"100\" /></node>' +\n '<label id=\"label_1\" fontSize=\"12\" isReadOnly=\"true\" status=\"1\">' +\n '<position x=\"33\" y=\"140\" /><text>Node 1</text></label>' +\n '</pfdn:diagram>';\n\nexport type EditorOptions = InteractiveViewerOptions;\n\nexport class Editor extends InteractiveViewer {\n /** Editing modules on top of the interaction layer. */\n static readonly editionModules: readonly DiagramModule[] = [\n dragModule as DiagramModule,\n modellingModule as DiagramModule,\n exportingModule as DiagramModule,\n localStorageModule as DiagramModule,\n uploadModule as DiagramModule,\n paletteModule as DiagramModule,\n resizeElementModule as DiagramModule,\n // the properties panel (registers a side tab; side-tabs + search-panel are\n // inherited from InteractiveViewer)\n entryFactoryModule as DiagramModule,\n pfdnPropertiesProviderModule as DiagramModule,\n propertiesPanelModule as DiagramModule\n ];\n\n /** The document a fresh editor opens with (used by {@link createDiagram}). */\n initialDiagram = INITIAL_DIAGRAM;\n\n /** (Re)open the initial diagram. */\n createDiagram(): Promise<void> {\n return this.importDiagram(this.initialDiagram);\n }\n\n getModules(): readonly DiagramModule[] {\n // interaction + editing features first (they subscribe / swap the layer),\n // then the drawers\n return [\n ...InteractiveViewer.interactionModules,\n ...Editor.editionModules,\n ...Viewer.modules\n ];\n }\n\n /** Create a node (and its associated label) at an optional position. */\n createNode(parameters: CreateParameters = {}): ModellingModelElement {\n return this.get<ModellingNodes>('modellingNodes').create(parameters);\n }\n\n /** Select an element by definition (e.g. to prepare a delete). */\n select(definition: ModellingModelElement): void {\n const element = this.get<DrawingRegistry>('drawingRegistry').get(definition.id as string);\n if (element) {\n this.get<Selection>('selection').select(element, definition);\n }\n }\n\n /** Delete the current selection (cascading to associated labels). */\n deleteSelected(): void {\n this.get<Selection>('selection').deleteSelected();\n }\n}\n\nexport default Editor;\n"],"mappings":";AAOA,SAAS,yBAAwD;AACjE,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,IAAM,kBACJ;AAYK,IAAM,UAAN,MAAM,gBAAe,kBAAkB;AAAA,EAAvC;AAAA;AAkBL;AAAA,0BAAiB;AAAA;AAAA;AAAA,EAGjB,gBAA+B;AAC7B,WAAO,KAAK,cAAc,KAAK,cAAc;AAAA,EAC/C;AAAA,EAEA,aAAuC;AAGrC,WAAO;AAAA,MACL,GAAG,kBAAkB;AAAA,MACrB,GAAG,QAAO;AAAA,MACV,GAAG,OAAO;AAAA,IACZ;AAAA,EACF;AAAA;AAAA,EAGA,WAAW,aAA+B,CAAC,GAA0B;AACnE,WAAO,KAAK,IAAoB,gBAAgB,EAAE,OAAO,UAAU;AAAA,EACrE;AAAA;AAAA,EAGA,OAAO,YAAyC;AAC9C,UAAM,UAAU,KAAK,IAAqB,iBAAiB,EAAE,IAAI,WAAW,EAAY;AACxF,QAAI,SAAS;AACX,WAAK,IAAe,WAAW,EAAE,OAAO,SAAS,UAAU;AAAA,IAC7D;AAAA,EACF;AAAA;AAAA,EAGA,iBAAuB;AACrB,SAAK,IAAe,WAAW,EAAE,eAAe;AAAA,EAClD;AACF;AAAA;AApDa,QAEK,iBAA2C;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AACF;AAfK,IAAM,SAAN;AAsDP,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@d3-polytree/editor",
3
+ "version": "0.1.0",
4
+ "description": "Polytree editor (create and modify diagrams)",
5
+ "license": "MIT",
6
+ "author": "David Castillo",
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ },
17
+ "./umd": "./dist/editor.umd.js"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "sideEffects": false,
23
+ "dependencies": {
24
+ "@d3-polytree/viewer": "0.1.0",
25
+ "@d3-polytree/core": "0.1.0",
26
+ "@d3-polytree/interactive-viewer": "0.1.0",
27
+ "@d3-polytree/properties-panel": "0.1.0"
28
+ },
29
+ "unpkg": "./dist/editor.umd.js",
30
+ "jsdelivr": "./dist/editor.umd.js",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/davcs86/d3-polytree.git",
34
+ "directory": "packages/editor"
35
+ },
36
+ "homepage": "https://github.com/davcs86/d3-polytree/tree/v2/packages/editor#readme",
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run"
44
+ }
45
+ }