-
-
Notifications
You must be signed in to change notification settings - Fork 233
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -115,6 +115,18 @@ export class TextColorExtension extends MarkExtension<TextColorOptions> { | |||||||||||||
return this.store.commands.removeMark.original({ type: this.type, ...options, expand: true }); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Get the color for the selection | ||||||||||||||
*/ | ||||||||||||||
@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 commentThe 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';
Suggested change
|
||||||||||||||
|
||||||||||||||
const state = this.store.getState(); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be used? |
||||||||||||||
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 commentThe 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
Suggested change
|
||||||||||||||
return textMarkInfo.mark.attrs.color; | ||||||||||||||
} | ||||||||||||||
/** | ||||||||||||||
* Get the color from the provided string. The string can be a computed | ||||||||||||||
* property as well. | ||||||||||||||
|
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