mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-06 06:40:07 +09:00
Rebuild every attachment before editing a message
The editor keeps an attachment's content as it finds it, so a hand-written embed with a url but no href reached the editor with its markup unvalidated, and a mention saved under Trix's editor carried the generic octet-stream content type the editor doesn't permit and was dropped on save. Rebuilding each attachment from its attachable renders the hardened preview partial and restores the mention content type.
This commit is contained in:
@@ -31,13 +31,14 @@ module RichTextEditorHelper
|
||||
composer_editor.send_keys :tab
|
||||
end
|
||||
|
||||
def paste_in_composer(text)
|
||||
def paste_in_composer(text, html: nil)
|
||||
composer_editor.click
|
||||
|
||||
page.execute_script(<<~JS, text)
|
||||
page.execute_script(<<~JS, text, html)
|
||||
const content = document.querySelector("#composer lexxy-editor .lexxy-editor__content")
|
||||
const event = new ClipboardEvent("paste", { bubbles: true, cancelable: true, clipboardData: new DataTransfer() })
|
||||
event.clipboardData.setData("text/plain", arguments[0])
|
||||
if (arguments[1]) event.clipboardData.setData("text/html", arguments[1])
|
||||
content.dispatchEvent(event)
|
||||
JS
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user