-
Notifications
You must be signed in to change notification settings - Fork 81
Closed
Description
We have a number of records in our database with the original <div> wrapper which was used before #724
Now when running since that change, the editor input is blank when loading these prior records. New records, which don't include a wrapping <div> work just fine.
Test which seems to reproduce this:
# In test/system/load_html_test.rb
test "wrapped attachments are normalized" do
visit new_post_path(attachment_tag_name: "bc-attachment")
person = people(:james)
find_editor.value = <<~HTML
<div>Hello World <bc-attachment sgid="#{person.attachable_sgid}" content-type="#{person.content_type}" content=""#{person.name}""></bc-attachment></div>
HTML
assert_editor_html do
assert_selector "bc-attachment"
end
endPotential fix:
diff --git a/src/nodes/image_gallery_node.js b/src/nodes/image_gallery_node.js
index 5a26e1d..c7b28c8 100644
--- a/src/nodes/image_gallery_node.js
+++ b/src/nodes/image_gallery_node.js
@@ -22,8 +22,7 @@ export class ImageGalleryNode extends ElementNode {
static importDOM() {
return {
div: (element) => {
- const containsAttachment = element.querySelector(`:scope > :is(${this.#attachmentTags.join()})`)
- if (!containsAttachment) return null
+ if (!this.#containsPreviewableAttachment(element)) return null
return {
conversion: () => {
@@ -50,6 +49,11 @@ export class ImageGalleryNode extends ElementNode {
return Object.keys(ActionTextAttachmentNode.importDOM())
}
+ static #containsPreviewableAttachment(element) {
+ return element.querySelector(`:scope > img`) ||
+ element.querySelector(`:scope > :is(${this.#attachmentTags.join()}):not([content])[content-type^="image/"]:not([content-type*="svg"])`)
+ }
+
createDOM() {
const div = document.createElement("div")
div.className = this.#galleryClassNamesAlthough the :not rules here seem wonky but attempts to match the isPreviewableImage functionality from src/helpers/html_helper.js
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels