How to update some blocks, not all. #1877
Replies: 10 comments
-
Hi @hughfenghen |
Beta Was this translation helpful? Give feedback.
-
@gohabereg Good, thanks~ |
Beta Was this translation helpful? Give feedback.
-
Hi @hughfenghen I've opened a #1075 PR with Block API. However, at the moment we can't provide a method to update a certain block, as data passed to the Tool constructor. So to update it, we need to construct the new Block with updated data and replace the old one. I don't think this approach is the best one, so we need to design a block update flow and describe it with APIs and docs. |
Beta Was this translation helpful? Give feedback.
-
I tried to refactor some code from render method. But when I click Edit from settings part, the edit UI show and hide immediately and show the rendered result. Maybe I should wait for the new feature? scenario: a textarea to edit KaTeX. here is the js file: https://gist.github.com/taurenshaman/3cd1dc489defe2999c27fdcc1140ceea demo: https://taurenshaman.github.io/demo/editor@codexteam+katex.html?v=3 |
Beta Was this translation helpful? Give feedback.
-
Hi @gohabereg. Thanks a lot for the PR! That's exactly what I need. Only one question, how can I use it? I tried to call updated https://stackblitz.com/edit/angular-editorjs-insert?file=src%2Fapp%2Fapp.component.ts |
Beta Was this translation helpful? Give feedback.
-
is there any way to solve this problem |
Beta Was this translation helpful? Give feedback.
-
i need it too |
Beta Was this translation helpful? Give feedback.
-
👀 |
Beta Was this translation helpful? Give feedback.
-
2021-03-20.11.49.39.movIf you update all the blocks, the page will jump, so the user experience is very bad let block_data = await this.editor.save();
block_data = _.cloneDeep(block_data);
let find_index = _.findIndex(block_data.blocks, x => {
return x.data.meta_data._id == a.data.meta_data._id;
});
let old_info = block_data.blocks[find_index];
let new_data = _.cloneDeep(old_info);
new_data.data = _.cloneDeep(a.data);
block_data.blocks[find_index] = new_data;
this.editor.blocks.render(block_data);
Is there any way to execute a plug-in function from the outside? For example, a function of the plug-in is responsible for local updates, rather than re rendering the entire component |
Beta Was this translation helpful? Give feedback.
-
I think this is a good feature request! I approach to use the diff library: https://github.com/kpdecker/jsdiff |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, i know editor.render() can update all blocks, Is there any way to update only a certain block?
I see from the source that BlockMananger may be able to do it, but it is not a public API.
If editor.js can get or update specific blocks, it may be beneficial for collaborative editing and performance.
Beta Was this translation helpful? Give feedback.
All reactions