本文整理汇总了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);
}
};