move plugins
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import { EditorState, Plugin } from 'prosemirror-state'
|
||||
import { EditorView} from 'prosemirror-view'
|
||||
import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model'
|
||||
import { undoInputRule } from 'prosemirror-inputrules'
|
||||
import { keymap } from 'prosemirror-keymap'
|
||||
import { baseKeymap } from 'prosemirror-commands'
|
||||
import { dropCursor } from 'prosemirror-dropcursor'
|
||||
import { gapCursor } from 'prosemirror-gapcursor'
|
||||
|
||||
import magicMethods from './utils/magicMethods'
|
||||
import elementFromString from './utils/elementFromString'
|
||||
import getAllMethodNames from './utils/getAllMethodNames'
|
||||
@@ -21,6 +17,7 @@ import Node from './Node'
|
||||
import Mark from './Mark'
|
||||
import EventEmitter from './EventEmitter'
|
||||
import ComponentRenderer from './ComponentRenderer'
|
||||
import defaultPlugins from './plugins'
|
||||
|
||||
// commands
|
||||
import clearContent from './commands/clearContent'
|
||||
@@ -38,9 +35,6 @@ import toggleMark from './commands/toggleMark'
|
||||
import toggleNode from './commands/toggleNode'
|
||||
import updateMark from './commands/updateMark'
|
||||
|
||||
// plugins
|
||||
import focusPlugin from './plugins/focus'
|
||||
|
||||
export type Command = (next: Function, editor: Editor) => (...args: any) => any
|
||||
|
||||
export interface CommandSpec {
|
||||
@@ -181,11 +175,7 @@ export class Editor extends EventEmitter {
|
||||
private get plugins() {
|
||||
return [
|
||||
...this.extensionManager.plugins,
|
||||
keymap({ Backspace: undoInputRule }),
|
||||
keymap(baseKeymap),
|
||||
dropCursor(),
|
||||
gapCursor(),
|
||||
focusPlugin(this.proxy),
|
||||
...defaultPlugins.map(plugin => plugin(this.proxy)),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
9
packages/core/src/plugins/editable.ts
Normal file
9
packages/core/src/plugins/editable.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Plugin, PluginKey } from 'prosemirror-state'
|
||||
import Editor from '../..'
|
||||
|
||||
export default (editor: Editor) => new Plugin({
|
||||
key: new PluginKey('editable'),
|
||||
props: {
|
||||
editable: () => editor.isEditable,
|
||||
},
|
||||
})
|
||||
16
packages/core/src/plugins/index.ts
Normal file
16
packages/core/src/plugins/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { undoInputRule } from 'prosemirror-inputrules'
|
||||
import { keymap } from 'prosemirror-keymap'
|
||||
import { baseKeymap } from 'prosemirror-commands'
|
||||
import { dropCursor } from 'prosemirror-dropcursor'
|
||||
import { gapCursor } from 'prosemirror-gapcursor'
|
||||
import editable from './editable'
|
||||
import focus from './focus'
|
||||
|
||||
export default [
|
||||
() => dropCursor(),
|
||||
() => gapCursor(),
|
||||
() => keymap({ Backspace: undoInputRule }),
|
||||
() => keymap(baseKeymap),
|
||||
editable,
|
||||
focus,
|
||||
]
|
||||
Reference in New Issue
Block a user