From b8de7f0721da32faa67a1aa0d8a72846737018c7 Mon Sep 17 00:00:00 2001 From: Philip Cesar Garay Date: Tue, 6 Apr 2021 05:27:56 +0800 Subject: [PATCH] feat(preview-any-file): add new methods for preview-any-file cordova (#3643) * feat(adjust): add missing wrappers for cordova api * feat(adjust): add missing wrappers for cordova api --- .../plugins/preview-any-file/index.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/@ionic-native/plugins/preview-any-file/index.ts b/src/@ionic-native/plugins/preview-any-file/index.ts index dc2a9801f..9e7ca12a7 100644 --- a/src/@ionic-native/plugins/preview-any-file/index.ts +++ b/src/@ionic-native/plugins/preview-any-file/index.ts @@ -1,5 +1,18 @@ import { Injectable } from '@angular/core'; import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; + +export interface PreviewAnyFileOptions { + /** + * The name of the file to preview. + */ + name?: string; + /** + * The mime type of the file to preview. + */ + mimeType: string; +} + + /** * @name PreviewAnyFile * @description @@ -22,7 +35,18 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; * .catch((error: any) => console.error(error)); * * ``` + * + * + * ... + * + * + * this.previewAnyFile.previewPath('http://www.domain.com/samplefile') + * .then((res: any) => console.log(res)) + * .catch((error: any) => console.error(error)); + * + * ``` */ + @Plugin({ pluginName: 'PreviewAnyFile', plugin: 'cordova-plugin-preview-any-file', // npm package name, example: cordova-plugin-camera @@ -43,4 +67,34 @@ export class PreviewAnyFile extends IonicNativePlugin { preview(url: string): Promise { return; } + + /** + * previewPath function will return success callback if the file successfully opened, if the content is base64 you have to use previewBase64 method + * @param base64 {String} base64 string content + * @param options {PreviewAnyFileOptions} define the name of the file with extension or it's mimeType, if the correct extension not exist in the path + */ + @Cordova() + previewBase64(base64: string,options?: PreviewAnyFileOptions): Promise { + return; + } + + /** + * previewPath function will return success callback if the file successfully opened, if the content is base64 you have to use previewBase64 method + * @param url {String} full absolute URL -> file://, content://, http://, https, ... etc, if extension not exist, you must define it in the opt param + * @param options {PreviewAnyFileOptions} define the name of the file with extension or it's mimeType, if the correct extension not exist in the path + */ + @Cordova() + previewPath(url: string,options?: PreviewAnyFileOptions): Promise { + return; + } + + /** + * previewPath function will return success callback if the file successfully opened, if the content is base64 you have to use previewBase64 method + * @param url {String} full absolute URL -> file://, content://, http://, https, ... etc, if extension not exist, you must define it in the opt param + * @param options {PreviewAnyFileOptions} define the name of the file with extension or it's mimeType, if the correct extension not exist in the path + */ + @Cordova() + previewAsset(url: string,options?: PreviewAnyFileOptions): Promise { + return; + } }