Giter Site home page Giter Site logo

Comments (5)

matthewlipski avatar matthewlipski commented on August 30, 2024

Yes! It's just that the code style button is not included in the formatting toolbar by default, see here how to add it. You can also wrap text in tilde ("`") characters to convert it to code.

from blocknote.

ugeshgupta000 avatar ugeshgupta000 commented on August 30, 2024

Thankyou for responding. One more question along the lines:

I am looking to implement a custom block, which can contain code, and when rendered, gets a button on the side to quickly copy the code. In this case, the code is expected to be a multi-line code. For rendering the button, i was thinking of doing similar to https://www.blocknotejs.org/examples/ui-components/formatting-toolbar-block-type-items

As per my understanding, in blocknote, each line becomes a separate block. Is there a way to combine a selection of lines into a single block, and yet still maintain the multi-line content inside it? Please let me know in case you have other suggestions to implement it. Thanks in advance.

from blocknote.

matthewlipski avatar matthewlipski commented on August 30, 2024

You can indeed have line breaks inside blocks, allowing you to have multiple lines in a single block (Shift+Enter is the keyboard shortcut for that). If you want to write code in that block, you'll most likely want to also override the Tab and Enter keyboard shortcuts, see how to do that here.

from blocknote.

ugeshgupta000 avatar ugeshgupta000 commented on August 30, 2024

Can you help me on:

  • how to combine multiple blocks into a single one
  • how to extract the string contents from specific blocks and not from entire document.

Sorry, i tried, but i am not getting appropriate examples to achieve the same.

from blocknote.

matthewlipski avatar matthewlipski commented on August 30, 2024

There is no API functionality to merge multiple blocks, since that's a pretty niche use case. The best you can do is call editor._tiptapEditor.commands.BNMergeBlocks multiple times but this uses the ProseMirror API.

To get the plain text of a block you have to process its content, which is in the form of InlineContent[]. It contains styled text and links, so you just need to loop over everything and concat the text of each InlineContent object to a string.

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.