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