mirror of
https://github.com/heyman/heynote.git
synced 2025-02-02 03:20:06 +01:00
Use block aware "Select All" command in context menu and app menu
This commit is contained in:
parent
3107cb5368
commit
449b0a569f
@ -1,5 +1,5 @@
|
|||||||
const { app, Menu } = require("electron")
|
const { app, Menu } = require("electron")
|
||||||
import { OPEN_SETTINGS_EVENT, UNDO_EVENT, REDO_EVENT, MOVE_BLOCK_EVENT, DELETE_BLOCK_EVENT, CHANGE_BUFFER_EVENT } from '@/src/common/constants'
|
import { OPEN_SETTINGS_EVENT, UNDO_EVENT, REDO_EVENT, MOVE_BLOCK_EVENT, DELETE_BLOCK_EVENT, CHANGE_BUFFER_EVENT, SELECT_ALL_EVENT } from '@/src/common/constants'
|
||||||
import { openAboutWindow } from "./about";
|
import { openAboutWindow } from "./about";
|
||||||
import { quit } from "./index"
|
import { quit } from "./index"
|
||||||
|
|
||||||
@ -22,6 +22,14 @@ const redoMenuItem = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectAllMenuItem = {
|
||||||
|
label: 'Select All',
|
||||||
|
accelerator: 'CommandOrControl+a',
|
||||||
|
click: (menuItem, window, event) => {
|
||||||
|
window?.webContents.send(SELECT_ALL_EVENT)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
const deleteBlockMenuItem = {
|
const deleteBlockMenuItem = {
|
||||||
label: 'Delete block',
|
label: 'Delete block',
|
||||||
accelerator: 'CommandOrControl+Shift+D',
|
accelerator: 'CommandOrControl+Shift+D',
|
||||||
@ -117,7 +125,7 @@ const template = [
|
|||||||
...(isMac ? [
|
...(isMac ? [
|
||||||
{ role: 'pasteAndMatchStyle' },
|
{ role: 'pasteAndMatchStyle' },
|
||||||
{ role: 'delete' },
|
{ role: 'delete' },
|
||||||
{ role: 'selectAll' },
|
selectAllMenuItem,
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: 'Speech',
|
label: 'Speech',
|
||||||
@ -129,7 +137,7 @@ const template = [
|
|||||||
] : [
|
] : [
|
||||||
{ role: 'delete' },
|
{ role: 'delete' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ role: 'selectAll' }
|
selectAllMenuItem,
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -226,7 +234,7 @@ export function getEditorContextMenu(win) {
|
|||||||
{role: 'copy'},
|
{role: 'copy'},
|
||||||
{role: 'paste'},
|
{role: 'paste'},
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
{role: 'selectAll'},
|
selectAllMenuItem,
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
deleteBlockMenuItem,
|
deleteBlockMenuItem,
|
||||||
moveBlockMenuItem,
|
moveBlockMenuItem,
|
||||||
|
@ -9,6 +9,7 @@ export const UNDO_EVENT = "undo"
|
|||||||
export const MOVE_BLOCK_EVENT = "move-block"
|
export const MOVE_BLOCK_EVENT = "move-block"
|
||||||
export const DELETE_BLOCK_EVENT = "delete-block"
|
export const DELETE_BLOCK_EVENT = "delete-block"
|
||||||
export const CHANGE_BUFFER_EVENT = "change-buffer"
|
export const CHANGE_BUFFER_EVENT = "change-buffer"
|
||||||
|
export const SELECT_ALL_EVENT = "select-all"
|
||||||
|
|
||||||
export const UPDATE_AVAILABLE_EVENT = "update-available"
|
export const UPDATE_AVAILABLE_EVENT = "update-available"
|
||||||
export const UPDATE_NOT_AVAILABLE_EVENT = "update-not-available"
|
export const UPDATE_NOT_AVAILABLE_EVENT = "update-not-available"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import { useErrorStore } from "../stores/error-store"
|
import { useErrorStore } from "../stores/error-store"
|
||||||
import { useHeynoteStore } from "../stores/heynote-store.js"
|
import { useHeynoteStore } from "../stores/heynote-store.js"
|
||||||
import { useEditorCacheStore } from "../stores/editor-cache"
|
import { useEditorCacheStore } from "../stores/editor-cache"
|
||||||
import { REDO_EVENT, WINDOW_CLOSE_EVENT, DELETE_BLOCK_EVENT, UNDO_EVENT } from '@/src/common/constants';
|
import { REDO_EVENT, WINDOW_CLOSE_EVENT, DELETE_BLOCK_EVENT, UNDO_EVENT, SELECT_ALL_EVENT } from '@/src/common/constants';
|
||||||
|
|
||||||
const NUM_EDITOR_INSTANCES = 5
|
const NUM_EDITOR_INSTANCES = 5
|
||||||
|
|
||||||
@ -57,6 +57,12 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.heynote.mainProcess.on(SELECT_ALL_EVENT, () => {
|
||||||
|
if (this.editor) {
|
||||||
|
toRaw(this.editor).selectAll()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// if debugSyntaxTree prop is set, display syntax tree for debugging
|
// if debugSyntaxTree prop is set, display syntax tree for debugging
|
||||||
if (this.debugSyntaxTree) {
|
if (this.debugSyntaxTree) {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
@ -82,6 +88,7 @@
|
|||||||
window.heynote.mainProcess.off(UNDO_EVENT)
|
window.heynote.mainProcess.off(UNDO_EVENT)
|
||||||
window.heynote.mainProcess.off(REDO_EVENT)
|
window.heynote.mainProcess.off(REDO_EVENT)
|
||||||
window.heynote.mainProcess.off(DELETE_BLOCK_EVENT)
|
window.heynote.mainProcess.off(DELETE_BLOCK_EVENT)
|
||||||
|
window.heynote.mainProcess.off(SELECT_ALL_EVENT)
|
||||||
this.editorCacheStore.tearDown();
|
this.editorCacheStore.tearDown();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import { customSetup } from "./setup.js"
|
|||||||
import { heynoteLang } from "./lang-heynote/heynote.js"
|
import { heynoteLang } from "./lang-heynote/heynote.js"
|
||||||
import { noteBlockExtension, blockLineNumbers, blockState, getActiveNoteBlock, triggerCursorChange } from "./block/block.js"
|
import { noteBlockExtension, blockLineNumbers, blockState, getActiveNoteBlock, triggerCursorChange } from "./block/block.js"
|
||||||
import { heynoteEvent, SET_CONTENT, DELETE_BLOCK, APPEND_BLOCK } from "./annotation.js";
|
import { heynoteEvent, SET_CONTENT, DELETE_BLOCK, APPEND_BLOCK } from "./annotation.js";
|
||||||
import { changeCurrentBlockLanguage, triggerCurrenciesLoaded, getBlockDelimiter, deleteBlock } from "./block/commands.js"
|
import { changeCurrentBlockLanguage, triggerCurrenciesLoaded, getBlockDelimiter, deleteBlock, selectAll } from "./block/commands.js"
|
||||||
import { formatBlockContent } from "./block/format-code.js"
|
import { formatBlockContent } from "./block/format-code.js"
|
||||||
import { heynoteKeymap } from "./keymap.js"
|
import { heynoteKeymap } from "./keymap.js"
|
||||||
import { emacsKeymap } from "./emacs.js"
|
import { emacsKeymap } from "./emacs.js"
|
||||||
@ -413,6 +413,10 @@ export class HeynoteEditor {
|
|||||||
redo() {
|
redo() {
|
||||||
redo(this.view)
|
redo(this.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectAll() {
|
||||||
|
selectAll(this.view)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user