How to use the @ephox/katamari.Arr.find 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 / ui / core / complex / FontsizeSelect.ts View on Github external
const getMatchingValue = () => {
    let matchOpt = Option.none();
    const items = dataset.data;

    const px = editor.queryCommandValue('FontSize');
    if (px) {
      // checking for three digits after decimal point, should be precise enough
      for (let precision = 3; matchOpt.isNone() && precision >= 0; precision--) {
        const pt = toPt(px, precision);
        const legacy = toLegacy(pt);
        matchOpt = Arr.find(items, (item) => item.format === px || item.format === pt || item.format === legacy);
      }
    }

    return { matchOpt, px };
  };
github tinymce / tinymce / modules / tinymce / src / core / main / ts / selection / SelectionUtils.ts View on Github external
return Options.lift2(getStartNode(rng), getEndNode(rng), function (startNode, endNode) {
    const start = Arr.find(getFirstChildren(elm), Fun.curry(Compare.eq, startNode));
    const end = Arr.find(getLastChildren(elm), Fun.curry(Compare.eq, endNode));
    return start.isSome() && end.isSome();
  }).getOr(false);
};
github tinymce / tinymce / src / core / main / ts / caret / BlockBoundary.ts View on Github external
const getClosestBlock = (root: Element, pos: CaretPosition) => {
  return Arr.find(Parents.parentsAndSelf(Element.fromDom(pos.container()), root), ElementType.isBlock);
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / AlignSelect.ts View on Github external
const getMatchingValue = (): Option> => {
    return  Arr.find(alignMenuItems, (item) => editor.formatter.match(item.format));
  };
github tinymce / tinymce / modules / tinymce / src / plugins / charmap / main / ts / ui / Dialog.ts View on Github external
const scanAndSet = (dialogApi: Types.Dialog.DialogInstanceApi, pattern: string) => {
    Arr.find(charMap, (group) => group.name === currentTab.get()).each((f) => {
      const items = Scan.scan(f, pattern);
      dialogApi.setData({
        results: items
      });
    });
  };
github tinymce / tinymce / modules / tinymce / src / plugins / textpattern / main / ts / core / BlockPattern.ts View on Github external
const findPattern = <p pattern="">(patterns: P[], text: string): Option</p><p> =&gt; {
  const nuText = text.replace('\u00a0', ' ');
  return Arr.find(patterns, (pattern) =&gt; {
    if (text.indexOf(pattern.start) !== 0 &amp;&amp; nuText.indexOf(pattern.start) !== 0) {
      return false;
    }

    return true;
  });
};
</p>
github tinymce / tinymce / modules / tinymce / src / plugins / template / main / ts / ui / Dialog.ts View on Github external
const findTemplate = (templates: InternalTemplate[], templateTitle: string) => {
    return Arr.find(templates, (t) => {
      return t.text === templateTitle;
    });
  };
github tinymce / tinymce / modules / tinymce / src / core / main / ts / selection / SelectionUtils.ts View on Github external
return Options.lift2(getStartNode(rng), getEndNode(rng), function (startNode, endNode) {
    const start = Arr.find(getFirstChildren(elm), Fun.curry(Compare.eq, startNode));
    const end = Arr.find(getLastChildren(elm), Fun.curry(Compare.eq, endNode));
    return start.isSome() && end.isSome();
  }).getOr(false);
};