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
We’re in the process of migrating a custom plugin originally built for Plate.js v31 to the latest version. While adapting the plugin, we're trying to insert a custom FabricJS-based canvas element using a pattern similar to insertExcalidraw,
However, we're encountering the following error during insertion:
exportconstinsertFabricJSEditor=(editor: SlateEditor,props: NodeProps<TTextCanvasElement>={},options: InsertNodesOptions={}): void=>{if(!editor||!editor.selection){console.warn('Editor or selection is not valid');return;}constselection=editor.selection;letinsertPath;try{if(selection.focus&&selection.focus.path){constselectionParentEntry=editor.api.parent(selection.focus.path);if(selectionParentEntry){const[,parentPath]=selectionParentEntry;insertPath=parentPath;}}}catch(error){console.error('Error determining insertion path:',error);}if(!insertPath){try{constlastNodeEntry=editor.api.last([]);if(lastNodeEntry){const[,lastPath]=lastNodeEntry;insertPath=lastPath;}else{insertPath=[0];}}catch(error){console.error('Error determining fallback insertion path:',error);insertPath=[0];}}constcurrentQuestion: Question=(propsasTTextCanvasElement).currentQuestion??getDefaultQuestion();console.log('insertPath',insertPath);editor.tf.insertNodes<TTextCanvasElement>({type: editor.getType({key: ELEMENT_CANVAS}),children: [{type: ParagraphPlugin.key,text: currentQuestion.question,},{text: ''},],
currentQuestion,currentCanvasData: '',
...props,},{at: insertPath,nextBlock: true,
...(optionsasany),});};
Is this error due to changes in the editor.api.parent or insertNodes usage in the latest Plate architecture? What would be the recommended approach to insert a block-level custom element now
Any guidance or updated example would be greatly appreciated!
Reproduction URL
No response
Reproduction steps
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
This discussion was converted from issue #4301 on May 14, 2025 11:42.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Hi team,
We’re in the process of migrating a custom plugin originally built for Plate.js v31 to the latest version. While adapting the plugin, we're trying to insert a custom FabricJS-based canvas element using a pattern similar to insertExcalidraw,
However, we're encountering the following error during insertion:
Here’s the code for the insert function:
Is this error due to changes in the editor.api.parent or insertNodes usage in the latest Plate architecture? What would be the recommended approach to insert a block-level custom element now
Any guidance or updated example would be greatly appreciated!
Reproduction URL
No response
Reproduction steps
Plate version
41
Slate React version
0.114
Screenshots
Logs
Browsers
No response
Beta Was this translation helpful? Give feedback.
All reactions