@@ -29,28 +29,30 @@ import androidx.appcompat.content.res.AppCompatResources
2929import org.wordpress.aztec.plugins.IAztecPlugin
3030import org.wordpress.aztec.plugins.html2visual.IHtmlTagHandler
3131import org.wordpress.aztec.spans.AztecAudioSpan
32- import org.wordpress.aztec.spans.AztecHeadingSpan
3332import org.wordpress.aztec.spans.AztecHorizontalRuleSpan
3433import org.wordpress.aztec.spans.AztecImageSpan
35- import org.wordpress.aztec.spans.AztecListItemSpan
3634import org.wordpress.aztec.spans.AztecMediaClickableSpan
3735import org.wordpress.aztec.spans.AztecMediaSpan
38- import org.wordpress.aztec.spans.AztecOrderedListSpan
39- import org.wordpress.aztec.spans.AztecPreformatSpan
40- import org.wordpress.aztec.spans.AztecQuoteSpan
4136import org.wordpress.aztec.spans.AztecStrikethroughSpan
42- import org.wordpress.aztec.spans.AztecUnorderedListSpan
4337import org.wordpress.aztec.spans.AztecVideoSpan
44- import org.wordpress.aztec.spans.HiddenHtmlBlock
4538import org.wordpress.aztec.spans.HiddenHtmlSpan
4639import org.wordpress.aztec.spans.IAztecAttributedSpan
4740import org.wordpress.aztec.spans.IAztecNestable
41+ import org.wordpress.aztec.spans.createAztecQuoteSpan
42+ import org.wordpress.aztec.spans.createHeadingSpan
43+ import org.wordpress.aztec.spans.createHiddenHtmlBlockSpan
44+ import org.wordpress.aztec.spans.createHiddenHtmlSpan
45+ import org.wordpress.aztec.spans.createListItemSpan
46+ import org.wordpress.aztec.spans.createOrderedListSpan
4847import org.wordpress.aztec.spans.createParagraphSpan
48+ import org.wordpress.aztec.spans.createPreformatSpan
49+ import org.wordpress.aztec.spans.createUnorderedListSpan
4950import org.wordpress.aztec.util.getLast
5051import org.xml.sax.Attributes
5152import java.util.ArrayList
5253
53- class AztecTagHandler (val context : Context , val plugins : List <IAztecPlugin > = ArrayList ()) : Html.TagHandler {
54+ class AztecTagHandler (val context : Context , val plugins : List <IAztecPlugin > = ArrayList (), private val alignmentRendering : AlignmentRendering
55+ ) : Html.TagHandler {
5456 private val loadingDrawable: Drawable
5557
5658 // Simple LIFO stack to track the html tag nesting for easy reference when we need to handle the ending of a tag
@@ -72,31 +74,35 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
7274
7375 when (tag.toLowerCase()) {
7476 LIST_LI -> {
75- handleElement(output, opening, AztecListItemSpan (nestingLevel, AztecAttributes (attributes)))
77+ val span = createListItemSpan(nestingLevel, alignmentRendering, AztecAttributes (attributes))
78+ handleElement(output, opening, span)
7679 return true
7780 }
7881 STRIKETHROUGH_S , STRIKETHROUGH_STRIKE , STRIKETHROUGH_DEL -> {
7982 handleElement(output, opening, AztecStrikethroughSpan (tag, AztecAttributes (attributes)))
8083 return true
8184 }
8285 SPAN -> {
83- handleElement(output, opening, HiddenHtmlSpan (tag, AztecAttributes (attributes), nestingLevel))
86+ val span = createHiddenHtmlSpan(tag, AztecAttributes (attributes), nestingLevel, alignmentRendering)
87+ handleElement(output, opening, span)
8488 return true
8589 }
8690 DIV , FIGURE , FIGCAPTION , SECTION -> {
87- handleElement(output, opening, HiddenHtmlBlock (tag, AztecAttributes (attributes), nestingLevel))
91+ val hiddenHtmlBlockSpan = createHiddenHtmlBlockSpan(tag, alignmentRendering, nestingLevel, AztecAttributes (attributes))
92+ handleElement(output, opening, hiddenHtmlBlockSpan)
8893 return true
8994 }
9095 LIST_UL -> {
91- handleElement(output, opening, AztecUnorderedListSpan (nestingLevel, AztecAttributes (attributes)))
96+ handleElement(output, opening, createUnorderedListSpan (nestingLevel, alignmentRendering , AztecAttributes (attributes)))
9297 return true
9398 }
9499 LIST_OL -> {
95- handleElement(output, opening, AztecOrderedListSpan (nestingLevel, AztecAttributes (attributes)))
100+ handleElement(output, opening, createOrderedListSpan (nestingLevel, alignmentRendering , AztecAttributes (attributes)))
96101 return true
97102 }
98103 BLOCKQUOTE -> {
99- handleElement(output, opening, AztecQuoteSpan (nestingLevel, AztecAttributes (attributes)))
104+ val span = createAztecQuoteSpan(nestingLevel, AztecAttributes (attributes), alignmentRendering)
105+ handleElement(output, opening, span)
100106 return true
101107 }
102108 IMAGE -> {
@@ -118,7 +124,8 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
118124 return true
119125 }
120126 PARAGRAPH -> {
121- handleElement(output, opening, createParagraphSpan(nestingLevel, AztecAttributes (attributes)))
127+ val paragraphSpan = createParagraphSpan(nestingLevel, alignmentRendering, AztecAttributes (attributes))
128+ handleElement(output, opening, paragraphSpan)
122129 return true
123130 }
124131 LINE -> {
@@ -133,12 +140,13 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
133140 return true
134141 }
135142 PREFORMAT -> {
136- handleElement(output, opening, AztecPreformatSpan (nestingLevel, AztecAttributes (attributes)))
143+ val preformatSpan = createPreformatSpan(nestingLevel, alignmentRendering, AztecAttributes (attributes))
144+ handleElement(output, opening, preformatSpan)
137145 return true
138146 }
139147 else -> {
140148 if (tag.length == 2 && Character .toLowerCase(tag[0 ]) == ' h' && tag[1 ] >= ' 1' && tag[1 ] <= ' 6' ) {
141- handleElement(output, opening, AztecHeadingSpan (nestingLevel, tag, AztecAttributes (attributes)))
149+ handleElement(output, opening, createHeadingSpan (nestingLevel, tag, AztecAttributes (attributes), alignmentRendering ))
142150 return true
143151 }
144152 }
0 commit comments