Behaviour SwRS-MDOKFSTUDIO-BLOCK-216
A refused open or save keeps the typed text and says why
When the host refuses to open a block editor or to save its text, the extension SHALL change nothing in the document, answer the page with the reason of the refusal, and let the page show that reason while it keeps the text the writer typed.
Another outcome at step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-025, in the state “A block editor is open”.
Another outcome at step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-006, in the state “A block editor is open”.
Scenarios 10
The situations the tests check; open one to read it.
nominalRequests that match the document are accepted
| Input | Outcome |
|---|---|
| A previewEditOpen for the rendered revision of a document that has not changed | The block's source is sent |
| A first save whose originalText equals the block in the document | The edit is held and written |
| A first save for existing lines | The edit is held |
refusalThe host refuses what no longer fits the document
| Input | Outcome |
|---|---|
| previewEditOpen when the lines no longer exist in the document, or the document was edited after the last render | The answer carries "The preview is stale. Refresh it before editing this block." and no page editor is registered |
| A first previewEditSave whose originalText differs from the block in the document, for example "Not the current source" | The answer carries "The source block changed while it was being edited." and nothing is written |
| A first previewEditSave for lines beyond the document, also the save of an insertion after a missing line, or a revision that does not fit | The answer carries "The preview is stale. Reopen the block before saving." and nothing is written |
| A previewEditSave with another editId, document, range, original text or revision than the held edit | The answer carries "The preview block edit is stale. Reopen the block before saving." and the document is unchanged |
| A previewEditOpen that names an older render than the host holds | The answer carries "The preview is out of date. Try again once it has refreshed." and no page editor is registered; the frame of the editor shows the reason |
| A previewEditCancel with another editId, document, range, original text or revision than the held edit | The answer carries "The preview block edit is stale. Reopen the block before cancelling." and nothing changes |
refusalA refused open leaves the frame without a text box
Givenan editor frame that shows "Loading Markdown source…" and a previewEditSource answer with the error "Another Markdown block is already being edited."
Whenit reaches the open frame
Thenthe frame has no text box and its status line, which is in the frame from the start, holds the message
The frame gets a Close button, the Refresh button is enabled again, and the frame is the open editor only until the writer leaves it
nominalThe writer leaves a refused open
Giventhe frame of a refused open
Whenthe writer presses Escape, clicks Close, clicks Refresh or clicks another block
Thenthe frame closes without posting a cancel, and a click on another block opens that block
boundaryThe answer of another editor
Givenan answer whose editId is not the open editor's
Whenit arrives
Thenit is ignored
refusalA refused save keeps the typed text
Givenan editor whose final save was refused
Whenthe error arrives
Thenthe text box keeps the text, the status line shows the error and the editor is no longer finishing
nominalTyping again saves again
Giventhe same editor after a refused save
Whenthe writer types again
Thenthe next autosave is posted and the key hint returns to the status line
refusalA save that fails after Cancel, or meets a change of the file, reopens the editor with the typed text and the reason
Givenan editor whose final save is in flight and that the writer closed with Cancel or Escape
Whenthe host answers with an error carrying unsavedText (a refusal, a rejected write, a source block that changed, a change of the file)
Thenthe page reopens the editor on that block with the same editor id and no previewEditOpen, the text box holds the typed text, the status line shows the reason, and the page posts previewEditReopen with reopened true
the clicks and field opens that waited for the save are dropped
until the page answers, the host keeps the editor id as the open page editor, so renders wait, and keeps the text
the clicks and field opens that waited for the save are dropped
until the page answers, the host keeps the editor id as the open page editor, so renders wait, and keeps the text
refusalA change of the file while the editor saves keeps the editor open with the typed text and the reason
Givena final save that is requested and not written, and a change of the document from outside the preview
Whenthe change arrives
Thenthe host writes nothing, answers with the error "The file changed outside the preview before your text was saved. Copy your text, then reopen the block." carrying the text, and keeps the render waiting for the editor
refusalA failure the preview cannot show offers the text to copy
Givena failed detached save and a page that answers previewEditReopen with reopened false
Whenthe host receives it
Thenthe host releases the edit, renders, and shows a warning with a "Copy text" action; picking it puts the kept text on the clipboard and dismissing it writes nothing
Implemented in 5
Tested by 10
- test/core/protocol/hostToPage.test.tsunit
- test/core/protocol/pageToHost.test.tsunit
- test/integration/previewEditing.test.tsintegration
- test/page/blockReq.requirements.test.tsunit
- test/page/runtimeDetachedSave.test.tsunit
- test/page/runtimeDetachedSaveEnds.test.tsunit
- test/page/runtimeDetachedSaveKinds.test.tsunit
- test/page/runtimeSaveEnds.test.tsunit
- test/session/blockReq.requirements.test.tsunit
- test/session/detachedSave.test.tsunit