Behaviour SwRS-MDOKFSTUDIO-FMEDIT-004
Text values are edited as one or several lines
When a writer edits the value of a text field, the extension SHALL show a text box in which Enter saves a one-line value, Enter adds a line in a multi-line value, Cmd or Ctrl+Enter saves, and the saved value keeps no trailing line break unless the original had one and is written as a YAML literal block when it holds line breaks.
Step 2 of path 1 in StRS-MDOKFSTUDIO-FMEDIT-001: from “A field editor is open” to “The new value is saved”.
Scenarios 7
The situations the tests check; open one to read it.
nominalEnter saves a one-line text value
Givena text field title holding a one-line value, its editor open in the one-row text box
Whenthe writer presses Enter
Thenone previewFrontmatterSave is posted with the typed value
nominalIn a multi-line value Enter adds a line and Cmd or Ctrl+Enter saves
Givena text field editor whose value has two lines
Whenthe writer presses Enter, then Cmd or Ctrl+Enter
ThenEnter adds a line and posts nothing, and Cmd or Ctrl+Enter posts one previewFrontmatterSave with the typed value
refusalKeys that do not save a text value
| Input | Outcome |
|---|---|
| Enter during IME composition in a one-line value | The key is ignored and nothing is posted |
| Shift+Enter in the text box of a text field | The key is left to the text box, which adds a line, and nothing is posted |
| Alt+Enter in the same editor | Nothing is posted |
boundaryTrailing line breaks of the typed value
| Input | Outcome |
|---|---|
| Original value without a trailing line break, two empty lines typed after the text, then save | The posted fieldValue has no trailing line break |
| Original value ending with a line break, saved without removing it | The trailing line break is kept in the posted value |
nominalA multi-line value is written as a literal block
Givena plain frontmatter field description holding one line, followed by the field b: 2
Whenthe value "a\nb" (two lines) is saved for description
Thenthe field is written as a literal block (description: |- then the lines a and b indented), and the line b: 2 and the fences stay unchanged
nominalFields without a schema type are edited as YAML text
Givena document without a schema and a field tags holding an object (the same box serves a field of unknown type, a list-typed field with a non-list value and an object value)
Whenthe writer opens its editor
Thena text box labelled "Frontmatter tags" shows the value as YAML, its rows between 1 and 20; Enter adds a line and Cmd or Ctrl+Enter saves
boundaryA field just added opens an empty box
Givena field just added, whose value is the empty string
Whenits editor opens
Thenthe text box starts empty instead of showing the two quote characters
Implemented in 2
Tested by 2
Known limits (1)
- objects are edited as de-indented YAML and a YAML parser error is shown as raw, possibly multi-line text.
Replaces
SwRS-MDOKFSTUDIO-FMEDIT-005Trailing line breaks of a text value are dropped superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-004 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-006A multi-line text value is written as a literal block superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-004 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-015Fields without a schema type are edited as YAML text superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-004 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-075Shift+Enter adds a line in a text field without saving superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-004 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-076In a multi-line text value Enter adds a line and Cmd or Ctrl+Enter saves superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-004 Markdown file