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


TypeScript ApproxStructure.fromHtml方法代码示例

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


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

示例1:

 }, (doc, body, gui, component, store) => {
   return [
     Assertions.sAssertStructure(
       'Assert table structure',
       ApproxStructure.fromHtml((
         '<table class="tox-dialog__table">' +
           '<thead>' +
             '<tr>' +
               '<th>one</th>' +
               '<th>two</th>' +
               '<th>three</th>' +
             '</tr>' +
           '</thead>' +
           '<tbody>' +
             '<tr>' +
               '<td>a</td>' +
               '<td>b</td>' +
               '<td>c</td>' +
             '</tr>' +
             '<tr>' +
               '<td>d</td>' +
               '<td>e</td>' +
               '<td>f</td>' +
             '</tr>' +
           '</tbody>' +
         '</table>'
       )),
       component.element()
     )
   ];
 },
开发者ID:tinymce,项目名称:tinymce,代码行数:31,代码来源:TableTest.ts

示例2:

 Assertions.sAssertStructure('Content should only have one bookmark span', ApproxStructure.build((s, str) => {
   return s.element('body', {
     children: [
       s.element('p', {
         children: [
           ApproxStructure.fromHtml(bookmarkSpan),
           s.element('br', {
             attrs: {
               'data-mce-bogus': str.is('1')
             }
           })
         ]
       }),
       s.element('p', {
         children: [
           s.element('br', {
             attrs: {
               'data-mce-bogus': str.is('1')
             }
           })
         ]
       })
     ]
   });
 }), body),
开发者ID:tinymce,项目名称:tinymce,代码行数:25,代码来源:InsertNewLineTest.ts

示例3:

 const sAssertHtmlStructure = (label: string, expectedHtml: string) => Assertions.sAssertStructure(label, ApproxStructure.build((s) => {
   return s.element('body', {
     children: [
       ApproxStructure.fromHtml(expectedHtml),
       s.theRest()
     ]
   });
 }), editorBody);
开发者ID:tinymce,项目名称:tinymce,代码行数:8,代码来源:ContextMenuTest.ts

示例4:

      return Step.sync(function () {
        const body = editor.getBody();
        body.normalize(); // consolidate text nodes

        Assertions.assertStructure(
          'Asserting HTML structure of the element: ' + selector,
          ApproxStructure.fromHtml(expected),
          SelectorFind.descendant(Element.fromDom(body), selector).getOrDie('Nothing in the Editor matches selector: ' + selector)
        );
      });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:10,代码来源:TableDialogTest.ts

示例5: function

 const sInsertTableTests = function (editor, tinyApis) {
   return GeneralSteps.sequence([
     tinyApis.sSetContent('<p><br></p><p>b</p>'),
     tinyApis.sSetCursor([0], 0),
     Toolbar.sClickButton('Insert table'),
     sAssertTableStructure(editor, ApproxStructure.fromHtml([
       '<table style="border-collapse: collapse; width: 100%;" border="1">',
       '<tbody>',
       '<tr>',
       '<td style="width: 50%;"><br></td>',
       '<td style="width: 50%;"><br></td>',
       '</tr>',
       '<tr>',
       '<td style="width: 50%;"><br></td>',
       '<td style="width: 50%;"><br></td>',
       '</tr>',
       '</tbody>',
       '</table>'
     ].join(''))
     )
   ]);
 };
开发者ID:abstask,项目名称:tinymce,代码行数:22,代码来源:ThemeTest.ts

示例6: ModernTheme

UnitTest.asynctest('browser.tinymce.core.keyboard.ArrowKeysTableTest', (success, failure) => {
    const browser = PlatformDetection.detect().browser;

    ModernTheme();

    const table = (html: string) => ApproxStructure.fromHtml('<table><tbody><tr><td>' + html + '</td></tr></tbody></table>');
    const block = ApproxStructure.fromHtml('<p><br></p>');
    const caret = (type: string) => {
      return ApproxStructure.fromHtml(`<p data-mce-caret="${type}" data-mce-bogus="all"><br data-mce-bogus="1"></p>`);
    };
    const visualCaret = (before: boolean) => {
      const caretClass = before ? 'mce-visual-caret-before' : 'mce-visual-caret';
      return ApproxStructure.fromHtml(`<div class="mce-visual-caret ${caretClass}" data-mce-bogus="all"></div>`);
    };

    const caretBefore = Fun.curry(caret, 'before');
    const caretAfter = Fun.curry(caret, 'after');
    const visualCaretBefore = Fun.curry(visualCaret, true);
    const visualCaretAfter = Fun.curry(visualCaret, false);
    const buildBody = (children) => ApproxStructure.build((s, str, arr) => s.element('body', { children }));

    TinyLoader.setup(function (editor, onSuccess, onFailure) {
      Pipeline.async({}, [
        Logger.t('FakeCaret before/after table', GeneralSteps.sequence(browser.isEdge() || browser.isFirefox() ? [
          Logger.t('Move fake caret left before table', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
            ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
            ActionChains.cContentKeystroke(Keys.left()),
            ApiChains.cAssertContentStructure(buildBody([ caretBefore(), table('1'), visualCaretBefore() ])),
            ApiChains.cAssertSelection([0], 0, [0], 0)
          ])),
          Logger.t('Move fake caret right after table', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
            ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
            ActionChains.cContentKeystroke(Keys.right()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), visualCaretAfter() ])),
            ApiChains.cAssertSelection([1], 0, [1], 0)
          ])),
          Logger.t('Move fake caret right after table then right again before other table', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table><table><tbody><tr><td>2</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), table('2') ])),
            ActionChains.cContentKeystroke(Keys.right()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), table('2'), visualCaretAfter() ])),
            ApiChains.cAssertSelection([1], 0, [1], 0),
            ActionChains.cContentKeystroke(Keys.right()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), caretBefore(), table('2'), visualCaretBefore() ])),
            ApiChains.cAssertSelection([1], 0, [1], 0)
          ])),
          Logger.t('Move fake caret left before table then left again after other table', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table><table><tbody><tr><td>2</td></tr></tbody></table>'),
            ApiChains.cSetCursor([1, 0, 0, 0, 0], 0),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), table('2') ])),
            ActionChains.cContentKeystroke(Keys.left()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), caretBefore(), table('2'), visualCaretBefore() ])),
            ApiChains.cAssertSelection([1], 0, [1], 0),
            ActionChains.cContentKeystroke(Keys.left()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), table('2'), visualCaretAfter() ])),
            ApiChains.cAssertSelection([1], 0, [1], 0)
          ])),
          Logger.t('Move fake up for when table is first element', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
            ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
            ActionChains.cContentKeystroke(Keys.up()),
            ApiChains.cAssertContentStructure(buildBody([ block, table('1') ])),
            ApiChains.cAssertSelection([0], 0, [0], 0)
          ])),
          Logger.t('Move fake down for when table is last element', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
            ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
            ActionChains.cContentKeystroke(Keys.down()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), block ])),
            ApiChains.cAssertSelection([1], 0, [1], 0)
          ])),
          Logger.t('Move fake up for when table is first element but not when caret is not as start', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
            ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
            ActionChains.cContentKeystroke(Keys.up()),
            ApiChains.cAssertContentStructure(buildBody([ block, table('1') ])),
            ApiChains.cAssertSelection([0], 0, [0], 0)
          ])),
          Logger.t('Move fake down for when table is last element but not when caret is not as end', Chain.asStep(editor, [
            ApiChains.cFocus,
            ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
            ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
            ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
            ActionChains.cContentKeystroke(Keys.down()),
            ApiChains.cAssertContentStructure(buildBody([ table('1'), block ])),
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:ArrowKeysTableTest.ts

示例7:

 const visualCaret = (before: boolean) => {
   const caretClass = before ? 'mce-visual-caret-before' : 'mce-visual-caret';
   return ApproxStructure.fromHtml(`<div class="mce-visual-caret ${caretClass}" data-mce-bogus="all"></div>`);
 };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:4,代码来源:ArrowKeysTableTest.ts


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