Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("wraps an array", () =>
from([schema.node("hard_break"), schema.text("foo")], p(br, "foo")))
it("can replace a block selection", () => {
let state = new TestState({doc: doc(p("abc"), hr, hr, blockquote(p("ow"))), schema})
state.nodeSel(5)
state.apply(state.tr.replaceSelectionWith(schema.node("code_block")))
ist(state.doc, doc(p("abc"), pre(), hr, blockquote(p("ow"))), eq)
ist(state.selection.from, 7)
state.nodeSel(8)
state.apply(state.tr.replaceSelectionWith(schema.node("paragraph")))
ist(state.doc, doc(p("abc"), pre(), hr, p()), eq)
ist(state.selection.from, 9)
})
it("moves after an inserted leaf node", () => {
let state = new TestState({doc: doc(p("foobar")), schema})
state.textSel(4)
state.apply(state.tr.replaceSelectionWith(schema.node("horizontal_rule")))
ist(state.doc, doc(p("foo"), hr, p("bar")), eq)
ist(state.selection.head, 7)
state.textSel(10)
state.apply(state.tr.replaceSelectionWith(schema.node("horizontal_rule")))
ist(state.doc, doc(p("foo"), hr, p("bar"), hr), eq)
ist(state.selection.from, 11)
})
it("can insert two block nodes", () =>
ins(doc(p("one"), "<a>", p("two<2>")),
[schema.node("paragraph", null, [schema.text("hi")]),
schema.node("horizontal_rule")],
doc(p("one"), p("hi"), hr, "</a><a>", p("two<2>"))))
</a>
it("can insert two block nodes", () =>
ins(doc(p("one"), "<a>", p("two<2>")),
[schema.node("paragraph", null, [schema.text("hi")]),
schema.node("horizontal_rule")],
doc(p("one"), p("hi"), hr, "</a><a>", p("two<2>"))))
</a>
it("wraps a single node", () =>
from(schema.node("paragraph"), doc(p())))
it("can insert a break", () =>
ins(doc(p("hello<a>there")),
schema.node("hard_break"),
doc(p("hello", br, "</a><a>there"))))
</a>
it("can replace a block selection", () => {
let state = new TestState({doc: doc(p("abc"), hr, hr, blockquote(p("ow"))), schema})
state.nodeSel(5)
state.apply(state.tr.replaceSelectionWith(schema.node("code_block")))
ist(state.doc, doc(p("abc"), pre(), hr, blockquote(p("ow"))), eq)
ist(state.selection.from, 7)
state.nodeSel(8)
state.apply(state.tr.replaceSelectionWith(schema.node("paragraph")))
ist(state.doc, doc(p("abc"), pre(), hr, p()), eq)
ist(state.selection.from, 9)
})
it("doesn't doubly map decorations nested in multiple nodes", () => {
let d = doc(h1("u"), blockquote(p()))
let set = build(d, {pos: 5})
let tr = new Transform(d).replaceWith(0, 3, schema.node("heading", {level: 1}))
ist(set.map(tr.mapping, tr.doc).find().map(d => d.from).join(), "4")
})
it("can insert at the end of a blockquote", () =>
ins(doc(blockquote(p("hey"), "<a>"), p("after")),
schema.node("paragraph"),
doc(blockquote(p("hey"), p()), p("after"))))
</a>