本文整理汇总了TypeScript中@ephox/katamari.Options.cat方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Options.cat方法的具体用法?TypeScript Options.cat怎么用?TypeScript Options.cat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Options
的用法示例。
在下文中一共展示了Options.cat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: select
export const createChoiceItems = (items: SingleMenuItemApi[], onItemValueHandler: (itemValue: string) => void, columns: 'auto' | number, itemPresets: Types.PresetItemTypes, itemResponse: ItemResponse, select: (value: string) => boolean, providersBackstage: UiFactoryBackstageProviders) => {
return Options.cat(
Arr.map(items, (item) => {
if (item.type === 'choiceitem') {
return BridgeMenu.createChoiceMenuItem(item).fold(
handleError,
(d: BridgeMenu.ChoiceMenuItem) => Option.some(renderChoiceItem(d, columns === 1, itemPresets, onItemValueHandler, select(item.value), itemResponse, providersBackstage))
);
} else {
return Option.none();
}
})
);
};
示例2: menuHasIcons
export const createPartialMenu = (value: string, items: SingleMenuItemApi[], itemResponse: ItemResponse, backstage: UiFactoryBackstage): Partial<MenuTypes.MenuSpec> => {
const hasIcons = menuHasIcons(items);
const alloyItems = Options.cat(
Arr.map(items, (item: SingleMenuItemApi) => {
const createItem = (i: SingleMenuItemApi) => createMenuItemFromBridge(i, itemResponse, backstage, hasIcons);
if (item.type === 'nestedmenuitem' && item.getSubmenuItems().length <= 0) {
return createItem(Merger.merge(item, {disabled: true}));
} else {
return createItem(item);
}
})
);
return createPartialMenuWithAlloyItems(value, hasIcons, alloyItems, 1, 'normal');
};
示例3:
const structureItem = (optText: Option<string>, optIcon: Option<string>) => (s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-collection__item') ],
children: Options.cat([
optIcon.map((icon) => s.element('div', {
classes: [ arr.has('tox-collection__item-icon') ],
html: str.is(icon)
})),
optText.map((text) => s.element('div', {
classes: [ arr.has('tox-collection__item-label') ],
html: str.is(text)
}))
])
});
};
示例4: getInitialData
const makeDialog = (settings: LinkDialogInfo, onSubmit, editorSettings): Types.Dialog.DialogApi<LinkDialogData> => {
const urlInput: Types.Dialog.BodyComponentApi[] = [
{
name: 'url',
type: 'urlinput',
filetype: 'file',
label: 'URL'
}
];
const displayText = settings.anchor.text.map<Types.Dialog.BodyComponentApi>(() => (
{
name: 'text',
type: 'input',
label: 'Text to display'
}
)).toArray();
const titleText: Types.Dialog.BodyComponentApi[] = settings.flags.titleEnabled ? [
{
name: 'title',
type: 'input',
label: 'Title'
}
] : [];
const defaultTarget: Option<string> = Settings.hasDefaultLinkTarget(editorSettings) ? Option.some(Settings.getDefaultLinkTarget(editorSettings)) : Option.none();
const initialData = getInitialData(settings, defaultTarget);
const dialogDelta = DialogChanges.init(initialData, settings);
const catalogs = settings.catalogs;
const body: Types.Dialog.PanelApi = {
type: 'panel',
items: Arr.flatten([
urlInput,
displayText,
titleText,
Options.cat<Types.Dialog.BodyComponentApi>([
catalogs.anchor.map(ListOptions.createUi('anchor', 'Anchors')),
catalogs.rels.map(ListOptions.createUi('rel', 'Rel')),
catalogs.targets.map(ListOptions.createUi('target', 'Open link in...')),
catalogs.link.map(ListOptions.createUi('link', 'Link list')),
catalogs.classes.map(ListOptions.createUi('linkClass', 'Class'))
])
])
};
return {
title: 'Insert/Edit Link',
size: 'normal',
body,
buttons: [
{
type: 'cancel',
name: 'cancel',
text: 'Cancel'
},
{
type: 'submit',
name: 'save',
text: 'Save',
primary: true
}
],
initialData,
onChange: (api: Types.Dialog.DialogInstanceApi<LinkDialogData>, {name}) => {
dialogDelta.onChange(api.getData, { name }).each((newData) => {
api.setData(newData);
});
},
onSubmit
};
};