feat: add 'all' option to focus command, fix #2181
This commit is contained in:
@@ -16,15 +16,22 @@ function resolveSelection(state: EditorState, position: FocusPosition = null) {
|
||||
}
|
||||
}
|
||||
|
||||
if (position === 'end') {
|
||||
const { size } = state.doc.content
|
||||
const { size } = state.doc.content
|
||||
|
||||
if (position === 'end') {
|
||||
return {
|
||||
from: size,
|
||||
to: size,
|
||||
}
|
||||
}
|
||||
|
||||
if (position === 'all') {
|
||||
return {
|
||||
from: 0,
|
||||
to: size,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
from: position,
|
||||
to: position,
|
||||
|
||||
@@ -212,7 +212,7 @@ export type ChainedCommands = {
|
||||
|
||||
export type CanCommands = SingleCommands & { chain: () => ChainedCommands }
|
||||
|
||||
export type FocusPosition = 'start' | 'end' | number | boolean | null
|
||||
export type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null
|
||||
|
||||
export type Range = {
|
||||
from: number,
|
||||
|
||||
Reference in New Issue
Block a user