• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Node.attr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中tinymce/core/html/Node.attr函数的典型用法代码示例。如果您正苦于以下问题:TypeScript attr函数的具体用法?TypeScript attr怎么用?TypeScript attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了attr函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

  Tools.each('keywords,description,author,copyright,robots'.split(','), function (name) {
    const nodes = headerFragment.getAll('meta');
    let i, meta;
    const value = data[name];

    for (i = 0; i < nodes.length; i++) {
      meta = nodes[i];

      if (meta.attr('name') === name) {
        if (value) {
          meta.attr('content', value);
        } else {
          meta.remove();
        }

        return;
      }
    }

    if (value) {
      elm = new Node('meta', 1);
      elm.attr('name', name);
      elm.attr('content', value);
      elm.shortEnded = true;

      addHeadNode(elm);
    }
  });
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:28,代码来源:Parser.ts


示例2: function

const createPreviewIframeNode = function (editor, node) {
  let previewWrapper;
  let previewNode;
  let shimNode;
  const name = node.name;

  previewWrapper = new Node('span', 1);
  previewWrapper.attr({
    'contentEditable': 'false',
    'style': node.attr('style'),
    'data-mce-object': name,
    'class': 'mce-preview-object mce-object-' + name
  });

  retainAttributesAndInnerHtml(editor, node, previewWrapper);

  previewNode = new Node(name, 1);
  previewNode.attr({
    src: node.attr('src'),
    allowfullscreen: node.attr('allowfullscreen'),
    width: node.attr('width') || '300',
    height: node.attr('height') || (name === 'audio' ? '30' : '150'),
    frameborder: '0'
  });

  shimNode = new Node('span', 1);
  shimNode.attr('class', 'mce-shim');

  previewWrapper.append(previewNode);
  previewWrapper.append(shimNode);

  return previewWrapper;
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:33,代码来源:Nodes.ts


示例3: function

  suite.test('clone', function () {
    let root, node, clone;

    node = new Node('#text', 3);
    node.value = 'value';
    clone = node.clone();
    LegacyUnit.equal(clone.name, '#text');
    LegacyUnit.equal(clone.type, 3);
    LegacyUnit.equal(clone.value, 'value');
    LegacyUnit.equal(clone.parent, undefined);
    LegacyUnit.equal(clone.next, undefined);
    LegacyUnit.equal(clone.prev, undefined);

    root = new Node('#frag', 11);
    node = new Node('#text', 3);
    node.value = 'value';
    root.append(node);
    LegacyUnit.equal(clone.name, '#text');
    LegacyUnit.equal(clone.type, 3);
    LegacyUnit.equal(clone.value, 'value');
    LegacyUnit.equal(clone.parent, undefined);
    LegacyUnit.equal(clone.next, undefined);
    LegacyUnit.equal(clone.prev, undefined);

    node = new Node('b', 1);
    node.attr('id', 'id');
    node.attr('class', 'class');
    node.attr('title', 'title');
    clone = node.clone();
    LegacyUnit.equal(clone.name, 'b');
    LegacyUnit.equal(clone.type, 1);
    LegacyUnit.deepEqual(clone.attributes, [{ name: 'class', value: 'class' }, { name: 'title', value: 'title' }]);
    LegacyUnit.deepEqual(clone.attributes.map, { class: 'class', title: 'title' });
  });
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:34,代码来源:NodeTest.ts


示例4: convertParagraphToLi

  function convertParagraphToLi(paragraphNode, listName, start?) {
    const level = paragraphNode._listLevel || lastLevel;

    // Handle list nesting
    if (level !== lastLevel) {
      if (level < lastLevel) {
        // Move to parent list
        if (currentListNode) {
          currentListNode = currentListNode.parent.parent;
        }
      } else {
        // Create new list
        prevListNode = currentListNode;
        currentListNode = null;
      }
    }

    if (!currentListNode || currentListNode.name !== listName) {
      prevListNode = prevListNode || currentListNode;
      currentListNode = new Node(listName, 1);

      if (start > 1) {
        currentListNode.attr('start', '' + start);
      }

      paragraphNode.wrap(currentListNode);
    } else {
      currentListNode.append(paragraphNode);
    }

    paragraphNode.name = 'li';

    // Append list to previous list if it exists
    if (level > lastLevel && prevListNode) {
      prevListNode.lastChild.append(currentListNode);
    }

    lastLevel = level;

    // Remove start of list item "1. " or "&middot; " etc
    removeIgnoredNodes(paragraphNode);
    trimListStart(paragraphNode, /^\u00a0+/);
    trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
    trimListStart(paragraphNode, /^\u00a0+/);
  }
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:45,代码来源:WordFilter.ts


示例5: function

    editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) {
      let i = nodes.length;
      let node;
      let realElm;
      let ai;
      let attribs;
      let innerHtml;
      let innerNode;
      let realElmName;
      let className;

      while (i--) {
        node = nodes[i];
        if (!node.parent) {
          continue;
        }

        realElmName = node.attr(name);
        realElm = new Node(realElmName, 1);

        // Add width/height to everything but audio
        if (realElmName !== 'audio' && realElmName !== 'script') {
          className = node.attr('class');
          if (className && className.indexOf('mce-preview-object') !== -1) {
            realElm.attr({
              width: node.firstChild.attr('width'),
              height: node.firstChild.attr('height')
            });
          } else {
            realElm.attr({
              width: node.attr('width'),
              height: node.attr('height')
            });
          }
        }

        realElm.attr({
          style: node.attr('style')
        });

        // Unprefix all placeholder attributes
        attribs = node.attributes;
        ai = attribs.length;
        while (ai--) {
          const attrName = attribs[ai].name;

          if (attrName.indexOf('data-mce-p-') === 0) {
            realElm.attr(attrName.substr(11), attribs[ai].value);
          }
        }

        if (realElmName === 'script') {
          realElm.attr('type', 'text/javascript');
        }

        // Inject innerhtml
        innerHtml = node.attr('data-mce-html');
        if (innerHtml) {
          innerNode = new Node('#text', 3);
          innerNode.raw = true;
          innerNode.value = Sanitize.sanitize(editor, unescape(innerHtml));
          realElm.append(innerNode);
        }

        node.replace(realElm);
      }
    });
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:67,代码来源:FilterContent.ts



注:本文中的tinymce/core/html/Node.attr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript SaxParser.parse函数代码示例发布时间:2022-05-25
下一篇:
TypeScript Node.append函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap