Behaviour SwRS-MDOKFSTUDIO-LIFE-069
A render of the loaded document updates the page in place
When a render finishes and the loaded page can take its content, the extension SHALL send only the new content of the page as a content patch, which the page applies in place and reports ready, instead of a new page document.
Step 2 of path 1 in StRS-MDOKFSTUDIO-LIFE-005: from “A new render is done” to “The page shows the new content in place”.
Scenarios 10
The situations the tests check; open one to read it.
nominalTyping
Givena ready page of preview.md, incremental updates on, and no condition of the requirement that loads a new page document (SwRS-MDOKFSTUDIO-LIFE-071) met
Whenthe writer types and a render finishes
Thenthe host posts previewContentPatch with the inner HTML of the content container and does not assign a new page document (unit test test/page/runtimeContentPatch.test.ts "T34: a content patch replaces the content, moves the identifiers and posts previewReady")
boundaryThe incrementalUpdates setting
| Input | Outcome |
|---|---|
| No stored value for markdownOkfSchemaStudio.preview.incrementalUpdates, preview settings read | incrementalUpdates is true |
| The setting set to false in the settings editor, a render finishes | The page document is assigned again with the new HTML, without a window reload |
refusalOne of the exceptions
Giventhe new render has another shell, for example math appears
Whenthe render finishes
Thenthe whole page is assigned instead (see SwRS-MDOKFSTUDIO-LIFE-071)
nominalPatches in a chain
| Input | Outcome |
|---|---|
| Two patches addressed to consecutive identifiers, received before the page acknowledged the previous one | Both apply in order and the page ends on the identifiers of the second |
| A patch with stale fields in the middle of a chain | The later patches are ignored and nothing is acknowledged (a rejected patch stops the chain) |
nominalReady report after a patch
Givena patch moving the page from request 1 to request 2
Whenthe page applies it
Thenit posts previewReady for request 2 with its reading state; if a block editor was open when the patch arrived, the report says no block editor is open (blockEditOpen false)
nominalWhat the page does when it applies a patch
| Input | Outcome |
|---|---|
| A page with the first and third details elements open | The first and third details elements of the new content are open |
| No details element open | No initial state is kept and the sections of the new content start closed |
| A patch that carries an initial anchor line or a pin | The page scrolls so the line sits at the reading line, like a loaded page |
| A patch without anchor and pin | The scroll position is kept |
| A visible pending notice | The notice is gone |
| No notice shown | Nothing is created |
| A link tooltip open on the old content | The tooltip is closed |
| No tooltip | Nothing changes |
nominalUnchanged blocks stay in place
Giventen blocks and a patch that changes the fifth
Whenthe page replaces the content
Thennine nodes are the same elements as before, with their focus, selection, loaded images and diagrams, and only the fifth comes from the patch (unit test test/page/modules/contentMorph.test.ts "PERF-05: unchanged blocks are kept in place, changed and new ones come from the patch")
boundaryRepeated blocks and links
Giventhree identical paragraphs, a paragraph with a link, and a node the page added itself
Whenthe page replaces the content
Thenequal blocks pair in document order and each kept node is used once, a block with a link has the same key as on the first load, and page-added or text nodes are never kept
nominalA line inserted above keeps the blocks below
Givena document of 200 blocks and a patch that adds one paragraph at the top, so that every block below it moves down by two source lines
Whenthe page replaces the content
Thenthe 200 existing blocks are the same elements as before, the paragraph is the only new element, and each kept block carries the new `data-line`, `data-sphinx-source-line`, `data-sphinx-source-end-line` and `data-sphinx-preview-block` values (unit test test/page/modules/contentMorph.test.ts "P-07: a line inserted above keeps every block below it and moves its line attributes in place")
boundaryA block the page rewrote is rebuilt
Givena block whose content the page wrote itself (a table cell left with Tab shows the text just typed in it)
Whena patch carries the same host HTML for that block as the render the page started from
Thenthe block is rebuilt from the patch, not kept; a block the page did not write into is still kept (unit tests test/page/modules/contentMorph.test.ts "a block the page rewrote is rebuilt by the next patch, even when its host HTML is unchanged", test/page/runtimeTableCellStale.test.ts)
Implemented in 7
Tested by 7
- test/core/configuration/previewConfiguration.test.tsunit
- test/core/preview/contentPatch.test.tsunit
- test/host/lifeReq.requirements.test.tsunit
- test/integration/realInput/tableStaleRender.tsintegration
- test/page/modules/contentMorph.test.tsunit
- test/page/runtimeContentPatch.test.tsunit
- test/page/runtimeTableCellStale.test.tsunit