当前位置: 首页>>代码示例>>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;未经允许,请勿转载。