Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("can serialize marks", () => roundTrip(doc(p("foo", em("bar", strong("baz")), " ", a("x")))))
it("notices text added to a cursor wrapper at the start of a mark", () => {
let view = tempEditor({doc: doc(p(strong(a("foo<a>"), "bar")))})
findTextNode(view.dom, "foo").nodeValue = "fooxy"
flush(view)
ist(view.state.doc, doc(p(strong(a("foo"), "xybar"))), eq)
})
</a>
"<p>hello</p>"))
it("can represent a line break",
test(doc(p("hi", br, "there")),
"<p>hi<br>there</p>"))
it("can represent an image",
test(doc(p("hi", img({alt: "x"}), "there")),
'<p>hi<img alt="x" src="img.png">there</p>'))
it("joins styles",
test(doc(p("one", strong("two", em("three")), em("four"), "five")),
"<p>one<strong>two</strong><em><strong>three</strong>four</em>five</p>"))
it("can represent links",
test(doc(p("a ", a({href: "foo"}, "big ", a({href: "bar"}, "nested"), " link"))),
"<p>a <a href="\"foo\"">big </a><a href="\"bar\"">nested</a><a href="\"foo\""> link</a></p>"))
it("can represent and unordered list",
test(doc(ul(li(p("one")), li(p("two")), li(p("three", strong("!")))), p("after")),
"<ul><li><p>one</p></li><li><p>two</p></li><li><p>three<strong>!</strong></p></li></ul><p>after</p>"))
it("can represent an ordered list",
test(doc(ol(li(p("one")), li(p("two")), li(p("three", strong("!")))), p("after")),
"<ol><li><p>one</p></li><li><p>two</p></li><li><p>three<strong>!</strong></p></li></ol><p>after</p>"))
it("can represent a blockquote",
test(doc(blockquote(p("hello"), p("bye"))),
"<blockquote><p>hello</p><p>bye</p></blockquote>"))
it("can represent a nested blockquote",
test(doc(blockquote(blockquote(blockquote(p("he said"))), p("i said"))),
it("removes cursor wrapper text when the wrapper otherwise remains valid", () => {
let view = tempEditor({doc: doc(p(a(strong("foo<a>"), "bar")))})
findTextNode(view.dom, "foo").nodeValue = "fooq"
flush(view)
ist(view.state.doc, doc(p(a(strong("fooq"), "bar"))), eq)
ist(!findTextNode(view.dom, "\ufeffq"))
})
</a>
it("preserves styles after cut", () =>
t(doc(p("a sentence with an ", em("emphasized ", a("li<a>nk")), " in it")),
doc(p(em(a("nk")), " in it")), 1, 0))
</a>
it("doesn't preserve non-inclusive marks of a deleted selection", () => {
let state = new TestState({doc: doc(p("foo", a(em("<a>bar<b>")), "baz"))})
state.deleteSelection()
ist(state.state.storedMarks.length, 1)
})
</b></a>
it("works for virtual motion when in a mark", () => {
let view = tempEditor({doc: doc(p(a("fo<a>o "), new Array(50).join("foo "), a("fo<b>o "),
new Array(50).join("foo "), a("foo")))})
ist(view.endOfTextblock("up"))
ist(!view.endOfTextblock("down"))
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, view.state.doc.tag.b)))
ist(!view.endOfTextblock("up"))
ist(!view.endOfTextblock("down"))
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, view.state.doc.tag.c)))
ist(!view.endOfTextblock("up"))
ist(view.endOfTextblock("down"))
})
</b></a>
it("works for virtual motion when in a mark", () => {
let view = tempEditor({doc: doc(p(a("fo<a>o "), new Array(50).join("foo "), a("fo<b>o "),
new Array(50).join("foo "), a("foo")))})
ist(view.endOfTextblock("up"))
ist(!view.endOfTextblock("down"))
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, view.state.doc.tag.b)))
ist(!view.endOfTextblock("up"))
ist(!view.endOfTextblock("down"))
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, view.state.doc.tag.c)))
ist(!view.endOfTextblock("up"))
ist(view.endOfTextblock("down"))
})
</b></a>
it("should overwrite marks with different attributes", () =>
add(doc(p("this is a ", a("<a>link<b>"))),
schema.mark("link", {href: "bar"}),
doc(p("this is a ", a({href: "bar"}, "link")))))
</b></a>