diff --git a/app/main.js b/app/main.js index 190643c11..73411f8bc 100644 --- a/app/main.js +++ b/app/main.js @@ -9,7 +9,6 @@ const { BrowserWindow, Menu, ipcMain } = electron const DEBUG = process.env.DEBUG -const BLANK_DOCUMENT = path.join(__dirname, 'templates', 'blank.dar') const tmpDir = app.getPath('temp') const darStorageFolder = path.join(tmpDir, app.getName(), 'dar-storage') @@ -18,6 +17,13 @@ fsExtra.ensureDirSync(darStorageFolder) const windowStates = new Map() const isDAR = path => Boolean(/.dar$/i.exec(path)) +const BLANK_DOCUMENT = path.join(__dirname, 'templates', 'blank.dar') +const BLANK_FIGURE_PACKAGE = path.join(__dirname, 'templates', 'blank-figure-package.dar') +const templates = { + 'article': BLANK_DOCUMENT, + 'figure-package': BLANK_FIGURE_PACKAGE +} + app.on('ready', () => { protocol.registerFileProtocol('dar', (request, handler) => { const resourcePath = path.normalize(request.url.substr(6)) @@ -180,8 +186,10 @@ function promptOpen () { }) } -function openNew () { - createEditorWindow(BLANK_DOCUMENT, true) +function openNew (templateId) { + templateId = templateId || 'article' + const template = templates[templateId] + createEditorWindow(template, true) } // used to dispatch save requests from the menu to the window @@ -209,10 +217,21 @@ function createMenu () { submenu: [ { label: 'New', - accelerator: 'CommandOrControl+N', - click () { - openNew() - } + submenu: [ + { + label: 'Article', + accelerator: 'CommandOrControl+N', + click () { + openNew('article') + } + }, + { + label: 'Figure Pacakge', + click () { + openNew('figure-package') + } + } + ] }, { label: 'Open', diff --git a/app/templates/blank-figure-package.dar b/app/templates/blank-figure-package.dar new file mode 100644 index 000000000..a74ddcd22 Binary files /dev/null and b/app/templates/blank-figure-package.dar differ