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
46 lines (45 loc) • 1.92 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 e = Object.defineProperty;
var s = (r, t, o) => t in r ? e(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
var i = (r, t, o) => s(r, typeof t != "symbol" ? t + "" : t, o);
/* empty css */
/* empty css */
import { ExportMenu as l } from "./components/ExportMenu.mjs";
import { createToolbarButton as u } from "../ToolbarPlugin/utils.mjs";
import h from "../../icons/export.svg.mjs";
class x {
constructor() {
i(this, "name", "export");
i(this, "hotkeys", [{ keys: "Ctrl+Alt+E", description: "Export document", command: "export", icon: "📤" }]);
i(this, "editor", null);
i(this, "menu", null);
i(this, "toolbarButton", null);
}
initialize(t) {
this.menu = new l(t), this.editor = t, this.addToolbarButton(), this.editor.on("export", () => {
this.showExportMenu();
});
}
addToolbarButton() {
var o, n;
const t = (o = this.editor) == null ? void 0 : o.getToolbar();
t && (this.toolbarButton = u({
icon: h,
title: ((n = this.editor) == null ? void 0 : n.t("Export")) ?? "",
onClick: () => this.showExportMenu()
}), t.appendChild(this.toolbarButton));
}
showExportMenu() {
var o;
if (!this.editor) return;
const t = this.editor.getContainer().innerHTML;
(o = this.menu) == null || o.show(t);
}
destroy() {
var t;
this.toolbarButton && this.toolbarButton.parentElement && this.toolbarButton.parentElement.removeChild(this.toolbarButton), this.menu && (this.menu.destroy(), this.menu = null), (t = this.editor) == null || t.off("export"), this.editor = null, this.toolbarButton = null;
}
}
export {
x as ExportPlugin
};