commit
df3d73a2a2
@ -15,6 +15,7 @@ export default async function insertImageFile(
|
|||||||
try {
|
try {
|
||||||
// load the file as a data URL
|
// load the file as a data URL
|
||||||
const id = uuid.v4();
|
const id = uuid.v4();
|
||||||
|
const alt = '';
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener('load', () => {
|
reader.addEventListener('load', () => {
|
||||||
const src = reader.result;
|
const src = reader.result;
|
||||||
@ -24,7 +25,7 @@ export default async function insertImageFile(
|
|||||||
.insertBlock({
|
.insertBlock({
|
||||||
type: 'image',
|
type: 'image',
|
||||||
isVoid: true,
|
isVoid: true,
|
||||||
data: { src, id, loading: true },
|
data: { src, id, alt, loading: true },
|
||||||
})
|
})
|
||||||
.apply();
|
.apply();
|
||||||
editor.onChange(state);
|
editor.onChange(state);
|
||||||
@ -45,7 +46,7 @@ export default async function insertImageFile(
|
|||||||
);
|
);
|
||||||
|
|
||||||
return finalTransform.setNodeByKey(placeholder.key, {
|
return finalTransform.setNodeByKey(placeholder.key, {
|
||||||
data: { src, loading: false },
|
data: { src, alt, loading: false },
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
Reference in New Issue
Block a user