diff --git a/docs/api/commands/join-down.md b/docs/api/commands/join-down.md new file mode 100644 index 00000000000..18d3be53e80 --- /dev/null +++ b/docs/api/commands/join-down.md @@ -0,0 +1,8 @@ +# joinDown +The `joinDown` command joins the selected block, or if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling below it. [See also](https://prosemirror.net/docs/ref/#commands.joinDown) + +## Usage +```js +editor.commands.joinDown() +``` + diff --git a/docs/api/commands/join-up.md b/docs/api/commands/join-up.md new file mode 100644 index 00000000000..89e70a3b70a --- /dev/null +++ b/docs/api/commands/join-up.md @@ -0,0 +1,8 @@ +# joinUp +The `joinUp` command joins the selected block, or if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it. [See also](https://prosemirror.net/docs/ref/#commands.joinUp) + +## Usage +```js +editor.commands.joinUp() +``` + diff --git a/packages/core/src/commands/index.ts b/packages/core/src/commands/index.ts index 44242042afb..a9711f9b3e7 100644 --- a/packages/core/src/commands/index.ts +++ b/packages/core/src/commands/index.ts @@ -15,8 +15,7 @@ export * from './focus' export * from './forEach' export * from './insertContent' export * from './insertContentAt' -export * from './joinBackward' -export * from './joinForward' +export * from './join' export * from './keyboardShortcut' export * from './lift' export * from './liftEmptyBlock' diff --git a/packages/core/src/commands/join.ts b/packages/core/src/commands/join.ts new file mode 100644 index 00000000000..a872aeb21b0 --- /dev/null +++ b/packages/core/src/commands/join.ts @@ -0,0 +1,50 @@ +import { + joinBackward as originalJoinBackward, joinDown as originalJoinDown, joinForward as originalJoinForward, joinUp as originalJoinUp, +} from 'prosemirror-commands' + +import { RawCommands } from '../types' + +declare module '@tiptap/core' { + interface Commands { + joinUp: { + /** + * Join two nodes Up. + */ + joinUp: () => ReturnType, + } + joinDown: { + /** + * Join two nodes Down. + */ + joinDown: () => ReturnType, + } + joinBackward: { + /** + * Join two nodes Backwards. + */ + joinBackward: () => ReturnType, + } + joinForward: { + /** + * Join two nodes Forwards. + */ + joinForward: () => ReturnType, + } + } +} + +export const joinUp: RawCommands['joinUp'] = () => ({ state, dispatch }) => { + return originalJoinUp(state, dispatch) +} + +export const joinDown: RawCommands['joinDown'] = () => ({ state, dispatch }) => { + return originalJoinDown(state, dispatch) +} + +export const joinBackward: RawCommands['joinBackward'] = () => ({ state, dispatch }) => { + return originalJoinBackward(state, dispatch) +} + +export const joinForward: RawCommands['joinForward'] = () => ({ state, dispatch }) => { + return originalJoinForward(state, dispatch) +} diff --git a/packages/core/src/commands/joinBackward.ts b/packages/core/src/commands/joinBackward.ts deleted file mode 100644 index f00f0cd6e42..00000000000 --- a/packages/core/src/commands/joinBackward.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { joinBackward as originalJoinBackward } from 'prosemirror-commands' - -import { RawCommands } from '../types' - -declare module '@tiptap/core' { - interface Commands { - joinBackward: { - /** - * Join two nodes backward. - */ - joinBackward: () => ReturnType, - } - } -} - -export const joinBackward: RawCommands['joinBackward'] = () => ({ state, dispatch }) => { - return originalJoinBackward(state, dispatch) -} diff --git a/packages/core/src/commands/joinForward.ts b/packages/core/src/commands/joinForward.ts deleted file mode 100644 index 8f224318458..00000000000 --- a/packages/core/src/commands/joinForward.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { joinForward as originalJoinForward } from 'prosemirror-commands' - -import { RawCommands } from '../types' - -declare module '@tiptap/core' { - interface Commands { - joinForward: { - /** - * Join two nodes forward. - */ - joinForward: () => ReturnType, - } - } -} - -export const joinForward: RawCommands['joinForward'] = () => ({ state, dispatch }) => { - return originalJoinForward(state, dispatch) -}