本文整理汇总了TypeScript中@ephox/sugar.SelectorFind.closest方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SelectorFind.closest方法的具体用法?TypeScript SelectorFind.closest怎么用?TypeScript SelectorFind.closest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.SelectorFind
的用法示例。
在下文中一共展示了SelectorFind.closest方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
predicate: (node) => {
const sugarNode = Element.fromDom(node);
const textBlockElementsMap = editor.schema.getTextBlockElements();
const isRoot = (elem) => elem.dom() === editor.getBody();
return SelectorFind.closest(sugarNode, 'table', isRoot).fold(
() => PredicateFind.closest(sugarNode, (elem) => {
return Node.name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom());
}, isRoot).isSome(),
() => false
);
},
示例2:
SelectorFind.descendant(comp.element(), '.' + MenuButtonClasses.Active).each((activeButton) => {
SelectorFind.closest(se.event().target(), '.' + MenuButtonClasses.Button).each((hoveredButton) => {
if (! Compare.eq(activeButton, hoveredButton)) {
// Now, find the components, and expand the hovered one, and close the active one
comp.getSystem().getByDom(activeButton).each((activeComp) => {
comp.getSystem().getByDom(hoveredButton).each((hoveredComp) => {
Dropdown.expand(hoveredComp);
Dropdown.close(activeComp);
Focusing.focus(hoveredComp);
});
});
}
});
});
示例3: renderTitle
const renderInlineHeader = (foo: WindowHeaderFoo, titleId: string, providersBackstage: UiFactoryBackstageProviders): AlloySpec => {
return Container.sketch({
dom: DomFactory.fromHtml('<div class="tox-dialog__header"></div>'),
components: [
renderTitle(foo, Option.some(titleId), providersBackstage),
renderClose(providersBackstage)
],
containerBehaviours: Behaviour.derive([
Dragging.config({
mode: 'mouse',
blockerClass: 'blocker',
getTarget (handle) {
return SelectorFind.closest(handle, '[role="dialog"]').getOrDie();
},
snaps: {
getSnapPoints: () => [ ],
leftAttr: 'data-drag-left',
topAttr: 'data-drag-top'
}
}),
])
});
};
示例4: 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
};
})
);
});
};
示例5:
const getClosestCell = (container, isRoot) => {
return SelectorFind.closest(Element.fromDom(container), 'td,th', isRoot);
};
示例6: function
return DomEvent.bind(scope, 'touchmove', function (event) {
SelectorFind.closest(event.target(), selector).filter(hasScroll).fold(function () {
event.raw().preventDefault();
}, Fun.noop);
});
示例7: function
const query = function (editor) {
const start = Element.fromDom(editor.selection.getStart());
return SelectorFind.closest(start, 'a');
};
示例8: f
const runOnItem = (f: (c: AlloyComponent, tgt: Element, itemValue: string) => void) => <T extends EventFormat>(comp: AlloyComponent, se: SimulatedEvent<T>) => {
SelectorFind.closest(se.event().target(), '[data-collection-item-value]').each((target) => {
f(comp, target, Attr.get(target, 'data-collection-item-value'));
});
};