Skip to content

Commit 993f00c

Browse files
feat(editor): Allow specifying a custom app name in the about dialog
1 parent 60862c7 commit 993f00c

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

docs/demo/example.ts

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ const createEditor = async (
3939
const editor = new Editor(parentElement, {
4040
keyboardShortcutOverrides: loadKeybindingOverrides(),
4141
iconProvider: new MaterialIconProvider(),
42+
43+
appInfo: {
44+
name: 'js-draw demo',
45+
version: '1.2.3',
46+
},
4247
});
4348

4449
const { hasChanges } = watchForChanges(editor, appNotifier);

packages/js-draw/src/Editor.ts

+33-3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ export interface EditorSettings {
8888
* Additional messages to show in the "about" dialog.
8989
*/
9090
notices: AboutDialogEntry[],
91+
92+
/**
93+
* Information about the app/website js-draw is running within
94+
* to show at the beginning of the about dialog.
95+
*/
96+
appInfo: {
97+
name: string,
98+
version?: string,
99+
}|null,
91100
}
92101

93102
/**
@@ -242,6 +251,7 @@ export class Editor {
242251
keyboardShortcutOverrides: settings.keyboardShortcutOverrides ?? {},
243252
iconProvider: settings.iconProvider ?? new IconProvider(),
244253
notices: [],
254+
appInfo: settings.appInfo ? { ...settings.appInfo } : null,
245255
};
246256

247257
// Validate settings
@@ -1514,16 +1524,36 @@ export class Editor {
15141524
const iconLicenseText = this.icons.licenseInfo();
15151525

15161526
const notices: AboutDialogEntry[] = [];
1527+
1528+
if (this.settings.appInfo) {
1529+
const versionLines = [];
1530+
if (this.settings.appInfo.version) {
1531+
versionLines.push(`v${this.settings.appInfo.version}`, '');
1532+
}
1533+
1534+
notices.push({
1535+
heading: `${this.settings.appInfo.name}`,
1536+
text: [
1537+
...versionLines,
1538+
`Powered by js-draw v${version.number}.`,
1539+
].join('\n'),
1540+
});
1541+
} else {
1542+
notices.push({
1543+
heading: 'js-draw',
1544+
text: `v${version.number}`,
1545+
});
1546+
}
1547+
15171548
notices.push({
1518-
heading: 'js-draw',
1549+
heading: 'Developer information',
15191550
text: [
1520-
`v${version.number}`,
1521-
'',
15221551
'Image debug information (from when this dialog was opened):',
15231552
` ${this.viewport.getScaleFactor()}x zoom, ${180/Math.PI * this.viewport.getRotationAngle()} rotation`,
15241553
` ${this.image.estimateNumElements()} components`,
15251554
` ${this.getImportExportRect().w}x${this.getImportExportRect().h} size`,
15261555
].join('\n'),
1556+
minimized: true,
15271557
});
15281558

15291559
notices.push({

0 commit comments

Comments
 (0)