Editor.js: How to update some blocks, not all.

Created on 21 Mar 2020  路  6Comments  路  Source: codex-team/editor.js

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.

Most helpful comment

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.

All 6 comments

Hi @hughfenghen
We gonna export some Block API soon

@gohabereg Good, thanks~

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.

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?
ezgif-6-f6df70aabf40

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

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.

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 insert method with new arguments, but get an error: "Cannot read property 'config' of undefined". Could you take a look at the stackblits example? Thanks in advance!

https://stackblitz.com/edit/angular-editorjs-insert?file=src%2Fapp%2Fapp.component.ts

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.

is there any way to solve this problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cossssmin picture cossssmin  路  3Comments

davedbase picture davedbase  路  3Comments

Yakumo-Yukari picture Yakumo-Yukari  路  5Comments

Someskumarasamy picture Someskumarasamy  路  4Comments

vsvanshi picture vsvanshi  路  4Comments