Skip to content
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 v2 #934

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f00c599
New Feature, support for BackgroundColorSpan:
felipevaladares May 26, 2020
8dd7d9a
- Added new icons for ToolbarAction.BACKGROUND
felipevaladares May 26, 2020
34175a8
- Example of multiple bg colors
felipevaladares May 26, 2020
6ae030b
- General improvements, removing code that is not necessary
felipevaladares May 26, 2020
cc8533d
- Fix bug when handling with multiple bg colors
felipevaladares May 26, 2020
ded1c56
- Fix ktlint issue
felipevaladares May 26, 2020
536d95d
- Fix bug https://github.com/wordpress-mobile/AztecEditor-Android/iss…
felipevaladares Jun 30, 2020
c6a1bcf
- Improved bg color implementation, fix bugs when using multiple back…
felipevaladares Jul 2, 2020
3213bc2
- Fix lint errors
felipevaladares Jul 2, 2020
a96ef7c
-
felipevaladares Jul 2, 2020
ba6962d
- Fix broken test, changing to 'em' because it comes first on the ita…
felipevaladares Jul 2, 2020
a95d50e
- Removing bg color button from toolbar, Added BackgroundColorButton …
felipevaladares Jul 3, 2020
936884e
- Removing bg color from ToolbarAction
felipevaladares Jul 3, 2020
40503ef
- Fix highlight color not appearing when BackgroundColorSpan is applied
felipevaladares Jul 3, 2020
c876547
- Fix lint error, added alpha for custom implementations on AztecBack…
felipevaladares Jul 3, 2020
3a99a6e
- Added possibility to clear references from toolbar and editor, to f…
felipevaladares Jul 6, 2020
a00fd4a
- Fix lint error
felipevaladares Jul 6, 2020
76266cb
Merge tag 'v1.3.45' into feature/background-color-span-support
lvcasasanta Jan 21, 2021
aa13895
Fix the bug that keeps background button highlighted
lvcasasanta Jan 22, 2021
b25b30b
Returning removeInlineCssStyle method
lvcasasanta Jan 22, 2021
4c1566e
Removing attributes from constructor
lvcasasanta Jan 22, 2021
3523beb
Visual Editor is using "blue_dark" #005082
lvcasasanta Jan 22, 2021
810fe3d
Remove unnecessary check
lvcasasanta Jan 22, 2021
b58d9bd
lint: address ktlint concerns
yuvalgnessin-qz Jan 27, 2021
4261e37
test: fix broken unit tests and add BG color tests
yuvalgnessin-qz Jan 27, 2021
bdbce24
Revert "Remove unnecessary check"
yuvalgnessin-qz Feb 2, 2021
ab286ed
fix: disable BG color if it is not added as a plugin
yuvalgnessin-qz Feb 8, 2021
baad141
fix: add null check for toolbar action views
yuvalgnessin-qz Mar 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import org.wordpress.aztec.IHistoryListener
import org.wordpress.aztec.ITextFormat
import org.wordpress.aztec.glideloader.GlideImageLoader
import org.wordpress.aztec.glideloader.GlideVideoThumbnailLoader
import org.wordpress.aztec.plugins.BackgroundColorButton
import org.wordpress.aztec.plugins.CssBackgroundColorPlugin
import org.wordpress.aztec.plugins.CssUnderlinePlugin
import org.wordpress.aztec.plugins.IMediaToolbarButton
import org.wordpress.aztec.plugins.shortcodes.AudioShortcodePlugin
Expand Down Expand Up @@ -89,6 +91,7 @@ open class MainActivity : AppCompatActivity(),
private val BOLD = "<b>Bold</b><br>"
private val ITALIC = "<i style=\"color:darkred\">Italic</i><br>"
private val UNDERLINE = "<u style=\"color:lime\">Underline</u><br>"
private val BACKGROUND = "<span style=\"background-color:#005082\">BACK<b>GROUND</b></span><br>"
private val STRIKETHROUGH = "<s style=\"color:#ff666666\" class=\"test\">Strikethrough</s><br>" // <s> or <strike> or <del>
private val ORDERED = "<ol style=\"color:green\"><li>Ordered</li><li>should have color</li></ol>"
private val ORDERED_WITH_START = "<h4>Start in 10 List:</h4>" +
Expand Down Expand Up @@ -185,6 +188,7 @@ open class MainActivity : AppCompatActivity(),
BOLD +
ITALIC +
UNDERLINE +
BACKGROUND +
STRIKETHROUGH +
ORDERED +
ORDERED_WITH_START +
Expand Down Expand Up @@ -459,9 +463,13 @@ open class MainActivity : AppCompatActivity(),
aztec.visualEditor.setCalypsoMode(false)
aztec.sourceEditor?.setCalypsoMode(false)

aztec.visualEditor.setBackgroundSpanColor(resources.getColor(R.color.blue_dark))

aztec.sourceEditor?.displayStyledAndFormattedHtml(EXAMPLE)

aztec.addPlugin(CssUnderlinePlugin())
aztec.addPlugin(CssBackgroundColorPlugin())
aztec.addPlugin(BackgroundColorButton(visualEditor))
}

if (savedInstanceState == null) {
Expand Down
17 changes: 16 additions & 1 deletion aztec/src/main/kotlin/org/wordpress/aztec/AztecTagHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import android.text.Spanned
import androidx.appcompat.content.res.AppCompatResources
import org.wordpress.aztec.plugins.IAztecPlugin
import org.wordpress.aztec.plugins.html2visual.IHtmlTagHandler
import org.wordpress.aztec.source.CssStyleFormatter
import org.wordpress.aztec.spans.AztecAudioSpan
import org.wordpress.aztec.spans.AztecBackgroundColorSpan
import org.wordpress.aztec.spans.AztecHorizontalRuleSpan
import org.wordpress.aztec.spans.AztecImageSpan
import org.wordpress.aztec.spans.AztecMediaClickableSpan
Expand All @@ -38,6 +40,7 @@ import org.wordpress.aztec.spans.AztecVideoSpan
import org.wordpress.aztec.spans.HiddenHtmlSpan
import org.wordpress.aztec.spans.IAztecAttributedSpan
import org.wordpress.aztec.spans.IAztecNestable
import org.wordpress.aztec.spans.IAztecSpan
import org.wordpress.aztec.spans.createAztecQuoteSpan
import org.wordpress.aztec.spans.createHeadingSpan
import org.wordpress.aztec.spans.createHiddenHtmlBlockSpan
Expand All @@ -47,6 +50,7 @@ import org.wordpress.aztec.spans.createOrderedListSpan
import org.wordpress.aztec.spans.createParagraphSpan
import org.wordpress.aztec.spans.createPreformatSpan
import org.wordpress.aztec.spans.createUnorderedListSpan
import org.wordpress.aztec.util.ColorConverter
import org.wordpress.aztec.util.getLast
import org.xml.sax.Attributes
import java.util.ArrayList
Expand Down Expand Up @@ -83,7 +87,7 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
return true
}
SPAN -> {
val span = createHiddenHtmlSpan(tag, AztecAttributes(attributes), nestingLevel, alignmentRendering)
val span = handleBackgroundColorSpanTag(attributes, tag, nestingLevel)
handleElement(output, opening, span)
return true
}
Expand Down Expand Up @@ -154,6 +158,17 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
return false
}

private fun handleBackgroundColorSpanTag(attributes: Attributes, tag: String, nestingLevel: Int): IAztecSpan {
val attrs = AztecAttributes(attributes)
return if (CssStyleFormatter.containsStyleAttribute(attrs, CssStyleFormatter.CSS_BACKGROUND_COLOR_ATTRIBUTE) || (tagStack.isNotEmpty() && tagStack.last() is AztecBackgroundColorSpan)) {
val att = CssStyleFormatter.getStyleAttribute(attrs, CssStyleFormatter.CSS_BACKGROUND_COLOR_ATTRIBUTE)
val color = ColorConverter.getColorInt(att)
AztecBackgroundColorSpan(color)
} else {
createHiddenHtmlSpan(tag, attrs, nestingLevel, alignmentRendering)
}
}

private fun processTagHandlerPlugins(tag: String, opening: Boolean, output: Editable, attributes: Attributes, nestingLevel: Int): Boolean {
plugins.filter { it is IHtmlTagHandler }
.map { it as IHtmlTagHandler }
Expand Down
9 changes: 8 additions & 1 deletion aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
isInCalypsoMode = isCompatibleWithCalypso
}

fun setBackgroundSpanColor(color: Int) {
inlineFormatter.backgroundSpanColor = color
}

fun setGutenbergMode(isCompatibleWithGutenberg: Boolean) {
isInGutenbergMode = isCompatibleWithGutenberg
}
Expand Down Expand Up @@ -1143,6 +1147,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
AztecTextFormat.FORMAT_CITE,
AztecTextFormat.FORMAT_UNDERLINE,
AztecTextFormat.FORMAT_STRIKETHROUGH,
AztecTextFormat.FORMAT_BACKGROUND,
AztecTextFormat.FORMAT_CODE -> inlineFormatter.toggle(textFormat)
AztecTextFormat.FORMAT_BOLD,
AztecTextFormat.FORMAT_STRONG -> inlineFormatter.toggleAny(ToolbarAction.BOLD.textFormats)
Expand Down Expand Up @@ -1178,6 +1183,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
AztecTextFormat.FORMAT_CITE,
AztecTextFormat.FORMAT_UNDERLINE,
AztecTextFormat.FORMAT_STRIKETHROUGH,
AztecTextFormat.FORMAT_BACKGROUND,
AztecTextFormat.FORMAT_CODE -> return inlineFormatter.containsInlineStyle(format, selStart, selEnd)
AztecTextFormat.FORMAT_UNORDERED_LIST,
AztecTextFormat.FORMAT_ORDERED_LIST -> return blockFormatter.containsList(format, selStart, selEnd)
Expand All @@ -1191,7 +1197,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}
}

fun setToolbar(toolbar: IAztecToolbar) {
fun setToolbar(toolbar: IAztecToolbar?) {
formatToolbar = toolbar
}

Expand Down Expand Up @@ -1633,6 +1639,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
inlineFormatter.removeInlineStyle(AztecTextFormat.FORMAT_STRIKETHROUGH, start, end)
inlineFormatter.removeInlineStyle(AztecTextFormat.FORMAT_UNDERLINE, start, end)
inlineFormatter.removeInlineStyle(AztecTextFormat.FORMAT_CODE, start, end)
inlineFormatter.removeInlineStyle(AztecTextFormat.FORMAT_BACKGROUND, start, end)
}

fun removeBlockStylesFromRange(start: Int, end: Int, ignoreLineBounds: Boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ enum class AztecTextFormat : ITextFormat {
FORMAT_FONT,
FORMAT_MONOSPACE,
FORMAT_CODE,
FORMAT_BACKGROUND,
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import org.wordpress.aztec.AztecText
import org.wordpress.aztec.AztecTextFormat
import org.wordpress.aztec.Constants
import org.wordpress.aztec.ITextFormat
import org.wordpress.aztec.R
import org.wordpress.aztec.spans.AztecBackgroundColorSpan
import org.wordpress.aztec.spans.AztecCodeSpan
import org.wordpress.aztec.spans.AztecStrikethroughSpan
import org.wordpress.aztec.spans.AztecStyleBoldSpan
import org.wordpress.aztec.spans.AztecStyleCiteSpan
import org.wordpress.aztec.spans.AztecStyleItalicSpan
import org.wordpress.aztec.spans.AztecStyleEmphasisSpan
import org.wordpress.aztec.spans.AztecStyleStrongSpan
import org.wordpress.aztec.spans.AztecStyleItalicSpan
import org.wordpress.aztec.spans.AztecStyleSpan
import org.wordpress.aztec.spans.AztecStyleStrongSpan
import org.wordpress.aztec.spans.AztecUnderlineSpan
import org.wordpress.aztec.spans.IAztecInlineSpan
import org.wordpress.aztec.watchers.TextChangedEvent
Expand All @@ -30,6 +32,8 @@ import java.util.ArrayList
*/
class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormatter(editor) {

var backgroundSpanColor: Int? = null

data class CodeStyle(val codeBackground: Int, val codeBackgroundAlpha: Float, val codeColor: Int)

fun toggle(textFormat: ITextFormat) {
Expand Down Expand Up @@ -69,6 +73,7 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
AztecTextFormat.FORMAT_EMPHASIS,
AztecTextFormat.FORMAT_CITE,
AztecTextFormat.FORMAT_STRIKETHROUGH,
AztecTextFormat.FORMAT_BACKGROUND,
AztecTextFormat.FORMAT_UNDERLINE,
AztecTextFormat.FORMAT_CODE -> {
applyInlineStyle(item, textChangedEvent.inputStart, textChangedEvent.inputEnd)
Expand Down Expand Up @@ -111,6 +116,11 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
return
}

if (textFormat == AztecTextFormat.FORMAT_BACKGROUND) {
//clear previous background before applying a new one to avoid problems when using multiple bg colors
removeBackgroundInSelection(selectionStart, selectionEnd)
}

var precedingSpan: IAztecInlineSpan? = null
var followingSpan: IAztecInlineSpan? = null

Expand All @@ -129,10 +139,10 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat

if (spanEnd > start) {
// ensure css style is applied
(precedingSpan as IAztecInlineSpan).applyInlineStyleAttributes(editableText, start, end)
spanToApply.applyInlineStyleAttributes(editableText, start, end)
return@applyInlineStyle // we are adding text inside span - no need to do anything special
} else {
applySpan(precedingSpan as IAztecInlineSpan, spanStart, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
applySpan(spanToApply, spanStart, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
}
Expand All @@ -148,8 +158,7 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat

if (followingSpan != null) {
val spanEnd = editableText.getSpanEnd(followingSpan)
applySpan(followingSpan as IAztecInlineSpan, start, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
editableText.setSpan(followingSpan, start, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
applySpan(spanToApply, start, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}

Expand All @@ -172,10 +181,27 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat

applySpan(spanToApply, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}

joinStyleSpans(start, end)
}

private fun removeBackgroundInSelection(selStart: Int, selEnd: Int) {
val spans = editableText.getSpans(selStart, selEnd, AztecBackgroundColorSpan::class.java)
spans.forEach { span ->
if (span != null) {
val currentSpanStart = editableText.getSpanStart(span)
val currentSpanEnd = editableText.getSpanEnd(span)
val color = span.backgroundColor
editableText.removeSpan(span)
if (selEnd < currentSpanEnd) {
editableText.setSpan(AztecBackgroundColorSpan(color), selEnd, currentSpanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
if (selStart > currentSpanStart) {
editableText.setSpan(AztecBackgroundColorSpan(color), currentSpanStart, selStart, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
}
}

private fun applySpan(span: IAztecInlineSpan, start: Int, end: Int, type: Int) {
if (start > end || start < 0 || end > editableText.length) {
// If an external logger is available log the error there.
Expand Down Expand Up @@ -205,6 +231,7 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
AztecStrikethroughSpan::class.java -> return AztecTextFormat.FORMAT_STRIKETHROUGH
AztecUnderlineSpan::class.java -> return AztecTextFormat.FORMAT_UNDERLINE
AztecCodeSpan::class.java -> return AztecTextFormat.FORMAT_CODE
AztecBackgroundColorSpan::class.java -> return AztecTextFormat.FORMAT_BACKGROUND
else -> return null
}
}
Expand All @@ -221,7 +248,7 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
editableText.removeSpan(it)
}
}
// remove the CSS style span

removeInlineCssStyle()

list.forEach {
Expand All @@ -238,7 +265,7 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
joinStyleSpans(start, end)
}

fun removeInlineCssStyle(start: Int = selectionStart, end: Int = selectionEnd) {
private fun removeInlineCssStyle(start: Int = selectionStart, end: Int = selectionEnd) {
val spans = editableText.getSpans(start, end, ForegroundColorSpan::class.java)
spans.forEach {
editableText.removeSpan(it)
Expand All @@ -254,12 +281,17 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
if (firstSpan is StyleSpan && secondSpan is StyleSpan) {
return firstSpan.style == secondSpan.style
}
// special check for BackgroundSpan
if (firstSpan is AztecBackgroundColorSpan && secondSpan is AztecBackgroundColorSpan) {
return firstSpan.backgroundColor == secondSpan.backgroundColor
}

return firstSpan.javaClass == secondSpan.javaClass
}

// TODO: Check if there is more efficient way to tidy spans
fun joinStyleSpans(start: Int, end: Int) {

// joins spans on the left
if (start > 1) {
val spansInSelection = editableText.getSpans(start, end, IAztecInlineSpan::class.java)
Expand Down Expand Up @@ -349,6 +381,8 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
AztecTextFormat.FORMAT_STRIKETHROUGH -> return AztecStrikethroughSpan()
AztecTextFormat.FORMAT_UNDERLINE -> return AztecUnderlineSpan()
AztecTextFormat.FORMAT_CODE -> return AztecCodeSpan(codeStyle)
AztecTextFormat.FORMAT_BACKGROUND -> return AztecBackgroundColorSpan(backgroundSpanColor ?: R.color.background)

else -> return AztecStyleSpan(Typeface.NORMAL)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.wordpress.aztec.plugins

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.wordpress.aztec.AztecText
import org.wordpress.aztec.R
import org.wordpress.aztec.toolbar.AztecToolbar
import org.wordpress.aztec.toolbar.IToolbarAction
import org.wordpress.aztec.toolbar.ToolbarAction

class BackgroundColorButton(private val visualEditor: AztecText) : IToolbarButton {

override val action: IToolbarAction = ToolbarAction.BACKGROUND
override val context = visualEditor.context!!

override fun toggle() {
visualEditor.toggleFormatting(action.textFormats.first())
}

override fun inflateButton(parent: ViewGroup) {
LayoutInflater.from(context).inflate(R.layout.background_color_button, parent)
}

override fun toolbarStateAboutToChange(toolbar: AztecToolbar, enable: Boolean) {
toolbar.findViewById<View>(action.buttonId).isEnabled = enable
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.wordpress.aztec.plugins

import android.text.SpannableStringBuilder
import org.wordpress.aztec.plugins.visual2html.ISpanPreprocessor
import org.wordpress.aztec.source.CssStyleFormatter
import org.wordpress.aztec.spans.AztecBackgroundColorSpan

class CssBackgroundColorPlugin : ISpanPreprocessor {

override fun beforeSpansProcessed(spannable: SpannableStringBuilder) {
spannable.getSpans(0, spannable.length, AztecBackgroundColorSpan::class.java).forEach {
if (!CssStyleFormatter.containsStyleAttribute(it.attributes, CssStyleFormatter.CSS_BACKGROUND_COLOR_ATTRIBUTE)) {
CssStyleFormatter.addStyleAttribute(it.attributes, CssStyleFormatter.CSS_BACKGROUND_COLOR_ATTRIBUTE, it.getColorHex())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.wordpress.aztec.source

import androidx.core.text.TextDirectionHeuristicsCompat
import android.text.Editable
import android.text.Layout
import android.text.Spannable
import android.text.style.BackgroundColorSpan
import android.text.style.ForegroundColorSpan
import androidx.core.text.TextDirectionHeuristicsCompat
import org.wordpress.aztec.AztecAttributes
import org.wordpress.aztec.spans.IAztecAlignmentSpan
import org.wordpress.aztec.spans.IAztecAttributedSpan
Expand All @@ -26,10 +27,11 @@ class CssStyleFormatter {
val CSS_TEXT_DECORATION_ATTRIBUTE = "text-decoration"
val CSS_TEXT_ALIGN_ATTRIBUTE = "text-align"
val CSS_COLOR_ATTRIBUTE = "color"
val CSS_BACKGROUND_COLOR_ATTRIBUTE = "background-color"

/**
* Check the provided [attributedSpan] for the *style* attribute. If found, parse out the
* supported CSS style properties and use the results to create a [ForegroundColorSpan],
* supported CSS style properties and use the results to create a [ForegroundColorSpan] and/or [BackgroundColorSpan]
* then add it to the provided [text].
*
* Must be called immediately after the base [IAztecAttributedSpan] has been processed.
Expand All @@ -41,6 +43,7 @@ class CssStyleFormatter {
fun applyInlineStyleAttributes(text: Editable, attributedSpan: IAztecAttributedSpan, start: Int, end: Int) {
if (attributedSpan.attributes.hasAttribute(STYLE_ATTRIBUTE) && start != end) {
processColor(attributedSpan.attributes, text, start, end)
processBackgroundColor(attributedSpan.attributes, text, start, end)
if (attributedSpan is IAztecParagraphStyle) {
processAlignment(attributedSpan, text, start, end)
}
Expand Down Expand Up @@ -85,6 +88,16 @@ class CssStyleFormatter {
}
}

private fun processBackgroundColor(attributes: AztecAttributes, text: Editable, start: Int, end: Int) {
val colorAttrValue = getStyleAttribute(attributes, CSS_BACKGROUND_COLOR_ATTRIBUTE)
if (!colorAttrValue.isBlank()) {
val colorInt = ColorConverter.getColorInt(colorAttrValue)
if (colorInt != ColorConverter.COLOR_NOT_FOUND) {
text.setSpan(BackgroundColorSpan(colorInt), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
}

fun containsStyleAttribute(attributes: AztecAttributes, styleAttributeName: String): Boolean {
return attributes.hasAttribute(STYLE_ATTRIBUTE) && getMatcher(attributes, styleAttributeName).find()
}
Expand Down