You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Desktop: Fixes #9149: Toolbar icons in view mode are partly not grayed out and can be used
This commit is contained in:
@ -260,6 +260,7 @@ packages/app-desktop/gui/NoteEditor/commands/index.js
|
|||||||
packages/app-desktop/gui/NoteEditor/commands/pasteAsText.js
|
packages/app-desktop/gui/NoteEditor/commands/pasteAsText.js
|
||||||
packages/app-desktop/gui/NoteEditor/commands/showLocalSearch.js
|
packages/app-desktop/gui/NoteEditor/commands/showLocalSearch.js
|
||||||
packages/app-desktop/gui/NoteEditor/commands/showRevisions.js
|
packages/app-desktop/gui/NoteEditor/commands/showRevisions.js
|
||||||
|
packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.test.js
|
||||||
packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.js
|
packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.js
|
||||||
packages/app-desktop/gui/NoteEditor/styles/index.js
|
packages/app-desktop/gui/NoteEditor/styles/index.js
|
||||||
packages/app-desktop/gui/NoteEditor/utils/clipboardUtils.test.js
|
packages/app-desktop/gui/NoteEditor/utils/clipboardUtils.test.js
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -242,6 +242,7 @@ packages/app-desktop/gui/NoteEditor/commands/index.js
|
|||||||
packages/app-desktop/gui/NoteEditor/commands/pasteAsText.js
|
packages/app-desktop/gui/NoteEditor/commands/pasteAsText.js
|
||||||
packages/app-desktop/gui/NoteEditor/commands/showLocalSearch.js
|
packages/app-desktop/gui/NoteEditor/commands/showLocalSearch.js
|
||||||
packages/app-desktop/gui/NoteEditor/commands/showRevisions.js
|
packages/app-desktop/gui/NoteEditor/commands/showRevisions.js
|
||||||
|
packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.test.js
|
||||||
packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.js
|
packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.js
|
||||||
packages/app-desktop/gui/NoteEditor/styles/index.js
|
packages/app-desktop/gui/NoteEditor/styles/index.js
|
||||||
packages/app-desktop/gui/NoteEditor/utils/clipboardUtils.test.js
|
packages/app-desktop/gui/NoteEditor/utils/clipboardUtils.test.js
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
import WhenClause from '@joplin/lib/services/WhenClause';
|
||||||
|
import { enabledCondition } from './editorCommandDeclarations';
|
||||||
|
|
||||||
|
const baseContext: Record<string, any> = {
|
||||||
|
modalDialogVisible: false,
|
||||||
|
gotoAnythingVisible: false,
|
||||||
|
markdownEditorPaneVisible: true,
|
||||||
|
oneNoteSelected: true,
|
||||||
|
noteIsMarkdown: true,
|
||||||
|
noteIsReadOnly: false,
|
||||||
|
richTextEditorVisible: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('editorCommandDeclarations', () => {
|
||||||
|
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
{},
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
markdownEditorPaneVisible: false,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
noteIsReadOnly: true,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
// In the Markdown editor, but only the viewer is visible
|
||||||
|
{
|
||||||
|
markdownEditorPaneVisible: false,
|
||||||
|
richTextEditorVisible: false,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
// In the Markdown editor, and the viewer is visible
|
||||||
|
{
|
||||||
|
markdownEditorPaneVisible: true,
|
||||||
|
richTextEditorVisible: false,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
// In the RT editor
|
||||||
|
{
|
||||||
|
markdownEditorPaneVisible: false,
|
||||||
|
richTextEditorVisible: true,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
])('should create the enabledCondition', (context: Record<string, any>, expected: boolean) => {
|
||||||
|
const condition = enabledCondition('textBold');
|
||||||
|
const wc = new WhenClause(condition);
|
||||||
|
const actual = wc.evaluate({ ...baseContext, ...context });
|
||||||
|
expect(actual).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -9,7 +9,17 @@ const workWithHtmlNotes = [
|
|||||||
export const enabledCondition = (commandName: string) => {
|
export const enabledCondition = (commandName: string) => {
|
||||||
const markdownEditorOnly = !Object.keys(joplinCommandToTinyMceCommands).includes(commandName);
|
const markdownEditorOnly = !Object.keys(joplinCommandToTinyMceCommands).includes(commandName);
|
||||||
const noteMustBeMarkdown = !workWithHtmlNotes.includes(commandName);
|
const noteMustBeMarkdown = !workWithHtmlNotes.includes(commandName);
|
||||||
return `(!modalDialogVisible || gotoAnythingVisible) ${markdownEditorOnly ? '&& markdownEditorPaneVisible' : ''} && oneNoteSelected ${noteMustBeMarkdown ? '&& noteIsMarkdown' : ''} && !noteIsReadOnly`;
|
|
||||||
|
const output = [
|
||||||
|
'!modalDialogVisible',
|
||||||
|
'!gotoAnythingVisible',
|
||||||
|
markdownEditorOnly ? 'markdownEditorPaneVisible' : '(markdownEditorPaneVisible || richTextEditorVisible)',
|
||||||
|
'oneNoteSelected',
|
||||||
|
noteMustBeMarkdown ? 'noteIsMarkdown' : '',
|
||||||
|
'!noteIsReadOnly',
|
||||||
|
];
|
||||||
|
|
||||||
|
return output.filter(c => !!c).join(' && ');
|
||||||
};
|
};
|
||||||
|
|
||||||
const declarations: CommandDeclaration[] = [
|
const declarations: CommandDeclaration[] = [
|
||||||
|
Reference in New Issue
Block a user