Skip to content

Commit

Permalink
Add helper for text color extention
Browse files Browse the repository at this point in the history
  • Loading branch information
Anenth committed Jul 21, 2022
1 parent bb33bd8 commit 4d04910
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

const state = this.store.getState();
const textMarkInfo = getMarkRange(selection.$from, this.type);
if (!textMarkInfo) return this.options.defaultColor;
return textMarkInfo.mark.attrs.color;
}
/**
* Get the color from the provided string. The string can be a computed
* property as well.
Expand Down

0 comments on commit 4d04910

Please sign in to comment.