一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
37 行
1.8 KiB
TypeScript
37 行
1.8 KiB
TypeScript
// This extends the generic stateToWhenClauseContext (potentially shared by
|
|
// all apps) with additional properties specific to the desktop app. So in
|
|
// general, any desktop component should import this file, and not the lib
|
|
// one.
|
|
|
|
import { AppState } from '../../app.reducer';
|
|
import libStateToWhenClauseContext, { WhenClauseContextOptions } from '@joplin/lib/services/commands/stateToWhenClauseContext';
|
|
import layoutItemProp from '../../gui/ResizableLayout/utils/layoutItemProp';
|
|
import { defaultWindowId, stateUtils } from '@joplin/lib/reducer';
|
|
|
|
export default function stateToWhenClauseContext(state: AppState, options: WhenClauseContextOptions = null) {
|
|
const windowId = options?.windowId ?? defaultWindowId;
|
|
const isMainWindow = windowId === defaultWindowId;
|
|
const windowState = stateUtils.windowStateById(state, windowId);
|
|
const isAltInstance = !!state.settings.altInstanceId;
|
|
|
|
return {
|
|
...libStateToWhenClauseContext(state, options),
|
|
|
|
// UI elements
|
|
markdownEditorVisible: !!windowState.editorCodeView && !state.settings['isSafeMode'],
|
|
richTextEditorVisible: !windowState.editorCodeView && !state.settings['isSafeMode'],
|
|
|
|
markdownEditorPaneVisible: windowState.editorCodeView && windowState.noteVisiblePanes.includes('editor'),
|
|
markdownViewerPaneVisible: windowState.editorCodeView && windowState.noteVisiblePanes.includes('viewer'),
|
|
modalDialogVisible: !!Object.keys(state.visibleDialogs).length,
|
|
gotoAnythingVisible: !!state.visibleDialogs['gotoAnything'],
|
|
sidebarVisible: isMainWindow && !!state.mainLayout && layoutItemProp(state.mainLayout, 'sideBar', 'visible'),
|
|
noteListHasNotes: !!windowState.notes.length,
|
|
isAltInstance,
|
|
activeNoteIsWhiteboard: !!windowState.activeNoteIsWhiteboard,
|
|
|
|
// Deprecated
|
|
sideBarVisible: !!state.mainLayout && layoutItemProp(state.mainLayout, 'sideBar', 'visible'),
|
|
};
|
|
}
|