Skip to content

Commit 3875c09

Browse files
committed
Use AlignmentApproach with HiddenHtmlSpan
1 parent 1238849 commit 3875c09

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecTagHandler.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import org.wordpress.aztec.spans.IAztecNestable
4141
import org.wordpress.aztec.spans.createAztecQuoteSpan
4242
import org.wordpress.aztec.spans.createHeadingSpan
4343
import org.wordpress.aztec.spans.createHiddenHtmlBlockSpan
44+
import org.wordpress.aztec.spans.createHiddenHtmlSpan
4445
import org.wordpress.aztec.spans.createListItemSpan
4546
import org.wordpress.aztec.spans.createOrderedListSpan
4647
import org.wordpress.aztec.spans.createParagraphSpan
@@ -82,7 +83,8 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
8283
return true
8384
}
8485
SPAN -> {
85-
handleElement(output, opening, HiddenHtmlSpan(tag, AztecAttributes(attributes), nestingLevel))
86+
val span = createHiddenHtmlSpan(tag, AztecAttributes(attributes), nestingLevel, alignmentApproach)
87+
handleElement(output, opening, span)
8688
return true
8789
}
8890
DIV, FIGURE, FIGCAPTION, SECTION -> {

aztec/src/main/kotlin/org/wordpress/aztec/plugins/CssUnderlinePlugin.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package org.wordpress.aztec.plugins
33
import android.text.Spannable
44
import android.text.SpannableStringBuilder
55
import android.text.Spanned
6+
import org.wordpress.aztec.AlignmentApproach
7+
import org.wordpress.aztec.AztecText
68
import org.wordpress.aztec.plugins.html2visual.ISpanPostprocessor
79
import org.wordpress.aztec.plugins.visual2html.ISpanPreprocessor
810
import org.wordpress.aztec.source.CssStyleFormatter
@@ -11,7 +13,9 @@ import org.wordpress.aztec.spans.HiddenHtmlSpan
1113
import org.wordpress.aztec.spans.IAztecNestable
1214
import org.wordpress.aztec.util.SpanWrapper
1315

14-
class CssUnderlinePlugin : ISpanPostprocessor, ISpanPreprocessor {
16+
class CssUnderlinePlugin(
17+
val alignmentApproach: AlignmentApproach = AztecText.DEFAULT_ALIGNMENT_APPROACH
18+
) : ISpanPostprocessor, ISpanPreprocessor {
1519

1620
private val SPAN_TAG = "span"
1721
private val UNDERLINE_STYLE_VALUE = "underline"
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
package org.wordpress.aztec.spans
22

33
import android.text.Layout
4+
import org.wordpress.aztec.AlignmentApproach
45
import org.wordpress.aztec.AztecAttributes
56

6-
class HiddenHtmlSpan(tag: String,
7-
override var attributes: AztecAttributes = AztecAttributes(),
8-
override var nestingLevel: Int) : IAztecAlignmentSpan, IAztecParagraphStyle {
7+
fun createHiddenHtmlSpan(tag: String,
8+
attributes: AztecAttributes = AztecAttributes(),
9+
nestingLevel: Int,
10+
alignmentApproach: AlignmentApproach
11+
) = when (alignmentApproach) {
12+
AlignmentApproach.SPAN_LEVEL -> HiddenHtmlSpanAligned(tag, attributes, nestingLevel)
13+
AlignmentApproach.VIEW_LEVEL -> HiddenHtmlSpan(tag, attributes, nestingLevel)
14+
}
15+
16+
class HiddenHtmlSpanAligned(tag: String,
17+
attributes: AztecAttributes,
18+
nestingLevel: Int
19+
) : HiddenHtmlSpan(tag, attributes, nestingLevel), IAztecAlignmentSpan {
920
override var align: Layout.Alignment? = null
21+
}
1022

23+
open class HiddenHtmlSpan(tag: String,
24+
override var attributes: AztecAttributes,
25+
override var nestingLevel: Int) : IAztecParagraphStyle {
1126
override val TAG: String = tag
1227
}

0 commit comments

Comments
 (0)