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


TypeScript Editor.undo方法代码示例

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


在下文中一共展示了Editor.undo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: it

  it("does not try to act on undo/redo changes", () => {
    makeSplitMergeInputTrigger(
      editor, mode, pSelector, key.makeKey(";"), BACKSPACE, DELETE);
    let ps = editor.dataRoot.querySelectorAll("body p");
    assert.equal(ps.length, 1);
    editor.caretManager.setCaret(ps[0], 0);
    // Synthetic event
    const event = makeFakePasteEvent({
      types: ["text/plain"],
      getData: () => "ab;cd;ef",
    });
    editor.$guiRoot.trigger(event);

    ps = editor.dataRoot.querySelectorAll("body p");
    assert.equal(ps.length, 3);
    assert.equal(cleanNamespace(ps[0].outerHTML), "<p>ab</p>");
    assert.equal(cleanNamespace(ps[1].outerHTML), "<p>cd</p>");
    assert.equal(cleanNamespace(ps[2].outerHTML),
                 "<p>efBlah blah <term>blah</term><term>blah2</term> blah.</p>",
                 "first split: 3rd part");

    editor.undo();
    ps = editor.dataRoot.querySelectorAll("body p");
    assert.equal(ps.length, 1);
    assert.equal(cleanNamespace(ps[0].outerHTML),
                 "<p>Blah blah <term>blah</term><term>blah2</term> blah.</p>",
                 "after undo");

    editor.redo();
    ps = editor.dataRoot.querySelectorAll("body p");
    assert.equal(ps.length, 3, "after redo: length");
    assert.equal(cleanNamespace(ps[0].outerHTML), "<p>ab</p>",
                 "after redo: 1st part");
    assert.equal(cleanNamespace(ps[1].outerHTML), "<p>cd</p>",
                 "after redo: 2nd part");
    assert.equal(cleanNamespace(ps[2].outerHTML),
                 "<p>efBlah blah <term>blah</term><term>blah2</term> blah.</p>",
                 "after redo: 3rd part");
  });
开发者ID:lddubeau,项目名称:wed,代码行数:39,代码来源:input-trigger-test.ts

示例3: mit

    mit("merges on DELETE, and can undo", () => {
      inputTriggerFactory.makeSplitMergeInputTrigger(
        editor, mode, pSelector, ENTER, BACKSPACE, DELETE);

      let ps = editor.dataRoot.querySelectorAll("body>p");
      assert.equal(ps.length, 2,
                   "there should be 2 paragraphs before delete");

      editor.caretManager.setCaret(ps[0].lastChild,
                                   ps[0].lastChild!.nodeValue!.length);
      editor.type(DELETE);

      ps = editor.dataRoot.querySelectorAll("body>p");
      assert.equal(ps.length, 1,
                   "there should be 1 paragraph after delete");
      assert.equal(cleanNamespace(ps[0].outerHTML), "<p>BarFoo</p>");

      editor.undo();
      ps = editor.dataRoot.querySelectorAll("body>p");
      assert.equal(ps.length, 2, "there should be 2 paragraphs after undo");
      assert.equal(cleanNamespace(ps[0].outerHTML), "<p>Bar</p>");
      assert.equal(cleanNamespace(ps[1].outerHTML), "<p>Foo</p>");
    });
开发者ID:lddubeau,项目名称:wed,代码行数:23,代码来源:input-trigger-factory-test.ts


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