Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/ui-kit. 🦊 fox ui, svelte 5 and tailwind 4 flo-bit.dev/ui-kit
Something went wrong. Try again.
1.0 kB · 35 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536import { Extension } from '@tiptap/core';import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';import { SvelteNodeViewRenderer } from 'svelte-tiptap';import type { CodeBlockExtensionOptions } from './helpers';import CodeBlockView from './CodeBlockView.svelte';
export const CodeBlockExtension = Extension.create<CodeBlockExtensionOptions>({ name: 'codeBlockExtension',
addOptions() { return { // eslint-disable-next-line @typescript-eslint/no-explicit-any lowlight: undefined as any, defaultLanguage: null, codeBlockComponent: undefined, HTMLAttributes: {} }; },
addExtensions() { const component = this.options.codeBlockComponent ?? CodeBlockView;
const codeBlockLowlight = CodeBlockLowlight.extend({ addNodeView() { return SvelteNodeViewRenderer(component); } }).configure({ lowlight: this.options.lowlight, defaultLanguage: this.options.defaultLanguage ?? null, HTMLAttributes: this.options.HTMLAttributes ?? {} });
return [codeBlockLowlight]; }});