本文整理汇总了TypeScript中tinymce/core/api/html/Schema.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
UnitTest.asynctest('browser.tinymce.core.InsertListTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const schema = Schema({});
const createFragment = function (html) {
const parser = DomParser({ validate: false });
const fragment = parser.parse(html);
return fragment;
};
const createDomFragment = function (html) {
return DOMUtils.DOM.createFragment(html);
};
suite.test('isListFragment', function () {
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ul><li>x</li></ul>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ol><li>x</li></ol>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<meta><ul><li>x</li></ul>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ul><li>x</li></ul><span id="mce_marker"></span>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ul><li>x</li></ul><p><br></p>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ul><li>x</li></ul><p></p>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ul><li>x</li></ul><p>\u00a0</p>')), true);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<ul><li>x</li></ul><p>x</p>')), false);
LegacyUnit.equal(InsertList.isListFragment(schema, createFragment('<div></div>')), false);
});
suite.test('listItems', function () {
const list = createDomFragment('<ul><li>a</li><li>b</li><li>c</li></ul>').firstChild;
LegacyUnit.equal(InsertList.listItems(list).length, 3);
LegacyUnit.equal(InsertList.listItems(list)[0].nodeName, 'LI');
});
suite.test('trimListItems', function () {
const list = createDomFragment('<ul><li>a</li><li>b</li><li></li></ul>').firstChild;
LegacyUnit.equal(InsertList.listItems(list).length, 3);
LegacyUnit.equal(InsertList.trimListItems(InsertList.listItems(list)).length, 2);
});
Pipeline.async({}, suite.toSteps({}), function () {
success();
}, failure);
});
示例2: function
suite.test('Remove redundant br elements', function () {
let parser, root;
const schema = Schema();
parser = DomParser({ remove_trailing_brs: true }, schema);
root = parser.parse(
'<p>a<br></p>' +
'<p>a<br>b<br></p>' +
'<p>a<br><br></p><p>a<br><span data-mce-type="bookmark"></span><br></p>' +
'<p>a<span data-mce-type="bookmark"></span><br></p>'
);
LegacyUnit.equal(
serializer.serialize(root),
'<p>a</p><p>a<br />b</p><p>a<br /><br /></p><p>a<br /><br /></p><p>a</p>',
'Remove traling br elements.'
);
});
示例3: function
suite.test('getNonEmptyElements', function () {
let schema;
schema = Schema();
LegacyUnit.deepEqual(schema.getNonEmptyElements(), {
EMBED: {}, PARAM: {}, META: {}, LINK: {}, ISINDEX: {},
INPUT: {}, IMG: {}, HR: {}, FRAME: {}, COL: {}, BR: {},
BASEFONT: {}, BASE: {}, AREA: {}, SOURCE : {},
TD: {}, TH: {}, IFRAME: {}, VIDEO: {}, AUDIO: {}, OBJECT: {},
WBR: {}, TRACK : {}, SCRIPT : {}, PRE: {}, CODE: {},
embed: {}, param: {}, meta: {}, link: {}, isindex: {},
input: {}, img: {}, hr: {}, frame: {}, col: {}, br: {},
basefont: {}, base: {}, area: {}, source : {},
td: {}, th: {}, iframe: {}, video: {}, audio: {}, object: {},
wbr : {}, track : {}, script : {}, pre: {}, code: {}
});
});
示例4: function
const filterWordContent = function (editor: Editor, content: string) {
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;
//.........这里部分代码省略.........