mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-12 03:43:01 +02:00
Windows fixes
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
# Change Log
|
||||
|
||||
## [3.0.0]
|
||||
## [3.0.0] - 2020-08-27
|
||||
|
||||
- [#61](https://github.com/estruyf/vscode-front-matter/issues/61): List of recently modified files
|
||||
- [#64](https://github.com/estruyf/vscode-front-matter/issues/64): Publish toggle for easier publishing an article
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
- Fix typo in the `package.json` file for the preview command
|
||||
|
||||
## [2.5.0] - 2020-08-19
|
||||
## [2.5.0] - 2020-08-19
|
||||
|
||||
- Moved the center layout button to the other actions section
|
||||
- [#60](https://github.com/estruyf/vscode-front-matter/issues/60): Added the ability to open a site preview in VS Code
|
||||
|
||||
@@ -196,8 +196,7 @@ export class Article {
|
||||
overwrite: false
|
||||
});
|
||||
} catch (e) {
|
||||
Notifications.error(`Failed to rename file.`);
|
||||
console.log(e?.message || e);
|
||||
Notifications.error(`Failed to rename file: ${e?.message || e}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-14
@@ -24,22 +24,22 @@ export class Dashboard {
|
||||
/**
|
||||
* Init the dashboard
|
||||
*/
|
||||
public static async init(extensionPath: string) {
|
||||
public static async init() {
|
||||
const config = SettingsHelper.getConfig();
|
||||
const openOnStartup = config.get(SETTINGS_DASHBOARD_OPENONSTART);
|
||||
if (openOnStartup) {
|
||||
Dashboard.open(extensionPath);
|
||||
Dashboard.open();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open or reveal the dashboard
|
||||
*/
|
||||
public static async open(extensionPath: string) {
|
||||
public static async open() {
|
||||
if (Dashboard.isOpen) {
|
||||
Dashboard.reveal();
|
||||
} else {
|
||||
Dashboard.create(extensionPath);
|
||||
Dashboard.create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ export class Dashboard {
|
||||
/**
|
||||
* Create the dashboard webview
|
||||
*/
|
||||
public static async create(extensionPath: string) {
|
||||
public static async create() {
|
||||
const extensionUri = Extension.getInstance().extensionPath;
|
||||
|
||||
// Create the preview webview
|
||||
Dashboard.webview = window.createWebviewPanel(
|
||||
@@ -77,11 +78,11 @@ export class Dashboard {
|
||||
Dashboard.isDisposed = false;
|
||||
|
||||
Dashboard.webview.iconPath = {
|
||||
dark: Uri.file(join(extensionPath, 'assets/frontmatter-dark.svg')),
|
||||
light: Uri.file(join(extensionPath, 'assets/frontmatter.svg'))
|
||||
dark: Uri.file(join(extensionUri.fsPath, 'assets/frontmatter-dark.svg')),
|
||||
light: Uri.file(join(extensionUri.fsPath, 'assets/frontmatter.svg'))
|
||||
};
|
||||
|
||||
Dashboard.webview.webview.html = Dashboard.getWebviewContent(Dashboard.webview.webview, Uri.parse(extensionPath));
|
||||
Dashboard.webview.webview.html = Dashboard.getWebviewContent(Dashboard.webview.webview, extensionUri);
|
||||
|
||||
Dashboard.webview.onDidChangeViewState(() => {
|
||||
if (this.webview?.visible) {
|
||||
@@ -113,16 +114,12 @@ export class Dashboard {
|
||||
Dashboard.updateSetting(msg.data);
|
||||
break;
|
||||
case DashboardMessage.InitializeProject:
|
||||
await commands.executeCommand(COMMAND_NAME.init);
|
||||
// Delay to allow the project to be initialized
|
||||
setTimeout(() => {
|
||||
Dashboard.getSettings();
|
||||
}, 1000);
|
||||
await commands.executeCommand(COMMAND_NAME.init, Dashboard.getSettings);
|
||||
break;
|
||||
case DashboardMessage.Reload:
|
||||
Dashboard.webview?.dispose();
|
||||
setTimeout(() => {
|
||||
Dashboard.open(Extension.getInstance().extensionPath);
|
||||
Dashboard.open();
|
||||
}, 100);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ export class Folders {
|
||||
const projectName = Folders.getProjectFolderName();
|
||||
let projectStart = folder.fsPath.split(projectName).pop();
|
||||
if (projectStart) {
|
||||
projectStart = projectStart.replace(/\\/g, '/');
|
||||
projectStart = projectStart.startsWith('/') ? projectStart.substr(1) : projectStart;
|
||||
const mdFiles = await workspace.findFiles(join(projectStart, '**/*.md'));
|
||||
const mdxFiles = await workspace.findFiles(join(projectStart, '**/*.mdx'));
|
||||
|
||||
@@ -251,7 +251,6 @@ export class Settings {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(file.path);
|
||||
// Continue with the next file
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ export class StatusListener {
|
||||
|
||||
// Update the StatusBar based on the article draft state
|
||||
if (article && typeof article.data["draft"] !== "undefined") {
|
||||
// console.log(`Draft status: ${article.data["draft"]}`);
|
||||
if (article.data["draft"] === true) {
|
||||
frontMatterSB.text = `$(book) ${draftMsg}`;
|
||||
frontMatterSB.show();
|
||||
|
||||
+10
-4
@@ -20,14 +20,14 @@ let collection: vscode.DiagnosticCollection;
|
||||
const mdSelector: vscode.DocumentSelector = { language: 'markdown', scheme: 'file' };
|
||||
|
||||
export async function activate({ subscriptions, extensionUri, extensionPath, globalState }: vscode.ExtensionContext) {
|
||||
const extension = Extension.getInstance(globalState, extensionPath);
|
||||
const extension = Extension.getInstance(globalState, extensionUri);
|
||||
|
||||
collection = vscode.languages.createDiagnosticCollection('frontMatter');
|
||||
|
||||
// Pages dashboard
|
||||
Dashboard.init(extensionPath);
|
||||
Dashboard.init();
|
||||
subscriptions.push(vscode.commands.registerCommand(COMMAND_NAME.dashboard, () => {
|
||||
Dashboard.open(extensionPath);
|
||||
Dashboard.open();
|
||||
}));
|
||||
|
||||
if (!extension.getVersion().usedVersion) {
|
||||
@@ -101,7 +101,13 @@ export async function activate({ subscriptions, extensionUri, extensionPath, glo
|
||||
|
||||
// Initialize command
|
||||
Template.init();
|
||||
const projectInit = vscode.commands.registerCommand(COMMAND_NAME.init, Project.init);
|
||||
const projectInit = vscode.commands.registerCommand(COMMAND_NAME.init, async (cb: Function) => {
|
||||
await Project.init();
|
||||
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
|
||||
// Collapse all sections in the webview
|
||||
const collapseAll = vscode.commands.registerCommand(COMMAND_NAME.collapseSections, () => {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { Memento, extensions } from "vscode";
|
||||
import { Memento, extensions, Uri } from "vscode";
|
||||
import { EXTENSION_ID, EXTENSION_STATE_VERSION } from "../constants/Extension";
|
||||
|
||||
|
||||
export class Extension {
|
||||
private static instance: Extension;
|
||||
|
||||
private constructor(private globalState: Memento, private extPath: string) {}
|
||||
private constructor(private globalState: Memento, private extPath: Uri) {}
|
||||
|
||||
/**
|
||||
* Creates the singleton instance for the panel
|
||||
* @param extPath
|
||||
*/
|
||||
public static getInstance(globalState?: Memento, extPath?: string): Extension {
|
||||
public static getInstance(globalState?: Memento, extPath?: Uri): Extension {
|
||||
if (!Extension.instance && globalState && extPath) {
|
||||
Extension.instance = new Extension(globalState, extPath);
|
||||
}
|
||||
@@ -19,6 +19,9 @@ export class Extension {
|
||||
return Extension.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version information for the extension
|
||||
*/
|
||||
public getVersion(): { usedVersion: string | undefined, installedVersion: string } {
|
||||
const frontMatter = extensions.getExtension(EXTENSION_ID)!;
|
||||
const installedVersion = frontMatter.packageJSON.version;
|
||||
@@ -34,11 +37,17 @@ export class Extension {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current version information for the extension
|
||||
*/
|
||||
public setVersion(installedVersion: string): void {
|
||||
this.globalState.update(EXTENSION_STATE_VERSION, installedVersion);
|
||||
}
|
||||
|
||||
public get extensionPath(): string {
|
||||
/**
|
||||
* Get the path to the extension
|
||||
*/
|
||||
public get extensionPath(): Uri {
|
||||
return this.extPath;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ const DEFAULT_VALUE = "No filter";
|
||||
|
||||
export const Filter: React.FunctionComponent<IFilterProps> = ({label, activeItem, items, onClick}: React.PropsWithChildren<IFilterProps>) => {
|
||||
|
||||
console.log(items);
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ export const Startup: React.FunctionComponent<IStartupProps> = ({settings}: Reac
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
console.log(`openOnStart`, settings.openOnStart);
|
||||
setIsChecked(!!settings.openOnStart);
|
||||
}, [settings?.openOnStart]);
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ export const GlobalSettings: React.FunctionComponent<IGlobalSettingsProps> = ({s
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isDirty) {
|
||||
console.log(debouncePreviewUrl);
|
||||
setIsDirty(false);
|
||||
MessageHelper.sendMessage(CommandToCode.updatePreviewUrl, debouncePreviewUrl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user