add basic extension classes

This commit is contained in:
Philipp Kühn
2020-10-09 22:59:25 +02:00
parent a4ccb36e10
commit 8324f57528
13 changed files with 421 additions and 266 deletions

View File

@@ -1,28 +1,48 @@
import { MarkSpec, MarkType } from 'prosemirror-model'
import Extension, { ExtensionMethods } from './Extension'
import { Editor } from './Editor'
// import { MarkSpec, MarkType } from 'prosemirror-model'
// import Extension, { ExtensionMethods } from './Extension'
// import { Editor } from './Editor'
export interface MarkProps<Options> {
name: string
editor: Editor
options: Options
type: MarkType
}
// export interface MarkProps<Options> {
// name: string
// editor: Editor
// options: Options
// type: MarkType
// }
export interface MarkMethods<Props, Options> extends ExtensionMethods<Props, Options> {
topMark: boolean
schema: (params: Omit<Props, 'type' | 'editor'>) => MarkSpec
}
// export interface MarkMethods<Props, Options> extends ExtensionMethods<Props, Options> {
// topMark: boolean
// schema: (params: Omit<Props, 'type' | 'editor'>) => MarkSpec
// }
// export default class Mark<
// Options = {},
// Props = MarkProps<Options>,
// Methods extends MarkMethods<Props, Options> = MarkMethods<Props, Options>,
// > extends Extension<Options, Props, Methods> {
// type = 'mark'
// public schema(value: Methods['schema']) {
// this.storeConfig('schema', value, 'overwrite')
// return this
// }
// }
import Extension from './Extension'
export default class Node<Options = {}> extends Extension<Options> {
export default class Mark<
Options = {},
Props = MarkProps<Options>,
Methods extends MarkMethods<Props, Options> = MarkMethods<Props, Options>,
> extends Extension<Options, Props, Methods> {
type = 'mark'
public schema(value: Methods['schema']) {
this.storeConfig('schema', value, 'overwrite')
return this
createAttributes() {
return {}
}
parseHTML() {
return []
}
renderHTML() {
return []
}
}