diff --git a/drawio_desktop/package.json b/drawio_desktop/package.json index 2f6c569..bc93212 100644 --- a/drawio_desktop/package.json +++ b/drawio_desktop/package.json @@ -11,7 +11,10 @@ "webpack:production": "webpack --mode production", "webpack:development": "webpack --mode development", "build": "npm run webpack:production", - "dev": "npm run webpack:development" + "dev": "npm run webpack:development", + "copy-plugin": "copy /y dist\\mermaid-plugin.webpack.js %appdata%\\draw.io\\plugins\\", + "run-drawio": "..\\..\\draw.io-20.3.0-windows-no-installer.exe --args --enable-plugins", + "maj-dev": "npm run dev && npm run copy-plugin && npm run run-drawio" }, "devDependencies": { "mermaid": "^8.13.3", diff --git a/drawio_desktop/src/mermaid-plugin.js b/drawio_desktop/src/mermaid-plugin.js index e0cf21c..971c391 100644 --- a/drawio_desktop/src/mermaid-plugin.js +++ b/drawio_desktop/src/mermaid-plugin.js @@ -51,7 +51,7 @@ var DialogMermaid = function (editorUi, shape) { SVG | PNG |
Help | - Syntax | + Syntax |


@@ -209,8 +209,17 @@ var DialogMermaid = function (editorUi, shape) { ); } - var cancelBtn = mxUtils.button(mxResources.get('close'), function () { - win.destroy(); + var cancelBtn = mxUtils.button(mxResources.get('cancel'), function () { + // Check if modified or ask to save + let cellValue = editorUi.editor.graph.convertValueToString(shape.state.cell).replace(/(\r\n|\n\r)/g,"\n") + let formValue = textarea.value.replace(/(\r\n|\n\r)/g,"\n") + console.log(cellValue, formValue, cellValue == formValue, cellValue === formValue) + if ( + (cellValue == formValue) || + (mxUtils.confirm(mxResources.get('changesNotSaved')+"\n"+mxResources.get('areYouSure'))) + ) { + win.destroy(); + } }); cancelBtn.className = 'geBtn'; @@ -219,7 +228,14 @@ var DialogMermaid = function (editorUi, shape) { buttons.appendChild(cancelBtn); } - var okBtn = mxUtils.button(mxResources.get('apply'), function (evt) { + var saveBtn = mxUtils.button(mxResources.get('save'), function (evt) { + parse(textarea.value, evt); + }); + buttons.appendChild(saveBtn); + + saveBtn.className = 'geBtn'; + + var okBtn = mxUtils.button(mxResources.get('saveAndExit'), function (evt) { parse(textarea.value, evt); win.destroy(); }); @@ -241,7 +257,8 @@ Draw.loadPlugin(function (ui) { // Build mermaid settings : by least order // - mermaid_plugin_defaults : this plugin defaults // - EditorUi.defaultMermaidConfig : drawio defaults mermaid - // - Editor.config.defaultMermaidConfig : drawio config (from PreConfig and local configuration) + // - window.defaultMermaidConfig : drawio config from PreConfig + // - Editor.config.defaultMermaidConfig : drawio config (from PreConfig or local configuration) let mermaid_settings = {}; mermaid_settings = merge(mermaid_settings, mermaid_plugin_defaults); @@ -252,6 +269,13 @@ Draw.loadPlugin(function (ui) { throw e; } } + try { + mermaid_settings = merge(mermaid_settings, window.defaultMermaidConfig); + } catch (e) { + if (!e instanceof TypeError) { + throw e; + } + } try { mermaid_settings = merge(mermaid_settings, window.Editor.config.defaultMermaidConfig); } catch (e) { @@ -404,10 +428,9 @@ Draw.loadPlugin(function (ui) { }); +}); -}); - diff --git a/drawio_desktop/src/shapes/shapeMermaid.js b/drawio_desktop/src/shapes/shapeMermaid.js index 7456725..862ca24 100644 --- a/drawio_desktop/src/shapes/shapeMermaid.js +++ b/drawio_desktop/src/shapes/shapeMermaid.js @@ -228,7 +228,7 @@ mxShapeMermaid.prototype.buildCustomProperties = function (defaults) { { name: 'gantt_fontSize', dispName: 'gantt_fontSize', type: 'int', min: 1, max: 1000, defVal: defaults.gantt.fontSize }, { name: 'gantt_fontFamily', dispName: 'gantt_fontFamily', type: 'string', defVal: defaults.gantt.fontFamily }, { name: 'gantt_numberSectionStyles', dispName: 'gantt_numberSectionStyles', type: 'int', min: 1, max: 1000, defVal: defaults.gantt.numberSectionStyles }, - { name: 'gantt_axisFormat', dispName: 'gantt_axisFormat', type: 'string', defVal: defaults.gantt.axisFormat }, + { name: 'gantt_axisFormat', dispName: 'gantt_axisFormat', type: 'string', defVal: encodeURIComponent(defaults.gantt.axisFormat) }, { name: 'gantt_useMaxWidth', dispName: 'gantt_useMaxWidth', type: 'bool', defVal: defaults.gantt.useMaxWidth }, { name: 'journey_diagramMarginX', dispName: 'journey_diagramMarginX', type: 'int', min: 1, max: 1000, defVal: defaults.journey.diagramMarginX },