本文整理汇总了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)
);
};