Content and Proposals
How emend sends your text to the AI and safely applies the change it suggests.
A proposal is the change the AI suggests. This page explains how emend turns your text into something the AI can read, and how it makes sure a proposal is safe to apply.
Your editor stores the document as Tiptap JSON. The AI works better with Markdown, so emend sends Markdown to the AI and turns the answer back into Tiptap content. Your stored document stays Tiptap JSON.
Step 1: emend takes a snapshot
When you send a request, emend saves:
- The text the AI may change, and the text it may read.
- That text as Markdown.
- A version number of the document at that moment.
- What kinds of content your editor supports (for example, tables or images).
If the text you want to change contains something that cannot be turned into Markdown, the request is blocked. The same is true for the text the AI reads, unless your code chooses to send it as plain text instead.
Step 2: emend checks the answer
When the AI finishes, emend checks whether your editor can display the answer. There are three possible results:
| Result | What it means |
|---|---|
supported-markdown | The answer fits your editor. You can accept it. |
plain-text-fallback | The answer can only be applied as plain text, and your code has allowed that. |
blocked | Your editor cannot display the answer. You can still read and copy it, but not apply it. |
Step 3: you see a preview
The highlighted text and the suggested change are only drawn on top of your editor. They are not saved into your document. They disappear when you accept, reject, or close the suggestion.
Out-of-date suggestions cannot be accepted
Each suggestion remembers the document version from Step 1. If the document changes before you accept, the suggestion is out of date and emend will not apply it. Run the request again on the current text instead.
Accept is one change you can undo
When you click Accept, emend checks everything one last time and then replaces the text in a single step. Like any other edit, you can undo it with the keys Cmd+Z on Mac or Ctrl+Z on Windows and Linux. If a suggestion would replace a whole document that is not empty, emend asks you to confirm first.
Reject removes the suggestion and leaves your document as it was.
Next, read Transports to learn how AI components send requests to your server and get answers back.