Satisfy formatter

This commit is contained in:
Henrik Giesel 2021-01-19 01:08:15 +01:00
parent 4deeb798ca
commit a4921a36dd

View file

@ -287,7 +287,9 @@ function saveField(type: "blur" | "key"): void {
return; return;
} }
// type is either 'blur' or 'key' // type is either 'blur' or 'key'
pycmd(`${type}:${currentFieldOrdinal()}:${currentNoteId}:${currentField.innerHTML}`) pycmd(
`${type}:${currentFieldOrdinal()}:${currentNoteId}:${currentField.innerHTML}`
);
} }
function currentFieldOrdinal(): string { function currentFieldOrdinal(): string {
@ -388,11 +390,13 @@ function setFields(fields: [string, string][]): void {
</td> </td>
</tr>`; </tr>`;
} }
$("#fields").html(`<table cellpadding=0 width=100% style='table-layout: fixed;'>${txt}</table>`); $("#fields").html(
`<table cellpadding=0 width=100% style='table-layout: fixed;'>${txt}</table>`
);
maybeDisableButtons(); maybeDisableButtons();
} }
function setBackgrounds(cols: ("dupe")[]) { function setBackgrounds(cols: "dupe"[]) {
for (let i = 0; i < cols.length; i++) { for (let i = 0; i < cols.length; i++) {
if (cols[i] === "dupe") { if (cols[i] === "dupe") {
$(`#f${i}`).addClass("dupe"); $(`#f${i}`).addClass("dupe");
@ -422,7 +426,11 @@ function hideDupes(): void {
$("#dupes").hide(); $("#dupes").hide();
} }
let pasteHTML = function (html: string, internal: boolean, extendedMode: boolean): void { let pasteHTML = function (
html: string,
internal: boolean,
extendedMode: boolean
): void {
html = filterHTML(html, internal, extendedMode); html = filterHTML(html, internal, extendedMode);
if (html !== "") { if (html !== "") {
@ -430,7 +438,11 @@ let pasteHTML = function (html: string, internal: boolean, extendedMode: boolean
} }
}; };
let filterHTML = function (html: string, internal: boolean, extendedMode: boolean): string { let filterHTML = function (
html: string,
internal: boolean,
extendedMode: boolean
): string {
// wrap it in <top> as we aren't allowed to change top level elements // wrap it in <top> as we aren't allowed to change top level elements
const top = $.parseHTML(`<ankitop>${html}</ankitop>`)[0] as Element; const top = $.parseHTML(`<ankitop>${html}</ankitop>`)[0] as Element;
if (internal) { if (internal) {
@ -518,14 +530,14 @@ let filterExternalSpan = function (elem: HTMLElement) {
// filter styling // filter styling
for (let i = 0; i < elem.style.length; i++) { for (let i = 0; i < elem.style.length; i++) {
const name = elem.style.item(i); const name = elem.style.item(i);
const value = elem.style.getPropertyValue(name) const value = elem.style.getPropertyValue(name);
if ( if (
!allowedStyling.hasOwnProperty(name) || !allowedStyling.hasOwnProperty(name) ||
// google docs adds this unnecessarily // google docs adds this unnecessarily
name === "background-color" && value === "transparent" || (name === "background-color" && value === "transparent") ||
// ignore coloured text in night mode for now // ignore coloured text in night mode for now
isNightMode() && (name === "background-color" || name === "color") (isNightMode() && (name === "background-color" || name === "color"))
) { ) {
elem.style.removeProperty(name); elem.style.removeProperty(name);
} }
@ -608,8 +620,12 @@ let adjustFieldsTopMargin = function (): void {
let mouseDown = 0; let mouseDown = 0;
$(function (): void { $(function (): void {
document.body.addEventListener("mousedown", () => (mouseDown++)); document.body.addEventListener("mousedown", (): void => {
document.body.addEventListener("mouseup", () => (mouseDown--)); mouseDown++;
});
document.body.addEventListener("mouseup", (): void => {
mouseDown--;
});
document.addEventListener("click", (evt: MouseEvent): void => { document.addEventListener("click", (evt: MouseEvent): void => {
const src = evt.target as Element; const src = evt.target as Element;