Fix media snippet markup insertion to article content's #874

This commit is contained in:
Elio Struyf
2024-10-23 10:30:43 +02:00
parent 9f2aa34aac
commit 1d485adbca
2 changed files with 16 additions and 3 deletions
+2
View File
@@ -12,6 +12,8 @@
### 🐞 Fixes
- [#874](https://github.com/estruyf/vscode-front-matter/issues/874): Fix media snippet markup insertion to article content's
## [10.5.0] - 2024-10-21 - [Release notes](https://beta.frontmatter.codes/updates/v10.5.0)
### 🎨 Enhancements
+14 -3
View File
@@ -18,7 +18,7 @@ import {
SETTING_MEDIA_SUPPORTED_MIMETYPES
} from '../constants';
import { SortingOption } from '../dashboardWebView/models';
import { MediaInfo, MediaPaths, SortOrder, SortType } from '../models';
import { BlockFieldData, MediaInfo, MediaPaths, SortOrder, SortType } from '../models';
import { basename, join, parse, dirname, relative } from 'path';
import { statSync } from 'fs';
import { Uri, workspace, window, Position } from 'vscode';
@@ -376,7 +376,18 @@ export class MediaHelpers {
* Insert an image into the front matter or contents
* @param data
*/
public static async insertMediaToMarkdown(data: any) {
public static async insertMediaToMarkdown(data: {
file: string;
relPath: string;
snippet: string;
position: Position;
title?: string;
alt?: string;
caption?: string;
fieldName: string;
parents: string[];
blockData: BlockFieldData;
}) {
if (data?.file && data?.relPath) {
await EditorHelper.showFile(data.file);
Dashboard.resetViewData();
@@ -444,7 +455,7 @@ export class MediaHelpers {
const docType = Wysiwyg.getDocType(filePath);
let snippet = data.snippet || '';
if (!data.Snippet) {
if (!snippet) {
if (docType === 'markdown') {
snippet = `${isFile ? '' : '!'}[${caption}](${FrameworkDetector.relAssetPathUpdate(
relPath,