You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-27 23:28:38 +02:00
Desktop: Simplified and improve command service, and added command palette
- Commands "enabled" state is now expressed using a "when-clause" like in VSCode - A command palette has been added to the Tools menu
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
import { stateUtils } from 'lib/reducer';
|
||||
|
||||
const BaseModel = require('lib/BaseModel');
|
||||
const Folder = require('lib/models/Folder');
|
||||
const MarkupToHtml = require('lib/joplin-renderer/MarkupToHtml');
|
||||
|
||||
export default function stateToWhenClauseContext(state:any) {
|
||||
const noteId = state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null;
|
||||
const note = noteId ? BaseModel.byId(state.notes, noteId) : null;
|
||||
|
||||
return {
|
||||
// UI elements
|
||||
markdownEditorVisible: !!state.settings['editor.codeView'],
|
||||
richTextEditorVisible: !state.settings['editor.codeView'],
|
||||
markdownEditorPaneVisible: state.settings['editor.codeView'] && state.noteVisiblePanes.includes('editor'),
|
||||
markdownViewerPaneVisible: state.settings['editor.codeView'] && state.noteVisiblePanes.includes('viewer'),
|
||||
modalDialogVisible: !!Object.keys(state.visibleDialogs).length,
|
||||
sideBarVisible: !!state.sidebarVisibility,
|
||||
noteListHasNotes: !!state.notes.length,
|
||||
|
||||
// Application state
|
||||
notesAreBeingSaved: stateUtils.hasNotesBeingSaved(state),
|
||||
syncStarted: state.syncStarted,
|
||||
|
||||
// Current location
|
||||
inConflictFolder: state.selectedFolderId === Folder.conflictFolderId(),
|
||||
|
||||
// Note selection
|
||||
oneNoteSelected: !!note,
|
||||
someNotesSelected: state.selectedNoteIds.length > 0,
|
||||
multipleNotesSelected: state.selectedNoteIds.length > 1,
|
||||
noNotesSelected: !state.selectedNoteIds.length,
|
||||
|
||||
// Note history
|
||||
historyhasBackwardNotes: state.backwardHistoryNotes.length > 0,
|
||||
historyhasForwardNotes: state.forwardHistoryNotes.length > 0,
|
||||
|
||||
// Folder selection
|
||||
oneFolderSelected: !!state.selectedFolderId,
|
||||
|
||||
// Current note properties
|
||||
noteIsTodo: note ? !!note.is_todo : false,
|
||||
noteTodoCompleted: note ? !!note.todo_completed : false,
|
||||
noteIsMarkdown: note ? note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN : false,
|
||||
noteIsHtml: note ? note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_HTML : false,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user