something like this
export const LoadEditor = {
async mounted() {
startQuillEditor(this.el);
},
destroyed() {
if (this.quill) this.quill.destroy();
},
};
var toolbarOptions = [
["bold", "italic", "underline", "strike"], // toggled buttons
["blockquote", "code-block"],
[{ header: 1 }, { header: 2 }], // custom button values
[{ list: "ordered" }, { list: "bullet" }],
[{ script: "sub" }, { script: "super" }], // superscript/subscript
[{ indent: "-1" }, { indent: "+1" }], // outdent/indent
[{ direction: "rtl" }], // text direction
[{ size: ["small", false, "large", "huge"] }], // custom dropdown
[{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ color: [] }, { background: [] }], // dropdown with defaults from theme
[{ font: [] }],
[{ align: [] }],
["clean"], // remove formatting button
];
const codeInput = document.getElementById("quill-editor");
const startQuillEditor = (el) => {
Promise.all([
//how to point to the local assets bundle - OR must refer to the https://domain/assets/folder
//also the example can't load properly the css in this way - Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css"
import("https://cdn.quilljs.com/1.3.6/quill.snow.css"),
import("https://cdn.quilljs.com/1.3.6/quill.js"),
]).then(([quillcss, quill]) => {
const quill = new Quill(el, {
theme: "snow",
debug: false,
modules: {
toolbar: {
toolbar: toolbarOptions,
},
},
});
});
};
p.s. the idea is to bundle the quill.js with an additional esbuild step, and loading it only for this particular view
inside the config.exs
config :esbuild,
....
args: ~w(js/app.js js/quill.js --bundle --target=es2016 --outdir=../priv/static/assets),