mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import html from './app.element.html?raw';
|
|
import 'plugins-styles/lib/styles.css';
|
|
import './app.element.css';
|
|
|
|
export class AppElement extends HTMLElement {
|
|
public static observedAttributes = [];
|
|
|
|
connectedCallback() {
|
|
this.innerHTML = html;
|
|
|
|
Array.from(this.querySelectorAll('template')).forEach((el: HTMLElement) => {
|
|
const pre = document.createElement('pre');
|
|
const code = document.createElement('code');
|
|
code.classList.add('language-html');
|
|
const removeLineIndentation = el.innerHTML.replaceAll(
|
|
this.getIndentationSize(el.innerHTML),
|
|
'',
|
|
);
|
|
|
|
code.textContent = removeLineIndentation;
|
|
|
|
pre.appendChild(code);
|
|
|
|
el.parentNode?.appendChild(pre);
|
|
el.remove();
|
|
});
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(window as any).hljs?.highlightAll();
|
|
}
|
|
|
|
getIndentationSize(str: string) {
|
|
const size = str.length - str.trimStart().length;
|
|
return ' '.repeat(size - 1);
|
|
}
|
|
}
|
|
customElements.define('app-root', AppElement);
|