From 66faa4ec2542591e71bb396fc8ec7b08a53bc05a Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Mon, 26 Jul 2021 05:28:28 +0200 Subject: [PATCH 1/2] Rename to text color and text color highlight --- ftl/core/editing.ftl | 4 +++- ts/editor/ColorButtons.svelte | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ftl/core/editing.ftl b/ftl/core/editing.ftl index c6e6d1265..92a1f7bca 100644 --- a/ftl/core/editing.ftl +++ b/ftl/core/editing.ftl @@ -32,7 +32,8 @@ editing-outdent = Decrease indent editing-paste = Paste editing-record-audio = Record audio editing-remove-formatting = Remove formatting -editing-set-foreground-color = Set foreground color +editing-set-text-color = Set text color +editing-set-text-highlight-color = Set text highlight color editing-show-duplicates = Show Duplicates editing-subscript = Subscript editing-superscript = Superscript @@ -56,3 +57,4 @@ editing-cloze-deletion-ctrlandshiftandc = Cloze deletion (Ctrl+Shift+C) editing-change-colour-f8 = Change colour (F8) editing-set-foreground-colour-f7 = Set foreground colour (F7) editing-customize-card-templates-ctrlandl = Customize Card Templates (Ctrl+L) +editing-set-foreground-color = Set foreground color diff --git a/ts/editor/ColorButtons.svelte b/ts/editor/ColorButtons.svelte index cdb8f72f7..bc518a6ff 100644 --- a/ts/editor/ColorButtons.svelte +++ b/ts/editor/ColorButtons.svelte @@ -39,7 +39,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + {@html highlightColorIcon} {@html colorHelperIcon} From 95c8f5a12a0fce00086c4e54295efd4cdd0295d8 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Mon, 26 Jul 2021 06:15:30 +0200 Subject: [PATCH 2/2] Use event object in createShortcut, fix F8 for highlight --- ts/change-notetype/SaveButton.svelte | 3 ++- ts/components/WithShortcut.svelte | 3 +-- ts/deck-options/SaveButton.svelte | 3 ++- ts/editor/ClozeButton.svelte | 2 +- ts/editor/ColorButtons.svelte | 4 ++-- ts/editor/CommandIconButton.svelte | 4 ++-- ts/editor/NoteTypeButtons.svelte | 2 +- ts/editor/PreviewButton.svelte | 2 +- ts/editor/TemplateButtons.svelte | 18 +++++++++--------- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ts/change-notetype/SaveButton.svelte b/ts/change-notetype/SaveButton.svelte index 1528d314c..c3bd7a8f0 100644 --- a/ts/change-notetype/SaveButton.svelte +++ b/ts/change-notetype/SaveButton.svelte @@ -29,7 +29,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html theme="primary" on:click={() => save()} tooltip={shortcutLabel} - on:mount={createShortcut}>{tr.actionsSave()} createShortcut(event.detail.button)} + >{tr.actionsSave()} diff --git a/ts/components/WithShortcut.svelte b/ts/components/WithShortcut.svelte index 64fa58949..260b10f92 100644 --- a/ts/components/WithShortcut.svelte +++ b/ts/components/WithShortcut.svelte @@ -12,8 +12,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let deregister: () => void; - function createShortcut({ detail }: CustomEvent): void { - const mounted: HTMLButtonElement = detail.button; + function createShortcut(mounted: HTMLElement): void { deregister = registerShortcut((event: KeyboardEvent) => { mounted.dispatchEvent(new MouseEvent("click", event)); event.preventDefault(); diff --git a/ts/deck-options/SaveButton.svelte b/ts/deck-options/SaveButton.svelte index a7cc91af4..8dfb384b5 100644 --- a/ts/deck-options/SaveButton.svelte +++ b/ts/deck-options/SaveButton.svelte @@ -65,7 +65,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html theme="primary" on:click={() => save(false)} tooltip={shortcutLabel} - on:mount={createShortcut}>{tr.deckConfigSaveButton()} createShortcut(event.detail.button)} + >{tr.deckConfigSaveButton()} diff --git a/ts/editor/ClozeButton.svelte b/ts/editor/ClozeButton.svelte index fef1ef8a8..3320eb4f4 100644 --- a/ts/editor/ClozeButton.svelte +++ b/ts/editor/ClozeButton.svelte @@ -48,7 +48,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html tooltip={`${tr.editingClozeDeletion()} (${shortcutLabel})`} {disabled} on:click={onCloze} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {@html ellipseIcon} diff --git a/ts/editor/ColorButtons.svelte b/ts/editor/ColorButtons.svelte index bc518a6ff..ae6686302 100644 --- a/ts/editor/ColorButtons.svelte +++ b/ts/editor/ColorButtons.svelte @@ -44,7 +44,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html )} {disabled} on:click={forecolorWrap} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {@html textColorIcon} {@html colorHelperIcon} @@ -68,7 +68,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html forecolorWrap = wrapWithForecolor(setColor(event)); forecolorWrap(); }} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.input)} /> diff --git a/ts/editor/CommandIconButton.svelte b/ts/editor/CommandIconButton.svelte index 4781d2ccc..e06ef94bd 100644 --- a/ts/editor/CommandIconButton.svelte +++ b/ts/editor/CommandIconButton.svelte @@ -48,7 +48,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html tooltip={appendInParentheses(tooltip, shortcutLabel)} {disabled} on:click={() => document.execCommand(key)} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > @@ -69,7 +69,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html document.execCommand(key); updateState(event); }} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > diff --git a/ts/editor/NoteTypeButtons.svelte b/ts/editor/NoteTypeButtons.svelte index ce4f6fc70..c98e3dbe3 100644 --- a/ts/editor/NoteTypeButtons.svelte +++ b/ts/editor/NoteTypeButtons.svelte @@ -29,7 +29,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html bridgeCommand("cards")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingCards()}... diff --git a/ts/editor/PreviewButton.svelte b/ts/editor/PreviewButton.svelte index f5edfa4e0..8cd9833d3 100644 --- a/ts/editor/PreviewButton.svelte +++ b/ts/editor/PreviewButton.svelte @@ -14,7 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html bridgeCommand("preview")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.actionsPreview()} diff --git a/ts/editor/TemplateButtons.svelte b/ts/editor/TemplateButtons.svelte index 245e41a13..cb224de5b 100644 --- a/ts/editor/TemplateButtons.svelte +++ b/ts/editor/TemplateButtons.svelte @@ -53,7 +53,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html iconSize={70} {disabled} on:click={onAttachment} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {@html paperclipIcon} @@ -72,7 +72,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html iconSize={70} {disabled} on:click={onRecord} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {@html micIcon} @@ -105,7 +105,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > wrapCurrent("\\(", "\\)")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingMathjaxInline()} {shortcutLabel} @@ -119,7 +119,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > wrapCurrent("\\[", "\\]")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingMathjaxBlock()} {shortcutLabel} @@ -133,7 +133,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > wrapCurrent("\\(\\ce{", "}\\)")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingMathjaxChemistry()} {shortcutLabel} @@ -147,7 +147,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > wrapCurrent("[latex]", "[/latex]")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingLatex()} {shortcutLabel} @@ -161,7 +161,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > wrapCurrent("[$]", "[/$]")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingLatexEquation()} {shortcutLabel} @@ -175,7 +175,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > wrapCurrent("[$$]", "[/$$]")} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {tr.editingLatexMathEnv()} {shortcutLabel} @@ -202,7 +202,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html active={inCodable} disabled={!fieldFocused} on:click={onHtmlEdit} - on:mount={createShortcut} + on:mount={(event) => createShortcut(event.detail.button)} > {@html xmlIcon}