2021-05-22 21:17:00 +00:00
|
|
|
/// @ts-ignore
|
|
|
|
import SuttyEditor from "@suttyweb/editor";
|
|
|
|
import "@suttyweb/editor/dist/style.css";
|
|
|
|
|
2021-02-12 15:57:23 +00:00
|
|
|
document.addEventListener("turbolinks:load", () => {
|
2021-04-28 18:48:50 +00:00
|
|
|
const flash = document.querySelector<HTMLElement>(".js-flash");
|
|
|
|
|
|
|
|
if (flash) {
|
|
|
|
const keys = JSON.parse(flash.dataset.keys || "[]");
|
|
|
|
|
|
|
|
switch (flash.dataset.target) {
|
|
|
|
case "editor":
|
|
|
|
switch (flash.dataset.action) {
|
|
|
|
case "forget-content":
|
|
|
|
keys.forEach(forgetContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const editorEl of document.querySelectorAll<HTMLElement>(
|
|
|
|
".editor[data-editor]"
|
|
|
|
)) {
|
|
|
|
try {
|
2021-05-22 21:17:00 +00:00
|
|
|
new SuttyEditor({
|
|
|
|
target: editorEl,
|
|
|
|
props: {
|
|
|
|
textareaEl: editorEl.parentElement!.querySelector("textarea"),
|
|
|
|
},
|
|
|
|
});
|
2021-04-28 18:48:50 +00:00
|
|
|
} catch (error) {
|
2021-05-22 21:17:00 +00:00
|
|
|
console.error(error);
|
|
|
|
alert(error);
|
2021-04-28 18:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|