2020-09-09 05:44:45 +08:00
|
|
|
import { MarkSpec, MarkType } from 'prosemirror-model'
|
2020-09-19 06:20:34 +08:00
|
|
|
import Extension, { ExtensionMethods } from './Extension'
|
2020-09-09 18:57:50 +08:00
|
|
|
import { Editor } from './Editor'
|
2020-03-30 18:40:25 +08:00
|
|
|
|
2020-09-19 06:20:34 +08:00
|
|
|
export interface MarkProps<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-19 06:20:34 +08:00
|
|
|
export interface MarkMethods<Props, Options> extends ExtensionMethods<Props, Options> {
|
2020-09-09 05:44:45 +08:00
|
|
|
topMark: boolean
|
2020-09-19 06:20:34 +08:00
|
|
|
schema: (params: Omit<Props, '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 = {},
|
2020-09-19 06:20:34 +08:00
|
|
|
Props = MarkProps<Options>,
|
2020-09-25 19:56:31 +08:00
|
|
|
Methods extends MarkMethods<Props, Options> = MarkMethods<Props, Options>,
|
2020-09-19 06:20:34 +08:00
|
|
|
> extends Extension<Options, Props, Methods> {
|
2020-09-09 17:23:24 +08:00
|
|
|
type = 'mark'
|
2020-09-09 05:44:45 +08:00
|
|
|
|
2020-09-19 06:20:34 +08:00
|
|
|
public schema(value: Methods['schema']) {
|
2020-09-09 05:44:45 +08:00
|
|
|
this.storeConfig('schema', value, 'overwrite')
|
|
|
|
return this
|
|
|
|
}
|
2020-09-24 06:29:05 +08:00
|
|
|
}
|