當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。