From c5aedfffd1430b1f28b7e08d184d15fa4ca55431 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Tue, 18 Apr 2023 12:54:55 +0200 Subject: [PATCH] Enhancement: Add ability to open snippet in modal for editing #424 --- package.json | 6 ++++++ src/commands/Article.ts | 1 + src/constants/settings.ts | 2 ++ .../components/SnippetsView/SnippetForm.tsx | 7 +++++-- src/dashboardWebView/models/Settings.ts | 1 + src/helpers/DashboardSettings.ts | 4 +++- 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a4aa7e5d..bfa1283d 100644 --- a/package.json +++ b/package.json @@ -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)", diff --git a/src/commands/Article.ts b/src/commands/Article.ts index e1a5e0f5..9da7a049 100644 --- a/src/commands/Article.ts +++ b/src/commands/Article.ts @@ -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 ) { diff --git a/src/constants/settings.ts b/src/constants/settings.ts index 0e641015..098344db 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -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 */ diff --git a/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx b/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx index 9095cef6..dcc10dd7 100644 --- a/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx +++ b/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx @@ -106,8 +106,11 @@ const SnippetForm: React.ForwardRefRenderFunction(SETTING_DATA_TYPES), snippets: Settings.get(SETTING_CONTENT_SNIPPETS), + snippetsWrapper: Settings.get(SETTING_SNIPPETS_WRAPPER), isBacker: await ext.getState(CONTEXT.backer, 'global') } as ISettings;