From 160d9013584b70245dfb9da02c531727903742c2 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 7 Sep 2023 21:57:40 +0200 Subject: [PATCH] Removed draft toggle + Added fm action --- CHANGELOG.md | 2 ++ assets/frontmatter.woff | Bin 0 -> 1376 bytes package.json | 9 ++++++++ src/commands/StatusListener.ts | 26 +-------------------- src/constants/Extension.ts | 1 - src/extension.ts | 41 ++++++++++++++++----------------- 6 files changed, 32 insertions(+), 47 deletions(-) create mode 100644 assets/frontmatter.woff diff --git a/CHANGELOG.md b/CHANGELOG.md index 91426c06..fef7a50d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/frontmatter.woff b/assets/frontmatter.woff new file mode 100644 index 0000000000000000000000000000000000000000..46ae87e4ec554c4893244dcbfa61a9d6e460bc6a GIT binary patch literal 1376 zcmaJ=O=uHA6n<}JH%&J+vDR48w64TIJk*~yt+lNde+pHKP)im3>n2^(LX#~?iY_refsuw{#c<4a{!IKD{RXkL0iU+Mt{APCjDHh-Ed-J{Ty_q-rX7<9dzCL1t zm?IR?<7#D>lVits>?YzcVk1gptIX}0oHGe-4E~VP#^G02vQANPPvNUvr7N=&Gv~oQ zgPv4ciaxF#bDdElnLxZ<>86Fxx5hw%Q)_KfS~DV_kL60!;Gm@Tw%Q^}Pk0%XcO8D6 z)@?MGbEZ*O-iB{$jZ!A>5n9|ibc?Y|;=n(bO01eU!I;Bo{ zbFzM8JQ;6|C+izp8=AQhZ+lxuH>dUs5J}m#CAFn3wS&QQ^VXUuZ(3d(mWR)z^e0=J~TM zSQs)EU2B0kyuR{??Zn=u<{o?Ti}-#irR9e|q*OnH9*$rA=A4Ulf2D|_yZm;;8~vyF zW6(Wy&(Ucun5XXo4pxc0^J^vTDr5Q)-&fP%r?qF{jyKbNJ;NkN|2?>re&!MzrH8?~ zOf`u3yA{AA0hYk+0XBfA0&L<>j|Vse{%C+LT1VH^9W!ddL=o|^0L}(j0`~;i0KODp zlh%+O;1Kx109({X_r^0`&hzp#P8sqj2lXgF>=ugSUf$l-vXh3%r2-X^fB@FnMJ=>* z*;&hygKl { - 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); };