Sha256: 7fab92512c1aa4bb58e2ba692b2cc15b03a00c65ce0b24f2955b090b83415e9c
Contents?: true
Size: 1.73 KB
Versions: 3
Compression:
Stored size: 1.73 KB
Contents
// = require quill.min // = require_self ((exports) => { const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video"]; const createQuillEditor = (container) => { const toolbar = $(container).data("toolbar"); const disabled = $(container).data("disabled"); let quillToolbar = [ ["bold", "italic", "underline"], [{ list: "ordered" }, { list: "bullet" }], ["link", "clean"] ]; if (toolbar === "full") { quillToolbar = [ [{ header: [1, 2, 3, 4, 5, 6, false] }], ...quillToolbar, ["video"] ]; } else if (toolbar === "basic") { quillToolbar = [ ...quillToolbar, ["video"] ]; } const $input = $(container).siblings('input[type="hidden"]'); container.innerHTML = $input.val() || ""; const quill = new Quill(container, { modules: { toolbar: quillToolbar }, formats: quillFormats, theme: "snow" }); if (disabled) { quill.disable(); } quill.on("text-change", () => { const text = quill.getText(); // Triggers CustomEvent with the cursor position // It is required in input_mentions.js let event = new CustomEvent("quill-position", { detail: quill.getSelection() }); container.dispatchEvent(event); if (text === "\n") { $input.val(""); } else { $input.val(quill.root.innerHTML); } }); }; const quillEditor = () => { $(".editor-container").each((_idx, container) => { createQuillEditor(container); }); }; exports.Decidim = exports.Decidim || {}; exports.Decidim.quillEditor = quillEditor; exports.Decidim.createQuillEditor = createQuillEditor; })(window);
Version data entries
3 entries across 3 versions & 1 rubygems