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