mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-08 09:53:20 +02:00
Removed draft toggle + Added fm action
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
### 🎨 Enhancements
|
||||
|
||||
- Grouping and status tabs enhancements
|
||||
- Removed the status bar item to toggle the draft field
|
||||
- Added a FM status bar item to open the dashboard
|
||||
- [#570](https://github.com/estruyf/vscode-front-matter/issues/570): Clear empty values on content creation and editing
|
||||
- [#645](https://github.com/estruyf/vscode-front-matter/issues/645): French localization added (thanks to [Clément Barbaza](https://github.com/cba85))
|
||||
- [#649](https://github.com/estruyf/vscode-front-matter/issues/649): Parse optional variables from snippets
|
||||
|
||||
Binary file not shown.
@@ -55,6 +55,15 @@
|
||||
],
|
||||
"main": "./dist/extension.js",
|
||||
"contributes": {
|
||||
"icons": {
|
||||
"fm-logo": {
|
||||
"description": "Front Matter icon",
|
||||
"default": {
|
||||
"fontPath": "assets/frontmatter.woff",
|
||||
"fontCharacter": "\\e900"
|
||||
}
|
||||
}
|
||||
},
|
||||
"configurationDefaults": {
|
||||
"files.associations": {
|
||||
"**/frontmatter.json": "jsonc",
|
||||
|
||||
@@ -24,18 +24,7 @@ export class StatusListener {
|
||||
* @param frontMatterSB
|
||||
* @param collection
|
||||
*/
|
||||
public static async verify(
|
||||
frontMatterSB: vscode.StatusBarItem,
|
||||
collection: vscode.DiagnosticCollection
|
||||
) {
|
||||
const draftMsg = 'in draft';
|
||||
const publishMsg = 'to publish';
|
||||
|
||||
const draft = ContentType.getDraftField();
|
||||
if (!draft || draft.type !== 'boolean') {
|
||||
frontMatterSB.hide();
|
||||
}
|
||||
|
||||
public static async verify(collection: vscode.DiagnosticCollection) {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
let document = editor?.document;
|
||||
|
||||
@@ -54,17 +43,6 @@ export class StatusListener {
|
||||
? ArticleHelper.getFrontMatter(editor)
|
||||
: await ArticleHelper.getFrontMatterByPath(document.uri.fsPath);
|
||||
|
||||
// Update the StatusBar based on the article draft state
|
||||
if (article && typeof article.data['draft'] !== 'undefined') {
|
||||
if (article.data['draft'] === true) {
|
||||
frontMatterSB.text = `$(book) ${draftMsg}`;
|
||||
frontMatterSB.show();
|
||||
} else if (article.data['draft'] === false) {
|
||||
frontMatterSB.text = `$(book) ${publishMsg}`;
|
||||
frontMatterSB.show();
|
||||
}
|
||||
}
|
||||
|
||||
// Check SEO and required fields
|
||||
if (article && article.data) {
|
||||
collection.clear();
|
||||
@@ -108,8 +86,6 @@ export class StatusListener {
|
||||
DataListener.pushMetadata(null);
|
||||
}
|
||||
}
|
||||
|
||||
frontMatterSB.hide();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ export const COMMAND_NAME = {
|
||||
setLastModifiedDate: getCommandName('setLastModifiedDate'),
|
||||
generateSlug: getCommandName('generateSlug'),
|
||||
createFromTemplate: getCommandName('createFromTemplate'),
|
||||
toggleDraft: getCommandName('toggleDraft'),
|
||||
registerFolder: getCommandName('registerFolder'),
|
||||
unregisterFolder: getCommandName('unregisterFolder'),
|
||||
createContent: getCommandName('createContent'),
|
||||
|
||||
+20
-21
@@ -37,8 +37,7 @@ import {
|
||||
} from './commands';
|
||||
import { join } from 'path';
|
||||
|
||||
let frontMatterStatusBar: vscode.StatusBarItem;
|
||||
let statusDebouncer: { (fnc: any, time: number): void };
|
||||
let pageUpdateDebouncer: { (fnc: any, time: number): void };
|
||||
let editDebounce: { (fnc: any, time: number): void };
|
||||
let collection: vscode.DiagnosticCollection;
|
||||
|
||||
@@ -190,12 +189,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
)
|
||||
);
|
||||
|
||||
const toggleDraftCommand = COMMAND_NAME.toggleDraft;
|
||||
const toggleDraft = vscode.commands.registerCommand(toggleDraftCommand, async () => {
|
||||
await Article.toggleDraft();
|
||||
triggerShowDraftStatus(`toggleDraft`);
|
||||
});
|
||||
|
||||
// Register project folders
|
||||
const registerFolder = vscode.commands.registerCommand(
|
||||
COMMAND_NAME.registerFolder,
|
||||
@@ -277,21 +270,27 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
SettingsHelper.startListening();
|
||||
|
||||
// Create the status bar
|
||||
frontMatterStatusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
|
||||
frontMatterStatusBar.command = toggleDraftCommand;
|
||||
subscriptions.push(frontMatterStatusBar);
|
||||
statusDebouncer = debounceCallback();
|
||||
let fmStatusBarItem = vscode.window.createStatusBarItem(
|
||||
'fm-statusBarItem',
|
||||
vscode.StatusBarAlignment.Right,
|
||||
-100
|
||||
);
|
||||
fmStatusBarItem.command = COMMAND_NAME.dashboard;
|
||||
fmStatusBarItem.text = `$(fm-logo)`;
|
||||
fmStatusBarItem.tooltip = `Front Matter CMS`;
|
||||
fmStatusBarItem.show();
|
||||
|
||||
// Register listeners that make sure the status bar updates
|
||||
pageUpdateDebouncer = debounceCallback();
|
||||
subscriptions.push(
|
||||
vscode.window.onDidChangeActiveTextEditor(() =>
|
||||
triggerShowDraftStatus(`onDidChangeActiveTextEditor`)
|
||||
triggerPageUpdate(`onDidChangeActiveTextEditor`)
|
||||
)
|
||||
);
|
||||
subscriptions.push(
|
||||
vscode.window.onDidChangeTextEditorSelection((e) => {
|
||||
if (e.kind === vscode.TextEditorSelectionChangeKind.Mouse) {
|
||||
statusDebouncer(() => triggerShowDraftStatus(`onDidChangeTextEditorSelection`), 200);
|
||||
pageUpdateDebouncer(() => triggerPageUpdate(`onDidChangeTextEditorSelection`), 200);
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -300,13 +299,13 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
const filePath = TextDocumentChangeEvent.document.uri.fsPath;
|
||||
if (filePath && !filePath.toLowerCase().startsWith(`extension-output`)) {
|
||||
MarkdownFoldingProvider.triggerHighlighting();
|
||||
statusDebouncer(() => triggerShowDraftStatus(`onDidChangeTextEditorSelection`), 200);
|
||||
pageUpdateDebouncer(() => triggerPageUpdate(`onDidChangeTextEditorSelection`), 200);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Automatically run the command
|
||||
triggerShowDraftStatus(`triggerShowDraftStatus`);
|
||||
triggerPageUpdate(`main`);
|
||||
|
||||
// Listener for file edit changes
|
||||
subscriptions.push(vscode.workspace.onWillSaveTextDocument(handleAutoDateUpdate));
|
||||
@@ -378,14 +377,14 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
generateSlug,
|
||||
createFromTemplate,
|
||||
createTemplate,
|
||||
toggleDraft,
|
||||
registerFolder,
|
||||
unregisterFolder,
|
||||
createContent,
|
||||
createByContentType,
|
||||
createByTemplate,
|
||||
collapseAll,
|
||||
createFolder
|
||||
createFolder,
|
||||
fmStatusBarItem
|
||||
);
|
||||
|
||||
console.log(`𝖥𝗋𝗈𝗇𝗍 𝖬𝖺𝗍𝗍𝖾𝗋 𝖢𝖬𝖲 𝖺𝖼𝗍𝗂𝗏𝖺𝗍𝖾𝖽! 𝖱𝖾𝖺𝖽𝗒 𝗍𝗈 𝗌𝗍𝖺𝗋𝗍 𝗐𝗋𝗂𝗍𝗂𝗇𝗀... 👩💻🧑💻👨💻`);
|
||||
@@ -397,9 +396,9 @@ const handleAutoDateUpdate = (e: vscode.TextDocumentWillSaveEvent) => {
|
||||
Article.autoUpdate(e);
|
||||
};
|
||||
|
||||
const triggerShowDraftStatus = (location: string) => {
|
||||
const triggerPageUpdate = (location: string) => {
|
||||
Logger.info(`Triggering draft status update: ${location}`);
|
||||
statusDebouncer(() => {
|
||||
StatusListener.verify(frontMatterStatusBar, collection);
|
||||
pageUpdateDebouncer(() => {
|
||||
StatusListener.verify(collection);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user