本文整理汇总了TypeScript中@ephox/katamari.Option.from方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Option.from方法的具体用法?TypeScript Option.from怎么用?TypeScript Option.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Option
的用法示例。
在下文中一共展示了Option.from方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const getToolbarIconButton = (clazz, editor) => {
const icons = editor.ui.registry.getAll().icons;
const optOxideIcon = Option.from(icons[clazz]);
return optOxideIcon.fold(
() => UiDomFactory.dom('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item ${prefix}-icon-' + clazz + ' ${prefix}-icon"></span>'),
(icon) => UiDomFactory.dom('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item">' + icon + '</span>')
);
};
示例2: function
return function (rootElm, elm) {
return Option.from(elm)
.map(Element.fromDom)
.filter(Node.isElement)
.bind(function (element: any) {
return getSpecifiedFontProp(propName, rootElm, element.dom())
.or(getComputedFontProp(propName, element.dom()));
})
.getOr('');
};
示例3:
}, (rgbForm) => {
Representing.setValue(rgbForm, {
hex: Option.from(m[1]).getOr('')
});
// So not the way to do this.
Form.getField(rgbForm, 'hex').each((hexField) => {
AlloyTriggers.emit(hexField, NativeEvents.input());
});
});
示例4: bodyElement
const fixedToolbarAnchor = (): AnchorSpec => ({
anchor: 'node',
root: bodyElement(),
node: Option.from(bodyElement()),
bubble: Bubble.nu(-12, -12, bubbleAlignments),
layouts: {
onRtl: () => [ LayoutInside.northeast ],
onLtr: () => [ LayoutInside.northwest ]
}
});
示例5:
select: (value) => {
const optCurrentRgb = Option.from(getCurrentColor(editor, format));
return optCurrentRgb.bind((currentRgb) => {
return RgbaColour.fromString(currentRgb).map((rgba) => {
const currentHex = HexColour.fromRgba(rgba).value();
// note: value = '#FFFFFF', currentHex = 'ffffff'
return Strings.contains(value.toLowerCase(), currentHex);
});
}).getOr(false);
},
示例6:
}).orThunk(() => {
if (isSystemFontStack(font)) {
return Option.from({
title: 'System Font',
format: font
});
} else {
return Option.none();
}
});
示例7: return
return (rootElm: Element, elm: Node): string => {
return Option.from(elm)
.map(SugarElement.fromDom)
.filter(SugarNode.isElement)
.bind((element: any) => {
return getSpecifiedFontProp(propName, rootElm, element.dom())
.or(getComputedFontProp(propName, element.dom()));
})
.getOr('');
};
示例8: function
const scrollBounds = function () {
const rects = Rectangles.getRectangles(cWin);
return Option.from(rects[0]).bind(function (rect) {
const viewTop = rect.top() - socket.dom().scrollTop;
const outside = viewTop > outerWindow.innerHeight + VIEW_MARGIN || viewTop < -VIEW_MARGIN;
return outside ? Option.some({
top: Fun.constant(viewTop),
bottom: Fun.constant(viewTop + rect.height())
}) : Option.none();
});
};
示例9: function
const focusInput = function (dialog) {
const inputs = SelectorFilter.descendants(dialog.element(), 'input');
const optInput = Option.from(inputs[spec.state.currentScreen.get()]);
optInput.each(function (input) {
dialog.getSystem().getByDom(input).each(function (inputComp) {
AlloyTriggers.dispatchFocus(dialog, inputComp.element());
});
});
const dotitems = memDots.get(dialog);
Highlighting.highlightAt(dotitems, spec.state.currentScreen.get());
};
示例10:
const getTextContent = (editor: Editor): string => {
return Option.from(editor.selection.getRng()).map((rng) => {
const bin = editor.dom.add(editor.getBody(), 'div', {
'data-mce-bogus': 'all',
'style': 'overflow: hidden; opacity: 0;'
}, rng.cloneContents());
const text = Zwsp.trim(bin.innerText);
editor.dom.remove(bin);
return text;
}).getOr('');
};