mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-22 01:19:36 +08:00
feat(plugin): add Document Viewer plugin (#1520)
* typo(barcode-scanner): fixe circle lint error * typo(docs): Unified the documentations In some plugins the typescript markup was missing. I also unified the console.log string from console.log("hello") to console.log('Hello') so any plugin page look the same. * Initial commit * updated interface * updated interface
This commit is contained in:
parent
142525e133
commit
6855fe8f7d
93
src/@ionic-native/plugins/document-viewer/index.ts
Normal file
93
src/@ionic-native/plugins/document-viewer/index.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
export interface DocumentViewerOptions {
|
||||||
|
title: string;
|
||||||
|
documentView: {
|
||||||
|
closeLabel: string;
|
||||||
|
};
|
||||||
|
navigationView: {
|
||||||
|
closeLabel: string;
|
||||||
|
};
|
||||||
|
email: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
print: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
openWith: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
bookmarks: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
search: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
autoClose: {
|
||||||
|
onPause: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Document Viewer
|
||||||
|
* @description
|
||||||
|
* This plugin offers a slim API to view PDF files which are either stored in the apps assets folder (/www/*) or in any other file system directory available via the cordova file plugin.
|
||||||
|
*
|
||||||
|
* @usage
|
||||||
|
* ```typescript
|
||||||
|
* import { DocumentViewer } from '@ionic-native/document-viewer';
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* constructor(private document: DocumentViewer) { }
|
||||||
|
*
|
||||||
|
* ...
|
||||||
|
* const options = {
|
||||||
|
* title: 'My PDF'
|
||||||
|
* }
|
||||||
|
* this.document.view('assets/myFile.pdf', 'application/pdf', options)
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @interfaces
|
||||||
|
* DocumentViewerOptions
|
||||||
|
*/
|
||||||
|
@Plugin({
|
||||||
|
pluginName: 'Document Viewer',
|
||||||
|
plugin: 'cordova-plugin-document-viewer',
|
||||||
|
pluginRef: 'SitewaertsDocumentViewer',
|
||||||
|
repo: 'DocumentViewer',
|
||||||
|
platforms: ['Android', 'iOS', 'Windows']
|
||||||
|
})
|
||||||
|
@Injectable()
|
||||||
|
export class DocumentViewer extends IonicNativePlugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the email composer pre-filled with data.
|
||||||
|
*
|
||||||
|
* @returns {Promise<any>} Resolves promise when the EmailComposer has been opened
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
getSupportInfo(): Promise<any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the document can be shown
|
||||||
|
*
|
||||||
|
* @param url {string} Url to the file
|
||||||
|
* @param contentType {string} Content type of the file
|
||||||
|
* @param options {Array<DocumentViewerOptions>} options
|
||||||
|
*/
|
||||||
|
@Cordova({ sync: true })
|
||||||
|
canViewDocument(url: string, contentType: string, options: Array<DocumentViewerOptions>): void { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the file
|
||||||
|
*
|
||||||
|
* @param url {string} Url to the file
|
||||||
|
* @param contentType {string} Content type of the file
|
||||||
|
* @param options {Array<DocumentViewerOptions>} options
|
||||||
|
*/
|
||||||
|
@Cordova({ sync: true })
|
||||||
|
viewDocument(url: string, contentType: string, options: Array<DocumentViewerOptions>): void { }
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user