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


TypeScript DLocRange.mustMakeDOMRange方法代码示例

本文整理汇总了TypeScript中wed/dloc.DLocRange.mustMakeDOMRange方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DLocRange.mustMakeDOMRange方法的具体用法?TypeScript DLocRange.mustMakeDOMRange怎么用?TypeScript DLocRange.mustMakeDOMRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wed/dloc.DLocRange的用法示例。


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

示例1: beforeEach

  beforeEach(() => {
    dataRoot = editor.dataRoot;
    caretManager = editor.caretManager;

    ps = Array.from(dataRoot.querySelectorAll("body p"));
    firstBodyP = ps[0];
    firstBodyPLocation = caretManager.mustFromDataLocation(
      DLoc.mustMakeDLoc(dataRoot, firstBodyP, 0));
    caretManager.setCaret(firstBodyPLocation);

    // First 3 text characters in the 5th paragraph (at index 4).
    const pFiveStart = DLoc.mustMakeDLoc(dataRoot, ps[4].firstChild, 0);
    pFiveFirstThree = new DLocRange(
      caretManager.mustFromDataLocation(pFiveStart),
      caretManager.mustFromDataLocation(pFiveStart.makeWithOffset(3)));
    expect(pFiveFirstThree.mustMakeDOMRange().toString()).to.equal("abc");

    pFiveFirstFour = new DLocRange(
      caretManager.mustFromDataLocation(pFiveStart),
      caretManager.mustFromDataLocation(pFiveStart.makeWithOffset(4)));
    expect(pFiveFirstFour.mustMakeDOMRange().toString()).to.equal("abcd");

    const pSevenStart = DLoc.mustMakeDLoc(dataRoot, ps[6].firstChild, 0);
    pSevenFirstThree = new DLocRange(
      caretManager.mustFromDataLocation(pSevenStart),
      caretManager.mustFromDataLocation(pSevenStart.makeWithOffset(3)));
    expect(pSevenFirstThree.mustMakeDOMRange().toString()).to.equal("abc");

    // This is the first "abc" found when doing a TEXT search.
    firstABCText = new DLocRange(
      caretManager.mustFromDataLocation(ps[3].firstChild!.firstChild!, 0),
      caretManager.mustFromDataLocation(ps[3].lastChild!, 1));
  });
开发者ID:lddubeau,项目名称:wed,代码行数:33,代码来源:quick-search-test.ts

示例2: before

  before(() => {
    guiRoot = editor.guiRoot;
    dataRoot = editor.dataRoot;
    caretManager = editor.caretManager;
    docScope = editor.caretManager.docDLocRange;

    ps = Array.from(editor.dataRoot.querySelectorAll("body p"));
    firstBodyP = ps[0];
    firstBodyPLocation = caretManager.mustFromDataLocation(
      DLoc.mustMakeDLoc(dataRoot, firstBodyP, 0));

    // First 3 text characters in the 5th paragraph (at index 4).
    const pFiveStart = DLoc.mustMakeDLoc(dataRoot, ps[4].firstChild, 0);
    pFiveFirstThree = new DLocRange(
      caretManager.mustFromDataLocation(pFiveStart),
      caretManager.mustFromDataLocation(pFiveStart.makeWithOffset(3)));
    expect(pFiveFirstThree.mustMakeDOMRange().toString()).to.equal("abc");

    pFiveFirstFour = new DLocRange(
      caretManager.mustFromDataLocation(pFiveStart),
      caretManager.mustFromDataLocation(pFiveStart.makeWithOffset(4)));
    expect(pFiveFirstFour.mustMakeDOMRange().toString()).to.equal("abcd");

    const pSevenStart = DLoc.mustMakeDLoc(dataRoot, ps[6].firstChild, 0);
    pSevenFirstThree = new DLocRange(
      caretManager.mustFromDataLocation(pSevenStart),
      caretManager.mustFromDataLocation(pSevenStart.makeWithOffset(3)));
    expect(pSevenFirstThree.mustMakeDOMRange().toString()).to.equal("abc");

    // This is the first "abc" found when doing a TEXT search.
    firstABCText = new DLocRange(
      caretManager.mustFromDataLocation(ps[3].firstChild!.firstChild!, 0),
      caretManager.mustFromDataLocation(ps[3].lastChild!, 1));

    // This is the first "abcd" found when doing a TEXT search.
    firstABCDText = new DLocRange(
      caretManager.mustFromDataLocation(ps[3].firstChild!.firstChild!, 0),
      caretManager.mustFromDataLocation(ps[3].lastChild!, 2));

    const rend = ps[7].getAttributeNode("rend")!;
    firstABCAttribute = new DLocRange(
      caretManager.mustFromDataLocation(rend, 0),
      caretManager.mustFromDataLocation(rend, 3));

    firstABCDAttribute = new DLocRange(
      caretManager.mustFromDataLocation(rend, 0),
      caretManager.mustFromDataLocation(rend, 4));

    secondABCAttribute = new DLocRange(
      caretManager.mustFromDataLocation(rend, 4),
      caretManager.mustFromDataLocation(rend, 7));
  });
开发者ID:lddubeau,项目名称:wed,代码行数:52,代码来源:search-test.ts

示例3: checkHighlightRanges

  function checkHighlightRanges(range: DLocRange): void {
    const highlights = document.querySelectorAll("._wed_highlight");
    expect(highlights).to.have.property("length").greaterThan(0);
    let highlightRect = highlights[0].getBoundingClientRect();
    const rangeRect =
      range.mustMakeDOMRange().getBoundingClientRect();

    // The highlights are built as a series of rectangles. Checking each and
    // every rectangle would be onerous. We check the start and end of the
    // range.

    // Rounding can make the boundaries vary a bit.
    expect(highlightRect).to.have.nested.property("top")
      .closeTo(rangeRect.top, 3);
    expect(highlightRect).to.have.nested.property("left")
      .closeTo(rangeRect.left, 3);

    highlightRect = highlights[highlights.length - 1].getBoundingClientRect();
    expect(highlightRect).to.have.nested.property("bottom")
      .closeTo(rangeRect.bottom, 3);
    expect(highlightRect).to.have.nested.property("right")
      .closeTo(rangeRect.right, 3);
  }
开发者ID:lddubeau,项目名称:wed,代码行数:23,代码来源:quick-search-test.ts

示例4:

 assert.throws(() => range.mustMakeDOMRange(), Error,
开发者ID:lddubeau,项目名称:wed,代码行数:1,代码来源:dloc-test.ts


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