mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-08 09:53:20 +02:00
Fix media snippet markup insertion to article content's #874
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user