2020-11-07 17:59:37 +02:00
|
|
|
import { CommandDeclaration } from '@joplin/lib/services/CommandService';
|
|
|
|
import { _ } from '@joplin/lib/locale';
|
2023-07-16 18:42:42 +02:00
|
|
|
import { joplinCommandToTinyMceCommands } from './NoteBody/TinyMCE/utils/joplinCommandToTinyMceCommands';
|
|
|
|
|
2023-10-31 18:53:47 +02:00
|
|
|
const workWithHtmlNotes = [
|
|
|
|
'attachFile',
|
|
|
|
];
|
|
|
|
|
2023-07-16 18:42:42 +02:00
|
|
|
export const enabledCondition = (commandName: string) => {
|
|
|
|
const markdownEditorOnly = !Object.keys(joplinCommandToTinyMceCommands).includes(commandName);
|
2023-10-31 18:53:47 +02:00
|
|
|
const noteMustBeMarkdown = !workWithHtmlNotes.includes(commandName);
|
2023-11-09 16:58:38 +02:00
|
|
|
|
|
|
|
const output = [
|
|
|
|
'!modalDialogVisible',
|
|
|
|
'!gotoAnythingVisible',
|
|
|
|
markdownEditorOnly ? 'markdownEditorPaneVisible' : '(markdownEditorPaneVisible || richTextEditorVisible)',
|
|
|
|
'oneNoteSelected',
|
|
|
|
noteMustBeMarkdown ? 'noteIsMarkdown' : '',
|
|
|
|
'!noteIsReadOnly',
|
|
|
|
];
|
|
|
|
|
|
|
|
return output.filter(c => !!c).join(' && ');
|
2023-07-16 18:42:42 +02:00
|
|
|
};
|
2020-07-03 23:32:39 +02:00
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
const declarations: CommandDeclaration[] = [
|
2020-07-03 23:32:39 +02:00
|
|
|
{
|
|
|
|
name: 'insertText',
|
|
|
|
},
|
2020-10-09 19:35:46 +02:00
|
|
|
{
|
|
|
|
name: 'scrollToHash',
|
|
|
|
},
|
2020-07-03 23:32:39 +02:00
|
|
|
{
|
|
|
|
name: 'textCopy',
|
|
|
|
label: () => _('Copy'),
|
|
|
|
role: 'copy',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textCut',
|
|
|
|
label: () => _('Cut'),
|
|
|
|
role: 'cut',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textPaste',
|
|
|
|
label: () => _('Paste'),
|
|
|
|
role: 'paste',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textSelectAll',
|
|
|
|
label: () => _('Select all'),
|
|
|
|
role: 'selectAll',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textBold',
|
|
|
|
label: () => _('Bold'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-bold',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textItalic',
|
|
|
|
label: () => _('Italic'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-italic',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textLink',
|
|
|
|
label: () => _('Hyperlink'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-link',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textCode',
|
|
|
|
label: () => _('Code'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-code',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'attachFile',
|
|
|
|
label: () => _('Attach file'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-attachment',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textNumberedList',
|
|
|
|
label: () => _('Numbered List'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-numbered-list',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textBulletedList',
|
|
|
|
label: () => _('Bulleted List'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-bulleted-list',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textCheckbox',
|
|
|
|
label: () => _('Checkbox'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-to-do-list',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textHeading',
|
|
|
|
label: () => _('Heading'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-heading',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'textHorizontalRule',
|
|
|
|
label: () => _('Horizontal Rule'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'fas fa-ellipsis-h',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'insertDateTime',
|
2022-10-30 20:37:58 +02:00
|
|
|
label: () => _('Insert time'),
|
2020-09-15 15:01:07 +02:00
|
|
|
iconName: 'icon-add-date',
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
2020-12-19 19:57:41 +02:00
|
|
|
{
|
|
|
|
name: 'editor.deleteLine',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Delete line'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
2021-04-25 10:57:35 +02:00
|
|
|
{
|
|
|
|
name: 'editor.duplicateLine',
|
|
|
|
label: () => _('Duplicate line'),
|
|
|
|
},
|
2020-12-19 19:57:41 +02:00
|
|
|
{
|
|
|
|
name: 'editor.undo',
|
2022-03-03 15:53:11 +02:00
|
|
|
label: () => _('Editor: %s', _('Undo')),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.redo',
|
2022-03-03 15:53:11 +02:00
|
|
|
label: () => _('Editor: %s', _('Redo')),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.indentLess',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Indent less'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.indentMore',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Indent more'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.toggleComment',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Toggle comment'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.sortSelectedLines',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Sort selected lines'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.swapLineUp',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Swap line up'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'editor.swapLineDown',
|
2021-01-21 20:23:32 +02:00
|
|
|
label: () => _('Swap line down'),
|
2020-12-19 19:57:41 +02:00
|
|
|
},
|
2020-10-09 19:35:46 +02:00
|
|
|
{
|
|
|
|
name: 'selectedText',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'replaceSelection',
|
|
|
|
},
|
2020-11-14 00:50:03 +02:00
|
|
|
{
|
2020-11-14 12:57:09 +02:00
|
|
|
name: 'editor.setText',
|
2020-11-14 00:50:03 +02:00
|
|
|
},
|
2020-12-02 12:36:00 +02:00
|
|
|
{
|
|
|
|
name: 'editor.focus',
|
|
|
|
},
|
2021-02-06 18:01:06 +02:00
|
|
|
{
|
|
|
|
name: 'editor.execCommand',
|
|
|
|
},
|
2020-07-03 23:32:39 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
export default declarations;
|