Step.sync(function () {
        const headStuff = editor.getDoc().head.querySelectorAll('link, style');
        const linkIndex = Arr.findIndex(headStuff, function (elm) {
          return Node.name(Element.fromDom(elm)) === 'link';
        }).getOrDie('could not find link elemnt');
        const styleIndex = Arr.findIndex(headStuff, function (elm) {
          return elm.innerText === contentStyle;
        }).getOrDie('could not find content style tag');

        Assertions.assertEq('style tag should be after link tag', linkIndex < styleIndex, true);
      })
Example #2
0
const getChildrenUntilBlockBoundary = (block: Element) => {
  const children = Traverse.children(block);
  return Arr.findIndex(children, ElementType.isBlock).fold(
    () => children,
    (index) => children.slice(0, index)
  );
};
Example #3
0
const getParentInlines = function (rootElm, startElm) {
  const parents = Parents.parentsAndSelf(startElm, rootElm);
  return Arr.findIndex(parents, ElementType.isBlock).fold(
    Fun.constant(parents),
    function (index) {
      return parents.slice(0, index);
    }
  );
};
Example #4
0
 const closeNotification = function (notification) {
   Arr.findIndex(notifications, function (otherNotification) {
     return otherNotification === notification;
   }).each(function (index) {
     // Mutate here since third party might have stored away the window array
     // TODO: Consider breaking this api
     notifications.splice(index, 1);
   });
 };
Example #5
0
const getChildrenUntilBlockBoundary = function (block) {
  const children = Traverse.children(block);
  return Arr.findIndex(children, ElementType.isBlock).fold(
    function () {
      return children;
    },
    function (index) {
      return children.slice(0, index);
    }
  );
};
  const closeWindow = function (win) {
    Arr.findIndex(windows, function (otherWindow) {
      return otherWindow === win;
    }).each(function (index) {
      // Mutate here since third party might have stored away the window array, consider breaking this api
      windows.splice(index, 1);

      fireCloseEvent(win);

      // Move focus back to editor when the last window is closed
      if (windows.length === 0) {
        editor.focus();
      }
    });
  };
Example #7
0
const detectSize = (comp: AlloyComponent, margin: number, selectorClass: string): Option<{ numColumns: number, numRows: number}> => {
  const descendants = SelectorFilter.descendants(comp.element(), '.' + selectorClass);

  // TODO: This seems to cause performance issues in the emoji dialog
  if (descendants.length > 0) {
    const columnLength = Arr.findIndex(descendants, (c) => {
      const thisTop = c.dom().getBoundingClientRect().top;
      const cTop = descendants[0].dom().getBoundingClientRect().top;
      return Math.abs(thisTop - cTop) > margin;

    }).getOr(descendants.length);

    return Option.some({
      numColumns: columnLength,
      numRows: Math.ceil(descendants.length / columnLength)
    });
  } else {
    return Option.none();
  }
};
const getCellIndex = (cells, cell) => {
  return Arr.findIndex(cells, (x) => Compare.eq(x, cell));
};
Example #9
0
const sizeToIndex = function (size) {
  return Arr.findIndex(candidates, function (v) {
    return v === size;
  });
};
Example #10
0
const hasItemName = function (namedMenuItems, name) {
  return Arr.findIndex(namedMenuItems, function (namedMenuItem) {
    return namedMenuItem.name === name;
  }).isSome();
};
const getCellIndex = function (cellArray, cell) {
  return Arr.findIndex(cellArray, function (x) {
    return Compare.eq(x, cell);
  });
};