prosekit/extensions/code-block
CodeBlockAttrs
The attributes for the codeBlock
node.
language
Type:
string
CodeBlockHighlightOptions
Type: { parser: HighlightParser }
HighlightParser
An alias for the Parser
type from the prosemirror-highlight
package.
Type: Parser
defineCodeBlock
ts
function defineCodeBlock(): CodeBlockExtension
Adds codeBlock
nodes to the editor. This includes the following extensions:
- defineCodeBlockSpec
- defineCodeBlockInputRule
- defineCodeBlockEnterRule
- defineCodeBlockKeymap
- defineCodeBlockCommands.
defineCodeBlockCommands
ts
function defineCodeBlockCommands(): CodeBlockCommandsExtension
Adds commands for working with codeBlock
nodes.
defineCodeBlockEnterRule
ts
function defineCodeBlockEnterRule(): PlainExtension
Adds enter rules for codeBlock
nodes.
defineCodeBlockHighlight
ts
function defineCodeBlockHighlight(options: CodeBlockHighlightOptions): Extension
Adds syntax highlighting to code blocks. This function requires a Parser
instance from the prosemirror-highlight
package. See the documentation for more information.
defineCodeBlockInputRule
ts
function defineCodeBlockInputRule(): PlainExtension
Adds input rules for codeBlock
nodes.
defineCodeBlockKeymap
ts
function defineCodeBlockKeymap(): PlainExtension
Defines the keymap for code blocks.
defineCodeBlockShiki
ts
function defineCodeBlockShiki(options?: CodeBlockShikiOptions): Extension
Adds syntax highlighting to code blocks using the Shiki package.
defineCodeBlockSpec
ts
function defineCodeBlockSpec(): CodeBlockSpecExtension
Defines the codeBlock
node spec.