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


TypeScript Element.fromDom方法代码示例

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


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

示例1: TinyApis

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

    // TODO: Consider testing collapse sections.
    const sTestWordGrabIfCollapsed = Logger.t(
      'Should word grab with a collapsed selection',
      GeneralSteps.sequence([
        // '<p>This |is| the first paragraph</p><p>This is the second.</p>'
        tinyApis.sSetContent('<p>This is the first paragraph here</p><p>This is the second.</p>'),
        tinyApis.sSetSelection([ 0, 0 ], 'This is the first p'.length, [ 0, 0 ], 'This is the first p'.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'one-paragraph' }),
        sAssertHtmlContent(tinyApis, [
          `<p>This is the first <span data-test-anything="one-paragraph" data-mce-annotation="test-annotation" data-mce-annotation-uid="test-uid" class="mce-annotation">paragraph</span> here</p>`,
          '<p>This is the second.</p'
        ]),

        tinyApis.sAssertSelection([ 0 ], 1, [ 0 ], 2)
      ])
    );

    const sTestCanAnnotateDirectParentOfRoot = Logger.t(
      'Should be able to annotate a direct parent of the body (e.g. an empty paragraph)',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>First</p><p><br/></p><p>Third</p>'),
        tinyApis.sSetSelection([ 1 ], 0, [ 1 ], 0),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'empty-paragraph' }),
        sAssertHtmlContent(tinyApis, [
          '<p>First</p>',
          '<p><span data-test-anything="empty-paragraph" data-mce-annotation="test-annotation" data-mce-annotation-uid="test-uid" class="mce-annotation"><br /></span></p>',
          '<p>Third</p>'
        ]),
      ])
    );

    const sTestCanAnnotateBeforeTwoNonBreakingSpaces = Logger.t(
      'Should annotate when the cursor is collapsed before two nbsps',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Annotation here &nbsp;&nbsp;, please</p>'),
        tinyApis.sSetCursor([ 0, 0 ], 'Annotation here '.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
        Assertions.sAssertStructure(
          'Checking body element',
          ApproxStructure.build((s, str, arr) => {
            return s.element('body', {
              children: [
                s.element('p', {
                  children: [
                    s.text( str.is('Annotation here ') ),
                    s.element('span', {
                      classes: [ arr.has('mce-annotation') ],
                      html: str.is('&nbsp;')
                    }),
                    s.text( str.is('\u00A0\u00A0, please'))
                  ]
                })
              ]
            });
          }),
          Element.fromDom(editor.getBody())
        )
      ])
    );

    const sTestCanAnnotateWithinTwoNonBreakingSpaces = Logger.t(
      'Should annotate when the cursor is collapsed between two nbsps',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Annotation here &nbsp;&nbsp;, please</p>'),
        tinyApis.sSetCursor([ 0, 0 ], 'Annotation here  '.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
        Assertions.sAssertStructure(
          'Checking body element',
          ApproxStructure.build((s, str, arr) => {
            return s.element('body', {
              children: [
                s.element('p', {
                  children: [
                    s.text( str.is('Annotation here \u00A0') ),
                    s.element('span', {
                      classes: [ arr.has('mce-annotation') ],
                      html: str.is('&nbsp;')
                    }),
                    s.text( str.is('\u00A0, please'))
                  ]
                })
              ]
            });
          }),
          Element.fromDom(editor.getBody())
        )
      ])
    );

    const sTestCanAnnotateAfterTwoNonBreakingSpaces = Logger.t(
      'Should annotate when the cursor is collapsed after two nbsps',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Annotation here &nbsp;&nbsp;, please</p>'),
        tinyApis.sSetCursor([ 0, 0 ], 'Annotation here   '.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
        Assertions.sAssertStructure(
          'Checking body element',
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:AnnotateTest.ts

示例2: function

 }, function (e) {
   return Compare.eq(e, Element.fromDom(editor.getBody()));
 });
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:HeadingSlider.ts

示例3: getPositionsBelow

 return Chain.mapper(function (scope) {
   const container = Hierarchy.follow(Element.fromDom(scope.get()), path).getOrDie();
   const pos = CaretPosition(container.dom(), offset);
   return getPositionsBelow(scope.get(), pos);
 });
开发者ID:abstask,项目名称:tinymce,代码行数:5,代码来源:LineReaderTest.ts

示例4: function

 const message = function () {
   const actual = Element.fromDom(actElement);
   const actPath = Hierarchy.path(root, actual).getOrDie('could not find path to root');
   return 'Expected path: ' + JSON.stringify(expPath) + '.\nActual path: ' + JSON.stringify(actPath);
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:5,代码来源:SelectionBookmarkIframeEditorTest.ts

示例5: function

const get = function (editor: Editor, container?) {
  return editor.inline ? ResizeWire.body(Util.getBody(editor), createContainer()) : ResizeWire.only(Element.fromDom(editor.getDoc()));
};
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:TableWire.ts

示例6: function

const store = function (editor) {
  const newBookmark = shouldStore(editor) ? getBookmark(Element.fromDom(editor.getBody())) : Option.none();

  editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;
};
开发者ID:abstask,项目名称:tinymce,代码行数:5,代码来源:SelectionBookmark.ts

示例7: function

 return Arr.bind(ranges, function (range) {
   const node = RangeNodes.getSelectedNode(range);
   return node ? [ Element.fromDom(node) ] : [];
 });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:4,代码来源:MultiRange.ts

示例8:

 const sAssertHtmlStructure = (label, expectedHtml) => Chain.asStep({editor}, [ NamedChain.read('editor', Chain.op((editor) => {
   const elm = Replication.deep(Element.fromDom(editor.getBody()));
   Arr.each(SelectorFilter.descendants(elm, '*[data-mce-bogus="all"]'), Remove.remove);
   const actualHtml = Html.get(elm);
   Assertions.assertHtmlStructure(label, `<body>${expectedHtml}</body>`, `<body>${actualHtml}</body>`);
 }))]);
开发者ID:tinymce,项目名称:tinymce,代码行数:6,代码来源:ContextToolbarTest.ts

示例9: function

const insertBrBefore = function (editor, inline) {
  const br = Element.fromTag('br');
  Insert.before(Element.fromDom(inline), br);
  editor.undoManager.add();
};
开发者ID:abstask,项目名称:tinymce,代码行数:5,代码来源:InsertBr.ts

示例10: function

 FieldSchema.state('body', function (spec) {
   return Element.fromDom(
     spec.socket.dom().ownerDocument.body
   );
 }),
开发者ID:danielpunkass,项目名称:tinymce,代码行数:5,代码来源:MobileSchema.ts


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