本文整理匯總了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 '';
}
};
示例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;
};
示例3: function
const setSelected = function (state: boolean, elm: HTMLElement) {
if (state) {
elm.setAttribute('data-mce-selected', 'inline-boundary');
} else {
elm.removeAttribute('data-mce-selected');
}
};
示例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');
}
};
示例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);
}),
示例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]);
}
};
示例7: function
const showBlockCaretContainer = function (editor: Editor, blockCaretContainer: HTMLElement) {
if (blockCaretContainer.hasAttribute('data-mce-caret')) {
CaretContainer.showCaretContainerBlock(blockCaretContainer);
removeIeControlRect(editor);
editor.selection.scrollIntoView(blockCaretContainer);
}
};
示例8: function
const getElmIndex = function (elm: HTMLElement) {
const value = elm.getAttribute('data-mce-index');
if (typeof value === 'number') {
return '' + value;
}
return value;
};
示例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)
});
};
示例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);
}
};