feat: add selectTextblockStart and selectTextblockEnd commands
This commit is contained in:
5
docs/api/commands/select-textblock-end.md
Normal file
5
docs/api/commands/select-textblock-end.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# selectTextblockEnd
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis)
|
||||||
|
:::
|
||||||
5
docs/api/commands/select-textblock-start.md
Normal file
5
docs/api/commands/select-textblock-start.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# selectTextblockStart
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis)
|
||||||
|
:::
|
||||||
@@ -223,6 +223,12 @@
|
|||||||
- title: selectParentNode
|
- title: selectParentNode
|
||||||
link: /api/commands/select-parent-node
|
link: /api/commands/select-parent-node
|
||||||
type: draft
|
type: draft
|
||||||
|
- title: selectTextblockEnd
|
||||||
|
link: /api/commands/select-textblock-end
|
||||||
|
type: draft
|
||||||
|
- title: selectTextblockStart
|
||||||
|
link: /api/commands/select-textblock-start
|
||||||
|
type: draft
|
||||||
- title: setContent
|
- title: setContent
|
||||||
link: /api/commands/set-content
|
link: /api/commands/set-content
|
||||||
- title: setMark
|
- title: setMark
|
||||||
|
|||||||
19
packages/core/src/commands/selectTextblockEnd.ts
Normal file
19
packages/core/src/commands/selectTextblockEnd.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
// TODO: add types to @types/prosemirror-commands
|
||||||
|
import { selectTextblockEnd as originalSelectTextblockEnd } from 'prosemirror-commands'
|
||||||
|
import { RawCommands } from '../types'
|
||||||
|
|
||||||
|
declare module '@tiptap/core' {
|
||||||
|
interface Commands<ReturnType> {
|
||||||
|
selectTextblockEnd: {
|
||||||
|
/**
|
||||||
|
* Moves the cursor to the end of current text block.
|
||||||
|
*/
|
||||||
|
selectTextblockEnd: () => ReturnType,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const selectTextblockEnd: RawCommands['selectTextblockEnd'] = () => ({ state, dispatch }) => {
|
||||||
|
return originalSelectTextblockEnd(state, dispatch)
|
||||||
|
}
|
||||||
19
packages/core/src/commands/selectTextblockStart.ts
Normal file
19
packages/core/src/commands/selectTextblockStart.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
// TODO: add types to @types/prosemirror-commands
|
||||||
|
import { selectTextblockStart as originalSelectTextblockStart } from 'prosemirror-commands'
|
||||||
|
import { RawCommands } from '../types'
|
||||||
|
|
||||||
|
declare module '@tiptap/core' {
|
||||||
|
interface Commands<ReturnType> {
|
||||||
|
selectTextblockStart: {
|
||||||
|
/**
|
||||||
|
* Moves the cursor to the start of current text block.
|
||||||
|
*/
|
||||||
|
selectTextblockStart: () => ReturnType,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const selectTextblockStart: RawCommands['selectTextblockStart'] = () => ({ state, dispatch }) => {
|
||||||
|
return originalSelectTextblockStart(state, dispatch)
|
||||||
|
}
|
||||||
@@ -28,6 +28,8 @@ import * as selectAll from '../commands/selectAll'
|
|||||||
import * as selectNodeBackward from '../commands/selectNodeBackward'
|
import * as selectNodeBackward from '../commands/selectNodeBackward'
|
||||||
import * as selectNodeForward from '../commands/selectNodeForward'
|
import * as selectNodeForward from '../commands/selectNodeForward'
|
||||||
import * as selectParentNode from '../commands/selectParentNode'
|
import * as selectParentNode from '../commands/selectParentNode'
|
||||||
|
import * as selectTextblockEnd from '../commands/selectTextblockEnd'
|
||||||
|
import * as selectTextblockStart from '../commands/selectTextblockStart'
|
||||||
import * as setContent from '../commands/setContent'
|
import * as setContent from '../commands/setContent'
|
||||||
import * as setMark from '../commands/setMark'
|
import * as setMark from '../commands/setMark'
|
||||||
import * as setMeta from '../commands/setMeta'
|
import * as setMeta from '../commands/setMeta'
|
||||||
@@ -77,6 +79,8 @@ export { selectAll }
|
|||||||
export { selectNodeBackward }
|
export { selectNodeBackward }
|
||||||
export { selectNodeForward }
|
export { selectNodeForward }
|
||||||
export { selectParentNode }
|
export { selectParentNode }
|
||||||
|
export { selectTextblockEnd }
|
||||||
|
export { selectTextblockStart }
|
||||||
export { setContent }
|
export { setContent }
|
||||||
export { setMark }
|
export { setMark }
|
||||||
export { setMeta }
|
export { setMeta }
|
||||||
@@ -131,6 +135,8 @@ export const Commands = Extension.create({
|
|||||||
...selectNodeBackward,
|
...selectNodeBackward,
|
||||||
...selectNodeForward,
|
...selectNodeForward,
|
||||||
...selectParentNode,
|
...selectParentNode,
|
||||||
|
...selectTextblockEnd,
|
||||||
|
...selectTextblockStart,
|
||||||
...setContent,
|
...setContent,
|
||||||
...setMark,
|
...setMark,
|
||||||
...setMeta,
|
...setMeta,
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ export const Keymap = Extension.create({
|
|||||||
Delete: handleDelete,
|
Delete: handleDelete,
|
||||||
'Mod-Delete': handleDelete,
|
'Mod-Delete': handleDelete,
|
||||||
'Mod-a': () => this.editor.commands.selectAll(),
|
'Mod-a': () => this.editor.commands.selectAll(),
|
||||||
|
'Ctrl-a': () => this.editor.commands.selectTextblockStart(),
|
||||||
|
'Ctrl-e': () => this.editor.commands.selectTextblockEnd(),
|
||||||
|
Home: () => this.editor.commands.selectTextblockStart(),
|
||||||
|
End: () => this.editor.commands.selectTextblockStart(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user