-
Hi there, useEffect(() => {
if (editingItem) { // received item to edit from external props
const content = [
{
type: 'paragraph',
children: [
{
text: editingItem.text,
},
],
},
];
// insert tags at the end
editingItem.tags?.forEach((tag) => {
content[0].children.push({
type: 'tag',
tagText: tag,
children: [{text: ''}],
});
content[0].children.push({text: ''});
});
// set editor value
setValue(content);
// Trying to move cursor, but it doesn't work
setTimeout(() => {
// What should I run here?
Transforms.move(editor, {unit: 'line', edge: 'end'});
}, 0);
}
}, [editingItem, editor]); However, the cursor still remains at the beginning of the editor Seems like I am missing some core concept. |
Beta Was this translation helpful? Give feedback.
Answered by
Deliaz
Oct 17, 2021
Replies: 1 comment
-
Found out this code does what I want: setTimeout(() => {
Transforms.select(editor, Editor.end(editor, []));
}, 10); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Deliaz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found out this code does what I want: