UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

40 lines (39 loc) 1.35 kB
var o = Object.defineProperty; var a = (r, t, e) => t in r ? o(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e; var s = (r, t, e) => a(r, typeof t != "symbol" ? t + "" : t, e); /* empty css */ /* empty css */ import { StatisticsCalculator as c } from "./services/StatisticsCalculator.mjs"; import { FooterRenderer as u } from "./components/FooterRenderer.mjs"; class m { constructor() { s(this, "name", "footer"); s(this, "editor", null); s(this, "calculator"); s(this, "renderer", null); this.calculator = new c(); } initialize(t) { this.editor = t, this.renderer = new u(t), this.setupFooter(), this.setupEventListeners(); } setupFooter() { var i, n; if (!this.editor) return; const t = this.editor.getContainer(), e = (i = this.renderer) == null ? void 0 : i.createElement(); e && ((n = t.parentElement) == null || n.insertBefore(e, t.nextSibling)), this.updateStatistics(); } setupEventListeners() { this.editor && this.editor.subscribeToContentChange(() => { this.updateStatistics(); }); } updateStatistics() { var i; if (!this.editor) return; const t = this.editor.getContainer().innerHTML, e = this.calculator.calculate(t); (i = this.renderer) == null || i.update(e); } } export { m as FooterPlugin };