GithubHelp home page GithubHelp logo

Comments (8)

slyguy5646 avatar slyguy5646 commented on May 20, 2024

Hey there, I wanted this feature for a project I'm working on so that I could load the state of the editor based on a DB and things like that. I think I have coded up a pretty decent solution if there isn't one already.

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

This should have been closed here: #154

See docs @ https://www.blocknotejs.org/docs/editor

from blocknote.

slyguy5646 avatar slyguy5646 commented on May 20, 2024

Is there a way to load this initial content from raw html or the json that tiptap gives back? For me it was a little awkard having to create the blocks and then pass it to the editor as the initial content. And if so, is this content easily storable in a database or the like to load later?

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

It's possible to convert to/from HTML, but not recommended. See https://www.blocknotejs.org/docs/converting-blocks

from blocknote.

slyguy5646 avatar slyguy5646 commented on May 20, 2024

This should have been closed here: #154

See docs @ https://www.blocknotejs.org/docs/editor

This shows how to store it, thanks.

from blocknote.

slyguy5646 avatar slyguy5646 commented on May 20, 2024

Hey there, sorry to bother again. The only problem I see with this method of loading initial data is doing it with asynchronous data. I tried it utilizing a useEffect hook for data fetching which then sets the data to a state variable. This doesn't load as initial content because the editor is done being instantiated before the data can be fetched. Is there a better way to accomplish this?

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

two options

a) you could create the editor only after the data has been fetched
b) you could replace the initial content with replaceblocks when the data has been loaded: https://www.blocknotejs.org/docs/manipulating-blocks#replacing-blocks (little less nice imo)

from blocknote.

slyguy5646 avatar slyguy5646 commented on May 20, 2024

Got it thanks so much.

from blocknote.

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.