mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-06 18:01:24 +02:00
Dependency updates + Panel view refactoring
This commit is contained in:
@@ -3,7 +3,7 @@ import { COMMAND_NAME, CONTEXT } from '../constants';
|
||||
import { Extension } from '../helpers';
|
||||
import { Credentials } from '../services/Credentials';
|
||||
import fetch from 'node-fetch';
|
||||
import { ExplorerView } from '../explorerView/ExplorerView';
|
||||
import { PanelWebview } from '../PanelWebview/PanelWebview';
|
||||
import { Dashboard } from './Dashboard';
|
||||
import { SettingsListener } from '../listeners/panel';
|
||||
|
||||
@@ -61,8 +61,8 @@ export class Backers {
|
||||
await ext.setState(CONTEXT.backer, true, 'global');
|
||||
|
||||
if (!prevData) {
|
||||
const explorerView = ExplorerView.getInstance();
|
||||
if (explorerView.visible) {
|
||||
const PanelView = PanelWebview.getInstance();
|
||||
if (PanelView.visible) {
|
||||
SettingsListener.getSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from './../constants';
|
||||
import * as vscode from 'vscode';
|
||||
import { ArticleHelper, Notifications, SeoHelper, Settings } from '../helpers';
|
||||
import { ExplorerView } from '../explorerView/ExplorerView';
|
||||
import { PanelWebview } from '../PanelWebview/PanelWebview';
|
||||
import { DefaultFields } from '../constants';
|
||||
import { ContentType } from '../helpers/ContentType';
|
||||
import { DataListener } from '../listeners/panel';
|
||||
@@ -91,7 +91,7 @@ export class StatusListener {
|
||||
}
|
||||
}
|
||||
|
||||
const panel = ExplorerView.getInstance();
|
||||
const panel = PanelWebview.getInstance();
|
||||
if (panel && panel.visible) {
|
||||
DataListener.pushMetadata(article?.data);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ export class StatusListener {
|
||||
} else {
|
||||
commands.executeCommand('setContext', CONTEXT.isValidFile, false);
|
||||
|
||||
const panel = ExplorerView.getInstance();
|
||||
const panel = PanelWebview.getInstance();
|
||||
if (panel && panel.visible) {
|
||||
DataListener.pushMetadata(null);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export const TelemetryEvent = {
|
||||
insertMediaToContent: 'insertMediaToContent',
|
||||
insertFileToContent: 'insertFileToContent',
|
||||
updateMediaMetadata: 'updateMediaMetadata',
|
||||
openExplorerView: 'openExplorerView',
|
||||
openPanelWebview: 'openPanelWebview',
|
||||
|
||||
// Chatbot
|
||||
openChatbot: 'openChatbot',
|
||||
|
||||
+6
-6
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
|
||||
import { COMMAND_NAME, TelemetryEvent } from './constants';
|
||||
import { MarkdownFoldingProvider } from './providers/MarkdownFoldingProvider';
|
||||
import { TagType } from './panelWebView/TagType';
|
||||
import { ExplorerView } from './explorerView/ExplorerView';
|
||||
import { PanelWebview } from './PanelWebview/PanelWebview';
|
||||
import { DashboardSettings, debounceCallback, Logger, Settings as SettingsHelper } from './helpers';
|
||||
import ContentProvider from './providers/ContentProvider';
|
||||
import { PagesListener } from './listeners/dashboard';
|
||||
@@ -124,9 +124,9 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
|
||||
// Register the explorer view
|
||||
const explorerSidebar = ExplorerView.getInstance(extensionUri);
|
||||
const explorerView = vscode.window.registerWebviewViewProvider(
|
||||
ExplorerView.viewType,
|
||||
const explorerSidebar = PanelWebview.getInstance(extensionUri);
|
||||
const PanelView = vscode.window.registerWebviewViewProvider(
|
||||
PanelWebview.viewType,
|
||||
explorerSidebar,
|
||||
{
|
||||
webviewOptions: {
|
||||
@@ -264,7 +264,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
// Collapse all sections in the webview
|
||||
const collapseAll = vscode.commands.registerCommand(COMMAND_NAME.collapseSections, () => {
|
||||
ExplorerView.getInstance()?.collapseAll();
|
||||
PanelWebview.getInstance()?.collapseAll();
|
||||
});
|
||||
|
||||
// Things to do when configuration changes
|
||||
@@ -370,7 +370,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
// Subscribe all commands
|
||||
subscriptions.push(
|
||||
insertTags,
|
||||
explorerView,
|
||||
PanelView,
|
||||
insertCategories,
|
||||
createTag,
|
||||
createCategory,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { STATIC_FOLDER_PLACEHOLDER } from './../constants/StaticFolderPlaceholder';
|
||||
import { ExplorerView } from './../explorerView/ExplorerView';
|
||||
import { PanelWebview } from './../PanelWebview/PanelWebview';
|
||||
import { Uri, window } from 'vscode';
|
||||
import { dirname, extname, join } from 'path';
|
||||
import { Field } from '../models';
|
||||
@@ -104,7 +104,7 @@ export class ImageHelper {
|
||||
*/
|
||||
public static processImageFields(updatedMetadata: any, fields: Field[], parents: string[] = []) {
|
||||
const imageFields = fields.filter((field) => field.type === 'image');
|
||||
const panel = ExplorerView.getInstance();
|
||||
const panel = PanelWebview.getInstance();
|
||||
|
||||
// Support multi-level fields
|
||||
let parentObj = updatedMetadata;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { GeneralCommands } from './../../constants/GeneralCommands';
|
||||
import { Dashboard } from '../../commands/Dashboard';
|
||||
import { ExplorerView } from '../../explorerView/ExplorerView';
|
||||
import { PanelWebview } from '../../PanelWebview/PanelWebview';
|
||||
import { Extension } from '../../helpers';
|
||||
import { Logger } from '../../helpers/Logger';
|
||||
import { commands, Uri } from 'vscode';
|
||||
@@ -26,7 +26,7 @@ export abstract class BaseListener {
|
||||
Logger.info(`Sending message to webview (panel&dashboard): ${command}`);
|
||||
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
panel.sendMessage({ command: command as any, payload });
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from './../../constants/settings';
|
||||
import { Settings } from './../../helpers/SettingsHelper';
|
||||
import { Dashboard } from '../../commands/Dashboard';
|
||||
import { ExplorerView } from '../../explorerView/ExplorerView';
|
||||
import { PanelWebview } from '../../PanelWebview/PanelWebview';
|
||||
import {
|
||||
ArticleHelper,
|
||||
Extension,
|
||||
@@ -258,7 +258,7 @@ export class GitListener {
|
||||
*/
|
||||
private static sendMsg(command: string, payload: any) {
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
panel.sendMessage({ command: command as any, payload });
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Extension } from './../../helpers/Extension';
|
||||
import { ExplorerView } from './../../explorerView/ExplorerView';
|
||||
import { PanelWebview } from './../../PanelWebview/PanelWebview';
|
||||
import { Logger } from '../../helpers';
|
||||
import { Command } from '../../panelWebView/Command';
|
||||
import { PostMessageData } from '../../models';
|
||||
@@ -16,7 +16,7 @@ export abstract class BaseListener {
|
||||
Logger.info(`Sending message to panel: ${command}`);
|
||||
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
panel.sendMessage({
|
||||
command,
|
||||
@@ -28,7 +28,7 @@ export abstract class BaseListener {
|
||||
Logger.info(`Sending request result to panel: ${command}`);
|
||||
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
panel.getWebview()?.postMessage({
|
||||
command,
|
||||
@@ -41,7 +41,7 @@ export abstract class BaseListener {
|
||||
Logger.info(`Sending request error to the panel: ${command}`);
|
||||
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
panel.getWebview()?.postMessage({
|
||||
command,
|
||||
|
||||
@@ -20,7 +20,7 @@ import { ParsedFrontMatter } from '../../parsers';
|
||||
import { processKnownPlaceholders } from '../../helpers/PlaceholderHelper';
|
||||
import { Field, PostMessageData } from '../../models';
|
||||
import { encodeEmoji } from '../../utils';
|
||||
import { ExplorerView } from '../../explorerView/ExplorerView';
|
||||
import { PanelWebview } from '../../PanelWebview/PanelWebview';
|
||||
import { MessageHandlerData } from '@estruyf/vscode';
|
||||
import { SponsorAi } from '../../services/SponsorAI';
|
||||
|
||||
@@ -84,7 +84,7 @@ export class DataListener extends BaseListener {
|
||||
}
|
||||
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
const editor = window.activeTextEditor;
|
||||
if (!editor) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ExplorerView } from './../../explorerView/ExplorerView';
|
||||
import { PanelWebview } from './../../PanelWebview/PanelWebview';
|
||||
import { commands, window } from 'vscode';
|
||||
import { Dashboard } from '../../commands/Dashboard';
|
||||
import { COMMAND_NAME } from '../../constants';
|
||||
@@ -38,7 +38,7 @@ export class MediaListener extends BaseListener {
|
||||
return;
|
||||
}
|
||||
|
||||
const panel = ExplorerView.getInstance();
|
||||
const panel = PanelWebview.getInstance();
|
||||
|
||||
if (typeof payload === 'string') {
|
||||
const imagePath = payload;
|
||||
@@ -75,7 +75,7 @@ export class MediaListener extends BaseListener {
|
||||
|
||||
const imgUrl = ImageHelper.relToAbs(filePath || '', data);
|
||||
if (imgUrl) {
|
||||
const viewUrl = ExplorerView.getInstance().getWebview()?.asWebviewUri(imgUrl);
|
||||
const viewUrl = PanelWebview.getInstance().getWebview()?.asWebviewUri(imgUrl);
|
||||
if (viewUrl) {
|
||||
this.sendMsg(Command.sendMediaUrl, {
|
||||
original: data,
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
SETTING_SEO_TITLE_FIELD
|
||||
} from '../../constants';
|
||||
import { SponsorAi } from '../../services/SponsorAI';
|
||||
import { ExplorerView } from '../../explorerView/ExplorerView';
|
||||
import { PanelWebview } from '../../PanelWebview/PanelWebview';
|
||||
import { MessageHandlerData } from '@estruyf/vscode';
|
||||
|
||||
export class TaxonomyListener extends BaseListener {
|
||||
@@ -71,7 +71,7 @@ export class TaxonomyListener extends BaseListener {
|
||||
}
|
||||
|
||||
const extPath = Extension.getInstance().extensionPath;
|
||||
const panel = ExplorerView.getInstance(extPath);
|
||||
const panel = PanelWebview.getInstance(extPath);
|
||||
|
||||
const editor = window.activeTextEditor;
|
||||
if (!editor) {
|
||||
|
||||
@@ -29,9 +29,9 @@ import { Telemetry } from '../helpers/Telemetry';
|
||||
import { GitListener, ModeListener } from '../listeners/general';
|
||||
import { Folders } from '../commands';
|
||||
|
||||
export class ExplorerView implements WebviewViewProvider, Disposable {
|
||||
export class PanelWebview implements WebviewViewProvider, Disposable {
|
||||
public static readonly viewType = 'frontMatter.explorer';
|
||||
private static instance: ExplorerView;
|
||||
private static instance: PanelWebview;
|
||||
|
||||
private panel: WebviewView | null = null;
|
||||
private disposable: Disposable | null = null;
|
||||
@@ -42,12 +42,12 @@ export class ExplorerView implements WebviewViewProvider, Disposable {
|
||||
* Creates the singleton instance for the panel
|
||||
* @param extPath
|
||||
*/
|
||||
public static getInstance(extPath?: Uri): ExplorerView {
|
||||
if (!ExplorerView.instance) {
|
||||
ExplorerView.instance = new ExplorerView(extPath as Uri);
|
||||
public static getInstance(extPath?: Uri): PanelWebview {
|
||||
if (!PanelWebview.instance) {
|
||||
PanelWebview.instance = new PanelWebview(extPath as Uri);
|
||||
}
|
||||
|
||||
return ExplorerView.instance;
|
||||
return PanelWebview.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ export class ExplorerView implements WebviewViewProvider, Disposable {
|
||||
|
||||
webviewView.onDidChangeVisibility(() => {
|
||||
if (this.visible) {
|
||||
Telemetry.send(TelemetryEvent.openExplorerView);
|
||||
Telemetry.send(TelemetryEvent.openPanelWebview);
|
||||
DataListener.getFileData();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user