fix type issue
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export interface ExtensionCallback {
|
||||
options: any
|
||||
}
|
||||
|
||||
export interface ExtensionExtends<Callback = ExtensionCallback> {
|
||||
export interface ExtensionExtends<Callback> {
|
||||
name: string
|
||||
options: AnyObject
|
||||
commands: (params: Callback) => CommandSpec
|
||||
@@ -78,7 +78,7 @@ export interface ExtensionExtends<Callback = ExtensionCallback> {
|
||||
plugins: (params: Callback) => Plugin[]
|
||||
}
|
||||
|
||||
export default class Extension<Options = {}, Extends extends ExtensionExtends = ExtensionExtends> {
|
||||
export default class Extension<Options = {}, Callback = ExtensionCallback, Extends extends ExtensionExtends<Callback> = ExtensionExtends<Callback>> {
|
||||
type = 'extension'
|
||||
config: any = {}
|
||||
configs: {
|
||||
|
||||
@@ -36,6 +36,7 @@ export default class ExtensionManager {
|
||||
: {
|
||||
editor,
|
||||
options: deepmerge(extension.config.defaults, extension.usedOptions),
|
||||
// TODO: type is not available here
|
||||
// get type() {
|
||||
// console.log('called', editor.schema)
|
||||
|
||||
|
||||
@@ -1,33 +1,20 @@
|
||||
import { MarkSpec, MarkType } from 'prosemirror-model'
|
||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
// export default abstract class Mark extends Extension {
|
||||
|
||||
// constructor(options = {}) {
|
||||
// super(options)
|
||||
// }
|
||||
|
||||
// public extensionType = 'mark'
|
||||
|
||||
// abstract schema(): MarkSpec
|
||||
|
||||
// get type() {
|
||||
// return this.editor.schema.marks[this.name]
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
export interface MarkCallback extends ExtensionCallback {
|
||||
// TODO: fix optional
|
||||
type?: MarkType
|
||||
interface Callback {
|
||||
name: string
|
||||
editor: Editor
|
||||
options: any
|
||||
type: MarkType
|
||||
}
|
||||
|
||||
export interface MarkExtends<Callback = MarkCallback> extends ExtensionExtends<Callback> {
|
||||
export interface MarkExtends extends ExtensionExtends<Callback> {
|
||||
topMark: boolean
|
||||
schema: (params: Callback) => MarkSpec
|
||||
}
|
||||
|
||||
export default class Mark<Options = {}> extends Extension<Options, MarkExtends> {
|
||||
export default class Mark<Options = {}> extends Extension<Options, Callback, MarkExtends> {
|
||||
type = 'mark'
|
||||
|
||||
public schema(value: MarkExtends['schema']) {
|
||||
|
||||
@@ -1,35 +1,20 @@
|
||||
import { NodeSpec, NodeType } from 'prosemirror-model'
|
||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
// export default abstract class Node extends Extension {
|
||||
|
||||
// constructor(options = {}) {
|
||||
// super(options)
|
||||
// }
|
||||
|
||||
// public extensionType = 'node'
|
||||
|
||||
// public topNode = false
|
||||
|
||||
// abstract schema(): NodeSpec
|
||||
|
||||
// get type() {
|
||||
// return this.editor.schema.nodes[this.name]
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
export interface NodeCallback extends ExtensionCallback {
|
||||
// TODO: fix optional
|
||||
type?: NodeType
|
||||
interface Callback {
|
||||
name: string
|
||||
editor: Editor
|
||||
options: any
|
||||
type: NodeType
|
||||
}
|
||||
|
||||
export interface NodeExtends<Callback = NodeCallback> extends ExtensionExtends<Callback> {
|
||||
export interface NodeExtends extends ExtensionExtends<Callback> {
|
||||
topNode: boolean
|
||||
schema: (params: Callback) => NodeSpec
|
||||
}
|
||||
|
||||
export default class Node<Options = {}> extends Extension<Options, NodeExtends> {
|
||||
export default class Node<Options = {}> extends Extension<Options, Callback, NodeExtends> {
|
||||
type = 'node'
|
||||
|
||||
public topNode(value: NodeExtends['topNode'] = true) {
|
||||
|
||||
@@ -34,22 +34,23 @@ export default new Mark()
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-b': () => editor.bold()
|
||||
}))
|
||||
// .inputRules(({ type }) => {
|
||||
// return ['**', '__'].map(character => {
|
||||
// const regex = VerEx()
|
||||
// .add('(?:^|\\s)')
|
||||
// .beginCapture()
|
||||
// .find(character)
|
||||
// .beginCapture()
|
||||
// .somethingBut(character)
|
||||
// .endCapture()
|
||||
// .find(character)
|
||||
// .endCapture()
|
||||
// .endOfLine()
|
||||
.inputRules(({ type }) => {
|
||||
console.log(type)
|
||||
return ['**', '__'].map(character => {
|
||||
const regex = VerEx()
|
||||
.add('(?:^|\\s)')
|
||||
.beginCapture()
|
||||
.find(character)
|
||||
.beginCapture()
|
||||
.somethingBut(character)
|
||||
.endCapture()
|
||||
.find(character)
|
||||
.endCapture()
|
||||
.endOfLine()
|
||||
|
||||
// return markInputRule(regex, type)
|
||||
// })
|
||||
// })
|
||||
return markInputRule(regex, type)
|
||||
})
|
||||
})
|
||||
// .pasteRules(({ type }) => {
|
||||
// return ['**', '__'].map(character => {
|
||||
// const regex = VerEx()
|
||||
|
||||
Reference in New Issue
Block a user