mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Book Editing: Support adding new sections to a book (#17074)
* add a new section command
This commit is contained in:
@@ -18,7 +18,7 @@ export interface IBookTocManager {
|
||||
updateBook(sources: BookTreeItem[], target: BookTreeItem, targetSection?: JupyterBookSection): Promise<void>;
|
||||
removeNotebook(element: BookTreeItem): Promise<void>;
|
||||
createBook(bookContentPath: string, contentFolder: string): Promise<void>;
|
||||
addNewFile(pathDetails: TocEntryPathHandler, bookItem: BookTreeItem): Promise<void>;
|
||||
addNewTocEntry(pathDetails: TocEntryPathHandler, bookItem: BookTreeItem, isSection?: boolean): Promise<void>;
|
||||
recovery(): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ export class BookTocManager implements IBookTocManager {
|
||||
}
|
||||
}
|
||||
|
||||
public async addNewFile(pathDetails: TocEntryPathHandler, bookItem: BookTreeItem): Promise<void> {
|
||||
public async addNewTocEntry(pathDetails: TocEntryPathHandler, bookItem: BookTreeItem, isSection?: boolean): Promise<void> {
|
||||
let findSection: JupyterBookSection | undefined = undefined;
|
||||
await fs.writeFile(pathDetails.filePath, '');
|
||||
if (bookItem.contextValue === 'section') {
|
||||
@@ -453,6 +453,11 @@ export class BookTocManager implements IBookTocManager {
|
||||
title: pathDetails.titleInTocEntry,
|
||||
file: pathDetails.fileInTocEntry
|
||||
};
|
||||
|
||||
if (isSection) {
|
||||
fileEntryInToc.sections = [];
|
||||
}
|
||||
|
||||
if (bookItem.book.version === BookVersion.v1) {
|
||||
fileEntryInToc = convertTo(BookVersion.v1, fileEntryInToc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user