本文整理汇总了TypeScript中tinymce/core/html/Serializer.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
suite.test('Pad empty with br', function () {
const schema = Schema();
const parser = DomParser({ padd_empty_with_br: true }, schema);
const serializer = Serializer({ padd_empty_with_br: true }, schema);
const root = parser.parse('<p>a</p><p></p>');
LegacyUnit.equal(serializer.serialize(root), '<p>a</p><p><br /></p>');
});
示例2: function
suite.test('Sorting of attributes', function () {
const serializer = Serializer();
LegacyUnit.equal(
serializer.serialize(DomParser().parse('<b class="class" id="id">x</b>')),
'<strong id="id" class="class">x</strong>'
);
});
示例3: setAttr
const dataToHtml = function (editor, data, head) {
let headerFragment, headElement, html, elm, value;
const dom = editor.dom;
function setAttr(elm, name, value) {
elm.attr(name, value ? value : undefined);
}
function addHeadNode(node) {
if (headElement.firstChild) {
headElement.insert(node, headElement.firstChild);
} else {
headElement.append(node);
}
}
headerFragment = parseHeader(head);
headElement = headerFragment.getAll('head')[0];
if (!headElement) {
elm = headerFragment.getAll('html')[0];
headElement = new Node('head', 1);
if (elm.firstChild) {
elm.insert(headElement, elm.firstChild, true);
} else {
elm.append(headElement);
}
}
// Add/update/remove XML-PI
elm = headerFragment.firstChild;
if (data.xml_pi) {
value = 'version="1.0"';
if (data.docencoding) {
value += ' encoding="' + data.docencoding + '"';
}
if (elm.type !== 7) {
elm = new Node('xml', 7);
headerFragment.insert(elm, headerFragment.firstChild, true);
}
elm.value = value;
} else if (elm && elm.type === 7) {
elm.remove();
}
// Add/update/remove doctype
elm = headerFragment.getAll('#doctype')[0];
if (data.doctype) {
if (!elm) {
elm = new Node('#doctype', 10);
if (data.xml_pi) {
headerFragment.insert(elm, headerFragment.firstChild);
} else {
addHeadNode(elm);
}
}
elm.value = data.doctype.substring(9, data.doctype.length - 1);
} else if (elm) {
elm.remove();
}
// Add meta encoding
elm = null;
Tools.each(headerFragment.getAll('meta'), function (meta) {
if (meta.attr('http-equiv') === 'Content-Type') {
elm = meta;
}
});
if (data.docencoding) {
if (!elm) {
elm = new Node('meta', 1);
elm.attr('http-equiv', 'Content-Type');
elm.shortEnded = true;
addHeadNode(elm);
}
elm.attr('content', 'text/html; charset=' + data.docencoding);
} else if (elm) {
elm.remove();
}
// Add/update/remove title
elm = headerFragment.getAll('title')[0];
if (data.title) {
if (!elm) {
elm = new Node('title', 1);
addHeadNode(elm);
} else {
elm.empty();
}
elm.append(new Node('#text', 3)).value = data.title;
} else if (elm) {
elm.remove();
//.........这里部分代码省略.........
示例4: function
const filterWordContent = function (editor, content) {
let retainStyleProperties, validStyles;
retainStyleProperties = Settings.getRetainStyleProps(editor);
if (retainStyleProperties) {
validStyles = Tools.makeMap(retainStyleProperties.split(/[, ]/));
}
// Remove basic Word junk
content = Utils.filter(content, [
// Remove apple new line markers
/<br class="?Apple-interchange-newline"?>/gi,
// Remove google docs internal guid markers
/<b[^>]+id="?docs-internal-[^>]*>/gi,
// Word comments like conditional comments etc
/<!--[\s\S]+?-->/gi,
// Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
// MS Office namespaced tags, and a few other tags
/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
// Convert <s> into <strike> for line-though
[/<(\/?)s>/gi, '<$1strike>'],
// Replace nsbp entites to char since it's easier to handle
[/ /gi, '\u00a0'],
// Convert <span style="mso-spacerun:yes">___</span> to string of alternating
// breaking/non-breaking spaces of same length
[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
function (str, spaces) {
return (spaces.length > 0) ?
spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join('\u00a0') : '';
}
]
]);
const validElements = Settings.getWordValidElements(editor);
// Setup strict schema
const schema = Schema({
valid_elements: validElements,
valid_children: '-li[p]'
});
// Add style/class attribute to all element rules since the user might have removed them from
// paste_word_valid_elements config option and we need to check them for properties
Tools.each(schema.elements, function (rule) {
/*eslint dot-notation:0*/
if (!rule.attributes.class) {
rule.attributes.class = {};
rule.attributesOrder.push('class');
}
if (!rule.attributes.style) {
rule.attributes.style = {};
rule.attributesOrder.push('style');
}
});
// Parse HTML into DOM structure
const domParser = DomParser({}, schema);
// Filter styles to remove "mso" specific styles and convert some of them
domParser.addAttributeFilter('style', function (nodes) {
let i = nodes.length, node;
while (i--) {
node = nodes[i];
node.attr('style', filterStyles(editor, validStyles, node, node.attr('style')));
// Remove pointess spans
if (node.name === 'span' && node.parent && !node.attributes.length) {
node.unwrap();
}
}
});
// Check the class attribute for comments or del items and remove those
domParser.addAttributeFilter('class', function (nodes) {
let i = nodes.length, node, className;
while (i--) {
node = nodes[i];
className = node.attr('class');
if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) {
node.remove();
}
node.attr('class', null);
}
});
// Remove all del elements since we don't want the track changes code in the editor
domParser.addNodeFilter('del', function (nodes) {
let i = nodes.length;
//.........这里部分代码省略.........
示例5: function
const toHtml = function (node) {
const htmlSerializer = Serializer({});
return htmlSerializer.serialize(node);
};