remove commands from tiptap package
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/heyscrumpy/tiptap.git"
|
||||
},
|
||||
@@ -89,6 +89,8 @@
|
||||
"prosemirror-state": "^1.2.1",
|
||||
"prosemirror-tables": "^0.7.6",
|
||||
"prosemirror-utils": "^0.6.5",
|
||||
"prosemirror-view": "^1.4.3"
|
||||
"prosemirror-view": "^1.4.3",
|
||||
"tiptap-commands": "^0.1.0",
|
||||
"tiptap-utils": "^0.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
import {
|
||||
chainCommands,
|
||||
deleteSelection,
|
||||
joinBackward,
|
||||
selectNodeBackward,
|
||||
joinForward,
|
||||
selectNodeForward,
|
||||
joinUp,
|
||||
joinDown,
|
||||
lift,
|
||||
newlineInCode,
|
||||
exitCode,
|
||||
createParagraphNear,
|
||||
liftEmptyBlock,
|
||||
splitBlock,
|
||||
splitBlockKeepMarks,
|
||||
selectParentNode,
|
||||
selectAll,
|
||||
wrapIn,
|
||||
setBlockType,
|
||||
toggleMark,
|
||||
autoJoin,
|
||||
baseKeymap,
|
||||
pcBaseKeymap,
|
||||
macBaseKeymap,
|
||||
} from 'prosemirror-commands'
|
||||
|
||||
import {
|
||||
addListNodes,
|
||||
wrapInList,
|
||||
splitListItem,
|
||||
liftListItem,
|
||||
sinkListItem,
|
||||
} from 'prosemirror-schema-list'
|
||||
|
||||
import {
|
||||
wrappingInputRule,
|
||||
textblockTypeInputRule,
|
||||
} from 'prosemirror-inputrules'
|
||||
|
||||
import removeMark from './removeMark'
|
||||
import toggleBlockType from './toggleBlockType'
|
||||
import toggleList from './toggleList'
|
||||
import updateMark from './updateMark'
|
||||
|
||||
export {
|
||||
// prosemirror-commands
|
||||
chainCommands,
|
||||
deleteSelection,
|
||||
joinBackward,
|
||||
selectNodeBackward,
|
||||
joinForward,
|
||||
selectNodeForward,
|
||||
joinUp,
|
||||
joinDown,
|
||||
lift,
|
||||
newlineInCode,
|
||||
exitCode,
|
||||
createParagraphNear,
|
||||
liftEmptyBlock,
|
||||
splitBlock,
|
||||
splitBlockKeepMarks,
|
||||
selectParentNode,
|
||||
selectAll,
|
||||
wrapIn,
|
||||
setBlockType,
|
||||
toggleMark,
|
||||
autoJoin,
|
||||
baseKeymap,
|
||||
pcBaseKeymap,
|
||||
macBaseKeymap,
|
||||
|
||||
// prosemirror-schema-list
|
||||
addListNodes,
|
||||
wrapInList,
|
||||
splitListItem,
|
||||
liftListItem,
|
||||
sinkListItem,
|
||||
|
||||
// prosemirror-inputrules
|
||||
wrappingInputRule,
|
||||
textblockTypeInputRule,
|
||||
|
||||
// custom
|
||||
removeMark,
|
||||
toggleBlockType,
|
||||
toggleList,
|
||||
updateMark,
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export default function (type) {
|
||||
return (state, dispatch) => {
|
||||
const { from, to } = state.selection
|
||||
return dispatch(state.tr.removeMark(from, to, type))
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { setBlockType } from 'prosemirror-commands'
|
||||
import { nodeIsActive } from '../utils'
|
||||
|
||||
export default function (type, toggletype, attrs = {}) {
|
||||
return (state, dispatch, view) => {
|
||||
const isActive = nodeIsActive(state, type, attrs)
|
||||
|
||||
if (isActive) {
|
||||
return setBlockType(toggletype)(state, dispatch, view)
|
||||
}
|
||||
|
||||
return setBlockType(type, attrs)(state, dispatch, view)
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
import { nodeIsActive } from '../utils'
|
||||
import { wrapInList, liftListItem } from '../helpers'
|
||||
|
||||
export default function toggleList(type, itemType) {
|
||||
return (state, dispatch, view) => {
|
||||
const isActive = nodeIsActive(state, type)
|
||||
|
||||
if (isActive) {
|
||||
return liftListItem(itemType)(state, dispatch, view)
|
||||
}
|
||||
|
||||
return wrapInList(type)(state, dispatch, view)
|
||||
}
|
||||
}
|
||||
|
||||
// https://discuss.prosemirror.net/t/list-type-toggle/948
|
||||
|
||||
// import { wrapInList, liftListItem } from 'prosemirror-schema-list'
|
||||
|
||||
// function isList(node, schema) {
|
||||
// return (node.type === schema.nodes.bullet_list || node.type === schema.nodes.ordered_list)
|
||||
// }
|
||||
|
||||
// export default function toggleList(listType, schema) {
|
||||
// const lift = liftListItem(schema.nodes.list_item)
|
||||
// const wrap = wrapInList(listType)
|
||||
|
||||
// return (state, dispatch) => {
|
||||
// const { $from, $to } = state.selection
|
||||
// const range = $from.blockRange($to)
|
||||
// if (!range) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// if (range.depth >= 2 && $from.node(range.depth - 1).type === listType) {
|
||||
// return lift(state, dispatch)
|
||||
// } else if (range.depth >= 2 && isList($from.node(range.depth - 1), schema)) {
|
||||
// const tr = state.tr
|
||||
// const node = $from.before(range.depth - 1)
|
||||
// console.log({node})
|
||||
// // TODO: how do I pass the node above to `setNodeType`?
|
||||
// // tr.setNodeType(range.start, listType);
|
||||
// if (dispatch) dispatch(tr)
|
||||
// return false
|
||||
// } else {
|
||||
// return wrap(state, dispatch)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,6 +0,0 @@
|
||||
export default function (type, attrs) {
|
||||
return (state, dispatch) => {
|
||||
const { from, to } = state.selection
|
||||
return dispatch(state.tr.addMark(from, to, type.create(attrs)))
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Mark } from '../utils'
|
||||
import { toggleMark } from '../helpers'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class BoldMark extends Mark {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Mark } from '../utils'
|
||||
import { toggleMark } from '../helpers'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class CodeMark extends Mark {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Mark } from '../utils'
|
||||
import { toggleMark } from '../helpers'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class ItalicMark extends Mark {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Mark } from '../utils'
|
||||
import { updateMark, removeMark } from '../helpers'
|
||||
import { updateMark, removeMark } from 'tiptap-commands'
|
||||
|
||||
export default class LinkMark extends Mark {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { wrappingInputRule, setBlockType, wrapIn } from '../helpers'
|
||||
import { wrappingInputRule, setBlockType, wrapIn } from 'tiptap-commands'
|
||||
|
||||
export default class BlockquoteNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from '../helpers'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
||||
|
||||
export default class BulletNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { toggleBlockType, setBlockType, textblockTypeInputRule } from '../helpers'
|
||||
import { toggleBlockType, setBlockType, textblockTypeInputRule } from 'tiptap-commands'
|
||||
|
||||
export default class CodeBlockNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { chainCommands, exitCode } from '../helpers'
|
||||
import { chainCommands, exitCode } from 'tiptap-commands'
|
||||
|
||||
export default class HardBreakNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { setBlockType, textblockTypeInputRule, toggleBlockType } from '../helpers'
|
||||
import { setBlockType, textblockTypeInputRule, toggleBlockType } from 'tiptap-commands'
|
||||
|
||||
export default class HeadingNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { splitListItem, liftListItem, sinkListItem } from '../helpers'
|
||||
import { splitListItem, liftListItem, sinkListItem } from 'tiptap-commands'
|
||||
|
||||
export default class OrderedListNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from '../helpers'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
||||
|
||||
export default class OrderedListNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { setBlockType } from '../helpers'
|
||||
import { setBlockType } from 'tiptap-commands'
|
||||
|
||||
export default class ParagraphNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { splitListItem, liftListItem } from '../helpers'
|
||||
import { splitListItem, liftListItem } from 'tiptap-commands'
|
||||
|
||||
export default class TodoItemNode extends Node {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node } from '../utils'
|
||||
import { wrapInList, wrappingInputRule } from '../helpers'
|
||||
import { wrapInList, wrappingInputRule } from 'tiptap-commands'
|
||||
|
||||
export default class BulletNode extends Node {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user