feat: Add option to 'Create new child doc' from link editor

This commit is contained in:
Tom Moor
2023-12-27 22:40:21 -05:00
parent 7be71fda61
commit bd7d5c338d
8 changed files with 56 additions and 28 deletions

View File

@@ -43,7 +43,7 @@ type Children = (options: {
revision: Revision | undefined;
abilities: Record<string, boolean>;
readOnly: boolean;
onCreateLink: (title: string) => Promise<string>;
onCreateLink: (title: string, nested?: boolean) => Promise<string>;
sharedTree: NavigationNode | undefined;
}) => React.ReactNode;
@@ -152,14 +152,14 @@ function DataLoader({ match, children }: Props) {
}, [document?.id, document?.isDeleted, revisionId, views]);
const onCreateLink = React.useCallback(
async (title: string) => {
async (title: string, nested?: boolean) => {
if (!document) {
throw new Error("Document not loaded yet");
}
const newDocument = await documents.create({
collectionId: document.collectionId,
parentDocumentId: document.parentDocumentId,
parentDocumentId: nested ? document.id : document.parentDocumentId,
title,
text: "",
});

View File

@@ -78,7 +78,7 @@ type Props = WithTranslation &
revision?: Revision;
readOnly: boolean;
shareId?: string;
onCreateLink?: (title: string) => Promise<string>;
onCreateLink?: (title: string, nested?: boolean) => Promise<string>;
onSearchLink?: (term: string) => any;
};