refactoring
This commit is contained in:
@@ -14,25 +14,16 @@ import createStyleTag from './utils/createStyleTag'
|
||||
import CommandManager from './CommandManager'
|
||||
import ExtensionManager from './ExtensionManager'
|
||||
import EventEmitter from './EventEmitter'
|
||||
import { Extensions, EditorContent, CommandSpec } from './types'
|
||||
import { EditorOptions, EditorContent, CommandSpec } from './types'
|
||||
import * as extensions from './extensions'
|
||||
import style from './style'
|
||||
|
||||
export { extensions }
|
||||
|
||||
interface HTMLElement {
|
||||
export interface HTMLElement {
|
||||
editor?: Editor
|
||||
}
|
||||
|
||||
interface EditorOptions {
|
||||
element: Element,
|
||||
content: EditorContent,
|
||||
extensions: Extensions,
|
||||
injectCSS: boolean,
|
||||
autoFocus: 'start' | 'end' | number | boolean | null,
|
||||
editable: boolean,
|
||||
}
|
||||
|
||||
@magicMethods
|
||||
export class Editor extends EventEmitter {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Plugin } from 'prosemirror-state'
|
||||
import { InputRule } from 'prosemirror-inputrules'
|
||||
import { Editor } from './Editor'
|
||||
import { GlobalAttributes } from './types'
|
||||
|
||||
@@ -44,7 +45,7 @@ export interface ExtensionConfig<Options = any, Commands = {}> {
|
||||
addInputRules?: (this: {
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
}) => any[],
|
||||
}) => InputRule[],
|
||||
|
||||
/**
|
||||
* Paste rules
|
||||
@@ -52,7 +53,7 @@ export interface ExtensionConfig<Options = any, Commands = {}> {
|
||||
addPasteRules?: (this: {
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
}) => any[],
|
||||
}) => Plugin[],
|
||||
|
||||
/**
|
||||
* ProseMirror plugins
|
||||
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
MarkType,
|
||||
} from 'prosemirror-model'
|
||||
import { Plugin } from 'prosemirror-state'
|
||||
import { InputRule } from 'prosemirror-inputrules'
|
||||
import { ExtensionConfig } from './Extension'
|
||||
import { Attribute, Overwrite } from './types'
|
||||
import { Attributes, Overwrite } from './types'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<ExtensionConfig<Options, Commands>, {
|
||||
@@ -59,9 +60,7 @@ export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
this: {
|
||||
options: Options,
|
||||
},
|
||||
) => {
|
||||
[key: string]: Attribute
|
||||
},
|
||||
) => Attributes,
|
||||
|
||||
/**
|
||||
* Commands
|
||||
@@ -90,7 +89,7 @@ export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
type: MarkType,
|
||||
}) => any[],
|
||||
}) => InputRule[],
|
||||
|
||||
/**
|
||||
* Paste rules
|
||||
@@ -99,7 +98,7 @@ export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
type: MarkType,
|
||||
}) => any[],
|
||||
}) => Plugin[],
|
||||
|
||||
/**
|
||||
* ProseMirror plugins
|
||||
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
NodeType,
|
||||
} from 'prosemirror-model'
|
||||
import { Plugin } from 'prosemirror-state'
|
||||
import { InputRule } from 'prosemirror-inputrules'
|
||||
import { ExtensionConfig } from './Extension'
|
||||
import { Attribute, NodeViewRenderer, Overwrite } from './types'
|
||||
import { Attributes, NodeViewRenderer, Overwrite } from './types'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<ExtensionConfig<Options, Commands>, {
|
||||
@@ -94,9 +95,7 @@ export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
this: {
|
||||
options: Options,
|
||||
},
|
||||
) => {
|
||||
[key: string]: Attribute
|
||||
},
|
||||
) => Attributes,
|
||||
|
||||
/**
|
||||
* Commands
|
||||
@@ -125,7 +124,7 @@ export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
type: NodeType,
|
||||
}) => any[],
|
||||
}) => InputRule[],
|
||||
|
||||
/**
|
||||
* Paste rules
|
||||
@@ -134,7 +133,7 @@ export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
type: NodeType,
|
||||
}) => any[],
|
||||
}) => Plugin[],
|
||||
|
||||
/**
|
||||
* ProseMirror plugins
|
||||
|
||||
@@ -4,8 +4,6 @@ export * from './Node'
|
||||
export * from './Mark'
|
||||
export * from './types'
|
||||
|
||||
export interface AllExtensions {}
|
||||
|
||||
export { default as nodeInputRule } from './inputRules/nodeInputRule'
|
||||
export { default as markInputRule } from './inputRules/markInputRule'
|
||||
export { default as markPasteRule } from './pasteRules/markPasteRule'
|
||||
@@ -15,3 +13,5 @@ export { default as generateHTML } from './utils/generateHTML'
|
||||
export { default as getHTMLFromFragment } from './utils/getHTMLFromFragment'
|
||||
export { default as getMarkAttrs } from './utils/getMarkAttrs'
|
||||
export { default as mergeAttributes } from './utils/mergeAttributes'
|
||||
|
||||
export interface AllExtensions {}
|
||||
|
||||
@@ -7,6 +7,17 @@ import { Mark } from './Mark'
|
||||
import { Editor } from './Editor'
|
||||
import { AllExtensions } from '.'
|
||||
|
||||
export type Extensions = (Extension | Node | Mark)[]
|
||||
|
||||
export interface EditorOptions {
|
||||
element: Element,
|
||||
content: EditorContent,
|
||||
extensions: Extensions,
|
||||
injectCSS: boolean,
|
||||
autoFocus: 'start' | 'end' | number | boolean | null,
|
||||
editable: boolean,
|
||||
}
|
||||
|
||||
export type EditorContent = string | JSON | null
|
||||
|
||||
export type Command = (props: {
|
||||
@@ -22,8 +33,6 @@ export type Command = (props: {
|
||||
|
||||
export type CommandSpec = (...args: any[]) => Command
|
||||
|
||||
export type Extensions = (Extension | Node | Mark)[]
|
||||
|
||||
export type Attribute = {
|
||||
default: any,
|
||||
rendered?: boolean,
|
||||
|
||||
Reference in New Issue
Block a user