Skip to content

Commit 1d485ad

Browse files
committed
Fix media snippet markup insertion to article content's #874
1 parent 9f2aa34 commit 1d485ad

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
### 🐞 Fixes
1414

15+
- [#874](https://github.com/estruyf/vscode-front-matter/issues/874): Fix media snippet markup insertion to article content's
16+
1517
## [10.5.0] - 2024-10-21 - [Release notes](https://beta.frontmatter.codes/updates/v10.5.0)
1618

1719
### 🎨 Enhancements

src/helpers/MediaHelpers.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
SETTING_MEDIA_SUPPORTED_MIMETYPES
1919
} from '../constants';
2020
import { SortingOption } from '../dashboardWebView/models';
21-
import { MediaInfo, MediaPaths, SortOrder, SortType } from '../models';
21+
import { BlockFieldData, MediaInfo, MediaPaths, SortOrder, SortType } from '../models';
2222
import { basename, join, parse, dirname, relative } from 'path';
2323
import { statSync } from 'fs';
2424
import { Uri, workspace, window, Position } from 'vscode';
@@ -376,7 +376,18 @@ export class MediaHelpers {
376376
* Insert an image into the front matter or contents
377377
* @param data
378378
*/
379-
public static async insertMediaToMarkdown(data: any) {
379+
public static async insertMediaToMarkdown(data: {
380+
file: string;
381+
relPath: string;
382+
snippet: string;
383+
position: Position;
384+
title?: string;
385+
alt?: string;
386+
caption?: string;
387+
fieldName: string;
388+
parents: string[];
389+
blockData: BlockFieldData;
390+
}) {
380391
if (data?.file && data?.relPath) {
381392
await EditorHelper.showFile(data.file);
382393
Dashboard.resetViewData();
@@ -444,7 +455,7 @@ export class MediaHelpers {
444455
const docType = Wysiwyg.getDocType(filePath);
445456

446457
let snippet = data.snippet || '';
447-
if (!data.Snippet) {
458+
if (!snippet) {
448459
if (docType === 'markdown') {
449460
snippet = `${isFile ? '' : '!'}[${caption}](${FrameworkDetector.relAssetPathUpdate(
450461
relPath,

0 commit comments

Comments
 (0)