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


TypeScript editor.Editor類代碼示例

本文整理匯總了TypeScript中wed/editor.Editor的典型用法代碼示例。如果您正苦於以下問題:TypeScript Editor類的具體用法?TypeScript Editor怎麽用?TypeScript Editor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: it

  it("undoing an attribute value change undoes the value change", () => {
    let initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    caretManager.setCaret(initial, 4);
    assert.equal(initial.data, "rend_value", "initial value");
    editor.type("blah");

    // We have to refetch because the decorations have been redone.
    initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    assert.equal(initial.data, "rendblah_value");
    caretCheck(editor, initial, 8, "caret after text insertion");

    // Check that the data is also modified
    const dataNode = editor.toDataNode(initial) as Attr;
    assert.equal(dataNode.value, "rendblah_value");

    editor.undo();

    // We have to refetch because the decorations have been redone.
    initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    assert.equal(initial.data, "rend_value");
    caretCheck(editor, initial, 4, "caret after undo");

    // Check that the data change has been undone.
    assert.equal(dataNode.value, "rend_value", "value undone");
  });
開發者ID:lddubeau,項目名稱:wed,代碼行數:25,代碼來源:wed-undo-redo-test.ts

示例2: waitForSuccess

    it("changing label visibility level", async () => {
      // Changing label visibility does not merely refresh the errors but
      // recreates them because errors that were visible may become invisible or
      // errors that were invisible may become visible.

      await processRunner.onCompleted();
      // tslint:disable-next-line:no-any
      const errorLayer = (editor as any).errorLayer.el as Element;
      let orig = _slice.call(errorLayer.children);

      // Reduce the visibility level.
      editor.type(keyConstants.LOWER_LABEL_VISIBILITY);
      let after;
      await waitForSuccess(() => {
        after = _slice.call(errorLayer.children);
        assertNewMarkers(orig, after, "decreasing the level");
      });

      orig = after;

      // Increase visibility level
      editor.type(keyConstants.INCREASE_LABEL_VISIBILITY);
      await waitForSuccess(() => {
        assertNewMarkers(orig, _slice.call(errorLayer.children),
                         "increasing the level");
      });
    });
開發者ID:lddubeau,項目名稱:wed,代碼行數:27,代碼來源:wed-validation-error-test.ts

示例3: it

  it("doing an attribute deletion changes the data", () => {
    const p = ps[7];
    const dataP = editor.toDataNode(p) as Element;
    const attrNames = getAttributeNamesFor(p);
    let attrValues = getAttributeValuesFor(p);
    const initialLength = attrValues.length;
    assert.isTrue(initialLength > 0, "the paragraph should have attributes");
    const attr = editor.toDataNode(attrValues[0]) as Attr;
    const decodedName = attrNames[0].textContent!;
    const trs = editor.modeTree.getMode(attr).getContextualActions(
      ["delete-attribute"], decodedName, attr);

    caretManager.setCaret(attr, 0);
    caretCheck(editor, attrValues[0].firstChild!, 0,
               "the caret should be in the attribute");
    trs[0].execute({ node: attr, name: decodedName });
    attrValues = getAttributeValuesFor(p);
    assert.equal(attrValues.length, initialLength - 1,
                 "one attribute should be gone");
    caretCheck(editor, attrValues[0].firstChild!, 0,
               "the caret should be in the first attribute value");

    assert.isNull(attr.ownerElement,
                  "the old attribute should not have an onwer element");
    assert.isNull(dataP.getAttribute(attr.name));
  });
開發者ID:lddubeau,項目名稱:wed,代碼行數:26,代碼來源:wed-transformation-test.ts

示例4: it

 it("searches forward", () => {
   editor.type(QUICKSEARCH_FORWARD);
   editor.type("abc", WedEventTarget.MINIBUFFER);
   checkHighlightRanges(firstABCText);
   editor.type(QUICKSEARCH_FORWARD, WedEventTarget.MINIBUFFER);
   checkHighlightRanges(pFiveFirstThree);
   editor.type(ESCAPE, WedEventTarget.MINIBUFFER);
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:8,代碼來源:quick-search-test.ts

示例5: waitForSuccess

  it("modification status shows an unmodified document after save", () => {
    // Text node inside title.
    const initial = titles[0].childNodes[1];
    caretManager.setCaret(initial, 0);
    editor.type(" ");

    assert.isTrue($modificationStatus.hasClass("label-warning"));
    editor.type(keyConstants.SAVE);
    return waitForSuccess(() => {
      assert.isTrue($modificationStatus.hasClass("label-success"));
    });
  });
開發者ID:lddubeau,項目名稱:wed,代碼行數:12,代碼來源:wed-file-state-test.ts

示例6: it

 it("that takes completions", () => {
   const p = ps[9];
   const attrVals = getAttributeValuesFor(p);
   caretManager.setCaret(attrVals[0].firstChild, 0);
   contextMenuHasOption(editor, /^Y$/);
   editor.type("Y");
   // The context menu should be gone.
   const menu = editor.window.document.
     getElementsByClassName("wed-context-menu")[0];
   assert.isUndefined(menu, "the menu should not exist");
   editor.type(keyConstants.REPLACEMENT_MENU);
   contextMenuHasOption(editor, /^Y$/);
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:13,代碼來源:wed-menu-test.ts

示例7: getAttributeValuesFor

 "attribute is not visible", () => {
   // Reduce visibility to 0 so that no attribute is visible.
   editor.setLabelVisibilityLevel(0);
   const attrVals = getAttributeValuesFor(ps[9]);
   caretManager.setCaret(attrVals[0].firstChild, 0);
   let menu = editor.window.document.
     getElementsByClassName("wed-context-menu")[0];
   assert.isUndefined(menu, "the menu should not exist");
   // The menu won't come up with a the shortcut.
   editor.type(keyConstants.REPLACEMENT_MENU);
   menu = editor.window.document.
     getElementsByClassName("wed-context-menu")[0];
   assert.isUndefined(menu, "the menu should not exist");
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:14,代碼來源:wed-menu-test.ts

示例8: it

  it("typing multiple spaces in an attribute normalizes the space", () => {
    // Text node inside title.
    let initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    caretManager.setCaret(initial, 0);
    assert.equal(initial.data, "rend_value");

    editor.type(" ");

    // We have to refetch because the decorations have been redone.
    initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    assert.equal(initial.data, " rend_value");
    caretCheck(editor, initial, 1, "caret after text insertion");

    // Check that the data is also modified
    const dataNode = editor.toDataNode(initial) as Attr;
    assert.equal(dataNode.value, " rend_value");

    editor.type(" ");

    // We have to refetch because the decorations have been redone.
    initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    assert.equal(initial.data, " rend_value");
    caretCheck(editor, initial, 1, "caret after text insertion");

    // Check that the data is also modified
    assert.equal(dataNode.value, " rend_value");

    caretManager.setCaret(initial, 11);

    editor.type(" ");

    // We have to refetch because the decorations have been redone.
    initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    assert.equal(initial.data, " rend_value ");
    caretCheck(editor, initial, 12, "caret after text insertion");

    // Check that the data is also modified
    assert.equal(dataNode.value, " rend_value ");

    editor.type(" ");

    // We have to refetch because the decorations have been redone.
    initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
    assert.equal(initial.data, " rend_value ");
    caretCheck(editor, initial, 12, "caret after text insertion");

    // Check that the data is also modified
    assert.equal(dataNode.value, " rend_value ");
  });
開發者ID:lddubeau,項目名稱:wed,代碼行數:49,代碼來源:wed-typing-test.ts

示例9: it

 it("searches forward", () => {
   editor.type(SEARCH_FORWARD);
   typeInSearch("abc");
   checkHighlightRanges(firstABCText);
   clickFind();
   checkHighlightRanges(pFiveFirstThree);
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:7,代碼來源:dialog-search-replace-test.ts


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