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


TypeScript dom-globals.HTMLElement类代码示例

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


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

示例1:

const getAttrib = (image: HTMLElement, name: string): string => {
  if (image.hasAttribute(name)) {
    return image.getAttribute(name);
  } else {
    return '';
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:ImageData.ts

示例2:

const getAbsoluteClientRect = (root: HTMLElement, element: HTMLElement, before: boolean): ClientRect => {
  const clientRect = GeomClientRect.collapse(element.getBoundingClientRect(), before);
  let docElm, scrollX, scrollY, margin, rootRect;

  if (root.tagName === 'BODY') {
    docElm = root.ownerDocument.documentElement;
    scrollX = root.scrollLeft || docElm.scrollLeft;
    scrollY = root.scrollTop || docElm.scrollTop;
  } else {
    rootRect = root.getBoundingClientRect();
    scrollX = root.scrollLeft - rootRect.left;
    scrollY = root.scrollTop - rootRect.top;
  }

  clientRect.left += scrollX;
  clientRect.right += scrollX;
  clientRect.top += scrollY;
  clientRect.bottom += scrollY;
  clientRect.width = 1;

  margin = element.offsetWidth - element.clientWidth;

  if (margin > 0) {
    if (before) {
      margin *= -1;
    }

    clientRect.left += margin;
    clientRect.right += margin;
  }

  return clientRect;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:33,代码来源:FakeCaret.ts

示例3: function

const setSelected = function (state: boolean, elm: HTMLElement) {
  if (state) {
    elm.setAttribute('data-mce-selected', 'inline-boundary');
  } else {
    elm.removeAttribute('data-mce-selected');
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:BoundarySelection.ts

示例4: normalizeCss

const normalizeStyle = (image: HTMLElement, normalizeCss: CssNormalizer) => {
  const attrValue = image.getAttribute('style');
  const value = normalizeCss(attrValue !== null ? attrValue : '');

  if (value.length > 0) {
    image.setAttribute('style', value);
    image.setAttribute('data-mce-style', value);
  } else {
    image.removeAttribute('style');
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:11,代码来源:ImageData.ts

示例5: Event

 Chain.op(function (elm: Element) {
   const element: HTMLElement = elm.dom();
   // NOTE we can't fake a paste event here.
   let event;
   if (Type.isFunction(Event)) {
     event = new Event(name, {
       bubbles: true,
       cancelable: true
     });
   } else { // support IE
     event = document.createEvent('Event');
     event.initEvent(name, true, true);
   }
   element.dispatchEvent(event);
 }),
开发者ID:tinymce,项目名称:tinymce,代码行数:15,代码来源:Utils.ts

示例6: function

 const showBlockCaretContainer = function (blockCaretContainer: HTMLElement) {
   if (blockCaretContainer.hasAttribute('data-mce-caret')) {
     CaretContainer.showCaretContainerBlock(blockCaretContainer);
     setRange(getRange()); // Removes control rect on IE
     editor.selection.scrollIntoView(blockCaretContainer[0]);
   }
 };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:SelectionOverrides.ts

示例7: function

const showBlockCaretContainer = function (editor: Editor, blockCaretContainer: HTMLElement) {
  if (blockCaretContainer.hasAttribute('data-mce-caret')) {
    CaretContainer.showCaretContainerBlock(blockCaretContainer);
    removeIeControlRect(editor);
    editor.selection.scrollIntoView(blockCaretContainer);
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:CaretContainerInput.ts

示例8: function

const getElmIndex = function (elm: HTMLElement) {
  const value = elm.getAttribute('data-mce-index');

  if (typeof value === 'number') {
    return '' + value;
  }

  return value;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:9,代码来源:Actions.ts

示例9: function

const measureElement = function (elm: HTMLElement) {
  const clientRect = elm.getBoundingClientRect();

  return toAbsolute({
    x: clientRect.left,
    y: clientRect.top,
    w: Math.max(elm.clientWidth, elm.offsetWidth),
    h: Math.max(elm.clientHeight, elm.offsetHeight)
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:10,代码来源:Measure.ts

示例10: getSelectedImage

const insertOrUpdateImage = (editor: Editor, data: ImageData) => {
  const image = getSelectedImage(editor);
  if (image) {
    if (data.src) {
      writeImageDataToSelection(editor, data);
    } else {
      deleteImage(editor, image);
    }
  } else if (data.src) {
    insertImageAtCaret(editor, data);
  }
};
开发者ID:tinymce,项目名称:tinymce,代码行数:12,代码来源:ImageSelection.ts


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