refactoring
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ view }) => {
|
||||
const element = view.dom as HTMLElement
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (emitUpdate: Boolean = false): Command => ({ commands }) => {
|
||||
return commands.setContent('', emitUpdate)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { liftTarget } from 'prosemirror-transform'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ state, tr, dispatch }) => {
|
||||
const { selection } = tr
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { deleteSelection } from 'prosemirror-commands'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ state, dispatch }) => {
|
||||
return deleteSelection(state, dispatch)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
import getMarkRange from '../utils/getMarkRange'
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { Editor, Command } from '../Editor'
|
||||
import { Editor } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import minMax from '../utils/minMax'
|
||||
|
||||
type Position = 'start' | 'end' | number | boolean | null
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DOMParser } from 'prosemirror-model'
|
||||
import { Selection, Transaction } from 'prosemirror-state'
|
||||
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform'
|
||||
import elementFromString from '../utils/elementFromString'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
// TODO: move to utils
|
||||
// https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (value: string): Command => ({ tr, dispatch }) => {
|
||||
if (dispatch) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { liftListItem } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
export default (typeOrName: string | NodeType): Command => ({ state, dispatch }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
import getMarkRange from '../utils/getMarkRange'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ tr, state, dispatch }) => {
|
||||
const { selection } = tr
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (attributeNames: string[] = []): Command => ({ tr, state, dispatch }) => {
|
||||
const { selection } = tr
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ tr, dispatch }) => {
|
||||
if (dispatch) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { selectAll } from 'prosemirror-commands'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ state, dispatch }) => {
|
||||
return selectAll(state, dispatch)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { selectParentNode } from 'prosemirror-commands'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (): Command => ({ state, dispatch }) => {
|
||||
return selectParentNode(state, dispatch)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { setBlockType } from 'prosemirror-commands'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
export default (typeOrName: string | NodeType, attrs = {}): Command => ({ state, dispatch }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (content: string, emitUpdate: Boolean = false, parseOptions = {}): Command => ({ tr, editor, dispatch }) => {
|
||||
const { createDocument } = editor
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
export default (typeOrName: string | NodeType): Command => ({ state, dispatch }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { canSplit } from 'prosemirror-transform'
|
||||
import { ContentMatch, Fragment } from 'prosemirror-model'
|
||||
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
function defaultBlockAt(match: ContentMatch) {
|
||||
for (let i = 0; i < match.edgeCount; i + 1) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { splitListItem } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
export default (typeOrName: string | NodeType): Command => ({ state, dispatch }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import nodeIsActive from '../utils/nodeIsActive'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { findParentNode } from 'prosemirror-utils'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
import isList from '../utils/isList'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { toggleMark } from 'prosemirror-commands'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
import markIsActive from '../utils/markIsActive'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { wrapIn, lift } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import nodeIsActive from '../utils/nodeIsActive'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])): Command => props => {
|
||||
const items = typeof commands === 'function'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
import getMarkAttrs from '../utils/getMarkAttrs'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
|
||||
export default (attributes: {}): Command => ({ tr, state, dispatch }) => {
|
||||
const { selection } = tr
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { wrapInList } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import { Command } from '../types'
|
||||
import getNodeType from '../utils/getNodeType'
|
||||
|
||||
export default (typeOrName: string | NodeType, attrs?: {}): Command => ({ state, dispatch }) => {
|
||||
|
||||
Reference in New Issue
Block a user