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


TypeScript Theme.default函数代码示例

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


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

示例1: Theme

UnitTest.asynctest('browser.tinymce.core.keyboard.InsertKeysBrModeTest', (success, failure) => {
  Theme();

  const sFireInsert = (editor: Editor) => {
    return Step.sync(() => {
      editor.fire('input', { isComposing: false });
    });
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      Logger.t('Insert key in text with in nbsp text node', GeneralSteps.sequence([
        Logger.t('Nbsp at first character position', GeneralSteps.sequence([
          Logger.t('Insert in text node with nbsp at start of body', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent(' a'),
            tinyApis.sSetCursor([0], 2),
            sFireInsert(editor),
            tinyApis.sAssertSelection([0], 2, [0], 2),
            tinyApis.sAssertContent(' a')
          ])),
          Logger.t('Insert in text in node with leading nbsp after inline with trailing space', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a<em>b </em>&nbsp;c'),
            tinyApis.sSetCursor([2], 2),
            sFireInsert(editor),
            tinyApis.sAssertSelection([2], 2, [2], 2),
            tinyApis.sAssertContent('a<em>b </em>&nbsp;c')
          ])),
          Logger.t('Insert in text in node with leading nbsp after inline', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a<em>b</em>&nbsp;c'),
            tinyApis.sSetCursor([2], 2),
            sFireInsert(editor),
            tinyApis.sAssertSelection([2], 2, [2], 2),
            tinyApis.sAssertContent('a<em>b</em> c')
          ])),
          Logger.t('Insert in text in node with leading nbsp after inline with trailing nbsp', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a<em>b&nbsp;</em>&nbsp;c'),
            tinyApis.sSetCursor([2], 2),
            sFireInsert(editor),
            tinyApis.sAssertSelection([2], 2, [2], 2),
            tinyApis.sAssertContent('a<em>b&nbsp;</em> c')
          ])),
          Logger.t('Insert at beginning of text node with leading nbsp after a br', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a<br />&nbsp;b'),
            tinyApis.sSetCursor([2], 0),
            sFireInsert(editor),
            tinyApis.sAssertSelection([2], 0, [2], 0),
            tinyApis.sAssertContent('a<br />&nbsp;b')
          ])),
          Logger.t('Insert at beginning of text node with leading nbsp within inline element followed by br', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a<br /><em>&nbsp;b</em>'),
            tinyApis.sSetCursor([2, 0], 0),
            sFireInsert(editor),
            tinyApis.sAssertSelection([2, 0], 0, [2, 0], 0),
            tinyApis.sAssertContent('a<br /><em>&nbsp;b</em>')
          ]))
        ])),

        Logger.t('Nbsp at last character position', GeneralSteps.sequence([
          Logger.t('Insert in text node with nbsp at end of body', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a&nbsp;'),
            tinyApis.sSetCursor([0], 0),
            sFireInsert(editor),
            tinyApis.sAssertSelection([0], 0, [0], 0),
            tinyApis.sAssertContent('a&nbsp;')
          ])),
          Logger.t('Insert in text in node with leading nbsp after inline with trailing space', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a&nbsp;<em> b</em>c'),
            tinyApis.sSetCursor([0], 0),
            sFireInsert(editor),
            tinyApis.sAssertSelection([0], 0, [0], 0),
            tinyApis.sAssertContent('a&nbsp;<em> b</em>c')
          ])),
          Logger.t('Insert in text in node with trailing nbsp before inline', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a&nbsp;<em>b</em>c'),
            tinyApis.sSetCursor([0], 0),
            sFireInsert(editor),
            tinyApis.sAssertSelection([0], 0, [0], 0),
            tinyApis.sAssertContent('a <em>b</em>c')
          ])),
          Logger.t('Insert in text in node with trailing nbsp before inline with leading nbsp', GeneralSteps.sequence([
            tinyApis.sFocus,
            tinyApis.sSetRawContent('a&nbsp;<em>&nbsp;b</em>c'),
            tinyApis.sSetCursor([0], 0),
            sFireInsert(editor),
            tinyApis.sAssertSelection([0], 0, [0], 0),
            tinyApis.sAssertContent('a <em>&nbsp;b</em>c')
          ])),
          Logger.t('Insert in text in node with single middle nbsp', GeneralSteps.sequence([
            tinyApis.sFocus,
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:InsertKeysBrModeTest.ts

示例2: function

  function () {
    const success = arguments[arguments.length - 2];
    const failure = arguments[arguments.length - 1];
    const os = PlatformDetection.detect().os;

    Theme();

    const sAssertCaretAtZwsp = function (editor) {
      return Step.sync(function () {
        const rng = editor.selection.getRng();
        const sc = rng.startContainer, so = rng.startOffset;
        const chr = sc.data.substr(so, 1);
        Assertions.assertEq('Should be zwsp at caret', chr, Zwsp.ZWSP);
      });
    };

    const sAssertCaretAfterZwsp = function (editor) {
      return Step.sync(function () {
        const rng = editor.selection.getRng();
        const sc = rng.startContainer, so = rng.startOffset;
        const chr = sc.data.substr(so - 1, 1);
        Assertions.assertEq('Should be after a zwsp at caret', chr, Zwsp.ZWSP);
      });
    };

    TinyLoader.setup(function (editor, onSuccess, onFailure) {
      const tinyApis = TinyApis(editor);
      const tinyActions = TinyActions(editor);

      Pipeline.async({}, [
        tinyApis.sFocus,
        Logger.t('Arrow keys anchor with text', GeneralSteps.sequence([
          Logger.t('From start to end inside anchor over text', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
            tinyApis.sSetCursor([0, 0, 0], 0),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.right(), { }),
            tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
            sAssertCaretAtZwsp(editor)
          ])),
          Logger.t('From start to before anchor with text', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
            tinyApis.sSetCursor([0, 0, 0], 0),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.left(), { }),
            tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0),
            sAssertCaretAtZwsp(editor)
          ])),
          Logger.t('From end to after anchor with text', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.right(), { }),
            tinyApis.sAssertSelection([0, 1], 1, [0, 1], 1),
            sAssertCaretAfterZwsp(editor)
          ])),
          Logger.t('From end to start inside anchor over text', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.left(), { }),
            tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
            sAssertCaretAfterZwsp(editor)
          ]))
        ])),

        Logger.t('Arrow keys anchor with image', GeneralSteps.sequence([
          Logger.t('From start to end inside anchor over img', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
            tinyApis.sSetCursor([0, 0], 0),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.right(), { }),
            tinyApis.sAssertSelection([0, 0, 1], 0, [0, 0, 1], 0),
            sAssertCaretAtZwsp(editor)
          ])),
          Logger.t('From start to before on anchor with img', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
            tinyApis.sSetCursor([0, 0], 0),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.left(), { }),
            tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0),
            sAssertCaretAtZwsp(editor)
          ])),
          Logger.t('From end to after on anchor with img', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
            tinyApis.sSetCursor([0, 0], 1),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.right(), { }),
            tinyApis.sAssertSelection([0, 1], 1, [0, 1], 1),
            sAssertCaretAfterZwsp(editor)
          ])),
          Logger.t('From end to start inside anchor over img', GeneralSteps.sequence([
            tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
            tinyApis.sSetCursor([0, 0], 1),
            tinyApis.sNodeChanged,
            tinyActions.sContentKeystroke(Keys.left(), { }),
            tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
            sAssertCaretAfterZwsp(editor)
          ]))
        ])),
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:ArrowKeysInlineBoundariesTest.ts

示例3: Plugin

UnitTest.asynctest('browser.tinymce.plugins.toc.TocPluginTest', (success, failure) => {

  const suite = LegacyUnit.createSuite();

  Plugin();
  Theme();

  const stripAttribs = function ($el, attr) {
    if (Tools.isArray(attr)) {
      Tools.each(attr, function (attr) {
        stripAttribs($el, attr);
      });
      return;
    }

    $el.removeAttr(attr);
    $el.find('[' + attr + ']').removeAttr(attr);
  };

  const trimBr = function (html) {
    return html.replace(/<br data-mce-bogus="1" \/>/g, '');
  };

  suite.test('TestCase-TBA: TableOfContents: mceInsertToc', function (editor) {
    editor.getBody().innerHTML =
      '<h1 id="h1">H1</h1>' +
      '<p>This is some text.</p><br />' +
      '<h2 id="h2">H2</h2>' +
      '<p>This is some text.</p><hr />' +
      '<h1 id="h3">H1</h1>' +
      '<p>This is some text.</p>' +
      '<h3 id="h4">H3</h3>' +
      '<p>This is some text.</p>'
      ;

    LegacyUnit.setSelection(editor, 'h1', 0);
    editor.execCommand('mceInsertToc');

    const $toc = editor.$('.tst-toc');

    LegacyUnit.equal($toc.length, 2, 'ToC inserted');
    LegacyUnit.equal($toc.attr('contentEditable'), 'false', 'cE=false');

    LegacyUnit.equal($toc.find('ul ul ul').length, 0, 'no levels beyond 2 are included');

    stripAttribs($toc, ['data-mce-href', 'data-mce-selected']);

    LegacyUnit.equal(trimBr(HtmlUtils.normalizeHtml($toc[0].outerHTML)),
      '<div class="tst-toc" contenteditable="false">' +
      '<h3 contenteditable="true">Table of Contents</h3>' +
      '<ul>' +
      '<li>' +
      '<a href="#h1">H1</a>' +
      '<ul>' +
      '<li><a href="#h2">H2</a></li>' +
      '</ul>' +
      '</li>' +
      '<li>' +
      '<a href="#h3">H1</a>' +
      '</li>' +
      '</ul>' +
      '</div>',
      'no surprises in ToC structure'
    );
  });

  suite.test('TestCase-TBA: TableOfContents: mceInsertToc - flat structure', function (editor) {
    editor.getBody().innerHTML =
      '<h1 id="h1">H1</h1>' +
      '<p>This is some text.</p><br />' +
      '<h1 id="h2">H1</h1>' +
      '<p>This is some text.</p><hr />' +
      '<h1 id="h3">H1</h1>' +
      '<p>This is some text.</p>' +
      '<h2 id="h4">H2</h2>' +
      '<p>This is some text.</p>'
      ;

    LegacyUnit.setSelection(editor, 'h1', 0);
    editor.execCommand('mceInsertToc');

    const $toc = editor.$('.tst-toc');

    stripAttribs($toc, ['data-mce-href', 'data-mce-selected']);

    LegacyUnit.equal(trimBr(HtmlUtils.normalizeHtml($toc[0].innerHTML)),
      '<h3 contenteditable="true">Table of Contents</h3>' +
      '<ul>' +
      '<li>' +
      '<a href="#h1">H1</a>' +
      '</li>' +
      '<li>' +
      '<a href="#h2">H1</a>' +
      '</li>' +
      '<li>' +
      '<a href="#h3">H1</a>' +
      '<ul>' +
      '<li><a href="#h4">H2</a></li>' +
      '</ul>' +
      '</li>' +
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:TocPluginTest.ts

示例4: Plugin

UnitTest.asynctest('tinymce.lists.browser.ApplyTest', (success, failure) => {
  const suite = LegacyUnit.createSuite();

  Plugin();
  Theme();

  suite.test('TestCase-TBA: Lists: Apply UL list to single P', function (editor) {
    editor.getBody().innerHTML = LegacyUnit.trimBrs(
      '<p>a</p>'
    );

    editor.focus();
    LegacyUnit.setSelection(editor, 'p', 0);
    LegacyUnit.execCommand(editor, 'InsertUnorderedList');

    LegacyUnit.equal(editor.getContent(), '<ul><li>a</li></ul>');
    LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI');
  });

  suite.test('TestCase-TBA: Lists: Apply UL list to single empty P', function (editor) {
    editor.getBody().innerHTML = LegacyUnit.trimBrs(
      '<p><br></p>'
    );

    editor.focus();
    LegacyUnit.setSelection(editor, 'p', 0);
    LegacyUnit.execCommand(editor, 'InsertUnorderedList');

    LegacyUnit.equal(LegacyUnit.trimBrs(editor.getContent({ format: 'raw' })), '<ul><li></li></ul>');
    LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI');
  });

  suite.test('TestCase-TBA: Lists: Apply UL list to multiple Ps', function (editor) {
    editor.getBody().innerHTML = LegacyUnit.trimBrs(
      '<p>a</p>' +
      '<p>b</p>' +
      '<p>c</p>'
    );

    editor.focus();
    LegacyUnit.setSelection(editor, 'p', 0, 'p:last', 0);
    LegacyUnit.execCommand(editor, 'InsertUnorderedList');

    LegacyUnit.equal(editor.getContent(),
      '<ul>' +
      '<li>a</li>' +
      '<li>b</li>' +
      '<li>c</li>' +
      '</ul>'
    );
    LegacyUnit.equal(editor.selection.getStart().nodeName, 'LI');
  });

  suite.test('TestCase-TBA: Lists: Apply OL list to single P', function (editor) {
    editor.getBody().innerHTML = LegacyUnit.trimBrs(
      '<p>a</p>'
    );

    editor.focus();
    LegacyUnit.setSelection(editor, 'p', 0);
    LegacyUnit.execCommand(editor, 'InsertOrderedList');

    LegacyUnit.equal(editor.getContent(), '<ol><li>a</li></ol>');
    LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI');
  });

  suite.test('TestCase-TBA: Lists: Apply OL list to single empty P', function (editor) {
    editor.getBody().innerHTML = LegacyUnit.trimBrs(
      '<p><br></p>'
    );

    editor.focus();
    LegacyUnit.setSelection(editor, 'p', 0);
    LegacyUnit.execCommand(editor, 'InsertOrderedList');

    LegacyUnit.equal(LegacyUnit.trimBrs(editor.getContent({ format: 'raw' })), '<ol><li></li></ol>');
    LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI');
  });

  suite.test('TestCase-TBA: Lists: Apply OL list to multiple Ps', function (editor) {
    editor.getBody().innerHTML = LegacyUnit.trimBrs(
      '<p>a</p>' +
      '<p>b</p>' +
      '<p>c</p>'
    );

    editor.focus();
    LegacyUnit.setSelection(editor, 'p', 0, 'p:last', 0);
    LegacyUnit.execCommand(editor, 'InsertOrderedList');

    LegacyUnit.equal(editor.getContent(),
      '<ol>' +
      '<li>a</li>' +
      '<li>b</li>' +
      '<li>c</li>' +
      '</ol>'
    );
    LegacyUnit.equal(editor.selection.getStart().nodeName, 'LI');
  });

//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:ApplyTest.ts

示例5: mBindEventMutator

UnitTest.asynctest('browser.tinymce.core.dom.SelectionEventsTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  Theme();

  const mBindEventMutator = function (editor, eventName, mutator) {
    return Step.stateful(function (value, next, die) {
      const eventArgs = Cell(null);

      const handler = function (e) {
        mutator(editor, e);
        eventArgs.set(e);
      };

      editor.on(eventName, handler);
      next({ eventArgs, handler });
    });
  };

  const mBindEvent = function (editor, eventName) {
    return mBindEventMutator(editor, eventName, Fun.noop);
  };

  const mUnbindEvent = function (editor, eventName) {
    return Step.stateful(function (value: any, next, die) {
      editor.off(eventName, value.handler);
      next({});
    });
  };

  const mAssertSetSelectionEventArgs = function (editor, expectedForward) {
    return Step.stateful(function (value: any, next, die) {
      Assertions.assertEq('Should be expected forward flag', expectedForward, value.eventArgs.get().forward);
      assertSelectAllRange(editor, value.eventArgs.get().range);
      next(value);
    });
  };

  const getSelectAllRng = function (editor) {
    const rng = document.createRange();
    rng.setStartBefore(editor.getBody().firstChild);
    rng.setEndAfter(editor.getBody().firstChild);
    return rng;
  };

  const sSetRng = function (editor, forward) {
    return Step.sync(function () {
      editor.selection.setRng(getSelectAllRng(editor), forward);
    });
  };

  const sGetRng = function (editor, forward?) {
    return Step.sync(function () {
      editor.selection.getRng();
    });
  };

  const selectAll = function (editor, eventArgs) {
    eventArgs.range = getSelectAllRng(editor);
  };

  const assertSelectAllRange = function (editor, actualRng) {
    Assertions.assertDomEq(
      'Should be expected startContainer',
      Element.fromDom(editor.getBody()),
      Element.fromDom(actualRng.startContainer)
    );

    Assertions.assertDomEq(
      'Should be expected endContainer',
      Element.fromDom(editor.getBody()),
      Element.fromDom(actualRng.endContainer)
    );
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    Pipeline.async({}, [
      tinyApis.sFocus,
      Logger.t('SetSelectionRange event', GeneralSteps.sequence([
        mBindEvent(editor, 'SetSelectionRange'),
        tinyApis.sSetContent('<p>a</p>'),
        sSetRng(editor, undefined),
        mAssertSetSelectionEventArgs(editor, undefined),
        sSetRng(editor, true),
        mAssertSetSelectionEventArgs(editor, true),
        sSetRng(editor, false),
        mAssertSetSelectionEventArgs(editor, false),
        mUnbindEvent(editor, 'SetSelectionRange')
      ])),
      Logger.t('AfterSetSelectionRange event', GeneralSteps.sequence([
        mBindEvent(editor, 'AfterSetSelectionRange'),
        tinyApis.sSetContent('<p>a</p>'),
        sSetRng(editor, undefined),
        Step.stateful(function (value, next, die) {
          Assertions.assertEq('', 'undefined', typeof value.eventArgs.get().forward);
          next(value);
        }),
        sSetRng(editor, true),
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:SelectionEventsTest.ts

示例6: Plugin

UnitTest.asynctest('browser.tinymce.plugins.autosave.AutoSavePluginTest', (success, failure) => {
  const suite = LegacyUnit.createSuite();

  Plugin();
  Theme();

  suite.test('TestCase-TBA: AutoSave: isEmpty true', function (editor) {
    LegacyUnit.equal(editor.plugins.autosave.isEmpty(''), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('   '), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('\t\t\t'), true);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p id="x"></p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p></p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p> </p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p>\t</p>'), true);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br></p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br /></p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /></p>'), true);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br><br></p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br /><br /></p>'), true);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /><br data-mce-bogus="true" /></p>'), true);
  });

  suite.test('TestCase-TBA: AutoSave: isEmpty false', function (editor) {
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('X'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('   X'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('\t\t\tX'), false);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p>X</p>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p> X</p>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p>\tX</p>'), false);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br>X</p>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br />X</p>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" />X</p>'), false);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br><br>X</p>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br /><br />X</p>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /><br data-mce-bogus="true" />X</p>'), false);

    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<h1></h1>'), false);
    LegacyUnit.equal(editor.plugins.autosave.isEmpty('<img src="x" />'), false);
  });

  suite.test('TestCase-TBA: AutoSave: hasDraft/storeDraft/restoreDraft', function (editor) {
    LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);

    editor.setContent('X');
    editor.undoManager.add();
    editor.plugins.autosave.storeDraft();

    LegacyUnit.equal(editor.plugins.autosave.hasDraft(), true);

    editor.setContent('Y');
    editor.undoManager.add();

    editor.plugins.autosave.restoreDraft();
    LegacyUnit.equal(editor.getContent(), '<p>X</p>');
    editor.plugins.autosave.removeDraft();
  });

  suite.test('TestCase-TBA: AutoSave: recognises location hash change', function (editor) {
    LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);

    editor.setContent('X');
    editor.undoManager.add();
    editor.plugins.autosave.storeDraft();

    window.location.hash = 'test' + Math.random().toString(36).substring(7);

    LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);

    history.replaceState('', document.title, window.location.pathname + window.location.search);
  });

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    Pipeline.async({}, Log.steps('TBA', 'AutoSave: Test autosave isEmpty true/false, drafts and location hash change', suite.toSteps(editor)), onSuccess, onFailure);
  }, {
    plugins: 'autosave',
    indent: false,
    base_url: '/project/tinymce/js/tinymce'
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:85,代码来源:AutoSavePluginTest.ts

示例7: Theme

UnitTest.asynctest('Remove context menu on focusout', (success, failure) => {
  Theme();

  const inputElmCell = Cell<Element>(null);
  const sAddInput = Step.sync(() => {
    const input = Element.fromTag('input');
    inputElmCell.set(input);

    Insert.append(Body.body(), input);
  });

  const sRemoveInput = Step.sync(() => {
    Remove.remove(inputElmCell.get());
  });

  const cFocusInput = Chain.op(() => {
    Focus.focus(inputElmCell.get());
  });

  const cWaitForContextmenuState = (state: boolean) => Chain.control(
    Chain.op(() => {
      const contextToolbar = UiFinder.findIn(Body.body(), '.tox-pop');

      Assertions.assertEq('no context toolbar', state, contextToolbar.isValue());
    }),
    Guard.tryUntil('Wait for context menu to appear.', 100, 3000)
  );

  const html = '<p>One <a href="http://tiny.cloud">link</a> Two</p>';

  const setup = (ed: Editor) => {
    ed.ui.registry.addButton('alpha', {
      text: 'Alpha',
      onAction: Fun.noop
    });
    ed.ui.registry.addContextToolbar('test-toolbar', {
      predicate: (node) => {
        return node.nodeName && node.nodeName.toLowerCase() === 'a'; },
      items: 'alpha'
    });
  };

  Pipeline.async({}, [
    sAddInput,
    Logger.t('iframe editor focusout should remove context menu', Chain.asStep({}, [
      McEditor.cFromHtml(html, { setup, base_url: '/project/tinymce/js/tinymce' }),
      ApiChains.cFocus,
      ApiChains.cSetCursor([ 0, 1, 0 ], 1),
      cWaitForContextmenuState(true),
      cFocusInput,
      cWaitForContextmenuState(false),
      McEditor.cRemove
    ])),
    Logger.t('inline editor focusout should remove context menu', Chain.asStep({}, [
      McEditor.cFromHtml(html, { setup, inline: true, base_url: '/project/tinymce/js/tinymce' }),
      ApiChains.cFocus,
      ApiChains.cSetCursor([ 1, 0 ], 1),
      cWaitForContextmenuState(true),
      cFocusInput,
      cWaitForContextmenuState(false),
      McEditor.cRemove
    ])),
    sRemoveInput
  ], () => success(), failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:65,代码来源:RemoveContextMenuOnFocusoutTest.ts

示例8: function

UnitTest.asynctest('browser.core.DataToHtmlTest', function (success, failure) {
  Plugin();
  Theme();

  const sTestDataToHtml = function (editor, data, expected) {
    const actual = Element.fromHtml(DataToHtml.dataToHtml(editor, data));

    return Logger.t(`Test html data ${expected}`, Waiter.sTryUntil('Wait for structure check',
      Assertions.sAssertStructure('Assert equal', expected, actual),
      10, 500)
    );
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {

    const videoStruct = ApproxStructure.build(function (s, str/*, arr*/) {
      return s.element('video', {
        children: [
          s.text(str.is('\n')),
          s.element('source', {
            attrs: {
              src: str.is('a')
            }
          }),
          s.text(str.is('\n'))
        ],
        attrs: {
          height: str.is('150'),
          width: str.is('300')
        }
      });
    });

    const iframeStruct = ApproxStructure.build(function (s, str/*, arr*/) {
      return s.element('iframe', {
        attrs: {
          height: str.is('150'),
          width: str.is('300')
        }
      });
    });

    Pipeline.async({},
      Log.steps('TBA', 'Media: Assert html structure of the video and iframe elements', [
        sTestDataToHtml(editor,
          {
            'type': 'video',
            'source1': 'a',
            'source2': '',
            'poster': '',
            'data-ephox-embed': 'a'
          },
          videoStruct),
        sTestDataToHtml(editor,
          {
            'type': 'iframe',
            'source1': 'a',
            'source2': '',
            'poster': '',
            'data-ephox-embed': 'a'
          },
          iframeStruct)
      ])
    , onSuccess, onFailure);
  }, {
    plugins: ['media'],
    toolbar: 'media',
    theme: 'silver',
    base_url: '/project/tinymce/js/tinymce',
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:71,代码来源:DataToHtmlTest.ts

示例9: function

UnitTest.asynctest('browser.tinymce.core.SelectionOverridesTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const suite = LegacyUnit.createSuite();

  Theme();

  const pressKey = function (key) {
    return function (editor) {
      Keyboard.keystroke(key, {}, TinyDom.fromDom(editor.getBody()));
    };
  };

  const exitPreTest = function (arrow, offset, expectedContent) {
    return function (editor) {
      editor.setContent('<pre>abc</pre>');

      LegacyUnit.setSelection(editor, 'pre', 1);
      arrow(editor);
      LegacyUnit.equal(editor.getContent(), '<pre>abc</pre>');
      LegacyUnit.equal(editor.selection.getNode().nodeName, 'PRE');

      LegacyUnit.setSelection(editor, 'pre', offset);
      arrow(editor);
      LegacyUnit.equal(editor.getContent(), expectedContent);
      LegacyUnit.equal(editor.selection.getNode().nodeName, 'P');
    };
  };

  const ok = function (a, label) {
    LegacyUnit.equal(a, true, label);
  };

  const leftArrow = pressKey(VK.LEFT);
  const rightArrow = pressKey(VK.RIGHT);
  const upArrow = pressKey(VK.UP);
  const downArrow = pressKey(VK.DOWN);

  suite.test('left/right over cE=false inline', function (editor) {
    editor.focus();
    editor.setContent('<span contenteditable="false">1</span>');
    editor.selection.select(editor.$('span')[0]);

    leftArrow(editor);
    LegacyUnit.equal(editor.getContent(), '<p><span contenteditable="false">1</span></p>');
    LegacyUnit.equal(CaretContainer.isCaretContainerInline(editor.selection.getRng().startContainer), true);
    LegacyUnit.equalDom(editor.selection.getRng().startContainer, editor.$('p')[0].firstChild);

    rightArrow(editor);
    LegacyUnit.equal(editor.getContent(), '<p><span contenteditable="false">1</span></p>');
    LegacyUnit.equalDom(editor.selection.getNode(), editor.$('span')[0]);

    rightArrow(editor);
    LegacyUnit.equal(editor.getContent(), '<p><span contenteditable="false">1</span></p>');
    LegacyUnit.equal(CaretContainer.isCaretContainerInline(editor.selection.getRng().startContainer), true);
    LegacyUnit.equalDom(editor.selection.getRng().startContainer, editor.$('p')[0].lastChild);
  });

  suite.test('left/right over cE=false block', function (editor) {
    editor.setContent('<p contenteditable="false">1</p>');
    editor.selection.select(editor.$('p[contenteditable=false]')[0]);

    leftArrow(editor);
    LegacyUnit.equal(editor.getContent(), '<p contenteditable="false">1</p>');
    LegacyUnit.equal(CaretContainer.isCaretContainerBlock(editor.selection.getRng().startContainer), true);

    rightArrow(editor);
    LegacyUnit.equal(editor.getContent(), '<p contenteditable="false">1</p>');
    LegacyUnit.equalDom(editor.selection.getNode(), editor.$('p[contenteditable=false]')[0]);

    rightArrow(editor);
    LegacyUnit.equal(editor.getContent(), '<p contenteditable="false">1</p>');
    LegacyUnit.equal(CaretContainer.isCaretContainerBlock(editor.selection.getRng().startContainer), true);
  });

  suite.test('left before cE=false block and type', function (editor) {
    editor.setContent('<p contenteditable="false">1</p>');
    editor.selection.select(editor.$('p')[0]);

    leftArrow(editor);
    KeyUtils.type(editor, 'a');
    LegacyUnit.equal(editor.getContent(), '<p>a</p><p contenteditable="false">1</p>');
    LegacyUnit.equal(CaretContainer.isCaretContainerBlock(editor.selection.getRng().startContainer.parentNode), false);
  });

  suite.test('right after cE=false block and type', function (editor) {
    editor.setContent('<p contenteditable="false">1</p>');
    editor.selection.select(editor.$('p[contenteditable=false]')[0]);

    rightArrow(editor);
    KeyUtils.type(editor, 'a');
    LegacyUnit.equal(editor.getContent(), '<p contenteditable="false">1</p><p>a</p>');
    LegacyUnit.equal(CaretContainer.isCaretContainerBlock(editor.selection.getRng().startContainer.parentNode), false);
  });

  suite.test('up from P to inline cE=false', function (editor) {
    editor.setContent('<p>a<span contentEditable="false">1</span></p><p>abc</p>');
    LegacyUnit.setSelection(editor, 'p:last', 3);

    upArrow(editor);
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:SelectionOverridesTest.ts

示例10: PastePlugin

UnitTest.asynctest('browser.tinymce.plugins.paste.InternalClipboardTest', (success, failure) => {
  let dataTransfer, lastPreProcessEvent, lastPostProcessEvent;

  PastePlugin();
  TablePlugin();
  Theme();

  const sResetProcessEvents = Logger.t('Reset process events', Step.sync(function () {
    lastPreProcessEvent = null;
    lastPostProcessEvent = null;
  }));

  const sCutCopyDataTransferEvent = function (editor, type) {
    return Logger.t('Cut copy data transfer event', Step.sync(function () {
      dataTransfer = MockDataTransfer.create({});
      editor.fire(type, { clipboardData: dataTransfer });
    }));
  };

  const sPasteDataTransferEvent = function (editor, data) {
    return Logger.t('Paste data transfer event', Step.sync(function () {
      dataTransfer = MockDataTransfer.create(data);
      editor.fire('paste', { clipboardData: dataTransfer });
    }));
  };

  const sAssertClipboardData = function (expectedHtml, expectedText) {
    return Logger.t(`Assert clipboard data ${expectedHtml}, ${expectedText}`, Step.sync(function () {
      RawAssertions.assertEq('text/html data should match', expectedHtml, dataTransfer.getData('text/html'));
      RawAssertions.assertEq('text/plain data should match', expectedText, dataTransfer.getData('text/plain'));
    }));
  };

  const sCopy = function (editor, tinyApis, html, spath, soffset, fpath, foffset) {
    return Logger.t('Copy', GeneralSteps.sequence([
      tinyApis.sSetContent(html),
      tinyApis.sSetSelection(spath, soffset, fpath, foffset),
      sCutCopyDataTransferEvent(editor, 'copy')
    ]));
  };

  const sCut = function (editor, tinyApis, html, spath, soffset, fpath, foffset) {
    return Logger.t('Cut', GeneralSteps.sequence([
      tinyApis.sSetContent(html),
      tinyApis.sSetSelection(spath, soffset, fpath, foffset),
      sCutCopyDataTransferEvent(editor, 'cut')
    ]));
  };

  const sPaste = function (editor, tinyApis, startHtml, pasteData, spath, soffset, fpath, foffset) {
    return Logger.t('Paste', GeneralSteps.sequence([
      tinyApis.sSetContent(startHtml),
      tinyApis.sSetSelection(spath, soffset, fpath, foffset),
      sResetProcessEvents,
      sPasteDataTransferEvent(editor, pasteData)
    ]));
  };

  const sTestCopy = function (editor, tinyApis) {
    return Log.stepsAsStep('TBA', 'Paste: Copy simple text', [
        sCopy(editor, tinyApis, '<p>text</p>', [0, 0], 0, [0, 0], 4),
        sAssertClipboardData('text', 'text'),
        tinyApis.sAssertContent('<p>text</p>'),
        tinyApis.sAssertSelection([0, 0], 0, [0, 0], 4)
      ]),

      Log.stepsAsStep('TBA', 'Paste: Copy inline elements', [
        sCopy(editor, tinyApis, '<p>te<em>x</em>t</p>', [0, 0], 0, [0, 2], 1),
        sAssertClipboardData('te<em>x</em>t', 'text'),
        tinyApis.sAssertContent('<p>te<em>x</em>t</p>'),
        tinyApis.sAssertSelection([0, 0], 0, [0, 2], 1)
      ]),

      Log.stepsAsStep('TBA', 'Paste: Copy partialy selected inline elements', [
        sCopy(editor, tinyApis, '<p>a<em>cd</em>e</p>', [0, 0], 0, [0, 1, 0], 1),
        sAssertClipboardData('a<em>c</em>', 'ac'),
        tinyApis.sAssertContent('<p>a<em>cd</em>e</p>'),
        tinyApis.sAssertSelection([0, 0], 0, [0, 1, 0], 1)
      ]),

      Log.stepsAsStep('TBA', 'Paste: Copy collapsed selection', [
        sCopy(editor, tinyApis, '<p>abc</p>', [0, 0], 1, [0, 0], 1),
        sAssertClipboardData('', ''),
        tinyApis.sAssertContent('<p>abc</p>'),
        tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
      ]),

      Log.stepsAsStep('TBA', 'Copy collapsed selection with table selection', [
        sCopy(editor, tinyApis,
          '<table data-mce-selected="1">' +
            '<tbody>' +
              '<tr>' +
                '<td data-mce-first-selected="1" data-mce-selected="1">a</td>' +
                '<td data-mce-last-selected="1" data-mce-selected="1">b</td>' +
              '</tr>' +
            '</tbody>' +
          '</table>',
        [0, 0, 0, 1, 0], 0, [0, 0, 0, 1, 0], 0),
        sAssertClipboardData(
          '<table>\n' +
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:InternalClipboardTest.ts


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