mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Fix field description not toggled properly (#1919)
It appears that a variable bound to the `innerHTML` property of a contenteditable element is only updated when `input` event fires on the element, and not when changes are made to the DOM programmatically.
This commit is contained in:
parent
3969487e77
commit
bc5633e070
2 changed files with 3 additions and 4 deletions
|
@ -39,14 +39,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
const description = getContext<Readable<string>>(descriptionKey);
|
const description = getContext<Readable<string>>(descriptionKey);
|
||||||
$: descriptionCSSValue = `"${$description}"`;
|
$: descriptionCSSValue = `"${$description}"`;
|
||||||
|
|
||||||
let innerHTML = "";
|
export let content: Writable<string>;
|
||||||
$: empty = ["", "<br>"].includes(innerHTML);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<anki-editable
|
<anki-editable
|
||||||
class:empty
|
class:empty={!$content}
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
bind:innerHTML
|
|
||||||
use:resolve
|
use:resolve
|
||||||
use:setupFocusHandling
|
use:setupFocusHandling
|
||||||
use:preventBuiltinShortcuts
|
use:preventBuiltinShortcuts
|
||||||
|
|
|
@ -148,6 +148,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
mirrors: [mirror],
|
mirrors: [mirror],
|
||||||
inputHandlers: [setupInputHandler, setupGlobalInputHandler],
|
inputHandlers: [setupInputHandler, setupGlobalInputHandler],
|
||||||
api: api.editable,
|
api: api.editable,
|
||||||
|
content,
|
||||||
},
|
},
|
||||||
context: allContexts,
|
context: allContexts,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue