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
49 lines (48 loc) • 1.93 kB
JavaScript
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */
var o = Object.defineProperty;
var u = (r, t, e) => t in r ? o(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
var i = (r, t, e) => u(r, typeof t != "symbol" ? t + "" : t, e);
/* empty css */
/* empty css */
import { StatisticsCalculator as l } from "./services/StatisticsCalculator.mjs";
import { FooterRenderer as a } from "./components/FooterRenderer.mjs";
class f {
constructor() {
i(this, "name", "footer");
i(this, "editor", null);
i(this, "calculator");
i(this, "renderer", null);
i(this, "unsubscribe", null);
this.calculator = new l();
}
initialize(t) {
this.editor = t, this.renderer = new a(t), this.setupFooter(), this.setupEventListeners();
}
setupFooter() {
var s, n;
if (!this.editor) return;
const t = this.editor.getContainer(), e = (s = this.renderer) == null ? void 0 : s.createElement();
e && ((n = t.parentElement) == null || n.insertBefore(e, t.nextSibling)), this.updateStatistics();
}
setupEventListeners() {
this.editor && (this.unsubscribe = this.editor.subscribeToContentChange(() => {
this.updateStatistics();
}));
}
updateStatistics() {
var s;
if (!this.editor) return;
const t = this.editor.getContainer().innerHTML, e = this.calculator.calculate(t);
(s = this.renderer) == null || s.update(e);
}
destroy() {
if (this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), this.renderer) {
const t = this.renderer.element;
t && t.parentElement && t.parentElement.removeChild(t), this.renderer = null;
}
this.editor = null, this.calculator = null;
}
}
export {
f as FooterPlugin
};