How to use the @ephox/katamari.Arr.filter 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 / dialog / Dropzone.ts View on Github external
const filterByExtension = function (files: FileList) {
  const re = new RegExp('(' + extensionsAccepted.split(/\s*,\s*/).join('|') + ')$', 'i');
  return Arr.filter(Arr.from(files), (file) => re.test(file.name));
};
github tinymce / tinymce / modules / tinymce / src / plugins / paste / main / ts / core / Clipboard.ts View on Github external
const getImagesFromDataTransfer = (dataTransfer: DataTransfer) => {
  const items = dataTransfer.items ? Arr.map(Arr.from(dataTransfer.items), (item) => item.getAsFile()) : [];
  const files = dataTransfer.files ? Arr.from(dataTransfer.files) : [];
  const images = Arr.filter(items.length > 0 ? items : files, (file) => /^image\/(jpeg|png|gif|bmp)$/.test(file.type));
  return images;
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / api / Settings.ts View on Github external
const getMultipleToolbarsSetting = (editor: Editor): Option => {
  const keys = Obj.keys(editor.settings);
  const toolbarKeys = Arr.filter(keys, (key) => /^toolbar([1-9])$/.test(key));
  const toolbars = Arr.map(toolbarKeys, (key) => editor.getParam(key, false, 'string'));
  const toolbarArray = Arr.filter(toolbars, (toolbar) => typeof toolbar === 'string');
  return toolbarArray.length > 0 ? Option.some(toolbarArray) : Option.none();
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / keyboard / Nbsps.ts View on Github external
const getClosestBlock = (root: Element, pos: CaretPosition): Element => {
  const parentBlocks = Arr.filter(Parents.parentsAndSelf(Element.fromDom(pos.container()), root), ElementType.isBlock);
  return Arr.head(parentBlocks).getOr(root);
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ListsIndendation.ts View on Github external
const indentSelectedEntries = (entries: Entry[], indentation: Indentation): void => {
  Arr.each(Arr.filter(entries, isSelected), (entry) => indentEntry(indentation, entry));
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / core / Selection.ts View on Github external
const getSelectedDlItems = (editor: Editor): Node[] => {
  return Arr.filter(getSelectedListItems(editor), NodeType.isDlItemNode);
};
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);
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / selection / SelectionTargets.ts View on Github external
return () => {
      changeHandlers.set(Arr.filter(changeHandlers.get(), (h) => h !== handler));
    };
  };
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / core / Selection.ts View on Github external
const getSelectedLists = (editor: Editor): Node[] => {
  const firstList = findLastParentListNode(editor, editor.selection.getStart());
  const subsequentLists = Arr.filter(editor.selection.getSelectedBlocks(), NodeType.isOlUlNode);

  return firstList.toArray().concat(subsequentLists);
};