-
I'm looking to customize a plugin that allows me to pass selected text from plate component to another component from my component. Do you think this is feasible, or do you have any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Can you explain in more detail what you're trying to achieve? |
Beta Was this translation helpful? Give feedback.
-
Here's how I would do that: // This component should be rendered inside a PlateProvider,
// or else `editor` should be accessed another way
export default () => {
const editor = usePlateEditorState();
const selectionValue = useMemo(() => selection
? getEditorString(editor, editor.selection)
: 'No selection'
), [editor, editor.selection]);
return <textarea value={selectionValue} readOnly />;
}; You'll need to wrap the relevant parts of your application inside a PlateProvider in order for Alternatively, you could access the selected text through the DOM using |
Beta Was this translation helpful? Give feedback.
Here's how I would do that:
You'll need to wrap the relevant parts of your application inside a PlateProvider in order for
usePlateEditorState
to work. If wrapping in a PlateProvider isn't practical, you can try one of the other ways of getting access to theeditor
described here.Alternatively, you could acc…