5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 07:06:22 +00:00

fix: cargar los editores dinámicamente #17599

This commit is contained in:
f 2024-10-16 12:06:38 -03:00
parent e1ac21674b
commit be8bcdcd2b
No known key found for this signature in database
4 changed files with 20 additions and 17 deletions

View file

@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus";
import SuttyEditor from "@suttyweb/editor";
import "@suttyweb/editor/dist/style.css";
export default class extends Controller {
static targets = ["textarea"];
connect() {
this.editor =
new SuttyEditor({
target: this.element,
props: {
textareaEl: this.textareaTarget,
},
});
}
}

View file

@ -4,5 +4,4 @@ import './input-tag'
import './prosemirror' import './prosemirror'
import './timezone' import './timezone'
import './turbolinks-anchors' import './turbolinks-anchors'
import './new_editor'
import './htmx_abort' import './htmx_abort'

View file

@ -1,14 +0,0 @@
import SuttyEditor from "@suttyweb/editor";
import "@suttyweb/editor/dist/style.css";
document.addEventListener("turbolinks:load", () => {
document.querySelectorAll(".new-editor").forEach((editorContainer) => {
new SuttyEditor({
target: editorContainer,
props: {
textareaEl: editorContainer.querySelector("textarea"),
},
});
});
});

View file

@ -3,7 +3,7 @@
= render 'posts/attribute_feedback', = render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata post: post, attribute: attribute, metadata: metadata
.new-editor.content{ id: attribute } .new-editor.content{ id: attribute, data: { controller: 'new-editor' } }
= text_area_tag "#{base}[#{attribute}]", metadata.to_s.html_safe, = text_area_tag "#{base}[#{attribute}]", metadata.to_s.html_safe,
dir: dir, lang: locale, dir: dir, lang: locale, 'data-new-editor-target': 'textarea',
**field_options(attribute, metadata), class: 'd-none' **field_options(attribute, metadata), class: 'd-none'