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
69 lines (68 loc) • 2.9 kB
JavaScript
var S = Object.defineProperty;
var C = (r, t, e) => t in r ? S(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
var h = (r, t, e) => C(r, typeof t != "symbol" ? t + "" : t, e);
import { createContainer as n, createSpan as d } from "../../../utils/helpers.mjs";
class x {
constructor(t) {
h(this, "editor");
h(this, "element", null);
h(this, "stats", {});
this.editor = t;
}
createElement() {
this.element = n("editor-footer");
const t = n("editor-footer-block"), e = n("flex items-center gap-4"), i = this.createStatElement(
this.editor.t("Words"),
// Переводим текст
"stat-words"
), s = this.createStatElement(
this.editor.t("Characters"),
// Переводим текст
"stat-characters"
), o = this.createStatElement(
this.editor.t("Characters (without spaces)"),
// Переводим текст
"stat-characters-no-spaces"
);
e.appendChild(i), e.appendChild(s), e.appendChild(o);
const a = n("flex items-center gap-4"), c = this.createStatElement(
this.editor.t("Sentences"),
// Переводим текст
"stat-sentences"
), p = this.createStatElement(
this.editor.t("Paragraphs"),
// Переводим текст
"stat-paragraphs"
), l = this.createStatElement(
this.editor.t("Reading time"),
// Переводим текст
"stat-reading-time",
this.editor.t("min")
// Переводим суффикс
), m = n("collaboration-status");
return a.appendChild(m), a.appendChild(c), a.appendChild(p), a.appendChild(l), t.appendChild(e), t.appendChild(a), this.element.appendChild(t), this.stats = {
words: i,
characters: s,
charactersNoSpaces: o,
sentences: c,
paragraphs: p,
readingTime: l
}, this.element;
}
createStatElement(t, e, i = "") {
const s = n(), o = d("", `${t}: `);
o.textContent = `${t}: `;
const a = d("", `${e} font-medium`);
if (a.textContent = "0", s.appendChild(o), s.appendChild(a), i) {
const c = d("", ` ${i}`);
s.appendChild(c);
}
return s;
}
update(t) {
this.element && (this.stats.words.textContent = this.editor.t("Words") + ": " + t.words.toLocaleString(), this.stats.characters.textContent = this.editor.t("Characters") + ": " + t.characters.toLocaleString(), this.stats.charactersNoSpaces.textContent = this.editor.t("Characters (without spaces)") + ": " + t.charactersNoSpaces.toLocaleString(), this.stats.sentences.textContent = this.editor.t("Sentences") + ": " + t.sentences.toLocaleString(), this.stats.paragraphs.textContent = this.editor.t("Paragraphs") + ": " + t.paragraphs.toLocaleString(), this.stats.readingTime.textContent = this.editor.t("Reading time") + ": " + t.readingTime.toString());
}
}
export {
x as FooterRenderer
};