Skip to content

block

const block: object

Defined in: src/helpers/block.helpers.ts:587

Factory functions that create Notion block objects.

Every function returns a plain object. Pass this object to blocks.children.append() or pages.create().

audio: (source) => BlockObject

string | FileSource

BlockObject

bookmark: (url, options?) => BlockObject

string

RichTextInput

BlockObject

breadcrumb: () => BlockObject

BlockObject

bulletedListItem: (text, options?) => BlockObject

RichTextInput

TextBlockOptions

BlockObject

callout: (text, options?) => BlockObject

RichTextInput

CalloutOptions

BlockObject

code: (content, language, options?) => BlockObject

string

"abap" | "arduino" | "bash" | "basic" | "c" | "clojure" | "coffeescript" | "c++" | "c#" | "css" | "dart" | "diff" | "docker" | "elixir" | "elm" | "erlang" | "flow" | "fortran" | "f#" | "gherkin" | "glsl" | "go" | "graphql" | "groovy" | "haskell" | "html" | "java" | "javascript" | "json" | "julia" | "kotlin" | "latex" | "less" | "lisp" | "livescript" | "lua" | "makefile" | "markdown" | "markup" | "matlab" | "mermaid" | "nix" | "objective-c" | "ocaml" | "pascal" | "perl" | "php" | "plain text" | "powershell" | "prolog" | "protobuf" | "python" | "r" | "reason" | "ruby" | "rust" | "sass" | "scala" | "scheme" | "scss" | "shell" | "sql" | "swift" | "typescript" | "vb.net" | "verilog" | "vhdl" | "visual basic" | "webassembly" | "xml" | "yaml" | "java/c/c++/c#"

CodeOptions

BlockObject

column: (children) => BlockObject

unknown[]

BlockObject

columnList: (columns) => BlockObject

unknown[][]

BlockObject

divider: () => BlockObject

BlockObject

embed: (url) => BlockObject

string

BlockObject

equation: (expression) => BlockObject

string

BlockObject

file: (source, options?) => BlockObject

string | FileSource

MediaOptions

BlockObject

heading1: (text, options?) => BlockObject

RichTextInput

HeadingOptions

BlockObject

heading2: (text, options?) => BlockObject

RichTextInput

HeadingOptions

BlockObject

heading3: (text, options?) => BlockObject

RichTextInput

HeadingOptions

BlockObject

heading4: (text, options?) => BlockObject

RichTextInput

HeadingOptions

BlockObject

image: (source, options?) => BlockObject

string | FileSource

MediaOptions

BlockObject

linkPreview: (url) => BlockObject

string

BlockObject

meetingNotes: (text, options?) => BlockObject

RichTextInput

unknown[]

BlockObject

numberedListItem: (text, options?) => BlockObject

RichTextInput

NumberedListOptions

BlockObject

paragraph: (text, options?) => BlockObject

Create a paragraph block.

RichTextInput

ParagraphOptions

BlockObject

block.paragraph('Hello world')
block.paragraph(richText('Hello').bold(), { color: 'blue' })

pdf: (source, options?) => BlockObject

string | FileSource

MediaOptions

BlockObject

quote: (text, options?) => BlockObject

RichTextInput

TextBlockOptions

BlockObject

syncedBlock: (options?) => BlockObject

Create a synced block.

  • Without syncedFrom: creates a new original synced block.
  • With syncedFrom: creates a reference to an existing synced block.

unknown[]

string

BlockObject

tab: (tabs) => BlockObject

Create a tab block. A tab block accepts only paragraph blocks as direct children. Each tab is one paragraph. The paragraph’s rich text holds the tab label. The paragraph’s children hold the tab’s content.

TabItem[]

BlockObject

block.tab([
{ label: 'Overview', children: [block.paragraph('Intro text')] },
{ label: 'Details', icon: icon.emoji('📋'), children: [block.paragraph('More info')] },
])

table: (width, options?) => BlockObject

number

TableOptions

BlockObject

tableOfContents: (options?) => BlockObject

"default" | "blue" | "blue_background" | "brown" | "brown_background" | "gray" | "gray_background" | "green" | "green_background" | "orange" | "orange_background" | "pink" | "pink_background" | "purple" | "purple_background" | "red" | "red_background" | "yellow" | "yellow_background"

BlockObject

tableRow: (cells) => BlockObject

RichTextInput[]

BlockObject

template: (text, options?) => BlockObject

RichTextInput

unknown[]

BlockObject

toDo: (text, options?) => BlockObject

RichTextInput

ToDoOptions

BlockObject

toggle: (text, options?) => BlockObject

RichTextInput

TextBlockOptions

BlockObject

video: (source, options?) => BlockObject

string | FileSource

MediaOptions

BlockObject

import { block, richText } from '@visus-io/notion-sdk-ts';
const children = [
block.heading1('My Page'),
block.paragraph('Some introductory text.'),
block.paragraph(richText('Bold intro').bold()),
block.toDo('First task', { checked: true }),
block.toDo('Second task'),
block.code('console.log("hi")', 'typescript'),
block.divider(),
block.quote('A wise saying'),
block.image('https://example.com/photo.png'),
block.table(2, {
hasColumnHeader: true,
children: [
block.tableRow(['Name', 'Value']),
block.tableRow(['Alpha', '1']),
],
}),
];