mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-06 01:41:48 +02:00
#554 - hide media snippets
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
- [#535](https://github.com/estruyf/vscode-front-matter/issues/535): Retain the scroll position after selecting a media file
|
||||
- [#538](https://github.com/estruyf/vscode-front-matter/issues/538): Added support to encode emojis in the string field
|
||||
- [#549](https://github.com/estruyf/vscode-front-matter/issues/549): Git submodule support to sync changes
|
||||
- [#554](https://github.com/estruyf/vscode-front-matter/issues/554): When inserting snippets, only the content snippets will be shown
|
||||
|
||||
### ⚡️ Optimizations
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ export const QuickAction: React.FunctionComponent<IQuickActionProps> = ({
|
||||
type="button"
|
||||
title={title}
|
||||
onClick={onClick}
|
||||
className={`px-2 group inline-flex justify-center text-sm font-medium ${
|
||||
getColors(
|
||||
'text-vulcan-400 hover:text-vulcan-600 dark:text-gray-400 dark:hover:text-whisper-600',
|
||||
'text-[var(--vscode-foreground)] hover:text-[var(--vscode-list-activeSelectionForeground)]'
|
||||
)
|
||||
}`}
|
||||
className={`px-2 group inline-flex justify-center text-sm font-medium ${getColors(
|
||||
'text-vulcan-400 hover:text-vulcan-600 dark:text-gray-400 dark:hover:text-whisper-600',
|
||||
'text-[var(--vscode-foreground)] hover:text-[var(--frontmatter-button-hoverBackground)]'
|
||||
)
|
||||
}`}
|
||||
>
|
||||
{children}
|
||||
<span className="sr-only">{title}</span>
|
||||
|
||||
@@ -35,7 +35,14 @@ export const Snippets: React.FunctionComponent<ISnippetsProps> = (
|
||||
|
||||
const snippets = settings?.snippets || {};
|
||||
const snippetKeys = useMemo(() => {
|
||||
const allSnippetKeys = Object.keys(snippets).sort((a, b) => a.localeCompare(b));
|
||||
let allSnippetKeys = Object.keys(snippets).sort((a, b) => a.localeCompare(b));
|
||||
|
||||
if (viewData?.data?.filePath) {
|
||||
allSnippetKeys = allSnippetKeys.filter((key) => {
|
||||
return !snippets[key].isMediaSnippet;
|
||||
});
|
||||
}
|
||||
|
||||
return allSnippetKeys.filter((key) => {
|
||||
const value = snippetFilter.toLowerCase();
|
||||
const keyValue = key.toLowerCase();
|
||||
@@ -44,7 +51,9 @@ export const Snippets: React.FunctionComponent<ISnippetsProps> = (
|
||||
// Contains in key or description, values included in key are ranked higher (sort and fuzzy search)
|
||||
return keyValue.includes(value) || descriptionValue.includes(value);
|
||||
});
|
||||
}, [settings?.snippets, snippetFilter]);
|
||||
|
||||
|
||||
}, [settings?.snippets, snippetFilter, viewData?.data?.filePath]);
|
||||
|
||||
const onSnippetAdd = useCallback(() => {
|
||||
if (!snippetTitle || !snippetBody) {
|
||||
|
||||
Reference in New Issue
Block a user