Add new file UI (#14773)

Adds a notebook or markdown file to a book's top level or a section by right click on Book Tree View
This commit is contained in:
Barbara Valdez
2021-03-30 18:44:52 -07:00
committed by GitHub
parent b774f09b6c
commit 8aa222d1c8
13 changed files with 428 additions and 247 deletions

View File

@@ -0,0 +1,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { FileExtension } from '../common/utils';
export class TocEntryPathHandler {
public readonly fileInTocEntry: string;
public readonly titleInTocEntry: string;
public readonly fileExtension: FileExtension;
constructor(public readonly filePath: string, public readonly bookRoot: string, title?: string) {
const relativePath = path.relative(bookRoot, filePath);
const pathDetails = path.parse(relativePath);
this.fileInTocEntry = relativePath.replace(pathDetails.ext, '');
this.titleInTocEntry = title ?? pathDetails.name;
this.fileExtension = pathDetails.ext === FileExtension.Notebook ? FileExtension.Notebook : FileExtension.Markdown;
}
}