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


TypeScript Chain.injectThunked方法代码示例

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


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

示例1: function

UnitTest.asynctest('browser.tinymce.core.focus.CefFocusTest', function (success, failure) {
  Theme();

  const sCreateInlineEditor = function (html) {
    return Chain.asStep({}, [
      McEditor.cFromHtml(html, {
        inline: true,
        base_url: '/project/tinymce/js/tinymce'
      })
    ]);
  };

  const sAssertSelection = function (editorIndex, startPath, startOffset, endPath, endOffset) {
    return Step.sync(function () {
      const editor = EditorManager.get(editorIndex);
      const startContainer = Hierarchy.follow(Element.fromDom(editor.getBody()), startPath).getOrDie();
      const endContainer = Hierarchy.follow(Element.fromDom(editor.getBody()), endPath).getOrDie();
      const rng = editor.selection.getRng();

      Assertions.assertDomEq('Should be expected from start container', startContainer, Element.fromDom(rng.startContainer));
      Assertions.assertEq('Should be expected from start offset', startOffset, rng.startOffset);
      Assertions.assertDomEq('Should be expected end container', endContainer, Element.fromDom(rng.endContainer));
      Assertions.assertEq('Should be expected end offset', endOffset, rng.endOffset);
    });
  };

  const sRemoveEditors = Chain.asStep({}, [
    Chain.injectThunked(() => EditorManager.get(1)),
    McEditor.cRemove,
    Chain.injectThunked(() => EditorManager.get(0)),
    McEditor.cRemove
  ]);

  Pipeline.async({}, [
    Logger.t('Focus editors', GeneralSteps.sequence([
      sCreateInlineEditor('<div class="tinymce"><p contenteditable="false">a</p></div>'),
      sCreateInlineEditor('<div class="tinymce"><p contenteditable="false">b</p></div>'),
      Step.sync(function () {
        EditorManager.get(0).getBody().focus();
        EditorManager.get(1).getBody().focus();
      }),
      Waiter.sTryUntil('Wait for selection to move', sAssertSelection(1, [0], 0, [0], 0), 10, 3000),
      Step.sync(function () {
        const caretElm0 = EditorManager.get(0).getBody().querySelector('[data-mce-caret]');
        const caretElm1 = EditorManager.get(1).getBody().querySelector('[data-mce-caret]');

        Assertions.assertEq('Should not be a caret element present editor 0', false, !!caretElm0);
        Assertions.assertEq('Should be a caret element present editor 1', true, !!caretElm1);
      }),
      sRemoveEditors
    ]))
  ], function () {
    success();
  }, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:55,代码来源:CefFocusTest.ts

示例2: function

 const sTestIsXYInContentArea = function (editor, deltaX, deltaY) {
   const dx1 = - 25 - deltaX;
   const dy1 = -25 - deltaY;
   const dx2 = - 5 - deltaX;
   const dy2 = - 5 - deltaY;
   return Step.label('Check points relative to deltaX=' + deltaX + ' deltaY=' + deltaY, Chain.asStep({}, [
     Chain.fromParent(
       Chain.label(
         'Calculate bounding rectangle',
         Chain.injectThunked(() => getIframeClientRect(editor))
       ), [
         Chain.label(
           'Check 〈bottom right〉 + (' + dx1 + ', ' + dy1 + ') is inside editor',
           Chain.op((rect) => Assertions.assertEq(
             'Should be inside the area since the scrollbars are excluded',
             true,
             EditorView.isXYInContentArea(editor, rect.width + dx1, rect.height + dy1)
           ))
         ),
         Chain.label(
           'Check 〈bottom right〉 + (' + dx2 + ', ' + dy2 + ') is ' + (hiddenScrollbar ? 'inside' : 'outside') + ' editor',
           Chain.op((rect) => Assertions.assertEq(
             (hiddenScrollbar ?
               'Should be inside the area since the scrollbars are hidden' :
               'Should be outside the area since the cordinate is on the scrollbars'),
             hiddenScrollbar,
             EditorView.isXYInContentArea(editor, rect.width + dx2, rect.height + dy2)
           ))
         )
       ]
     )
   ]));
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:33,代码来源:EditorViewIframeTest.ts


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