How to use the prosemirror-test-builder.schema.nodes function in prosemirror-test-builder

To help you get started, we’ve selected a few prosemirror-test-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProseMirror / prosemirror-model / test / test-dom.js View on Github external
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")))))

    function parse(html, options, doc) {
      return () =&gt; {
        let dom = document.createElement("div")
        dom.innerHTML = html
        let result = parser.parse(dom, options)
        ist(result, doc, eq)
      }
    }

    it("accepts the topNode option",
       parse("<li>wow</li><li>such</li>", {topNode: schema.nodes.bullet_list.createAndFill()},
             ul(li(p("wow")), li(p("such")))))

    let item = schema.nodes.list_item.createAndFill()
    it("accepts the topMatch option",
       parse("<ul><li>x</li></ul>", {topNode: item, topMatch: item.contentMatchAt(1)},
             li(ul(li(p("x"))))))

    it("accepts from and to options",
       parse("<hr><p>foo</p><p>bar</p><img>", {from: 1, to: 3},
             doc(p("foo"), p("bar"))))

    it("accepts the preserveWhitespace option",
       parse("foo   bar", {preserveWhitespace: true},
             doc(p("foo   bar"))))

    function open(html, nodes, openStart, openEnd) {
github ProseMirror / prosemirror-model / test / test-content.js View on Github external
  let m = get(expr), ts = types ? types.split(" ").map(t =&gt; schema.nodes[t]) : []
  for (let i = 0; m &amp;&amp; i &lt; ts.length; i++) m = m.matchType(ts[i])
github ProseMirror / prosemirror-commands / test / test-commands.js View on Github external
it("joins lists when wrapping a paragraph after them in a list", () =&gt;
     apply(doc(ul(li(p("a"))), p("b<a>")),
           autoJoin(wrapIn(schema.nodes.bullet_list), ["bullet_list"]),
           doc(ul(li(p("a")), li(p("b"))))))
</a>
github ProseMirror / prosemirror-transform / test / test-trans.js View on Github external
it("will wrap a node with the suitable parent", () =&gt;
       ins(doc(p("foo<a>bar")),
           schema.nodes.list_item.createAndFill(),
           doc(p("foo"), ol(li(p())), p("bar"))))
  })</a>
github ProseMirror / prosemirror-model / test / test-dom.js View on Github external
doc(p(strong("xxbar")))))

    function parse(html, options, doc) {
      return () =&gt; {
        let dom = document.createElement("div")
        dom.innerHTML = html
        let result = parser.parse(dom, options)
        ist(result, doc, eq)
      }
    }

    it("accepts the topNode option",
       parse("<li>wow</li><li>such</li>", {topNode: schema.nodes.bullet_list.createAndFill()},
             ul(li(p("wow")), li(p("such")))))

    let item = schema.nodes.list_item.createAndFill()
    it("accepts the topMatch option",
       parse("<ul><li>x</li></ul>", {topNode: item, topMatch: item.contentMatchAt(1)},
             li(ul(li(p("x"))))))

    it("accepts from and to options",
       parse("<hr><p>foo</p><p>bar</p><img>", {from: 1, to: 3},
             doc(p("foo"), p("bar"))))

    it("accepts the preserveWhitespace option",
       parse("foo   bar", {preserveWhitespace: true},
             doc(p("foo   bar"))))

    function open(html, nodes, openStart, openEnd) {
      return () =&gt; {
        let dom = document.createElement("div")
        dom.innerHTML = html
github ProseMirror / prosemirror-commands / test / test-commands.js View on Github external
describe("wrapIn", () =&gt; {
  let wrap = wrapIn(schema.nodes.blockquote)

  it("can wrap a paragraph", () =&gt;
     apply(doc(p("fo<a>o")), wrap, doc(blockquote(p("foo")))))

  it("wraps multiple pragraphs", () =&gt;
     apply(doc(p("fo</a><a>o"), p("bar"), p("ba<b>z"), p("quux")), wrap,
           doc(blockquote(p("foo"), p("bar"), p("baz")), p("quux"))))

  it("wraps an already wrapped node", () =&gt;
     apply(doc(blockquote(p("fo</b></a><b><a>o"))), wrap,
           doc(blockquote(blockquote(p("foo"))))))

  it("can wrap a node selection", () =&gt;
     apply(doc("</a><a>", ul(li(p("foo")))), wrap,
           doc(blockquote(ul(li(p("foo")))))))
})</a></b>
github ProseMirror / prosemirror-transform / test / test-trans.js View on Github external
function type(doc, expect, nodeType, attrs) {
      testTransform(new Transform(doc).setBlockType(doc.tag.a, doc.tag.b || doc.tag.a, schema.nodes[nodeType], attrs),
                    expect)
    }
github ProseMirror / prosemirror-view / test / test-decoration.js View on Github external
                           tr => tr.replaceWith(0, 3, schema.nodes.horizontal_rule.create()))
      ist(str(set), "[]")
github ProseMirror / prosemirror-changeset / test / test-changes.js View on Github external
    tr => tr.wrap(tr.doc.resolve(1).blockRange(), [{type: schema.nodes.blockquote}])
  ], [[0, 0, 0, 1], [1, 1, 2, 4], [2, 2, 5, 6]]))