2021-04-13 10:57:08 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
2021-02-09 04:38:04 +01:00
|
|
|
|
2021-02-28 14:12:48 +01:00
|
|
|
import type { EditingArea } from "./editingArea";
|
2021-02-08 19:45:42 +01:00
|
|
|
|
2021-02-28 14:12:48 +01:00
|
|
|
import { saveField } from "./changeTimer";
|
2021-02-08 19:45:42 +01:00
|
|
|
import { bridgeCommand } from "./lib";
|
|
|
|
|
|
|
|
export function onFocus(evt: FocusEvent): void {
|
|
|
|
const currentField = evt.currentTarget as EditingArea;
|
2021-03-08 20:40:23 +01:00
|
|
|
currentField.focusEditable();
|
|
|
|
bridgeCommand(`focus:${currentField.ord}`);
|
2021-04-07 23:53:09 +02:00
|
|
|
// @ts-expect-error
|
|
|
|
editorToolbar.enableButtons();
|
2021-02-08 19:45:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function onBlur(evt: FocusEvent): void {
|
2021-02-23 12:55:04 +01:00
|
|
|
const previousFocus = evt.currentTarget as EditingArea;
|
2021-03-08 20:40:23 +01:00
|
|
|
const currentFieldUnchanged = previousFocus === document.activeElement;
|
2021-02-08 19:45:42 +01:00
|
|
|
|
2021-03-08 20:40:23 +01:00
|
|
|
saveField(previousFocus, currentFieldUnchanged ? "key" : "blur");
|
2021-04-07 23:53:09 +02:00
|
|
|
// @ts-expect-error
|
|
|
|
editorToolbar.disableButtons();
|
2021-02-08 19:45:42 +01:00
|
|
|
}
|