{doc.key}
setRevisionMenuOpenKey(open ? doc.key : null)}
>
Revision history
{revisionMenuOpenKey === doc.key && isFetchingDocumentRevisions && revisionHistory.length === 0 ? (
Loading revisions...
) : revisionHistory.length > 0 ? (
{revisionHistory.map((revision) => {
const isCurrentRevision = revision.id === doc.latestRevisionId;
return (
previewRevision(doc, revision.id)}
className="items-start"
>
rev {revision.revisionNumber}
{isCurrentRevision ? (
Current
) : null}
{relativeTime(revision.createdAt)} • {getRevisionActorLabel(revision)}
);
})}
) : (
No revisions yet
)}
updated {relativeTime(displayedUpdatedAt)}
{showTitle &&
{displayedTitle}
}
{!isHistoricalPreview ? (
beginEdit(doc.key)}>
Edit document
) : null}
{!isHistoricalPreview ? : null}
downloadDocumentFile(doc.key, displayedBody)}
>
Download document
{canDeleteDocuments ? : null}
{canDeleteDocuments ? (
setConfirmDeleteKey(doc.key)}
>
Delete document
) : null}
{
if (activeDraft) {
await handleDraftBlur(event);
}
}
: undefined}
onKeyDown={!isHistoricalPreview
? async (event) => {
if (activeDraft) {
await handleDraftKeyDown(event);
}
}
: undefined}
>
{isHistoricalPreview && selectedHistoricalRevision && (
Viewing revision {selectedHistoricalRevision.revisionNumber}
This is a historical preview. Restoring it creates a new latest revision and keeps history append-only.
)}
{activeConflict && !isHistoricalPreview && (
Out of date
This document changed while you were editing. Your local draft is preserved and autosave is paused.
{activeConflict.showRemote && (
Remote revision {activeConflict.serverDocument.latestRevisionNumber}
•
updated {relativeTime(activeConflict.serverDocument.updatedAt)}
{!isPlanKey(doc.key) && activeConflict.serverDocument.title ? (
{activeConflict.serverDocument.title}
) : null}
{renderBody(activeConflict.serverDocument.body, "text-[14px] leading-7")}
)}
)}
{activeDraft && !isPlanKey(doc.key) && !isHistoricalPreview && (
{
markDocumentDirty(doc.key);
setDraft((current) => current ? { ...current, title: event.target.value } : current);
}}
placeholder="Optional title"
/>
)}
{isHistoricalPreview ? (
{renderBody(displayedBody, documentBodyContentClassName)}
) : activeDraft ? (
{
markDocumentDirty(doc.key);
setDraft((current) => {
if (current && current.key === doc.key && !current.isNew) {
return { ...current, body };
}
return current;
});
}}
placeholder="Markdown body"
bordered={false}
className="bg-transparent"
contentClassName={documentBodyContentClassName}
mentions={mentions}
imageUploadHandler={imageUploadHandler}
onSubmit={() => void commitDraft(activeDraft ?? draft, { clearAfterSave: false, trackAutosave: true })}
/>
) : (
{renderBody(displayedBody, documentBodyContentClassName)}
)}
{isHistoricalPreview
? "Viewing historical revision"
: activeDraft
? activeConflict
? "Out of date"
: autosaveDocumentKey === doc.key
? autosaveState === "saving"
? "Autosaving..."
: autosaveState === "saved"
? "Saved"
: autosaveState === "error"
? "Could not save"
: ""
: ""
: ""}
{canVoteOnDocument && doc.latestRevisionId ? (
onVote?.(doc.latestRevisionId!, vote, options) ?? Promise.resolve()
}
/>
) : null}
) : null}
{confirmDeleteKey === doc.key && (
Delete this document? This cannot be undone.