We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fb4646b commit feea304Copy full SHA for feea304
7 files changed
package-lock.json
package.json
@@ -17,7 +17,6 @@
17
"cytoscape-edgehandles": "^3.6.0",
18
"cytoscape-grid-guide": "^2.3.2",
19
"cytoscape-node-editing": "^4.0.0",
20
- "cytoscape-svg": "^0.4.0",
21
"file-saver": "^2.0.5",
22
"hotkeys-js": "^3.8.7",
23
"jquery": "^3.0.0",
src/component/File-drag-drop.jsx
@@ -41,7 +41,7 @@ const app = ({ superState, dispatcher }) => {
41
fileRef.current.value = null;
42
const droppedFile = e.dataTransfer.files[0];
43
const ext = droppedFile && droppedFile.name.split('.').slice(-1)[0]?.toLowerCase();
44
- const allowed = ['graphml', 'json', 'png', 'svg', 'jpg', 'jpeg'];
+ const allowed = ['graphml', 'json', 'png', 'jpg', 'jpeg'];
45
if (e.dataTransfer.files.length === 1 && allowed.includes(ext)) {
46
readFile(superStateRef.current, dispatcherRef.current, droppedFile);
47
}
@@ -71,7 +71,7 @@ const app = ({ superState, dispatcher }) => {
71
ref={fileRef}
72
onClick={(e) => { e.target.value = null; }}
73
style={{ display: 'none' }}
74
- accept=".graphml,.json,.png,.svg,.jpg,.jpeg"
+ accept=".graphml,.json,.png,.jpg,.jpeg"
75
onChange={(e) => readFile(superState, dispatcher, e.target.files[0])}
76
/>
77
<span className="arrow">⟶</span>
src/graph-builder/graph-core/1-core.js
@@ -1,7 +1,6 @@
1
import cytoscape from 'cytoscape';
2
import edgehandles from 'cytoscape-edgehandles';
3
import gridGuide from 'cytoscape-grid-guide';
4
-import svg from 'cytoscape-svg';
5
import Konva from 'konva';
6
import nodeEditing from 'cytoscape-node-editing';
7
import $ from 'jquery';
@@ -45,9 +44,6 @@ class CoreGraph {
if (typeof cytoscape('core', 'gridGuide') !== 'function') {
gridGuide(cytoscape);
48
- if (typeof cytoscape('core', 'svg') !== 'function') {
49
- cytoscape.use(svg);
50
- }
51
// if (cy) this.cy = cy;
52
this.cy = cytoscape({ ...cyOptions(darkMode), container: element });
53
this.cy.on('position', 'node', () => {
src/graph-builder/graph-core/5-load-save.js
@@ -52,23 +52,6 @@ class GraphLoadSave extends GraphUndoRedo {
saveAs(blob, `${this.getName()}.graphml.png`);
return;
54
55
- if (format === 'SVG') {
56
- const blob = new Blob([this.cy.svg({ full: true })], { type: 'image/svg+xml;charset=utf-8' });
57
- saveAs(blob, `${this.getName()}-DHGWorkflow.svg`);
58
- return;
59
60
- if (format === 'SVG-EMBEDDED') {
61
- const svgStr = this.cy.svg({ full: true });
62
- const parser = new DOMParser();
63
- const doc = parser.parseFromString(svgStr, 'image/svg+xml');
64
- const metadata = doc.createElementNS('http://www.w3.org/2000/svg', 'metadata');
65
- metadata.setAttribute('data-graphml', this.getGraphML());
66
- doc.documentElement.insertBefore(metadata, doc.documentElement.firstChild);
67
- const newSvg = new XMLSerializer().serializeToString(doc);
68
- const blob = new Blob([newSvg], { type: 'image/svg+xml;charset=utf-8' });
69
- saveAs(blob, `${this.getName()}.graphml.svg`);
70
if (format === 'JPG-EMBEDDED') {
const b64Uri = this.cy.jpg({ full: true });
const b64Data = b64Uri.split(',')[1];
src/toolbarActions/toolbarFunctions.js
@@ -218,36 +218,6 @@ const readFile = async (state, setState, file, fileHandle) => {
218
};
219
if (fileHandle) fr.readAsArrayBuffer(await fileHandle.getFile());
220
else fr.readAsArrayBuffer(file);
221
- } else if (ext === 'svg') {
222
- fr.onload = (x) => {
223
- try {
224
- const parserDOM = new DOMParser();
225
- const svgDoc = parserDOM.parseFromString(x.target.result, 'image/svg+xml');
226
- const metadata = svgDoc.getElementsByTagName('metadata')[0];
227
- const graphML = metadata ? metadata.getAttribute('data-graphml') : null;
228
- if (graphML) {
229
- parser(graphML).then(({ authorName }) => {
230
- setState({
231
- type: T.ADD_GRAPH,
232
- payload: {
233
- projectName,
234
- graphML,
235
- fileHandle: null,
236
- fileName: file.name,
237
- authorName,
238
- },
239
- });
240
- toast.success('Imported embedded GraphML from SVG!');
241
- }).catch(() => toast.error('Embedded GraphML inside SVG is invalid.'));
242
- } else {
243
- toast.error('This SVG does not contain an embedded GraphML Workflow.');
244
245
- } catch (err) {
246
- toast.error('Could not parse the SVG file.');
247
248
- };
249
- if (fileHandle) fr.readAsText(await fileHandle.getFile());
250
- else fr.readAsText(file);
251
} else if (ext === 'jpg' || ext === 'jpeg') {
252
fr.onload = (x) => {
253
try {
src/toolbarActions/toolbarList.js
@@ -306,8 +306,6 @@ const toolbarList = (state, dispatcher) => [
306
{ fn: () => downloadImg(s, d, 'JPG-EMBEDDED'), name: 'JPG (with GraphML)' },
307
{ fn: () => downloadImg(s, d, 'PNG'), name: 'PNG' },
308
{ fn: () => downloadImg(s, d, 'PNG-EMBEDDED'), name: 'PNG (with GraphML)' },
309
- { fn: () => downloadImg(s, d, 'SVG'), name: 'SVG' },
310
- { fn: () => downloadImg(s, d, 'SVG-EMBEDDED'), name: 'SVG (with GraphML)' },
311
{ fn: () => saveAsJson(s, d), name: 'JSON' },
312
],
313
visibility: true,
0 commit comments