mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
add AllExtensions interface
This commit is contained in:
parent
79172753ef
commit
6746163dda
@ -14,7 +14,7 @@ import createStyleTag from './utils/createStyleTag'
|
||||
import CommandManager from './CommandManager'
|
||||
import ExtensionManager from './ExtensionManager'
|
||||
import EventEmitter from './EventEmitter'
|
||||
import { Extensions } from './types'
|
||||
import { Extensions, UnionToIntersection, PickValue } from './types'
|
||||
import defaultPlugins from './plugins'
|
||||
import * as coreCommands from './commands'
|
||||
import style from './style'
|
||||
@ -35,19 +35,13 @@ export interface CommandsSpec {
|
||||
[key: string]: CommandSpec
|
||||
}
|
||||
|
||||
export interface Commands {}
|
||||
export interface AllExtensions {}
|
||||
|
||||
export type CommandNames = Extract<keyof Commands, string>
|
||||
|
||||
export type SingleCommands = {
|
||||
[Item in keyof Commands]: Commands[Item] extends (...args: any[]) => any
|
||||
? (...args: Parameters<Commands[Item]>) => boolean
|
||||
: never
|
||||
}
|
||||
export type SingleCommands = UnionToIntersection<ReturnType<PickValue<ReturnType<AllExtensions[keyof AllExtensions]>, 'addCommands'>>>
|
||||
|
||||
export type ChainedCommands = {
|
||||
[Item in keyof Commands]: Commands[Item] extends (...args: any[]) => any
|
||||
? (...args: Parameters<Commands[Item]>) => ChainedCommands
|
||||
[Item in keyof SingleCommands]: SingleCommands[Item] extends (...args: any[]) => any
|
||||
? (...args: Parameters<SingleCommands[Item]>) => ChainedCommands
|
||||
: never
|
||||
} & {
|
||||
run: () => boolean
|
||||
|
@ -27,3 +27,9 @@ export type GlobalAttributes = {
|
||||
types: string[],
|
||||
attributes: Attributes,
|
||||
}[]
|
||||
|
||||
export type PickValue<T, K extends keyof T> = T[K]
|
||||
|
||||
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I)=>void)
|
||||
? I
|
||||
: never
|
||||
|
@ -1,17 +1,9 @@
|
||||
import { Command, createNode } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
// export type BlockquoteCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// blockquote: BlockquoteCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export const inputRegex = /^\s*>\s$/gm
|
||||
|
||||
export default createNode({
|
||||
const Blockquote = createNode({
|
||||
name: 'blockquote',
|
||||
|
||||
content: 'block*',
|
||||
@ -32,7 +24,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
blockquote: () => ({ commands }) => {
|
||||
blockquote: (): Command => ({ commands }) => {
|
||||
return commands.toggleWrap('blockquote')
|
||||
},
|
||||
}
|
||||
@ -50,3 +42,11 @@ export default createNode({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Blockquote
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Blockquote: typeof Blockquote,
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export const starPasteRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/gm
|
||||
export const underscoreInputRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm
|
||||
export const underscorePasteRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm
|
||||
|
||||
export default createMark({
|
||||
const Bold = createMark({
|
||||
name: 'bold',
|
||||
|
||||
parseHTML() {
|
||||
@ -40,7 +40,10 @@ export default createMark({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
bold: () => ({ commands }) => {
|
||||
/**
|
||||
* bold command
|
||||
*/
|
||||
bold: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('bold')
|
||||
},
|
||||
}
|
||||
@ -66,3 +69,11 @@ export default createMark({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Bold
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Bold: typeof Bold,
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
import { Command, createNode } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
// export type BulletListCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// bulletList: BulletListCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createNode({
|
||||
const BulletList = createNode({
|
||||
name: 'bullet_list',
|
||||
|
||||
content: 'list_item+',
|
||||
@ -28,7 +20,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
bulletList: () => ({ commands }) => {
|
||||
bulletList: (): Command => ({ commands }) => {
|
||||
return commands.toggleList('bullet_list', 'list_item')
|
||||
},
|
||||
}
|
||||
@ -46,3 +38,11 @@ export default createNode({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default BulletList
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
BulletList: typeof BulletList,
|
||||
}
|
||||
}
|
||||
|
@ -5,18 +5,10 @@ export interface CodeBlockOptions {
|
||||
languageClassPrefix: string,
|
||||
}
|
||||
|
||||
// export type CodeBlockCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// codeBlock: CodeBlockCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export const backtickInputRegex = /^```(?<language>[a-z]*)? $/
|
||||
export const tildeInputRegex = /^~~~(?<language>[a-z]*)? $/
|
||||
|
||||
export default createNode({
|
||||
const CodeBlock = createNode({
|
||||
name: 'code_block',
|
||||
|
||||
defaultOptions: <CodeBlockOptions>{
|
||||
@ -70,7 +62,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
codeBlock: attrs => ({ commands }) => {
|
||||
codeBlock: (attrs?: CodeBlockOptions): Command => ({ commands }) => {
|
||||
return commands.toggleBlockType('code_block', 'paragraph', attrs)
|
||||
},
|
||||
}
|
||||
@ -89,3 +81,11 @@ export default createNode({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default CodeBlock
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
CodeBlock: typeof CodeBlock,
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,10 @@ import {
|
||||
Command, createMark, markInputRule, markPasteRule,
|
||||
} from '@tiptap/core'
|
||||
|
||||
// export type CodeCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// code: CodeCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/gm
|
||||
|
||||
export default createMark({
|
||||
const Code = createMark({
|
||||
name: 'code',
|
||||
|
||||
excludes: '_',
|
||||
@ -30,7 +22,7 @@ export default createMark({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
code: () => ({ commands }) => {
|
||||
code: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('code')
|
||||
},
|
||||
}
|
||||
@ -54,3 +46,11 @@ export default createMark({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Code
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Code: typeof Code,
|
||||
}
|
||||
}
|
||||
|
@ -8,18 +8,7 @@ export interface CollaborationCursorOptions {
|
||||
render (user: { name: string, color: string }): HTMLElement,
|
||||
}
|
||||
|
||||
// export type UserCommand = (attributes: {
|
||||
// name: string,
|
||||
// color: string,
|
||||
// }) => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// user: UserCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createExtension({
|
||||
const CollaborationCursor = createExtension({
|
||||
name: 'collaboration_cursor',
|
||||
|
||||
defaultOptions: <CollaborationCursorOptions>{
|
||||
@ -43,7 +32,10 @@ export default createExtension({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
user: attributes => () => {
|
||||
user: (attributes: {
|
||||
name: string,
|
||||
color: string,
|
||||
}): Command => () => {
|
||||
this.options.provider.awareness.setLocalStateField('user', attributes)
|
||||
|
||||
return true
|
||||
@ -68,3 +60,11 @@ export default createExtension({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default CollaborationCursor
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
CollaborationCursor: typeof CollaborationCursor,
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ export interface CollaborationOptions {
|
||||
type: any,
|
||||
}
|
||||
|
||||
export default createExtension({
|
||||
const Collaboration = createExtension({
|
||||
name: 'collaboration',
|
||||
|
||||
defaultOptions: <CollaborationOptions>{
|
||||
@ -31,3 +31,11 @@ export default createExtension({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default Collaboration
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Collaboration: typeof Collaboration,
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,15 @@
|
||||
import { createNode } from '@tiptap/core'
|
||||
|
||||
export default createNode({
|
||||
const Document = createNode({
|
||||
name: 'document',
|
||||
topNode: true,
|
||||
content: 'block+',
|
||||
})
|
||||
|
||||
export default Document
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Document: typeof Document,
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ export interface FocusOptions {
|
||||
nested: boolean,
|
||||
}
|
||||
|
||||
export default createExtension({
|
||||
const Focus = createExtension({
|
||||
name: 'focus',
|
||||
|
||||
defaultOptions: <FocusOptions>{
|
||||
@ -48,3 +48,11 @@ export default createExtension({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Focus
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Focus: typeof Focus,
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
import { Command, createNode } from '@tiptap/core'
|
||||
import { chainCommands, exitCode } from 'prosemirror-commands'
|
||||
|
||||
// export type HardBreakCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// hardBreak: HardBreakCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createNode({
|
||||
const HardBreak = createNode({
|
||||
name: 'hardBreak',
|
||||
|
||||
inline: true,
|
||||
@ -30,7 +22,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
hardBreak: () => ({
|
||||
hardBreak: (): Command => ({
|
||||
tr, state, dispatch, view,
|
||||
}) => {
|
||||
return chainCommands(exitCode, () => {
|
||||
@ -48,3 +40,11 @@ export default createNode({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default HardBreak
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
HardBreak: typeof HardBreak,
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,7 @@ export interface HeadingOptions {
|
||||
levels: Level[],
|
||||
}
|
||||
|
||||
// export type HeadingCommand = (options: { level: Level }) => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// heading: HeadingCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createNode({
|
||||
const Heading = createNode({
|
||||
name: 'heading',
|
||||
|
||||
defaultOptions: <HeadingOptions>{
|
||||
@ -51,8 +43,11 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
heading: attrs => ({ commands }) => {
|
||||
return commands.toggleBlockType('heading', 'paragraph', attrs)
|
||||
/**
|
||||
* heading command
|
||||
*/
|
||||
heading: (options: { level: Level }): Command => ({ commands }) => {
|
||||
return commands.toggleBlockType('heading', 'paragraph', options)
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -72,3 +67,11 @@ export default createNode({
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export default Heading
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Heading: typeof Heading,
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,12 @@
|
||||
import { Command, createExtension } from '@tiptap/core'
|
||||
import {
|
||||
history,
|
||||
undo,
|
||||
redo,
|
||||
} from 'prosemirror-history'
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// undo: () => Command,
|
||||
// redo: () => Command,
|
||||
// }
|
||||
// }
|
||||
import { history, undo, redo } from 'prosemirror-history'
|
||||
|
||||
export interface HistoryOptions {
|
||||
depth: number,
|
||||
newGroupDelay: number,
|
||||
}
|
||||
|
||||
export default createExtension({
|
||||
const History = createExtension({
|
||||
name: 'history',
|
||||
|
||||
defaultOptions: <HistoryOptions>{
|
||||
@ -27,10 +16,10 @@ export default createExtension({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
undo: () => ({ state, dispatch }) => {
|
||||
undo: (): Command => ({ state, dispatch }) => {
|
||||
return undo(state, dispatch)
|
||||
},
|
||||
redo: () => ({ state, dispatch }) => {
|
||||
redo: (): Command => ({ state, dispatch }) => {
|
||||
return redo(state, dispatch)
|
||||
},
|
||||
}
|
||||
@ -50,3 +39,11 @@ export default createExtension({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default History
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
History: typeof History,
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,6 @@
|
||||
import { Command, createNode, nodeInputRule } from '@tiptap/core'
|
||||
|
||||
// export type HorizontalRuleCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// horizontalRule: HorizontalRuleCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createNode({
|
||||
const HorizontalRule = createNode({
|
||||
name: 'horizontalRule',
|
||||
|
||||
group: 'block',
|
||||
@ -25,7 +17,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
horizontalRule: () => ({ tr }) => {
|
||||
horizontalRule: (): Command => ({ tr }) => {
|
||||
tr.replaceSelectionWith(this.type.create())
|
||||
|
||||
return true
|
||||
@ -39,3 +31,11 @@ export default createNode({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default HorizontalRule
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
HorizontalRule: typeof HorizontalRule,
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,12 @@ import {
|
||||
Command, createMark, markInputRule, markPasteRule,
|
||||
} from '@tiptap/core'
|
||||
|
||||
// export type ItalicCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// italic: ItalicCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export const starInputRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/gm
|
||||
export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm
|
||||
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm
|
||||
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm
|
||||
|
||||
export default createMark({
|
||||
const Italic = createMark({
|
||||
name: 'italic',
|
||||
|
||||
parseHTML() {
|
||||
@ -39,7 +31,7 @@ export default createMark({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
italic: () => ({ commands }) => {
|
||||
italic: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('italic')
|
||||
},
|
||||
}
|
||||
@ -65,3 +57,11 @@ export default createMark({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Italic
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Italic: typeof Italic,
|
||||
}
|
||||
}
|
||||
|
@ -9,17 +9,9 @@ export interface LinkOptions {
|
||||
rel: string,
|
||||
}
|
||||
|
||||
// export type LinkCommand = (options: {href?: string, target?: string}) => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// link: LinkCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%_+.~#?&//=]*)/gi
|
||||
|
||||
export default createMark({
|
||||
const Link = createMark({
|
||||
name: 'link',
|
||||
|
||||
inclusive: false,
|
||||
@ -66,12 +58,12 @@ export default createMark({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
link: attributes => ({ commands }) => {
|
||||
if (!attributes.href) {
|
||||
link: (options: { href?: string, target?: string }): Command => ({ commands }) => {
|
||||
if (!options.href) {
|
||||
return commands.removeMark('link')
|
||||
}
|
||||
|
||||
return commands.updateMark('link', attributes)
|
||||
return commands.updateMark('link', options)
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -113,3 +105,11 @@ export default createMark({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Link
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Link: typeof Link,
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createNode } from '@tiptap/core'
|
||||
|
||||
export default createNode({
|
||||
const ListItem = createNode({
|
||||
name: 'list_item',
|
||||
|
||||
content: 'paragraph block*',
|
||||
@ -25,3 +25,11 @@ export default createNode({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default ListItem
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
ListItem: typeof ListItem,
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
import { Command, createNode } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
// export type OrderedListCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// orderedList: OrderedListCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createNode({
|
||||
const OrderedList = createNode({
|
||||
name: 'ordered_list',
|
||||
|
||||
content: 'list_item+',
|
||||
@ -46,7 +38,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
orderedList: () => ({ commands }) => {
|
||||
orderedList: (): Command => ({ commands }) => {
|
||||
return commands.toggleList('ordered_list', 'list_item')
|
||||
},
|
||||
}
|
||||
@ -69,3 +61,11 @@ export default createNode({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default OrderedList
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
OrderedList: typeof OrderedList,
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
import { createNode } from '@tiptap/core'
|
||||
import { Command, createNode } from '@tiptap/core'
|
||||
// import ParagraphComponent from './paragraph.vue'
|
||||
|
||||
// export type ParagraphCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// paragraph: ParagraphCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createNode({
|
||||
const Paragraph = createNode({
|
||||
name: 'paragraph',
|
||||
|
||||
group: 'block',
|
||||
@ -58,7 +50,7 @@ export default createNode({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
paragraph: () => ({ commands }) => {
|
||||
paragraph: (): Command => ({ commands }) => {
|
||||
return commands.toggleBlockType('paragraph', 'paragraph')
|
||||
},
|
||||
}
|
||||
@ -70,3 +62,11 @@ export default createNode({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default Paragraph
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Paragraph: typeof Paragraph,
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,10 @@ import {
|
||||
Command, createMark, markInputRule, markPasteRule,
|
||||
} from '@tiptap/core'
|
||||
|
||||
// type StrikeCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// strike: StrikeCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/gm
|
||||
|
||||
export default createMark({
|
||||
const Strike = createMark({
|
||||
name: 'strike',
|
||||
|
||||
parseHTML() {
|
||||
@ -40,7 +32,7 @@ export default createMark({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
strike: () => ({ commands }) => {
|
||||
strike: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('strike')
|
||||
},
|
||||
}
|
||||
@ -64,3 +56,11 @@ export default createMark({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default Strike
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Strike: typeof Strike,
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
import { createNode } from '@tiptap/core'
|
||||
|
||||
export default createNode({
|
||||
const Text = createNode({
|
||||
name: 'text',
|
||||
group: 'inline',
|
||||
})
|
||||
|
||||
export default Text
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Text: typeof Text,
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,6 @@
|
||||
import { Command, createMark } from '@tiptap/core'
|
||||
|
||||
// export type UnderlineCommand = () => Command
|
||||
|
||||
// declare module '@tiptap/core/src/Editor' {
|
||||
// interface Commands {
|
||||
// underline: UnderlineCommand,
|
||||
// }
|
||||
// }
|
||||
|
||||
export default createMark({
|
||||
const Underline = createMark({
|
||||
name: 'underline',
|
||||
|
||||
parseHTML() {
|
||||
@ -29,7 +21,7 @@ export default createMark({
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
underline: () => ({ commands }) => {
|
||||
underline: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('underline')
|
||||
},
|
||||
}
|
||||
@ -41,3 +33,11 @@ export default createMark({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default Underline
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface AllExtensions {
|
||||
Underline: typeof Underline,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user