• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Plugin.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: function

export default function () {
  AdvListPlugin();
  AnchorPlugin();
  AutoLinkPlugin();
  AutoResizePlugin();
  AutoSavePlugin();
  BbCodePlugin();
  CharMapPlugin();
  CodePlugin();
  CodeSamplePlugin();
  ColorPickerPlugin();
  ContextMenuPlugin();
  DirectionalityPlugin();
  EmoticonsPlugin();
  FullPagePlugin();
  FullScreenPlugin();
  HrPlugin();
  ImagePlugin();
  ImageToolsPlugin();
  ImportCssPlugin();
  InsertDatetimePlugin();
  LegacyOutputPlugin();
  LinkPlugin();
  ListsPlugin();
  MediaPlugin();
  NonBreakingPlugin();
  NonEditablePlugin();
  PageBreakPlugin();
  PastePlugin();
  PreviewPlugin();
  PrintPlugin();
  SavePlugin();
  SearchReplacePlugin();
  SpellCheckerPlugin();
  TabFocusPlugin();
  TablePlugin();
  TemplatePlugin();
  TextColorPlugin();
  TextPatternPlugin();
  TocPlugin();
  VisualBlocksPlugin();
  VisualCharsPlugin();
  WordCountPlugin();
  ModernTheme();
  MobileTheme();
  HelpPlugin();

  PluginManager.urls.emoticons = '../../../../js/tinymce/plugins/emoticons';

  const settings = {
    skin_url: '../../../../js/tinymce/skins/lightgray',
    codesample_content_css: '../../../../js/tinymce/plugins/codesample/css/prism.css',
    visualblocks_content_css: '../../../../js/tinymce/plugins/visualblocks/css/visualblocks.css',
    images_upload_url: 'd',
    selector: 'textarea',
    // rtl_ui: true,
    link_list: [
      { title: 'My page 1', value: 'http://www.tinymce.com' },
      { title: 'My page 2', value: 'http://www.moxiecode.com' }
    ],
    image_list: [
      { title: 'My page 1', value: 'http://www.tinymce.com' },
      { title: 'My page 2', value: 'http://www.moxiecode.com' }
    ],
    image_class_list: [
      { title: 'None', value: '' },
      { title: 'Some class', value: 'class-name' }
    ],
    importcss_append: true,
    height: 400,
    file_picker_callback (callback, value, meta) {
      // Provide file and text for the link dialog
      if (meta.filetype === 'file') {
        callback('https://www.google.com/logos/google.jpg', { text: 'My text' });
      }

      // Provide image and alt text for the image dialog
      if (meta.filetype === 'image') {
        callback('https://www.google.com/logos/google.jpg', { alt: 'My alt text' });
      }

      // Provide alternative source and posted for the media dialog
      if (meta.filetype === 'media') {
        callback('movie.mp4', { source2: 'alt.ogg', poster: 'https://www.google.com/logos/google.jpg' });
      }
    },
    spellchecker_callback (method, text, success, failure) {
      const words = text.match(this.getWordCharPattern());

      if (method === 'spellcheck') {
        const suggestions = {};

        for (let i = 0; i < words.length; i++) {
          suggestions[words[i]] = ['First', 'Second'];
        }

        success(suggestions);
      }

      if (method === 'addToDictionary') {
//.........这里部分代码省略.........
开发者ID:howardjing,项目名称:tinymce,代码行数:101,代码来源:FullDemo.ts


示例2: function

export default function () {
  AdvListPlugin();
  AnchorPlugin();
  AutoLinkPlugin();
  AutoResizePlugin();
  AutoSavePlugin();
  BbCodePlugin();
  CharMapPlugin();
  CodePlugin();
  CodeSamplePlugin();
  ColorPickerPlugin();
  ContextMenuPlugin();
  DirectionalityPlugin();
  EmoticonsPlugin();
  FullPagePlugin();
  FullScreenPlugin();
  HrPlugin();
  ImagePlugin();
  ImageToolsPlugin();
  ImportCssPlugin();
  InsertDatetimePlugin();
  LegacyOutputPlugin();
  LinkPlugin();
  ListsPlugin();
  MediaPlugin();
  NonBreakingPlugin();
  NonEditablePlugin();
  PageBreakPlugin();
  PastePlugin();
  PreviewPlugin();
  PrintPlugin();
  SavePlugin();
  SearchReplacePlugin();
  SpellCheckerPlugin();
  TabFocusPlugin();
  TablePlugin();
  TemplatePlugin();
  TextColorPlugin();
  TextPatternPlugin();
  TocPlugin();
  VisualBlocksPlugin();
  VisualCharsPlugin();
  WordCountPlugin();
  ModernTheme();

  const cmd = function (command, value?) {
    return { command, value };
  };

  const commands = [
    cmd('Bold'),
    cmd('Italic'),
    cmd('Underline'),
    cmd('Strikethrough'),
    cmd('Superscript'),
    cmd('Subscript'),
    cmd('Cut'),
    cmd('Copy'),
    cmd('Paste'),
    cmd('Unlink'),
    cmd('JustifyLeft'),
    cmd('JustifyCenter'),
    cmd('JustifyRight'),
    cmd('JustifyFull'),
    cmd('JustifyNone'),
    cmd('InsertUnorderedList'),
    cmd('InsertOrderedList'),
    cmd('ForeColor', 'red'),
    cmd('HiliteColor', 'green'),
    cmd('FontName', 'Arial'),
    cmd('FontSize', 7),
    cmd('RemoveFormat'),
    cmd('mceBlockQuote'),
    cmd('FormatBlock', 'h1'),
    cmd('mceInsertContent', 'abc'),
    cmd('mceToggleFormat', 'bold'),
    cmd('mceSetContent', 'abc'),
    cmd('Indent'),
    cmd('Outdent'),
    cmd('InsertHorizontalRule'),
    cmd('mceToggleVisualAid'),
    cmd('mceInsertLink', 'url'),
    cmd('selectAll'),
    cmd('delete'),
    cmd('mceNewDocument'),
    cmd('Undo'),
    cmd('Redo'),
    cmd('mceAutoResize'),
    cmd('mceShowCharmap'),
    cmd('mceCodeEditor'),
    cmd('mceDirectionLTR'),
    cmd('mceDirectionRTL'),
    cmd('mceFullPageProperties'),
    cmd('mceFullscreen'),
    cmd('mceImage'),
    cmd('mceInsertDate'),
    cmd('mceInsertTime'),
    cmd('InsertDefinitionList'),
    cmd('mceNonBreaking'),
    cmd('mcePageBreak'),
//.........这里部分代码省略.........
开发者ID:howardjing,项目名称:tinymce,代码行数:101,代码来源:CommandsDemo.ts


示例3: success

UnitTest.asynctest('browser.tinymce.plugins.imagetools.SequenceTest', (success, failure) => {

  const platform = PlatformDetection.detect();

  if (platform.browser.isIE() || platform.browser.isEdge()) {
    console.log('Disabled on IE and Edge because of race conditions');
    return success();
  }

  const srcUrl = '/project/tinymce/src/plugins/imagetools/demo/img/dogleft.jpg';
  // var corsUrl = 'http://moxiecode.cachefly.net/tinymce/v9/images/logo.png';

  Plugin();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const imgOps = ImageOps(editor);

    const sManipulateImage = function (message, url) {
      return Log.stepsAsStep('TBA', `ImageTools: ${message}`, [
        ImageUtils.sLoadImage(editor, url),
        tinyApis.sSelect('img', []),
        imgOps.sExecToolbar('Flip horizontally'),
        imgOps.sExecToolbar('Rotate clockwise'),
        imgOps.sExecDialog('Invert'),
        imgOps.sExecDialog('Crop'),
        imgOps.sExecDialog('Resize'),
        imgOps.sExecDialog('Flip vertically'),
        imgOps.sExecDialog('Rotate clockwise'),
        imgOps.sExecDialog('Brightness'),
        imgOps.sExecDialog('Sharpen'),
        imgOps.sExecDialog('Contrast'),
        imgOps.sExecDialog('Color levels'),
        imgOps.sExecDialog('Gamma')
      ]);
    };

    Pipeline.async({}, [
      // sManipulateImage('Test image operations on an image CORS domain', corsUrl),
      sManipulateImage('Test image operations on an image from the same domain', srcUrl)
    ], onSuccess, onFailure);
  }, {
    theme: 'silver',
    plugins: 'imagetools',
    imagetools_cors_hosts: ['moxiecode.cachefly.net'],
    base_url: '/project/tinymce/js/tinymce',
    toolbar: 'editimage',
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:49,代码来源:SequenceTest.ts


示例4: function

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

  const srcUrl = '/project/src/plugins/imagetools/demo/img/dogleft.jpg';
  // var corsUrl = 'http://moxiecode.cachefly.net/tinymce/v9/images/logo.png';

  Plugin();
  ModernTheme();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const imgOps = ImageOps(editor);

    const sManipulateImage = function (message, url) {
      return Logger.t(message, GeneralSteps.sequence([
        ImageUtils.sLoadImage(editor, url),
        tinyApis.sSelect('img', []),
        imgOps.sExecToolbar('Flip horizontally'),
        imgOps.sExecToolbar('Rotate clockwise'),
        imgOps.sExecDialog('Invert'),
        imgOps.sExecDialog('Crop'),
        imgOps.sExecDialog('Resize'),
        imgOps.sExecDialog('Flip vertically'),
        imgOps.sExecDialog('Rotate clockwise'),
        imgOps.sExecDialog('Brightness'),
        imgOps.sExecDialog('Sharpen'),
        imgOps.sExecDialog('Contrast'),
        imgOps.sExecDialog('Color levels'),
        imgOps.sExecDialog('Gamma')
      ]));
    };

    Pipeline.async({}, [
      // sManipulateImage('Test image operations on an image CORS domain', corsUrl),
      sManipulateImage('Test image operations on an image from the same domain', srcUrl)
    ], onSuccess, onFailure);
  }, {
    plugins: 'imagetools',
    imagetools_cors_hosts: ['moxiecode.cachefly.net'],
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:43,代码来源:SequenceTest.ts


示例5:

 * Released under LGPL License.
 * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

import DomQuery from 'tinymce/core/dom/DomQuery';
import ImageToolsPlugin from 'tinymce/plugins/imagetools/Plugin';

declare let tinymce: any;

const $ = DomQuery;
const imgSrc = '../img/dogleft.jpg';

ImageToolsPlugin();

$(
  '<textarea class="tinymce">' +
  '<p>' +
  '<img src="' + imgSrc + '" width="160" height="100">' +
  '<img src="' + imgSrc + '" style="width: 160px; height: 100px">' +
  '<img src="' + imgSrc + '" style="width: 20%">' +
  '<img src="' + imgSrc + '">' +
  '<img src="http://moxiecode.cachefly.net/tinymce/v9/images/logo.png">' +
  '</p>' +
  '</textarea>',
).appendTo('#ephox-ui');

tinymce.init({
  // imagetools_cors_hosts: ["moxiecode.cachefly.net"],
开发者ID:howardjing,项目名称:tinymce,代码行数:31,代码来源:Demo.ts


示例6: Plugin

UnitTest.asynctest('browser.tinymce.plugins.imagetools.ImageToolsPluginTest', (success, failure) => {
  const uploadHandlerState = ImageUtils.createStateContainer();

  const srcUrl = '/project/tinymce/src/plugins/imagetools/demo/img/dogleft.jpg';

  Plugin();

  const sAssertUploadFilename = function (expected) {
    return Logger.t('Assert uploaded filename', Step.sync(function () {
      const blobInfo = uploadHandlerState.get().blobInfo;
      RawAssertions.assertEq('Should be expected file name', expected, blobInfo.filename());
    }));
  };

  const sAssertUploadFilenameMatches = function (matchRegex) {
    return Logger.t('Assert uploaded filename', Step.sync(function () {
      const blobInfo = uploadHandlerState.get().blobInfo;
      RawAssertions.assertEq(`File name ${blobInfo.filename()} should match ${matchRegex}`, true, matchRegex.test(blobInfo.filename()));
    }));
  };

  const sAssertUri = function (expected) {
    return Logger.t('ImageTools: Assert uri', Step.sync(function () {
      const blobInfo = uploadHandlerState.get().blobInfo;
      const uri = new URI(blobInfo.uri());
      RawAssertions.assertEq('Should be expected uri', expected, uri.relative);
    }));
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      Log.stepsAsStep('TBA', 'ImageTools: test generate filename', [
        uploadHandlerState.sResetState,
        tinyApis.sSetSetting('images_reuse_filename', false),
        ImageUtils.sLoadImage(editor, srcUrl),
        tinyApis.sSelect('img', []),
        ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
        ImageUtils.sWaitForBlobImage(editor),
        ImageUtils.sUploadImages(editor),
        uploadHandlerState.sWaitForState,
        sAssertUploadFilenameMatches(/imagetools\d+\.jpg/)
      ]),
      Log.stepsAsStep('TBA', 'ImageTools: test reuse filename', [
        uploadHandlerState.sResetState,
        tinyApis.sSetSetting('images_reuse_filename', true),
        ImageUtils.sLoadImage(editor, srcUrl),
        tinyApis.sSelect('img', []),
        ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
        ImageUtils.sWaitForBlobImage(editor),
        ImageUtils.sUploadImages(editor),
        uploadHandlerState.sWaitForState,
        sAssertUploadFilename('dogleft.jpg'),
        sAssertUri(srcUrl)
      ]),
      Log.stepsAsStep('TBA', 'ImageTools: test rotate image', [
        ImageUtils.sLoadImage(editor, srcUrl, {width: 200, height: 100}),
        tinyApis.sSelect('img', []),
        ImageUtils.sExecCommand(editor, 'mceImageRotateRight'),
        ImageUtils.sWaitForBlobImage(editor),
        tinyApis.sAssertContentPresence({
          'img[width="100"][height="200"]': 1
        })
      ])
    ], onSuccess, onFailure);
  }, {
    theme: 'silver',
    plugins: 'imagetools',
    automatic_uploads: false,
    images_upload_handler: uploadHandlerState.handler(srcUrl),
    base_url: '/project/tinymce/js/tinymce',
  }, success, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:74,代码来源:ImageToolsPluginTest.ts


示例7: function

UnitTest.asynctest('browser.tinymce.plugins.imagetools.ImageToolsErrorTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const uploadHandlerState = ImageUtils.createStateContainer();

  const corsUrl = 'http://moxiecode.cachefly.net/tinymce/v9/images/logo.png';

  Plugin();
  ModernTheme();

  const sAssertErrorMessage = function (html) {
    return Chain.asStep(TinyDom.fromDom(document.body), [
      UiFinder.cWaitFor('Could not find notification', '.mce-notification-inner'),
      Chain.mapper(Html.get),
      Assertions.cAssertHtml('Message html does not match', html)
    ]);
  };

  const sCloseErrorMessage = Chain.asStep(TinyDom.fromDom(document.body), [
    UiFinder.cWaitFor('Could not find notification', '.mce-notification > button'),
    Mouse.cClick
  ]);

  TinyLoader.setup(
    function (editor, onSuccess, onFailure) {
      const tinyApis = TinyApis(editor);
      const stepsWithTeardown = Arr.bind([
        Logger.t('incorrect service url no api key', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', 'http://0.0.0.0.0.0/'),
          tinyApis.sSetSetting('api_key', undefined),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy HTTP error: Incorrect Image Proxy URL')
        ])),

        Logger.t('incorrect service url with api key', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', 'http://0.0.0.0.0.0/'),
          tinyApis.sSetSetting('api_key', 'fake_key'),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy HTTP error: Incorrect Image Proxy URL')
        ])),

        Logger.t('403 no api key', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', '/custom/403'),
          tinyApis.sSetSetting('api_key', undefined),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy HTTP error: Rejected request')
        ])),

        Logger.t('403 with api key', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', '/custom/403'),
          tinyApis.sSetSetting('api_key', 'fake_key'),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy Service error: Invalid JSON in service error message')
        ])),

        Logger.t('403 with api key and return error data', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', '/custom/403data'),
          tinyApis.sSetSetting('api_key', 'fake_key'),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy Service error: Unknown service error')
        ])),

        Logger.t('404 no api key', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', '/custom/404'),
          tinyApis.sSetSetting('api_key', undefined),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy HTTP error: Could not find Image Proxy')
        ])),

        Logger.t('404 with api key', GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          tinyApis.sSetSetting('imagetools_proxy', '/custom/404'),
          tinyApis.sSetSetting('api_key', 'fake_key'),
          ImageUtils.sLoadImage(editor, corsUrl),
          tinyApis.sSelect('img', []),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage('ImageProxy HTTP error: Could not find Image Proxy')
        ]))
      ], function (step) {
        return [
          step,
          GeneralSteps.sequence([
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:ImageToolsErrorTest.ts


示例8: function

UnitTest.asynctest('browser.tinymce.plugins.imagetools.ImageToolsErrorTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const uploadHandlerState = ImageUtils.createStateContainer();

  const corsUrl = 'http://moxiecode.cachefly.net/tinymce/v9/images/logo.png';

  Plugin();

  const sAssertErrorMessage = function (html) {
    return Step.label('Check notification message', Chain.asStep(TinyDom.fromDom(document.body), [
      UiFinder.cWaitFor('Find notification', '.tox-notification__body > p'),
      Chain.label('Get notification HTML', Chain.mapper(Html.get)),
      Chain.label('Assert HTML matches expected', Assertions.cAssertHtml('Message html does not match', html))
    ]));
  };

  const sCloseErrorMessage = Step.label('Close error message', Chain.asStep(TinyDom.fromDom(document.body), [
    UiFinder.cWaitFor('Could not find notification', '.tox-notification > button'),
    Mouse.cClick
  ]));

  TinyLoader.setup(
    function (editor, onSuccess, onFailure) {
      const tinyApis = TinyApis(editor);

      const sTestImageToolsError = (testId, description, proxyUrl, apiKey, errorMessage) => Log.step(
        testId, description, GeneralSteps.sequence([
          uploadHandlerState.sResetState,
          Step.label('Set image proxy URL', tinyApis.sSetSetting('imagetools_proxy', proxyUrl)),
          Step.label('Set API key', tinyApis.sSetSetting('api_key', apiKey)),
          ImageUtils.sLoadImage(editor, corsUrl),
          Step.label('Select image', tinyApis.sSelect('img', [])),
          ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
          sAssertErrorMessage(errorMessage),
          sCloseErrorMessage,
          Step.label('Clear editor content', tinyApis.sSetContent(''))
        ])
      );

      const tests = [

        sTestImageToolsError('TBA', 'Incorrect service url no api key',
            'http://0.0.0.0.0.0/', undefined, 'ImageProxy HTTP error: Incorrect Image Proxy URL'),

        sTestImageToolsError('TBA', 'Incorrect service url with api key',
            'http://0.0.0.0.0.0/', 'fake_key', 'ImageProxy HTTP error: Incorrect Image Proxy URL'),

        sTestImageToolsError('TBA', '403 no api key',
            '/custom/403', undefined, 'ImageProxy HTTP error: Rejected request'),

        sTestImageToolsError('TBA', '403 with api key',
            '/custom/403', 'fake_key', 'ImageProxy Service error: Invalid JSON in service error message'),

        sTestImageToolsError('TBA', '403 with api key and return error data',
            '/custom/403data', 'fake_key', 'ImageProxy Service error: Unknown service error'),

        sTestImageToolsError('TBA', '404 no api key',
            '/custom/404', undefined, 'ImageProxy HTTP error: Could not find Image Proxy'),

        sTestImageToolsError('TBA', '404 with api key',
            '/custom/404', 'fake_key', 'ImageProxy HTTP error: Could not find Image Proxy'),

      ];

      Pipeline.async({}, tests, onSuccess, onFailure);
    },
    {
      theme: 'silver',
      plugins: 'imagetools',
      automatic_uploads: false,
      base_url: '/project/tinymce/js/tinymce',
    },
    success,
    failure
  );
});
开发者ID:tinymce,项目名称:tinymce,代码行数:77,代码来源:ImageToolsErrorTest.ts


示例9: function

UnitTest.asynctest('browser.tinymce.plugins.imagetools.ImageToolsPluginTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const uploadHandlerState = ImageUtils.createStateContainer();

  const srcUrl = '/project/src/plugins/imagetools/demo/img/dogleft.jpg';

  ModernTheme();
  Plugin();

  const sAssertUploadFilename = function (expected) {
    return Step.sync(function () {
      const blobInfo = uploadHandlerState.get().blobInfo;
      RawAssertions.assertEq('Should be expected file name', expected, blobInfo.filename());
    });
  };

  const sAssertUri = function (expected) {
    return Step.sync(function () {
      const blobInfo = uploadHandlerState.get().blobInfo;
      const uri = new URI(blobInfo.uri());
      RawAssertions.assertEq('Should be expected uri', expected, uri.relative);
    });
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    const sTestGenerateFileName = function () {
      return GeneralSteps.sequence([
        uploadHandlerState.sResetState,
        tinyApis.sSetSetting('images_reuse_filename', false),
        ImageUtils.sLoadImage(editor, srcUrl),
        tinyApis.sSelect('img', []),
        ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
        ImageUtils.sWaitForBlobImage(editor),
        ImageUtils.sUploadImages(editor),
        uploadHandlerState.sWaitForState,
        sAssertUploadFilename('imagetools0.jpg')
      ]);
    };

    const sTestReuseFilename = function () {
      return GeneralSteps.sequence([
        uploadHandlerState.sResetState,
        tinyApis.sSetSetting('images_reuse_filename', true),
        ImageUtils.sLoadImage(editor, srcUrl),
        tinyApis.sSelect('img', []),
        ImageUtils.sExecCommand(editor, 'mceImageFlipHorizontal'),
        ImageUtils.sWaitForBlobImage(editor),
        ImageUtils.sUploadImages(editor),
        uploadHandlerState.sWaitForState,
        sAssertUploadFilename('dogleft.jpg'),
        sAssertUri(srcUrl)
      ]);
    };

    Pipeline.async({}, [
      sTestGenerateFileName(),
      sTestReuseFilename()
    ], onSuccess, onFailure);
  }, {
    plugins: 'imagetools',
    automatic_uploads: false,
    images_upload_handler: uploadHandlerState.handler(srcUrl),
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:68,代码来源:ImageToolsPluginTest.ts


示例10: Theme

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

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);
    const doc = Element.fromDom(document);
    const imgOps = ImageOps(editor);

    const srcUrl = '/project/tinymce/src/plugins/imagetools/demo/img/dogleft.jpg';

    const sOpenContextToolbar = (source) => {
      return GeneralSteps.sequence([
        ImageUtils.sLoadImage(editor, source, {width: 800, height: 600}),
        tinyApis.sSelect('img', []),
        tinyUi.sWaitForUi('Wait for table context toolbar', '.tox-toolbar button[aria-label="Rotate counterclockwise"]'),
      ]);
    };

    // Use keyboard shortcut ctrl+F9 to navigate to the context toolbar
    const sPressKeyboardShortcutKey = Keyboard.sKeydown(Element.fromDom(editor.getDoc()), 120, { ctrl: true });
    const sPressRightArrowKey = Keyboard.sKeydown(doc, Keys.right(), { });

    // Assert focus is on the expected toolbar button
    const sAssertFocusOnItem = (label, selector) => {
      return FocusTools.sTryOnSelector(`Focus should be on: ${label}`, doc, selector);
    };

    const sOpenAndCloseDialog = (label) => {
      return GeneralSteps.sequence([
        Chain.asStep(editor, [
          tinyUi.cWaitForPopup('wait for dialog', `div:contains("${label}")`),
          UiChains.cCloseDialog('div[role="dialog"]')
        ]),
        Waiter.sTryUntil('Wait for dialog to close', UiFinder.sNotExists(TinyDom.fromDom(document.body), 'div[role="dialog"]'), 50, 5000)
      ]);
    };

    const cGetImageSrc = Chain.mapper(() => {
      const dom = editor.dom;
      const element = dom.getParent(editor.selection.getStart(), 'img');
      return dom.getAttrib(element, 'src');
    });

    const cClickContextToolbarButton = (label) => {
      return Chain.fromParent(tinyUi.cWaitForPopup('wait for Imagetools toolbar', '.tox-pop__dialog div'), [
        imgOps.cClickToolbarButton(label)
      ]);
    };

    const cGetImageSources = (label) => {
      return NamedChain.asChain(
        [
          NamedChain.direct(NamedChain.inputName(), Chain.identity, 'editor'),
          Chain.label('Store img src before flip', NamedChain.write('srcBeforeFlip', cGetImageSrc)),
          Chain.label('Flip image', NamedChain.read('editor', cClickContextToolbarButton(label))),
          // Wait for image to flip
          Chain.wait(500),
          Chain.label('Store img src after flip', NamedChain.write('srcAfterFlip', cGetImageSrc)),
          NamedChain.merge(['srcBeforeFlip', 'srcAfterFlip'], 'urls'),
          NamedChain.output('urls')
        ]
      );
    };

    const sAssertImageFlip = (label) => {
      return Chain.asStep({editor}, [
        Chain.label(`Assert ${label}`,
        NamedChain.asChain([
          NamedChain.direct(NamedChain.inputName(), Chain.identity, 'editor'),
          NamedChain.direct('editor', cGetImageSources(label), 'urls'),
          NamedChain.read('urls', Chain.op((urls) => {
            Assertions.assertEq(`Image should be flipped: ${label}`, true, ( urls.srcBeforeFlip !== urls.srcAfterFlip ));
          }))
        ]))
      ]);
    };

    Pipeline.async({}, [
      tinyApis.sFocus,
      Log.stepsAsStep('TBA', 'ImageTools: context toolbar keyboard navigation test', [
        sOpenContextToolbar(srcUrl),
        sPressKeyboardShortcutKey,
        sAssertFocusOnItem('Rotate counterclockwise button', 'button[aria-label="Rotate counterclockwise"]'),
        sPressRightArrowKey,
        sAssertFocusOnItem('Rotate clockwise button', 'button[aria-label="Rotate clockwise"]'),
        sPressRightArrowKey,
        sAssertFocusOnItem('Flip vertically button', 'button[aria-label="Flip vertically"]'),
        sPressRightArrowKey,
        sAssertFocusOnItem('Flip horizontally button', 'button[aria-label="Flip horizontally"]'),
        sPressRightArrowKey,
        sAssertFocusOnItem('Edit image button', 'button[aria-label="Edit image"]'),
        sPressRightArrowKey,
        sAssertFocusOnItem('Image options button', 'button[aria-label="Image options"]'),
        sPressRightArrowKey,
        sAssertFocusOnItem('Rotate counterclockwise button', 'button[aria-label="Rotate counterclockwise"]')
      ]),
      Log.stepsAsStep('TBA', 'ImageTools: context toolbar functionality test', [
        sOpenContextToolbar(srcUrl),
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:ContextToolbarTest.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript Plugin.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript Plugin.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap