mirror of
https://github.com/marktext/marktext.git
synced 2025-05-10 22:12:29 +08:00
parent
44228b2af6
commit
d4e8bae233
@ -22,7 +22,9 @@ ipcMain.on('mt::ask-for-image-auto-path', (e, { pathname, src, id }) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const edit = (win, type) => {
|
export const edit = (win, type) => {
|
||||||
win.webContents.send('AGANI::edit', { type })
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::edit', { type })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const screenshot = (win, type) => {
|
export const screenshot = (win, type) => {
|
||||||
@ -30,5 +32,7 @@ export const screenshot = (win, type) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const lineEnding = (win, lineEnding) => {
|
export const lineEnding = (win, lineEnding) => {
|
||||||
win.webContents.send('AGANI::set-line-ending', { lineEnding, ignoreSaveStatus: false })
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::set-line-ending', { lineEnding, ignoreSaveStatus: false })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,9 @@ ipcMain.on('AGANI::format-link-click', (e, { data, dirname }) => {
|
|||||||
// --- menu -------------------------------------
|
// --- menu -------------------------------------
|
||||||
|
|
||||||
export const exportFile = (win, type) => {
|
export const exportFile = (win, type) => {
|
||||||
win.webContents.send('mt::show-export-dialog', type)
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('mt::show-export-dialog', type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const importFile = async win => {
|
export const importFile = async win => {
|
||||||
@ -444,6 +446,9 @@ export const importFile = async win => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const print = win => {
|
export const print = win => {
|
||||||
|
if (!win) {
|
||||||
|
return
|
||||||
|
}
|
||||||
// See GH#749, Electron#16085 and Electron#17523.
|
// See GH#749, Electron#16085 and Electron#17523.
|
||||||
dialog.showMessageBox(win, {
|
dialog.showMessageBox(win, {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
@ -492,7 +497,9 @@ export const openFileOrFolder = (win, pathname) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const newBlankTab = win => {
|
export const newBlankTab = win => {
|
||||||
win.webContents.send('mt::new-untitled-tab')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('mt::new-untitled-tab')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const newEditorWindow = () => {
|
export const newEditorWindow = () => {
|
||||||
@ -500,15 +507,21 @@ export const newEditorWindow = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const closeTab = win => {
|
export const closeTab = win => {
|
||||||
win.webContents.send('AGANI::close-tab')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::close-tab')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const save = win => {
|
export const save = win => {
|
||||||
win.webContents.send('AGANI::ask-file-save')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::ask-file-save')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const saveAs = win => {
|
export const saveAs = win => {
|
||||||
win.webContents.send('AGANI::ask-file-save-as')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::ask-file-save-as')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const autoSave = (menuItem, browserWindow) => {
|
export const autoSave = (menuItem, browserWindow) => {
|
||||||
@ -517,11 +530,15 @@ export const autoSave = (menuItem, browserWindow) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const moveTo = win => {
|
export const moveTo = win => {
|
||||||
win.webContents.send('AGANI::ask-file-move-to')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::ask-file-move-to')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rename = win => {
|
export const rename = win => {
|
||||||
win.webContents.send('AGANI::ask-file-rename')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::ask-file-rename')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const clearRecentlyUsed = () => {
|
export const clearRecentlyUsed = () => {
|
||||||
|
@ -9,12 +9,9 @@ const MENU_ID_FORMAT_MAP = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const format = (win, type) => {
|
export const format = (win, type) => {
|
||||||
// Fix #961
|
if (win && win.webContents) {
|
||||||
// TODO: This is not the best solution for fix #961, but we don't know how to reproduce this issue.
|
win.webContents.send('AGANI::format', { type })
|
||||||
if (!win) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
win.webContents.send('AGANI::format', { type })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- IPC events -------------------------------------------------------------
|
// --- IPC events -------------------------------------------------------------
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
export const showAboutDialog = win => {
|
export const showAboutDialog = win => {
|
||||||
win.webContents.send('AGANI::about-dialog')
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::about-dialog')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const showTweetDialog = (win, type) => {
|
export const showTweetDialog = (win, type) => {
|
||||||
win.webContents.send('AGANI::tweet', type)
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::tweet', type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ const MENU_ID_MAP = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const paragraph = (win, type) => {
|
export const paragraph = (win, type) => {
|
||||||
win.webContents.send('AGANI::paragraph', { type })
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::paragraph', { type })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- IPC events -------------------------------------------------------------
|
// --- IPC events -------------------------------------------------------------
|
||||||
|
@ -4,6 +4,9 @@ const typewriterModeMenuItemId = 'typewriterModeMenuItem'
|
|||||||
const focusModeMenuItemId = 'focusModeMenuItem'
|
const focusModeMenuItemId = 'focusModeMenuItem'
|
||||||
|
|
||||||
export const typeMode = (win, type, item) => {
|
export const typeMode = (win, type, item) => {
|
||||||
|
if (!win) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const { checked } = item
|
const { checked } = item
|
||||||
win.webContents.send('AGANI::view', { type, checked })
|
win.webContents.send('AGANI::view', { type, checked })
|
||||||
|
|
||||||
@ -16,7 +19,9 @@ export const typeMode = (win, type, item) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const layout = (item, win, type) => {
|
export const layout = (item, win, type) => {
|
||||||
win.webContents.send('AGANI::listen-for-view-layout', { [type]: item.checked })
|
if (win && win.webContents) {
|
||||||
|
win.webContents.send('AGANI::listen-for-view-layout', { [type]: item.checked })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const showTabBar = win => {
|
export const showTabBar = win => {
|
||||||
|
Loading…
Reference in New Issue
Block a user