How to use the @ephox/imagetools.ResultConversions.blobToImageResult function in @ephox/imagetools

To help you get started, we’ve selected a few @ephox/imagetools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / imagetools / ImageTools.ts View on Github external
const blobManipulate = (anyInSystem: AlloyComponent, blob: Blob, filter: (ir: ImageResult) => ImageResult | PromiseLike, action: (blob: Blob) => string, swap: () => void): Promise> => {
    block(anyInSystem);
    return ResultConversions.blobToImageResult(blob).
      then(filter).
      then(imageResultToBlob).
      then(action).
      then((url) => {
        return updateSrc(anyInSystem, url).then((oImg) => {
          updateButtonUndoStates(anyInSystem);
          swap();
          unblock(anyInSystem);
          return oImg;
        });
      }).catch((err) => {
      // tslint:disable-next-line:no-console
        console.log(err); // TODO: Notify the user?
        unblock(anyInSystem);
        return err;
      });