本文整理匯總了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;
};