文件
mynode/packages/app-mobile/components/EditorToolbar/utils/allToolbarCommandNamesFromState.ts
chen 301194963b
一些检查失败了
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
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

70 行
2.0 KiB
TypeScript

import { AppState } from '../../../utils/types';
import { utils as pluginUtils } from '@joplin/lib/services/plugins/reducer';
import { EditorCommandType } from '@joplin/editor/types';
const builtInCommandNames = [
'attachFile',
'synchronize',
'-',
'editor.textHeading1',
'editor.textHeading2',
'editor.textHeading3',
'editor.textHeading4',
'editor.textHeading5',
EditorCommandType.ToggleBolded,
EditorCommandType.ToggleItalicized,
'-',
EditorCommandType.ToggleCode,
`editor.${EditorCommandType.ToggleMath}`,
'-',
EditorCommandType.ToggleNumberedList,
EditorCommandType.ToggleBulletedList,
EditorCommandType.ToggleCheckList,
'-',
`editor.${EditorCommandType.ToggleBlockQuote}`,
`editor.${EditorCommandType.InsertTable}`,
`editor.${EditorCommandType.InsertCodeBlock}`,
'-',
EditorCommandType.IndentLess,
EditorCommandType.IndentMore,
`editor.${EditorCommandType.SwapLineDown}`,
`editor.${EditorCommandType.SwapLineUp}`,
`editor.${EditorCommandType.DeleteLine}`,
`editor.${EditorCommandType.DuplicateLine}`,
`editor.${EditorCommandType.SortSelectedLines}`,
'-',
'insertDateTime',
'-',
EditorCommandType.EditLink,
'setTags',
EditorCommandType.ToggleSearch,
'hideKeyboard',
'-',
`editor.${EditorCommandType.GoDocStart}`,
`editor.${EditorCommandType.GoDocEnd}`,
];
const allToolbarCommandNamesFromState = (state: AppState) => {
const pluginCommandNames = pluginUtils.commandNamesFromViews(state.pluginService.plugins, 'editorToolbar');
let allCommandNames = builtInCommandNames;
if (pluginCommandNames.length > 0) {
allCommandNames = allCommandNames.concat(['-'], pluginCommandNames);
}
// If the user disables math markup, the "toggle math" button won't be useful.
// Disabling the math markup button maintains compatibility with the previous
// toolbar.
const mathEnabled = state.settings['markdown.plugin.katex'];
if (!mathEnabled) {
allCommandNames = allCommandNames.filter(
name => name !== `editor.${EditorCommandType.ToggleMath}`,
);
}
return allCommandNames;
};
export default allToolbarCommandNamesFromState;