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