You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before with the deserializeHtml.getNode function we could return a async function.
But now parsers.html.deserializer.parse only accept sync function.
Reproduction URL
No response
Reproduction steps
I'm building a custom image plugin based on the platejs plugin.
A image plugin that only support image uploading. I need to handle pasting image.
import{withImageUpload}from"./with-image-upload";importtype{Image}from"@/database/types";import{typePluginConfig,typeTElement,createTSlatePlugin,}from"@udecode/plate-common";exportinterfaceTImageElementextendsTElement{image: Image;}exporttypeImageConfig=PluginConfig<"img",{/** * Method that will upload the image to a server. * The method receives the file of the uploaded image, and should return the uploaded image. */uploadImage?: (file: File)=>Promise<Image>;/** * Method that will delete the image from a server. * The method receives the id of the image to delete. */deleteImage?: (imageId: string)=>Promise<void>;}>;exportconstImagePlugin=createTSlatePlugin<ImageConfig>({extendEditor: withImageUpload,key: "img",node: {isElement: true,isVoid: true},}).extend(({ plugin })=>({parsers: {html: {deserializer: {parse: async({ element, getOptions })=>{constuploadImage=getOptions().uploadImage;if(!uploadImage)return;constsrc=element.getAttribute("src");constalt=element.getAttribute("alt");if(!src)return;constresponse=awaitfetch(src);constblob=awaitresponse.blob();constname=src.split("/").pop()||"image";constfile=newFile([blob],name);constimage=awaituploadImage(file);return{type: plugin.node.type,
image,};},rules: [{validNodeName: "IMG",},],},},},}));
Plate version
^37.0.0
Slate React version
^37.0.0
Screenshots
No response
Logs
No response
Browsers
No response
Funding
You can sponsor this specific effort via a Polar.sh pledge below
We receive the pledge once the issue is completed & verified
The text was updated successfully, but these errors were encountered:
Description
Before with the
deserializeHtml.getNode
function we could return a async function.But now
parsers.html.deserializer.parse
only accept sync function.Reproduction URL
No response
Reproduction steps
I'm building a custom image plugin based on the platejs plugin.
A image plugin that only support image uploading. I need to handle pasting image.
Plate version
^37.0.0
Slate React version
^37.0.0
Screenshots
No response
Logs
No response
Browsers
No response
Funding
The text was updated successfully, but these errors were encountered: