mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 23:15:15 +08:00
improve options interface
This commit is contained in:
parent
55ff908423
commit
215c26748b
@ -26,11 +26,11 @@ declare module '@tiptap/core' {
|
||||
|
||||
export const inputRegex = /^\s*>\s$/gm
|
||||
|
||||
export const Blockquote = Node.create({
|
||||
export const Blockquote = Node.create<BlockquoteOptions>({
|
||||
|
||||
name: 'blockquote',
|
||||
|
||||
defaultOptions: <BlockquoteOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -34,10 +34,10 @@ export const starPasteRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/gm
|
||||
export const underscoreInputRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm
|
||||
export const underscorePasteRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm
|
||||
|
||||
export const Bold = Mark.create({
|
||||
export const Bold = Mark.create<BoldOptions>({
|
||||
name: 'bold',
|
||||
|
||||
defaultOptions: <BoldOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -18,10 +18,10 @@ declare module '@tiptap/core' {
|
||||
|
||||
export const inputRegex = /^\s*([-+*])\s$/
|
||||
|
||||
export const BulletList = Node.create({
|
||||
export const BulletList = Node.create<BulletListOptions>({
|
||||
name: 'bulletList',
|
||||
|
||||
defaultOptions: <BulletListOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -7,10 +7,10 @@ export interface CharacterCountOptions {
|
||||
limit?: number,
|
||||
}
|
||||
|
||||
export const CharacterCount = Extension.create({
|
||||
export const CharacterCount = Extension.create<CharacterCountOptions>({
|
||||
name: 'characterCount',
|
||||
|
||||
defaultOptions: <CharacterCountOptions>{
|
||||
defaultOptions: {
|
||||
limit: 0,
|
||||
},
|
||||
|
||||
|
@ -24,10 +24,10 @@ declare module '@tiptap/core' {
|
||||
export const backtickInputRegex = /^```(?<language>[a-z]*)? $/
|
||||
export const tildeInputRegex = /^~~~(?<language>[a-z]*)? $/
|
||||
|
||||
export const CodeBlock = Node.create({
|
||||
export const CodeBlock = Node.create<CodeBlockOptions>({
|
||||
name: 'codeBlock',
|
||||
|
||||
defaultOptions: <CodeBlockOptions>{
|
||||
defaultOptions: {
|
||||
languageClassPrefix: 'language-',
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
@ -32,10 +32,10 @@ declare module '@tiptap/core' {
|
||||
export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/gm
|
||||
|
||||
export const Code = Mark.create({
|
||||
export const Code = Mark.create<CodeOptions>({
|
||||
name: 'code',
|
||||
|
||||
defaultOptions: <CodeOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -26,10 +26,10 @@ const awarenessStatesToArray = (states: Map<number, { [key: string]: any }>) =>
|
||||
})
|
||||
}
|
||||
|
||||
export const CollaborationCursor = Extension.create({
|
||||
export const CollaborationCursor = Extension.create<CollaborationCursorOptions>({
|
||||
name: 'collaborationCursor',
|
||||
|
||||
defaultOptions: <CollaborationCursorOptions>{
|
||||
defaultOptions: {
|
||||
provider: null,
|
||||
user: {
|
||||
name: null,
|
||||
|
@ -34,10 +34,10 @@ export interface CollaborationOptions {
|
||||
fragment: any,
|
||||
}
|
||||
|
||||
export const Collaboration = Extension.create({
|
||||
export const Collaboration = Extension.create<CollaborationOptions>({
|
||||
name: 'collaboration',
|
||||
|
||||
defaultOptions: <CollaborationOptions>{
|
||||
defaultOptions: {
|
||||
document: null,
|
||||
field: 'default',
|
||||
fragment: null,
|
||||
|
@ -7,10 +7,10 @@ export interface DropcursorOptions {
|
||||
class: string | null,
|
||||
}
|
||||
|
||||
export const Dropcursor = Extension.create({
|
||||
export const Dropcursor = Extension.create<DropcursorOptions>({
|
||||
name: 'dropCursor',
|
||||
|
||||
defaultOptions: <DropcursorOptions>{
|
||||
defaultOptions: {
|
||||
color: 'black',
|
||||
width: 1,
|
||||
class: null,
|
||||
|
@ -7,10 +7,10 @@ export interface FocusOptions {
|
||||
mode: 'all' | 'deepest' | 'shallowest',
|
||||
}
|
||||
|
||||
export const FocusClasses = Extension.create({
|
||||
export const FocusClasses = Extension.create<FocusOptions>({
|
||||
name: 'focus',
|
||||
|
||||
defaultOptions: <FocusOptions>{
|
||||
defaultOptions: {
|
||||
className: 'has-focus',
|
||||
mode: 'all',
|
||||
},
|
||||
|
@ -18,10 +18,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const FontFamily = Extension.create({
|
||||
export const FontFamily = Extension.create<FontFamilyOptions>({
|
||||
name: 'fontFamily',
|
||||
|
||||
defaultOptions: <FontFamilyOptions>{
|
||||
defaultOptions: {
|
||||
types: ['textStyle'],
|
||||
},
|
||||
|
||||
|
@ -16,11 +16,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const HardBreak = Node.create({
|
||||
export const HardBreak = Node.create<HardBreakOptions>({
|
||||
name: 'hardBreak',
|
||||
|
||||
defaultOptions: <HardBreakOptions>{
|
||||
languageClassPrefix: 'language-',
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -23,10 +23,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const Heading = Node.create({
|
||||
export const Heading = Node.create<HeadingOptions>({
|
||||
name: 'heading',
|
||||
|
||||
defaultOptions: <HeadingOptions>{
|
||||
defaultOptions: {
|
||||
levels: [1, 2, 3, 4, 5, 6],
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
@ -33,10 +33,10 @@ declare module '@tiptap/core' {
|
||||
export const inputRegex = /(?:^|\s)((?:==)((?:[^~]+))(?:==))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:==)((?:[^~]+))(?:==))/gm
|
||||
|
||||
export const Highlight = Mark.create({
|
||||
export const Highlight = Mark.create<HighlightOptions>({
|
||||
name: 'highlight',
|
||||
|
||||
defaultOptions: <HighlightOptions>{
|
||||
defaultOptions: {
|
||||
multicolor: false,
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
@ -19,10 +19,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const History = Extension.create({
|
||||
export const History = Extension.create<HistoryOptions>({
|
||||
name: 'history',
|
||||
|
||||
defaultOptions: <HistoryOptions>{
|
||||
defaultOptions: {
|
||||
depth: 100,
|
||||
newGroupDelay: 500,
|
||||
},
|
||||
|
@ -20,10 +20,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const HorizontalRule = Node.create({
|
||||
export const HorizontalRule = Node.create<HorizontalRuleOptions>({
|
||||
name: 'horizontalRule',
|
||||
|
||||
defaultOptions: <HorizontalRuleOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -23,10 +23,10 @@ declare module '@tiptap/core' {
|
||||
|
||||
export const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/
|
||||
|
||||
export const Image = Node.create({
|
||||
export const Image = Node.create<ImageOptions>({
|
||||
name: 'image',
|
||||
|
||||
defaultOptions: <ImageOptions>{
|
||||
defaultOptions: {
|
||||
inline: false,
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
@ -34,10 +34,10 @@ export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm
|
||||
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm
|
||||
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm
|
||||
|
||||
export const Italic = Mark.create({
|
||||
export const Italic = Mark.create<ItalicOptions>({
|
||||
name: 'italic',
|
||||
|
||||
defaultOptions: <ItalicOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -33,12 +33,12 @@ declare module '@tiptap/core' {
|
||||
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi
|
||||
export const pasteRegexWithBrackets = /(?:\()https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/()]*)(?:\))/gi
|
||||
|
||||
export const Link = Mark.create({
|
||||
export const Link = Mark.create<LinkOptions>({
|
||||
name: 'link',
|
||||
|
||||
inclusive: false,
|
||||
|
||||
defaultOptions: <LinkOptions>{
|
||||
defaultOptions: {
|
||||
openOnClick: true,
|
||||
HTMLAttributes: {
|
||||
target: '_blank',
|
||||
|
@ -6,10 +6,10 @@ export interface ListItemOptions {
|
||||
},
|
||||
}
|
||||
|
||||
export const ListItem = Node.create({
|
||||
export const ListItem = Node.create<ListItemOptions>({
|
||||
name: 'listItem',
|
||||
|
||||
defaultOptions: <ListItemOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -8,10 +8,10 @@ export type MentionOptions = {
|
||||
suggestion: Omit<SuggestionOptions, 'editor'>,
|
||||
}
|
||||
|
||||
export const Mention = Node.create({
|
||||
export const Mention = Node.create<MentionOptions>({
|
||||
name: 'mention',
|
||||
|
||||
defaultOptions: <MentionOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
suggestion: {
|
||||
char: '@',
|
||||
|
@ -18,10 +18,10 @@ declare module '@tiptap/core' {
|
||||
|
||||
export const inputRegex = /^(\d+)\.\s$/
|
||||
|
||||
export const OrderedList = Node.create({
|
||||
export const OrderedList = Node.create<OrderedListOptions>({
|
||||
name: 'orderedList',
|
||||
|
||||
defaultOptions: <OrderedListOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -15,10 +15,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const Paragraph = Node.create({
|
||||
export const Paragraph = Node.create<ParagraphOptions>({
|
||||
name: 'paragraph',
|
||||
|
||||
defaultOptions: <ParagraphOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -32,10 +32,10 @@ declare module '@tiptap/core' {
|
||||
export const inputRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/gm
|
||||
|
||||
export const Strike = Mark.create({
|
||||
export const Strike = Mark.create<StrikeOptions>({
|
||||
name: 'strike',
|
||||
|
||||
defaultOptions: <StrikeOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -5,10 +5,10 @@ export interface TableCellOptions {
|
||||
[key: string]: any
|
||||
},
|
||||
}
|
||||
export const TableCell = Node.create({
|
||||
export const TableCell = Node.create<TableCellOptions>({
|
||||
name: 'tableCell',
|
||||
|
||||
defaultOptions: <TableCellOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -5,10 +5,10 @@ export interface TableHeaderOptions {
|
||||
[key: string]: any
|
||||
},
|
||||
}
|
||||
export const TableHeader = Node.create({
|
||||
export const TableHeader = Node.create<TableHeaderOptions>({
|
||||
name: 'tableHeader',
|
||||
|
||||
defaultOptions: <TableHeaderOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -6,10 +6,10 @@ export interface TableRowOptions {
|
||||
},
|
||||
}
|
||||
|
||||
export const TableRow = Node.create({
|
||||
export const TableRow = Node.create<TableRowOptions>({
|
||||
name: 'tableRow',
|
||||
|
||||
defaultOptions: <TableRowOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -64,14 +64,16 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const Table = Node.create({
|
||||
export const Table = Node.create<TableOptions>({
|
||||
name: 'table',
|
||||
|
||||
defaultOptions: <TableOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
resizable: false,
|
||||
handleWidth: 5,
|
||||
cellMinWidth: 25,
|
||||
// TODO: fix
|
||||
// @ts-ignore
|
||||
View: TableView,
|
||||
lastColumnResizable: true,
|
||||
allowTableNodeSelection: false,
|
||||
|
@ -10,10 +10,10 @@ export interface TaskItemOptions {
|
||||
|
||||
export const inputRegex = /^\s*(\[([ |x])\])\s$/
|
||||
|
||||
export const TaskItem = Node.create({
|
||||
export const TaskItem = Node.create<TaskItemOptions>({
|
||||
name: 'taskItem',
|
||||
|
||||
defaultOptions: <TaskItemOptions>{
|
||||
defaultOptions: {
|
||||
nested: false,
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
@ -15,10 +15,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const TaskList = Node.create({
|
||||
export const TaskList = Node.create<TaskListOptions>({
|
||||
name: 'taskList',
|
||||
|
||||
defaultOptions: <TaskListOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -19,10 +19,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const TextAlign = Extension.create({
|
||||
export const TextAlign = Extension.create<TextAlignOptions>({
|
||||
name: 'textAlign',
|
||||
|
||||
defaultOptions: <TextAlignOptions>{
|
||||
defaultOptions: {
|
||||
types: ['heading', 'paragraph'],
|
||||
alignments: ['left', 'center', 'right', 'justify'],
|
||||
defaultAlignment: 'left',
|
||||
|
@ -20,10 +20,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const TextStyle = Mark.create({
|
||||
export const TextStyle = Mark.create<TextStyleOptions>({
|
||||
name: 'textStyle',
|
||||
|
||||
defaultOptions: <TextStyleOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
@ -23,10 +23,10 @@ declare module '@tiptap/core' {
|
||||
}
|
||||
}
|
||||
|
||||
export const Underline = Mark.create({
|
||||
export const Underline = Mark.create<UnderlineOptions>({
|
||||
name: 'underline',
|
||||
|
||||
defaultOptions: <UnderlineOptions>{
|
||||
defaultOptions: {
|
||||
HTMLAttributes: {},
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user