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


TypeScript Element.fromHtml方法代码示例

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


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

示例1:

 Logger.t('isInlineTarget with various editor settings', Step.sync(function () {
   Assertions.assertEq('Links should be inline target', true, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<a href="a">').dom()));
   Assertions.assertEq('Code should be inline target', true, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<code>').dom()));
   Assertions.assertEq('None link anchor should not be inline target', false, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<a>').dom()));
   Assertions.assertEq('Bold should not be inline target', false, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<b>').dom()));
   Assertions.assertEq('Bold should be inline target if configured', true, InlineUtils.isInlineTarget(createFakeEditor({
     inline_boundaries_selector: 'b'
   }), Element.fromHtml('<b>').dom()));
   Assertions.assertEq('Italic should be inline target if configured', true, InlineUtils.isInlineTarget(createFakeEditor({
     inline_boundaries_selector: 'b,i'
   }), Element.fromHtml('<i>').dom()));
 })),
开发者ID:danielpunkass,项目名称:tinymce,代码行数:12,代码来源:InlineUtilsTest.ts

示例2: function

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

    return Waiter.sTryUntil('Wait for structure check',
      Assertions.sAssertStructure('Assert equal', expected, actual),
      10, 500);
  };
开发者ID:abstask,项目名称:tinymce,代码行数:7,代码来源:DataToHtmlTest.ts

示例3: function

 Logger.sync('getInfo ... ' + scenario.label + ', link: ' + scenario.linkHtml, function () {
   editorState.start.set(Element.fromHtml(scenario.linkHtml).dom());
   editorState.content.set(scenario.selection);
   const info = LinkBridge.getInfo(editor);
   RawAssertions.assertEq('Checking getInfo (link)', scenario.expected, Objects.narrow(info, [ 'url', 'text', 'target', 'title' ]));
   RawAssertions.assertEq('Checking link is set', true, info.link.isSome());
 });
开发者ID:abstask,项目名称:tinymce,代码行数:7,代码来源:LinkBridgeTest.ts

示例4: return

 onSetup: (api) => {
   console.log('onSetup ' + name);
   const box = Element.fromHtml('<div style="width: ' + width + 'px; background: ' + background + ';"></div>');
   api.element().appendChild(box.dom());
   return () => {
     api.element().removeChild(box.dom());
   };
 },
开发者ID:tinymce,项目名称:tinymce,代码行数:8,代码来源:FullDemo.ts

示例5:

 Chain.op((editor) => {
   const wrapperElm = Element.fromHtml('<div class="tinymce-editor"></div>');
   Selectors.one('#' + editor.id).each((textareaElm) => {
     Insert.wrap(textareaElm, wrapperElm);
   });
   Selectors.one('.tinymce-mobile-outer-container').each((editorElm) => {
     Insert.wrap(editorElm, wrapperElm);
   });
 }),
开发者ID:tinymce,项目名称:tinymce,代码行数:9,代码来源:EditorRemoveTest.ts

示例6:

      Logger.t('getParentCaretContainer', Step.sync(function () {
        const body = Element.fromHtml('<div><span id="_mce_caret">a</span></div>');
        const caret = Element.fromDom(body.dom().firstChild);

        Assertions.assertDomEq('Should be caret element on child', caret, Element.fromDom(CaretFormat.getParentCaretContainer(body.dom(), caret.dom().firstChild)));
        Assertions.assertDomEq('Should be caret element on self', caret, Element.fromDom(CaretFormat.getParentCaretContainer(body.dom(), caret.dom())));
        Assertions.assertEq('Should not be caret element', null, CaretFormat.getParentCaretContainer(body, Element.fromTag('span').dom()));
        Assertions.assertEq('Should not be caret element', null, CaretFormat.getParentCaretContainer(caret.dom(), caret.dom()));
      })),
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:9,代码来源:CaretFormatTest.ts

示例7:

 return Chain.binder(function (_) {
   const tableElm = Element.fromHtml(html);
   const startElm = Hierarchy.follow(tableElm, startPath).getOrDie();
   const endElm = Hierarchy.follow(tableElm, endPath).getOrDie();
   return SimpleTableModel.subsection(SimpleTableModel.fromDom(tableElm), startElm, endElm).fold(
     Fun.constant(Result.error('Failed to get the subsection')),
     Result.value
   );
 });
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:9,代码来源:SimpleTableModelTest.ts

示例8: function

const paddEmptyBlock = function (elm) {
  if (Empty.isEmpty(elm)) {
    const br = Element.fromHtml('<br data-mce-bogus="1">');
    Remove.empty(elm);
    Insert.append(elm, br);
    return Option.some(CaretPosition.before(br.dom()));
  } else {
    return Option.none();
  }
};
开发者ID:tinymce,项目名称:tinymce,代码行数:10,代码来源:DeleteElement.ts

示例9:

    return Chain.mapper(function () {
      const elm = Element.fromHtml(html);
      const sc = Hierarchy.follow(elm, startPath).getOrDie();
      const ec = Hierarchy.follow(elm, endPath).getOrDie();
      const rng = document.createRange();

      rng.setStart(sc.dom(), startOffset);
      rng.setEnd(ec.dom(), endOffset);

      return TableDeleteAction.getActionFromRange(elm, rng);
    });
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:11,代码来源:TableDeleteActionTest.ts

示例10: createLocation

    return Step.sync(function () {
      const elm = Element.fromHtml('<div>' + html + '</div>');
      const location = createLocation(elm, elementPath, offset);
      const caret = Cell(null);

      Assertions.assertEq('Should be a valid location: ' + html, true, location.isSome());

      const pos = BoundaryCaret.renderCaret(caret, location.getOrDie()).getOrDie();
      Assertions.assertHtml('Should be equal html', expectedHtml, elm.dom().innerHTML);

      const container = Hierarchy.follow(elm, expectedPath);
      Assertions.assertDomEq('Should be equal nodes', container.getOrDie(), Element.fromDom(pos.container()));
    });
开发者ID:abstask,项目名称:tinymce,代码行数:13,代码来源:BoundaryCaretTest.ts


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