How to use the @ephox/katamari.Arr.head 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 / plugins / image / main / ts / ui / Dialog.ts View on Github external
const changeFileInput = (helpers: Helpers, info: ImageDialogInfo, state: ImageDialogState, api: API) => {
  const data = api.getData();
  api.block('Uploading image'); // What msg do we pass to the lock?
  Arr.head(data.fileinput)
    .fold(() => {
      api.unblock();
    }, (file) => {
      const blobUri: string = URL.createObjectURL(file);

      const uploader = Uploader({
        url: info.url,
        basePath: info.basePath,
        credentials: info.credentials,
        handler: info.handler
      });

      const finalize = () => {
        api.unblock();
        URL.revokeObjectURL(blobUri);
      };
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ComposeList.ts View on Github external
const appendSegments = (head: Segment[], tail: Segment[]): void => {
  Options.lift2(Arr.last(head), Arr.head(tail), joinSegment);
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / alien / DialogTabHeight.ts View on Github external
const getMaxHeight = (heights: number[]) => {
  return Arr.head(Arr.sort(heights, (a, b) => {
    if (a > b) {
      return -1;
    } else if (a < b) {
      return +1;
    } else {
      return 0;
    }
  }));
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / caret / LineReader.ts View on Github external
(lastPos) => {
        return Options.lift2(Arr.head(lastPos.getClientRects()), Arr.head(newPos.getClientRects()), (lastRect, newRect) => {
          const lastDist = Math.abs(x - lastRect.left);
          const newDist = Math.abs(x - newRect.left);
          return newDist <= lastDist ? newPos : lastPos;
        }).or(acc);
      }
    );
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ComposeList.ts View on Github external
const composeList = (scope: Document, entries: Entry[]): Option<element> =&gt; {
  const cast: Segment[] = Arr.foldl(entries, (cast, entry) =&gt; {
    return entry.depth &gt; cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
  }, []);

  return Arr.head(cast).map((segment) =&gt; segment.list);
};
</element>
github tinymce / tinymce / modules / tinymce / src / core / main / ts / caret / TableCells.ts View on Github external
const findClosestPositionInAboveCell = (table: HTMLElement, pos: CaretPosition): Option =&gt; {
  return Arr.head(pos.getClientRects()).bind((rect) =&gt; {
    return getClosestCellAbove(table, rect.left, rect.top);
  }).bind((cell) =&gt; findClosestHorizontalPosition(getLastLinePositions(cell), pos));
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / caret / CaretBr.ts View on Github external
const findBr = (forward: boolean, root: Element, pos: CaretPosition) => {
  const parentBlocks = Arr.filter(Parents.parentsAndSelf(Element.fromDom(pos.container()), root), ElementType.isBlock);
  const scope = Arr.head(parentBlocks).getOr(root);
  return CaretFinder.fromPosition(forward, scope.dom(), pos).filter(isBr);
};