Some checks failed
Verify / Install node dependencies (push) Failing after 2s
Verify / Build packages (push) Has been skipped
Verify / Check linting & formatting (push) Has been skipped
Verify / Run unit tests (push) Has been skipped
Verify / Run e2e tests (shard 1/4) (push) Has been skipped
Verify / Run e2e tests (shard 2/4) (push) Has been skipped
Verify / Run e2e tests (shard 3/4) (push) Has been skipped
Verify / Run e2e tests (shard 4/4) (push) Has been skipped
Publish / Resolve publish config (push) Failing after 2s
Publish / Send notification to Slack (push) Has been skipped
Publish / Send failure notification to Slack (push) Failing after 8s
Verify / Merge e2e reports (push) Has been skipped
Publish / Build (push) Has been skipped
Publish / Bump Versions OR Release to Registry (push) Has been skipped
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import type { CodeBlockOptions } from '@tiptap/extension-code-block'
|
|
import { CodeBlock } from '@tiptap/extension-code-block'
|
|
|
|
import { LowlightPlugin } from './lowlight-plugin.js'
|
|
|
|
export interface CodeBlockLowlightOptions extends CodeBlockOptions {
|
|
/**
|
|
* The lowlight instance.
|
|
*/
|
|
lowlight: any
|
|
}
|
|
|
|
/**
|
|
* This extension allows you to highlight code blocks with lowlight.
|
|
* @see https://tiptap.dev/api/nodes/code-block-lowlight
|
|
*/
|
|
export const CodeBlockLowlight = CodeBlock.extend<CodeBlockLowlightOptions>({
|
|
addOptions() {
|
|
return {
|
|
...this.parent?.(),
|
|
lowlight: {},
|
|
languageClassPrefix: 'language-',
|
|
exitOnTripleEnter: true,
|
|
exitOnArrowDown: true,
|
|
exitOnArrowUp: true,
|
|
defaultLanguage: null,
|
|
enableTabIndentation: false,
|
|
tabSize: 4,
|
|
HTMLAttributes: {},
|
|
}
|
|
},
|
|
|
|
addProseMirrorPlugins() {
|
|
return [
|
|
...(this.parent?.() || []),
|
|
LowlightPlugin({
|
|
name: this.name,
|
|
lowlight: this.options.lowlight,
|
|
defaultLanguage: this.options.defaultLanguage,
|
|
}),
|
|
]
|
|
},
|
|
})
|