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


TypeScript TrimHtml.trimExternal函數代碼示例

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

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

示例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;
};
開發者ID:nyroDev,項目名稱:tinymce,代碼行數:33,代碼來源:EditorContent.ts

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


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