Skip to content

fix(record): keep contenteditable line breaks in recorded fill values - #724

Open
shunxinyi-ljs wants to merge 4 commits into
Tencent:mainfrom
shunxinyi-ljs:fix/record-editor-line-breaks
Open

shunxinyi-ljs wants to merge 4 commits into
Tencent:mainfrom
shunxinyi-ljs:fix/record-editor-line-breaks

Conversation

@shunxinyi-ljs

@shunxinyi-ljs shunxinyi-ljs commented Nov 13, 2026 •

Copy link
Copy Markdown

The recorded fill value of a contenteditable editor lost its line breaks: the value was read with textContent, which does not contain the boundaries Chrome stores as <div>/<br>. Typing Alpha, Enter, Beta recorded value: "AlphaBeta", so replaying the trace collapsed the edit into one line. Fixes #594.

Change. fillableValue now reads an editor the way bsk fill verifies the same value (FILL_VALUE_FUNCTION in tools/interaction.ts): typed layouts are read as literal <div>/<br> lines, other rich structures keep their rendered text, and line-edge whitespace follows white-space. Inputs and textareas still read .value. This is one function in apps/extension/src/content/record-capture.ts; the fill tool is unchanged. The fill reader is a page-world function string, so it is mirrored rather than imported.

Failing evidence. On unmodified main, in real Chrome 157.0.8103.51 (CDP Input.insertText plus Enter, production startRecordCapture, Windows): the editor's DOM becomes Alpha<div>Beta</div> and the emitted step carries value: "AlphaBeta".

Verification.

  • record-editor-value.browser.test.ts, 6 cases in real Chrome: 6 fail on unmodified record-capture.ts, 6 pass with the change. One case also asserts the recorded value carries no U+00A0, because Chrome types a space at a line edge as a non-breaking space. Opt-in via BSK_CLICK_CHROME like the existing browser tests, so CI does not run it.
  • record-capture.test.ts, happy-dom, runs in CI: 9 cases added. On unmodified record-capture.ts 6 fail; the other 3 (single line, pre-wrap whitespace, empty editor) are guards that pass on both sides. The file passes, 52 cases.
  • Recording and reducer suites together: 63 passed. record-input-buttons.browser.test.ts: 10 passed. tsc --noEmit and biome format clean on the changed files.

Behaviour change. Recorded fill values for contenteditable editors now contain \n at the lines the person typed, and the rendered text for rich structures such as <p> blocks. Existing recordings keep their old values. bsk fill already accepts multi-line values for editors, so replay and its verification agree again.

The whitespace rule mirrors the current FILL_COLLAPSES_WHITESPACE (normal, nowrap). Chrome also types edge spaces as U+00A0 in pre-line editors, which still reach the recorded value; #639 adds pre-line to the fill side, and the recorder should follow once that lands rather than lead it here.

@shunxinyi-ljs
shunxinyi-ljs marked this pull request as ready for review November 13, 2026 05:07
@NianJiuZst

Copy link
Copy Markdown
Collaborator

Great work!

@NianJiuZst NianJiuZst self-assigned this Nov 13, 2026
Recording read a contenteditable value with `textContent`, which drops the
line boundaries Chrome stores as <div> and <br> elements. Typing "Alpha",
Enter, "Beta" recorded `value: "AlphaBeta"`, so replay collapsed the edit.

Read the editor the way `bsk fill` verifies it: typed layouts are read as
literal lines, other rich structures keep their rendered text.

Fixes Tencent#594
The helper returned Input.insertText's reply, which does not match the
Promise<void> the edit callback declares; tsc rejects it in CI.
@shunxinyi-ljs
shunxinyi-ljs force-pushed the fix/record-editor-line-breaks branch from 2de7644 to e5a6d63 Compare November 13, 2026 10:15
…ncent#724)

Why:
1. Main advanced past 0.5.0 through Wave 2-5A (Tencent#731-Tencent#754) and Tencent#749, creating
   adjacent [Unreleased] merge conflicts in CHANGELOG.md and CHANGELOG.zh-CN.md.
2. Tencent#731/Tencent#732 unified real-browser suites on BSK_TEST_CHROME and enforced via
   scripts/run-browser-tests.test.mjs that every *.browser.test.ts suite is
   registered in .github/workflows/ci.yml with zero skipped assertions.

What:
- Merge origin/main and place the bilingual Tencent#594/Tencent#724 changelog entries under
  [Unreleased] -> Fixed / 修复.
- Migrate apps/extension/src/content/__tests__/record-editor-value.browser.test.ts
  from legacy BSK_CLICK_CHROME to BSK_TEST_CHROME.
- Register src/content/__tests__/record-editor-value.browser.test.ts in
  .github/workflows/ci.yml alongside record-input-buttons.browser.test.ts.

This branch has not been deployed

No deployments
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.

录制 contenteditable 多行内容时 fill 值丢失换行

2 participants