stetdocdocs

Operations reference

View as markdown

There are 19 operations. A batch names the base token it was written against and lists operations, which apply completely or not at all. Every operation is a JSON object with an op field, and an unknown field is refused. A range inside a paragraph is find (which must match once, or occurrence says which match) or start and end (offsets in the paragraph's Final text, in Unicode scalar values unless the edit asks for UTF-16 units), or nothing for the whole paragraph.

Block text

Block text is the same batch without JSON escaping. The grammar is provisional until the format experiments settle it.

base: 3f9a0c11d2b4e577:7:51ac09f2e8b34d11
---
@replace
ref: p42
find: the Supplier shall
with: the Supplier must
---
@insert
ref: p42
place: after
paragraphs: <<END
A first new paragraph.
A second one.
END

A stanza starts with @name. A field is key: value on one line, or key: <<TAG and the lines up to a line that is exactly TAG. A key that is not a field of the operation is refused. What a newline means depends on the kind of the field:

KindOne lineHeredocA newline inside the value
texteverything after the first : the lines, joined by a newlineonly in a heredoc
listone entryone entry for each linenever inside an entry
ref, choice, number, boolthe valuenot allowednever

Summary

OperationWhat it doesTrackedReversible
replaceReplaces a text range, or the whole paragraph, with new text. The difference is made word by word.yesyes
insertInserts new paragraphs before or after a paragraph or a table, in order.yesyes
deleteDeletes a whole paragraph or table, a text range, or the blocks from one paragraph through another.yesyes
splitCuts a paragraph in two, at an offset or before or after some text.yesyes
mergeJoins a paragraph and the one after it.yesyes
formatChanges the formatting of the runs in a range, or of the whole paragraph.yesyes
paragraphChanges the formatting of a paragraph. Values take units such as 0.5in, 6pt and 1.5cm.yesyes
styleSets the paragraph style.yesyes
listChanges the level of a list item, restarts its numbering at a number, or takes it out of the list.yesyes
setSets any schema property of a paragraph, run, paragraph mark, section, table, row or cell.yesyes
rowInserts a table row, or deletes one.yesyes
commentAdds a comment anchored to a range, or to the whole paragraph.nono
replyReplies to a comment thread.nono
resolveResolves a comment thread, or reopens it.nono
edit-commentReplaces the text of one of the author's own comments.nono
delete-commentDeletes one of the author's own comments, with its replies.nono
delete-noteDeletes a footnote or endnote, with its reference.yesyes
acceptAccepts revisions: applies them.nono
rejectRejects revisions: undoes them.nono

replace

Replaces a text range, or the whole paragraph, with new text. The difference is made word by word.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph.
withtextyesThe new text. A newline is a line break inside the paragraph, and a tab is written as a tab.
findtextnoThe text to find in the paragraph's Final text. It must match once, or occurrence says which match. A newline matches a line break of the paragraph.
occurrencenumbernoWhich match of find to use, counted from 1.
startnumbernoThe first character of the range, as an offset in the Final text. Not with find.
endnumbernoOne past the last character of the range, as an offset in the Final text. Not with find.
json
{"op":"replace","ref":"p42","find":"shall","with":"must"}

insert

Inserts new paragraphs before or after a paragraph or a table, in order.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph or table the new paragraphs go next to.
placechoiceyesWhether they go before or after it. One of before, after.
paragraphslistyesThe paragraphs, in order. Each is one paragraph of text, and a newline inside one is a line break of that paragraph. In JSON an entry may be an object with a text and a style, and in block text one style applies to all.
json
{"op":"insert","ref":"p42","place":"after","paragraphs":["A new paragraph."]}

delete

Deletes a whole paragraph or table, a text range, or the blocks from one paragraph through another.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph, table or first paragraph of the range.
torefnoThe last paragraph of a range that spans paragraphs. Then start is an offset in ref and end an offset in to.
findtextnoThe text to find in the paragraph's Final text. It must match once, or occurrence says which match. A newline matches a line break of the paragraph.
occurrencenumbernoWhich match of find to use, counted from 1.
startnumbernoThe first character of the range, as an offset in the Final text. Not with find.
endnumbernoOne past the last character of the range, as an offset in the Final text. Not with find.
json
{"op":"delete","ref":"p42"}

split

Cuts a paragraph in two, at an offset or before or after some text.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes. Give exactly one of at, before, after.

FieldKindRequiredMeaning
refrefyesThe paragraph.
atnumbernoThe offset of the cut in the Final text.
beforetextnoCut just before this text, which must match once. A newline matches a line break.
aftertextnoCut just after this text, which must match once. A newline matches a line break.
json
{"op":"split","ref":"p42","before":"Notwithstanding"}

merge

Joins a paragraph and the one after it.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph that stays.
secondrefnoThe paragraph that is joined into it. By default the next paragraph that is not a deleted block.
json
{"op":"merge","ref":"p42"}

format

Changes the formatting of the runs in a range, or of the whole paragraph.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph.
boldboolnoBold on or off.
italicboolnoItalic on or off.
underlinetextnoThe underline style: single, double, none and the others Word has.
strikeboolnoStrike through on or off.
colortextnoThe text colour, RRGGBB or auto.
highlighttextnoThe highlight colour, by Word's name.
sizetextnoThe font size with a unit, such as 12pt.
fonttextnoThe font name.
char_styletextnoThe id or name of a character style.
clearlistnoThe names of formatting to remove, one for each entry.
findtextnoThe text to find in the paragraph's Final text. It must match once, or occurrence says which match. A newline matches a line break of the paragraph.
occurrencenumbernoWhich match of find to use, counted from 1.
startnumbernoThe first character of the range, as an offset in the Final text. Not with find.
endnumbernoOne past the last character of the range, as an offset in the Final text. Not with find.
json
{"op":"format","ref":"p42","find":"Losses","bold":true}

paragraph

Changes the formatting of a paragraph. Values take units such as 0.5in, 6pt and 1.5cm.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph.
alignchoicenoThe alignment. One of left, center, right, justify.
indent_lefttextnoThe left indent.
indent_righttextnoThe right indent.
first_linetextnoThe indent of the first line.
hangingtextnoThe hanging indent.
space_beforetextnoThe space before the paragraph.
space_aftertextnoThe space after the paragraph.
line_spacingtextnoThe line spacing.
keep_nextboolnoKeep with the next paragraph.
keep_linesboolnoKeep the lines together.
page_break_beforeboolnoStart a new page before the paragraph.
clearlistnoThe names of properties to remove, one for each entry.
json
{"op":"paragraph","ref":"p42","align":"center","space_after":"6pt"}

style

Sets the paragraph style.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe paragraph.
styletextyesThe style, by id or by name as the view shows it. One line.
json
{"op":"style","ref":"p42","style":"Heading 2"}

list

Changes the level of a list item, restarts its numbering at a number, or takes it out of the list.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes. Give exactly one of level, restart, remove.

FieldKindRequiredMeaning
refrefyesThe paragraph.
levelnumbernoThe new level, from 0.
restartnumbernoRestart the numbering at this number.
removeboolnoTake the paragraph out of its list.
json
{"op":"list","ref":"p42","level":1}

set

Sets any schema property of a paragraph, run, paragraph mark, section, table, row or cell.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
propspropertiesyesThe properties to set. In block text each line is a name, an optional value and attribute=value pairs, with no spaces inside a value. A property with children is JSON only.
targetchoicenoWhat to set it on. By default from the kind of ref. One of paragraph, run, mark, section, table, row, cell.
refrefnoThe paragraph, table or row. A section is named by section instead.
sectionnumbernoThe number of the section, as inspect sections shows it, from 1.
cellnumbernoThe cell of a row, from 1.
clearlistnoThe names of properties to remove, one for each entry.
findtextnoThe text to find in the paragraph's Final text. It must match once, or occurrence says which match. A newline matches a line break of the paragraph.
occurrencenumbernoWhich match of find to use, counted from 1.
startnumbernoThe first character of the range, as an offset in the Final text. Not with find.
endnumbernoOne past the last character of the range, as an offset in the Final text. Not with find.
json
{"op":"set","ref":"p42","props":[{"name":"jc","val":"center"}]}

row

Inserts a table row, or deletes one.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
refrefyesThe row.
actionchoiceyesWhether to insert a row next to this one or delete it. One of insert, delete.
placechoicenoFor an insert, whether the new row goes before or after. After by default. One of before, after.
cellslistnoFor an insert, the text of each cell, in order. A newline inside one is a line break of the cell.
json
{"op":"row","ref":"r17","action":"delete"}

comment

Adds a comment anchored to a range, or to the whole paragraph.

Tracked as revisions: no. Reversible by rejecting what it wrote: no.

FieldKindRequiredMeaning
refrefyesThe paragraph.
texttextyesThe text of the comment. A newline is a paragraph break of the comment, which has no line break inside a paragraph.
initialstextnoThe initials shown with the comment. By default the first letters of the author's words.
findtextnoThe text to find in the paragraph's Final text. It must match once, or occurrence says which match. A newline matches a line break of the paragraph.
occurrencenumbernoWhich match of find to use, counted from 1.
startnumbernoThe first character of the range, as an offset in the Final text. Not with find.
endnumbernoOne past the last character of the range, as an offset in the Final text. Not with find.
json
{"op":"comment","ref":"p42","find":"Losses","text":"Check this against schedule 2."}

reply

Replies to a comment thread.

Tracked as revisions: no. Reversible by rejecting what it wrote: no.

FieldKindRequiredMeaning
commentrefyesAny comment of the thread, such as c3.
texttextyesThe text of the reply. A newline is a paragraph break.
json
{"op":"reply","comment":"c3","text":"Agreed."}

resolve

Resolves a comment thread, or reopens it.

Tracked as revisions: no. Reversible by rejecting what it wrote: no.

FieldKindRequiredMeaning
commentrefyesAny comment of the thread.
reopenboolnoReopen the thread instead of resolving it.
json
{"op":"resolve","comment":"c3"}

edit-comment

Replaces the text of one of the author's own comments.

Tracked as revisions: no. Reversible by rejecting what it wrote: no.

FieldKindRequiredMeaning
commentrefyesThe comment.
texttextyesThe new text. A newline is a paragraph break.
json
{"op":"edit-comment","comment":"c3","text":"Checked."}

delete-comment

Deletes one of the author's own comments, with its replies.

Tracked as revisions: no. Reversible by rejecting what it wrote: no.

FieldKindRequiredMeaning
commentrefyesThe comment.
json
{"op":"delete-comment","comment":"c3"}

delete-note

Deletes a footnote or endnote, with its reference.

Tracked as revisions: yes. Reversible by rejecting what it wrote: yes.

FieldKindRequiredMeaning
noterefyesThe note, such as fn3 or en2: its kind and its ordinal.
json
{"op":"delete-note","note":"fn3"}

accept

Accepts revisions: applies them.

Tracked as revisions: no. Reversible by rejecting what it wrote: no. Give exactly one of all, author, ids.

FieldKindRequiredMeaning
allboolnoEvery revision.
authortextnoEvery revision of this author, by name or by the short code the view shows.
idsnumber listnoThe revisions with these ids, the numbers after # in the view. A change is resolved whole.
json
{"op":"accept","author":"JD"}

reject

Rejects revisions: undoes them.

Tracked as revisions: no. Reversible by rejecting what it wrote: no. Give exactly one of all, author, ids.

FieldKindRequiredMeaning
allboolnoEvery revision.
authortextnoEvery revision of this author, by name or by the short code the view shows.
idsnumber listnoThe revisions with these ids, the numbers after # in the view. A change is resolved whole.
json
{"op":"reject","ids":[7,8]}