• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript agar.Keyboard类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: insertTablePickerApprox

    (editor, onSuccess, onFailure) => {
      const doc = Element.fromDom(document);

      Pipeline.async({ }, Log.steps(
        'TBA',
        'Check structure of table picker',
        [
          Mouse.sClickOn(Body.body(), '.tox-toolbar button'),
          UiFinder.sWaitForVisible('Waiting for menu', Body.body(), '[role="menu"]'),
          Chain.asStep(Body.body(), [
            UiFinder.cFindIn('[role="menu"]'),
            Assertions.cAssertStructure(
              'Checking structure',
              ApproxStructure.build((s, str, arr) => insertTablePickerApprox(s, str, arr, 1, 1))
            )
          ]),
          FocusTools.sTryOnSelector('Focus should be on first table cell', doc, '.tox-insert-table-picker__selected:last'),
          Keyboard.sKeydown(doc, Keys.down(), {}),
          Keyboard.sKeydown(doc, Keys.right(), {}),
          Chain.asStep(Body.body(), [
            UiFinder.cFindIn('[role="menu"]'),
            Assertions.cAssertStructure(
              'Checking structure',
              ApproxStructure.build((s, str, arr) => insertTablePickerApprox(s, str, arr, 2, 2))
            )
          ]),
          FocusTools.sTryOnSelector('Focus should be on 2 down, 2 across table cell', doc, '.tox-insert-table-picker__selected:last')
        ]
      ), onSuccess, onFailure);
    },
开发者ID:tinymce,项目名称:tinymce,代码行数:30,代码来源:OxideTablePickerMenuTest.ts


示例2: sAssertFocusOnItem

  return Arr.bind(navigation.concat(navigation.slice(0, 1)), (nav, i) => {
    const exploration = (nav.subitems.length > 0) ? [
      Keyboard.sKeydown(doc, Keys.right(), { }),
      sAssertFocusOnItem(doc, nav.subitems[0])
    ].concat(
      Arr.bind(
        nav.subitems.slice(1).concat(nav.subitems.slice(0, 1)),
        (si) => [
          Keyboard.sKeydown(doc, Keys.down(), { }),
          sDelay,
          sAssertFocusOnItem(doc, si)
        ]
      )
    ).concat([
      Keyboard.sKeydown(doc, Keys.escape(), { })
    ]) : [
      // Should do nothing
      Keyboard.sKeydown(doc, Keys.right(), { })
    ];

    return Arr.flatten([
      [ sAssertFocusOnItem(doc, nav.item) ],
      exploration,
      [ sAssertFocusOnItem(doc, nav.item) ],
      [ sDelay ],
      // Move to the next one
      i < navigation.length ? [ Keyboard.sKeydown(doc, Keys.down(), { }) ] : [ ]
    ]);
  });
开发者ID:tinymce,项目名称:tinymce,代码行数:29,代码来源:MenuNavigationTestUtils.ts


示例3: function

const sTypeChar = function (doc, chr) {
  return GeneralSteps.sequence([
    Keyboard.sKeydown(doc, chr, {}),
    Keyboard.sKeypress(doc, chr, {}),
    sInsertCharAtSelection(doc, chr),
    Keyboard.sKeyup(doc, chr, {})
  ]);
};
开发者ID:abstask,项目名称:tinymce,代码行数:8,代码来源:TypeText.ts


示例4:

 const sSetContentAndTrigger = (content: string, triggerCharCode: number) => {
   return GeneralSteps.sequence([
     tinyApis.sSetContent(`<p>${content}</p>`),
     tinyApis.sSetCursor([ 0, 0 ], content.length),
     Keyboard.sKeydown(eDoc, triggerCharCode, { }),
     Keyboard.sKeypress(eDoc, triggerCharCode, { })
   ]);
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:8,代码来源:AutocompleterTest.ts


示例5: TinyApis

  TinyLoader.setup((editor, onSuccess, onFailure) => {
    const tinyApis = TinyApis(editor);
    const doc = Element.fromDom(document);

    // Tab key press
    const sPressTabKey = Keyboard.sKeydown(doc, Keys.tab(), { });

    // Down arrow key press to nav between tabs
    const sPressDownArrowKey = Keyboard.sKeydown(doc, Keys.down(), { });

    // Assert focus is on the expected form element
    const sAssertFocusOnItem = (label, selector) => {
      return FocusTools.sTryOnSelector(
        `Focus should be on: ${label}`,
        doc,
        selector
      );
    };

    Pipeline.async({}, [
      Log.stepsAsStep('TBA', 'Help: Open dialog', [
        tinyApis.sFocus,
        tinyApis.sExecCommand('mceHelp')
      ]),

      Log.stepsAsStep('TBA', 'Help: test the tab key navigation cycles through all focusable fields in Handy Shortcuts tab', [
        sAssertFocusOnItem('Handy Shortcuts Tab', '.tox-dialog__body-nav-item:contains("Handy Shortcuts")'),
        sPressTabKey,
        sAssertFocusOnItem('Handy Shortcuts Items', '.tox-dialog__table'),
        sPressTabKey,
        sAssertFocusOnItem('Close Button', '.tox-button:contains("Close")'),
        sPressTabKey,
        sAssertFocusOnItem('Handy Shortcuts Tab', '.tox-dialog__body-nav-item:contains("Handy Shortcuts")'),
        sPressDownArrowKey
      ]),

      Log.stepsAsStep('TBA', 'Help: test the tab key navigation cycles through all focusable fields in Plugins tab', [
        sAssertFocusOnItem('Plugins Tab', '.tox-dialog__body-nav-item:contains("Plugins")'),
        sPressTabKey,
        sAssertFocusOnItem('Installed Plugins', 'div[role="document"]'),
        sPressTabKey,
        sAssertFocusOnItem('Close Button', '.tox-button:contains("Close")'),
        sPressTabKey,
        sAssertFocusOnItem('Plugins Tab', '.tox-dialog__body-nav-item:contains("Plugins")'),
        sPressDownArrowKey
      ]),

      Log.stepsAsStep('TBA', 'Help: test the tab key navigation cycles through all focusable fields in Version tab', [
        sAssertFocusOnItem('Version Tab', '.tox-dialog__body-nav-item:contains("Version")'),
        sPressTabKey,
        sAssertFocusOnItem('TinyMCE Version', 'div[role="document"]'),
        sPressTabKey,
        sAssertFocusOnItem('Close Button', '.tox-button:contains("Close")'),
        sPressTabKey,
        sAssertFocusOnItem('Version Tab', '.tox-dialog__body-nav-item:contains("Version")')
      ])
    ], onSuccess, onFailure);
  }, {
开发者ID:tinymce,项目名称:tinymce,代码行数:58,代码来源:DialogKeyboardNavTest.ts


示例6: TinyApis

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

    Pipeline.async({}, [
      Log.stepsAsStep('TBA', 'Link: should not get anchor info if not selected node', [
        TestLinkUi.sClearHistory,
        tinyApis.sSetContent('<p><a href="http://tinymce.com" class="shouldbekept" title="shouldalsobekept">tiny</a></p>'),
        tinyApis.sSetSelection([0, 0, 0], 2, [0, 0, 0], 2),
        tinyApis.sExecCommand('mcelink'),
        TestLinkUi.sAssertDialogContents({
          href: 'http://tinymce.com',
          text: 'tiny',
          title: 'shouldalsobekept',
          target: ''
        }),
        FocusTools.sSetActiveValue(doc, 'http://something'),
        Keyboard.sKeydown(doc, Keys.enter(), { }),
        Waiter.sTryUntil(
          'Wait until link is inserted',
          tinyApis.sAssertContentPresence({
            'a[href="http://something"]': 1,
            'a[class="shouldbekept"]': 1,
            'a[title="shouldalsobekept"]': 1
          }),
          100,
          1000
        ),
        TestLinkUi.sClearHistory
      ]),
      Log.stepsAsStep('TBA', 'Link: should remove attributes if unset in the dialog', [
        TestLinkUi.sClearHistory,
        tinyApis.sSetContent('<p><a href="http://tinymce.com" class="shouldbekept" title="shouldnotbekept">tiny</a></p>'),
        tinyApis.sSetSelection([0, 0, 0], 2, [0, 0, 0], 2),
        tinyApis.sExecCommand('mcelink'),
        TestLinkUi.sAssertDialogContents({
          href: 'http://tinymce.com',
          text: 'tiny',
          title: 'shouldnotbekept',
          target: ''
        }),
        FocusTools.sSetActiveValue(doc, 'http://something'),
        TestLinkUi.sSetInputFieldValue('Title', ''),
        Keyboard.sKeydown(doc, Keys.enter(), { }),
        Waiter.sTryUntil(
          'Wait until link is inserted',
          tinyApis.sAssertContentPresence({
            'a[href="http://something"]': 1,
            'a[class="shouldbekept"]': 1,
            'a[title="shouldnotbekept"]': 0
          }),
          100,
          1000
        ),
        TestLinkUi.sClearHistory
      ])
    ], onSuccess, onFailure);
  }, {
开发者ID:tinymce,项目名称:tinymce,代码行数:58,代码来源:UpdateLinkTest.ts


示例7: sCheckItemsAtLocationPlus

 const sCheckSubItemsAtLocation = (expectedSubmenu: string) => sCheckItemsAtLocationPlus(
   GeneralSteps.sequence([
     Keyboard.sKeydown(doc, Keys.right(), { }),
     sAssertFocusOnItem(expectedSubmenu)
   ]),
   // Afterwards, escape the submenu
   Keyboard.sKeydown(doc, Keys.escape(), { }),
   (text) => sOpenMenu('', text)
 );
开发者ID:tinymce,项目名称:tinymce,代码行数:9,代码来源:SilverBespokeButtonsTest.ts


示例8: rgb

    (editor, onSuccess, onFailure) => {
      const doc = Element.fromDom(document);

      Pipeline.async({ }, Logger.ts(
        'Check structure of grid collection menu',
        [
          TestHelpers.GuiSetup.mAddStyles(doc, [
            ':focus { background-color: rgb(222, 224, 226); }'
          ]),
          Mouse.sClickOn(Body.body(), '.tox-split-button__chevron'),
          UiFinder.sWaitForVisible('Waiting for menu', Body.body(), '[role="menu"]'),
          Chain.asStep(Body.body(), [
            UiFinder.cFindIn('[role="menu"]'),
            Assertions.cAssertStructure(
              'Checking structure',
              ApproxStructure.build((s, str, arr) => {
                return s.element('div', {
                  classes: [ arr.has('tox-menu'), arr.has('tox-collection'), arr.has('tox-collection--grid') ],
                  children: [
                    s.element('div', {
                      classes: [ arr.has('tox-collection__group') ],
                      children: Arr.map([ '1', '2', '3', '4', '5', '6', '7', '8' ], (num) => {
                        return s.element('div', {
                          classes: [ arr.has('tox-collection__item') ],
                          attrs: {
                            title: str.is(num)
                          },
                          children: [
                            // NOTE: The oxide demo page has div, but I think that's just a mistake
                            s.element('div', {
                             classes: [ arr.has('tox-collection__item-icon') ],
                             children: [
                               s.element('svg', {})
                             ]
                            })
                          ]
                        });
                      })
                    })
                  ]
                });
              })
            )
          ]),

          // Without layout, the flatgrid cannot be calculated on phantom
          navigator.userAgent.indexOf('PhantomJS') > -1 ? Step.pass : GeneralSteps.sequence([
            FocusTools.sTryOnSelector('Focus should be on 1', doc, '.tox-collection__item[title="1"]'),
            Keyboard.sKeydown(doc, Keys.right(), { }),
            FocusTools.sTryOnSelector('Focus should be on 2', doc, '.tox-collection__item[title="2"]'),
            Keyboard.sKeydown(doc, Keys.right(), { }),
            FocusTools.sTryOnSelector('Focus should be on 3', doc, '.tox-collection__item[title="3"]')
          ]),
          TestHelpers.GuiSetup.mRemoveStyles
        ]
      ), onSuccess, onFailure);
    },
开发者ID:tinymce,项目名称:tinymce,代码行数:57,代码来源:OxideGridCollectionMenuTest.ts


示例9: TinyApis

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);
    const doc = Element.fromDom(document);
    const body = Body.body();

    Pipeline.async({},
      Log.steps('TBA', 'Emoticons: Open dialog, verify custom categories listed and search for custom emoticon', [
        tinyApis.sFocus,
        tinyUi.sClickOnToolbar('click emoticons', 'button'),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('wait for popup', 'div[role="dialog"]'),
        ]),
        FocusTools.sTryOnSelector('Focus should start on input', doc, 'input'),
        Chain.asStep(body, [
          UiFinder.cFindIn('[role="tablist"]'),
          Assertions.cAssertStructure('check custom categories are shown', ApproxStructure.build((s, str, arr) => {
            return s.element('div', {
              children: [
                tabElement(s, str, arr)('All'),
                tabElement(s, str, arr)('People'),
                tabElement(s, str, arr)('User Defined')
              ]
            });
          })),
        ]),
        FocusTools.sSetActiveValue(doc, 'clock'),
        Chain.asStep(doc, [
          FocusTools.cGetFocused,
          cFakeEvent('input')
        ]),
        Waiter.sTryUntil(
          'Wait until clock is the first choice (search should filter)',
          Chain.asStep(body, [
            UiFinder.cFindIn('.tox-collection__item:first'),
            Chain.mapper((item) => {
              return Attr.get(item, 'data-collection-item-value');
            }),
            Assertions.cAssertEq('Search should show custom clock', '⏲')
          ]),
          100,
          1000
        ),
        Keyboard.sKeydown(doc, Keys.tab(), {}),
        FocusTools.sTryOnSelector('Focus should have moved to collection', doc, '.tox-collection__item'),
        Keyboard.sKeydown(doc, Keys.enter(), {}),
        Waiter.sTryUntil(
          'Waiting for content update',
          tinyApis.sAssertContent('<p>⏲</p>'),
          100,
          1000
        )
      ])
      , onSuccess, onFailure);
  }, {
开发者ID:tinymce,项目名称:tinymce,代码行数:55,代码来源:EmoticonAppendTest.ts


示例10: TinyApis

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

    const rootDoc = Element.fromDom(document);

    const sOpenContextMenu = (target) => {
      return Chain.asStep(editor, [
        tinyUi.cTriggerContextMenu('trigger image context menu', target, '.tox-silver-sink [role="menuitem"]'),
        // Not sure why this is needed, but without the browser deselects the contextmenu target
        Chain.wait(0)
      ]);
    };

    const sWaitForAndSubmitDialog = Chain.asStep(editor, [
      tinyUi.cWaitForPopup('wait for dialog', 'div[role="dialog"]'),
      Mouse.cClickOn('.tox-button:contains("Save")')
    ]);

    Pipeline.async({}, [
      tinyApis.sFocus,
      Log.stepsAsStep('TBA', 'Opening context menus on a selected figure', [
        tinyApis.sSetRawContent('<figure class="image" contenteditable="false"><img src="image.png"><figcaption contenteditable="true">Caption</figcaption></figure><p>Second paragraph</p>'),
        tinyApis.sSetSelection([], 0, [], 1),
        sOpenContextMenu('figure.image'),
        Keyboard.sKeydown(rootDoc, Keys.enter(), {}),
        sWaitForAndSubmitDialog,
        tinyApis.sAssertSelection([], 0, [], 1)
      ]),
      Log.stepsAsStep('TBA', 'Opening context menus on an unselected figure', [
        tinyApis.sSetRawContent('<figure class="image" contenteditable="false"><img src="image.png"><figcaption contenteditable="true">Caption</figcaption></figure><p>Second paragraph</p>'),
        tinyApis.sSetSelection([1, 0], 1, [1, 0], 1),
        sOpenContextMenu('figure.image'),
        Keyboard.sKeydown(rootDoc, Keys.enter(), {}),
        sWaitForAndSubmitDialog,
        tinyApis.sAssertSelection([], 0, [], 1)
      ]),
      Log.stepsAsStep('TBA', 'Opening context menus on a selected image', [
        tinyApis.sSetRawContent('<p><img src="image.png" /></p><p>Second paragraph</p>'),
        tinyApis.sSetSelection([0], 0, [0], 1),
        sOpenContextMenu('img'),
        Keyboard.sKeydown(rootDoc, Keys.enter(), {}),
        sWaitForAndSubmitDialog,
        tinyApis.sAssertSelection([0], 0, [0], 1)
      ]),
      Log.stepsAsStep('TBA', 'Opening context menus on an unselected image', [
        tinyApis.sSetRawContent('<p><img src="image.png" /></p><p>Second paragraph</p>'),
        tinyApis.sSetSelection([1, 0], 1, [1, 0], 1),
        sOpenContextMenu('img'),
        Keyboard.sKeydown(rootDoc, Keys.enter(), {}),
        sWaitForAndSubmitDialog,
        tinyApis.sAssertSelection([0], 0, [0], 1)
      ])
    ], onSuccess, onFailure);
  }, {
开发者ID:tinymce,项目名称:tinymce,代码行数:55,代码来源:ContextMenuTest.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript agar.Keys类代码示例发布时间:2022-05-28
下一篇:
TypeScript agar.Guard类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap