mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 01:13:08 +02:00
Enhancement: Add ability to open snippet in modal for editing #424
This commit is contained in:
@@ -339,6 +339,12 @@
|
||||
"markdownDescription": "Specify the folder name where all your assets are located. For instance in Hugo this is the `static` folder. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.content.publicfolder)",
|
||||
"scope": "Content"
|
||||
},
|
||||
"frontMatter.snippets.wrapper": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"markdownDescription": "Specify if you want to wrap the snippets. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontMatter.snippets.wrapper)",
|
||||
"scope": "Content"
|
||||
},
|
||||
"frontMatter.content.snippets": {
|
||||
"type": "object",
|
||||
"markdownDescription": "Define the snippets you want to use in your content. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.content.snippets)",
|
||||
|
||||
@@ -448,6 +448,7 @@ export class Article {
|
||||
let snippetInfo: { id: string; fields: any[] } | undefined = undefined;
|
||||
let range: SnippetRange | undefined = undefined;
|
||||
if (
|
||||
snippetEndAfterPos > -1 &&
|
||||
(snippetStartAfterPos > snippetEndAfterPos || snippetStartAfterPos === -1) &&
|
||||
snippetStartBeforePos
|
||||
) {
|
||||
|
||||
@@ -94,6 +94,8 @@ export const SETTING_GIT_SUBMODULE_PUSH = 'git.submodule.push';
|
||||
export const SETTING_GIT_SUBMODULE_BRANCH = 'git.submodule.branch';
|
||||
export const SETTING_GIT_SUBMODULE_FOLDER = 'git.submodule.folder';
|
||||
|
||||
export const SETTING_SNIPPETS_WRAPPER = 'snippets.wrapper';
|
||||
|
||||
/**
|
||||
* Sponsors only settings
|
||||
*/
|
||||
|
||||
@@ -106,8 +106,11 @@ const SnippetForm: React.ForwardRefRenderFunction<SnippetFormHandle, ISnippetFor
|
||||
}
|
||||
|
||||
if (!onInsert) {
|
||||
if (!snippetKey) {
|
||||
Messenger.send(DashboardMessage.insertSnippet, snippetBody);
|
||||
if (!snippetKey || settings?.snippetsWrapper === false) {
|
||||
Messenger.send(DashboardMessage.insertSnippet, {
|
||||
file: viewData?.data?.filePath,
|
||||
snippet: snippetBody
|
||||
});
|
||||
} else {
|
||||
Messenger.send(DashboardMessage.insertSnippet, {
|
||||
file: viewData?.data?.filePath,
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface Settings {
|
||||
dataTypes: DataType[] | undefined;
|
||||
isBacker: boolean | undefined;
|
||||
snippets: Snippets | undefined;
|
||||
snippetsWrapper: boolean;
|
||||
date: { format: string };
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ import {
|
||||
SETTING_TAXONOMY_CUSTOM,
|
||||
SETTING_TEMPLATES_ENABLED,
|
||||
SETTING_GIT_ENABLED,
|
||||
SETTING_DASHBOARD_CONTENT_PAGINATION
|
||||
SETTING_DASHBOARD_CONTENT_PAGINATION,
|
||||
SETTING_SNIPPETS_WRAPPER
|
||||
} from '../constants';
|
||||
import {
|
||||
DashboardViewType,
|
||||
@@ -119,6 +120,7 @@ export class DashboardSettings {
|
||||
dataFiles: await this.getDataFiles(),
|
||||
dataTypes: Settings.get<DataType[]>(SETTING_DATA_TYPES),
|
||||
snippets: Settings.get<Snippets>(SETTING_CONTENT_SNIPPETS),
|
||||
snippetsWrapper: Settings.get<boolean>(SETTING_SNIPPETS_WRAPPER),
|
||||
isBacker: await ext.getState<boolean | undefined>(CONTEXT.backer, 'global')
|
||||
} as ISettings;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user