block
constblock: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().
Type Declaration
Section titled “Type Declaration”audio: (
source) =>BlockObject
Parameters
Section titled “Parameters”source
Section titled “source”string | FileSource
Returns
Section titled “Returns”BlockObject
bookmark
Section titled “bookmark”bookmark: (
url,options?) =>BlockObject
Parameters
Section titled “Parameters”string
options?
Section titled “options?”caption?
Section titled “caption?”Returns
Section titled “Returns”BlockObject
breadcrumb
Section titled “breadcrumb”breadcrumb: () =>
BlockObject
Returns
Section titled “Returns”BlockObject
bulletedListItem
Section titled “bulletedListItem”bulletedListItem: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”TextBlockOptions
Returns
Section titled “Returns”BlockObject
callout
Section titled “callout”callout: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”CalloutOptions
Returns
Section titled “Returns”BlockObject
code: (
content,language,options?) =>BlockObject
Parameters
Section titled “Parameters”content
Section titled “content”string
language
Section titled “language”"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#"
options?
Section titled “options?”CodeOptions
Returns
Section titled “Returns”BlockObject
column
Section titled “column”column: (
children) =>BlockObject
Parameters
Section titled “Parameters”children
Section titled “children”unknown[]
Returns
Section titled “Returns”BlockObject
columnList
Section titled “columnList”columnList: (
columns) =>BlockObject
Parameters
Section titled “Parameters”columns
Section titled “columns”unknown[][]
Returns
Section titled “Returns”BlockObject
divider
Section titled “divider”divider: () =>
BlockObject
Returns
Section titled “Returns”BlockObject
embed: (
url) =>BlockObject
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”BlockObject
equation
Section titled “equation”equation: (
expression) =>BlockObject
Parameters
Section titled “Parameters”expression
Section titled “expression”string
Returns
Section titled “Returns”BlockObject
file: (
source,options?) =>BlockObject
Parameters
Section titled “Parameters”source
Section titled “source”string | FileSource
options?
Section titled “options?”MediaOptions
Returns
Section titled “Returns”BlockObject
heading1
Section titled “heading1”heading1: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”HeadingOptions
Returns
Section titled “Returns”BlockObject
heading2
Section titled “heading2”heading2: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”HeadingOptions
Returns
Section titled “Returns”BlockObject
heading3
Section titled “heading3”heading3: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”HeadingOptions
Returns
Section titled “Returns”BlockObject
heading4
Section titled “heading4”heading4: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”HeadingOptions
Returns
Section titled “Returns”BlockObject
image: (
source,options?) =>BlockObject
Parameters
Section titled “Parameters”source
Section titled “source”string | FileSource
options?
Section titled “options?”MediaOptions
Returns
Section titled “Returns”BlockObject
linkPreview
Section titled “linkPreview”linkPreview: (
url) =>BlockObject
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”BlockObject
meetingNotes
Section titled “meetingNotes”meetingNotes: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”children?
Section titled “children?”unknown[]
Returns
Section titled “Returns”BlockObject
numberedListItem
Section titled “numberedListItem”numberedListItem: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”NumberedListOptions
Returns
Section titled “Returns”BlockObject
paragraph
Section titled “paragraph”paragraph: (
text,options?) =>BlockObject
Create a paragraph block.
Parameters
Section titled “Parameters”options?
Section titled “options?”ParagraphOptions
Returns
Section titled “Returns”BlockObject
Example
Section titled “Example”block.paragraph('Hello world')block.paragraph(richText('Hello').bold(), { color: 'blue' })pdf: (
source,options?) =>BlockObject
Parameters
Section titled “Parameters”source
Section titled “source”string | FileSource
options?
Section titled “options?”MediaOptions
Returns
Section titled “Returns”BlockObject
quote: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”TextBlockOptions
Returns
Section titled “Returns”BlockObject
syncedBlock
Section titled “syncedBlock”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.
Parameters
Section titled “Parameters”options?
Section titled “options?”children?
Section titled “children?”unknown[]
syncedFrom?
Section titled “syncedFrom?”string
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”TabItem[]
Returns
Section titled “Returns”BlockObject
Example
Section titled “Example”block.tab([ { label: 'Overview', children: [block.paragraph('Intro text')] }, { label: 'Details', icon: icon.emoji('📋'), children: [block.paragraph('More info')] },])table: (
width,options?) =>BlockObject
Parameters
Section titled “Parameters”number
options?
Section titled “options?”TableOptions
Returns
Section titled “Returns”BlockObject
tableOfContents
Section titled “tableOfContents”tableOfContents: (
options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”color?
Section titled “color?”"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"
Returns
Section titled “Returns”BlockObject
tableRow
Section titled “tableRow”tableRow: (
cells) =>BlockObject
Parameters
Section titled “Parameters”Returns
Section titled “Returns”BlockObject
template
Section titled “template”template: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”children?
Section titled “children?”unknown[]
Returns
Section titled “Returns”BlockObject
toDo: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”ToDoOptions
Returns
Section titled “Returns”BlockObject
toggle
Section titled “toggle”toggle: (
text,options?) =>BlockObject
Parameters
Section titled “Parameters”options?
Section titled “options?”TextBlockOptions
Returns
Section titled “Returns”BlockObject
video: (
source,options?) =>BlockObject
Parameters
Section titled “Parameters”source
Section titled “source”string | FileSource
options?
Section titled “options?”MediaOptions
Returns
Section titled “Returns”BlockObject
Example
Section titled “Example”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']), ], }),];