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 splitToDefaultListItem from './commands/splitToDefaultListItem'
|
||||||
import toggleBlockType from './commands/toggleBlockType'
|
import toggleBlockType from './commands/toggleBlockType'
|
||||||
import toggleList from './commands/toggleList'
|
import toggleList from './commands/toggleList'
|
||||||
|
import toggleWrap from './commands/toggleWrap'
|
||||||
import updateMark from './commands/updateMark'
|
import updateMark from './commands/updateMark'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -95,5 +96,6 @@ export {
|
|||||||
splitToDefaultListItem,
|
splitToDefaultListItem,
|
||||||
toggleBlockType,
|
toggleBlockType,
|
||||||
toggleList,
|
toggleList,
|
||||||
|
toggleWrap,
|
||||||
updateMark,
|
updateMark,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Node, Plugin } from 'tiptap'
|
import { Node } from 'tiptap'
|
||||||
import { wrappingInputRule, wrapIn } from 'tiptap-commands'
|
import { wrappingInputRule, toggleWrap } from 'tiptap-commands'
|
||||||
|
|
||||||
export default class BlockquoteNode extends Node {
|
export default class BlockquoteNode extends Node {
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ export default class BlockquoteNode extends Node {
|
|||||||
|
|
||||||
get schema() {
|
get schema() {
|
||||||
return {
|
return {
|
||||||
content: 'block+',
|
content: 'block*',
|
||||||
group: 'block',
|
group: 'block',
|
||||||
defining: true,
|
defining: true,
|
||||||
draggable: false,
|
draggable: false,
|
||||||
@@ -20,13 +20,13 @@ export default class BlockquoteNode extends Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
command({ type }) {
|
command({ type, schema }) {
|
||||||
return wrapIn(type)
|
return toggleWrap(type, schema.nodes.paragraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
keys({ type }) {
|
keys({ type }) {
|
||||||
return {
|
return {
|
||||||
'Ctrl->': wrapIn(type),
|
'Ctrl->': toggleWrap(type),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user