fix toggle blockquotes
This commit is contained in:
14
packages/tiptap-commands/src/commands/toggleWrap.js
Normal file
14
packages/tiptap-commands/src/commands/toggleWrap.js
Normal 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)
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user