fix toggle blockquotes

This commit is contained in:
Philipp Kühn
2018-10-10 15:08:37 +02:00
parent 27fa310937
commit fe210f68ed
3 changed files with 22 additions and 6 deletions

View File

@@ -0,0 +1,14 @@
import { wrapIn, lift } from 'prosemirror-commands'
import { nodeIsActive } from 'tiptap-utils'
export default function (type) {
return (state, dispatch, view) => {
const isActive = nodeIsActive(state, type)
if (isActive) {
return lift(state, dispatch)
}
return wrapIn(type)(state, dispatch, view)
}
}

View File

@@ -46,6 +46,7 @@ import setInlineBlockType from './commands/setInlineBlockType'
import splitToDefaultListItem from './commands/splitToDefaultListItem'
import toggleBlockType from './commands/toggleBlockType'
import toggleList from './commands/toggleList'
import toggleWrap from './commands/toggleWrap'
import updateMark from './commands/updateMark'
export {
@@ -95,5 +96,6 @@ export {
splitToDefaultListItem,
toggleBlockType,
toggleList,
toggleWrap,
updateMark,
}

View File

@@ -1,5 +1,5 @@
import { Node, Plugin } from 'tiptap'
import { wrappingInputRule, wrapIn } from 'tiptap-commands'
import { Node } from 'tiptap'
import { wrappingInputRule, toggleWrap } from 'tiptap-commands'
export default class BlockquoteNode extends Node {
@@ -9,7 +9,7 @@ export default class BlockquoteNode extends Node {
get schema() {
return {
content: 'block+',
content: 'block*',
group: 'block',
defining: true,
draggable: false,
@@ -20,13 +20,13 @@ export default class BlockquoteNode extends Node {
}
}
command({ type }) {
return wrapIn(type)
command({ type, schema }) {
return toggleWrap(type, schema.nodes.paragraph)
}
keys({ type }) {
return {
'Ctrl->': wrapIn(type),
'Ctrl->': toggleWrap(type),
}
}