本文整理汇总了TypeScript中@ephox/sugar.Traverse.children方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Traverse.children方法的具体用法?TypeScript Traverse.children怎么用?TypeScript Traverse.children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Traverse
的用法示例。
在下文中一共展示了Traverse.children方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const getChildrenUntilBlockBoundary = (block: Element) => {
const children = Traverse.children(block);
return Arr.findIndex(children, ElementType.isBlock).fold(
() => children,
(index) => children.slice(0, index)
);
};
示例2: parser
const parseList: Parser = (depth: number, itemSelection: Option<ItemSelection>, selectionState: Cell<boolean>, list: Element): Entry[] => {
return Arr.bind(Traverse.children(list), (element) => {
const parser = isList(element) ? parseList : parseItem;
const newDepth = depth + 1;
return parser(newDepth, itemSelection, selectionState, element);
});
};
示例3: context
const processElement = (elem) => {
const ctx = context(editor, elem, 'span', Node.name(elem));
switch (ctx) {
case ChildContext.InvalidChild: {
finishWrapper();
const children = Traverse.children(elem);
processElements(children);
finishWrapper();
break;
}
case ChildContext.Valid: {
const w = getOrOpenWrapper();
Insert.wrap(elem, w);
break;
}
// INVESTIGATE: Are these sensible things to do?
case ChildContext.Skipping:
case ChildContext.Existing:
case ChildContext.Caret: {
// Do nothing.
}
}
};
示例4: function
const clamp = function (offset, element) {
const max = Node.isText(element) ? Text.get(element).length : Traverse.children(element).length + 1;
if (offset > max) {
return max;
} else if (offset < 0) {
return 0;
}
return offset;
};
示例5: function
const getChildrenUntilBlockBoundary = function (block) {
const children = Traverse.children(block);
return Arr.findIndex(children, ElementType.isBlock).fold(
function () {
return children;
},
function (index) {
return children.slice(0, index);
}
);
};
示例6: function
const getTableCaptionDeltaY = function (elm) {
if (browser.isFirefox() && Node.name(elm) === 'table') {
return firstElement(Traverse.children(elm)).filter(function (elm) {
return Node.name(elm) === 'caption';
}).bind(function (caption) {
return firstElement(Traverse.nextSiblings(caption)).map(function (body) {
const bodyTop = body.dom().offsetTop;
const captionTop = caption.dom().offsetTop;
const captionHeight = caption.dom().offsetHeight;
return bodyTop <= captionTop ? -captionHeight : 0;
});
}).getOr(0);
} else {
return 0;
}
};
示例7: function
const isActive = function () {
return Traverse.children(container).length > 0;
};
示例8: function
const hasOnlyOneChild = function (elm) {
return Traverse.children(elm).length === 1;
};
示例9: function
const isPaddedElement = function (elm) {
return Arr.filter(Traverse.children(elm), isPaddingContents).length === 1;
};
示例10: isList
const parseList: Parser = (depth: number, itemSelection: Option<ItemTuple>, selectionState: Cell<boolean>, list: Element): Entry[] => {
const newDepth = depth + 1;
return Arr.bind(Traverse.children(list), (child) =>
isList(child) ? parseList(newDepth, itemSelection, selectionState, child) : parseItem(newDepth, itemSelection, selectionState, child)
);
};