1.0.4 • Published 12 days ago

@defensestation/blocknote-code v1.0.4

Weekly downloads
-
License
-
Repository
github
Last release
12 days ago

Code block for Blocknote

Stability Badge npm.io

Code block for Blocknote.

npm.io

Demo

A demo is worth a thousand words

Installation

Install via YARN

Get the package

$ yarn add @defensestation/blocknote-code

Usage

Include module at your application

import { CodeBlock, insertCode } from "@defensestation/blocknote-code";

Create schema with code block.

const schema = BlockNoteSchema.create({
   blockSpecs: {
    ...defaultBlockSpecs,
    procode: CodeBlock,
  },
});

Add slash menu item.

<BlockNoteView
    editor={editor}
    slashMenu={false}
  >
    <SuggestionMenuController
      triggerCharacter={"/"}
      getItems={async (query) =>
        filterSuggestionItems(
          [...getDefaultReactSlashMenuItems(editor), insertCode()],
          query
        )
      }
    />
  </BlockNoteView>