Make the text color part of the base style in editor

This commit is contained in:
Henrik Giesel 2021-01-28 22:01:34 +01:00
parent af3753948a
commit 3eade1c64d

View file

@ -433,8 +433,8 @@ class EditingArea extends HTMLElement {
this.setAttribute("contenteditable", "true"); this.setAttribute("contenteditable", "true");
} }
initialize(color: string): void { initialize(index: number): void {
this.style.color = color; this.className = `editor-field-${index}`;
} }
set fieldHTML(content: string) { set fieldHTML(content: string) {
@ -491,6 +491,7 @@ class EditingContainer extends HTMLDivElement {
font-family: initial; font-family: initial;
font-size: initial; font-size: initial;
direction: initial; direction: initial;
color: initial;
}`, }`,
0 0
); );
@ -507,10 +508,16 @@ class EditingContainer extends HTMLDivElement {
initialize(index: number, color: string, content: string): void { initialize(index: number, color: string, content: string): void {
this.id = `f${index}`; this.id = `f${index}`;
this.editingArea.initialize(color); this.editingArea.initialize(index);
this.setBaseColor(color);
this.editingArea.fieldHTML = content; 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 { setBaseStyling(fontFamily: string, fontSize: string, direction: string): void {
const firstRule = this.baseStylesheet.cssRules[0] as CSSStyleRule; const firstRule = this.baseStylesheet.cssRules[0] as CSSStyleRule;
firstRule.style.fontFamily = fontFamily; firstRule.style.fontFamily = fontFamily;