feat: base html sheet
This commit is contained in:
@@ -21,6 +21,34 @@ export class Image extends Box {
|
||||
return doc;
|
||||
}
|
||||
|
||||
public renderHtml(
|
||||
doc: Document,
|
||||
parent: HTMLElement,
|
||||
cssRules: string[],
|
||||
sheet: HTMLStyleElement
|
||||
): Document {
|
||||
const img = doc.createElement('img');
|
||||
img.src = this.imageData;
|
||||
const css = `img-${this.w ?? 0}-${this.h ?? 0}`;
|
||||
img.classList.add(`img`);
|
||||
img.classList.add(css);
|
||||
if (!cssRules.includes(css)) {
|
||||
cssRules.push(css);
|
||||
let rule = '';
|
||||
if (this.w > 0) {
|
||||
rule += `width: ${this.w}px;`;
|
||||
}
|
||||
if (this.h > 0) {
|
||||
rule += `height: ${this.h}px;`;
|
||||
}
|
||||
if (rule.length > 0) {
|
||||
sheet.innerHTML += ` .${css} { ${rule} }`;
|
||||
}
|
||||
}
|
||||
parent.append(img);
|
||||
return doc;
|
||||
}
|
||||
|
||||
public getElements(): AbstractElement[] {
|
||||
return [this];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user