tiptap/packages/core/src/Mark.ts

24 lines
613 B
TypeScript
Raw Normal View History

2020-09-09 05:44:45 +08:00
import { MarkSpec, MarkType } from 'prosemirror-model'
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
2020-09-09 18:57:50 +08:00
import { Editor } from './Editor'
2020-03-30 18:40:25 +08:00
2020-09-09 18:57:50 +08:00
interface Callback {
name: string
editor: Editor
options: any
type: MarkType
2020-09-09 05:44:45 +08:00
}
2020-03-30 18:40:25 +08:00
2020-09-09 18:57:50 +08:00
export interface MarkExtends extends ExtensionExtends<Callback> {
2020-09-09 05:44:45 +08:00
topMark: boolean
schema: (params: Callback) => MarkSpec
2020-03-30 18:40:25 +08:00
}
2020-09-09 05:44:45 +08:00
2020-09-09 18:57:50 +08:00
export default class Mark<Options = {}> extends Extension<Options, Callback, MarkExtends> {
2020-09-09 17:23:24 +08:00
type = 'mark'
2020-09-09 05:44:45 +08:00
public schema(value: MarkExtends['schema']) {
this.storeConfig('schema', value, 'overwrite')
return this
}
}