diff --git a/app/services/trix_scrubber.rb b/app/services/trix_scrubber.rb index a8aed288c0..e8ab55afe2 100644 --- a/app/services/trix_scrubber.rb +++ b/app/services/trix_scrubber.rb @@ -2,7 +2,7 @@ class TrixScrubber < Rails::Html::PermitScrubber ALLOWED_TAGS = ["p", "b", "strong", "em", "i", "a", "u", "br", "del", "h1", "blockquote", "pre", - "ul", "ol", "li", "div"].freeze + "ul", "ol", "li", "div", "hr"].freeze ALLOWED_ATTRIBUTES = ["href", "target", "src", "alt"].freeze def initialize diff --git a/app/webpacker/controllers/trixeditor_controller.js b/app/webpacker/controllers/trixeditor_controller.js index 7975d213ed..506086fb2b 100644 --- a/app/webpacker/controllers/trixeditor_controller.js +++ b/app/webpacker/controllers/trixeditor_controller.js @@ -3,10 +3,43 @@ import { Controller } from "stimulus"; export default class extends Controller { connect() { window.addEventListener("trix-change", this.#trixChange); + this.#trixInitialize(); + window.addEventListener("trix-initialize", this.#trixInitialize); } #trixChange = (event) => { // trigger a change event on the form that contains the Trix editor event.target.form.dispatchEvent(new Event("change", { bubbles: true })); }; + + #trixActionInvoke = (event) => { + if (event.actionName === "hr") { + this.element.editor.insertAttachment( + new Trix.Attachment({ content: "