當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Writer.default函數代碼示例

本文整理匯總了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>');
  });
開發者ID:abstask,項目名稱:tinymce,代碼行數:11,代碼來源:WriterTest.ts

示例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();
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:27,代碼來源:HtmlUtils.ts

示例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();
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:57,代碼來源:Sanitize.ts

示例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">&nbsp;<span contenteditable="false">X</span>&nbsp;</div>b</p>');
   LegacyUnit.equal(writer.getContent(), '<p>a b</p>');
   LegacyUnit.deepEqual(counter.counts, { start: 1, end: 1, text: 2 });
 });
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:9,代碼來源:SaxParserTest.ts


注:本文中的tinymce/core/api/html/Writer.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。