mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 17:23:35 -05:00
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:
20
extensions/notebook/src/book/tocEntryPathHandler.ts
Normal file
20
extensions/notebook/src/book/tocEntryPathHandler.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user