@opentiny/fluent-editor
Version:
A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.
65 lines (64 loc) • 2.44 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const quillEasyColor = require("quill-easy-color");
const fluentEditor = require("../../core/fluent-editor.cjs.js");
const OriginPicker = fluentEditor.default.import("ui/picker");
class Picker extends OriginPicker {
buildLabel() {
const label = document.createElement("span");
label.classList.add("ql-picker-label");
label.innerHTML = `<i class="icon" />`;
label.tabIndex = 0;
label.setAttribute("role", "button");
label.setAttribute("aria-expanded", "false");
this.container.appendChild(label);
return label;
}
buildItem(option) {
const item = super.buildItem(option);
const value = option.getAttribute("value");
item.style.setProperty("--value", value);
return item;
}
selectItem(item, trigger = false) {
const selected = this.container.querySelector(".ql-selected");
if (item === selected || item == null) return;
if (selected != null) {
selected.classList.remove("ql-selected");
}
item.classList.add("ql-selected");
this.select.selectedIndex = Array.from(item.parentNode.children).indexOf(item);
if (item.hasAttribute("data-value")) {
this.label.setAttribute("data-value", item.getAttribute("data-value"));
} else {
this.label.removeAttribute("data-value");
}
if (item.hasAttribute("data-label")) {
this.label.setAttribute("data-label", item.getAttribute("data-label"));
} else {
this.label.removeAttribute("data-label");
}
if (trigger) {
this.select.dispatchEvent(new Event("change"));
this.close();
}
}
}
class ColorPicker extends quillEasyColor.EasyColorPicker {
constructor(select, label, options) {
super(select, label, options);
}
buildItem(option) {
const item = super.buildItem(option);
item.setAttribute("title", option.getAttribute("value"));
return item;
}
}
__publicField(ColorPicker, "clearText");
__publicField(ColorPicker, "customText");
exports.ColorPicker = ColorPicker;
exports.Picker = Picker;
//# sourceMappingURL=better-picker.cjs.js.map