當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DLoc.mustMakeDLoc方法代碼示例

本文整理匯總了TypeScript中wed/dloc.DLoc.mustMakeDLoc方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DLoc.mustMakeDLoc方法的具體用法?TypeScript DLoc.mustMakeDLoc怎麽用?TypeScript DLoc.mustMakeDLoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wed/dloc.DLoc的用法示例。


在下文中一共展示了DLoc.mustMakeDLoc方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: before

 before(() => {
   const quoteNode = root.querySelector(".quote")!;
   quote = DLoc.mustMakeDLoc(root, quoteNode);
   attr = DLoc.mustMakeDLoc(
     root,
     quoteNode.getAttributeNode(encodedType), 0);
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:7,代碼來源:dloc-test.ts

示例2: 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

示例3: it

 it("returns false when the two ranges differ in end positions", () => {
   const range = new DLocRange(loc, loc);
   const range2 = new DLocRange(DLoc.mustMakeDLoc(root, a, 0),
                                DLoc.mustMakeDLoc(root, a, 1));
   assert.isTrue(range.start.equals(range2.start));
   assert.isFalse(range.end.equals(range2.end));
   assert.isFalse(range.equals(range2));
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:8,代碼來源:dloc-test.ts

示例4: 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

示例5: it

 it("with DLoc", () => {
   const tree = genericTree.cloneNode(true) as Document;
   const dataRoot = new DLocRoot(tree);
   const p = new validator.Validator(grammar, tree, []);
   const body = tree.getElementsByTagName("body")[0];
   const container = body.parentNode!;
   const index = Array.prototype.indexOf.call(container.childNodes, body);
   const ret = p.speculativelyValidate(
     DLoc.mustMakeDLoc(dataRoot, container, index), body);
   assert.isFalse(ret);
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:11,代碼來源:validator-test.ts

示例6: it

 it("throws on an invalid range", () => {
   const search = makeSearch(caretManager.caret!);
   const invalid = DLoc.mustMakeDLoc(guiRoot, guiRoot,
                                     guiRoot.childNodes.length);
   // We cheat and make the value invalid manually. Otherwise, we'd have to
   // modify the gui tree....
   (invalid as any).offset++;
   expect(invalid.isValid()).to.be.false;
   expect(
     () =>
       (search as any).setScope(
         new DLocRange(caretManager.minCaret, invalid)))
     .to.throw(Error, "passed an invalid range");
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:14,代碼來源:search-test.ts


注:本文中的wed/dloc.DLoc.mustMakeDLoc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。