add new syntax to all packages

This commit is contained in:
Philipp Kühn 2020-11-15 23:25:25 +01:00
parent 17dd284366
commit 034ee139a3
39 changed files with 353 additions and 205 deletions

View File

@ -63,51 +63,93 @@ export interface ExtensionSpec<Options = any, Commands = {}> {
}) => Plugin[],
}
/**
* Extension interface for internal usage
*/
export type Extension = Required<Omit<ExtensionSpec, 'defaultOptions'> & {
type: string,
options: {
[key: string]: any
},
}>
// /**
// * Extension interface for internal usage
// */
// export type Extension = Required<Omit<ExtensionSpec, 'defaultOptions'> & {
// type: string,
// options: {
// [key: string]: any
// },
// }>
/**
* Default extension
*/
export const defaultExtension: Extension = {
name: 'extension',
type: 'extension',
options: {},
addGlobalAttributes: () => [],
addCommands: () => ({}),
addKeyboardShortcuts: () => ({}),
addInputRules: () => [],
addPasteRules: () => [],
addProseMirrorPlugins: () => [],
}
// /**
// * Default extension
// */
// export const defaultExtension: Extension = {
// name: 'extension',
// type: 'extension',
// options: {},
// addGlobalAttributes: () => [],
// addCommands: () => ({}),
// addKeyboardShortcuts: () => ({}),
// addInputRules: () => [],
// addPasteRules: () => [],
// addProseMirrorPlugins: () => [],
// }
export function createExtension<Options extends {}, Commands extends {}>(config: ExtensionSpec<Options, Commands>) {
const extend = <ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<ExtensionSpec<ExtendedOptions, ExtendedCommands>>) => {
return createExtension({
...config,
...extendedConfig,
} as ExtensionSpec<ExtendedOptions, ExtendedCommands>)
// export function createExtension<Options extends {}, Commands extends {}>(config: ExtensionSpec<Options, Commands>) {
// const extend = <ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<ExtensionSpec<ExtendedOptions, ExtendedCommands>>) => {
// return createExtension({
// ...config,
// ...extendedConfig,
// } as ExtensionSpec<ExtendedOptions, ExtendedCommands>)
// }
// const setOptions = (options?: Partial<Options>) => {
// const { defaultOptions, ...rest } = config
// return {
// ...defaultExtension,
// ...rest,
// options: {
// ...defaultOptions,
// ...options,
// } as Options,
// }
// }
// return Object.assign(setOptions, { config, extend })
// }
export class Extension<Options = any, Commands = any> {
config: Required<ExtensionSpec> = {
name: 'extension',
defaultOptions: {},
addGlobalAttributes: () => [],
addCommands: () => ({}),
addKeyboardShortcuts: () => ({}),
addInputRules: () => [],
addPasteRules: () => [],
addProseMirrorPlugins: () => [],
}
const setOptions = (options?: Partial<Options>) => {
const { defaultOptions, ...rest } = config
options!: Options
return {
...defaultExtension,
...rest,
options: {
...defaultOptions,
...options,
} as Options,
constructor(config: ExtensionSpec<Options, Commands>) {
this.config = {
...this.config,
...config,
}
this.options = this.config.defaultOptions
}
static create<O, C>(config: ExtensionSpec<O, C>) {
return new Extension<O, C>(config)
}
set(options: Options) {
this.options = {
...this.config.defaultOptions,
...options,
}
}
return Object.assign(setOptions, { config, extend })
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<ExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
return new Extension<ExtendedOptions, ExtendedCommands>({
...this.config,
...extendedConfig,
} as ExtensionSpec<ExtendedOptions, ExtendedCommands>)
}
}

View File

@ -2,7 +2,7 @@ import {
DOMOutputSpec, MarkSpec, Mark, MarkType,
} from 'prosemirror-model'
import { Plugin } from 'prosemirror-state'
import { ExtensionSpec, defaultExtension } from './Extension'
import { ExtensionSpec } from './Extension'
import { Attributes, Overwrite } from './types'
import { Editor } from './Editor'
@ -106,46 +106,95 @@ export interface MarkExtensionSpec<Options = any, Commands = {}> extends Overwri
}) => Plugin[],
}> {}
export type MarkExtension = Required<Omit<MarkExtensionSpec, 'defaultOptions'> & {
type: string,
options: {
[key: string]: any
},
}>
// export type MarkExtension = Required<Omit<MarkExtensionSpec, 'defaultOptions'> & {
// type: string,
// options: {
// [key: string]: any
// },
// }>
const defaultMark: MarkExtension = {
...defaultExtension,
type: 'mark',
name: 'mark',
inclusive: null,
excludes: null,
group: null,
spanning: null,
parseHTML: () => null,
renderHTML: null,
addAttributes: () => ({}),
}
// const defaultMark: MarkExtension = {
// ...defaultExtension,
// type: 'mark',
// name: 'mark',
// inclusive: null,
// excludes: null,
// group: null,
// spanning: null,
// parseHTML: () => null,
// renderHTML: null,
// addAttributes: () => ({}),
// }
export function createMark<Options extends {}, Commands extends {}>(config: MarkExtensionSpec<Options, Commands>) {
const extend = <ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<MarkExtensionSpec<ExtendedOptions, ExtendedCommands>>) => {
return createMark({
...config,
...extendedConfig,
} as MarkExtensionSpec<ExtendedOptions, ExtendedCommands>)
// export function createMark<Options extends {}, Commands extends {}>(config: MarkExtensionSpec<Options, Commands>) {
// const extend = <ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<MarkExtensionSpec<ExtendedOptions, ExtendedCommands>>) => {
// return createMark({
// ...config,
// ...extendedConfig,
// } as MarkExtensionSpec<ExtendedOptions, ExtendedCommands>)
// }
// const setOptions = (options?: Partial<Options>) => {
// const { defaultOptions, ...rest } = config
// return {
// ...defaultMark,
// ...rest,
// options: {
// ...defaultOptions,
// ...options,
// } as Options,
// }
// }
// return Object.assign(setOptions, { config, extend })
// }
export class MarkExtension<Options = any, Commands = any> {
config: Required<MarkExtensionSpec> = {
name: 'mark',
defaultOptions: {},
addGlobalAttributes: () => [],
addCommands: () => ({}),
addKeyboardShortcuts: () => ({}),
addInputRules: () => [],
addPasteRules: () => [],
addProseMirrorPlugins: () => [],
inclusive: null,
excludes: null,
group: null,
spanning: null,
parseHTML: () => null,
renderHTML: null,
addAttributes: () => ({}),
}
const setOptions = (options?: Partial<Options>) => {
const { defaultOptions, ...rest } = config
options!: Options
return {
...defaultMark,
...rest,
options: {
...defaultOptions,
...options,
} as Options,
constructor(config: MarkExtensionSpec<Options, Commands>) {
this.config = {
...this.config,
...config,
}
this.options = this.config.defaultOptions
}
static create<O, C>(config: MarkExtensionSpec<O, C>) {
return new MarkExtension<O, C>(config)
}
set(options: Options) {
this.options = {
...this.config.defaultOptions,
...options,
}
}
return Object.assign(setOptions, { config, extend })
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<MarkExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
return new MarkExtension<ExtendedOptions, ExtendedCommands>({
...this.config,
...extendedConfig,
} as MarkExtensionSpec<ExtendedOptions, ExtendedCommands>)
}
}

View File

@ -2,7 +2,7 @@ import {
DOMOutputSpec, NodeSpec, Node, NodeType,
} from 'prosemirror-model'
import { Plugin } from 'prosemirror-state'
import { ExtensionSpec, defaultExtension } from './Extension'
import { ExtensionSpec } from './Extension'
import { Attributes, NodeViewRenderer, Overwrite } from './types'
import { Editor } from './Editor'
@ -150,54 +150,111 @@ export interface NodeExtensionSpec<Options = any, Commands = {}> extends Overwri
}) => NodeViewRenderer) | null,
}> {}
export type NodeExtension = Required<Omit<NodeExtensionSpec, 'defaultOptions'> & {
type: string,
options: {
[key: string]: any
},
}>
// export type NodeExtension = Required<Omit<NodeExtensionSpec, 'defaultOptions'> & {
// type: string,
// options: {
// [key: string]: any
// },
// }>
const defaultNode: NodeExtension = {
...defaultExtension,
type: 'node',
name: 'node',
topNode: false,
content: null,
marks: null,
group: null,
inline: null,
atom: null,
selectable: null,
draggable: null,
code: null,
defining: null,
isolating: null,
parseHTML: () => null,
renderHTML: null,
addAttributes: () => ({}),
addNodeView: null,
}
// const defaultNode: NodeExtension = {
// ...defaultExtension,
// type: 'node',
// name: 'node',
// topNode: false,
// content: null,
// marks: null,
// group: null,
// inline: null,
// atom: null,
// selectable: null,
// draggable: null,
// code: null,
// defining: null,
// isolating: null,
// parseHTML: () => null,
// renderHTML: null,
// addAttributes: () => ({}),
// addNodeView: null,
// }
export function createNode<Options extends {}, Commands extends {}>(config: NodeExtensionSpec<Options, Commands>) {
const extend = <ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<NodeExtensionSpec<ExtendedOptions, ExtendedCommands>>) => {
return createNode({
...config,
...extendedConfig,
} as NodeExtensionSpec<ExtendedOptions, ExtendedCommands>)
// export function createNode<Options extends {}, Commands extends {}>(config: NodeExtensionSpec<Options, Commands>) {
// const extend = <ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<NodeExtensionSpec<ExtendedOptions, ExtendedCommands>>) => {
// return createNode({
// ...config,
// ...extendedConfig,
// } as NodeExtensionSpec<ExtendedOptions, ExtendedCommands>)
// }
// const setOptions = (options?: Partial<Options>) => {
// const { defaultOptions, ...rest } = config
// return {
// ...defaultNode,
// ...rest,
// options: {
// ...defaultOptions,
// ...options,
// } as Options,
// }
// }
// return Object.assign(setOptions, { config, extend })
// }
export class NodeExtension<Options = any, Commands = any> {
config: Required<NodeExtensionSpec> = {
name: 'node',
defaultOptions: {},
addGlobalAttributes: () => [],
addCommands: () => ({}),
addKeyboardShortcuts: () => ({}),
addInputRules: () => [],
addPasteRules: () => [],
addProseMirrorPlugins: () => [],
topNode: false,
content: null,
marks: null,
group: null,
inline: null,
atom: null,
selectable: null,
draggable: null,
code: null,
defining: null,
isolating: null,
parseHTML: () => null,
renderHTML: null,
addAttributes: () => ({}),
addNodeView: null,
}
const setOptions = (options?: Partial<Options>) => {
const { defaultOptions, ...rest } = config
options!: Options
return {
...defaultNode,
...rest,
options: {
...defaultOptions,
...options,
} as Options,
constructor(config: NodeExtensionSpec<Options, Commands>) {
this.config = {
...this.config,
...config,
}
this.options = this.config.defaultOptions
}
static create<O, C>(config: NodeExtensionSpec<O, C>) {
return new NodeExtension<O, C>(config)
}
set(options: Options) {
this.options = {
...this.config.defaultOptions,
...options,
}
}
return Object.assign(setOptions, { config, extend })
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<NodeExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
return new NodeExtension<ExtendedOptions, ExtendedCommands>({
...this.config,
...extendedConfig,
} as NodeExtensionSpec<ExtendedOptions, ExtendedCommands>)
}
}

View File

@ -1,4 +1,4 @@
import { createExtension } from '../Extension'
import { Extension } from '../Extension'
import blur from '../commands/blur'
import clearContent from '../commands/clearContent'
import clearNodes from '../commands/clearNodes'
@ -28,7 +28,7 @@ import updateMarkAttributes from '../commands/updateMarkAttributes'
import updateNodeAttributes from '../commands/updateNodeAttributes'
import wrapInList from '../commands/wrapInList'
export const Commands = createExtension({
export const Commands = Extension.create({
addCommands() {
return {
/**

View File

@ -1,7 +1,7 @@
import { Plugin, PluginKey } from 'prosemirror-state'
import { createExtension } from '../Extension'
import { Extension } from '../Extension'
export const Editable = createExtension({
export const Editable = Extension.create({
addProseMirrorPlugins() {
return [
new Plugin({

View File

@ -1,7 +1,7 @@
import { Plugin, PluginKey } from 'prosemirror-state'
import { createExtension } from '../Extension'
import { Extension } from '../Extension'
export const FocusEvents = createExtension({
export const FocusEvents = Extension.create({
addProseMirrorPlugins() {
const { editor } = this

View File

@ -10,9 +10,9 @@ import {
selectNodeBackward,
} from 'prosemirror-commands'
import { undoInputRule } from 'prosemirror-inputrules'
import { createExtension } from '../Extension'
import { Extension } from '../Extension'
export const Keymap = createExtension({
export const Keymap = Extension.create({
addKeyboardShortcuts() {
const handleBackspace = () => this.editor.commands.try(({ state, dispatch }) => [
() => undoInputRule(state, dispatch),

View File

@ -1,4 +1,4 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface BlockquoteOptions {
@ -9,7 +9,7 @@ export interface BlockquoteOptions {
export const inputRegex = /^\s*>\s$/gm
const Blockquote = createNode({
const Blockquote = NodeExtension.create({
name: 'blockquote',
defaultOptions: <BlockquoteOptions>{

View File

@ -1,5 +1,5 @@
import {
Command, createMark, markInputRule, markPasteRule,
Command, MarkExtension, markInputRule, markPasteRule,
} from '@tiptap/core'
export interface BoldOptions {
@ -13,7 +13,7 @@ export const starPasteRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/gm
export const underscoreInputRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm
export const underscorePasteRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm
const Bold = createMark({
const Bold = MarkExtension.create({
name: 'bold',
defaultOptions: <BoldOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface BulletListOptions {
@ -9,7 +9,7 @@ export interface BulletListOptions {
export const inputRegex = /^\s*([-+*])\s$/
const BulletList = createNode({
const BulletList = NodeExtension.create({
name: 'bulletList',
defaultOptions: <BulletListOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
import { textblockTypeInputRule } from 'prosemirror-inputrules'
export interface CodeBlockOptions {
@ -11,7 +11,7 @@ export interface CodeBlockOptions {
export const backtickInputRegex = /^```(?<language>[a-z]*)? $/
export const tildeInputRegex = /^~~~(?<language>[a-z]*)? $/
const CodeBlock = createNode({
const CodeBlock = NodeExtension.create({
name: 'codeBlock',
defaultOptions: <CodeBlockOptions>{

View File

@ -1,6 +1,6 @@
import {
Command,
createMark,
MarkExtension,
markInputRule,
markPasteRule,
} from '@tiptap/core'
@ -14,7 +14,7 @@ export interface CodeOptions {
export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/gm
export const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/gm
const Code = createMark({
const Code = MarkExtension.create({
name: 'code',
defaultOptions: <CodeOptions>{

View File

@ -1,4 +1,4 @@
import { createExtension, Command } from '@tiptap/core'
import { Extension, Command } from '@tiptap/core'
import { yCursorPlugin } from 'y-prosemirror'
export interface CollaborationCursorOptions {
@ -8,7 +8,7 @@ export interface CollaborationCursorOptions {
render (user: { name: string, color: string }): HTMLElement,
}
const CollaborationCursor = createExtension({
const CollaborationCursor = Extension.create({
defaultOptions: <CollaborationCursorOptions>{
provider: null,
name: 'Someone',

View File

@ -1,4 +1,4 @@
import { createExtension } from '@tiptap/core'
import { Extension } from '@tiptap/core'
import {
redo, undo, ySyncPlugin, yUndoPlugin,
} from 'y-prosemirror'
@ -8,7 +8,7 @@ export interface CollaborationOptions {
type: any,
}
const Collaboration = createExtension({
const Collaboration = Extension.create({
defaultOptions: <CollaborationOptions>{
provider: null,
type: null,

View File

@ -1,6 +1,6 @@
import { createNode } from '@tiptap/core'
import { NodeExtension } from '@tiptap/core'
const Document = createNode({
const Document = NodeExtension.create({
name: 'document',
topNode: true,
content: 'block+',

View File

@ -1,7 +1,7 @@
import { createExtension } from '@tiptap/core'
import { Extension } from '@tiptap/core'
import { dropCursor } from 'prosemirror-dropcursor'
const Dropcursor = createExtension({
const Dropcursor = Extension.create({
addProseMirrorPlugins() {
return [
dropCursor(),

View File

@ -1,4 +1,4 @@
import { createExtension } from '@tiptap/core'
import { Extension } from '@tiptap/core'
import { Plugin, PluginKey } from 'prosemirror-state'
import { DecorationSet, Decoration } from 'prosemirror-view'
@ -7,7 +7,7 @@ export interface FocusOptions {
nested: boolean,
}
const FocusClasses = createExtension({
const FocusClasses = Extension.create({
defaultOptions: <FocusOptions>{
className: 'has-focus',
nested: false,

View File

@ -1,11 +1,11 @@
import { Command, createExtension } from '@tiptap/core'
import { Command, Extension } from '@tiptap/core'
import '@tiptap/extension-text-style'
type FontFamilyOptions = {
types: string[],
}
const FontFamily = createExtension({
const FontFamily = Extension.create({
defaultOptions: <FontFamilyOptions>{
types: ['textStyle'],
},

View File

@ -1,7 +1,7 @@
import { createExtension } from '@tiptap/core'
import { Extension } from '@tiptap/core'
import { gapCursor } from 'prosemirror-gapcursor'
const Gapcursor = createExtension({
const Gapcursor = Extension.create({
addProseMirrorPlugins() {
return [
gapCursor(),

View File

@ -1,7 +1,7 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
import { exitCode } from 'prosemirror-commands'
const HardBreak = createNode({
const HardBreak = NodeExtension.create({
name: 'hardBreak',
inline: true,

View File

@ -1,4 +1,4 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
import { textblockTypeInputRule } from 'prosemirror-inputrules'
type Level = 1 | 2 | 3 | 4 | 5 | 6
@ -10,7 +10,7 @@ export interface HeadingOptions {
},
}
const Heading = createNode({
const Heading = NodeExtension.create({
name: 'heading',
defaultOptions: <HeadingOptions>{

View File

@ -1,6 +1,6 @@
import {
Command,
createMark,
MarkExtension,
markInputRule,
markPasteRule,
} from '@tiptap/core'
@ -14,7 +14,7 @@ export interface HighlightOptions {
export const inputRegex = /(?:^|\s)((?:==)((?:[^~]+))(?:==))$/gm
export const pasteRegex = /(?:^|\s)((?:==)((?:[^~]+))(?:==))/gm
const Highlight = createMark({
const Highlight = MarkExtension.create({
name: 'highlight',
defaultOptions: <HighlightOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createExtension } from '@tiptap/core'
import { Command, Extension } from '@tiptap/core'
import { history, undo, redo } from 'prosemirror-history'
export interface HistoryOptions {
@ -6,7 +6,7 @@ export interface HistoryOptions {
newGroupDelay: number,
}
const History = createExtension({
const History = Extension.create({
defaultOptions: <HistoryOptions>{
depth: 100,
newGroupDelay: 500,

View File

@ -1,4 +1,4 @@
import { Command, createNode, nodeInputRule } from '@tiptap/core'
import { Command, NodeExtension, nodeInputRule } from '@tiptap/core'
export interface HorizontalRuleOptions {
HTMLAttributes: {
@ -6,7 +6,7 @@ export interface HorizontalRuleOptions {
},
}
const HorizontalRule = createNode({
const HorizontalRule = NodeExtension.create({
name: 'horizontalRule',
defaultOptions: <HorizontalRuleOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createNode, nodeInputRule } from '@tiptap/core'
import { Command, NodeExtension, nodeInputRule } from '@tiptap/core'
export interface ImageOptions {
inline: boolean,
@ -9,7 +9,7 @@ export interface ImageOptions {
export const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/
const Image = createNode({
const Image = NodeExtension.create({
name: 'image',
defaultOptions: <ImageOptions>{

View File

@ -1,6 +1,6 @@
import {
Command,
createMark,
MarkExtension,
markInputRule,
markPasteRule,
} from '@tiptap/core'
@ -16,7 +16,7 @@ export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm
const Italic = createMark({
const Italic = MarkExtension.create({
name: 'italic',
defaultOptions: <ItalicOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createMark, markPasteRule } from '@tiptap/core'
import { Command, MarkExtension, markPasteRule } from '@tiptap/core'
import { Plugin, PluginKey } from 'prosemirror-state'
export interface LinkOptions {
@ -10,7 +10,7 @@ export interface LinkOptions {
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/()]*)/gi
const Link = createMark({
const Link = MarkExtension.create({
name: 'link',
inclusive: false,

View File

@ -1,4 +1,4 @@
import { createNode } from '@tiptap/core'
import { NodeExtension } from '@tiptap/core'
export interface ListItemOptions {
HTMLAttributes: {
@ -6,7 +6,7 @@ export interface ListItemOptions {
},
}
const ListItem = createNode({
const ListItem = NodeExtension.create({
name: 'listItem',
defaultOptions: <ListItemOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface OrderedListOptions {
@ -9,7 +9,7 @@ export interface OrderedListOptions {
export const inputRegex = /^(\d+)\.\s$/
const OrderedList = createNode({
const OrderedList = NodeExtension.create({
name: 'orderedList',
defaultOptions: <OrderedListOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createNode } from '@tiptap/core'
import { Command, NodeExtension } from '@tiptap/core'
export interface ParagraphOptions {
HTMLAttributes: {
@ -6,7 +6,7 @@ export interface ParagraphOptions {
},
}
const Paragraph = createNode({
const Paragraph = NodeExtension.create({
name: 'paragraph',
defaultOptions: <ParagraphOptions>{

View File

@ -1,6 +1,6 @@
import {
Command,
createMark,
MarkExtension,
markInputRule,
markPasteRule,
} from '@tiptap/core'
@ -14,7 +14,7 @@ export interface StrikeOptions {
export const inputRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/gm
export const pasteRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/gm
const Strike = createMark({
const Strike = MarkExtension.create({
name: 'strike',
defaultOptions: <StrikeOptions>{

View File

@ -1,4 +1,4 @@
import { createNode, mergeAttributes } from '@tiptap/core'
import { NodeExtension, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
export interface TaskItemOptions {
@ -10,7 +10,7 @@ export interface TaskItemOptions {
export const inputRegex = /^\s*(\[([ |x])\])\s$/
const TaskItem = createNode({
const TaskItem = NodeExtension.create({
name: 'taskItem',
defaultOptions: <TaskItemOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createNode, mergeAttributes } from '@tiptap/core'
import { Command, NodeExtension, mergeAttributes } from '@tiptap/core'
export interface TaskListOptions {
HTMLAttributes: {
@ -6,7 +6,7 @@ export interface TaskListOptions {
},
}
const TaskList = createNode({
const TaskList = NodeExtension.create({
name: 'taskList',
defaultOptions: <TaskListOptions>{

View File

@ -1,4 +1,4 @@
import { Command, createExtension } from '@tiptap/core'
import { Command, Extension } from '@tiptap/core'
type TextAlignOptions = {
types: string[],
@ -6,7 +6,7 @@ type TextAlignOptions = {
defaultAlignment: string,
}
const TextAlign = createExtension({
const TextAlign = Extension.create({
defaultOptions: <TextAlignOptions>{
types: ['heading', 'paragraph'],
alignments: ['left', 'center', 'right', 'justify'],

View File

@ -1,6 +1,6 @@
import { Command, createMark, getMarkAttrs } from '@tiptap/core'
import { Command, MarkExtension, getMarkAttrs } from '@tiptap/core'
const TextStyle = createMark({
const TextStyle = MarkExtension.create({
name: 'textStyle',
parseHTML() {

View File

@ -1,6 +1,6 @@
import { createNode } from '@tiptap/core'
import { NodeExtension } from '@tiptap/core'
const Text = createNode({
const Text = NodeExtension.create({
name: 'text',
group: 'inline',
})

View File

@ -1,4 +1,4 @@
import { createExtension } from '@tiptap/core'
import { Extension } from '@tiptap/core'
import {
emDash,
ellipsis,
@ -20,7 +20,7 @@ export const laquo = new InputRule(/<<$/, '«')
export const raquo = new InputRule(/>>$/, '»')
export const multiplication = new InputRule(/\d+\s?([*x])\s?\d+$/, '×')
const Typography = createExtension({
const Typography = Extension.create({
addInputRules() {
return [
emDash,

View File

@ -1,4 +1,4 @@
import { Command, createMark } from '@tiptap/core'
import { Command, MarkExtension } from '@tiptap/core'
export interface UnderlineOptions {
HTMLAttributes: {
@ -6,7 +6,7 @@ export interface UnderlineOptions {
},
}
const Underline = createMark({
const Underline = MarkExtension.create({
name: 'underline',
defaultOptions: <UnderlineOptions>{

View File

@ -23,23 +23,23 @@ export function defaultExtensions(options: {
heading: HeadingOptions,
}) {
return [
Dropcursor(),
Gapcursor(),
Document(),
History(options?.history),
Paragraph(),
Text(),
Bold(),
Italic(),
Code(),
CodeBlock(options?.codeBlock),
Heading(options?.heading),
HardBreak(),
Strike(),
Blockquote(),
HorizontalRule(),
BulletList(),
OrderedList(),
ListItem(),
Dropcursor,
Gapcursor,
Document,
History.set(options?.history),
Paragraph,
Text,
Bold,
Italic,
Code,
CodeBlock.set(options?.codeBlock),
Heading.set(options?.heading),
HardBreak,
Strike,
Blockquote,
HorizontalRule,
BulletList,
OrderedList,
ListItem,
]
}