-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commands): add joinUp and joinDown command (#3455)
- Loading branch information
Showing
6 changed files
with
67 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ReturnType> { | ||
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) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.