本文整理汇总了TypeScript中@ephox/sugar.PredicateFind.closest方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PredicateFind.closest方法的具体用法?TypeScript PredicateFind.closest怎么用?TypeScript PredicateFind.closest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.PredicateFind
的用法示例。
在下文中一共展示了PredicateFind.closest方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const sketch = function (realm, editor): SketchSpec {
const spec = {
onChange (value) {
editor.execCommand('FormatBlock', null, headings[value].toLowerCase());
},
getInitialValue () {
const node = editor.selection.getStart();
const elem = Element.fromDom(node);
const heading = PredicateFind.closest(elem, (e) => {
const nodeName = Node.name(e);
return Arr.contains(headings, nodeName);
}, function (e) {
return Compare.eq(e, Element.fromDom(editor.getBody()));
});
return heading.bind((elm) => Arr.indexOf(headings, Node.name(elm))).getOr(0);
}
};
return ToolbarWidgets.button(realm, 'heading', function () {
return [
UiDomFactory.spec('<span class="${prefix}-toolbar-button ${prefix}-icon-small-heading ${prefix}-icon"></span>'),
makeSlider(spec),
UiDomFactory.spec('<span class="${prefix}-toolbar-button ${prefix}-icon-large-heading ${prefix}-icon"></span>')
];
});
};
示例2:
return optStart.map(function (start) {
const inline = PredicateFind.closest(start, (elem) => Css.getRaw(elem, 'font-size').isSome(), isRoot)
.bind((elem) => Css.getRaw(elem, 'font-size'));
return inline.getOrThunk(function () {
return Css.get(start, 'font-size');
});
}).getOr('');
示例3: getProperty
const getSpecifiedFontProp = (propName: string, rootElm: Element, elm: HTMLElement): Option<string> => {
const getProperty = (elm) => Css.getRaw(elm, propName);
const isRoot = (elm) => Compare.eq(SugarElement.fromDom(rootElm), elm);
return PredicateFind.closest(SugarElement.fromDom(elm), (elm) => getProperty(elm).isSome(), isRoot).bind(getProperty);
};
示例4:
const isEditable = (target: Element) => {
return PredicateFind.closest(target, (elm) => {
return NodeType.isContentEditableTrue(elm.dom()) || NodeType.isContentEditableFalse(elm.dom());
}).exists((elm) => NodeType.isContentEditableTrue(elm.dom()));
};
示例5: function
const getParentBlock = function (rootNode, elm) {
return Compare.contains(rootNode, elm) ? PredicateFind.closest(elm, function (element) {
return ElementType.isTextBlock(element) || ElementType.isListItem(element);
}, isBeforeRoot(rootNode)) : Option.none();
};
示例6:
.bind((elm) => PredicateFind.closest(elm, Node.isElement))
示例7:
const getClosestTargetBlock = (pos: CaretPosition, root: Element) => {
const isRoot = Fun.curry(Compare.eq, root);
return PredicateFind.closest(Element.fromDom(pos.container()), ElementType.isBlock, isRoot).filter(isTarget);
};
示例8:
() => PredicateFind.closest(sugarNode, (elem) => {
return Node.name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom());
}, isRoot).isSome(),