New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selection strategy for list commands #588
Comments
@jbailleul I haven't found a good way to define it yet |
@jaywcjlove If adding such an option to the commands is what's bothering you (maybe for genericity/re-usability purpose between commands), what about adding an optional parameter to the const makeList = (
state: ExecuteState,
api: TextAreaTextApi,
insertBefore: string | AlterLineFunction,
selectionStrategy: 'word' | 'line' = 'word'
): void => {
// Use `selectWord()` or `selectLine()` based on the `selectionStrategy` param
...
} With this, I would only have to override the commands from my side, and not the export const customUnorderedListCommand: ICommand = {
...unorderedListCommand,
execute: (state: ExecuteState, api: TextAreaTextApi) => {
makeList(state, api, '- ', 'line');
}
};
export const customOrderedListCommand: ICommand = {
...orderedListCommand,
execute: (state: ExecuteState, api: TextAreaTextApi) => {
makeList(state, api, (item, index) => `${index + 1}. `, 'line');
}
};
export const customCheckedListCommand: ICommand = {
...checkedListCommand,
execute: (state: ExecuteState, api: TextAreaTextApi) => {
makeList(state, api, () => `- [ ] `, 'line');
}
}; |
@jbailleul |
Hi!
I would like list commands (unordered list, ordered list and checked list commands) to be applied to the whole line instead of word.
For now, I've achieved that by defining custom commands and overriding the
makeList()
function:Would it be possible to have something like a
selectionStrategy
option on the commands, that could be set toword
orline
for example? Then themakeList()
function would useselectWord()
orselectLine()
accordingly?Thanks for you great work!
The text was updated successfully, but these errors were encountered: