Only toggle the current field, not all

This commit is contained in:
Henrik Giesel 2021-06-17 20:57:20 +02:00
parent 7266f485d0
commit a87f81f00b

View file

@ -18,7 +18,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { wrap } from "./wrap"; import { wrap } from "./wrap";
import { appendInParentheses } from "./helpers"; import { appendInParentheses } from "./helpers";
import { forEditorField, getEditorField } from "."; import { getCurrentField } from ".";
import { paperclipIcon, micIcon, functionIcon, xmlIcon } from "./icons"; import { paperclipIcon, micIcon, functionIcon, xmlIcon } from "./icons";
export let api = {}; export let api = {};
@ -32,13 +32,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
function checkHtmlEdit() { function checkHtmlEdit() {
return getEditorField(0)!.editingArea.codable.active; const currentField = getCurrentField();
return currentField ? currentField.codable.active : false;
} }
function onHtmlEdit() { function onHtmlEdit() {
forEditorField([], (field) => { const currentField = getCurrentField();
field.editingArea.toggleHtmlEdit(); if (currentField) {
}); currentField.toggleHtmlEdit();
}
} }
</script> </script>
@ -187,7 +189,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
updateState(event); updateState(event);
}} }}
on:mount={createShortcut} on:mount={createShortcut}
disables={false}
> >
{@html xmlIcon} {@html xmlIcon}
</IconButton> </IconButton>