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