返回介绍

tinymce-html-DomParser

发布于 2019-05-06 06:50:00 字数 3628 浏览 1299 评论 0 收藏 0

Examples

var parser = new tinymce.html.DomParser({validate: true}, schema);
var rootNode = parser.parse('<h1>content</h1>');

Methods

namesummarydefined by
addAttributeFilter()Adds a attribute filter function to the parser, the parser will collect nodes that has the specified attributes and then execute the callback ones it has finished parsing the document.tinymce.html.DomParser
addNodeFilter()Adds a node filter function to the parser, the parser will collect the specified nodes by name and then execute the callback ones it has finished parsing the document.tinymce.html.DomParser
filterNode()Runs the specified node though the element and attributes filters.tinymce.html.DomParser
parse()Parses the specified HTML string into a DOM like node tree and returns the result.tinymce.html.DomParser

Methods

addAttributeFilter

addAttributeFilter(callback:function)

Adds a attribute filter function to the parser, the parser will collect nodes that has the specified attributes and then execute the callback ones it has finished parsing the document.

Examples
parser.addAttributeFilter('src,href', function(nodes, name) {
 for (var i = 0; i < nodes.length; i++) {
  console.log(nodes[i].name);
 }
});
Parameters
  • callback (function) - Callback function to execute once it has collected nodes.

addNodeFilter

addNodeFilter(callback:function)

Adds a node filter function to the parser, the parser will collect the specified nodes by name and then execute the callback ones it has finished parsing the document.

Examples
parser.addNodeFilter('p,h1', function(nodes, name) {
 for (var i = 0; i < nodes.length; i++) {
  console.log(nodes[i].name);
 }
});
Parameters
  • callback (function) - Callback function to execute once it has collected nodes.

filterNode

filterNode(Node:tinymce.html.Node):tinymce.html.Node

Runs the specified node though the element and attributes filters.

Parameters
  • Node (tinymce.html.Node) - the node to run filters on.
Return value
  • tinymce.html.Node - The passed in node.

parse

parse(html:String, args:Object):tinymce.html.Node

Parses the specified HTML string into a DOM like node tree and returns the result.

Examples
var rootNode = new DomParser({...}).parse('<b>text</b>');
Parameters
  • html (String) - Html string to sax parse.
  • args (Object) - Optional args object that gets passed to all filter functions.
Return value
  • tinymce.html.Node - Root node containing the tree.

Can't find what you're looking for? Let us know.

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文