本文整理匯總了TypeScript中@ephox/katamari.Option.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Option.default方法的具體用法?TypeScript Option.default怎麽用?TypeScript Option.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/katamari.Option
的用法示例。
在下文中一共展示了Option.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: return
return () => {
const fontFamily = editor.queryCommandValue('FontName');
const match = getMatchingValue();
const text = match.fold(() => fontFamily, (item) => item.title);
AlloyTriggers.emitWith(comp, updateMenuText, {
text
});
};
示例2: findClosestCorner
const getClosestCell = (getYAxisValue: GetAxisValue, isTargetCorner: IsTargetCorner, table: HTMLElement, x: number, y: number): Option<HTMLElement> => {
const cells = SelectorFilter.descendants(Element.fromDom(table), 'td,th,caption').map((e) => e.dom());
const corners = Arr.filter(getCorners(getYAxisValue, cells), (corner) => isTargetCorner(corner, y));
return findClosestCorner(corners, x, y).map((corner) => {
return corner.cell;
});
};
示例3: getAttr
return getAttr(c, `${Markings.dataAnnotationId()}`).bind((uid) =>
getAttr(c, `${Markings.dataAnnotation()}`).map((name) => {
const elements = findMarkers(editor, uid);
return {
uid,
name,
elements
};
})
示例4: normalizeNbsps
const normalizeNbspsInEditor = (editor: Editor) => {
const root = Element.fromDom(editor.getBody());
if (editor.selection.isCollapsed()) {
normalizeNbsps(root, CaretPosition.fromRangeStart(editor.selection.getRng())).each((pos) => {
editor.selection.setRng(pos.toRange());
});
}
};
示例5: findEntryDelegate
return Options.findMap(list, (item) => {
if (isGroup(item)) {
return findEntryDelegate(item.items, value);
} else if (item.value === value) {
return Option.some(item);
} else {
return Option.none();
}
});
示例6: findInlinePatternRec
const findNestedInlinePatterns = (dom: DOMUtils, patterns: InlinePattern[], rng: Range, space: boolean): InlinePatternMatch[] => {
if (rng.collapsed === false) {
return [];
}
const block = dom.getParent(rng.startContainer, dom.isBlock);
return findInlinePatternRec(dom, patterns, rng.startContainer, rng.startOffset - (space ? 1 : 0), block).getOr([]);
};
示例7: parseLists
const listsIndentation = (editor: Editor, lists: Element[], indentation: Indentation) => {
const entrySets: EntrySet[] = parseLists(lists, getItemSelection(editor));
Arr.each(entrySets, (entrySet) => {
indentSelectedEntries(entrySet.entries, indentation);
InsertAll.before(entrySet.sourceList, composeEntries(editor, entrySet.entries));
Remove.remove(entrySet.sourceList);
});
};
示例8: getInsertionPoint
const mergeBlockInto = (rootNode: Element, fromBlock: Element, toBlock: Element): Option<CaretPosition> => {
trimBr(true, fromBlock);
trimBr(false, toBlock);
return getInsertionPoint(fromBlock, toBlock).fold(
Fun.curry(sidelongBlockMerge, rootNode, fromBlock, toBlock),
Fun.curry(nestedBlockMerge, rootNode, fromBlock, toBlock)
);
};
示例9: nonEmptyAttr
const extractFromAnchor = (editor, settings, anchor: HTMLAnchorElement, selection) => {
const dom = editor.dom;
const onlyText = Utils.isOnlyTextSelected(selection.getContent());
const text: Option<string> = onlyText ? Option.some(Utils.getAnchorText(selection, anchor)) : Option.none();
const url: Option<string> = anchor ? Option.some(dom.getAttrib(anchor, 'href')) : Option.none();
const target: Option<string> = anchor ? Option.from(dom.getAttrib(anchor, 'target')) : Option.none();
const rel = nonEmptyAttr(dom, anchor, 'rel');
const linkClass = nonEmptyAttr(dom, anchor, 'class');
const title = nonEmptyAttr(dom, anchor, 'title');
return {
url,
text,
title,
target,
rel,
linkClass
};
};
示例10: getPicker
const getPickerTypes = (settings: Record<string, any>): boolean | Record<string, boolean> => {
const optFileTypes = Option.some(settings.file_picker_types).filter(isTruthy);
const optLegacyTypes = Option.some(settings.file_browser_callback_types).filter(isTruthy);
const optTypes = optFileTypes.or(optLegacyTypes).map(makeMap);
return getPicker(settings).fold(
() => false,
(_picker) => optTypes.fold<boolean | Record<string, boolean>>(
() => true,
(types) => Obj.keys(types).length > 0 ? types : false)
);
};