-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue] Updating Yoopta's content programatically #424
Comments
@SimpleVictor you can. Just use |
@Darginec05 So I gave that a try and yes it works once but when I tried using it again then it wouldn't update. For example below I have a nested timeout
|
@Darginec05 I've created a reproducible playground here (https://playcode.io/2208081) I have a button that calls |
Here is a temp solution for others. I essentially updated the ids defined in the value + forced a rerender with the setRandomIncrement hook
|
In general, the main thing is that the IDs of each block should be new with each content update. You can use this API: const setContent = () => {
// editor.withoutSavingHistory(() => {
const timestamp = Date.now().toString();
const blockId = generateId();
const elementId = generateId();
const blockData: YooptaBlockData = Blocks.buildBlockData({
id: blockId,
value: [
{
id: elementId,
type: 'heading-one',
children: [{ text: timestamp }],
props: {
nodeType: 'block',
},
},
],
});
editor.setEditorValue({ [blockId]: blockData });
// });
}; |
Then what is the point of library yoopta/exports? |
Has this bug been raised before?
Description
Are we able to update the editor's content programmatically? Maybe it wasn't intended to be updated like this?
I have a hook below to update the content after 3 seconds. However the change does not take effect at all. Is this expected?
Screenshots
No response
Do you want to work on this issue?
No
The text was updated successfully, but these errors were encountered: