mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 22:10:24 +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)
|
cap = this.rules.def.exec(src)
|
||||||
if (!bq && top && cap) {
|
if (!bq && top && cap) {
|
||||||
let text = ''
|
let text = ''
|
||||||
while (cap) {
|
do {
|
||||||
src = src.substring(cap[0].length)
|
src = src.substring(cap[0].length)
|
||||||
this.tokens.links[cap[1].toLowerCase()] = {
|
this.tokens.links[cap[1].toLowerCase()] = {
|
||||||
href: cap[2],
|
href: cap[2],
|
||||||
title: cap[3]
|
title: cap[3]
|
||||||
}
|
}
|
||||||
text += cap[0]
|
text += cap[0]
|
||||||
|
if (cap[0].endsWith('\n\n')) break
|
||||||
cap = this.rules.def.exec(src)
|
cap = this.rules.def.exec(src)
|
||||||
}
|
} while (cap)
|
||||||
|
|
||||||
if (this.options.disableInline) {
|
if (this.options.disableInline) {
|
||||||
this.tokens.push({
|
this.tokens.push({
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
text
|
text: text.replace(/\n*$/, '')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
@ -243,6 +243,10 @@ export const newFile = () => {
|
|||||||
appWindow.createWindow()
|
appWindow.createWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const newTab = win => {
|
||||||
|
win.webContents.send('AGANI::new-tab')
|
||||||
|
}
|
||||||
|
|
||||||
export const save = win => {
|
export const save = win => {
|
||||||
win.webContents.send('AGANI::ask-file-save')
|
win.webContents.send('AGANI::ask-file-save')
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,14 @@ export default function (recentlyUsedFiles) {
|
|||||||
click (menuItem, browserWindow) {
|
click (menuItem, browserWindow) {
|
||||||
actions.newFile()
|
actions.newFile()
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
label: 'New Tab',
|
||||||
|
accelerator: 'Shift+CmdOrCtrl+T',
|
||||||
|
click (menuItem, browserWindow) {
|
||||||
|
actions.newTab(browserWindow)
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator'
|
||||||
}, {
|
}, {
|
||||||
label: 'Open File',
|
label: 'Open File',
|
||||||
accelerator: 'CmdOrCtrl+O',
|
accelerator: 'CmdOrCtrl+O',
|
||||||
|
@ -38,7 +38,7 @@ let viewMenu = {
|
|||||||
}, {
|
}, {
|
||||||
id: 'typewriterModeMenuItem',
|
id: 'typewriterModeMenuItem',
|
||||||
label: 'Typewriter Mode',
|
label: 'Typewriter Mode',
|
||||||
accelerator: 'Shift+CmdOrCtrl+T',
|
accelerator: 'Option+CmdOrCtrl+T',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: false,
|
checked: false,
|
||||||
click (item, browserWindow) {
|
click (item, browserWindow) {
|
||||||
|
@ -120,6 +120,7 @@
|
|||||||
dispatch('LISTEN_FOR_INSERT_IMAGE')
|
dispatch('LISTEN_FOR_INSERT_IMAGE')
|
||||||
dispatch('LISTEN_FOR_RENAME')
|
dispatch('LISTEN_FOR_RENAME')
|
||||||
dispatch('LINTEN_FOR_SET_LINE_ENDING')
|
dispatch('LINTEN_FOR_SET_LINE_ENDING')
|
||||||
|
dispatch('LISTEN_FOR_NEW_TAB')
|
||||||
// module: notification
|
// module: notification
|
||||||
dispatch('LISTEN_FOR_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 }) {
|
NEW_BLANK_FILE ({ commit, state, dispatch }) {
|
||||||
const { tabs, lineEnding } = state
|
const { tabs, lineEnding } = state
|
||||||
const fileState = getBlankFileState(tabs, lineEnding)
|
const fileState = getBlankFileState(tabs, lineEnding)
|
||||||
|
Loading…
Reference in New Issue
Block a user