/** * ToastUi editor initializer * * This script transforms form textareas created with * "PagedownFormBuilder" into ToastUi markdown editors. * */ const initializeMarkdownEditors = () => { const editors = document.querySelectorAll( '[data-behavior="markdown-editor-widget"]' ); editors.forEach((editor) => { const formInput = document.querySelector(`#${editor.dataset.id}`); if (!editor || !formInput) return; const toastEditor = new ToastUi({ el: editor, theme: window.getCurrentTheme(), initialValue: formInput.value, placeholder: formInput.placeholder, extendedAutolinks: true, linkAttributes: { target: "_blank", }, previewHighlight: false, height: "400px", autofocus: false, usageStatistics: false, language: I18n.locale, toolbarItems: [ ["heading", "bold", "italic"], ["link", "quote", "code", "codeblock"], ["ul", "ol"], ], initialEditType: "markdown", events: { change: () => { // Keep real form