Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion drawio_desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 30 additions & 7 deletions drawio_desktop/src/mermaid-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var DialogMermaid = function (editorUi, shape) {
<span style="display: none;"><a id="plugin_mermaid_button_svg" href="#">SVG</a> | </span>
<a id="plugin_mermaid_button_png" href="#">PNG</a> |
<br />Help |
<a target="_blank" href="https://mermaid-js.github.io/mermaid/#/./n00b-syntaxReference">Syntax</a> |
<a target="_blank" href="https://mermaid.js.org/intro/">Syntax</a> |
</p><br /></div>
</div>
<div style="flex: 0 0 32px;"></div>
Expand Down Expand Up @@ -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';
Expand All @@ -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();
});
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -404,10 +428,9 @@ Draw.loadPlugin(function (ui) {
});


});



});



2 changes: 1 addition & 1 deletion drawio_desktop/src/shapes/shapeMermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down