Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("ignores !<p></p>",
doc(p("hello!"))))
it("can handle a head/body input structure",
recover("<title>T</title>hi",
doc(p("hi"))))
it("only applies a mark once",
recover("<p>A <strong>big <strong>strong</strong> monster</strong>.</p>",
doc(p("A ", strong("big strong monster"), "."))))
it("interprets font-style: italic as em",
recover("<p><span style="font-style: italic">Hello</span>!</p>",
doc(p(em("Hello"), "!"))))
it("interprets font-weight: bold as strong",
recover("<p style="font-weight: bold">Hello</p>",
doc(p(strong("Hello")))))
it("ignores unknown inline tags",
recover("<p><u>a</u>bc</p>",
doc(p("abc"))))
it("can add marks specified before their parent node is opened",
recover("<em>hi</em> you",
doc(p(em("hi"), " you"))))
it("keeps applying a mark for the all of the node's content",
recover("<p><strong><span>xx</span>bar</strong></p>",
doc(p(strong("xxbar")))))
it("can remove across blocks", () =>
rem(doc(blockquote(p(em("much <a>em")), p(em("here too"))), p("between", em("...")), p(em("end<b>"))),
schema.mark("em"),
doc(blockquote(p(em("much "), "em"), p("here too")), p("between..."), p("end"))))
</b></a>
it("ignores marks in diffing", () =>
test(doc(p("abcdefghi")), doc(p(em("x"), strong("bc"), "defgh", em("y"))),
[1, 2, 1, 2], [9, 10, 9, 10]))
it("preserves marks when typing over marked text", () => {
let state = new TestState({doc: doc(p("foo ", em("<a>bar<b>"), " baz"))})
state.apply(state.tr.insertText("quux"))
ist(state.doc, doc(p("foo ", em("quux"), " baz")), eq)
state.apply(state.tr.insertText("bar", 5, 9))
ist(state.doc, doc(p("foo ", em("bar"), " baz")), eq)
})
</b></a>
it("will open all the way to the inner nodes",
open("<ul><li>foo</li><li>bar<br></li></ul>", [ul(li(p("foo")), li(p("bar", br)))], 3, 3))
it("accepts content open to the left",
open("<li><ul><li>a</li></ul></li>", [li(ul(li(p("a"))))], 4, 4))
it("accepts content open to the right",
open("<li>foo</li><li></li>", [li(p("foo")), li()], 2, 1))
it("will create textblocks for block nodes",
open("<div><div>foo</div><div>bar</div></div>", [p("foo"), p("bar")], 1, 1))
it("can parse marks at the start of defaulted textblocks",
open("<div>foo</div><div><em>bar</em></div>",
[p("foo"), p(em("bar"))], 1, 1))
function find(html, doc) {
return () => {
let dom = document.createElement("div")
dom.innerHTML = html
let tag = dom.querySelector("var"), prev = tag.previousSibling, next = tag.nextSibling, pos
if (prev && next && prev.nodeType == 3 && next.nodeType == 3) {
pos = {node: prev, offset: prev.nodeValue.length}
prev.nodeValue += next.nodeValue
next.parentNode.removeChild(next)
} else {
pos = {node: tag.parentNode, offset: Array.prototype.indexOf.call(tag.parentNode.childNodes, tag)}
}
tag.parentNode.removeChild(tag)
let result = parser.parse(dom, {
findPositions: [pos]
it("considers a mark active after the mark", () =>
isAt(doc(p(em("hi"), "<a> there")), em_, true))
</a>
it("considers a mark inactive before the mark", () =>
isAt(doc(p("one <a>", em("two"))), em_, false))
</a>
it("only clears markup when needed", () =>
type(doc(p("hello<a> ", em("world"))),
doc(h1("hello</a><a> ", em("world"))),
"heading", {level: 1}))
</a>