当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript domutil.indexOf函数代码示例

本文整理汇总了TypeScript中wed/domutil.indexOf函数的典型用法代码示例。如果您正苦于以下问题:TypeScript indexOf函数的具体用法?TypeScript indexOf怎么用?TypeScript indexOf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了indexOf函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getElementNameFor

 () => {
   const elName = getElementNameFor(ps[7]);
   const before = caretManager.makeCaret(elName, 0);
   const after = caretManager.newPosition(before, "left")!;
   const parent = ps[7].parentNode!;
   assert.equal(after.node, parent);
   assert.equal(after.offset, indexOf(parent.childNodes, ps[7]));
 });
开发者ID:lddubeau,项目名称:wed,代码行数:8,代码来源:wed-caret-test.ts

示例2: it

    it("moves out of a start label", () => {
      const p = ps[7];
      const initial = getElementNameFor(p)!;
      caretManager.setCaret(initial, 0);
      caretCheck(editor, initial, 0, "initial");

      const parent = p.parentNode!;
      caretManager.move("left");
      caretCheck(editor, parent, indexOf(parent.childNodes, p), "moved once");
    });
开发者ID:lddubeau,项目名称:wed,代码行数:10,代码来源:wed-caret-test.ts

示例3: it

    it("removes nodes and merges text", () => {
      const start = [p.firstChild!, 4] as domutil.Caret;
      const end = [p.lastChild!, 3] as domutil.Caret;
      assert.equal(p.childNodes.length, 5);

      const nodes = Array.prototype.slice.call(
        p.childNodes,
        domutil.indexOf(p.childNodes, start[0].nextSibling!),
        domutil.indexOf(p.childNodes, end[0].previousSibling!) + 1);
      nodes.unshift(p.ownerDocument.createTextNode("re "));
      nodes.push(p.ownerDocument.createTextNode(" af"));

      const [final, cutContent] = cut(start, end);

      // Check that we're doing what we think we're doing.
      assert.equal(p.childNodes.length, 1);
      assert.equal(p.innerHTML, "befoter");

      // Check the caret position.
      assert.deepEqual(final, [p.firstChild, 4]);

      // Check that the nodes are those we expected.
      checkNodes(cutContent, nodes);
    });
开发者ID:lddubeau,项目名称:wed,代码行数:24,代码来源:domutil-test.ts

示例4: it

  it("typing text when caret is adjacent to text (before text)", () => {
    // Text node inside title.
    const initial = editor.dataRoot.querySelectorAll("body>p")[3];
    const his = initial.getElementsByTagName("hi");
    const hi = his[his.length - 1];

    // We put the caret just after the last <hi>, which means it is just before
    // the last text node.
    caretManager.setCaret(initial, indexOf(initial.childNodes, hi) + 1);

    const initialLength = initial.childNodes.length;

    editor.type(" ");
    assert.equal(initial.lastChild!.textContent, " c");
    assert.equal(initial.childNodes.length, initialLength);
  });
开发者ID:lddubeau,项目名称:wed,代码行数:16,代码来源:wed-typing-test.ts

示例5: assertIsTextPhantom

       () => {
         const initial = editor.guiRoot.getElementsByClassName("ref")[0];
         // Check that what we are expecting to be around the caret is correct.
         const offset = 2;
         const caretNode = initial.childNodes[offset];
         assertIsTextPhantom(caretNode);
         assertIsTextPhantom(caretNode.previousSibling);

         caretManager.setCaret(initial, offset);
         caretCheck(editor, initial, offset, "initial");

         caretManager.move("left");

         caretCheck(editor, initial.parentNode!,
                    indexOf(initial.parentNode!.childNodes, initial),
                    "moved once");
       });
开发者ID:lddubeau,项目名称:wed,代码行数:17,代码来源:wed-caret-test.ts


注:本文中的wed/domutil.indexOf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。