Esempio n. 1
0
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 }));
};
Esempio n. 2
0
const lookup = (compInSystem: AlloyComponent, footerButtons: DialogMemButton[], buttonName: string) => {
  return Arr.find(footerButtons, (button) => {
    return button.name === buttonName;
  }).bind((memButton) => {
    return memButton.memento.getOpt(compInSystem);
  });
};
Esempio n. 3
0
 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);
   });
 })
Esempio n. 4
0
 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));
   });
 })
Esempio n. 5
0
 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
     });
   });
 };
Esempio n. 6
0
 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));
   });
 })
Esempio n. 7
0
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;
};
Esempio n. 10
0
    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());
    });