本文整理匯總了TypeScript中tinymce/core/api/html/Writer.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
suite.test('Doctype', function () {
let writer;
writer = Writer();
writer.doctype(' text');
LegacyUnit.equal(writer.getContent(), '<!DOCTYPE text>');
writer = Writer();
writer.doctype('');
LegacyUnit.equal(writer.getContent(), '<!DOCTYPE>');
});
示例2: function
const normalizeHtml = function (html) {
const writer = Writer();
SaxParser({
validate: false,
comment: writer.comment,
cdata: writer.cdata,
text: writer.text,
end: writer.end,
pi: writer.pi,
doctype: writer.doctype,
start (name, attrs, empty) {
attrs.sort(function (a, b) {
if (a.name === b.name) {
return 0;
}
return a.name > b.name ? 1 : -1;
});
writer.start(name, attrs, empty);
}
}).parse(html);
return writer.getContent();
};
示例3: function
const sanitize = function (editor, html) {
if (Settings.shouldFilterHtml(editor) === false) {
return html;
}
const writer = Writer();
let blocked;
SaxParser({
validate: false,
allow_conditional_comments: false,
special: 'script,noscript',
comment (text) {
writer.comment(text);
},
cdata (text) {
writer.cdata(text);
},
text (text, raw) {
writer.text(text, raw);
},
start (name, attrs, empty) {
blocked = true;
if (name === 'script' || name === 'noscript') {
return;
}
for (let i = 0; i < attrs.length; i++) {
if (attrs[i].name.indexOf('on') === 0) {
return;
}
if (attrs[i].name === 'style') {
attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
}
}
writer.start(name, attrs, empty);
blocked = false;
},
end (name) {
if (blocked) {
return;
}
writer.end(name);
}
}, Schema({})).parse(html);
return writer.getContent();
};
示例4: Schema
suite.test('remove bogus elements even if not part of valid_elements', () => {
const schema = Schema({ valid_elements: 'p,span,' });
const writer = Writer();
const counter = createCounter(writer);
const parser = SaxParser(counter, schema);
parser.parse('<p>a <div data-mce-bogus="all"> <span contenteditable="false">X</span> </div>b</p>');
LegacyUnit.equal(writer.getContent(), '<p>a b</p>');
LegacyUnit.deepEqual(counter.counts, { start: 1, end: 1, text: 2 });
});