一些检查失败了
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
40 行
1.4 KiB
TypeScript
40 行
1.4 KiB
TypeScript
import { EditorCommandType } from '@joplin/editor/types';
|
|
import { AppState } from '../../../utils/types';
|
|
import allToolbarCommandNamesFromState from './allToolbarCommandNamesFromState';
|
|
import { Platform } from 'react-native';
|
|
|
|
const omitFromDefault: string[] = [
|
|
'synchronize',
|
|
'editor.textHeading1',
|
|
'editor.textHeading3',
|
|
'editor.textHeading4',
|
|
'editor.textHeading5',
|
|
`editor.${EditorCommandType.SwapLineDown}`,
|
|
`editor.${EditorCommandType.SwapLineUp}`,
|
|
`editor.${EditorCommandType.DeleteLine}`,
|
|
`editor.${EditorCommandType.DuplicateLine}`,
|
|
`editor.${EditorCommandType.SortSelectedLines}`,
|
|
`editor.${EditorCommandType.GoDocStart}`,
|
|
`editor.${EditorCommandType.GoDocEnd}`,
|
|
];
|
|
|
|
// The "hide keyboard" button is only needed on iOS, so only show it there by default.
|
|
// (There's no default "dismiss" button on iPhone software keyboards).
|
|
if (Platform.OS !== 'ios') {
|
|
omitFromDefault.push('hideKeyboard');
|
|
}
|
|
|
|
const selectedCommandNamesFromState = (state: AppState) => {
|
|
const allCommandNames = allToolbarCommandNamesFromState(state);
|
|
const defaultCommandNames = allCommandNames.filter(commandName => {
|
|
return !omitFromDefault.includes(commandName);
|
|
});
|
|
|
|
const commandNameSetting = state.settings['editor.toolbarButtons'] ?? [];
|
|
const selectedCommands = commandNameSetting.length > 0 ? commandNameSetting : defaultCommandNames;
|
|
|
|
return selectedCommands.filter(command => allCommandNames.includes(command));
|
|
};
|
|
|
|
export default selectedCommandNamesFromState;
|