當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Tools.toArray函數代碼示例

本文整理匯總了TypeScript中tinymce/core/api/util/Tools.toArray函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript toArray函數的具體用法?TypeScript toArray怎麽用?TypeScript toArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了toArray函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

const done = function (editor, currentIndexState, keepEditorSelection?) {
  let i, nodes, startContainer, endContainer;

  nodes = Tools.toArray(editor.getBody().getElementsByTagName('span'));
  for (i = 0; i < nodes.length; i++) {
    const nodeIndex = getElmIndex(nodes[i]);

    if (nodeIndex !== null && nodeIndex.length) {
      if (nodeIndex === currentIndexState.get().toString()) {
        if (!startContainer) {
          startContainer = nodes[i].firstChild;
        }

        endContainer = nodes[i].firstChild;
      }

      unwrap(nodes[i]);
    }
  }

  if (startContainer && endContainer) {
    const rng = editor.dom.createRng();
    rng.setStart(startContainer, 0);
    rng.setEnd(endContainer, endContainer.data.length);

    if (keepEditorSelection !== false) {
      editor.selection.setRng(rng);
    }

    return rng;
  }
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:32,代碼來源:Actions.ts

示例2: function

  proto[name] = function () {
    const args = Tools.toArray(arguments);

    this.each(function (ctrl) {
      if (name in ctrl) {
        ctrl[name].apply(ctrl, args);
      }
    });

    return this;
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:11,代碼來源:Collection.ts

示例3: function

const load = function (doc, url) {
  const linkElements = Tools.toArray(doc.getElementsByTagName('link'));
  const matchingLinkElms = Tools.grep(linkElements, function (head) {
    return head.id === cssId;
  });

  if (matchingLinkElms.length === 0) {
    const linkElm = DOMUtils.DOM.create('link', {
      id: cssId,
      rel: 'stylesheet',
      href: url
    });

    doc.getElementsByTagName('head')[0].appendChild(linkElm);
  }
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:16,代碼來源:LoadCss.ts

示例4: function

const findSpansByIndex = function (editor, index) {
  let nodes;
  const spans = [];

  nodes = Tools.toArray(editor.getBody().getElementsByTagName('span'));
  if (nodes.length) {
    for (let i = 0; i < nodes.length; i++) {
      const nodeIndex = getElmIndex(nodes[i]);

      if (nodeIndex === null || !nodeIndex.length) {
        continue;
      }

      if (nodeIndex === index.toString()) {
        spans.push(nodes[i]);
      }
    }
  }

  return spans;
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:21,代碼來源:Actions.ts

示例5: each

   * @return {tinymce.ui.Collection} Current collection instance.
   */
  each (callback) {
    Tools.each(this, callback);

    return this;
  },

  /**
   * Returns an JavaScript array object of the contents inside the collection.
   *
   * @method toArray
   * @return {Array} Array with all items from collection.
   */
  toArray () {
    return Tools.toArray(this);
  },

  /**
   * Finds the index of the specified control or return -1 if it isn't in the collection.
   *
   * @method indexOf
   * @param {Control} ctrl Control instance to look for.
   * @return {Number} Index of the specified control or -1.
   */
  indexOf (ctrl) {
    const self = this;
    let i = self.length;

    while (i--) {
      if (self[i] === ctrl) {
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:31,代碼來源:Collection.ts


注:本文中的tinymce/core/api/util/Tools.toArray函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。