prosekit/extensions/code-block
Interfaces
Section titled “Interfaces”CodeBlockAttrs
Section titled “CodeBlockAttrs”The attributes for the codeBlock node.
Properties
Section titled “Properties”-
language:string
ShikiBundledLanguageInfo
Section titled “ShikiBundledLanguageInfo”Properties
Section titled “Properties”-
id:string
-
name:string
-
import:DynamicImportLanguageRegistration
-
aliases?:string[]
ShikiBundledThemeInfo
Section titled “ShikiBundledThemeInfo”Properties
Section titled “Properties”-
id:string
-
displayName:string
-
type:"light"|"dark"
-
import:DynamicImportThemeRegistration
Type Aliases
Section titled “Type Aliases”HighlightParser
Section titled “HighlightParser”-
type HighlightParser =Parser -
An alias for the
Parsertype from theprosemirror-highlightpackage.
CodeBlockHighlightOptions
Section titled “CodeBlockHighlightOptions”type CodeBlockHighlightOptions = { parser: HighlightParser; }
Properties
Section titled “Properties”ShikiBundledLanguage
Section titled “ShikiBundledLanguage”-
type ShikiBundledLanguage ="1c"|"1c-query"|"abap"|"actionscript-3"|"ada"|"adoc"|"angular-html"|"angular-ts"|"apache"|"apex"|"apl"|"applescript"|"ara"|"asciidoc"|"asm"|"astro"|"awk"|"ballerina"|"bash"|"bat"|"batch"|"be"|"beancount"|"berry"|"bibtex"|"bicep"|"blade"|"bsl"|"c"|"c#"|"c++"|"cadence"|"cairo"|"cdc"|"cjs"|"clarity"|"clj"|"clojure"|"closure-templates"|"cmake"|"cmd"|"cobol"|"codeowners"|"codeql"|"coffee"|"coffeescript"|"common-lisp"|"console"|"coq"|"cpp"|"cql"|"crystal"|"cs"|"csharp"|"css"|"csv"|"cts"|"cue"|"cypher"|"d"|"dart"|"dax"|"desktop"|"diff"|"docker"|"dockerfile"|"dotenv"|"dream-maker"|"edge"|"elisp"|"elixir"|"elm"|"emacs-lisp"|"erb"|"erl"|"erlang"|"f"|"f#"|"f03"|"f08"|"f18"|"f77"|"f90"|"f95"|"fennel"|"fish"|"fluent"|"for"|"fortran-fixed-form"|"fortran-free-form"|"fs"|"fsharp"|"fsl"|"ftl"|"gdresource"|"gdscript"|"gdshader"|"genie"|"gherkin"|"git-commit"|"git-rebase"|"gjs"|"gleam"|"glimmer-js"|"glimmer-ts"|"glsl"|"gnuplot"|"go"|"gql"|"graphql"|"groovy"|"gts"|"hack"|"haml"|"handlebars"|"haskell"|"haxe"|"hbs"|"hcl"|"hjson"|"hlsl"|"hs"|"html"|"html-derivative"|"http"|"hurl"|"hxml"|"hy"|"imba"|"ini"|"jade"|"java"|"javascript"|"jinja"|"jison"|"jl"|"js"|"json"|"json5"|"jsonc"|"jsonl"|"jsonnet"|"jssm"|"jsx"|"julia"|"kdl"|"kotlin"|"kql"|"kt"|"kts"|"kusto"|"latex"|"lean"|"lean4"|"less"|"liquid"|"lisp"|"lit"|"llvm"|"log"|"logo"|"lua"|"luau"|"make"|"makefile"|"markdown"|"marko"|"matlab"|"md"|"mdc"|"mdx"|"mediawiki"|"mermaid"|"mips"|"mipsasm"|"mjs"|"mmd"|"mojo"|"move"|"mts"|"nar"|"narrat"|"nextflow"|"nf"|"nginx"|"nim"|"nix"|"nu"|"nushell"|"objc"|"objective-c"|"objective-cpp"|"ocaml"|"openscad"|"pascal"|"perl"|"perl6"|"php"|"pkl"|"plsql"|"po"|"polar"|"postcss"|"pot"|"potx"|"powerquery"|"powershell"|"prisma"|"prolog"|"properties"|"proto"|"protobuf"|"ps"|"ps1"|"pug"|"puppet"|"purescript"|"py"|"python"|"ql"|"qml"|"qmldir"|"qss"|"r"|"racket"|"raku"|"razor"|"rb"|"reg"|"regex"|"regexp"|"rel"|"riscv"|"rosmsg"|"rs"|"rst"|"ruby"|"rust"|"sas"|"sass"|"scad"|"scala"|"scheme"|"scss"|"sdbl"|"sh"|"shader"|"shaderlab"|"shell"|"shellscript"|"shellsession"|"smalltalk"|"solidity"|"soy"|"sparql"|"spl"|"splunk"|"sql"|"ssh-config"|"stata"|"styl"|"stylus"|"svelte"|"swift"|"system-verilog"|"systemd"|"talon"|"talonscript"|"tasl"|"tcl"|"templ"|"terraform"|"tex"|"tf"|"tfvars"|"toml"|"ts"|"ts-tags"|"tsp"|"tsv"|"tsx"|"turtle"|"twig"|"typ"|"typescript"|"typespec"|"typst"|"v"|"vala"|"vb"|"verilog"|"vhdl"|"vim"|"viml"|"vimscript"|"vue"|"vue-html"|"vue-vine"|"vy"|"vyper"|"wasm"|"wenyan"|"wgsl"|"wiki"|"wikitext"|"wit"|"wl"|"wolfram"|"xml"|"xsl"|"yaml"|"yml"|"zenscript"|"zig"|"zsh"|"文言"
ShikiBundledTheme
Section titled “ShikiBundledTheme”-
type ShikiBundledTheme ="andromeeda"|"aurora-x"|"ayu-dark"|"catppuccin-frappe"|"catppuccin-latte"|"catppuccin-macchiato"|"catppuccin-mocha"|"dark-plus"|"dracula"|"dracula-soft"|"everforest-dark"|"everforest-light"|"github-dark"|"github-dark-default"|"github-dark-dimmed"|"github-dark-high-contrast"|"github-light"|"github-light-default"|"github-light-high-contrast"|"gruvbox-dark-hard"|"gruvbox-dark-medium"|"gruvbox-dark-soft"|"gruvbox-light-hard"|"gruvbox-light-medium"|"gruvbox-light-soft"|"houston"|"kanagawa-dragon"|"kanagawa-lotus"|"kanagawa-wave"|"laserwave"|"light-plus"|"material-theme"|"material-theme-darker"|"material-theme-lighter"|"material-theme-ocean"|"material-theme-palenight"|"min-dark"|"min-light"|"monokai"|"night-owl"|"nord"|"one-dark-pro"|"one-light"|"plastic"|"poimandres"|"red"|"rose-pine"|"rose-pine-dawn"|"rose-pine-moon"|"slack-dark"|"slack-ochin"|"snazzy-light"|"solarized-dark"|"solarized-light"|"synthwave-84"|"tokyo-night"|"vesper"|"vitesse-black"|"vitesse-dark"|"vitesse-light"
Variables
Section titled “Variables”shikiBundledLanguagesInfo
Section titled “shikiBundledLanguagesInfo”shikiBundledThemesInfo
Section titled “shikiBundledThemesInfo”Functions
Section titled “Functions”defineCodeBlockCommands()
Section titled “defineCodeBlockCommands()”-
function defineCodeBlockCommands():CodeBlockCommandsExtension -
Adds commands for working with
codeBlocknodes.
defineCodeBlockHighlight()
Section titled “defineCodeBlockHighlight()”-
function defineCodeBlockHighlight(options:CodeBlockHighlightOptions):Extension -
Adds syntax highlighting to code blocks. This function requires a
Parserinstance from theprosemirror-highlightpackage. See the documentation for more information.
defineCodeBlockInputRule()
Section titled “defineCodeBlockInputRule()”-
function defineCodeBlockInputRule():PlainExtension -
Adds input rules for
codeBlocknodes.
defineCodeBlockEnterRule()
Section titled “defineCodeBlockEnterRule()”-
function defineCodeBlockEnterRule():PlainExtension -
Adds enter rules for
codeBlocknodes.
defineCodeBlockKeymap()
Section titled “defineCodeBlockKeymap()”-
function defineCodeBlockKeymap():PlainExtension -
Defines the keymap for code blocks.
defineCodeBlockShiki()
Section titled “defineCodeBlockShiki()”-
function defineCodeBlockShiki(options:CodeBlockShikiOptions):Extension -
Adds syntax highlighting to code blocks using the Shiki package.
It will set two CSS variables on the code block elements:
--prosemirror-highlight: sets text color--prosemirror-highlight-bg: sets background color
defineCodeBlockSpec()
Section titled “defineCodeBlockSpec()”-
function defineCodeBlockSpec():CodeBlockSpecExtension -
Defines the
codeBlocknode spec.
defineCodeBlock()
Section titled “defineCodeBlock()”-
function defineCodeBlock():CodeBlockExtension -
Adds
codeBlocknodes to the editor. This includes the following extensions: