{assert, test, testGroup} = Trix.TestHelpers testGroup "HTML loading", -> testGroup "inline elements", template: "editor_with_styled_content", -> cases = "BR before block element styled otherwise": html: """a
""" expectedDocument: "a\n#{Trix.OBJECT_REPLACEMENT_CHARACTER}\n" "BR in text before block element styled otherwise": html: """
a
b
""" expectedDocument: "a\nb#{Trix.OBJECT_REPLACEMENT_CHARACTER}\n" for name, details of cases do (name, details) -> test name, (expectDocument) -> getEditor().loadHTML(details.html) expectDocument(details.expectedDocument) testGroup "bold elements", template: "editor_with_bold_styles", -> test " with font-weight: 500", (expectDocument) -> getEditor().loadHTML("a") assert.textAttributes([0, 1], bold: true) expectDocument("a\n") test " with font-weight: 600", (expectDocument) -> getEditor().loadHTML("a") assert.textAttributes([0, 1], bold: true) expectDocument("a\n") test "
with font-weight: bold", (expectDocument) -> getEditor().loadHTML("
a
") assert.textAttributes([0, 1], bold: true) expectDocument("a\n") testGroup "styled block elements", template: "editor_with_block_styles", -> test " in
with font-style: italic", (expectDocument) -> getEditor().loadHTML("
ab
") assert.textAttributes([0, 1], {}) assert.textAttributes([1, 2], italic: true) assert.blockAttributes([0, 2], ["quote"]) expectDocument("ab\n") test " in
  • with font-weight: bold", (expectDocument) -> getEditor().loadHTML("
    • ab
    ") assert.textAttributes([0, 1], {}) assert.textAttributes([1, 2], bold: true) assert.blockAttributes([0, 2], ["bulletList","bullet"]) expectDocument("ab\n") test "newline in
  • with font-weight: bold", (expectDocument) -> getEditor().loadHTML("
    • a
      b
    ") assert.textAttributes([0, 2], {}) assert.blockAttributes([0, 2], ["bulletList","bullet"]) expectDocument("a\nb\n") testGroup "in a table", template: "editor_in_table", -> test "block elements", (expectDocument) -> getEditor().loadHTML("

    a

    b
    ") assert.blockAttributes([0, 2], ["heading1"]) assert.blockAttributes([2, 4], ["quote"]) expectDocument("a\nb\n")