Example #1
0
const removeElementAndReposition = (caretContainer: Node, pos: CaretPosition): CaretPosition => {
  const parentNode = pos.container();
  const newPosition = Arr.indexOf(parentNode.childNodes, caretContainer).map(function (index) {
    return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos;
  }).getOr(pos);
  remove(caretContainer);
  return newPosition;
};
Example #2
0
  const add = (key: string): void => {
    // Remove duplicates first.
    Arr.indexOf(cache, key).each(remove);

    cache.unshift(key);

    // When max size is exceeded, the oldest colors will be removed
    if (cache.length > max) {
      cache.pop();
    }

    LocalStorage.setItem(storageName, JSON.stringify(cache));
  };
Example #3
0
const addToHistory = function (url, fileType) {
  const items = history[fileType];

  if (!/^https?/.test(url)) {
    return;
  }

  if (items) {
    if (Arr.indexOf(items, url) === -1) {
      history[fileType] = items.slice(0, HISTORY_LENGTH).concat(url);
    }
  } else {
    history[fileType] = [url];
  }
};
Example #4
0
 return TransformFind.closest(elem, function (e) {
   const nodeName = Node.name(e);
   return Arr.indexOf(headings, nodeName);
 }, function (e) {
Example #5
0
 return heading.bind((elm) => Arr.indexOf(headings, Node.name(elm))).getOr(0);