Content moderation¶
Frontend editing works with content moderation. By default, a change made from the page never publishes moderated content on its own: it is saved as a pending draft, and the published revision stays live until someone publishes the draft. Editors who are allowed to can publish their changes directly instead, see Saving and publishing directly.
This applies when the edited entity, or the host a paragraph belongs to, is under a content moderation workflow. Entities without moderation are saved as before.
What happens when an editor changes something¶
| The entity is in | The change is saved as |
|---|---|
| A published state | A new revision in the workflow's draft state. The published revision stays the default revision. |
An unpublished state, such as draft |
A new revision in that same state |
| No moderation state, or not moderated | A normal revision, as before |
The draft state is the workflow's default moderation state when that state is unpublished, and
draft otherwise.
Consecutive changes build on the pending draft rather than on the published content, so two edits in a row do not overwrite each other.
New revisions carry the editor as the author, the current time, and the log message "Updated with frontend editing." The log message of the revision they were copied from is not reused. The save queue lets the editor type their own message.
Saving and publishing directly¶
By default, Save creates a draft. An editor who is allowed to can instead publish a change directly, which saves it straight to the published revision. The page then updates in place, with no draft and no redirect, and shows "Your change was published."
Publishing directly is only possible when all of these hold:
- The content is moderated and its live revision is published.
- The translation has no pending draft. The form of a draft edits the draft, and publishing over a draft would leave it stale or overwrite it. Changes then go into a new draft, see below.
- The user has the
frontend editing publish directlypermission. - The user may make the workflow transition from the published state into the published state, for
example
use editorial transition publish.
The editor's preference¶
Each editor who may publish directly chooses whether their changes are published immediately or saved as a draft, in the same way as the frontend editing toggle. The preference is stored per user. A button shows the current preference ("Publishes immediately" or "Saves as draft", the same wording as the indicators) and switches it. It is an item of the top bar with the Navigation module, and a tab of the toolbar with the Toolbar module. The preference can also be set on the preferences tab of the user profile.
The preference applies to every change: the edit and add forms, move, delete, duplicate and the save queue. For editors who have not chosen yet, the Publish changes directly by default setting is the default. It is off by default, so changes are saved as drafts until the editor or the site decides otherwise.
Editors without the permission always save drafts, whatever the setting is. Editors who may publish directly but not save drafts (no transition into the draft state) always publish.
Buttons in the forms¶
When both are possible, the paragraph edit and add forms of the sidebar offer both buttons. The primary button follows the preference, the other one comes next to it:
| Preference | Primary button | Second button |
|---|---|---|
| Publishes immediately | Save and publish | Save as draft |
| Saves as draft | Save as draft | Save and publish |
A note above the buttons says what each one does, and each button has a tooltip. With only one way of saving, the form keeps the Save button, and the note says whether the change is published immediately or saved as a draft. No note is shown for content that is not moderated or was never published. With the save queue on, move, delete and duplicate are queued first, so the draft is created by Save All, with one draft for everything queued on that host. The buttons are available for paragraph forms only. Other entities are edited through their own form, which offers the workflow state itself.
Indicators¶
So that editors know in advance what will happen, the item actions say it:
- A badge next to the title of the item: "Publishes immediately", "Saves as draft", or "Saves as draft (a draft already exists)".
- The tooltip and accessible name of each action link (edit, add, move, delete, duplicate) end with the same text, for example "Move up: Publishes immediately".
- The save queue panel says what Save All does, and its buttons are named after it, for example Save All and publish and Save All as draft.
With the save queue on, the move, delete and duplicate links carry no badge and no mode in their tooltip, because they save nothing: what happens is decided by Save All. Add and edit keep theirs, as they still save at once.
The markup only says what is possible for the content and the user's permissions, so the page can be cached for all editors with the same permissions. Which of the two applies when both are possible is decided in the browser from the user's preference, and changes as soon as the editor switches it.
Content with a draft¶
While a translation has a draft, publishing directly is not possible, so a change cannot overwrite the draft. The change is saved as a new draft on top of it, if the user may save drafts, and the indicators say "Saves as draft (a draft already exists)". This only depends on the draft of the same translation: the other translations can still be published directly.
Changing the live page¶
While a draft exists, the live page shows the published revision, which is not the latest one. The
action links on it are not offered, because replacing a single field on the live page would mix
draft content into published content. The draft page (/node/{id}/latest) offers them.
Drafts belong to a translation, as in content moderation itself. A draft of the French translation only removes the action links from the French live page. The other translations stay editable on their live pages, and a change there creates a draft of that translation (or is published directly) without touching the French draft. When a draft is published later, content moderation takes the other translations from the then published revision.
When an editor changes something on the live page of content that has no draft yet, the change is saved as a draft and the browser is sent to the draft page, with a warning:
Your change was saved as a draft. The live page stays unchanged until the draft is published.
The page scrolls to the paragraph that was moved or duplicated. On the draft page, later changes update the page in place as usual.
The redirect only happens when the editor is allowed to see the latest version of the content.
Links carry a default_revision=1 query parameter to say that they were rendered on the live page;
a link without it never causes a redirect. Pages cached before this feature existed have links
without the parameter, so they update in place until they are rendered again.
Who may save a draft¶
Saving from the page skips the entity form, which is where content moderation normally validates the state transition. Frontend editing therefore checks the transition itself:
- The user needs the workflow transition into the draft state, for example
use editorial transition create_new_draft. - Without it, the action links and the paragraph edit link are not offered, and a request made by hand is refused with an access denied response before anything is saved.
See Permissions.
Limitations¶
- The log message is fixed. Besides publishing directly or saving a draft, the editor cannot
choose the target state. A site that needs something else can replace the
frontend_editing.revision_helperservice. See Services. - The preference can only be switched in the Navigation top bar or the Toolbar. Without either module, editors use the buttons of the forms and the save queue, and the site default applies to move, delete and duplicate.
- Only paragraphs are followed up to their host. Other composite entity types need a sub-module
that overrides
getRevisionRoot(). - Previewing the draft before saving and choosing any other workflow state in the sidebar are not part of this feature.