const getItemSelection = (editor: Editor): Option<ItemSelection> => { const selectedListItems = Arr.map(Selection.getSelectedListItems(editor), Element.fromDom); return Options.liftN([ Arr.find(selectedListItems, Fun.not(hasFirstChildList)), Arr.find(Arr.reverse(selectedListItems), Fun.not(hasFirstChildList)) ], (start, end) => ({ start, end })); };
const lookup = (compInSystem: AlloyComponent, footerButtons: DialogMemButton[], buttonName: string) => { return Arr.find(footerButtons, (button) => { return button.name === buttonName; }).bind((memButton) => { return memButton.memento.getOpt(compInSystem); }); };
Chain.async(function (container, next, die) { return Arr.find(editor.windowManager.getWindows(), function (win) { return container.dom().id === win._id; }).fold(() => die('Could not find popup window'), function (win) { next(win); }); })
Chain.on(function (container, next, die) { return Arr.find(editor.windowManager.getWindows(), function (win) { return container.dom().id === win._id; }).fold(die, function (win) { next(Chain.wrap(win)); }); })
const scanAndSet = (dialogApi: Types.Dialog.DialogInstanceApi<typeof initialData>, pattern: string) => { Arr.find(charMap, (group) => group.name === currentTab.get()).each((f) => { const items = Scan.scan(f, pattern); dialogApi.setData({ results: items }); }); };
AlloyEvents.run<SystemEvents.AlloySlotVisibilityEvent>(SystemEvents.slotVisibility(), (sidepanel, se) => { const data = se.event(); const optSidePanelSpec = Arr.find(specs, (config) => config.name === data.name()); optSidePanelSpec.each((sidePanelSpec) => { const handler = data.visible() ? sidePanelSpec.onShow : sidePanelSpec.onHide; handler(sidePanelSpec.getApi(sidepanel)); }); })
const maybeUrlize = function (editor, key) { return Arr.find(PluginUrls.urls, function (x) { return x.key === key; }).fold(function () { const getMetadata = editor.plugins[key].getMetadata; return typeof getMetadata === 'function' ? makeLink(getMetadata()) : key; }, function (x) { return makeLink({ name: x.name, url: 'https://www.tinymce.com/docs/plugins/' + x.key }); }); };
const getServiceErrorMsg = function (type) { return Arr.find(friendlyServiceErrors, function (error) { return error.type === type; }).fold( Fun.constant('Unknown service error'), function (error) { return error.message; } ); };
const getHttpErrorMsg = function (status) { const message = Arr.find(friendlyHttpErrors, function (error) { return status === error.code; }).fold( Fun.constant('Unknown ImageProxy error'), function (error) { return error.message; } ); return 'ImageProxy HTTP error: ' + message; };
return Step.sync(function () { state.set([]); const matches = MatchKeys.match(patterns, event); Assertions.assertEq('Should have some matches', true, matches.length > 0); Arr.find(matches, function (pattern) { return pattern.action(); }); Assertions.assertEq('Should have the expected state', expectedData, state.get()); });