move plugins

This commit is contained in:
Philipp Kühn
2020-08-21 21:23:46 +02:00
parent 9e1bb182db
commit 53f892ddd0
3 changed files with 28 additions and 13 deletions

View File

@@ -1,11 +1,7 @@
import { EditorState, Plugin } from 'prosemirror-state' import { EditorState, Plugin } from 'prosemirror-state'
import { EditorView} from 'prosemirror-view' import { EditorView} from 'prosemirror-view'
import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model' 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 magicMethods from './utils/magicMethods'
import elementFromString from './utils/elementFromString' import elementFromString from './utils/elementFromString'
import getAllMethodNames from './utils/getAllMethodNames' import getAllMethodNames from './utils/getAllMethodNames'
@@ -21,6 +17,7 @@ import Node from './Node'
import Mark from './Mark' import Mark from './Mark'
import EventEmitter from './EventEmitter' import EventEmitter from './EventEmitter'
import ComponentRenderer from './ComponentRenderer' import ComponentRenderer from './ComponentRenderer'
import defaultPlugins from './plugins'
// commands // commands
import clearContent from './commands/clearContent' import clearContent from './commands/clearContent'
@@ -38,9 +35,6 @@ import toggleMark from './commands/toggleMark'
import toggleNode from './commands/toggleNode' import toggleNode from './commands/toggleNode'
import updateMark from './commands/updateMark' import updateMark from './commands/updateMark'
// plugins
import focusPlugin from './plugins/focus'
export type Command = (next: Function, editor: Editor) => (...args: any) => any export type Command = (next: Function, editor: Editor) => (...args: any) => any
export interface CommandSpec { export interface CommandSpec {
@@ -181,11 +175,7 @@ export class Editor extends EventEmitter {
private get plugins() { private get plugins() {
return [ return [
...this.extensionManager.plugins, ...this.extensionManager.plugins,
keymap({ Backspace: undoInputRule }), ...defaultPlugins.map(plugin => plugin(this.proxy)),
keymap(baseKeymap),
dropCursor(),
gapCursor(),
focusPlugin(this.proxy),
] ]
} }

View 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,
},
})

View 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,
]