Behaviour SwRS-MDOKFSTUDIO-BLOCK-042
Typing is autosaved as the smallest single replacement
When a writer types in a block editor, the extension SHALL autosave the last text 400 milliseconds after the last keystroke, unless it equals the text last posted, posting it as one previewEditSave with final false that the host writes as the smallest single replacement of the text last written.
Step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-006: from “A block editor is open” to “The typed text is in the document”.
Step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-025: from “A block editor is open” to “The typed text is in the document”.
Scenarios 5
The situations the tests check; open one to read it.
nominalBurst of typing
Givenan open editor
a pending autosave
a pending autosave
Whenthe writer types ten characters within 100 ms and stops
the writer types before the 400 ms elapse
the writer types before the 400 ms elapse
Thenexactly one previewEditSave with final false is posted 400 ms after the last key, carrying the whole text
the timer restarts and no message is posted yet
the timer restarts and no message is posted yet
boundaryAn autosave of unchanged text sends nothing
| Input | Outcome |
|---|---|
| The autosave timer fires with the text just posted | No message is posted |
| The text returned to the last posted text before the timer fired | No message is posted |
nominalThe host writes the smallest replacement
Givena block `Hello world` written to the document and a new text `Hello brave world`
Whenthe host plans the edit
Thenthe edit replaces the empty range after `Hello ` with `brave `, offset by the start of the block
boundaryIdentical text and pair boundaries
| Input | Outcome |
|---|---|
| New text equal to the last written text | There is no edit and nothing is written |
| Texts `x\r\n` and `x\n` | The range starts at offset 1, before the CR, never between the CR and the LF |
| Texts `a😀b` and `a😁b`, whose emoji share the high surrogate | The range is 1 to 3 and replaces both halves of the pair with the new emoji |
boundaryOne save applied at a time, newest text kept
| Input | Outcome |
|---|---|
| A save being applied and two further saves received | When the running edit resolves, only the text of the last save is applied next |
| The pending text equals the text just written | No further edit is applied |