From c0d47e18b766c245ef490640edb10c8426d0da0f Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 8 Feb 2022 05:13:18 +0100 Subject: [PATCH] Fix CommandIconButton (#1648) - It did not respect shortcuts --- ts/editable/content-editable.ts | 2 +- .../editor-toolbar/CommandIconButton.svelte | 16 +++++++++------- .../editor-toolbar/FormatBlockButtons.svelte | 4 ---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ts/editable/content-editable.ts b/ts/editable/content-editable.ts index d334191a3..0b5b438a3 100644 --- a/ts/editable/content-editable.ts +++ b/ts/editable/content-editable.ts @@ -89,7 +89,7 @@ if (isApplePlatform()) { } export function preventBuiltinContentEditableShortcuts(editable: HTMLElement): void { - for (const keyCombination of ["Control+B", "Control+U", "Control+I", "Control+R"]) { + for (const keyCombination of ["Control+B", "Control+U", "Control+I"]) { registerShortcut(preventDefault, keyCombination, editable); } } diff --git a/ts/editor/editor-toolbar/CommandIconButton.svelte b/ts/editor/editor-toolbar/CommandIconButton.svelte index 5f3e933c9..86b1ab92c 100644 --- a/ts/editor/editor-toolbar/CommandIconButton.svelte +++ b/ts/editor/editor-toolbar/CommandIconButton.svelte @@ -6,15 +6,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import IconButton from "../../components/IconButton.svelte"; import Shortcut from "../../components/Shortcut.svelte"; import WithState from "../../components/WithState.svelte"; + import { getPlatformString } from "../../lib/shortcuts"; import { execCommand, queryCommandState } from "../helpers"; import { context as noteEditorContext } from "../NoteEditor.svelte"; import { editingInputIsRichText } from "../rich-text-input"; export let key: string; export let tooltip: string; - export let shortcut: string = ""; + export let shortcut: string | null = null; + + $: theTooltip = shortcut ? `${tooltip} (${getPlatformString(shortcut)})` : tooltip; - export let withoutShortcut = false; export let withoutState = false; const { focusedInput } = noteEditorContext.get(); @@ -27,12 +29,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {#if withoutState} - + - {#if !withoutShortcut} - + {#if shortcut} + {/if} {:else} { @@ -53,7 +55,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - {#if !withoutShortcut} + {#if shortcut} { diff --git a/ts/editor/editor-toolbar/FormatBlockButtons.svelte b/ts/editor/editor-toolbar/FormatBlockButtons.svelte index f41b025a0..f3fd765ec 100644 --- a/ts/editor/editor-toolbar/FormatBlockButtons.svelte +++ b/ts/editor/editor-toolbar/FormatBlockButtons.svelte @@ -97,7 +97,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {@html justifyLeftIcon} @@ -105,21 +104,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {@html justifyCenterIcon} {@html justifyRightIcon} {@html justifyFullIcon}