Skip to content

Commit 09d41c7

Browse files
committed
fix: keep image attrs consistant with mdast
1 parent a35d8ef commit 09d41c7

File tree

9 files changed

+115
-117
lines changed

9 files changed

+115
-117
lines changed

examples/svelte-rollup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"rollup-plugin-postcss": "^3.1.8",
1717
"rollup-plugin-svelte": "^7.1.0",
1818
"rollup-plugin-terser": "^7.0.2",
19-
"svelte": "^3.32.3"
19+
"svelte": "^3.34.0"
2020
},
2121
"dependencies": {
2222
"sirv-cli": "^1.0.11"

examples/svelte-ssr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"npm-run-all": "^4.1.5",
3131
"sapper": "^0.27.16",
3232
"style-loader": "^1.3.0",
33-
"svelte": "^3.32.3",
33+
"svelte": "^3.34.0",
3434
"svelte-loader": "^2.13.6",
3535
"webpack": "^4.46.0"
3636
}

examples/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"katex": "^0.12.0",
2424
"normalize.css": "^8.0.1",
2525
"style-loader": "^0.23.1",
26-
"svelte": "^3.32.3",
26+
"svelte": "^3.34.0",
2727
"svelte-loader": "2.13.6",
2828
"webpack": "^4.46.0",
2929
"webpack-cli": "^3.3.12",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"rollup-plugin-terser": "^7.0.2",
4646
"rollup-plugin-visualizer": "^4.2.0",
4747
"rollup-plugin-vue": "^5.1.9",
48-
"svelte": "^3.32.3",
48+
"svelte": "^3.34.0",
4949
"svelte-jester": "^1.3.0",
5050
"svelte-preprocess": "^4.6.9",
5151
"svgo": "^2.1.0",

packages/bytemd/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
"lib"
2626
],
2727
"dependencies": {
28-
"@popperjs/core": "^2.8.3",
28+
"@popperjs/core": "^2.8.4",
2929
"@types/classnames": "^2.2.11",
3030
"@types/codemirror": "^0.0.108",
3131
"@types/lodash.debounce": "^4.0.6",
3232
"@types/lodash.throttle": "^4.1.6",
33+
"@types/mdast": "^3.0.3",
3334
"classnames": "^2.2.6",
3435
"codemirror-ssr": "^0.0.6",
3536
"hast-util-sanitize": "^3.0.2",
@@ -41,8 +42,8 @@
4142
"remark-parse": "^9.0.0",
4243
"remark-rehype": "^8.0.0",
4344
"select-files": "^1.0.1",
44-
"tippy.js": "^6.3.0",
45-
"unified": "^9.2.0",
45+
"tippy.js": "^6.3.1",
46+
"unified": "^9.2.1",
4647
"vfile": "^4.2.1"
4748
}
4849
}

packages/bytemd/src/editor.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@
277277
const imgs = await uploadImages(files);
278278
context.appendBlock(
279279
imgs
280-
.map(({ src, alt, title }, i) => {
280+
.map(({ url, alt, title }, i) => {
281281
alt = alt ?? files[i].name;
282-
return `![${alt}](${src}${title ? ` "${title}"` : ''})`;
282+
return `![${alt}](${url}${title ? ` "${title}"` : ''})`;
283283
})
284284
.join('\n\n')
285285
);

packages/bytemd/src/editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ export function getBuiltinActions(
186186
const imgs = await uploadImages(files);
187187
const { line, ch } = appendBlock(
188188
imgs
189-
.map(({ src, alt, title }, i) => {
189+
.map(({ url, alt, title }, i) => {
190190
alt = alt ?? files[i].name;
191-
return `![${alt}](${src}${title ? ` "${title}"` : ''})`;
191+
return `![${alt}](${url}${title ? ` "${title}"` : ''})`;
192192
})
193193
.join('\n\n')
194194
);

packages/bytemd/src/types.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { VFile } from 'vfile';
44
import type { Editor, EditorConfiguration } from 'codemirror';
55
import type { EditorUtils } from './editor';
66
import type { BytemdLocale } from './locales/en-US';
7+
import type { Image } from 'mdast';
78

89
export interface BytemdEditorContext extends EditorUtils {
910
/**
@@ -124,13 +125,7 @@ export interface EditorProps extends ViewerProps {
124125
*/
125126
uploadImages?: (
126127
files: File[]
127-
) => Promise<
128-
{
129-
src: string;
130-
alt?: string;
131-
title?: string;
132-
}[]
133-
>;
128+
) => Promise<Pick<Image, 'url' | 'alt' | 'title'>[]>;
134129
}
135130

136131
export interface ViewerProps {

0 commit comments

Comments
 (0)