feature: add new tab menu item

This commit is contained in:
Jocs 2018-06-11 19:20:09 +08:00
parent 1735b2f7c1
commit fe6645e684
6 changed files with 25 additions and 4 deletions

View File

@ -325,19 +325,21 @@ Lexer.prototype.token = function (src, top, bq) {
cap = this.rules.def.exec(src)
if (!bq && top && cap) {
let text = ''
while (cap) {
do {
src = src.substring(cap[0].length)
this.tokens.links[cap[1].toLowerCase()] = {
href: cap[2],
title: cap[3]
}
text += cap[0]
if (cap[0].endsWith('\n\n')) break
cap = this.rules.def.exec(src)
}
} while (cap)
if (this.options.disableInline) {
this.tokens.push({
type: 'paragraph',
text
text: text.replace(/\n*$/, '')
})
}
continue

View File

@ -243,6 +243,10 @@ export const newFile = () => {
appWindow.createWindow()
}
export const newTab = win => {
win.webContents.send('AGANI::new-tab')
}
export const save = win => {
win.webContents.send('AGANI::ask-file-save')
}

View File

@ -14,6 +14,14 @@ export default function (recentlyUsedFiles) {
click (menuItem, browserWindow) {
actions.newFile()
}
}, {
label: 'New Tab',
accelerator: 'Shift+CmdOrCtrl+T',
click (menuItem, browserWindow) {
actions.newTab(browserWindow)
}
}, {
type: 'separator'
}, {
label: 'Open File',
accelerator: 'CmdOrCtrl+O',

View File

@ -38,7 +38,7 @@ let viewMenu = {
}, {
id: 'typewriterModeMenuItem',
label: 'Typewriter Mode',
accelerator: 'Shift+CmdOrCtrl+T',
accelerator: 'Option+CmdOrCtrl+T',
type: 'checkbox',
checked: false,
click (item, browserWindow) {

View File

@ -120,6 +120,7 @@
dispatch('LISTEN_FOR_INSERT_IMAGE')
dispatch('LISTEN_FOR_RENAME')
dispatch('LINTEN_FOR_SET_LINE_ENDING')
dispatch('LISTEN_FOR_NEW_TAB')
// module: notification
dispatch('LISTEN_FOR_NOTIFICATION')
}

View File

@ -293,6 +293,12 @@ const actions = {
})
},
LISTEN_FOR_NEW_TAB ({ dispatch }) {
ipcRenderer.on('AGANI::new-tab', e => {
dispatch('NEW_BLANK_FILE')
})
},
NEW_BLANK_FILE ({ commit, state, dispatch }) {
const { tabs, lineEnding } = state
const fileState = getBlankFileState(tabs, lineEnding)