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
58 lines (57 loc) • 2.03 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 d = Object.defineProperty;
var p = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
var r = (i, e, t) => p(i, typeof e != "symbol" ? e + "" : e, t);
const n = class n {
constructor() {
r(this, "notifications", []);
}
static getInstance() {
return n.instance || (n.instance = new n()), n.instance;
}
show(e) {
const { message: t, type: a = "info", duration: s = 3e3, position: h = "top-right" } = e;
let o = document.querySelector(
`.notification-container.${h.replace("-", "-")}`
);
o || (o = document.createElement("div"), o.className = `notification-container ${h.replace("-", "-")}`, document.body.appendChild(o));
const c = document.createElement("div");
c.className = `notification ${a}`, c.textContent = t, o.appendChild(c), this.notifications.push(c), s > 0 && setTimeout(() => {
this.remove(c);
}, s);
}
success(e, t) {
this.show({ ...t, message: e, type: "success" });
}
error(e, t) {
this.show({ ...t, message: e, type: "error" });
}
warning(e, t) {
this.show({ ...t, message: e, type: "warning" });
}
info(e, t) {
this.show({ ...t, message: e, type: "info" });
}
remove(e) {
e.parentNode && (e.classList.add("removing"), setTimeout(() => {
e.parentNode && e.parentNode.removeChild(e);
const t = this.notifications.indexOf(e);
t > -1 && this.notifications.splice(t, 1), document.querySelectorAll(".notification-container").forEach((s) => {
s.children.length === 0 && s.remove();
});
}, 300));
}
clearAll() {
this.notifications.forEach((e) => {
this.remove(e);
});
}
destroy() {
this.clearAll();
}
};
r(n, "instance");
let l = n;
export {
l as NotificationManager
};