本文整理匯總了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
});
});