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
Add helper for text color extention #1799
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for the contribution @Anenth!
Sorry my review is so late, my normal job has been taking up all my time recently
* Get the color for the selection | ||
*/ | ||
@helper() | ||
getTextColorForSelection(selection?: Selection): Helper<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should default to the current selection here, I believe
import { Selection } from '@remirror/core';
getTextColorForSelection(selection?: Selection): Helper<string> { | |
getTextColorForSelection(selection: Selection = this.store.getState().selection): Helper<string> { |
*/ | ||
@helper() | ||
getTextColorForSelection(selection?: Selection): Helper<string> { | ||
if (!selection) return this.options.defaultColor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we need to check we have a text selection here?
import { isTextSelection } from '@remirror/core';
if (!selection) return this.options.defaultColor; | |
if (!isTextSelection(selection) || selection.empty) { | |
return this.options.defaultColor; | |
} |
getTextColorForSelection(selection?: Selection): Helper<string> { | ||
if (!selection) return this.options.defaultColor; | ||
|
||
const state = this.store.getState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used?
|
||
const state = this.store.getState(); | ||
const textMarkInfo = getMarkRange(selection.$from, this.type); | ||
if (!textMarkInfo) return this.options.defaultColor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting is a bit off here, suspect this would be fixed by running pnpm fix
if (!textMarkInfo) return this.options.defaultColor; | |
if (!textMarkInfo) { | |
return this.options.defaultColor; | |
} | |
Description
Added a helper to get the color from the current selection
Checklist
pnpm fix
completed successfully.pnpm test
.Screenshots