Skip to content

Preserve HTML embeds when editing Docs - #5442

Merged
brsbl merged 1 commit into
mainfrom
bb/docs-raw-html-1-preserve-source
Oct 14, 2026
Merged

brsbl merged 1 commit into
mainfrom
bb/docs-raw-html-1-preserve-source

Conversation

@brsbl

@brsbl brsbl commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Opened from @alanagoyal's #5306 so it can be the base of a stack. Her commit d63b669 is unchanged and the description below is hers. Squash-merging credits her as co-author.

BB-Thread-ID: thr_fashr87x6y · 🤖 Generated with Claude Code

Human comments

bug reported in discord: https://discord.com/channels/1522478522332090528/1558237749574766804

What was wrong

Editing a sentence in Docs could silently remove a video elsewhere in the document. The editor rendered raw HTML through Markdown, then parsed it into Tiptap’s supported nodes. Unsupported elements such as <video> were dropped, and autosave wrote the incomplete document back to disk. A video with a fallback link became just the link; one without fallback text disappeared entirely.

What changed

  • Preserve raw HTML blocks and inline tags in dedicated editor nodes and write their source back when saving. This includes video attributes, nested markup, and fallback links.
  • Show HTML blocks as protected source placeholders and inline tags as protected text. Raw HTML is no longer interpreted as rich content in the editor; edit the HTML itself through a source editor. The existing ::html sandboxed previews still work.
  • Document the behavior and add regression coverage using the actual video embed from my blog post.

No Plugin SDK, CLI, or wire changes.

How you verified

  • pnpm exec turbo run test typecheck lint build --filter=bb-plugin-simple-notes: all 110 tests pass; typecheck and plugin build pass; lint has no errors and eight warnings in existing code.
  • Disabled the new extensions and reran the autosave regression. It failed with the saved document containing only the heading and edited prose—the entire video embed was gone. With the extensions enabled, the same edit preserves the exact embed.
  • Added coverage for repeated save/load cycles, single-line video with a fallback link, iframes, nested HTML, comments, inert scripts and event attributes, fenced HTML code, and deleting/undoing one of multiple embeds. Existing sandboxed-preview and proposal tests pass.

Verification used the real editor in jsdom; no manual desktop/browser smoke test was performed.

AGENT GENERATED

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T18:43:27.715871Z d63b669 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d63b669c22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/docs/raw-html.ts
parse: {
setup(markdown) {
markdown.renderer.rules.html_block = (tokens, index) => {
const source = tokens[index]!.content;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Protect raw blocks before preview rewriting

When an HTML block contains a line matching ::html{...} or Markdown image syntax—for example inside a <pre>, script, or video fallback—displayMarkdown() rewrites that text before this renderer receives it, so source is already corrupted and the next autosave persists the generated embed markup or a normalized image path. Extract or mask raw HTML before applying the preview transformations so an unrelated rich-editor change actually preserves the block byte-for-byte.

Useful? React with 👍 / 👎.

@brsbl

brsbl commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

How this stack changes Alana's commit

Alana's commit eca163280 is unchanged here. The layer above, Never strip HTML when saving Docs, saves untouched blocks byte for byte and replaces the locked placeholders with editable text, so Docs looks as it does on main and never strips HTML.

BB-Thread-ID: thr_fashr87x6y

AGENT GENERATED

@brsbl
brsbl force-pushed the bb/docs-raw-html-1-preserve-source branch from d63b669 to eca1632 Compare October 13, 2026 19:01
@brsbl
brsbl force-pushed the bb/docs-raw-html-1-preserve-source branch 2 times, most recently from eca1632 to 275570a Compare October 14, 2026 16:52
@brsbl
brsbl force-pushed the bb/docs-raw-html-1-preserve-source branch from 275570a to b3fb8a6 Compare October 14, 2026 17:45
@brsbl
brsbl merged commit c6af083 into main Oct 14, 2026
23 checks passed
@brsbl
brsbl deleted the bb/docs-raw-html-1-preserve-source branch October 14, 2026 18:05
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.

2 participants