From fe87f986d349baa1dffa6a3c09fc9ad71e974983 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Fri, 29 Jan 2021 13:36:48 +0100 Subject: [PATCH] Remove user styling in editor again for now --- qt/aqt/data/web/js/editor.ts | 25 ------------------------- qt/aqt/editor.py | 3 +-- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/qt/aqt/data/web/js/editor.ts b/qt/aqt/data/web/js/editor.ts index a1d2ab0f9..c62f1b898 100644 --- a/qt/aqt/data/web/js/editor.ts +++ b/qt/aqt/data/web/js/editor.ts @@ -460,7 +460,6 @@ class EditingContainer extends HTMLDivElement { editingArea: EditingArea; baseStylesheet: CSSStyleSheet; - userStyle: HTMLStyleElement; connectedCallback(): void { this.className = "field"; @@ -497,11 +496,6 @@ class EditingContainer extends HTMLDivElement { 0 ); - this.userStyle = this.editingShadow.appendChild( - document.createElement("style") - ); - this.userStyle.setAttribute("rel", "stylesheet"); - this.editingArea = this.editingShadow.appendChild( document.createElement("editing-area") ) as EditingArea; @@ -526,11 +520,6 @@ class EditingContainer extends HTMLDivElement { firstRule.style.direction = direction; } - setUserStyling(css: HTMLStyleElement): void { - this.userStyle.parentNode.replaceChild(css, this.userStyle); - this.userStyle = css; - } - isRightToLeft(): boolean { return this.editingArea.style.direction === "rtl"; } @@ -584,10 +573,6 @@ class EditorField extends HTMLDivElement { setBaseStyling(fontFamily: string, fontSize: string, direction: string): void { this.editingContainer.setBaseStyling(fontFamily, fontSize, direction); } - - setUserStyling(css: HTMLStyleElement): void { - this.editingContainer.setUserStyling(css); - } } customElements.define("editor-field", EditorField, { extends: "div" }); @@ -648,16 +633,6 @@ function setFonts(fonts: [string, number, boolean][]): void { }); } -function setUserStyling(css: string): void { - const userStyle = document.createElement("style"); - userStyle.setAttribute("rel", "stylesheet"); - userStyle.innerHTML = css; - - forField([], (_, field) => { - field.setUserStyling(userStyle.cloneNode(true) as HTMLStyleElement); - }); -} - function setNoteId(id: number): void { currentNoteId = id; } diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index cad272020..f99296143 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -504,10 +504,9 @@ class Editor: self.web.setFocus() gui_hooks.editor_did_load_note(self) - js = "setFields(%s); setFonts(%s); setUserStyling(%s); focusField(%s); setNoteId(%s)" % ( + js = "setFields(%s); setFonts(%s); focusField(%s); setNoteId(%s)" % ( json.dumps(data), json.dumps(self.fonts()), - json.dumps(self.note.model()["css"]), json.dumps(focusTo), json.dumps(self.note.id), )