Merge branch 'dev' of github.com:jgraph/drawio-desktop into dev

This commit is contained in:
Mohamed Mohamedin 2025-05-09 13:06:55 -04:00
commit edd5c53f09
2 changed files with 21 additions and 9 deletions

4
.gitignore vendored
View File

@ -3,4 +3,6 @@ node_modules
.project .project
/dist/ /dist/
/.classpath /.classpath
/.settings /.settings
package-lock.json
.DS_Store

View File

@ -437,9 +437,9 @@ app.whenReady().then(() =>
var themeRegExp = /^(dark|light)$/; var themeRegExp = /^(dark|light)$/;
var linkTargetRegExp = /^(auto|new-win|same-win)$/; var linkTargetRegExp = /^(auto|new-win|same-win)$/;
function argsRange(val) function argsRange(val)
{ {
return val.split('..').map(Number); return val.split('..').map(n => parseInt(n, 10) - 1);
} }
try try
@ -481,11 +481,11 @@ app.whenReady().then(() =>
.option('-a, --all-pages', .option('-a, --all-pages',
'export all pages (for PDF format only)') 'export all pages (for PDF format only)')
.option('-p, --page-index <pageIndex>', .option('-p, --page-index <pageIndex>',
'selects a specific page, if not specified and the format is an image, the first page is selected', parseInt) 'selects a specific page (1-based); if not specified and the format is an image, the first page is selected', (i) => parseInt(i) - 1)
.option('-l, --layers <comma separated layer indexes>', .option('-l, --layers <comma separated layer indexes>',
'selects which layers to export (applies to all pages), if not specified, all layers are selected') 'selects which layers to export (applies to all pages), if not specified, all layers are selected')
.option('-g, --page-range <from>..<to>', .option('-g, --page-range <from>..<to>',
'selects a page range (for PDF format only)', argsRange) 'selects a page range (1-based, for PDF format only)', argsRange)
.option('-u, --uncompressed', .option('-u, --uncompressed',
'Uncompressed XML output (for XML format only)') 'Uncompressed XML output (for XML format only)')
.option('-z, --zoom <zoom>', .option('-z, --zoom <zoom>',
@ -571,7 +571,7 @@ app.whenReady().then(() =>
format = options.format; format = options.format;
} }
var from = null, to = null; let from = null, to = null;
if (options.pageIndex != null && options.pageIndex >= 0) if (options.pageIndex != null && options.pageIndex >= 0)
{ {
@ -581,9 +581,19 @@ app.whenReady().then(() =>
} }
else if (options.pageRange && options.pageRange.length == 2) else if (options.pageRange && options.pageRange.length == 2)
{ {
from = options.pageRange[0] >= 0 ? options.pageRange[0] : null; const [rangeFrom, rangeTo] = options.pageRange;
to = options.pageRange[1] >= 0 ? options.pageRange[1] : null;
options.allPages = false; if (rangeFrom >= 0 && rangeTo >= 0 && rangeFrom <= rangeTo)
{
from = rangeFrom;
to = rangeTo;
options.allPages = false;
}
else
{
console.error('Invalid page range: must be non-negative and from ≤ to');
process.exit(1);
}
} }
var expArgs = { var expArgs = {