Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("does not violate schema constraints", () =>
apply(doc(ul(li(p("<a>foo"), blockquote(p("bar"))))), liftEmptyBlock, null))
</a>
it("can cut across different depths", () =>
t(doc(ul(li(p("hello")), li(p("wo<a>rld")), li(p("x"))), p(em("bo<b>o"))),
doc(ul(li(p("rld")), li(p("x"))), p(em("bo"))), 3, 1))
</b></a>
it("doesn't join lists when deleting an item inside of them", () =>
apply(doc(ul(li(p("a")), "<a>", li(p("b"))), ul(li(p("c")))),
autoJoin(deleteSelection, ["bullet_list"]),
doc(ul(li(p("a"))), ul(li(p("c"))))))
</a>
it("puts the cursor after the inserted text when inserting a list item", () => {
let state = new TestState({doc: doc(p("<a>abc"))})
let source = doc(ul(li(p("</a><a>def<b>"))))
state.apply(state.tr.replaceSelection(source.slice(source.tag.a, source.tag.b, true)))
ist(state.selection.from, 6)
})
})</b></a>
it("ignores meaningless whitespace",
recover(" <blockquote> <p>woo \n <em> hooo</em></p> </blockquote> ",
doc(blockquote(p("woo ", em("hooo"))))))
it("removes whitespace after a hard break",
recover("<p>hello<br>\n world</p>",
doc(p("hello", br, "world"))))
it("converts br nodes to newlines when they would otherwise be ignored",
recover("<pre>foo<br>bar</pre>",
doc(pre("foo\nbar"))))
it("finds a valid place for invalid content",
recover("<ul><li>hi</li><p>whoah</p><li>again</li></ul>",
doc(ul(li(p("hi")), li(p("whoah")), li(p("again"))))))
it("moves nodes up when they don't fit the current context",
recover("<div>hello<hr>bye</div>",
doc(p("hello"), hr, p("bye"))))
it("doesn't ignore whitespace-only text nodes",
recover("<p><em>one</em> <strong>two</strong></p>",
doc(p(em("one"), " ", strong("two")))))
it("can handle stray tab characters",
recover("<p> <b> </b></p>",
doc(p())))
it("normalizes random spaces",
recover("<p><b>1 </b> </p>",
doc(p(strong("1")))))
it("will close open nodes to the right", () =>
repl(doc(p("x"), "<a>"),
doc("</a><a>", ul(li(p("a")), li("<b>", p("b")))),
doc(p("x"), ul(li(p("a")), li(p())), "</b></a><b><a>")))
</a></b>
it("acts on multiple blocks when possible", () =>
apply(doc(p("a<a>bc"), p("def"), ul(li(p("ghi"), p("jk<b>l")))), setCode,
doc(pre("a</b></a><b><a>bc"), pre("def"), ul(li(p("ghi"), pre("jk<b>l"))))))
</b></a></b>
it("will sanely clean up top-level nodes in HTML", () => {
let view = tempEditor(), $p = view.state.doc.resolve(1)
ist(parseFromClipboard(view, "", "<ul><li>foo</li></ul>bar<br>", false, $p),
new Slice(doc(ul(li(p("foo"))), p("bar", br)).content, 3, 1), eq)
ist(parseFromClipboard(view, "", "<ul><li>foo</li></ul>bar<br><p>x</p>", false, $p),
new Slice(doc(ul(li(p("foo"))), p("bar", br), p("x")).content, 3, 1), eq)
ist(parseFromClipboard(view, "", "<li>foo</li><li>bar</li><p>x</p>", false, $p),
new Slice(doc(ol(li(p("foo")), li(p("bar"))), p("x")).content, 3, 1), eq)
})
it("allows deleting a selected block", () => {
let state = new TestState({doc: doc(p("foo"), ul(li(p("bar")), li(p("baz")), li(p("quux")))), schema})
state.nodeSel(0)
state.deleteSelection()
ist(state.doc, doc(ul(li(p("bar")), li(p("baz")), li(p("quux")))), eq)
ist(state.selection.head, 3)
state.nodeSel(2)
state.deleteSelection()
ist(state.doc, doc(ul(li(p("baz")), li(p("quux")))), eq)
ist(state.selection.head, 3)
state.nodeSel(9)
state.deleteSelection()
ist(state.doc, doc(ul(li(p("baz")))), eq)
ist(state.selection.head, 6)
state.nodeSel(0)
state.deleteSelection()
ist(state.doc, doc(p()), eq)
})