Skip to content

Commit

Permalink
21.1.8 release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgraph committed Apr 14, 2023
1 parent a117e3d commit 6add5ed
Show file tree
Hide file tree
Showing 27 changed files with 14,788 additions and 1,716 deletions.
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
14-APR-2023: 21.1.8

- Adds headless editor UI class that sets chromeless
- Fixes line jumps crossing waypoints [drawio-2664]
- Fixes possible NPE for VSDX import [drawio-3507]
- Fixes remove group with drag and drop [drawio-3510]
- Fixes moving vertical label position [drawio-3512]
- Updates AWS icons [drawio-3336]

12-APR-2023: 21.1.7

- [vsdx] Fixes text overflow of zero width/height labels [DID-7950]
- Uses Alt+Shift+R for clear waypoints [drawio-3501]
- Allow blank replace string in dialog [drawio-3502]
- Handles dark theme change in trees plugin [drawio-3496]
- Adds smart-template-type, -generate URL parameters

11-APR-2023: 21.1.6

- [conf cloud] Fixes large instances page IDs export and import and using new API [DID-7895]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21.1.6
21.1.8
41 changes: 17 additions & 24 deletions src/main/webapp/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ app.on('activate', function ()

app.on('will-finish-launching', function()
{
app.on("open-file", function(event, path)
app.on("open-file", function(event, filePath)
{
event.preventDefault();
// Creating a new window while a save/open dialog is open crashes the app
Expand All @@ -907,7 +907,7 @@ app.on('will-finish-launching', function()

if (loadEvtCount == 2)
{
win.webContents.send('args-obj', {args: [path]});
win.webContents.send('args-obj', {args: [filePath]});
}
}

Expand All @@ -924,7 +924,7 @@ app.on('will-finish-launching', function()
}
else
{
firstWinFilePath = path
firstWinFilePath = filePath
}
});
});
Expand Down Expand Up @@ -1872,13 +1872,14 @@ async function getFileDrafts(fileObject)

async function saveDraft(fileObject, data)
{
if (!checkFileContent(data))
var draftFileName = fileObject.draftFileName || getDraftFileName(fileObject);

if (!checkFileContent(data) || path.resolve(draftFileName).startsWith(__dirname))
{
throw new Error('Invalid file data');
}
else
{
var draftFileName = fileObject.draftFileName || getDraftFileName(fileObject);
await fsProm.writeFile(draftFileName, data, 'utf8');

if (isWin)
Expand All @@ -1896,7 +1897,7 @@ async function saveDraft(fileObject, data)

async function saveFile(fileObject, data, origStat, overwrite, defEnc)
{
if (!checkFileContent(data))
if (!checkFileContent(data) || path.resolve(fileObject.path).startsWith(__dirname))
{
throw new Error('Invalid file data');
}
Expand Down Expand Up @@ -2018,15 +2019,15 @@ async function saveFile(fileObject, data, origStat, overwrite, defEnc)
}
};

async function writeFile(path, data, enc)
async function writeFile(filePath, data, enc)
{
if (!checkFileContent(data, enc))
if (!checkFileContent(data, enc) || path.resolve(filePath).startsWith(__dirname))
{
throw new Error('Invalid file data');
}
else
{
return await fsProm.writeFile(path, data, enc);
return await fsProm.writeFile(filePath, data, enc);
}
};

Expand Down Expand Up @@ -2148,7 +2149,7 @@ async function readFile(filename, encoding)
{
let data = await fsProm.readFile(filename, encoding);

if (checkFileContent(data, encoding))
if (checkFileContent(data, encoding) && !path.resolve(filename).startsWith(__dirname))
{
return data;
}
Expand Down Expand Up @@ -2200,7 +2201,7 @@ async function deleteFile(file)
await fh.read(buffer, 0, 16);
await fh.close();

if (checkFileContent(buffer))
if (checkFileContent(buffer) && !path.resolve(file).startsWith(__dirname))
{
await fsProm.unlink(file);
}
Expand Down Expand Up @@ -2253,17 +2254,17 @@ function openExternal(url)
return false;
}

function watchFile(path)
function watchFile(filePath)
{
let win = BrowserWindow.getFocusedWindow();

if (win)
{
fs.watchFile(path, (curr, prev) => {
fs.watchFile(filePath, (curr, prev) => {
try
{
win.webContents.send('fileChanged', {
path: path,
path: filePath,
curr: curr,
prev: prev
});
Expand All @@ -2273,14 +2274,9 @@ function watchFile(path)
}
}

function unwatchFile(path)
function unwatchFile(filePath)
{
fs.unwatchFile(path);
}

function getCurDir()
{
return __dirname;
fs.unwatchFile(filePath);
}

ipcMain.on("rendererReq", async (event, args) =>
Expand Down Expand Up @@ -2363,9 +2359,6 @@ ipcMain.on("rendererReq", async (event, args) =>
case 'unwatchFile':
ret = await unwatchFile(args.path);
break;
case 'getCurDir':
ret = await getCurDir();
break;
};

event.reply('mainResp', {success: true, data: ret, reqId: args.reqId});
Expand Down
Binary file modified src/main/webapp/images/sidebar-aws4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,171 changes: 611 additions & 560 deletions src/main/webapp/js/app.min.js

Large diffs are not rendered by default.

105 changes: 58 additions & 47 deletions src/main/webapp/js/diagramly/Dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,13 @@ var NewDialog = function(editorUi, compact, showName, callback, createOnly, canc
typeSelect.appendChild(option);
}

var type = urlParams['smart-template-type'];

if (type != null)
{
typeSelect.value = type;
}

var button = mxUtils.button(mxResources.get('generate'), function()
{
var useMermaidFormat = typeSelect.value == 'gantt' || typeSelect.value == 'pie';
Expand Down Expand Up @@ -3399,6 +3406,14 @@ var NewDialog = function(editorUi, compact, showName, callback, createOnly, canc
{
description.value = decodeURIComponent(temp);
updateState();

if (urlParams['smart-template-generate'] == '1')
{
window.setTimeout(function()
{
button.click();
}, 0);
}
}

mxEvent.addListener(description, 'change', updateState);
Expand Down Expand Up @@ -7344,7 +7359,7 @@ var FindWindow = function(ui, x, y, w, h, withReplace)

function updateReplBtns()
{
if (lastSearchSuccessful && replaceInput.value)
if (lastSearchSuccessful)
{
replaceFindBtn.removeAttribute('disabled');
replaceBtn.removeAttribute('disabled');
Expand All @@ -7355,7 +7370,7 @@ var FindWindow = function(ui, x, y, w, h, withReplace)
replaceBtn.setAttribute('disabled', 'disabled');
}

if (replaceInput.value && searchInput.value)
if (searchInput.value)
{
replaceAllBtn.removeAttribute('disabled');
}
Expand Down Expand Up @@ -7702,7 +7717,7 @@ var FindWindow = function(ui, x, y, w, h, withReplace)
{
try
{
if (lblMatch != null && lastFound != null && replaceInput.value)
if (lblMatch != null && lastFound != null)
{
var cell = lastFound.cell, lbl = graph.getLabel(cell);

Expand Down Expand Up @@ -7739,11 +7754,12 @@ var FindWindow = function(ui, x, y, w, h, withReplace)
{
try
{
if (lblMatch != null && lastFound != null && replaceInput.value)
if (lblMatch != null && lastFound != null)
{
var cell = lastFound.cell, lbl = graph.getLabel(cell);

graph.model.setValue(cell, replaceInLabel(lbl, lblMatch, replaceInput.value, lblMatchPos - lblMatch.length, graph.getCurrentCellStyle(cell)));
graph.model.setValue(cell, replaceInLabel(lbl, lblMatch, replaceInput.value,
lblMatchPos - lblMatch.length, graph.getCurrentCellStyle(cell)));
replaceFindBtn.setAttribute('disabled', 'disabled');
replaceBtn.setAttribute('disabled', 'disabled');
}
Expand All @@ -7770,59 +7786,56 @@ var FindWindow = function(ui, x, y, w, h, withReplace)
{
replAllNotif.innerText = '';

if (replaceInput.value)
lastSearch = null; // Reset last search to check all matches
var currentPage = ui.currentPage;
var cells = ui.editor.graph.getSelectionCells();
ui.editor.graph.rendering = false;

graph.getModel().beginUpdate();
try
{
lastSearch = null; // Reset last search to check all matches
var currentPage = ui.currentPage;
var cells = ui.editor.graph.getSelectionCells();
ui.editor.graph.rendering = false;
var safeguard = 0;
var seen = {};

graph.getModel().beginUpdate();
try
while (search(false, true, true) && safeguard < 100)
{
var safeguard = 0;
var seen = {};
var cell = lastFound.cell, lbl = graph.getLabel(cell);
var oldSeen = seen[cell.id];

while (search(false, true, true) && safeguard < 100)
if (oldSeen && oldSeen.replAllMrk == marker && oldSeen.replAllPos >= lblMatchPos)
{
var cell = lastFound.cell, lbl = graph.getLabel(cell);
var oldSeen = seen[cell.id];

if (oldSeen && oldSeen.replAllMrk == marker && oldSeen.replAllPos >= lblMatchPos)
{
break;
}

seen[cell.id] = {replAllMrk: marker, replAllPos: lblMatchPos};

if (graph.isCellEditable(cell))
{
graph.model.setValue(cell, replaceInLabel(lbl, lblMatch, replaceInput.value,
lblMatchPos - lblMatch.length, graph.getCurrentCellStyle(cell)));
safeguard++;
}
break;
}

if (currentPage != ui.currentPage)
seen[cell.id] = {replAllMrk: marker, replAllPos: lblMatchPos};

if (graph.isCellEditable(cell))
{
ui.editor.graph.model.execute(new SelectPage(ui, currentPage));
graph.model.setValue(cell, replaceInLabel(lbl, lblMatch, replaceInput.value,
lblMatchPos - lblMatch.length, graph.getCurrentCellStyle(cell)));
safeguard++;
}

mxUtils.write(replAllNotif, mxResources.get('matchesRepl', [safeguard]));
}
catch (e)
{
ui.handleError(e);
}
finally

if (currentPage != ui.currentPage)
{
graph.getModel().endUpdate();
ui.editor.graph.setSelectionCells(cells);
ui.editor.graph.rendering = true;
ui.editor.graph.model.execute(new SelectPage(ui, currentPage));
}

marker++;
mxUtils.write(replAllNotif, mxResources.get('matchesRepl', [safeguard]));
}
catch (e)
{
ui.handleError(e);
}
finally
{
graph.getModel().endUpdate();
ui.editor.graph.setSelectionCells(cells);
ui.editor.graph.rendering = true;
}

marker++;
});

replaceAllBtn.setAttribute('title', mxResources.get('replaceAll'));
Expand Down Expand Up @@ -12997,9 +13010,7 @@ var FilePropertiesDialog = function(editorUi)
editorUi.hideDialog();
};
}

console.log('here', file.isRealtimeOptional(), file);


if (file != null && file.isRealtimeOptional())
{
row = document.createElement('tr');
Expand Down
28 changes: 25 additions & 3 deletions src/main/webapp/js/diagramly/DrawioFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,32 @@ DrawioFile.prototype.synchronizeFile = function(success, error)
{
if (this.sync != null)
{
this.sync.fileChanged(mxUtils.bind(this, function(patched)
var acceptResponse = true;

var timeoutThread = window.setTimeout(mxUtils.bind(this, function()
{
this.sync.cleanup(success, error, patched);
}), error);
acceptResponse = false;

if (error != null)
{
error({code: App.ERROR_TIMEOUT, message: mxResources.get('timeout'), retry: mxUtils.bind(this, function()
{
this.synchronizeFile(success, error);
})});
}
}), this.ui.timeout);

if (acceptResponse)
{
this.sync.fileChanged(mxUtils.bind(this, function(patched)
{
window.clearTimeout(timeoutThread);
this.sync.cleanup(success, error, patched);
}), error, function()
{
return !acceptResponse;
});
}
}
else
{
Expand Down

0 comments on commit 6add5ed

Please sign in to comment.