graphwise-reactodia 0.0.1-TR2 → 0.0.1-TR20
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/COPYING +674 -0
- package/COPYING.LESSER +165 -0
- package/NOTICE +41 -0
- package/README.md +225 -1
- package/dist/cjs/graphwise-reactodia.cjs.entry.js +28519 -41232
- package/dist/cjs/graphwise-reactodia.cjs.js +2 -2
- package/dist/cjs/{index-CII9aUQC.js → index-DtzCybH4.js} +16 -0
- package/dist/cjs/index.cjs.js +29 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/node-action-DkJ5ct17.js +96 -0
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.css +57 -1
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +135 -40
- package/dist/collection/components/graphwise-reactodia/i18n/language-key.js +5 -0
- package/dist/collection/components/graphwise-reactodia/i18n/translations.js +6 -1
- package/dist/collection/components/graphwise-reactodia/menu/export-diagram-action.js +19 -0
- package/dist/collection/components/graphwise-reactodia/menu/graphwise-menu.js +24 -0
- package/dist/collection/components/graphwise-reactodia/menu/import-diagram-action.js +31 -0
- package/dist/collection/components/graphwise-reactodia/models/clear-diagram-storage-event.js +5 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-cause.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-code.js +20 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-report.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-callback.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-detail.js +4 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-type.js +8 -0
- package/dist/collection/components/graphwise-reactodia/models/reactodia-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/sparql/sparql-query-function.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/sparql/sparql-query-params.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/subscription-list.js +35 -0
- package/dist/collection/components/graphwise-reactodia/models/subscription.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/triple.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/menu-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/menu-item.js +18 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/node-action.js +22 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/resolved-toolbar-position.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/resolved-ui-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/toolbar-dock.js +14 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/toolbar-position.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/ui-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/node-action/node-actions.js +22 -0
- package/dist/collection/components/graphwise-reactodia/providers/service/service-inject.js +15 -0
- package/dist/collection/components/graphwise-reactodia/providers/service/service.js +19 -0
- package/dist/collection/components/graphwise-reactodia/providers/service/service.provider.js +20 -0
- package/dist/collection/components/graphwise-reactodia/reactodia-app.js +188 -26
- package/dist/collection/components/graphwise-reactodia/services/diagram/diagram.service.js +71 -0
- package/dist/collection/components/graphwise-reactodia/services/diagram-file/diagram-file.service.js +68 -0
- package/dist/collection/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.js +71 -0
- package/dist/collection/components/graphwise-reactodia/services/error/error.service.js +78 -0
- package/dist/collection/components/graphwise-reactodia/services/event/event.service.js +58 -0
- package/dist/collection/components/graphwise-reactodia/services/window/window.service.js +24 -0
- package/dist/collection/components/graphwise-reactodia/styles/type-style.resolver.js +52 -0
- package/dist/collection/components/graphwise-reactodia/testing/storage.mock.js +35 -0
- package/dist/collection/components/graphwise-reactodia/ui-config/default-ui-config.js +30 -0
- package/dist/collection/components/graphwise-reactodia/ui-config/ui-config-mapper.js +51 -0
- package/dist/collection/components/graphwise-reactodia/utils/object-util.js +30 -0
- package/dist/collection/index.js +7 -1
- package/dist/collection/pages/graphwise-reactodia/main.js +157 -0
- package/dist/collection/pages/graphwise-reactodia/owl-rdfs-settings.js +195 -0
- package/dist/esm/graphwise-reactodia.entry.js +28519 -41232
- package/dist/esm/graphwise-reactodia.js +3 -3
- package/dist/esm/{index-Cypw7ydc.js → index-DpCR6zMg.js} +16 -1
- package/dist/esm/index.js +7 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/node-action-fwJ3Zupw.js +94 -0
- package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
- package/dist/graphwise-reactodia/index.esm.js +1 -0
- package/dist/graphwise-reactodia/p-DpCR6zMg.js +2 -0
- package/dist/graphwise-reactodia/p-c3d8a69a.entry.js +1 -0
- package/dist/graphwise-reactodia/p-fwJ3Zupw.js +1 -0
- package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +44 -16
- package/dist/types/components/graphwise-reactodia/i18n/language-key.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/i18n/translations.d.ts +2 -343
- package/dist/types/components/graphwise-reactodia/menu/export-diagram-action.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/menu/graphwise-menu.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/menu/import-diagram-action.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/models/clear-diagram-storage-event.d.ts +5 -0
- package/dist/types/components/graphwise-reactodia/models/error/error-cause.d.ts +10 -0
- package/dist/types/components/graphwise-reactodia/models/error/error-code.d.ts +19 -0
- package/dist/types/components/graphwise-reactodia/models/error/error-report.d.ts +13 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-callback.d.ts +5 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-detail.d.ts +55 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-type.d.ts +7 -0
- package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +20 -15
- package/dist/types/components/graphwise-reactodia/models/reactodia-config.d.ts +36 -0
- package/dist/types/components/graphwise-reactodia/models/sparql/sparql-query-function.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/models/sparql/sparql-query-params.d.ts +12 -0
- package/dist/types/components/graphwise-reactodia/models/subscription-list.d.ts +26 -0
- package/dist/types/components/graphwise-reactodia/models/subscription.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/models/triple.d.ts +19 -0
- package/dist/types/components/graphwise-reactodia/models/ui/menu-config.d.ts +8 -0
- package/dist/types/components/graphwise-reactodia/models/ui/menu-item.d.ts +17 -0
- package/dist/types/components/graphwise-reactodia/models/ui/node-action.d.ts +21 -0
- package/dist/types/components/graphwise-reactodia/models/ui/resolved-toolbar-position.d.ts +8 -0
- package/dist/types/components/graphwise-reactodia/models/ui/resolved-ui-config.d.ts +12 -0
- package/dist/types/components/graphwise-reactodia/models/ui/toolbar-dock.d.ts +13 -0
- package/dist/types/components/graphwise-reactodia/models/ui/toolbar-position.d.ts +11 -0
- package/dist/types/components/graphwise-reactodia/models/ui/ui-config.d.ts +17 -0
- package/dist/types/components/graphwise-reactodia/node-action/node-actions.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/providers/service/service-inject.d.ts +13 -0
- package/dist/types/components/graphwise-reactodia/providers/service/service.d.ts +28 -0
- package/dist/types/components/graphwise-reactodia/providers/service/service.provider.d.ts +16 -0
- package/dist/types/components/graphwise-reactodia/reactodia-app.d.ts +3 -2
- package/dist/types/components/graphwise-reactodia/services/diagram/diagram.service.d.ts +36 -0
- package/dist/types/components/graphwise-reactodia/services/diagram-file/diagram-file.service.d.ts +24 -0
- package/dist/types/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.d.ts +27 -0
- package/dist/types/components/graphwise-reactodia/services/error/error.service.d.ts +41 -0
- package/dist/types/components/graphwise-reactodia/services/event/event.service.d.ts +30 -0
- package/dist/types/components/graphwise-reactodia/services/window/window.service.d.ts +7 -0
- package/dist/types/components/graphwise-reactodia/styles/type-style.resolver.d.ts +11 -0
- package/dist/types/components/graphwise-reactodia/testing/storage.mock.d.ts +18 -0
- package/dist/types/components/graphwise-reactodia/ui-config/default-ui-config.d.ts +5 -0
- package/dist/types/components/graphwise-reactodia/ui-config/ui-config-mapper.d.ts +14 -0
- package/dist/types/components/graphwise-reactodia/utils/object-util.d.ts +15 -0
- package/dist/types/components.d.ts +60 -27
- package/dist/types/index.d.ts +15 -1
- package/package.json +39 -10
- package/dist/graphwise-reactodia/p-Cypw7ydc.js +0 -2
- package/dist/graphwise-reactodia/p-bafd6be5.entry.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-DtzCybH4.js');
|
|
4
4
|
var appGlobals = require('./app-globals-CcJr5lkF.js');
|
|
5
5
|
|
|
6
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"
|
|
22
|
+
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"],"theme":[1]},null,{"currentRepository":["onCurrentRepositoryChange"],"language":["onLanguageOrSettingsChange"],"providerSettings":["onLanguageOrSettingsChange"],"theme":["onThemeChange"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -289,6 +289,21 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
289
289
|
return propValue;
|
|
290
290
|
};
|
|
291
291
|
var getElement = (ref) => getHostRef(ref).$hostElement$ ;
|
|
292
|
+
|
|
293
|
+
// src/runtime/event-emitter.ts
|
|
294
|
+
var createEvent = (ref, name, flags) => {
|
|
295
|
+
const elm = getElement(ref);
|
|
296
|
+
return {
|
|
297
|
+
emit: (detail) => {
|
|
298
|
+
return emitEvent(elm, name, {
|
|
299
|
+
bubbles: true,
|
|
300
|
+
composed: true,
|
|
301
|
+
cancelable: true,
|
|
302
|
+
detail
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
};
|
|
292
307
|
var emitEvent = (elm, name, opts) => {
|
|
293
308
|
const ev = plt.ce(name, opts);
|
|
294
309
|
elm.dispatchEvent(ev);
|
|
@@ -1205,6 +1220,7 @@ var setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
|
1205
1220
|
|
|
1206
1221
|
exports.Host = Host;
|
|
1207
1222
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1223
|
+
exports.createEvent = createEvent;
|
|
1208
1224
|
exports.getElement = getElement;
|
|
1209
1225
|
exports.h = h;
|
|
1210
1226
|
exports.promiseResolve = promiseResolve;
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var nodeAction = require('./node-action-DkJ5ct17.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Name of the DOM event the `graphwise-reactodia` element dispatches for every event.
|
|
7
|
+
*/
|
|
8
|
+
const GRAPHWISE_REACTODIA_EVENT = 'graphwiseReactodiaEvent';
|
|
9
|
+
|
|
10
|
+
exports.CLEAR_DIAGRAM_STORAGE_EVENT = nodeAction.CLEAR_DIAGRAM_STORAGE_EVENT;
|
|
11
|
+
Object.defineProperty(exports, "ErrorCode", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return nodeAction.ErrorCode; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "EventType", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return nodeAction.EventType; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "MenuItem", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return nodeAction.MenuItem; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "NodeAction", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return nodeAction.NodeAction; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "ToolbarDock", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return nodeAction.ToolbarDock; }
|
|
30
|
+
});
|
|
31
|
+
exports.GRAPHWISE_REACTODIA_EVENT = GRAPHWISE_REACTODIA_EVENT;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-DtzCybH4.js');
|
|
4
4
|
var appGlobals = require('./app-globals-CcJr5lkF.js');
|
|
5
5
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"
|
|
9
|
+
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"],"theme":[1]},null,{"currentRepository":["onCurrentRepositoryChange"],"language":["onLanguageOrSettingsChange"],"providerSettings":["onLanguageOrSettingsChange"],"theme":["onThemeChange"]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event name for clearing the local store state of the diagram. There is an event listener listening for it, which
|
|
5
|
+
* will clear the local store state, whenever this event is fired.
|
|
6
|
+
*/
|
|
7
|
+
const CLEAR_DIAGRAM_STORAGE_EVENT = 'graphwise-reactodia:clear-diagram-storage';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The kind of event the wrapper announces to the host. It selects the payload of an {@link EventDetail}.
|
|
11
|
+
*/
|
|
12
|
+
exports.EventType = void 0;
|
|
13
|
+
(function (EventType) {
|
|
14
|
+
EventType["ERROR"] = "error";
|
|
15
|
+
EventType["TEXT_SEARCH"] = "text-search";
|
|
16
|
+
})(exports.EventType || (exports.EventType = {}));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The stable category of a reported error. The host uses it to choose its own message.
|
|
20
|
+
*/
|
|
21
|
+
exports.ErrorCode = void 0;
|
|
22
|
+
(function (ErrorCode) {
|
|
23
|
+
/** A required prop is missing. */
|
|
24
|
+
ErrorCode["MISSING_REQUIRED_PROP"] = "missing-required-prop";
|
|
25
|
+
/** A SPARQL data provider call failed. */
|
|
26
|
+
ErrorCode["DATA_FETCH"] = "data-fetch";
|
|
27
|
+
/** The startup load, a reload or a repository switch failed. */
|
|
28
|
+
ErrorCode["DIAGRAM_LOAD"] = "diagram-load";
|
|
29
|
+
/** The uploaded file was rejected or its import failed. */
|
|
30
|
+
ErrorCode["DIAGRAM_IMPORT"] = "diagram-import";
|
|
31
|
+
/** Reading the diagram from local storage failed. */
|
|
32
|
+
ErrorCode["LOCAL_DIAGRAM_READ"] = "local-diagram-read";
|
|
33
|
+
/** Saving the diagram in local storage failed. */
|
|
34
|
+
ErrorCode["LOCAL_DIAGRAM_SAVE"] = "local-diagram-save";
|
|
35
|
+
/** The host's UI configuration has an unknown value, which is skipped. */
|
|
36
|
+
ErrorCode["UNKNOWN_UI_CONFIG"] = "unknown-ui-config";
|
|
37
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The side or corner of the canvas a toolbar is docked to.
|
|
41
|
+
*/
|
|
42
|
+
exports.ToolbarDock = void 0;
|
|
43
|
+
(function (ToolbarDock) {
|
|
44
|
+
ToolbarDock["NW"] = "nw";
|
|
45
|
+
ToolbarDock["N"] = "n";
|
|
46
|
+
ToolbarDock["NE"] = "ne";
|
|
47
|
+
ToolbarDock["E"] = "e";
|
|
48
|
+
ToolbarDock["SE"] = "se";
|
|
49
|
+
ToolbarDock["S"] = "s";
|
|
50
|
+
ToolbarDock["SW"] = "sw";
|
|
51
|
+
ToolbarDock["W"] = "w";
|
|
52
|
+
})(exports.ToolbarDock || (exports.ToolbarDock = {}));
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* An entry of the workspace main menu.
|
|
56
|
+
*/
|
|
57
|
+
exports.MenuItem = void 0;
|
|
58
|
+
(function (MenuItem) {
|
|
59
|
+
/** Removes all nodes from the diagram. */
|
|
60
|
+
MenuItem["CLEAR_ALL"] = "clear-all";
|
|
61
|
+
/** Exports the diagram as a PNG image. */
|
|
62
|
+
MenuItem["EXPORT_PNG"] = "export-png";
|
|
63
|
+
/** Exports the diagram as an SVG image. */
|
|
64
|
+
MenuItem["EXPORT_SVG"] = "export-svg";
|
|
65
|
+
/** Prints the diagram. */
|
|
66
|
+
MenuItem["PRINT"] = "print";
|
|
67
|
+
/** Exports the diagram as a JSON file. */
|
|
68
|
+
MenuItem["EXPORT_JSON"] = "export-json";
|
|
69
|
+
/** Imports a diagram from a JSON file. */
|
|
70
|
+
MenuItem["IMPORT_JSON"] = "import-json";
|
|
71
|
+
})(exports.MenuItem || (exports.MenuItem = {}));
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A button shown around a selected node that acts on it.
|
|
75
|
+
*/
|
|
76
|
+
exports.NodeAction = void 0;
|
|
77
|
+
(function (NodeAction) {
|
|
78
|
+
/** Groups or ungroups the selected nodes. */
|
|
79
|
+
NodeAction["GROUP"] = "group";
|
|
80
|
+
/** Removes the node from the diagram. */
|
|
81
|
+
NodeAction["REMOVE"] = "remove";
|
|
82
|
+
/** Expands or collapses the node to show its properties. */
|
|
83
|
+
NodeAction["EXPAND"] = "expand";
|
|
84
|
+
/** Opens the node IRI. */
|
|
85
|
+
NodeAction["OPEN_LINK"] = "open-link";
|
|
86
|
+
/** Opens the menu to navigate to connected nodes. */
|
|
87
|
+
NodeAction["CONNECTIONS"] = "connections";
|
|
88
|
+
/** Searches for nodes connected to this one. */
|
|
89
|
+
NodeAction["ADD_TO_FILTER"] = "add-to-filter";
|
|
90
|
+
/** Adds an annotation to the node. */
|
|
91
|
+
NodeAction["ANNOTATE"] = "annotate";
|
|
92
|
+
/** Draws a new link from the node; for an entity, only in authoring mode. */
|
|
93
|
+
NodeAction["ESTABLISH_LINK"] = "establish-link";
|
|
94
|
+
})(exports.NodeAction || (exports.NodeAction = {}));
|
|
95
|
+
|
|
96
|
+
exports.CLEAR_DIAGRAM_STORAGE_EVENT = CLEAR_DIAGRAM_STORAGE_EVENT;
|
|
@@ -1,10 +1,66 @@
|
|
|
1
|
+
graphwise-reactodia {
|
|
2
|
+
/** @prop --graphwise-reactodia-type-color-01: Color slot 1 of 20 for node types */
|
|
3
|
+
--_graphwise-reactodia-type-color-01: var(--graphwise-reactodia-type-color-01);
|
|
4
|
+
/** @prop --graphwise-reactodia-type-color-02: Color slot 2 of 20 for node types */
|
|
5
|
+
--_graphwise-reactodia-type-color-02: var(--graphwise-reactodia-type-color-02);
|
|
6
|
+
/** @prop --graphwise-reactodia-type-color-03: Color slot 3 of 20 for node types */
|
|
7
|
+
--_graphwise-reactodia-type-color-03: var(--graphwise-reactodia-type-color-03);
|
|
8
|
+
/** @prop --graphwise-reactodia-type-color-04: Color slot 4 of 20 for node types */
|
|
9
|
+
--_graphwise-reactodia-type-color-04: var(--graphwise-reactodia-type-color-04);
|
|
10
|
+
/** @prop --graphwise-reactodia-type-color-05: Color slot 5 of 20 for node types */
|
|
11
|
+
--_graphwise-reactodia-type-color-05: var(--graphwise-reactodia-type-color-05);
|
|
12
|
+
/** @prop --graphwise-reactodia-type-color-06: Color slot 6 of 20 for node types */
|
|
13
|
+
--_graphwise-reactodia-type-color-06: var(--graphwise-reactodia-type-color-06);
|
|
14
|
+
/** @prop --graphwise-reactodia-type-color-07: Color slot 7 of 20 for node types */
|
|
15
|
+
--_graphwise-reactodia-type-color-07: var(--graphwise-reactodia-type-color-07);
|
|
16
|
+
/** @prop --graphwise-reactodia-type-color-08: Color slot 8 of 20 for node types */
|
|
17
|
+
--_graphwise-reactodia-type-color-08: var(--graphwise-reactodia-type-color-08);
|
|
18
|
+
/** @prop --graphwise-reactodia-type-color-09: Color slot 9 of 20 for node types */
|
|
19
|
+
--_graphwise-reactodia-type-color-09: var(--graphwise-reactodia-type-color-09);
|
|
20
|
+
/** @prop --graphwise-reactodia-type-color-10: Color slot 10 of 20 for node types */
|
|
21
|
+
--_graphwise-reactodia-type-color-10: var(--graphwise-reactodia-type-color-10);
|
|
22
|
+
/** @prop --graphwise-reactodia-type-color-11: Color slot 11 of 20 for node types */
|
|
23
|
+
--_graphwise-reactodia-type-color-11: var(--graphwise-reactodia-type-color-11);
|
|
24
|
+
/** @prop --graphwise-reactodia-type-color-12: Color slot 12 of 20 for node types */
|
|
25
|
+
--_graphwise-reactodia-type-color-12: var(--graphwise-reactodia-type-color-12);
|
|
26
|
+
/** @prop --graphwise-reactodia-type-color-13: Color slot 13 of 20 for node types */
|
|
27
|
+
--_graphwise-reactodia-type-color-13: var(--graphwise-reactodia-type-color-13);
|
|
28
|
+
/** @prop --graphwise-reactodia-type-color-14: Color slot 14 of 20 for node types */
|
|
29
|
+
--_graphwise-reactodia-type-color-14: var(--graphwise-reactodia-type-color-14);
|
|
30
|
+
/** @prop --graphwise-reactodia-type-color-15: Color slot 15 of 20 for node types */
|
|
31
|
+
--_graphwise-reactodia-type-color-15: var(--graphwise-reactodia-type-color-15);
|
|
32
|
+
/** @prop --graphwise-reactodia-type-color-16: Color slot 16 of 20 for node types */
|
|
33
|
+
--_graphwise-reactodia-type-color-16: var(--graphwise-reactodia-type-color-16);
|
|
34
|
+
/** @prop --graphwise-reactodia-type-color-17: Color slot 17 of 20 for node types */
|
|
35
|
+
--_graphwise-reactodia-type-color-17: var(--graphwise-reactodia-type-color-17);
|
|
36
|
+
/** @prop --graphwise-reactodia-type-color-18: Color slot 18 of 20 for node types */
|
|
37
|
+
--_graphwise-reactodia-type-color-18: var(--graphwise-reactodia-type-color-18);
|
|
38
|
+
/** @prop --graphwise-reactodia-type-color-19: Color slot 19 of 20 for node types */
|
|
39
|
+
--_graphwise-reactodia-type-color-19: var(--graphwise-reactodia-type-color-19);
|
|
40
|
+
/** @prop --graphwise-reactodia-type-color-20: Color slot 20 of 20 for node types */
|
|
41
|
+
--_graphwise-reactodia-type-color-20: var(--graphwise-reactodia-type-color-20);
|
|
42
|
+
/** @prop --graphwise-reactodia-type-color-contrast: Contrast color for categorical node styles (the letter inside the circle) */
|
|
43
|
+
--_graphwise-reactodia-type-color-contrast: var(--graphwise-reactodia-type-color-contrast, #fff);
|
|
44
|
+
}
|
|
45
|
+
|
|
1
46
|
graphwise-reactodia {
|
|
2
47
|
display: block;
|
|
3
48
|
width: 100%;
|
|
4
|
-
height:
|
|
49
|
+
height: 100%;
|
|
5
50
|
}
|
|
6
51
|
graphwise-reactodia .reactodia-container {
|
|
7
52
|
position: relative;
|
|
8
53
|
width: 100%;
|
|
9
54
|
height: 100%;
|
|
55
|
+
}
|
|
56
|
+
graphwise-reactodia .reactodia-standard-element__thumbnail:not(:has(img)) {
|
|
57
|
+
background: var(--reactodia-element-style-color);
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
color: var(--_graphwise-reactodia-type-color-contrast);
|
|
60
|
+
}
|
|
61
|
+
graphwise-reactodia .reactodia-note-annotation {
|
|
62
|
+
overflow: auto;
|
|
63
|
+
}
|
|
64
|
+
graphwise-reactodia .reactodia-note-annotation__editor {
|
|
65
|
+
overflow-wrap: anywhere;
|
|
10
66
|
}
|
|
@@ -1,69 +1,112 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
|
-
import {
|
|
2
|
+
import { mountReactodia, unmountReactodia, updateReactodia } from "./reactodia-app";
|
|
3
|
+
import { LanguageKey } from "./i18n/language-key";
|
|
4
|
+
import { ErrorCode } from "./models/error/error-code";
|
|
5
|
+
import { SubscriptionList } from "./models/subscription-list";
|
|
6
|
+
import { service } from "./providers/service/service-inject";
|
|
7
|
+
import { ErrorService } from "./services/error/error.service";
|
|
8
|
+
import { EventService } from "./services/event/event.service";
|
|
9
|
+
import { resetColors } from "./styles/type-style.resolver";
|
|
10
|
+
const errorService = service(ErrorService);
|
|
11
|
+
const eventService = service(EventService);
|
|
3
12
|
/**
|
|
4
13
|
* A web component that renders a graph with the Reactodia workspace.
|
|
5
14
|
*
|
|
6
15
|
* The component is backed by a SPARQL endpoint but is endpoint-agnostic: the host passes
|
|
7
|
-
* the active repository's endpoint via `current-repository` and a `queryFunction`
|
|
8
|
-
* performs the actual HTTP request. Reactodia fetches all node, link and type data
|
|
9
|
-
* through them; the canvas starts empty and the user populates it via the search bar.
|
|
16
|
+
* the active repository's endpoint via `current-repository` and a `config.queryFunction`
|
|
17
|
+
* that performs the actual HTTP request. Reactodia fetches all node, link and type data
|
|
18
|
+
* lazily through them; the canvas starts empty and the user populates it via the search bar.
|
|
10
19
|
*
|
|
11
20
|
* The component is a thin wrapper around Reactodia: query configuration lives outside the
|
|
12
21
|
* wrapper and is supplied through the `providerSettings` prop.
|
|
13
22
|
*/
|
|
14
23
|
export class GraphwiseReactodia {
|
|
15
24
|
constructor() {
|
|
25
|
+
this.subscriptions = new SubscriptionList();
|
|
16
26
|
/**
|
|
17
27
|
* UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
|
|
18
28
|
*/
|
|
19
|
-
this.language =
|
|
29
|
+
this.language = LanguageKey.EN;
|
|
30
|
+
/**
|
|
31
|
+
* `connectedCallback` and the watchers can run before all props are set: when the component's
|
|
32
|
+
* code is already loaded, the instance is created as soon as the
|
|
33
|
+
* element is attached, and every prop set after that triggers its watcher. Rendering at that
|
|
34
|
+
* point would initialise the graph without all props. `componentDidLoad` runs once the initial
|
|
35
|
+
* props are set, so we use it to determine when it's safe to render.
|
|
36
|
+
*/
|
|
37
|
+
this.isComponentLoaded = false;
|
|
20
38
|
}
|
|
21
|
-
|
|
39
|
+
onCurrentRepositoryChange() {
|
|
22
40
|
this.renderGraph();
|
|
23
41
|
}
|
|
24
|
-
|
|
42
|
+
onLanguageOrSettingsChange() {
|
|
25
43
|
// The translations are evaluated by the workspace at construction, so the only way
|
|
26
|
-
// to re-translate the UI is to re-create the graph.
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
// to re-translate the UI is to re-create the graph.
|
|
45
|
+
// Setting changes should keep the current diagram despite possible
|
|
46
|
+
this.renderGraph(true);
|
|
47
|
+
}
|
|
48
|
+
onThemeChange() {
|
|
49
|
+
resetColors();
|
|
50
|
+
this.renderGraph(true);
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
this.subscribeToEvents();
|
|
54
|
+
this.renderGraph();
|
|
30
55
|
}
|
|
31
56
|
componentDidLoad() {
|
|
57
|
+
this.isComponentLoaded = true;
|
|
32
58
|
this.renderGraph();
|
|
33
59
|
}
|
|
34
60
|
disconnectedCallback() {
|
|
61
|
+
this.subscriptions.unsubscribeAll();
|
|
35
62
|
if (this.reactRoot) {
|
|
36
63
|
unmountReactodia(this.reactRoot);
|
|
37
64
|
this.reactRoot = undefined;
|
|
38
65
|
}
|
|
39
66
|
}
|
|
40
67
|
render() {
|
|
41
|
-
return (h(Host, { key: '
|
|
68
|
+
return (h(Host, { key: 'b5997ab551d1afe62b4a81166aca98a7d62f4e35' }));
|
|
69
|
+
}
|
|
70
|
+
subscribeToEvents() {
|
|
71
|
+
this.subscriptions.add(eventService.subscribe((detail) => this.eventEmitter.emit(detail)));
|
|
42
72
|
}
|
|
43
|
-
renderGraph(
|
|
73
|
+
renderGraph(isReloading) {
|
|
74
|
+
var _a;
|
|
75
|
+
if (!this.isComponentLoaded) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
44
78
|
if (!this.currentRepository) {
|
|
45
|
-
throw
|
|
79
|
+
throw this.reportMissingPropError('currentRepository is required');
|
|
80
|
+
}
|
|
81
|
+
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
|
|
82
|
+
throw this.reportMissingPropError('config.queryFunction is required');
|
|
46
83
|
}
|
|
47
|
-
if (!this.
|
|
48
|
-
throw
|
|
84
|
+
if (!this.providerSettings) {
|
|
85
|
+
throw this.reportMissingPropError('providerSettings is required');
|
|
49
86
|
}
|
|
50
87
|
if (!this.hostElement) {
|
|
51
88
|
return;
|
|
52
89
|
}
|
|
53
90
|
const props = {
|
|
54
|
-
|
|
91
|
+
isReload: isReloading,
|
|
55
92
|
currentRepository: this.currentRepository,
|
|
56
|
-
|
|
93
|
+
config: this.config,
|
|
57
94
|
language: this.language,
|
|
58
95
|
providerSettings: this.providerSettings,
|
|
96
|
+
theme: this.theme,
|
|
59
97
|
};
|
|
60
|
-
if (this.reactRoot && !
|
|
98
|
+
if (this.reactRoot && !isReloading) {
|
|
61
99
|
void updateReactodia(props);
|
|
62
100
|
}
|
|
63
101
|
else {
|
|
64
102
|
this.reactRoot = mountReactodia(this.hostElement, props);
|
|
65
103
|
}
|
|
66
104
|
}
|
|
105
|
+
reportMissingPropError(message) {
|
|
106
|
+
const error = new Error(message);
|
|
107
|
+
errorService.report(ErrorCode.MISSING_REQUIRED_PROP, error);
|
|
108
|
+
return error;
|
|
109
|
+
}
|
|
67
110
|
static get is() { return "graphwise-reactodia"; }
|
|
68
111
|
static get originalStyleUrls() {
|
|
69
112
|
return {
|
|
@@ -87,35 +130,35 @@ export class GraphwiseReactodia {
|
|
|
87
130
|
"references": {}
|
|
88
131
|
},
|
|
89
132
|
"required": false,
|
|
90
|
-
"optional":
|
|
133
|
+
"optional": true,
|
|
91
134
|
"docs": {
|
|
92
135
|
"tags": [],
|
|
93
|
-
"text": "The active repository id. Appended to {@link queryFunction} as the request `url`;\nchanging it re-points the graph at the new repository (and resets the canvas),\nwhich is how runtime repository changes are handled."
|
|
136
|
+
"text": "The active repository id. Appended to {@link queryFunction } as the request `url`;\nchanging it re-points the graph at the new repository (and resets the canvas),\nwhich is how runtime repository changes are handled."
|
|
94
137
|
},
|
|
95
138
|
"getter": false,
|
|
96
139
|
"setter": false,
|
|
97
140
|
"reflect": false
|
|
98
141
|
},
|
|
99
|
-
"
|
|
142
|
+
"config": {
|
|
100
143
|
"type": "unknown",
|
|
101
|
-
"attribute": "
|
|
144
|
+
"attribute": "config",
|
|
102
145
|
"mutable": false,
|
|
103
146
|
"complexType": {
|
|
104
|
-
"original": "
|
|
105
|
-
"resolved": "
|
|
147
|
+
"original": "ReactodiaConfig",
|
|
148
|
+
"resolved": "ReactodiaConfig",
|
|
106
149
|
"references": {
|
|
107
|
-
"
|
|
150
|
+
"ReactodiaConfig": {
|
|
108
151
|
"location": "import",
|
|
109
|
-
"path": "
|
|
110
|
-
"id": "
|
|
152
|
+
"path": "./models/reactodia-config",
|
|
153
|
+
"id": "src/components/graphwise-reactodia/models/reactodia-config.ts::ReactodiaConfig"
|
|
111
154
|
}
|
|
112
155
|
}
|
|
113
156
|
},
|
|
114
157
|
"required": false,
|
|
115
|
-
"optional":
|
|
158
|
+
"optional": true,
|
|
116
159
|
"docs": {
|
|
117
160
|
"tags": [],
|
|
118
|
-
"text": "
|
|
161
|
+
"text": "Host-supplied configuration: the SPARQL `queryFunction` transport, an optional `seed`\nset of entities to pre-populate the canvas with and an optional `ui` configuration.\nA DOM property (an object, not an attribute) passed in from outside the wrapper.\n\nRead once on mount; not watched, as it only sets up the data source and initial canvas."
|
|
119
162
|
},
|
|
120
163
|
"getter": false,
|
|
121
164
|
"setter": false
|
|
@@ -125,9 +168,15 @@ export class GraphwiseReactodia {
|
|
|
125
168
|
"attribute": "language",
|
|
126
169
|
"mutable": false,
|
|
127
170
|
"complexType": {
|
|
128
|
-
"original": "
|
|
129
|
-
"resolved": "
|
|
130
|
-
"references": {
|
|
171
|
+
"original": "LanguageKey",
|
|
172
|
+
"resolved": "LanguageKey.EN | LanguageKey.FR",
|
|
173
|
+
"references": {
|
|
174
|
+
"LanguageKey": {
|
|
175
|
+
"location": "import",
|
|
176
|
+
"path": "./i18n/language-key",
|
|
177
|
+
"id": "src/components/graphwise-reactodia/i18n/language-key.ts::LanguageKey"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
131
180
|
},
|
|
132
181
|
"required": false,
|
|
133
182
|
"optional": false,
|
|
@@ -138,7 +187,7 @@ export class GraphwiseReactodia {
|
|
|
138
187
|
"getter": false,
|
|
139
188
|
"setter": false,
|
|
140
189
|
"reflect": false,
|
|
141
|
-
"defaultValue": "
|
|
190
|
+
"defaultValue": "LanguageKey.EN"
|
|
142
191
|
},
|
|
143
192
|
"providerSettings": {
|
|
144
193
|
"type": "unknown",
|
|
@@ -151,7 +200,7 @@ export class GraphwiseReactodia {
|
|
|
151
200
|
"SparqlDataProviderSettings": {
|
|
152
201
|
"location": "import",
|
|
153
202
|
"path": "@reactodia/workspace",
|
|
154
|
-
"id": "
|
|
203
|
+
"id": "reactodia-workspace/dist/typings/workspace.d.ts::SparqlDataProviderSettings"
|
|
155
204
|
}
|
|
156
205
|
}
|
|
157
206
|
},
|
|
@@ -159,24 +208,70 @@ export class GraphwiseReactodia {
|
|
|
159
208
|
"optional": true,
|
|
160
209
|
"docs": {
|
|
161
210
|
"tags": [],
|
|
162
|
-
"text": "Query preset for the SPARQL data provider, owned and configured by the host. A DOM\nproperty (an object, not an attribute) passed in from outside the wrapper.
|
|
211
|
+
"text": "Query preset for the SPARQL data provider, owned and configured by the host. A DOM\nproperty (an object, not an attribute) passed in from outside the wrapper. Required: the\nwrapper has no default preset and throws when it is missing. Changing it rebuilds the data\nprovider and reloads the graph with it, keeping the current diagram."
|
|
163
212
|
},
|
|
164
213
|
"getter": false,
|
|
165
214
|
"setter": false
|
|
215
|
+
},
|
|
216
|
+
"theme": {
|
|
217
|
+
"type": "string",
|
|
218
|
+
"attribute": "theme",
|
|
219
|
+
"mutable": false,
|
|
220
|
+
"complexType": {
|
|
221
|
+
"original": "'light' | 'dark'",
|
|
222
|
+
"resolved": "\"dark\" | \"light\"",
|
|
223
|
+
"references": {}
|
|
224
|
+
},
|
|
225
|
+
"required": false,
|
|
226
|
+
"optional": true,
|
|
227
|
+
"docs": {
|
|
228
|
+
"tags": [],
|
|
229
|
+
"text": "The reactodia theme to use"
|
|
230
|
+
},
|
|
231
|
+
"getter": false,
|
|
232
|
+
"setter": false,
|
|
233
|
+
"reflect": false
|
|
166
234
|
}
|
|
167
235
|
};
|
|
168
236
|
}
|
|
237
|
+
static get events() {
|
|
238
|
+
return [{
|
|
239
|
+
"method": "eventEmitter",
|
|
240
|
+
"name": "graphwiseReactodiaEvent",
|
|
241
|
+
"bubbles": true,
|
|
242
|
+
"cancelable": true,
|
|
243
|
+
"composed": true,
|
|
244
|
+
"docs": {
|
|
245
|
+
"tags": [],
|
|
246
|
+
"text": "Fires for every event to the host, differentiated by `detail.type`."
|
|
247
|
+
},
|
|
248
|
+
"complexType": {
|
|
249
|
+
"original": "EventDetail",
|
|
250
|
+
"resolved": "{ type: EventType.ERROR; payload: ErrorReport; } | { type: EventType.TEXT_SEARCH; payload?: undefined; }",
|
|
251
|
+
"references": {
|
|
252
|
+
"EventDetail": {
|
|
253
|
+
"location": "import",
|
|
254
|
+
"path": "./models/event/event-detail",
|
|
255
|
+
"id": "src/components/graphwise-reactodia/models/event/event-detail.ts::EventDetail"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}];
|
|
260
|
+
}
|
|
169
261
|
static get elementRef() { return "hostElement"; }
|
|
170
262
|
static get watchers() {
|
|
171
263
|
return [{
|
|
172
264
|
"propName": "currentRepository",
|
|
173
|
-
"methodName": "
|
|
265
|
+
"methodName": "onCurrentRepositoryChange"
|
|
266
|
+
}, {
|
|
267
|
+
"propName": "language",
|
|
268
|
+
"methodName": "onLanguageOrSettingsChange"
|
|
174
269
|
}, {
|
|
175
270
|
"propName": "providerSettings",
|
|
176
|
-
"methodName": "
|
|
271
|
+
"methodName": "onLanguageOrSettingsChange"
|
|
177
272
|
}, {
|
|
178
|
-
"propName": "
|
|
179
|
-
"methodName": "
|
|
273
|
+
"propName": "theme",
|
|
274
|
+
"methodName": "onThemeChange"
|
|
180
275
|
}];
|
|
181
276
|
}
|
|
182
277
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import enTranslation from "./en.reactodia.translation.json";
|
|
1
2
|
import frTranslation from "./fr.reactodia.translation.json";
|
|
3
|
+
import { LanguageKey } from "./language-key";
|
|
4
|
+
// English is provided by default from reactodia, so the English bundle holds only our own keys and overrides. If
|
|
5
|
+
// A key is missing, reactodia defaults to its own translation.
|
|
2
6
|
export const TRANSLATIONS = {
|
|
3
|
-
|
|
7
|
+
[LanguageKey.EN]: enTranslation,
|
|
8
|
+
[LanguageKey.FR]: frTranslation
|
|
4
9
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { ToolbarAction, useTranslation, useWorkspace } from "@reactodia/workspace";
|
|
3
|
+
import { service } from "../providers/service/service-inject";
|
|
4
|
+
import { DiagramFileService } from "../services/diagram-file/diagram-file.service";
|
|
5
|
+
/**
|
|
6
|
+
* Exports the diagram as a JSON file.
|
|
7
|
+
*/
|
|
8
|
+
export function ExportDiagramAction() {
|
|
9
|
+
const { model } = useWorkspace();
|
|
10
|
+
const t = useTranslation();
|
|
11
|
+
const diagramFileService = service(DiagramFileService);
|
|
12
|
+
const exportDiagram = () => {
|
|
13
|
+
const timestamp = new Date().toISOString().replace(/[-:]|\.\d+Z$/g, '');
|
|
14
|
+
diagramFileService.download(model.exportLayout(), `diagram-${timestamp}${DiagramFileService.FILE_EXTENSION}`);
|
|
15
|
+
};
|
|
16
|
+
return createElement(ToolbarAction,
|
|
17
|
+
// The same icon as ToolbarActionSave. We don't use that action, since it disables saving on refresh
|
|
18
|
+
{ className: 'reactodia-toolbar-action__save', title: t.text('graphwise_toolbar_action.export_json.title'), onSelect: exportDiagram }, t.text('graphwise_toolbar_action.export_json.label'));
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { ToolbarActionClearAll, ToolbarActionExport } from "@reactodia/workspace";
|
|
3
|
+
import { MenuItem } from "../models/ui/menu-item";
|
|
4
|
+
import { ExportDiagramAction } from "./export-diagram-action";
|
|
5
|
+
import { ImportDiagramAction } from "./import-diagram-action";
|
|
6
|
+
/**
|
|
7
|
+
* Each menu entry.
|
|
8
|
+
*
|
|
9
|
+
* Passing a `menu` to the `DefaultWorkspace` replaces its default actions, so they are listed here again.
|
|
10
|
+
*/
|
|
11
|
+
const MENU_ITEMS = {
|
|
12
|
+
[MenuItem.CLEAR_ALL]: (key) => createElement(ToolbarActionClearAll, { key }),
|
|
13
|
+
[MenuItem.EXPORT_PNG]: (key) => createElement(ToolbarActionExport, { key, kind: 'exportRaster' }),
|
|
14
|
+
[MenuItem.EXPORT_SVG]: (key) => createElement(ToolbarActionExport, { key, kind: 'exportSvg' }),
|
|
15
|
+
[MenuItem.PRINT]: (key) => createElement(ToolbarActionExport, { key, kind: 'print' }),
|
|
16
|
+
[MenuItem.EXPORT_JSON]: (key) => createElement(ExportDiagramAction, { key }),
|
|
17
|
+
[MenuItem.IMPORT_JSON]: (key) => createElement(ImportDiagramAction, { key })
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The menu entries for the given menu items.
|
|
21
|
+
*/
|
|
22
|
+
export function createMenuItems(items) {
|
|
23
|
+
return items.map((item) => MENU_ITEMS[item](item));
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { ToolbarActionOpen, useTranslation, useWorkspace } from "@reactodia/workspace";
|
|
3
|
+
import { service } from "../providers/service/service-inject";
|
|
4
|
+
import { DiagramService } from "../services/diagram/diagram.service";
|
|
5
|
+
import { DiagramFileService } from "../services/diagram-file/diagram-file.service";
|
|
6
|
+
import { ErrorService } from "../services/error/error.service";
|
|
7
|
+
import { ErrorCode } from "../models/error/error-code";
|
|
8
|
+
/**
|
|
9
|
+
* Imports a diagram from a JSON file into the workspace.
|
|
10
|
+
*/
|
|
11
|
+
export function ImportDiagramAction() {
|
|
12
|
+
const { model } = useWorkspace();
|
|
13
|
+
const t = useTranslation();
|
|
14
|
+
const diagramFileService = service(DiagramFileService);
|
|
15
|
+
const diagramService = service(DiagramService);
|
|
16
|
+
const errorService = service(ErrorService);
|
|
17
|
+
const importDiagram = async (file) => {
|
|
18
|
+
try {
|
|
19
|
+
const diagram = await diagramFileService.read(file);
|
|
20
|
+
await diagramService.importDiagram(model, model.dataProvider, diagram);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
errorService.report(ErrorCode.DIAGRAM_IMPORT, error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return createElement(ToolbarActionOpen, {
|
|
27
|
+
title: t.text('graphwise_toolbar_action.import_json.title'),
|
|
28
|
+
fileAccept: DiagramFileService.FILE_EXTENSION,
|
|
29
|
+
onSelect: (file) => void importDiagram(file)
|
|
30
|
+
}, t.text('graphwise_toolbar_action.import_json.label'));
|
|
31
|
+
}
|