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


TypeScript dom-globals.document.body类代码示例

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


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

示例1: function

const openLink = function (target) {
  const link = document.createElement('a');
  link.target = '_blank';
  link.href = target.href;
  link.rel = 'noreferrer noopener';

  const nuEvt = document.createEvent('MouseEvents');
  nuEvt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

  document.body.appendChild(link);
  link.dispatchEvent(nuEvt);
  document.body.removeChild(link);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:13,代码来源:TinyCodeDupe.ts

示例2:

 const sAddTestDiv = Step.sync(function () {
   const div = document.createElement('div');
   div.innerHTML = 'xxx';
   div.contentEditable = 'true';
   div.id = testDivId;
   document.body.appendChild(div);
 });
开发者ID:tinymce,项目名称:tinymce,代码行数:7,代码来源:GetSelectionContentTest.ts

示例3: function

  const setup = function (success, failure) {
    const div = document.createElement('div');

    div.innerHTML = (
      '<div id="lists">' +
      '<ul><li>before</li></ul>' +
      '<ul id="inline"><li>x</li></ul>' +
      '<ul><li>after</li></ul>' +
      '</div>'
    );

    document.body.appendChild(div);

    EditorManager.init({
      selector: '#inline',
      inline: true,
      add_unload_trigger: false,
      skin: false,
      plugins: 'lists',
      disable_nodechange: true,
      init_instance_callback (editor) {
        Pipeline.async({}, Log.steps('TBA', 'Lists: Backspace delete inline tests', suite.toSteps(editor)), function () {
          teardown(editor, div);
          success();
        }, failure);
      },
      valid_styles: {
        '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,' +
        'margin,margin-top,margin-right,margin-bottom,margin-left,display,position,top,left,list-style-type'
      }
    });
  };
开发者ID:tinymce,项目名称:tinymce,代码行数:32,代码来源:BackspaceDeleteInlineTest.ts

示例4: function

const getImageSize = function (url, callback) {
  const img = document.createElement('img');

  function done(dimensions) {
    if (img.parentNode) {
      img.parentNode.removeChild(img);
    }

    callback(dimensions);
  }

  img.onload = function () {
    const width = parseIntAndGetMax(img.width, img.clientWidth);
    const height = parseIntAndGetMax(img.height, img.clientHeight);
    const dimensions = {width, height};
    done(Result.value(dimensions));
  };

  img.onerror = function () {
    done(Result.error(undefined));
  };

  const style = img.style;
  style.visibility = 'hidden';
  style.position = 'fixed';
  style.bottom = style.left = '0px';
  style.width = style.height = 'auto';

  document.body.appendChild(img);
  img.src = url;
};
开发者ID:tinymce,项目名称:tinymce,代码行数:31,代码来源:Utils.ts

示例5: function

export default function () {

  const button = document.createElement('button');
  button.innerHTML = 'Get all annotations';
  button.addEventListener('click', () => {
    // tslint:disable no-console
    console.log('annotations', tinymce.activeEditor.annotator.getAll('alpha'));
    // tslint:enable no-console
  });
  document.body.appendChild(button);

  tinymce.init({
    skin_url: '../../../../js/tinymce/skins/ui/oxide',
    selector: 'textarea.tinymce',
    toolbar: 'annotate-alpha',
    plugins: [ ],

    content_style: '.mce-annotation { background-color: darkgreen; color: white; }',

    setup: (editor: Editor) => {
      editor.ui.registry.addButton('annotate-alpha', {
        text: 'Annotate',
        onAction() {
          const comment = prompt('Comment with?');
          editor.annotator.annotate('alpha', {
            comment
          });
          editor.focus();
        },
        onSetup (btnApi) {
          editor.annotator.annotationChanged('alpha', (state, name, obj) => {
            btnApi.setDisabled(state);
          });
          return () => {};
        }
      });

      editor.on('init', () => {
        editor.annotator.register('alpha', {
          persistent: true,
          decorate: (uid, data) => {
            return {
              attributes: {
                'data-mce-comment': data.comment ? data.comment : '',
                'data-mce-author': data.author ? data.author : 'anonymous'
              }
            };
          }
        });
      });
    },

    menubar: false
  });
}
开发者ID:tinymce,项目名称:tinymce,代码行数:55,代码来源:AnnotationsDemo.ts

示例6: function

  const assertSpecificFontProp = function (fontProp, html, path, expected) {
    const div = document.createElement('div');
    const fontGetProp = fontProp === 'fontSize' ? FontInfo.getFontSize : FontInfo.getFontFamily;

    document.body.appendChild(div);
    div.innerHTML = html;
    const elm = Hierarchy.follow(Element.fromDom(div), path).getOrDie('oh no! ' + path.toString() + '  path was bad');
    const actual = fontGetProp(div, elm.dom());
    LegacyUnit.equal(
      actual,
      expected,
      'Doesn\'t match the expected specific element style'
    );
    div.parentNode.removeChild(div);
  };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:15,代码来源:FontInfoTest.ts

示例7: function

  suite.test('hasFocus', function (editor) {
    editor.focus();
    LegacyUnit.equal(editor.hasFocus(), true);

    const input = document.createElement('input');
    document.body.appendChild(input);

    input.focus();
    LegacyUnit.equal(editor.hasFocus(), false);

    editor.focus();
    LegacyUnit.equal(editor.hasFocus(), true);

    input.parentNode.removeChild(input);
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:15,代码来源:EditorTest.ts

示例8: none

  suite.asyncTest('getFontFamily should always return string even if display: none (firefox specific bug)', function (_, done) {
    const iframe = document.createElement('iframe');
    iframe.style.display = 'none';
    document.body.appendChild(iframe);

    iframe.addEventListener('load', function () {
      const fontFamily = FontInfo.getFontFamily(iframe.contentDocument.body, iframe.contentDocument.body.firstChild);
      LegacyUnit.equal(typeof fontFamily, 'string', 'Should always be a string');
      iframe.parentNode.removeChild(iframe);

      done();
    }, false);

    iframe.contentDocument.open();
    iframe.contentDocument.write('<html><body><p>a</p></body></html>');
    iframe.contentDocument.close();
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:17,代码来源:FontInfoTest.ts

示例9: Promise

  return new Promise(function (resolve) {
    let fileInput;

    fileInput = document.createElement('input');
    fileInput.type = 'file';
    fileInput.style.position = 'fixed';
    fileInput.style.left = 0;
    fileInput.style.top = 0;
    fileInput.style.opacity = 0.001;
    document.body.appendChild(fileInput);

    fileInput.onchange = function (e) {
      resolve(Array.prototype.slice.call(e.target.files));
    };

    fileInput.click();
    fileInput.parentNode.removeChild(fileInput);
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:18,代码来源:Picker.ts

示例10: function

      Step.async(function (next, die) {
        const iframe = document.createElement('iframe');
        iframe.style.display = 'none';
        document.body.appendChild(iframe);

        iframe.addEventListener('load', function () {
          try {
            const measured = BoxUtils.measureBox(iframe.contentDocument.body.firstChild, 'border');
            Assertions.assertEq('should return 0', 0, measured.top);
            iframe.parentNode.removeChild(iframe);
            next();
          } catch (e) {
            die('Should not throw error, ' + e.message);
          }
        }, false);

        iframe.contentDocument.open();
        iframe.contentDocument.write('<html><body><div>a</div></body></html>');
        iframe.contentDocument.close();
      })
开发者ID:danielpunkass,项目名称:tinymce,代码行数:20,代码来源:BoxUtilsMeasureBoxIframeDisplayNoneTest.ts


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