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

Update strikethrough to default to <s> tag #919

Merged
merged 3 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class FormattingHistoryTests : BaseHistoryTest() {
fun testMakeStrikethroughUndoRedo() {
val snippet1 = "There's no crying in"
val snippet2 = " baseball!"
val html = "$snippet1<del>$snippet2</del>"
val html = "$snippet1<s>$snippet2</s>"
val editorPage = EditorPage()

// Insert first snippet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SimpleTextFormattingTests : BaseTest() {
fun testSimpleStrikethroughFormatting() {
val text1 = "some"
val text2 = "text"
val html = "$text1<del>$text2</del>"
val html = "$text1<s>$text2</s>"

EditorPage()
.insertText(text1)
Expand Down Expand Up @@ -351,7 +351,7 @@ class SimpleTextFormattingTests : BaseTest() {
fun testInlineStyleAndSpace() {
val text1 = "some"
val text2 = "text "
val html = "$text1<del>$text2</del>"
val html = "$text1<s>$text2</s>"

EditorPage()
.insertText(text1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.wordpress.aztec.spans
import android.text.style.StrikethroughSpan
import org.wordpress.aztec.AztecAttributes

class AztecStrikethroughSpan(tag: String = "del",
class AztecStrikethroughSpan(tag: String = "s",
override var attributes: AztecAttributes = AztecAttributes())
: StrikethroughSpan(), IAztecInlineSpan {
override val TAG = tag
Expand Down
36 changes: 18 additions & 18 deletions aztec/src/test/kotlin/org/wordpress/aztec/AztecToolbarTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class AztecToolbarTest {
Assert.assertTrue(strikeThroughButton.isChecked)

editText.append("strike")
Assert.assertEquals("<del>strike</del>", editText.toHtml())
Assert.assertEquals("<s>strike</s>", editText.toHtml())

strikeThroughButton.performClick()
Assert.assertFalse(strikeThroughButton.isChecked)
Expand All @@ -196,7 +196,7 @@ class AztecToolbarTest {
editText.setSelection(0, editText.length())
strikeThroughButton.performClick()
Assert.assertTrue(strikeThroughButton.isChecked)
Assert.assertEquals("<del>strike</del>", editText.toHtml())
Assert.assertEquals("<s>strike</s>", editText.toHtml())

strikeThroughButton.performClick()
Assert.assertFalse(strikeThroughButton.isChecked)
Expand Down Expand Up @@ -275,14 +275,14 @@ class AztecToolbarTest {
editText.append("Str")
strikeThroughButton.performClick()
editText.append("ike")
Assert.assertEquals("<strong>Bo</strong>ld<em>Ita</em>lic<del>Str</del>ike", editText.toHtml())
Assert.assertEquals("<strong>Bo</strong>ld<em>Ita</em>lic<s>Str</s>ike", editText.toHtml())

// Underline
underlineButton.performClick()
editText.append("Under")
underlineButton.performClick()
editText.append("line")
Assert.assertEquals("<strong>Bo</strong>ld<em>Ita</em>lic<del>Str</del>ike<u>Under</u>line", editText.toHtml())
Assert.assertEquals("<strong>Bo</strong>ld<em>Ita</em>lic<s>Str</s>ike<u>Under</u>line", editText.toHtml())

// Clear text
editText.setText("")
Expand All @@ -306,14 +306,14 @@ class AztecToolbarTest {
strikeThroughButton.performClick()
editText.append("ike")
strikeThroughButton.performClick()
Assert.assertEquals("Bo<strong>ld</strong>Ita<em>lic</em>Str<del>ike</del>", editText.toHtml())
Assert.assertEquals("Bo<strong>ld</strong>Ita<em>lic</em>Str<s>ike</s>", editText.toHtml())

// Underline
editText.append("Under")
underlineButton.performClick()
editText.append("line")
underlineButton.performClick()
Assert.assertEquals("Bo<strong>ld</strong>Ita<em>lic</em>Str<del>ike</del>Under<u>line</u>", editText.toHtml())
Assert.assertEquals("Bo<strong>ld</strong>Ita<em>lic</em>Str<s>ike</s>Under<u>line</u>", editText.toHtml())
}

/**
Expand Down Expand Up @@ -352,7 +352,7 @@ class AztecToolbarTest {
editText.append("Str")
strikeThroughButton.performClick()
editText.append("ike")
Assert.assertEquals(" <strong>Bo</strong>ld <em>Ita</em>lic <del>Str</del>ike", editText.toHtml())
Assert.assertEquals(" <strong>Bo</strong>ld <em>Ita</em>lic <s>Str</s>ike", editText.toHtml())

// Space
editText.append(" ")
Expand All @@ -362,7 +362,7 @@ class AztecToolbarTest {
editText.append("Under")
underlineButton.performClick()
editText.append("line")
Assert.assertEquals(" <strong>Bo</strong>ld <em>Ita</em>lic <del>Str</del>ike <u>Under</u>line", editText.toHtml())
Assert.assertEquals(" <strong>Bo</strong>ld <em>Ita</em>lic <s>Str</s>ike <u>Under</u>line", editText.toHtml())
}

/**
Expand Down Expand Up @@ -407,14 +407,14 @@ class AztecToolbarTest {
strikeThroughButton.performClick()
Assert.assertTrue(strikeThroughButton.isChecked)

Assert.assertEquals("<strong>bold</strong> <strong><em>bolditalic</em></strong> <em>italic</em> <del>strike</del> underline normal", editText.toHtml())
Assert.assertEquals("<strong>bold</strong> <strong><em>bolditalic</em></strong> <em>italic</em> <s>strike</s> underline normal", editText.toHtml())

editText.setSelection(30, 39)

underlineButton.performClick()
Assert.assertTrue(underlineButton.isChecked)

Assert.assertEquals("<strong>bold</strong> <strong><em>bolditalic</em></strong> <em>italic</em> <del>strike</del> <u>underline</u> normal", editText.toHtml())
Assert.assertEquals("<strong>bold</strong> <strong><em>bolditalic</em></strong> <em>italic</em> <s>strike</s> <u>underline</u> normal", editText.toHtml())
}

/**
Expand Down Expand Up @@ -447,19 +447,19 @@ class AztecToolbarTest {
strikeThroughButton.performClick()
Assert.assertTrue(strikeThroughButton.isChecked)
editText.append("strike")
Assert.assertEquals("<strong>bold</strong><strong><em>bolditalic</em></strong><em>italic</em><del>strike</del>", editText.toHtml())
Assert.assertEquals("<strong>bold</strong><strong><em>bolditalic</em></strong><em>italic</em><s>strike</s>", editText.toHtml())
strikeThroughButton.performClick()
Assert.assertFalse(strikeThroughButton.isChecked)

underlineButton.performClick()
Assert.assertTrue(underlineButton.isChecked)
editText.append("underline")
Assert.assertEquals("<strong>bold</strong><strong><em>bolditalic</em></strong><em>italic</em><del>strike</del><u>underline</u>", editText.toHtml())
Assert.assertEquals("<strong>bold</strong><strong><em>bolditalic</em></strong><em>italic</em><s>strike</s><u>underline</u>", editText.toHtml())
underlineButton.performClick()
Assert.assertFalse(underlineButton.isChecked)

editText.append("normal")
Assert.assertEquals("<strong>bold</strong><strong><em>bolditalic</em></strong><em>italic</em><del>strike</del><u>underline</u>normal", editText.toHtml())
Assert.assertEquals("<strong>bold</strong><strong><em>bolditalic</em></strong><em>italic</em><s>strike</s><u>underline</u>normal", editText.toHtml())
}

/**
Expand All @@ -470,7 +470,7 @@ class AztecToolbarTest {
@Test
@Throws(Exception::class)
fun testSelection() {
editText.fromHtml("<b>bold</b><b><i>bolditalic</i></b><i>italic</i><del>strike</del><u>underline</u>normal")
editText.fromHtml("<b>bold</b><b><i>bolditalic</i></b><i>italic</i><s>strike</s><u>underline</u>normal")

// cursor is at bold text
editText.setSelection(2)
Expand Down Expand Up @@ -554,15 +554,15 @@ class AztecToolbarTest {

/**
* Select part of text with one common style applied to it (bold) and another style (strikethrough)
* applied to part of it ("ds" from <b>bold</b><b><del>strike</del></b>) and extend partially
* applied to part of it ("ds" from <b>bold</b><b><s>strike</s></b>) and extend partially
* applied style (strikethrough) to other part of selection.
*
* @throws Exception
*/
@Test
@Throws(Exception::class)
fun extendStyleStrikethroughPartialSelection() {
editText.fromHtml("<b>bold</b><b><del>strike</del></b>")
editText.fromHtml("<b>bold</b><b><s>strike</s></b>")

val selectedText = editText.text.substring(3, 5)
Assert.assertEquals("ds", selectedText) // sanity check
Expand All @@ -572,7 +572,7 @@ class AztecToolbarTest {
Assert.assertFalse(strikeThroughButton.isChecked)

strikeThroughButton.performClick()
Assert.assertEquals("<b>bol</b><b><del>dstrike</del></b>", editText.toHtml())
Assert.assertEquals("<b>bol</b><b><s>dstrike</s></b>", editText.toHtml())
}

/**
Expand Down Expand Up @@ -685,7 +685,7 @@ class AztecToolbarTest {
editText.setSelection(9, 15)
strikeThroughButton.performClick()

Assert.assertEquals("<div class=\"third\"><strong>Div</strong><br><span><em>Span</em></span><br><del>Hidden</del></div>",
Assert.assertEquals("<div class=\"third\"><strong>Div</strong><br><span><em>Span</em></span><br><s>Hidden</s></div>",
editText.toHtml())
}

Expand Down
4 changes: 2 additions & 2 deletions aztec/src/test/kotlin/org/wordpress/aztec/LinkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class LinkTest {
@Test
@Throws(Exception::class)
fun insertLinkIntoStyledText() {
editText.fromHtml("<del><b>left</b><i>right</i></del>")
editText.fromHtml("<s><b>left</b><i>right</i></s>")
editText.setSelection(4)
editText.link("http://wordpress.com", "WordPress")
// Still valid, but order of b and del is switched here for some reason.
Assert.assertEquals("<b><del>left</del></b><b><del><a href=\"http://wordpress.com\">WordPress</a></del></b><del><i>right</i></del>", editText.toHtml())
Assert.assertEquals("<b><s>left</s></b><b><s><a href=\"http://wordpress.com\">WordPress</a></s></b><s><i>right</i></s>", editText.toHtml())
}

@Test
Expand Down