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-10 00:55:19 +08:00
|
|
|
export interface MarkCallback<Options> {
|
2020-09-09 18:57:50 +08:00
|
|
|
name: string
|
|
|
|
editor: Editor
|
2020-09-09 23:10:29 +08:00
|
|
|
options: Options
|
2020-09-09 18:57:50 +08:00
|
|
|
type: MarkType
|
2020-09-09 05:44:45 +08:00
|
|
|
}
|
2020-03-30 18:40:25 +08:00
|
|
|
|
2020-09-09 23:10:29 +08:00
|
|
|
export interface MarkExtends<Callback, Options> extends ExtensionExtends<Callback, Options> {
|
2020-09-09 05:44:45 +08:00
|
|
|
topMark: boolean
|
2020-09-09 23:22:59 +08:00
|
|
|
schema: (params: Omit<Callback, 'type' | 'editor'>) => MarkSpec
|
2020-03-30 18:40:25 +08:00
|
|
|
}
|
2020-09-09 05:44:45 +08:00
|
|
|
|
2020-09-09 23:10:29 +08:00
|
|
|
export default class Mark<
|
|
|
|
Options = {},
|
|
|
|
Callback = MarkCallback<Options>,
|
|
|
|
Extends extends MarkExtends<Callback, Options> = MarkExtends<Callback, Options>
|
|
|
|
> extends Extension<Options, Callback, Extends> {
|
2020-09-09 17:23:24 +08:00
|
|
|
type = 'mark'
|
2020-09-09 05:44:45 +08:00
|
|
|
|
2020-09-09 23:10:29 +08:00
|
|
|
public schema(value: Extends['schema']) {
|
2020-09-09 05:44:45 +08:00
|
|
|
this.storeConfig('schema', value, 'overwrite')
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
}
|