silence execCommand deprecation warnings for now

This commit is contained in:
Damien Elmes 2021-09-28 11:04:10 +10:00
parent 2a2469e7a2
commit 04ba24cb54
6 changed files with 30 additions and 15 deletions

View file

@ -16,7 +16,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { bridgeCommand } from "lib/bridgecommand";
import { withButton } from "components/helpers";
import { textColorIcon, highlightColorIcon, arrowIcon } from "./icons";
import { appendInParentheses } from "./helpers";
import { appendInParentheses, execCommand } from "./helpers";
export let api = {};
export let textColor: string;
@ -26,11 +26,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: backcolorWrap = wrapWithBackcolor(highlightColor);
const wrapWithForecolor = (color: string) => () => {
document.execCommand("forecolor", false, color);
execCommand("forecolor", false, color);
};
const wrapWithBackcolor = (color: string) => () => {
document.execCommand("backcolor", false, color);
execCommand("backcolor", false, color);
};
</script>

View file

@ -9,7 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import OnlyEditable from "./OnlyEditable.svelte";
import { withButton } from "components/helpers";
import { appendInParentheses } from "./helpers";
import { appendInParentheses, execCommand, queryCommandState } from "./helpers";
export let key: string;
export let tooltip: string;
@ -21,13 +21,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<OnlyEditable let:disabled>
{#if withoutShortcut && withoutState}
<IconButton {tooltip} {disabled} on:click={() => document.execCommand(key)}>
<IconButton {tooltip} {disabled} on:click={() => execCommand(key)}>
<slot />
</IconButton>
{:else if withoutShortcut}
<WithState
{key}
update={() => document.queryCommandState(key)}
update={() => queryCommandState(key)}
let:state={active}
let:updateState
>
@ -36,7 +36,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{active}
{disabled}
on:click={(event) => {
document.execCommand(key);
execCommand(key);
updateState(event);
}}
>
@ -48,7 +48,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<IconButton
tooltip={appendInParentheses(tooltip, shortcutLabel)}
{disabled}
on:click={() => document.execCommand(key)}
on:click={() => execCommand(key)}
on:mount={withButton(createShortcut)}
>
<slot />
@ -58,7 +58,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<WithShortcut {shortcut} let:createShortcut let:shortcutLabel>
<WithState
{key}
update={() => document.queryCommandState(key)}
update={() => queryCommandState(key)}
let:state={active}
let:updateState
>
@ -67,7 +67,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{active}
{disabled}
on:click={(event) => {
document.execCommand(key);
execCommand(key);
updateState(event);
}}
on:mount={withButton(createShortcut)}

View file

@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import CommandIconButton from "./CommandIconButton.svelte";
import { getListItem } from "lib/dom";
import { getCurrentField } from "./helpers";
import { getCurrentField, execCommand } from "./helpers";
import {
ulIcon,
olIcon,
@ -33,7 +33,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
function outdentListItem() {
const currentField = getCurrentField();
if (getListItem(currentField!.editableContainer.shadowRoot!)) {
document.execCommand("outdent");
execCommand("outdent");
} else {
alert("Indent/unindent currently only works with lists.");
}
@ -42,7 +42,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
function indentListItem() {
const currentField = getCurrentField();
if (getListItem(currentField!.editableContainer.shadowRoot!)) {
document.execCommand("indent");
execCommand("indent");
} else {
alert("Indent/unindent currently only works with lists.");
}

View file

@ -22,6 +22,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} from "./tags";
import { Tags } from "lib/proto";
import { postRequest } from "lib/postrequest";
import { execCommand } from "./helpers";
export let tags: TagType[] = [];
@ -355,7 +356,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
textarea.style.left = "-9999px";
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
execCommand("copy");
document.body.removeChild(textarea);
}

View file

@ -10,3 +10,17 @@ export function getCurrentField(): EditingArea | null {
export function appendInParentheses(text: string, appendix: string): string {
return `${text} (${appendix})`;
}
/// 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);
}

View file

@ -85,7 +85,7 @@ def svelte_check(name = "svelte_check", srcs = []):
"--workspace",
native.package_name(),
"--fail-on-warnings",
#"--fail-on-hints",
"--fail-on-hints",
],
data = [
"//ts:tsconfig.json",