mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 10:30:29 +08:00
feature: add new tab menu item
This commit is contained in:
parent
1735b2f7c1
commit
fe6645e684
@ -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
|
||||
|
@ -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')
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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) {
|
||||
|
@ -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')
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user