How to use the @ephox/katamari.Arr.bind function in @ephox/katamari

To help you get started, we’ve selected a few @ephox/katamari examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / Autocompleter.ts View on Github external
const getCombinedItems = (triggerChar: string, matches: AutocompleteLookupData[]): ItemTypes.ItemSpec[] => {
    const columns = Options.findMap(matches, (m) => Option.from(m.columns)).getOr(1);

    return Arr.bind(matches, (match) => {
      const choices = match.items;

      return createAutocompleteItems(
        choices,
        match.matchText,
        (itemValue, itemMeta) => {
          const nr = editor.selection.getRng();
          getContext(editor.dom, nr, triggerChar).fold(
            // tslint:disable-next-line:no-console
            () => console.error('Lost context. Cursor probably moved'),
            ({ range }) => {
              const autocompleterApi: InlineContent.AutocompleterInstanceApi = {
                hide: () => {
                  cancelIfNecessary();
                },
                reload: (fetchOptions: Record) => {
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / BespokeSelect.ts View on Github external
const generateItem = (rawItem: FormatItem, response: IrrelevantStyleItemResponse, disabled: boolean, value: Option): Option => {
    const translatedText = backstage.shared.providers.translate(rawItem.title);
    if (rawItem.type === 'separator') {
      return Option.some({
        type: 'separator',
        text: translatedText
      });
    } else if (rawItem.type === 'submenu') {
      const items = Arr.bind(rawItem.getStyleItems(), (si) => validate(si, response, value));
      if (response === IrrelevantStyleItemResponse.Hide && items.length <= 0) {
        return Option.none();
      } else {
        return Option.some({
          type: 'nestedmenuitem',
          text: translatedText,
          disabled: items.length <= 0,
          getSubmenuItems: () => Arr.bind(rawItem.getStyleItems(), (si) => validate(si, response, value))
        });
      }
    } else {
      return Option.some({
        // ONLY TOGGLEMENUITEMS HANDLE STYLE META.
        // See ToggleMenuItem and ItemStructure for how it's handled.
        // If this type ever changes, we'll need to change that too
        type: 'togglemenuitem',
github tinymce / tinymce / modules / snooker / src / main / ts / ephox / snooker / api / OtherCells.ts View on Github external
const getDownOrRightCells = (grid: RowCells[], selectedCells: DetailExt[], generators: Generators): Element[] => {
  // Get rows down or at the row of the top left cell (including rowspans)
  const downGrid = grid.slice(selectedCells[0].row() + selectedCells[0].rowspan() - 1, grid.length);
  const downDetails = toDetailList(downGrid, generators);
  // Get an array of the cells down or to the right of the bottom right cell
  return Arr.bind(downDetails, (detail) => {
    const slicedCells = detail.cells().slice(selectedCells[0].column() + selectedCells[0].colspan() - 1,  + detail.cells().length);
    return Arr.map(slicedCells, (cell) => {
      return cell.element();
    });
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ListsIndendation.ts View on Github external
const composeEntries = (editor, entries: Entry[]): Element[] => {
  return Arr.bind(Arr.groupBy(entries, isIndented), (entries) => {
    const groupIsIndented = Arr.head(entries).map(isIndented).getOr(false);
    return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
  });
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / StyleSelect.ts View on Github external
const getFormatItems = (fmt) => {
      const subs = fmt.items;
      return subs !== undefined && subs.length > 0 ? Arr.bind(subs, getFormatItems) : [ { title: fmt.title, format: fmt.format } ];
    };
    const flattenedItems = Arr.bind(getStyleFormats(editor), getFormatItems);
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / backstage / StyleFormatsBackstage.ts View on Github external
const flatten = (fmt): string[] => {
    const subs = fmt.items;
    return subs !== undefined && subs.length > 0 ? Arr.bind(subs, flatten) : [ fmt.format ];
  };
github tinymce / tinymce / modules / tinymce / src / core / main / ts / caret / TableCells.ts View on Github external
const getCorners = (getYAxisValue, tds: HTMLElement[]): Corner[] => {
  return Arr.bind(tds, (td) => {
    const rect = deflate(roundRect(td.getBoundingClientRect()), -1);
    return [
      { x: rect.left, y: getYAxisValue(rect), cell: td },
      { x: rect.right, y: getYAxisValue(rect), cell: td }
    ];
  });
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / BespokeSelect.ts View on Github external
const validateItems = (preItems: FormatItem[]) => {
    const value = spec.getCurrentValue();
    const response = spec.shouldHide ? IrrelevantStyleItemResponse.Hide : IrrelevantStyleItemResponse.Disable;
    return Arr.bind(preItems, (item) => validate(item, response, value));
  };