UNPKG

@cairn214/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.

42 lines (41 loc) 1.42 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const Quill = require("quill"); const emojiMap = require("../emoji-map.cjs.js"); const Embed = Quill.imports["blots/embed"]; class EmojiBlot extends Embed { static create(value) { const node = super.create(); if (typeof value === "object") { EmojiBlot.buildSpan(value, node); } else if (typeof value === "string") { const valueObj = emojiMap.default[value]; if (valueObj) { EmojiBlot.buildSpan(valueObj, node); } } node.setAttribute("contenteditable", false); return node; } static value(node) { return node.dataset.name; } static buildSpan(value, node) { node.setAttribute("data-name", value.name); const emojiSpan = document.createElement("span"); emojiSpan.classList.add(this.emojiClass); emojiSpan.classList.add(this.emojiPrefix + value.name); emojiSpan.textContent = String.fromCodePoint(...EmojiBlot.parseUnicode(value.unicode)); node.appendChild(emojiSpan); } static parseUnicode(string) { return string.split("-").map((str) => Number.parseInt(str, 16)); } } EmojiBlot.blotName = "emoji"; EmojiBlot.className = "ql-emojiblot"; EmojiBlot.tagName = "span"; EmojiBlot.emojiClass = "ap"; EmojiBlot.emojiPrefix = "ap-"; exports.default = EmojiBlot; //# sourceMappingURL=emoji-blot.cjs.js.map