本文整理汇总了TypeScript中@ephox/imagetools.BlobConversions类的典型用法代码示例。如果您正苦于以下问题:TypeScript BlobConversions类的具体用法?TypeScript BlobConversions怎么用?TypeScript BlobConversions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlobConversions类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const addImage = function (editor, blob) {
BlobConversions.blobToBase64(blob).then(function (base64) {
editor.undoManager.transact(function () {
const cache = editor.editorUpload.blobCache;
const info = cache.create(
Id.generate('mceu'), blob, base64
);
cache.add(info);
const img = editor.dom.createHTML('img', {
src: info.blobUri()
});
editor.insertContent(img);
});
});
};
示例2: Promise
return new Promise(function (resolve) {
BlobConversions.blobToImage(blob).
then(function (newImage) {
const newSize = ImageSize.getNaturalImageSize(newImage);
if (originalSize.w !== newSize.w || originalSize.h !== newSize.h) {
if (ImageSize.getImageSize(img)) {
ImageSize.setImageSize(img, newSize);
}
}
URL.revokeObjectURL(newImage.src);
resolve(blob);
});
});
示例3: function
const imageToBlob = function (editor, img) {
let src = img.src, apiKey;
if (isCorsImage(editor, img)) {
return Proxy.getUrl(img.src, null);
}
if (!isLocalImage(editor, img)) {
src = Settings.getProxyUrl(editor);
src += (src.indexOf('?') === -1 ? '?' : '&') + 'url=' + encodeURIComponent(img.src);
apiKey = getApiKey(editor);
return Proxy.getUrl(src, apiKey);
}
return BlobConversions.imageToBlob(img);
};
示例4: Promise
return new Promise(function (resolve) {
BlobConversions.blobToImage(blob).
then(function (newImage) {
const newSize = ImageSize.getNaturalImageSize(newImage);
if (originalSize.w !== newSize.w || originalSize.h !== newSize.h) {
if (ImageSize.getImageSize(img)) {
ImageSize.setImageSize(img, newSize);
}
}
URL.revokeObjectURL(newImage.src);
return blob;
}).
then(ResultConversions.blobToImageResult).
then(function (imageResult) {
return updateSelectedImage(editor, imageResult, true, imageUploadTimerState, img);
}, function () {
// Close dialog
});
});