本文整理汇总了TypeScript中tinymce/core/dom/TrimHtml.trimExternal函数的典型用法代码示例。如果您正苦于以下问题:TypeScript trimExternal函数的具体用法?TypeScript trimExternal怎么用?TypeScript trimExternal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trimExternal函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
UnitTest.test('browser.tinymce.core.dom.TrimHtmlTest', function () {
const serializer = DomSerializer({}, new Editor('id', {}, EditorManager));
RawAssertions.assertEq('Should be unchanged', '<p id="a" data-mce-abc="1">a</p>', TrimHtml.trimInternal(serializer, '<p id="a" data-mce-abc="1">a</p>'));
RawAssertions.assertEq('Should not have internal attr', '<p>a</p>', TrimHtml.trimInternal(serializer, '<p data-mce-selected="1">a</p>'));
RawAssertions.assertEq('Should trim zwsp', '<p>ab</p>', TrimHtml.trimInternal(serializer, '<p>a' + Zwsp.ZWSP + 'b</p>'));
RawAssertions.assertEq('Should be unchanged', '<p id="a" data-mce-abc="1">a</p>', TrimHtml.trimExternal(serializer, '<p id="a" data-mce-abc="1">a</p>'));
RawAssertions.assertEq('Should not have internal attr', '<p>a</p>', TrimHtml.trimExternal(serializer, '<p data-mce-selected="1">a</p>'));
RawAssertions.assertEq('Should not have zwsp', '<p>ab</p>', TrimHtml.trimExternal(serializer, '<p>a' + Zwsp.ZWSP + 'b</p>'));
});
示例2: function
suite.test('addTempAttr same attr twice', function () {
const ser1 = Serializer({});
const ser2 = Serializer({});
ser1.addTempAttr('data-x');
ser2.addTempAttr('data-x');
DOM.setHTML('test', '<p data-x="1" data-z="3">a</p>');
LegacyUnit.equal(ser1.serialize(DOM.get('test'), { getInner: 1 }), '<p data-z="3">a</p>');
LegacyUnit.equal(TrimHtml.trimExternal(ser1, '<p data-x="1" data-z="3">a</p>'), '<p data-z="3">a</p>');
LegacyUnit.equal(ser2.serialize(DOM.get('test'), { getInner: 1 }), '<p data-z="3">a</p>');
LegacyUnit.equal(TrimHtml.trimExternal(ser2, '<p data-x="1" data-z="3">a</p>'), '<p data-z="3">a</p>');
});
示例3: if
const getContentFromBody = (editor, args, body) => {
let content;
args.format = args.format ? args.format : defaultFormat;
args.get = true;
args.getInner = true;
if (!args.no_events) {
editor.fire('BeforeGetContent', args);
}
if (args.format === 'raw') {
content = Tools.trim(TrimHtml.trimExternal(editor.serializer, body.innerHTML));
} else if (args.format === 'text') {
content = Zwsp.trim(body.innerText || body.textContent);
} else if (args.format === 'tree') {
return editor.serializer.serialize(body, args);
} else {
content = trimEmptyContents(editor, editor.serializer.serialize(body, args));
}
if (args.format !== 'text') {
args.content = Tools.trim(content);
} else {
args.content = content;
}
if (!args.no_events) {
editor.fire('GetContent', args);
}
return args.content;
};
示例4: if
const getContent = (editor: Editor, args: GetContentArgs = {}): Content => {
let content;
const body = editor.getBody();
if (editor.removed) {
return '';
}
args.format = args.format ? args.format : defaultFormat;
args.get = true;
args.getInner = true;
if (!args.no_events) {
editor.fire('BeforeGetContent', args);
}
if (args.format === 'raw') {
content = Tools.trim(TrimHtml.trimExternal(editor.serializer, body.innerHTML));
} else if (args.format === 'text') {
content = body.innerText || body.textContent;
} else if (args.format === 'tree') {
return editor.serializer.serialize(body, args);
} else {
content = editor.serializer.serialize(body, args);
}
if (args.format !== 'text') {
args.content = Tools.trim(content);
} else {
args.content = content;
}
if (!args.no_events) {
editor.fire('GetContent', args);
}
return args.content;
};