本文整理汇总了TypeScript中@ephox/katamari.Arr.from方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Arr.from方法的具体用法?TypeScript Arr.from怎么用?TypeScript Arr.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Arr
的用法示例。
在下文中一共展示了Arr.from方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
suite.test('getClientRects from array', function () {
const viewElm = setupHtml('<b>a</b><b>b</b>');
const clientRects = Dimensions.getClientRects(Arr.from(viewElm.childNodes));
LegacyUnit.strictEqual(clientRects.length, 2);
LegacyUnit.equalDom(clientRects[0].node, viewElm.childNodes[0]);
LegacyUnit.equalDom(clientRects[1].node, viewElm.childNodes[1]);
});
示例2: CaretPosition
const removeElementAndReposition = (caretContainer: Node, pos: CaretPosition): CaretPosition => {
const parentNode = pos.container();
const newPosition = Arr.indexOf(Arr.from(parentNode.childNodes), caretContainer).map(function (index) {
return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos;
}).getOr(pos);
remove(caretContainer);
return newPosition;
};
示例3: function
const isAtomicContentEditableFalse = (node: Node): boolean => {
if (!isNonUiContentEditableFalse(node)) {
return false;
}
return Arr.foldl(Arr.from(node.getElementsByTagName('*')), function (result, elm) {
return result || isContentEditableTrue(elm);
}, false) !== true;
};
示例4:
const getFakeCaretTargets = (root: HTMLElement): HTMLElement[] => {
return Arr.filter(Arr.from(root.getElementsByTagName('*')), isFakeCaretTarget) as HTMLElement[];
};
示例5: function
const write = function (fragments: string[], elm: Element): Element {
const currentFragments = Arr.map(Arr.from(elm.childNodes), getOuterHtml);
applyDiff(Diff.diff(currentFragments, fragments), elm);
return elm;
};
示例6: function
const filterByExtension = function (files: FileList) {
const re = new RegExp('(' + extensionsAccepted.split(/\s*,\s*/).join('|') + ')$', 'i');
return Arr.filter(Arr.from(files), (file) => re.test(file.name));
};
示例7:
const getImagesFromDataTransfer = (dataTransfer: DataTransfer) => {
const items = dataTransfer.items ? Arr.map(Arr.from(dataTransfer.items), (item) => item.getAsFile()) : [];
const files = dataTransfer.files ? Arr.from(dataTransfer.files) : [];
const images = Arr.filter(items.length > 0 ? items : files, (file) => /^image\/(jpeg|png|gif|bmp)$/.test(file.type));
return images;
};
示例8: function
const getAllImages = function (elm: HTMLElement): HTMLImageElement[] {
return elm ? Arr.from(elm.getElementsByTagName('img')) : [];
};