Skip to content

Keep custom-layout page audio data (BL-16109)#7829

Open
JohnThomson wants to merge 2 commits intomasterfrom
keepCustomLayoutAudioAttrs
Open

Keep custom-layout page audio data (BL-16109)#7829
JohnThomson wants to merge 2 commits intomasterfrom
keepCustomLayoutAudioAttrs

Conversation

@JohnThomson
Copy link
Copy Markdown
Contributor

@JohnThomson JohnThomson commented Apr 9, 2026


Open with Devin

This change is Reviewable

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnThomson made 1 comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +1735 to +1758
if (node.Name == "img" && HtmlDom.IsInCustomLayoutPage(node))
{
// We don't want to transfer attribute values or classes from the custom page
// We don't want to transfer most image attribute values or classes from the custom page
// layout to the standard one. It's likely that special styling or image cropping
// or anything similar will have the wrong effect there. The one exception is the
// src of an image: we allow changing the cover image in one place to change it in
// the other, just as changing the text of a title in one place changes it in both.
// We don't need to worry about re-creating attribute values inside the custom margin
// box, because its whole content is saved.
if (node.Name == "img" && !string.IsNullOrWhiteSpace(node.GetAttribute("src")))
// We do want to transfer data normally for text elements; for example, talking book
// recordings should transfer (and also survive the book being opened in 6.3).
if (!string.IsNullOrWhiteSpace(node.GetAttribute("src")))
result.Add(
Tuple.Create("src", XmlString.FromUnencoded(node.GetAttribute("src")))
);
return result;
}
// Margin box doesn't have any of the properties that would normally make it one of the nodes
// passed to this method. However, it is the node that gets passed for a custom page. It would
// probably be harmless to process it normally, but it would result in the data-div node for
// the custom page content having the class marignBox. That might cause something unexpected,
// and the marginBox doesn't have any classes or attributes we need to preserve, so just skip it.
if (node.HasClass("marginBox"))
return result;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Behavioral change: all attributes on text elements in custom layout pages now transfer to standard pages

The old code at src/BloomExe/Book/BookData.cs:1735 suppressed ALL attributes for ALL element types in custom layout pages (except img src). The new code only suppresses attributes for img elements and marginBox nodes. This means that for text elements like div[data-book='bookTitle'], not only do the intended talking book attributes (e.g., data-audiorecordingmode, recordingmd5, data-duration) now propagate, but so do other attributes like style, id, and any other custom attributes. The restore path at line 2031 still prevents these from being merged INTO custom layout page elements, but they WILL be merged into standard page elements. This is probably fine since _attributesNotToCopy already filters UI junk, and the _classesNotToCopy list filters bloom-managed classes. However, if a custom layout page has specialized style or layout attributes on text elements, those could unexpectedly transfer to the standard page's version of those same elements.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant