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 the stored marks", () => {
let state = mkState(doc(p(em("foo<a>"))))
toggleMark(schema.marks.strong)(state, tr => state = state.apply(tr))
splitBlockKeepMarks(state, tr => state = state.apply(tr))
ist(state.storedMarks.length, 2)
})
})</a>
it("supports composition in a cursor wrapper", () => {
let pm = requireFocus(tempEditor({doc: doc(p("<a>"))}))
pm.dispatch(pm.state.tr.addStoredMark(schema.marks.em.create()))
compose(pm, () => edit(pm.dom.firstChild.appendChild(document.createTextNode("")), "a"), [
n => edit(n, "b"),
n => edit(n, "c")
], {node: true})
ist(pm.state.doc, doc(p(em("abc"))), eq)
})
</a>
it("handles composition in a multi-child mark with a cursor wrapper", () => {
let pm = requireFocus(tempEditor({doc: doc(p("one ", em("two<a>", strong(" three"))))}))
pm.dispatch(pm.state.tr.addStoredMark(schema.marks.code.create()))
let emNode = pm.dom.querySelector("em")
compose(pm, () => edit(emNode.insertBefore(document.createTextNode(""), emNode.querySelector("strong")), "o"), [
n => edit(n, "o"),
n => edit(n, "w")
], {node: true})
ist(pm.state.doc, doc(p("one ", em("two", code("oow"), strong(" three")))), eq)
})
</a>
it("works in a cursor wrapper", () => {
let view = tempEditor({doc: doc(p("foo<a>"))})
view.dispatch(view.state.tr.setStoredMarks([schema.marks.em.create()]))
ist(!view.endOfTextblock("backward"))
})
</a>
function mkStep(from, to, val) {
if (val == "+em")
return new AddMarkStep(from, to, schema.marks.em.create())
else if (val == "-em")
return new RemoveMarkStep(from, to, schema.marks.em.create())
else
return new ReplaceStep(from, to, val == null ? Slice.empty : new Slice(Fragment.from(schema.text(val)), 0, 0))
}