-
Notifications
You must be signed in to change notification settings - Fork 118
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
Added backgroundColorSpan support #911
Added backgroundColorSpan support #911
Conversation
- Added CssBackgroundColorPlugin based on CssUnderlinePlugin - Added AztecBackgroundColorSpan - General changes to implement and use BackgroundColorSpan
@felipevaladares Hi, can we change the text color of the selected text? |
This is to change the background color, not the text color, but you can use both |
the idea is to use in cases like the image on this #910 |
Thanks for your reply. I'm trying to customize your code to change the text color. |
I'm not sure if you will be able to do that using my code, you should probably create a new Span and Plugin based on my changes, i believe it will be very similar |
I have done it. Thanks for your support. Do you think we can change the font size of the selected text? |
Nice, i'm curious to see your code, have you opened a PR? |
@koke @maxme @bummytime @shiki @Tug could you guys please review this PR? |
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.
Nice work here @felipevaladares. Changes seem on the whole consistent with the existing code base, so nice job with that. However, I did notice a few minor issues that would be good to fix before merging this in.
-
While testing your PR, I noticed an existing issue that becomes more noticeable with your changes: Format text then remove format removes color style #914 . If you toggle text with background color bold or italic etc., and then toggle back off, the background color disappears unexpectedly. Ideally this is fixed before merging.
-
In the past we had other issues where certain text patterns did not show a visual for highlighting, or show a cursor when it is placed in the text. I think we are seeing similar issues with text with a backgroundColorSpan, highlighting shows no color change, and the cursor is not visible. Perhaps previous fixes for these types of issues will provide hints on how to fix that. (Issue/219 code highlight color #244 , Fixin visibility of cursor in quote #249)
-
Perhaps for at least this first iteration we can add Background Color button to the Plugin buttons section of the toolbar, so that it is easy to not include the button if we do not add the new CssBackgroundColorPlugin. This way existing apps using Aztec will not have the new button show up unless they want to use it. (For example, notice if you comment this line
AztecEditor-Android/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt
Line 443 in a1386be
.addPlugin(MoreToolbarButton(visualEditor)) aztec.addPlugin(CssBackgroundColorPlugin())
because it is in the main layout sections of simple and advanced toolbars instead of the plugin section.)
Thanks again for the changes here.
Hi @cameronvoell thanks for reviewing, i'll try to handle all the issues and improvements as soon as possible :) |
Hi @felipevaladares, Thank you very much! |
…as plugin so that could be optional
@cameronvoell can you verify if the 1st and 3th items are ok? I believe i fixed the #914 also i removed the button from the toolbar and changed to be a plugin, still trying to figure out the second item(highlighting problem) |
@cameronvoell highlight problem fixed 👍 |
…acilitate the use on recyclerview with multiple edittext for example
@@ -238,13 +262,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat | |||
joinStyleSpans(start, end) | |||
} | |||
|
|||
fun removeInlineCssStyle(start: Int = selectionStart, end: Int = selectionEnd) { |
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 am a little suspicious that removing this code might have side effects, though I'm not sure what they are yet. Also this does not seem to fix all cases of #914. For example, if you highlight the first red italic text in the sample text and turn off italic, and then open html you will see the color attribute is gone, and returning from html the color will be gone in the display text.
I did see that background color no longer disappears when you remove a text format so that is an improvement. Perhaps we leave this code as it was since it does not affect background, and it does not seem to completely fix #914 either.
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 code is weird, it just remove everything without any rules, not sure if it will break something, maybe it's a work around to something? it really doesn't make any sense to me
@@ -221,8 +247,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat | |||
editableText.removeSpan(it) | |||
} | |||
} | |||
// remove the CSS style span | |||
removeInlineCssStyle() |
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.
Suggest we keep this for now since it does not affect background color, see previous https://github.com/wordpress-mobile/AztecEditor-Android/pull/911/files#r463370943
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.
ok, if really doesn't affect bg color i think we can keep, but its something to take a look in the future, that method doesn't make much sense
|
||
class AztecBackgroundColorSpan( | ||
val color: Int, | ||
val alpha: Int = 220, |
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 think only color
is ever used as a constructor parameter from here. The other parameters can probably be moved to be class properties. What do you think?
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.
no problem, i'll take a look into this
Hello @arctouch-felipevaladares , thanks for the updates, and sorry for the delay with the review.
Nice fix here.
I left some comments about the 1st item, along with a few other comments on the code. The 3rd item for making the background button functionality an optional plugin is looking good as well 👍 I did find one other issue that is related to the highlight state of the Background button. It looks like after highlighting some text and then navigating elsewhere the button stays highlighted. The button should function like the other buttons in that it is highlighted only when placed above or highlighting text that has that property, and then it should automatically go to inactive state when moved elsewhere (see bold or italic button for example). |
Just a note that we're changing the project license, since this haven't landed yet it's not a problem, but if the patch land after the switch, it will be done under the MPL v2. Ref. #922 |
Hi @felipevaladares :) do you think you might be able to respond to @cameronvoell's comments in the near term? If not, I might be interested in taking over this effort. Let me know! |
Hi @yuvalgnessin-qz i will do that this week :) |
No problem, i agree |
I suggest the background icon take the current background color, so moving cursor could modify this color too And it will be ready for a color picker |
Hello @cameronvoell and others! Since @felipevaladares was not available to address the changes you requested, I have opened a new PR #934 implemented by @lvcasasanta to replace this one. It addresses all the changes you have requested. Please take a look as soon as you can. Thank you! |
I'm going ahead to close this PR, as it's been superseded by #1041. |
Test
Review
@koke @maxme @bummytime @shiki @Tug