Skip to content

Commit

Permalink
24.6.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgraph committed Jun 21, 2024
1 parent 969b942 commit 7449d2d
Show file tree
Hide file tree
Showing 86 changed files with 4,605 additions and 4,305 deletions.
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
21-JUN-2024: 24.6.1

- Improves Google Drive app not installed message [DID-11885]
- Disables shadows in printing and PDF export [jgraph/drawio-desktop#1784]

20-JUN-2024: 24.6.0

- Adds autosizeGrid style [jgraph/drawio#1131]
- Adds Editor.enableChatGpt with config switch
- Ignores service worker registration errors [jgraph/drawio#4483]
- Adds UI zoom to desktop help menu [jgraph/drawio-desktop#1359]
- Adds non-numpad zoom keyboard shortcuts [jgraph/drawio-desktop#978]
- Uses quotes for CSS font-family [jgraph/drawio-desktop#1604]
- Adds Editor.enableAnimations with config switch [jgraph/drawio#4491]
- Fixes grid color for print and PDF export in dark mode [jgraph/drawio#4488]
- Preserves cell hierarchy in SVG output [jgraph/drawio#3960]

17-JUN-2024: 24.5.5

- Simplifies publish dialog [jgraph/drawio#4346]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24.5.5
24.6.1
2,394 changes: 1,200 additions & 1,194 deletions src/main/webapp/js/app.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/webapp/js/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ try
document.body.appendChild(link);

if ((/test\.draw\.io$/.test(window.location.hostname)) ||
(/stage\.diagrams\.net$/.test(window.location.hostname)) ||
(/preprod\.diagrams\.net$/.test(window.location.hostname)) ||
(/app\.diagrams\.net$/.test(window.location.hostname)))
{
link = link.cloneNode(false);
Expand Down
10 changes: 1 addition & 9 deletions src/main/webapp/js/diagramly/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,7 @@ App.main = function(callback, createUi)
}
catch (e)
{
if (window.console != null && !EditorUi.isElectronApp)
{
console.error(e);
}
else
{
mxLog.show();
mxLog.debug(e.stack);
}
// ignore
}

// Loads Pusher API
Expand Down
177 changes: 117 additions & 60 deletions src/main/webapp/js/diagramly/Dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3817,75 +3817,99 @@ var NewDialog = function(editorUi, compact, showName, callback, createOnly, canc

mxEvent.addListener(generateInput, 'input', updateGenerateButtonState);

function generateDiagram()
function stopInput()
{
var desc = generateInput.value;
var listenerTriggered = false;

var prompt = 'Write a detailed and complex MermaidJS declaration for ' +
'"' + (desc != '' ? desc : 'something random') + '" ' +
'using correct MermaidJS syntax and do not ' +
'provide additional text in your response.';
var title = generateInput.value;

if (typeof mxMermaidToDrawio !== 'undefined')
{
mxMermaidToDrawio.addListener(mxUtils.bind(this, function(modelXml)
{
listenerTriggered = true;
templateXml = modelXml;
}));
}

generateInput.style.visibility = 'hidden';
generateButton.style.visibility = 'hidden';
generateElt.style.backgroundImage = 'url(' + Editor.spinImage + ')';
generateElt.style.backgroundSize = '12px 12px';
generateElt.style.backgroundImage = generateBackground;
generateElt.style.backgroundSize = 'contain';
editGenerate.style.visibility = 'visible';
magnifyGenerate.style.visibility = 'visible';
};

editorUi.generateOpenAiMermaidDiagram(prompt,
function(mermaidData, imageData, w, h)
function generateDiagram(cancel)
{
var desc = mxUtils.trim(generateInput.value);

if (!cancel && desc != '')
{
generateInput.style.visibility = 'hidden';
generateButton.style.visibility = 'hidden';
var listenerTriggered = false;

var prompt = 'Write a detailed and complex MermaidJS declaration for ' +
'"' + (desc != '' ? desc : 'something random') + '" ' +
'using correct MermaidJS syntax and do not ' +
'provide additional text in your response.';

if (typeof mxMermaidToDrawio !== 'undefined')
{
if (selectedElt == generateElt && generateInput.style.visibility == 'hidden')
mxMermaidToDrawio.addListener(mxUtils.bind(this, function(modelXml)
{
generateBackground = 'url(' + 'data:image/svg+xml;base64,' +
imageData.substring(imageData.indexOf(',') + 1) + ')';
generateElt.style.backgroundImage = generateBackground;
generateElt.style.backgroundSize = 'contain';
editGenerate.style.visibility = 'visible';
magnifyGenerate.style.visibility = 'visible';
generateElt.setAttribute('title', title);
listenerTriggered = true;
templateXml = modelXml;
}));
}

// Updates template XML for insert button
var xml = (listenerTriggered) ? templateXml :
editorUi.createMermaidXml(mermaidData,
EditorUi.defaultMermaidConfig,
imageData, w, h, title);
templateXml = xml;
lastAiXml = xml;
lastAiTitle = title;
}
}, function(e)
{
if (selectedElt == generateElt)
generateElt.style.backgroundImage = 'url(' + Editor.spinImage + ')';
generateElt.style.backgroundSize = '12px 12px';

editorUi.generateOpenAiMermaidDiagram(prompt,
function(mermaidData, imageData, w, h)
{
generateInput.style.visibility = 'visible';
generateButton.style.visibility = 'visible';
editGenerate.style.visibility = 'visible';
magnifyGenerate.style.visibility = 'visible';
editorUi.handleError(e);
if (selectedElt == generateElt && generateInput.style.visibility == 'hidden')
{
generateBackground = 'url(' + 'data:image/svg+xml;base64,' +
imageData.substring(imageData.indexOf(',') + 1) + ')';
generateElt.setAttribute('title', desc);

// Updates template XML for insert button
var xml = (listenerTriggered) ? templateXml :
editorUi.createMermaidXml(mermaidData,
EditorUi.defaultMermaidConfig,
imageData, w, h, desc);
templateXml = xml;
lastAiXml = xml;
lastAiTitle = desc;

stopInput();
}
}, function(e)
{
if (selectedElt == generateElt)
{
generateInput.style.visibility = 'visible';
generateButton.style.visibility = 'visible';
editGenerate.style.visibility = 'visible';
magnifyGenerate.style.visibility = 'visible';
editorUi.handleError(e);
}
}
}
);
);
}
else if (lastAiTitle != null)
{
generateInput.value = lastAiTitle;
stopInput();
}
};

mxEvent.addListener(generateButton, 'click', generateDiagram);
mxEvent.addListener(generateButton, 'click', function()
{
generateDiagram();
});

mxEvent.addListener(generateInput, 'keydown', function(evt)
{
if (evt.keyCode == 13 && !mxEvent.isShiftDown(evt))
{
generateDiagram();
evt.preventDefault();
mxEvent.consume(evt);
}
else if (evt.keyCode == 27)
{
generateDiagram(true);
mxEvent.consume(evt);
}
});

Expand Down Expand Up @@ -4209,15 +4233,17 @@ var NewDialog = function(editorUi, compact, showName, callback, createOnly, canc
categories['basic'] = [{title: 'blankDiagram'}];
var templates = categories['basic'];

if (editorUi.isExternalDataComms() &&
if (Editor.enableChatGpt &&
editorUi.isExternalDataComms() &&
editorUi.getServiceName() == 'draw.io' &&
typeof mxMermaidToDrawio !== 'undefined' &&
window.isMermaidEnabled)
{
categories['basic'].push({title: 'generate', type: 'generative'});
}

if (editorUi.isExternalDataComms() &&
if (Editor.enableChatGpt &&
editorUi.isExternalDataComms() &&
editorUi.getServiceName() == 'draw.io' &&
typeof mxMermaidToDrawio !== 'undefined' &&
window.isMermaidEnabled)
Expand Down Expand Up @@ -7126,7 +7152,17 @@ var RevisionDialog = function(editorUi, revs, restoreFn)

// Contains possible error messages
var errorNode = document.createElement('div');
errorNode.style.cssText = 'position:absolute;left:0;right:0;top:0;bottom:20px;text-align:center;transform:translate(0,50%);pointer-events:none;';
errorNode.style.position = 'absolute',
errorNode.style.display = 'none';
errorNode.style.textAlign = 'center';
errorNode.style.padding = '8px';
errorNode.style.borderRadius = '8px';
errorNode.style.left = '50%';
errorNode.style.top = '50%';
errorNode.style.whiteSpace = 'nowrap';
errorNode.style.transform = 'translate(-50%, -50%)';
errorNode.style.background = 'inherit';
errorNode.style.border = '1px solid';
container.appendChild(errorNode);

mxEvent.disableContextMenu(container);
Expand Down Expand Up @@ -7307,6 +7343,7 @@ var RevisionDialog = function(editorUi, revs, restoreFn)

if (curr == null)
{
errorNode.style.display = 'inline-block';
mxUtils.write(errorNode, mxResources.get('pageNotFound'));
}
else
Expand All @@ -7332,12 +7369,14 @@ var RevisionDialog = function(editorUi, revs, restoreFn)
}
catch (e)
{
errorNode.style.display = 'inline-block';
errorNode.innerText = '';
mxUtils.write(errorNode, mxResources.get('pageNotFound') + ': ' + e.message);
}
}, null, function()
{
mxUtils.setOpacity(compareBtn, 60);
errorNode.style.display = 'none';
errorNode.innerText = '';

if (container.style.display == 'none')
Expand Down Expand Up @@ -7627,11 +7666,12 @@ var RevisionDialog = function(editorUi, revs, restoreFn)
{
// Workaround for "invalid calling object" error in IE
var tmp = node.getElementsByTagName('diagram');
var newPages = {};
diagrams = [];

for (var i = 0; i < tmp.length; i++)
{
diagrams.push(tmp[i]);
diagrams.push(tmp[i]);
}

realPage = Math.min(currentPage, diagrams.length - 1);
Expand All @@ -7649,18 +7689,35 @@ var RevisionDialog = function(editorUi, revs, restoreFn)
for (var i = 0; i < diagrams.length; i++)
{
var pageOption = document.createElement('option');
var name = diagrams[i].getAttribute('name') ||
mxResources.get('pageWithNumber', [i + 1]);
mxUtils.write(pageOption, name);
pageOption.setAttribute('title', name + ' (' +
diagrams[i].getAttribute('id') + ')');
pageOption.setAttribute('value', i);
var name = diagrams[i].getAttribute('name') ||
mxResources.get('pageWithNumber', [i + 1]);
var localPage = editorUi.getPageById(diagrams[i].getAttribute('id'));
var state = '';

if (localPage != null)
{
var newPage = new DiagramPage(diagrams[i]);

if (editorUi.getHashValueForPages([localPage]) != editorUi.getHashValueForPages([newPage]))
{
state = ' (M)';
}
}
else
{
state = ' (X)';
}

mxUtils.write(pageOption, name + state);

if (i == realPage)
{
pageOption.setAttribute('selected', 'selected');
}

pageSelect.appendChild(pageOption);
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/webapp/js/diagramly/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@
*/
Editor.defaultBorder = 5;

/**
* Specifies animations should be enabled. Default is true.
*/
Editor.enableAnimations = true;

/**
* Specifies if ChatGPT should be enabled. Default is true only
* on app.diagrams.net (including test and preprod).
*/
Editor.enableChatGpt = (/test\.draw\.io$/.test(window.location.hostname)) ||
(/preprod\.diagrams\.net$/.test(window.location.hostname)) ||
(/app\.diagrams\.net$/.test(window.location.hostname));

/**
* Specifies the ChatGPT API key. Default is null.
*/
Expand Down Expand Up @@ -646,6 +659,12 @@
return geo != null && !geo.relative;
}},
{name: 'autosize', dispName: 'Autosize', type: 'bool', defVal: false},
{name: 'autosizeGrid', dispName: 'Autosize Grid', type: 'enum', defVal: null,
enumList: [{val: null, dispName: 'Default'}, {val: '1', dispName: 'Enabled'}, {val: '0', dispName: 'Disabled'}], isVisible: function(state, format)
{
return state.vertices.length > 0 && format.editorUi.editor.graph.isAutoSizeCell(state.vertices[0]);
}
},
{name: 'fixedWidth', dispName: 'Fixed Width', type: 'bool', defVal: false},
{name: 'resizable', dispName: 'Resizable', type: 'bool', defVal: true},
{name: 'resizeWidth', dispName: 'Resize Width', type: 'bool', defVal: false},
Expand Down Expand Up @@ -2407,6 +2426,16 @@
mxConstants.SHADOW_BLUR = config.shadowBlur;
}

if (config.enableAnimations != null)
{
Editor.enableAnimations = config.enableAnimations;
}

if (config.enableChatGpt != null)
{
Editor.enableChatGpt = config.enableChatGpt;
}

if (config.gptApiKey != null)
{
Editor.gptApiKey = config.gptApiKey;
Expand Down
Loading

0 comments on commit 7449d2d

Please sign in to comment.