From d9954000b308ec86a310927ed50c561fa17561b2 Mon Sep 17 00:00:00 2001
From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com>
Date: Mon, 21 Sep 2026 07:16:23 -0400
Subject: [PATCH] refactor(mobile): the rich editor's document becomes
scope-threaded modules and a bundled factory (OTA phase C, C7.10 C1) (#21969)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* refactor(mobile): split the rich editor document's stylesheet and markup apart
The body constant carried the tail of a `:root` block, every CSS rule and the
editable surface's markup in one string, which only the HTML builder could
splice. A page mounting the document needs the stylesheet and the markup
separately, so they become a function over the theme and a constant.
Byte-for-byte inert: `mobile-rich-markdown-editor-document.test.ts`'s digest of
the shipped document is unchanged.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
* refactor(mobile): give the keyboard-inset normaliser its own module
It is the host's half of the inset, read by the controller, and it sat in the
module holding the document's in-page script. The script is about to become
ordinary TypeScript under `rich-markdown/`, where a native-side normaliser does
not belong.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
* feat(mobile): the rich editor's document becomes scope-threaded modules and a factory
The editor's ~600-line program lived in seven string constants a concatenator
glued into one `'
+
+/** The document with its script region emptied, which is what the digest above is of. */
+function documentShell(html: string): string {
+ const open = html.indexOf(SCRIPT_OPEN) + SCRIPT_OPEN.length
+ const close = html.indexOf(SCRIPT_CLOSE, open)
+ expect(open).toBeGreaterThan(SCRIPT_OPEN.length - 1)
+ expect(close).toBeGreaterThan(open)
+ return html.slice(0, open) + html.slice(close)
+}
describe('mobile rich markdown editor document', () => {
- it('reproduces the pre-split document byte for byte', () => {
- const document = buildMobileRichMarkdownEditorHtml()
- expect(Buffer.byteLength(document, 'utf8')).toBe(PRE_SPLIT_DOCUMENT_BYTES)
- expect(createHash('sha256').update(document, 'utf8').digest('hex')).toBe(
- PRE_SPLIT_DOCUMENT_SHA256
- )
+ it('reproduces the page around the document byte for byte', () => {
+ const shell = documentShell(buildMobileRichMarkdownEditorHtml())
+ expect(Buffer.byteLength(shell, 'utf8')).toBe(DOCUMENT_SHELL_BYTES)
+ expect(createHash('sha256').update(shell, 'utf8').digest('hex')).toBe(DOCUMENT_SHELL_SHA256)
+ })
+
+ it('carries the bundled document, whole, as its only script', () => {
+ const html = buildMobileRichMarkdownEditorHtml()
+ expect(html).toContain(`${SCRIPT_OPEN}${RICH_MARKDOWN_EDITOR_DOCUMENT_SCRIPT}${SCRIPT_CLOSE}`)
+ // One script, so the digest above is over the whole of what is not the document.
+ expect(html.split('