You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Mobile: Editor: Switch to a scrolling toolbar, allow adding/removing toolbar items (#11472)
This commit is contained in:
@ -1,14 +1,28 @@
|
||||
import { EditorCommandType } from '@joplin/editor/types';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { CommandDeclaration } from '@joplin/lib/services/CommandService';
|
||||
|
||||
export const enabledCondition = (_commandName: string) => {
|
||||
const output = [
|
||||
'!modalDialogVisible',
|
||||
'!noteIsReadOnly',
|
||||
];
|
||||
|
||||
return output.filter(c => !!c).join(' && ');
|
||||
};
|
||||
|
||||
const headerDeclarations = () => {
|
||||
const result: CommandDeclaration[] = [];
|
||||
for (let level = 1; level <= 5; level++) {
|
||||
result.push({
|
||||
name: `editor.textHeading${level}`,
|
||||
iconName: `material format-header-${level}`,
|
||||
label: () => _('Header %d', level),
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const declarations: CommandDeclaration[] = [
|
||||
{
|
||||
name: 'insertText',
|
||||
@ -34,6 +48,65 @@ const declarations: CommandDeclaration[] = [
|
||||
{
|
||||
name: 'editor.execCommand',
|
||||
},
|
||||
|
||||
{
|
||||
name: EditorCommandType.ToggleBolded,
|
||||
label: () => _('Bold'),
|
||||
iconName: 'material format-bold',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.ToggleItalicized,
|
||||
label: () => _('Italic'),
|
||||
iconName: 'material format-italic',
|
||||
},
|
||||
...headerDeclarations(),
|
||||
{
|
||||
name: EditorCommandType.ToggleCode,
|
||||
label: () => _('Code'),
|
||||
iconName: 'material code-json',
|
||||
},
|
||||
{
|
||||
// The 'editor.' prefix needs to be included because ToggleMath is not a legacy
|
||||
// editor command. Without this, ToggleMath is not recognised as an editor command.
|
||||
name: `editor.${EditorCommandType.ToggleMath}`,
|
||||
label: () => _('Math'),
|
||||
iconName: 'material sigma',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.ToggleNumberedList,
|
||||
label: () => _('Ordered list'),
|
||||
iconName: 'material format-list-numbered',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.ToggleBulletedList,
|
||||
label: () => _('Unordered list'),
|
||||
iconName: 'material format-list-bulleted',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.ToggleCheckList,
|
||||
label: () => _('Task list'),
|
||||
iconName: 'material format-list-checks',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.IndentLess,
|
||||
label: () => _('Decrease indent level'),
|
||||
iconName: 'ant indent-left',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.IndentMore,
|
||||
label: () => _('Increase indent level'),
|
||||
iconName: 'ant indent-right',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.ToggleSearch,
|
||||
label: () => _('Search'),
|
||||
iconName: 'material magnify',
|
||||
},
|
||||
{
|
||||
name: EditorCommandType.EditLink,
|
||||
label: () => _('Link'),
|
||||
iconName: 'material link',
|
||||
},
|
||||
];
|
||||
|
||||
export default declarations;
|
||||
|
Reference in New Issue
Block a user