本文整理匯總了TypeScript中@ephox/sugar.Traverse.child方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Traverse.child方法的具體用法?TypeScript Traverse.child怎麽用?TypeScript Traverse.child使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/sugar.Traverse
的用法示例。
在下文中一共展示了Traverse.child方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getAttr
const identify = (editor: Editor, annotationName: Option<string>): Option<{uid: string, name: string, elements: any[]}> => {
const rng = editor.selection.getRng();
const start = Element.fromDom(rng.startContainer);
const root = Element.fromDom(editor.getBody());
const selector = annotationName.fold(
() => '.' + Markings.annotation(),
(an) => `[${Markings.dataAnnotation()}="${an}"]`
);
const newStart = Traverse.child(start, rng.startOffset).getOr(start);
const closest = SelectorFind.closest(newStart, selector, (n) => {
return Compare.eq(n, root);
});
const getAttr = (c, property: string): Option<any> => {
if (Attr.has(c, property)) {
return Option.some(Attr.get(c, property));
} else {
return Option.none();
}
};
return closest.bind((c) => {
return getAttr(c, `${Markings.dataAnnotationId()}`).bind((uid) =>
getAttr(c, `${Markings.dataAnnotation()}`).map((name) => {
const elements = findMarkers(editor, uid);
return {
uid,
name,
elements
};
})
);
});
};
示例2: resolve
return Option.from(container).map(SugarElement.fromDom).map((elm) => {
return !real || !rng.collapsed ? Traverse.child(elm, resolve(elm, offset)).getOr(elm) : elm;
}).bind((elm) => SugarNode.isElement(elm) ? Option.some(elm) : Traverse.parent(elm)).map((elm: any) => elm.dom()).getOr(root);
示例3:
find: (comp: AlloyComponent) => {
return Traverse.child(comp.element(), index).bind((element) => {
return comp.getSystem().getByDom(element).toOption();
});
}