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


TypeScript Conversions.uriToBlob函数代码示例

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


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

示例1: function

 suite.asyncTest('uriToBlob', function (world, done) {
   Conversions.uriToBlob(invalidBlobUriSrc).then(function () {
     LegacyUnit.equal(true, false, 'Conversion should fail.');
     done();
   }).catch(function (error) {
     LegacyUnit.equal(typeof error, 'string');
     LegacyUnit.equal(error.indexOf(invalidBlobUriSrc) !== -1, true);
     done();
   });
 });
开发者ID:abstask,项目名称:tinymce,代码行数:10,代码来源:ConversionsTest.ts

示例2: cPopupToDialog

 const sTriggerUpload = Step.async(function (next, die) {
   Conversions.uriToBlob(b64).then(function (blob) {
     Pipeline.async({}, [
       Chain.asStep({}, [
         cPopupToDialog('div[role="dialog"][aria-label="Insert/edit image"]'),
         Chain.op(function (win) {
           const browseBtn = win.find('browsebutton')[0];
           browseBtn.value = function () {
             return blob;
           };
           browseBtn.fire('change');
         })
       ])
     ], next, die);
   });
 });
开发者ID:abstask,项目名称:tinymce,代码行数:16,代码来源:UploadTabTest.ts

示例3:

 const sTriggerUpload = Logger.t('Trigger upload', Step.async(function (next, die) {
   Conversions.uriToBlob(b64).then(function (blob) {
     Pipeline.async({}, [
       Chain.asStep({}, [
         // cPopupToDialog('div[role="dialog"]'),
         ui.cWaitForPopup('Locate popup', 'div[role="dialog"]'),
         UiFinder.cFindIn('input[type="file"]'),
         Chain.op(function (browse) {
           const browseBtn = browse.dom();
           // In order for this to work we need to find a way to set files in the input
           browseBtn.files = [];
         })
       ])
     ], next, die);
   });
 }));
开发者ID:tinymce,项目名称:tinymce,代码行数:16,代码来源:UploadTabTest.ts

示例4: appendTeardown

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    let canvas, context;

    canvas = document.createElement('canvas');
    canvas.width = 320;
    canvas.height = 200;

    context = canvas.getContext('2d');
    context.fillStyle = '#ff0000';
    context.fillRect(0, 0, 160, 100);
    context.fillStyle = '#00ff00';
    context.fillRect(160, 0, 160, 100);
    context.fillStyle = '#0000ff';
    context.fillRect(0, 100, 160, 100);
    context.fillStyle = '#ff00ff';
    context.fillRect(160, 100, 160, 100);

    testBlobDataUri = canvas.toDataURL();

    Conversions.uriToBlob(testBlobDataUri).then(function () {
      const steps = appendTeardown(editor, suite.toSteps(editor));
      Pipeline.async({}, steps, onSuccess, onFailure);
    });
  }, {
开发者ID:abstask,项目名称:tinymce,代码行数:24,代码来源:EditorUploadTest.ts

示例5: function

UnitTest.asynctest('browser.tinymce.core.file.ImageScannerTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const suite = LegacyUnit.createSuite();
  const viewBlock = ViewBlock();

  if (!Env.fileApi) {
    return;
  }

  const base64Src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==';
  let blobUriSrc;
  const invalidBlobUriSrc = 'blob:70BE8432-BA4D-4787-9AB9-86563351FBF7';

  Conversions.uriToBlob(base64Src).then(function (blob) {
    blobUriSrc = URL.createObjectURL(blob);
  });

  suite.asyncTest('findAll', function (_, done) {
    const imageScanner = ImageScanner(UploadStatus(), BlobCache());

    viewBlock.update(
      '<img src="' + base64Src + '">' +
      '<img src="' + blobUriSrc + '">' +
      '<img src="' + Env.transparentSrc + '">' +
      '<img src="' + base64Src + '" data-mce-bogus="1">' +
      '<img src="' + base64Src + '" data-mce-placeholder="1">' +
      '<img src="' + invalidBlobUriSrc + '">'
    );

    imageScanner.findAll(viewBlock.get()).then(function (result) {
      done();
      const blobInfo = result[0].blobInfo;
      LegacyUnit.equal(result.length, 3);
      LegacyUnit.equal(typeof result[result.length - 1], 'string', 'Last item is not the image, but error message.');
      LegacyUnit.equal('data:image/gif;base64,' + blobInfo.base64(), base64Src);
      LegacyUnit.equalDom(result[0].image, viewBlock.get().firstChild);
    });
  });

  suite.asyncTest('findAll (filtered)', function (_, done) {
    const imageScanner = ImageScanner(UploadStatus(), BlobCache());

    const predicate = function (img) {
      return !img.hasAttribute('data-skip');
    };

    viewBlock.update(
      '<img src="' + base64Src + '">' +
      '<img src="' + base64Src + '" data-skip="1">'
    );

    imageScanner.findAll(viewBlock.get(), predicate).then(function (result) {
      done();
      LegacyUnit.equal(result.length, 1);
      LegacyUnit.equal('data:image/gif;base64,' + result[0].blobInfo.base64(), base64Src);
      LegacyUnit.equalDom(result[0].image, viewBlock.get().firstChild);
    });
  });

  Conversions.uriToBlob(base64Src).then(function (blob) {
    blobUriSrc = URL.createObjectURL(blob);

    viewBlock.attach();
    Pipeline.async({}, suite.toSteps({}), function () {
      viewBlock.detach();
      success();
    }, failure);
  });
});
开发者ID:tinymce,项目名称:tinymce,代码行数:70,代码来源:ImageScannerTest.ts


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