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-07-19 15:27:11 +02:00
|
|
|
import type { EditingArea } from "./editing-area";
|
|
|
|
|
|
|
|
export function getCurrentField(): EditingArea | null {
|
|
|
|
return document.activeElement?.closest(".field") ?? null;
|
|
|
|
}
|
|
|
|
|
2021-04-28 23:31:45 +02:00
|
|
|
export function appendInParentheses(text: string, appendix: string): string {
|
|
|
|
return `${text} (${appendix})`;
|
|
|
|
}
|
2021-09-28 03:04:10 +02:00
|
|
|
|
|
|
|
/// trivial wrapper to silence Svelte deprecation warnings
|
|
|
|
export function execCommand(
|
|
|
|
command: string,
|
|
|
|
showUI?: boolean | undefined,
|
|
|
|
value?: string | undefined
|
|
|
|
): void {
|
|
|
|
document.execCommand(command, showUI, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// trivial wrapper to silence Svelte deprecation warnings
|
|
|
|
export function queryCommandState(command: string): boolean {
|
|
|
|
return document.queryCommandState(command);
|
|
|
|
}
|