@tiptap/extension-code
Version:
code extension for tiptap
50 lines (47 loc) • 1.42 kB
TypeScript
import { Mark } from '@tiptap/core';
interface CodeOptions {
/**
* The HTML attributes applied to the code element.
* @default {}
* @example { class: 'foo' }
*/
HTMLAttributes: Record<string, any>;
}
declare module '@tiptap/core' {
interface Commands<ReturnType> {
code: {
/**
* Set a code mark
*/
setCode: () => ReturnType;
/**
* Toggle inline code
*/
toggleCode: () => ReturnType;
/**
* Unset a code mark
*/
unsetCode: () => ReturnType;
};
}
}
/**
* Regular expressions to match inline code blocks enclosed in backticks.
* It matches:
* - An opening backtick, followed by
* - Any text that doesn't include a backtick (captured for marking), followed by
* - A closing backtick as the final character.
* This ensures that any text between backticks is formatted as code,
* regardless of the surrounding characters (exception being another backtick).
*/
declare const inputRegex: RegExp;
/**
* Matches inline code while pasting.
*/
declare const pasteRegex: RegExp;
/**
* This extension allows you to mark text as inline code.
* @see https://tiptap.dev/api/marks/code
*/
declare const Code: Mark<CodeOptions, any>;
export { Code, type CodeOptions, Code as default, inputRegex, pasteRegex };