Ejemplo n.º 1
0
  Tools.each(emoticons, function (row) {
    emoticonsHtml += '<tr>';

    Tools.each(row, function (icon) {
      const emoticonUrl = pluginUrl + '/img/smiley-' + icon + '.gif';

      emoticonsHtml += '<td><a href="#" data-mce-url="' + emoticonUrl + '" data-mce-alt="' + icon + '" tabindex="-1" ' +
        'role="option" aria-label="' + icon + '"><img src="' +
        emoticonUrl + '" style="width: 18px; height: 18px" role="presentation" /></a></td>';
    });

    emoticonsHtml += '</tr>';
  });
Ejemplo n.º 2
0
const replaceVals = function (editor, e) {
  const dom = editor.dom, vl = Settings.getTemplateReplaceValues(editor);

  Tools.each(dom.select('*', e), function (e) {
    Tools.each(vl, function (v, k) {
      if (dom.hasClass(e, k)) {
        if (typeof vl[k] === 'function') {
          vl[k](e);
        }
      }
    });
  });
};
Ejemplo n.º 3
0
  suite.test('loadCSS', function () {
    let c = 0;

    DOM.loadCSS('tinymce/dom/test.css?a=1,tinymce/dom/test.css?a=2,tinymce/dom/test.css?a=3');

    Tools.each(document.getElementsByTagName('link'), function (n) {
      if (n.href.indexOf('test.css?a=') !== -1) {
        c++;
      }
    });

    LegacyUnit.equal(c, 3);
  });
Ejemplo n.º 4
0
const buildMenuItems = function (listName: string, languageValues) {
  const items = [];

  Tools.each(languageValues, function (languageValue) {
    items.push({
      selectable: true,
      text: languageValue.name,
      data: languageValue.value
    });
  });

  return items;
};
Ejemplo n.º 5
0
const unwrapElements = function (editor, elms) {
  let bookmark, dom, selection;

  dom = editor.dom;
  selection = editor.selection;
  bookmark = Bookmark.create(dom, selection.getRng());

  Tools.each(elms, function (elm) {
    editor.dom.remove(elm, true);
  });

  selection.setRng(Bookmark.resolve(dom, bookmark));
};
Ejemplo n.º 6
0
const findMatchingValue = function (items, pt, px) {
  let value;

  Tools.each(items, function (item) {
    if (item.value === px) {
      value = px;
    } else if (item.value === pt) {
      value = pt;
    }
  });

  return value;
};
Ejemplo n.º 7
0
    const check = function (obj, val) {
      let count = 0;

      val = val.split(',');

      Tools.each(obj, function (o) {
        if (Tools.inArray(val, o.nodeName.toLowerCase()) !== -1 && o.specified) {
          count++;
        }
      });

      return count === obj.length;
    };
Ejemplo n.º 8
0
const toggleMultipleLists = function (editor, parentList, lists, listName, detail) {
  if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
    flattenListSelection(editor);
  } else {
    const bookmark = Bookmark.createBookmark(editor.selection.getRng(true));

    Tools.each([parentList].concat(lists), function (elm) {
      updateList(editor.dom, elm, listName, detail);
    });

    editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
  }
};
Ejemplo n.º 9
0
const getSelectedTextBlocks = function (editor, rng, root) {
  const textBlocks = [], dom = editor.dom;

  const startNode = getEndPointNode(editor, rng, true, root);
  const endNode = getEndPointNode(editor, rng, false, root);
  let block;
  const siblings = [];

  for (let node = startNode; node; node = node.nextSibling) {
    siblings.push(node);

    if (node === endNode) {
      break;
    }
  }

  Tools.each(siblings, function (node) {
    if (NodeType.isTextBlock(editor, node)) {
      textBlocks.push(node);
      block = null;
      return;
    }

    if (dom.isBlock(node) || NodeType.isBr(node)) {
      if (NodeType.isBr(node)) {
        dom.remove(node);
      }

      block = null;
      return;
    }

    const nextSibling = node.nextSibling;
    if (BookmarkManager.isBookmarkNode(node)) {
      if (NodeType.isTextBlock(editor, nextSibling) || (!nextSibling && node.parentNode === root)) {
        block = null;
        return;
      }
    }

    if (!block) {
      block = dom.create('p');
      node.parentNode.insertBefore(block, node);
      textBlocks.push(block);
    }

    block.appendChild(node);
  });

  return textBlocks;
};
Ejemplo n.º 10
0
const removeList = function (editor) {
  const bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
  const root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
  let listItems = Selection.getSelectedListItems(editor);
  const emptyListItems = Tools.grep(listItems, function (li) {
    return editor.dom.isEmpty(li);
  });

  listItems = Tools.grep(listItems, function (li) {
    return !editor.dom.isEmpty(li);
  });

  Tools.each(emptyListItems, function (li) {
    if (NodeType.isEmpty(editor.dom, li)) {
      Outdent.outdent(editor, li);
      return;
    }
  });

  Tools.each(listItems, function (li) {
    let node, rootList;

    if (li.parentNode === editor.getBody()) {
      return;
    }

    for (node = li; node && node !== root; node = node.parentNode) {
      if (NodeType.isListNode(node)) {
        rootList = node;
      }
    }

    SplitList.splitList(editor, rootList, li);
    NormalizeLists.normalizeLists(editor.dom, rootList.parentNode);
  });

  editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
};