From 3eade1c64d18308e3108d43396846ab56d9d84fb Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 28 Jan 2021 22:01:34 +0100 Subject: [PATCH] Make the text color part of the base style in editor --- qt/aqt/data/web/js/editor.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qt/aqt/data/web/js/editor.ts b/qt/aqt/data/web/js/editor.ts index 50c69e622..b7ab7306d 100644 --- a/qt/aqt/data/web/js/editor.ts +++ b/qt/aqt/data/web/js/editor.ts @@ -433,8 +433,8 @@ class EditingArea extends HTMLElement { this.setAttribute("contenteditable", "true"); } - initialize(color: string): void { - this.style.color = color; + initialize(index: number): void { + this.className = `editor-field-${index}`; } set fieldHTML(content: string) { @@ -491,6 +491,7 @@ class EditingContainer extends HTMLDivElement { font-family: initial; font-size: initial; direction: initial; + color: initial; }`, 0 ); @@ -507,10 +508,16 @@ class EditingContainer extends HTMLDivElement { initialize(index: number, color: string, content: string): void { this.id = `f${index}`; - this.editingArea.initialize(color); + this.editingArea.initialize(index); + this.setBaseColor(color); this.editingArea.fieldHTML = content; } + setBaseColor(color: string): void { + const firstRule = this.baseStylesheet.cssRules[0] as CSSStyleRule; + firstRule.style.color = color; + } + setBaseStyling(fontFamily: string, fontSize: string, direction: string): void { const firstRule = this.baseStylesheet.cssRules[0] as CSSStyleRule; firstRule.style.fontFamily = fontFamily;