GithubHelp home page GithubHelp logo

Comments (8)

altumsoftwareds avatar altumsoftwareds commented on May 21, 2024

If I will pass expected data directly as prop ( not waiting for response ) -- there is no issues at all.

from editor.js.

altumsoftwareds avatar altumsoftwareds commented on May 21, 2024

@neSpecc could you help, please?
1)
Безымянный

Безымянный

  1. onChange triggers with empty data however current answer is exists and it rewrites answer to be empty
  2. even after some additional rerenders of component ( as soon as I get requested from BE data from props ) current answer becomes correct again, but editor doesn't rerenders with correct answer ( data ) object

from editor.js.

altumsoftwareds avatar altumsoftwareds commented on May 21, 2024
<Editor 
                        key={`editor-${section}-${item}`} 
                        data={answer} 
                        onChange={(data) => {
                            console.log('editor beforeOnChange answer', answer)
                            console.log('editor onChange', data)
                            setAnswer(data)
                        }}
                        editorblock={`editorjs-container-${section}-${item}`} 
                    />

why I don't see current answer after onChange as soon as I have setAnswer which is the part of useState?

from editor.js.

neSpecc avatar neSpecc commented on May 21, 2024

@altumsoftwareds would you test in it 2.29.0-rc.4?

from editor.js.

ls84 avatar ls84 commented on May 21, 2024

I am not sure if this is related, I am getting the same "warning" when I put editor.save() method inside the onChange function. However It is fine when I trigger editor.save() somewhere else

editor = new EditorJS({
    holder : 'summary',
    onChange: function(api, event) {
        editor.save().then(console.log)
    }
});

from editor.js.

altumsoftwareds avatar altumsoftwareds commented on May 21, 2024

@ls84 where to put editor.save() else, for example?

from editor.js.

ls84 avatar ls84 commented on May 21, 2024

@ls84 where to put editor.save() else, for example?

I am guessing the problem of Block «paragraph» skipped because saved data is invalid is caused by saving data before it's ready to be saved out. My solution was to bind editor.save() to a button click action. Hope this helps

from editor.js.

a3626a avatar a3626a commented on May 21, 2024

It's because the Paragraph delays saving its data to element. And the save function makes data from its element.
(And the warning occurs when the element has empty body)

requestAnimationFrame causes the problem.

https://github.com/editor-js/paragraph/blob/6fff362a536599ba1f05a9dfd642d51668ac557b/src/index.js#L239-L254

There are two solutions.

  1. Override the Paragraph and remove 'requestAnimationFrame' logic.
  2. Save using requestAnimationFrame inside onChange. This will make the save is called after hydrate. (FIFO)

from editor.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.