Example #1
0
const validateBlocks = (editor: Editor, blocks: Element[]) => {
  return Arr.forall(blocks, (block) => {
    const indentStyleName = getIndentStyleName(Settings.shouldIndentUseMargin(editor), block);
    const intentValue = Css.getRaw(block, indentStyleName).map(parseIndentValue).getOr(0);
    const contentEditable = editor.dom.getContentEditable(block.dom());
    return contentEditable !== 'false' && intentValue > 0;
  });
};
Example #2
0
const unmergable = function (cell, selections) {
  const hasSpan = function (elem) {
    return (Attr.has(elem, 'rowspan') && parseInt(Attr.get(elem, 'rowspan'), 10) > 1) ||
           (Attr.has(elem, 'colspan') && parseInt(Attr.get(elem, 'colspan'), 10) > 1);
  };

  const candidates = selection(cell, selections);

  return candidates.length > 0 && Arr.forall(candidates, hasSpan) ? Option.some(candidates) : Option.none();
};
Example #3
0
  const isValidDataUriImage = function (imgElm: HTMLImageElement) {
    if (Arr.forall(urlFilters, (filter) => filter(imgElm)) === false) {
      return false;
    }

    if (imgElm.getAttribute('src').indexOf('data:') === 0) {
      const dataImgFilter = Settings.getImagesDataImgFilter(editor);
      return dataImgFilter(imgElm);
    }

    return true;
  };
Example #4
0
 const formatOrCmd = <T> (name: string, onFormat: (formats: string[]) => T, onCommand: (cmd: string, value: any) => T): Result<T, PatternError> => {
   if (pattern.format !== undefined) {
     let formats: string[];
     if (Type.isArray(pattern.format)) {
       if (!Arr.forall(pattern.format, Type.isString)) {
         return err(name + ' pattern has non-string items in the `format` array');
       }
       formats = pattern.format;
     } else if (Type.isString(pattern.format)) {
       formats = [pattern.format];
     } else {
       return err(name + ' pattern has non-string `format` parameter');
     }
     return Result.value(onFormat(formats));
   } else if (pattern.cmd !== undefined) {
     if (!Type.isString(pattern.cmd)) {
       return err(name + ' pattern has non-string `cmd` parameter');
     }
     return Result.value(onCommand(pattern.cmd, pattern.value));
   } else {
     return err(name + ' pattern is missing both `format` and `cmd` parameters');
   }
 };
Example #5
0
const isArrayOf = (p: (a: any) => boolean) => (a: any) => Type.isArray(a) && Arr.forall(a, p);
Example #6
0
const isArrayOfUrl = (a: any): boolean => {
  return Type.isArray(a) && a.length <= HISTORY_LENGTH && Arr.forall(a, isHttpUrl);
};
Example #7
0
 const matchesSystemStack = (): boolean => {
   // Split the fonts into an array and strip away any quotes
   const fonts = fontFamily.toLowerCase().split(/['"]?\s*,\s*['"]?/);
   return Arr.forall(systemStackFonts, (font) => fonts.indexOf(font.toLowerCase()) > -1);
 };