Skip to content

[docs-infra] Replace the contentEditable editor with a textarea editor - #1779

Draft
brijeshb42 wants to merge 6 commits into
di-migration-flat-importsfrom
di-migration-textarea-editor
Draft

[docs-infra] Replace the contentEditable editor with a textarea editor#1779
brijeshb42 wants to merge 6 commits into
di-migration-flat-importsfrom
di-migration-textarea-editor

Conversation

@brijeshb42

Copy link
Copy Markdown
Contributor

Replaces the contentEditable editing engine with a textarea laid over the highlighted <pre>.

The textarea owns the text, so selection, undo/redo, IME, and spellcheck are native. It paints nothing: an edit goes out through setSource, the host re-parses, and <Pre> re-renders from the new tree — so emphasis frames, collapse placeholders, and intersection-driven frame hydration keep working while editing.

Net −8,800 lines. EditingEngine is narrowed to the edit-time source manipulation useSourceEditing still needs; the editing surface moves to its own codeEditorLoader chunk, so a block that only commits programmatic edits no longer pulls the editor in.

No new dependency.

Notes

  • Indent and outdent go through document.execCommand('insertText') to stay on the native undo stack. jsdom has no execCommand, so unit tests cover the fallback and Pre.browser.tsx covers the real path.
  • Geometry is read from the live DOM in a layout effect: <code>'s font metrics and the frame spans' horizontal padding. Inheriting from <pre> is not enough — <code> and .frame carry their own metrics, and a fraction of a pixel per line compounds into visible drift.
  • Editing a collapsed region in place needs EditableSourceProjection and lands separately. Until then, focusing a collapsed block expands it.

@brijeshb42 brijeshb42 added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Aug 14, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy preview

Bundle size

ℹ️ Using snapshot from parent commit 76408ea (fallback from merge base bf6ed6d).

Total Size Change: ▼-39.7KB(-1.16%) - Total Gzip Change: ▼-11.7KB(-1.28%)
Files: 71 total (2 added, 0 removed, 4 changed)

Show details for 71 more bundles

CodeEditorparsed: 🔺+3.77KB(new) gzip: 🔺+1.7KB(new)
CodeContextparsed: 🔺+87B(new) gzip: 🔺+98B(new)
EditingEngineparsed: ▼-20.6KB(-87.37%) gzip: ▼-6.35KB(-83.45%)
@mui/internal-docs-infra/CodeProviderparsed: ▼-20.5KB(-12.92%) gzip: ▼-6.27KB(-13.38%)
@mui/internal-docs-infra/useDemoparsed: ▼-1.26KB(-0.98%) gzip: ▼-419B(-0.98%)
@mui/internal-docs-infra/useCodeparsed: ▼-1.18KB(-1.08%) gzip: ▼-418B(-1.15%)
@mui/internal-docs-infra/abstractCreateDemoparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateDemoClientparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateStreamparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateTypesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/ChunkProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/cliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeControllerContextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeExternalsContextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighterparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/errorsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazyparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazy/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoDataparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoData/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemapparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemap/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCodeWindowparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCoordinatedparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCopierparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCrossTabStateparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemoControllerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useErrorsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useLocalStorageStateparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/usePreferenceparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useScrollAnchorparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearchparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearch/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStreamparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStream/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useTypeparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useTypesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useUrlHashStateparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/withDocsInfraparsed: 0B(0.00%) gzip: 0B(0.00%)
addLineGuttersparsed: 0B(0.00%) gzip: 0B(0.00%)
BuildEngineparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterChunkparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterClientparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeInitialSourceLoaderparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeSourceLoaderparsed: 0B(0.00%) gzip: 0B(0.00%)
compileCssWithPostcssparsed: 0B(0.00%) gzip: 0B(0.00%)
createFrameparsed: 0B(0.00%) gzip: 0B(0.00%)
createParseSourceWorkerClientparsed: 0B(0.00%) gzip: 0B(0.00%)
embedTransformsparsed: 0B(0.00%) gzip: 0B(0.00%)
enhanceCodeEmphasisparsed: 0B(0.00%) gzip: 0B(0.00%)
findExpandingRangesparsed: 0B(0.00%) gzip: 0B(0.00%)
getHastTextContentparsed: 0B(0.00%) gzip: 0B(0.00%)
grammarLoadersparsed: 0B(0.00%) gzip: 0B(0.00%)
grammarsparsed: 0B(0.00%) gzip: 0B(0.00%)
isFrameSpanparsed: 0B(0.00%) gzip: 0B(0.00%)
loadIsomorphicCodeVariantparsed: 0B(0.00%) gzip: 0B(0.00%)
parseSourceparsed: 0B(0.00%) gzip: 0B(0.00%)
rolldown-runtimeparsed: 0B(0.00%) gzip: 0B(0.00%)
source.cssparsed: 0B(0.00%) gzip: 0B(0.00%)
source.jsparsed: 0B(0.00%) gzip: 0B(0.00%)
source.jsonparsed: 0B(0.00%) gzip: 0B(0.00%)
source.mdxparsed: 0B(0.00%) gzip: 0B(0.00%)
source.shellparsed: 0B(0.00%) gzip: 0B(0.00%)
source.tsparsed: 0B(0.00%) gzip: 0B(0.00%)
source.tsxparsed: 0B(0.00%) gzip: 0B(0.00%)
source.yamlparsed: 0B(0.00%) gzip: 0B(0.00%)
text.html.basicparsed: 0B(0.00%) gzip: 0B(0.00%)
text.mdparsed: 0B(0.00%) gzip: 0B(0.00%)
TransformEngineparsed: 0B(0.00%) gzip: 0B(0.00%)
transpileSourceparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Performance

ℹ️ Using benchmark from parent commit 76408ea (fallback from merge base bf6ed6d).

Total duration: 17.08 ms -0.71 ms(-4.0%) | Renders: 5 (+0) | Paint: 63.91 ms +0.48 ms(+0.8%)

Test Duration Renders
DataGrid mount with paint timing 2.60 ms ▼-1.44 ms(-35.6%) 1 (+0)
sub-series via labels 0.00 ms 0 (+0)

5 tests within noise — details

Metric alarms

Test Metric Change
sub-series via labels fib_phase#small 🔺 +0.03 ms

Check out the code infra dashboard for more information about this PR.

@brijeshb42
brijeshb42 force-pushed the di-migration-flat-imports branch from 76a3f28 to bf6ed6d Compare August 14, 2026 18:43
@brijeshb42
brijeshb42 force-pushed the di-migration-textarea-editor branch from dcf13d1 to 7e52522 Compare August 14, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant