Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("recognizes typing inside markup", () => {
let view = tempEditor({doc: doc(p("a", em("b", img, strong("cd<a>")), "e"))})
findTextNode(view.dom, "cd").nodeValue = "cdxy"
flush(view)
ist(view.state.doc, doc(p("a", em("b", img, strong("cdxy")), "e")), eq)
})
</a>
it("draws widgets inside the marks for their side", () => {
let view = tempEditor({
doc: doc(p(em("foo"), strong("bar"))),
plugins: [decoPlugin([Decoration.widget(4, document.createElement("img"), {side: -1})]),
decoPlugin([Decoration.widget(4, document.createElement("br"))]),
decoPlugin([Decoration.widget(7, document.createElement("span"))], {side: 1})]
})
ist(view.dom.querySelector("em img"))
ist(!view.dom.querySelector("strong img"))
ist(view.dom.querySelector("strong br"))
ist(!view.dom.querySelector("em br"))
ist(!view.dom.querySelector("strong span"))
})
it("can update with a state using a different schema", () => {
let testSchema = new Schema({nodes: schema.spec.nodes})
let view = tempEditor({doc: doc(p(strong("foo")))})
view.updateState(EditorState.create({doc: testSchema.nodes.doc.createAndFill()}))
ist(!view.dom.querySelector("strong"))
})
it("resolves ambiguous text input", () => {
let view = tempEditor({doc: doc(p("fo<a>o"))})
view.dispatch(view.state.tr.addStoredMark(view.state.schema.marks.strong.create()))
findTextNode(view.dom, "foo").nodeValue = "fooo"
flush(view)
ist(view.state.doc, doc(p("fo", strong("o"), "o")), eq)
})
</a>
it("recognizes typing inside markup", () => {
let view = tempEditor({doc: doc(p("a", em("b", img, strong("cd<a>")), "e"))})
findTextNode(view.dom, "cd").nodeValue = "cdxy"
flush(view)
ist(view.state.doc, doc(p("a", em("b", img, strong("cdxy")), "e")), eq)
})
</a>
}
it("can represent simple node",
test(doc(p("hello")),
"<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"))),
it("can delete text in markup", () => {
let view = tempEditor({doc: doc(p("a", em("b", img, strong("cd<a>")), "e"))})
findTextNode(view.dom, "cd").nodeValue = "c"
flush(view)
ist(view.state.doc, doc(p("a", em("b", img, strong("c")), "e")), eq)
})
</a>
it("should only add a mark once", () =>
add(doc(p("hello ", strong("<a>there"), "!<b>")),
schema.mark("strong"),
doc(p("hello ", strong("there!")))))
</b></a>