improve options interface

This commit is contained in:
Philipp Kühn 2021-02-10 18:25:08 +01:00
parent 55ff908423
commit 215c26748b
33 changed files with 68 additions and 67 deletions

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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,
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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',
},

View File

@ -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'],
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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,
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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',

View File

@ -6,10 +6,10 @@ export interface ListItemOptions {
},
}
export const ListItem = Node.create({
export const ListItem = Node.create<ListItemOptions>({
name: 'listItem',
defaultOptions: <ListItemOptions>{
defaultOptions: {
HTMLAttributes: {},
},

View File

@ -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: '@',

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -6,10 +6,10 @@ export interface TableRowOptions {
},
}
export const TableRow = Node.create({
export const TableRow = Node.create<TableRowOptions>({
name: 'tableRow',
defaultOptions: <TableRowOptions>{
defaultOptions: {
HTMLAttributes: {},
},

View File

@ -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,

View File

@ -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: {},
},

View File

@ -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: {},
},

View File

@ -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',

View File

@ -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: {},
},

View File

@ -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: {},
},