当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Plugin.default函数代码示例

本文整理汇总了TypeScript中tinymce/plugins/paste/Plugin.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

UnitTest.asynctest('tinymce.plugins.paste.browser.ImagePasteTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const suite = LegacyUnit.createSuite();

  Plugin();
  Theme();

  /* eslint-disable max-len */

  const sTeardown = function (editor) {
    return Step.sync(function () {
      delete editor.settings.paste_remove_styles_if_webkit;
      delete editor.settings.paste_retain_style_properties;
      delete editor.settings.paste_enable_default_filters;
      delete editor.settings.paste_data_images;
      delete editor.settings.paste_webkit_styles;
    });
  };

  const appendTeardown = function (editor, steps) {
    return Arr.bind(steps, function (step) {
      return [step, sTeardown(editor)];
    });
  };

  const trimContent = function (content) {
    return content.replace(/^<p>&nbsp;<\/p>\n?/, '').replace(/\n?<p>&nbsp;<\/p>$/, '');
  };

  suite.test('Plain text toggle event', function (editor) {
    const events = [];

    editor.on('PastePlainTextToggle', function (e) {
      events.push({ state: e.state });
    });

    editor.execCommand('mceTogglePlainTextPaste');
    LegacyUnit.deepEqual(events, [
      { state: true }
    ], 'Should be enabled');

    editor.execCommand('mceTogglePlainTextPaste');
    LegacyUnit.deepEqual(events, [
      { state: true },
      { state: false }
    ], 'Should be disabled');

    editor.execCommand('mceTogglePlainTextPaste');
    LegacyUnit.deepEqual(events, [
      { state: true },
      { state: false },
      { state: true }
    ], 'Should be enabled again');
  });

  suite.test('Paste simple text content', function (editor) {
    const rng = editor.dom.createRng();

    editor.setContent('<p>1234</p>');
    editor.focus();
    rng.setStart(editor.getBody().firstChild.firstChild, 1);
    rng.setEnd(editor.getBody().firstChild.firstChild, 3);
    editor.selection.setRng(rng);

    editor.execCommand('mceInsertClipboardContent', false, { content: 'TEST' });
    LegacyUnit.equal(editor.getContent(), '<p>1TEST4</p>');
  });

  suite.test('Paste styled text content', function (editor) {
    const rng = editor.dom.createRng();

    editor.settings.paste_remove_styles_if_webkit = false;

    editor.setContent('<p>1234</p>');
    rng.setStart(editor.getBody().firstChild.firstChild, 1);
    rng.setEnd(editor.getBody().firstChild.firstChild, 3);
    editor.selection.setRng(rng);

    editor.execCommand('mceInsertClipboardContent', false, { content: '<strong><em><span style="color: red;">TEST</span></em></strong>' });
    LegacyUnit.equal(editor.getContent(), '<p>1<strong><em><span style="color: red;">TEST</span></em></strong>4</p>');
  });

  suite.test('Paste paragraph in paragraph', function (editor) {
    const rng = editor.dom.createRng();

    editor.setContent('<p>1234</p>');
    rng.setStart(editor.getBody().firstChild.firstChild, 1);
    rng.setEnd(editor.getBody().firstChild.firstChild, 3);
    editor.selection.setRng(rng);

    editor.execCommand('mceInsertClipboardContent', false, { content: '<p>TEST</p>' });
    LegacyUnit.equal(editor.getContent(), '<p>1</p><p>TEST</p><p>4</p>');
  });

  suite.test('Paste paragraphs in complex paragraph', function (editor) {
    const rng = editor.dom.createRng();

    editor.setContent('<p><strong><em>1234</em></strong></p>');
    rng.setStart(editor.dom.select('em,i')[0].firstChild, 1);
//.........这里部分代码省略.........
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:101,代码来源:PasteTest.ts

示例2: ModernTheme

UnitTest.asynctest('tinymce.plugins.paste.browser.PasteFormatToggleTest', (success, failure) => {
  ModernTheme();
  PastePlugin();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const steps = Env.webkit ? [
      Logger.t('paste plain text',
        GeneralSteps.sequence([
          tinyApis.sExecCommand('mceTogglePlainTextPaste'),
          Paste.sPaste(editor, { 'text/html': '<p><strong>test</strong></p>'}),
          tinyApis.sAssertContent('<p>test</p>'),
          tinyApis.sSetContent(''),
          tinyApis.sExecCommand('mceTogglePlainTextPaste'),
          Paste.sPaste(editor, { 'text/html': '<p><strong>test</strong></p>'}),
          tinyApis.sAssertContent('<p><strong>test</strong></p>')
        ])
      )
    ] : [];

    Pipeline.async({}, steps, onSuccess, onFailure);
  }, {
    plugins: 'paste',
    toolbar: '',
    valid_styles: 'font-family,color',
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:abstask,项目名称:tinymce,代码行数:28,代码来源:PasteFormatToggleTest.ts

示例3: success

UnitTest.asynctest('tinymce.plugins.paste.webdriver.CutTest', (success, failure) => {

  Theme();
  PastePlugin();

  const platform = PlatformDetection.detect();

  /* Test does not work on Phantom */
  if (window.navigator.userAgent.indexOf('PhantomJS') > -1) {
    return success();
  }

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const api = TinyApis(editor);
    const ui = TinyUi(editor);

    // Cut doesn't seem to work in webdriver mode on ie, firefox is producing moveto not supported, edge fails if it's not observed
    Pipeline.async({}, (platform.browser.isIE() || platform.browser.isFirefox() || platform.browser.isEdge()) ? [] :
    Log.steps('TBA', 'Paste: Set and select content, cut using edit menu and assert cut content', [
      api.sSetContent('<p>abc</p>'),
      api.sSetSelection([0, 0], 1, [0, 0], 2),
      ui.sClickOnMenu('Click Edit menu', 'button:contains("Edit")'),
      Chain.asStep({}, [
        ui.cWaitForUi('Wait for menu item', '[role="menuitem"]:contains("Cut")'),
        RealMouse.cClick()
      ]),
      Waiter.sTryUntil('Cut is async now, so need to wait for content', api.sAssertContent('<p>ac</p>'), 100, 1000)
    ]), onSuccess, onFailure);
  }, {
    base_url: '/project/tinymce/js/tinymce',
    theme: 'silver'
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:33,代码来源:CutTest.ts

示例4: success

UnitTest.asynctest('tinymce.plugins.paste.webdriver.CutTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  Theme();
  PastePlugin();

  const platform = PlatformDetection.detect();

  /* Test does not work on Phantom */
  if (window.navigator.userAgent.indexOf('PhantomJS') > -1) {
    return success();
  }

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const api = TinyApis(editor);
    const ui = TinyUi(editor);

    // Cut doesn't seem to work in webdriver mode on ie, firefox is producing moveto not supported, edge fails if it's not observed
    Pipeline.async({}, (platform.browser.isIE() || platform.browser.isFirefox() || platform.browser.isEdge()) ? [] : [
      api.sSetContent('<p>abc</p>'),
      api.sSetSelection([0, 0], 1, [0, 0], 2),
      ui.sClickOnMenu('Click Edit menu', 'button:contains("Edit")'),
      ui.sWaitForUi('Wait for dropdown', '.mce-floatpanel[role="application"]'),
      RealMouse.sClickOn('.mce-i-cut'),
      Waiter.sTryUntil('Cut is async now, so need to wait for content', api.sAssertContent('<p>ac</p>'), 100, 1000)
    ], onSuccess, onFailure);
  }, {
    skin_url: '/project/js/tinymce/skins/lightgray',
    plugins: 'paste'
  }, success, failure);
});
开发者ID:danielpunkass,项目名称:tinymce,代码行数:32,代码来源:CutTest.ts

示例5: mobileTheme

UnitTest.asynctest('browser.tinymce.themes.mobile.ThemeTest', (success, failure) => {

  mobileTheme();
  ImagePlugin();
  TablePlugin();
  LinkPlugin();
  PastePlugin();
  ContextMenuPlugin();
  TextPatternPlugin();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const ui = TinyUi(editor);

    Pipeline.async({}, [
      UiFinder.sExists(Element.fromDom(document.body), `.${Styles.resolve('mask-tap-icon')}`),
      ui.sClickOnUi('Click the tap to edit button', `.${Styles.resolve('mask-tap-icon')}`),
      ui.sWaitForUi('Wait mobile Toolbar', `.${Styles.resolve('toolbar')}`),
      ui.sWaitForUi('Check for The first group', '[aria-label="The first group"]'),
      ui.sWaitForUi('Check for the action group', '[aria-label="the action group"]'),
      UiFinder.sNotExists(Element.fromDom(document.body), '[aria-label="The read only mode group"]'),
      UiFinder.sNotExists(Element.fromDom(document.body), `.${Styles.resolve('mask-edit-icon')}`),
      ui.sClickOnUi('Click back to Tap to Edit screen', `.${Styles.resolve('icon-back')}`),
      UiFinder.sExists(Element.fromDom(document.body), `.${Styles.resolve('mask-tap-icon')}`),
    ], onSuccess, onFailure);
  }, {
    theme: 'mobile',
    plugins: 'image table link paste textpattern',
    insert_toolbar: 'quickimage media quicktable',
    selection_toolbar: 'bold italic | quicklink h1 h2 blockquote',
    inline: false,
    base_url: '/project/tinymce/js/tinymce'
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:33,代码来源:ThemeTest.ts

示例6: Theme

UnitTest.asynctest('tinymce.plugins.paste.browser.PasteSettingsTest', (success, failure) => {
  Theme();
  Plugin();

  const cCreateInlineEditor = function (settings) {
    return Chain.control(
      McEditor.cFromSettings(Merger.merge(settings, {
        inline: true,
        base_url: '/project/tinymce/js/tinymce'
      })),
      Guard.addLogging('Create inline editor')
    );
  };

  const cRemoveEditor = Chain.control(
    McEditor.cRemove,
    Guard.addLogging('Remove editor')
  );

  Pipeline.async({}, [
    Chain.asStep({}, Log.chains('TBA', 'Paste: paste_as_text setting', [
      cCreateInlineEditor({
        paste_as_text: true,
        plugins: 'paste'
      }),
      Chain.op(function (editor) {
        Assertions.assertEq('Should be text format', 'text', editor.plugins.paste.clipboard.pasteFormat.get());
      }),
      cRemoveEditor
    ]))
  ], function () {
    success();
  }, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:34,代码来源:PasteSettingsTest.ts

示例7: function

UnitTest.test('tinymce.plugins.paste.browser.NewlinesTest', function () {
  Theme();
  PastePlugin();

  // testing Newlines.isPlainText()
  const textCases = [
    {
      label: 'Basic Chrome markup (including span-wrapped tab)',
      content: '<div><span style="white-space:pre">  </span>a</div><div><br></div><div>b</div>',
      isText: true
    },
    {
      label: 'Case shouldn\'t matter',
      content: '<DIV>a</DIV><DIV><BR></DIV>',
      isText: true
    },
    {
      label: 'Support all BR types',
      content: '<br><br />',
      isText: true
    },
    {
      label: 'Basic IE markup',
      content: '<p>a</p><p><br></p><p>b</p>',
      isText: true
    },
    {
      label: 'White-space wrapper (Chrome)',
      content: '<div><span style="white-space: pre;"> </span>a</div>',
      isText: true
    },
    {
      label: 'White-space wrapper (Chrome) with additional styles',
      content: '<div><span style="white-space: pre; color: red;"> </span>a</div>',
      isText: false
    },
    {
      label: 'Allowed tag but with attributes qualifies string as not a plain text',
      content: '<br data-mce-bogus="all" />',
      isText: false
    }
  ];

  // only DIV,P,BR and SPAN[style="white-space:pre"] tags are allowed in "plain text" string
  Arr.each('a,abbr,address,article,aside,audio,b,bdi,bdo,blockquote,button,cite,code,del,details,dfn,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,ins,label,menu,nav,noscript,object,ol,pre,q,s,script,section,select,small,strong,style,sub,sup,svg,table,textarea,time,u,ul,var,video,wbr'.split(','),
    function (tag) {
      const content = '<p>a</p><' + tag + '>b</' + tag + '><p>c<br>d</p>';
      textCases.push({
        label: tag.toUpperCase() + ' tag should qualify content (' + content + ') as not a plain text',
        content,
        isText: false
      });
    }
  );

  Obj.each(textCases, function (c) {
    Assertions.assertEq(c.label || 'Asserting: ' + c.content, c.isText, Newlines.isPlainText(c.content));
  });
});
开发者ID:abstask,项目名称:tinymce,代码行数:59,代码来源:NewlinesTest.ts

示例8: function

UnitTest.asynctest('Browser Test: .PasteStylesTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  ModernTheme();
  PastePlugin();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const steps = Env.webkit ? [
      Logger.t('Paste span with encoded style attribute, paste_webkit_styles: font-family',
        GeneralSteps.sequence([
          tinyApis.sSetSetting('paste_webkit_styles', 'font-family'),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;;color:green;">b</span>' }),
          tinyApis.sAssertContent('<p><span style="font-family: \'a b\';">b</span></p>')
        ])
      ),

      Logger.t('Paste span with encoded style attribute, paste_webkit_styles: all',
        GeneralSteps.sequence([
          tinyApis.sSetSetting('paste_webkit_styles', 'all'),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;; color: green;">b</span>' }),
          tinyApis.sAssertContent('<p><span style="font-family: \'a b\'; color: green;">b</span></p>')
        ])
      ),

      Logger.t('Paste span with encoded style attribute, paste_webkit_styles: none',
        GeneralSteps.sequence([
          tinyApis.sSetSetting('paste_webkit_styles', 'none'),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;;">b</span>' }),
          tinyApis.sAssertContent('<p>b</p>')
        ])
      ),

      Logger.t('Paste span with encoded style attribute, paste_remove_styles_if_webkit: false',
        GeneralSteps.sequence([
          tinyApis.sSetSetting('paste_remove_styles_if_webkit', false),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;;">b</span>' }),
          tinyApis.sAssertContent('<p><span style="font-family: \'a b\';">b</span></p>')
        ])
      )
    ] : [];

    Pipeline.async({}, steps, onSuccess, onFailure);
  }, {
    plugins: 'paste',
    toolbar: '',
    valid_styles: 'font-family,color',
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:abstask,项目名称:tinymce,代码行数:59,代码来源:PasteStylesTest.ts

示例9: Theme

UnitTest.asynctest('Browser Test: .PasteStylesTest', (success, failure) => {

  Theme();
  PastePlugin();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const steps = Env.webkit ? [
      Log.stepsAsStep('TBA', 'Paste: Paste span with encoded style attribute, paste_webkit_styles: font-family',
        [
          tinyApis.sSetSetting('paste_webkit_styles', 'font-family'),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;;color:green;">b</span>' }),
          tinyApis.sAssertContent('<p><span style="font-family: \'a b\';">b</span></p>')
        ]
      ),

      Log.stepsAsStep('TBA', 'Paste: Paste span with encoded style attribute, paste_webkit_styles: all',
        [
          tinyApis.sSetSetting('paste_webkit_styles', 'all'),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;; color: green;">b</span>' }),
          tinyApis.sAssertContent('<p><span style="font-family: \'a b\'; color: green;">b</span></p>')
        ]
      ),

      Log.stepsAsStep('TBA', 'Paste: Paste span with encoded style attribute, paste_webkit_styles: none',
        [
          tinyApis.sSetSetting('paste_webkit_styles', 'none'),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;;">b</span>' }),
          tinyApis.sAssertContent('<p>b</p>')
        ]
      ),

      Log.stepsAsStep('TBA', 'Paste: Paste span with encoded style attribute, paste_remove_styles_if_webkit: false',
        [
          tinyApis.sSetSetting('paste_remove_styles_if_webkit', false),
          tinyApis.sSetContent('<p>test</p>'),
          tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
          Paste.sPaste(editor, { 'text/html': '<span style="font-family: &quot;a b&quot;;">b</span>' }),
          tinyApis.sAssertContent('<p><span style="font-family: \'a b\';">b</span></p>')
        ]
      )
    ] : [];

    Pipeline.async({}, steps, onSuccess, onFailure);
  }, {
    plugins: 'paste',
    toolbar: '',
    valid_styles: 'font-family,color',
    base_url: '/project/tinymce/js/tinymce'
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:57,代码来源:PasteStylesTest.ts

示例10: function

UnitTest.asynctest('tinymce.plugins.paste.browser.PasteSettingsTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const viewBlock = ViewBlock();

  Theme();
  Plugin();

  const cCreateInlineEditor = function (settings) {
    return Chain.on(function (viewBlock, next, die) {
      viewBlock.update('<div id="inline-tiny"></div>');

      EditorManager.init(Merger.merge({
        selector: '#inline-tiny',
        inline: true,
        skin_url: '/project/js/tinymce/skins/lightgray',
        setup (editor) {
          editor.on('SkinLoaded', function () {
            next(Chain.wrap(editor));
          });
        }
      }, settings));
    });
  };

  const cRemoveEditor = Chain.op(function (editor) {
    editor.remove();
  });

  viewBlock.attach();
  Pipeline.async({}, [
    Logger.t('paste_as_text setting', Chain.asStep(viewBlock, [
      cCreateInlineEditor({
        paste_as_text: true,
        plugins: 'paste'
      }),
      Chain.op(function (editor) {
        Assertions.assertEq('Should be text format', 'text', editor.plugins.paste.clipboard.pasteFormat);
      }),
      cRemoveEditor
    ]))
  ], function () {
    viewBlock.detach();
    success();
  }, failure);
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:46,代码来源:PasteSettingsTest.ts


注:本文中的tinymce/plugins/paste/Plugin.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。