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;
};
Beispiel #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));
  };
Beispiel #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];
  }
};
Beispiel #4
0
 return TransformFind.closest(elem, function (e) {
   const nodeName = Node.name(e);
   return Arr.indexOf(headings, nodeName);
 }, function (e) {
Beispiel #5
0
 return heading.bind((elm) => Arr.indexOf(headings, Node.name(elm))).getOr(0);