Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("preserves styles started after cut", () =>
t(doc(p("a ", em("sentence"), " wi<a>th ", em("text"), " in it")),
doc(p("th ", em("text"), " in it")), 1, 0))
</a>
it("draws multiple widgets", () => {
let view = tempEditor({doc: doc(p("foobar")),
plugins: [decoPlugin(["1-widget", "4-widget", "7-widget"])]})
let found = view.dom.querySelectorAll("button")
ist(found.length, 3)
ist(found[0].nextSibling.textContent, "foo")
ist(found[1].nextSibling.textContent, "bar")
ist(found[2].previousSibling.textContent, "bar")
})
it("can go back and forth between screen coords and document positions", () => {
let view = tempEditor({doc: doc(p("one"), blockquote(p("two"), p("three")))})
;[1, 2, 4, 7, 14, 15].forEach(pos => {
let coords = view.coordsAtPos(pos)
let found = view.posAtCoords({top: coords.top + 1, left: coords.left}).pos
ist(found, pos)
})
})
it("deletes a leaf node after the current block", () =>
apply(doc(p("foo<a>"), hr, p("bar")), joinForward, doc(p("foo"), p("bar"))))
</a>
it("can change a wrapped block", () =>
type(doc(blockquote(p("one<a>"), p("two<b>"))),
doc(blockquote(h1("one</b></a><b><a>"), h1("two<b>"))),
"heading", {level: 1}))
</b></a></b>
it("moves a block into an adjacent wrapper", () =>
apply(doc(blockquote(p("hi")), p("<a>there")), joinBackward,
doc(blockquote(p("hi"), p("there")))))
</a>
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("can parse an empty code block",
recover("<pre></pre>",
doc(pre())))
it("preserves trailing space in a code block",
recover("<pre>foo\n</pre>",
doc(pre("foo\n"))))
it("normalizes newlines when preserving whitespace",
recover("<p>foo bar\nbaz</p>",
doc(p("foo bar baz")), {preserveWhitespace: true}))
it("doesn't treat a placeholder BR as real content", () => {
let view = tempEditor({doc: doc(p("i<a>"))})
view.dom.querySelector("p").innerHTML = "<br>"
flush(view)
ist(view.state.doc, doc(p()), eq)
})
</a>
it("notices when the second doc is shorter", () =>
end(doc(p("oops"), "<a>", p("a", em("b")), p("hello"), blockquote(h1("bye"))),
doc(p("a", em("b")), p("hello"), blockquote(h1("bye")))))
</a>
it("works inside highlighted text", () => {
let pm = requireFocus(tempEditor({doc: doc(p("one two")), plugins: [wordHighlighter]}))
compose(pm, () => edit(findTextNode(pm.dom, "one"), "x"), [
n => edit(n, "y"),
n => edit(n, ".")
])
ist(pm.state.doc, doc(p("onexy. two")), eq)
})