Andrey Antukh ec1af4ad96 🎉 Import penpot-plugins repository
As commit 819a549e4928d2b1fa98e52bee82d59aec0f70d8
2025-12-30 14:56:15 +01:00

37 lines
974 B
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();
});
(window as any).hljs.highlightAll();
}
getIndentationSize(str: string) {
const size = str.length - str.trimStart().length;
return ' '.repeat(size - 1);
}
}
customElements.define('app-root', AppElement);