mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Remove ePub.register, update Readme
This commit is contained in:
parent
ffb15d95e7
commit
9dc61250f4
21 changed files with 131 additions and 259 deletions
108
API.js
108
API.js
|
@ -1,108 +0,0 @@
|
|||
// API
|
||||
|
||||
// Epub Rendition
|
||||
// > Package (book)
|
||||
// - Manifest (files)
|
||||
// - Metadata (info)
|
||||
// - Spine (order)
|
||||
// - Navagation (toc)
|
||||
|
||||
// Need to split out rendering and book completely
|
||||
// Something like
|
||||
var epub = ePub("moby-dick.epub");
|
||||
var epub = ePub("http://s3path/ip/moby-dick.opf");
|
||||
// or
|
||||
var epub = new EPUBJS.Book("http://s3path/ip/moby-dick.opf");
|
||||
|
||||
// Returns a Scroll Controller, Attachs to a document (or window?)
|
||||
var epub = ePub("moby-dick.epub");
|
||||
|
||||
var epub = ePub();
|
||||
var book = epub.open(_url)
|
||||
return epub
|
||||
|
||||
// Creates a Book Package object, parses manifest
|
||||
var book = epub.open("moby-dick.epub");
|
||||
var book = epub.open("META-INF/container.xml");
|
||||
var book = epub.open("package.opf"); //-- maybe, not in spec?
|
||||
// Set the store
|
||||
|
||||
// Unzip if needed
|
||||
|
||||
// Get the container
|
||||
|
||||
// Get the package path
|
||||
book = new Book("path/to/book/package.opf", store);
|
||||
unpacked = book.unpack();
|
||||
|
||||
return unpacked
|
||||
|
||||
book.unpack()
|
||||
book.manifest
|
||||
book.metadata
|
||||
book.spine
|
||||
book.navigation.toc
|
||||
// book.navigation.landmarks
|
||||
// book.navigation.lot
|
||||
return book
|
||||
|
||||
// Loads a chapter of the Book
|
||||
var section = book.spine.get(1);
|
||||
var section = book.spine.get("chap1.html");
|
||||
var section = book.spine.get("#id1234");
|
||||
|
||||
// Alias for spine
|
||||
var section = book.section("epubcfi(/6/30[id-id2640702])");
|
||||
var section = book.section(1);
|
||||
|
||||
book.loaded.navigation.then()
|
||||
book.navigation.get()
|
||||
book.navigation.get("#toc-chap-1")
|
||||
book.navigation.get("chap1.html")
|
||||
|
||||
// Returns the straight html of the chapter
|
||||
//-- When does the chapter content processing happen?
|
||||
section.render()
|
||||
|
||||
// Create a new renderer
|
||||
var rendition = book.renderTo("viewer", {method: "paginate", options: true});
|
||||
// is the same as
|
||||
var rendition = new EPUBJS.Paginate(book, {options: true});
|
||||
rendition.attachTo("viewer");
|
||||
|
||||
// Render to a div
|
||||
rendition.attachTo("elementID");
|
||||
|
||||
// Display the provided chapter
|
||||
rendition.display(chapter);
|
||||
|
||||
epub.display();
|
||||
epub.display(1);
|
||||
epub.display("chapt1.html#something");
|
||||
epub.display("epubcfi(/6/30[id-id2640702]!2/4/1:0)");
|
||||
section = book.section(_arg);
|
||||
rendition.display(section);
|
||||
section.render();
|
||||
section.load();
|
||||
return rendition;
|
||||
|
||||
epub.rendition.backwards();
|
||||
epub.rendition.forwards();
|
||||
|
||||
epub.rendition.addStyle();
|
||||
epub.rendition.addStyles();
|
||||
|
||||
|
||||
epub.find("query");
|
||||
section.find("query");
|
||||
|
||||
epub.on("noAuth", function(){
|
||||
|
||||
});
|
||||
|
||||
rendition = epub.renderTo("elementID", { method: "paginate", width: "900", height: "600" });
|
||||
|
||||
rendition.next();
|
||||
rendition.prev();
|
||||
rendition.page();
|
||||
rendition.map();
|
142
README.md
142
README.md
|
@ -1,5 +1,4 @@
|
|||
Epub.js v0.3
|
||||
================================
|
||||
# Epub.js v0.3
|
||||
|
||||

|
||||
|
||||
|
@ -9,9 +8,7 @@ Epub.js provides an interface for common ebook functions (such as rendering, per
|
|||
|
||||
[Try it while reading Moby Dick](http://futurepress.github.com/epub.js/reader/)
|
||||
|
||||
|
||||
Why EPUB
|
||||
-------------------------
|
||||
## Why EPUB
|
||||
|
||||

|
||||
|
||||
|
@ -21,8 +18,7 @@ An unzipped ePUB3 is a collection of HTML5 files, CSS, images and other media
|
|||
|
||||
More specifically, the ePUB schema standardizes the table of contents, provides a manifest that enables the caching of the entire book, and separates the storage of the content from how it’s displayed.
|
||||
|
||||
Getting Started
|
||||
-------------------------
|
||||
## Getting Started
|
||||
|
||||
Get the minified code from the build folder:
|
||||
|
||||
|
@ -33,7 +29,7 @@ Get the minified code from the build folder:
|
|||
If using archived `.epub` files include JSZip:
|
||||
|
||||
```html
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
```
|
||||
|
||||
Setup a element to render to:
|
||||
|
@ -52,29 +48,53 @@ Create the new ePub, and then render it to that element:
|
|||
</script>
|
||||
```
|
||||
|
||||
Render Methods
|
||||
-------------------------
|
||||
## Render Methods
|
||||
|
||||
Single: `book.renderTo("area");`
|
||||
### Default
|
||||
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/single.html)
|
||||
```js
|
||||
book.renderTo("area", { method: "default", width: "100%", height: "100%" });
|
||||
```
|
||||
|
||||
Continuous: `book.renderTo("area", { method: "continuous", width: "100%", height: "100%" });`
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/spreads.html)
|
||||
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/continuous.html)
|
||||
The default manager only displays a single section at a time.
|
||||
|
||||
Paginate: `book.renderTo("area", { method: "paginate", width: "900", height: "600" });`
|
||||
### Continuous
|
||||
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/pages.html)
|
||||
```js
|
||||
book.renderTo("area", { method: "continuous", width: "100%", height: "100%" });
|
||||
```
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/continuous-scrolled.html)
|
||||
|
||||
The continuous manager will display as many sections as need to fill the screen, and preload the next section offscreen. This enables seamless swiping / scrolling between pages on mobile and desktop, but is less performant than the default method.
|
||||
|
||||
Documentation
|
||||
-------------------------
|
||||
## Flow Overrides
|
||||
|
||||
Work in progress documentation at [API.js](https://github.com/futurepress/epub.js/blob/v0.3/API.js)
|
||||
### Auto (Default)
|
||||
`book.renderTo("area", { flow: "auto", width: "900", height: "600" });`
|
||||
|
||||
Running Locally
|
||||
-------------------------
|
||||
Flow will be based on the settings in the OPF, defaults to `paginated`.
|
||||
|
||||
### Paginated
|
||||
|
||||
```js
|
||||
book.renderTo("area", { flow: "paginated", width: "900", height: "600" });
|
||||
```
|
||||
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/spreads.html)
|
||||
|
||||
Scrolled: `book.renderTo("area", { flow: "scrolled-doc" });`
|
||||
|
||||
[View example](https://s3.amazonaws.com/epubjs/examples/scrolled.html)
|
||||
|
||||
## Documentation
|
||||
|
||||
API documentation is available at [epubjs.org/documentation/0.3/](http://epubjs.org/documentation/0.3/)
|
||||
|
||||
A Markdown version is included in the repo at [documentation/API.md](htts://github.com/futurepress/epub.js/blob/v0.3/documentation/API.md)
|
||||
|
||||
## Running Locally
|
||||
|
||||
install [node.js](http://nodejs.org/)
|
||||
|
||||
|
@ -86,78 +106,80 @@ npm install
|
|||
then you can run the reader locally with the command
|
||||
|
||||
```javascript
|
||||
./tools/serve
|
||||
npm start
|
||||
```
|
||||
|
||||
install [bower](http://bower.io/)
|
||||
```javascript
|
||||
bower install
|
||||
```
|
||||
Examples
|
||||
-------------------------
|
||||
## Examples
|
||||
|
||||
See examples folder
|
||||
+ [Spreads](http://futurepress.github.io/epub.js/examples/spreads.html)
|
||||
+ [Scrolled](http://futurepress.github.io/epub.js/examples/scrolled.html)
|
||||
+ [Swipe](http://futurepress.github.io/epub.js/examples/swipe.html)
|
||||
+ [Input](http://futurepress.github.io/epub.js/examples/input.html)
|
||||
+ [Highlights](http://futurepress.github.io/epub.js/examples/highlights.html)
|
||||
|
||||
Testing
|
||||
-------------------------
|
||||
[View All Examples](http://futurepress.github.io/epub.js/examples/)
|
||||
|
||||
Once you start a server you can run the [QUnit](http://qunitjs.com/) tests at [http://localhost:8080/tests/](http://localhost:8080/tests/)
|
||||
## Testing
|
||||
|
||||
You can download the test books from https://github.com/futurepress/books by running:
|
||||
```
|
||||
git submodule update --init --recursive
|
||||
Test can be run by Karma from NPM
|
||||
|
||||
```js
|
||||
npm test
|
||||
```
|
||||
|
||||
Then you can pull the latest with:
|
||||
```
|
||||
git submodule foreach git pull origin master
|
||||
```
|
||||
## Building for Distribution
|
||||
|
||||
Building for Distribution
|
||||
-------------------------
|
||||
|
||||
Builds are concatenated and minified using [gulp](http://gulpjs.com/)
|
||||
Builds are concatenated and minified using [webpack](https://webpack.js.org/) and [babel](https://babeljs.io/)
|
||||
|
||||
To generate a new build run
|
||||
|
||||
```javascript
|
||||
gulp
|
||||
npm run preprocess
|
||||
```
|
||||
|
||||
or to continuously build run
|
||||
|
||||
```javascript
|
||||
gulp watch
|
||||
npm run watch
|
||||
```
|
||||
|
||||
Hooks
|
||||
-------------------------
|
||||
## Hooks
|
||||
|
||||
Similar to a plugins, Epub.js implements events that can be "hooked" into. Thus you can interact with and manipulate the contents of the book.
|
||||
|
||||
Examples of this functionality is loading videos from YouTube links before displaying a chapters contents or implementing annotation.
|
||||
|
||||
Hooks require a event to latch onto and a callback for when they are finished.
|
||||
Hooks require an event to register to and a can return a promise to block until they are finished.
|
||||
|
||||
Example hook:
|
||||
|
||||
```javascript
|
||||
EPUBJS.Hooks.register("beforeChapterDisplay").example = function(callback, renderer){
|
||||
rendition.hooks.content.register(function(contents, view) {
|
||||
|
||||
var elements = render.doc.querySelectorAll('[video]'),
|
||||
items = Array.prototype.slice.call(elements);
|
||||
var elements = contents.document.querySelectorAll('[video]');
|
||||
var items = Array.prototype.slice.call(elements);
|
||||
|
||||
items.forEach(function(item){
|
||||
//-- do something with the video item
|
||||
}
|
||||
// do something with the video item
|
||||
});
|
||||
|
||||
if(callback) callback();
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Additional Resources
|
||||
-------------------------
|
||||
The parts of the rendering process that can be hooked into are below.
|
||||
|
||||
```js
|
||||
book.spine.hooks.serialize // Section is being converted to text
|
||||
book.spine.hooks.content // Section has been loaded and parsed
|
||||
rendition.hooks.render // Section is rendered to the screen
|
||||
rendition.hooks.content // Section contents have been loaded
|
||||
rendition.hooks.unloaded // Section contents are being unloaded
|
||||
```
|
||||
|
||||
## Reader
|
||||
The reader has moved to its own repo at: https://github.com/futurepress/epubjs-reader/
|
||||
|
||||
## Additional Resources
|
||||
|
||||
[Epub.js Developer Mailing List](https://groups.google.com/forum/#!forum/epubjs)
|
||||
|
||||
|
@ -167,8 +189,6 @@ Follow us on twitter: @Epubjs
|
|||
|
||||
+ http://twitter.com/#!/Epubjs
|
||||
|
||||
Other
|
||||
-------------------------
|
||||
## Other
|
||||
|
||||
EPUB is a registered trademark of the [IDPF](http://idpf.org/).
|
||||
|
||||
|
|
10
bower.json
10
bower.json
|
@ -26,10 +26,12 @@
|
|||
"examples"
|
||||
],
|
||||
"dependencies": {
|
||||
"es6-promise": "~4.0.5",
|
||||
"jszip": "^3.1.1",
|
||||
"path-webpack": "^0.0.2",
|
||||
"event-emitter": "^0.3.5",
|
||||
"jszip": "^3.1.5",
|
||||
"lodash": "^4.17.4",
|
||||
"marks-pane": "^1.0.7",
|
||||
"path-webpack": "0.0.3",
|
||||
"stream-browserify": "^2.0.1",
|
||||
"xmldom": "^0.1.22"
|
||||
"xmldom": "^0.1.27"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,28 +17,6 @@ ePub("/path/to/book.epub", {})
|
|||
|
||||
Returns **[Book](#book)** a new Book object
|
||||
|
||||
### register
|
||||
|
||||
Register Managers and Views
|
||||
|
||||
#### manager
|
||||
|
||||
register a new view manager
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `name`
|
||||
- `manager`
|
||||
|
||||
#### view
|
||||
|
||||
register a new view
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `name`
|
||||
- `view`
|
||||
|
||||
## Book
|
||||
|
||||
An Epub representation with methods for the loading, parsing and manipulation
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Annotator Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/annotator/1.2.9/annotator.min.js"></script> -->
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Archived Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Continuous Spreads Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js + Hypothes.is Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js + Hypothes.is Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<!-- <script>
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
<li><a href="hooks.html">Hooks</a></li>
|
||||
<li><a href="highlights.html">Highlights</a></li>
|
||||
<li><a href="hypothesis.html">Hypothes.is</a></li>
|
||||
<!-- <li><a href="hypothesis.html">Annotations with Hypothes.is</a></li> -->
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Input Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Spreads Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Scrolled Full Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Spreads Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Spreads Example</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="examples.css">
|
||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "epubjs",
|
||||
"version": "0.3.57",
|
||||
"version": "0.3.58",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -8974,9 +8974,9 @@
|
|||
}
|
||||
},
|
||||
"jszip": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.4.tgz",
|
||||
"integrity": "sha512-z6w8iYIxZ/fcgul0j/OerkYnkomH8BZigvzbxVmr2h5HkZUrPtk2kjYtLkqR9wwQxEP6ecKNoKLsbhd18jfnGA==",
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz",
|
||||
"integrity": "sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ==",
|
||||
"requires": {
|
||||
"core-js": "2.3.0",
|
||||
"es6-promise": "3.0.2",
|
||||
|
@ -9877,9 +9877,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"marks-pane": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/marks-pane/-/marks-pane-1.0.5.tgz",
|
||||
"integrity": "sha512-R0PLPRriN2AST07cQLN22yvSmN+KyLfBGyruNrIifvkn9EDqCkkEp6rsTEzAn2GC5/UGlplR/fsJHm62ZWTfCQ=="
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/marks-pane/-/marks-pane-1.0.7.tgz",
|
||||
"integrity": "sha512-mef2u/bdbbzfD0A5wfYoAMD5gsTH2ypIN4qVR/CsM8/WFGP7drxX/PKUqmLuoffOT8fQyXoYrBuWYCgMpCGzIw=="
|
||||
},
|
||||
"math-expression-evaluator": {
|
||||
"version": "1.2.17",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "epubjs",
|
||||
"version": "0.3.58",
|
||||
"version": "0.3.59",
|
||||
"description": "Parse and Render Epubs",
|
||||
"main": "lib/index.js",
|
||||
"module": "src/index.js",
|
||||
|
@ -19,7 +19,7 @@
|
|||
"compile": "./node_modules/.bin/babel --optional runtime -d lib/ src/",
|
||||
"watch": "./node_modules/.bin/babel --watch --optional runtime -d lib/ src/",
|
||||
"serve": "./node_modules/.bin/gulp serve",
|
||||
"prepublish": "npm run compile && npm run build && npm run minify && npm run legacy"
|
||||
"preprocess": "npm run compile && npm run build && npm run minify && npm run legacy"
|
||||
},
|
||||
"author": "fchasen@gmail.com",
|
||||
"license": "BSD-2-Clause",
|
||||
|
@ -74,9 +74,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"event-emitter": "^0.3.5",
|
||||
"jszip": "^3.1.4",
|
||||
"jszip": "^3.1.5",
|
||||
"lodash": "^4.17.4",
|
||||
"marks-pane": "^1.0.5",
|
||||
"marks-pane": "^1.0.7",
|
||||
"path-webpack": "0.0.3",
|
||||
"stream-browserify": "^2.0.1",
|
||||
"xmldom": "^0.1.27"
|
||||
|
|
36
src/epub.js
36
src/epub.js
|
@ -1,8 +1,8 @@
|
|||
import Book from "./book";
|
||||
import Rendition from "./rendition";
|
||||
import EpubCFI from "./epubcfi";
|
||||
import CFI from "./epubcfi";
|
||||
import Contents from "./contents";
|
||||
import * as core from "./utils/core";
|
||||
import * as utils from "./utils/core";
|
||||
import '../libs/url/url-polyfill'
|
||||
|
||||
import IframeView from "./managers/views/iframe";
|
||||
|
@ -26,36 +26,10 @@ if (typeof(global) !== "undefined") {
|
|||
global.EPUBJS_VERSION = ePub.VERSION;
|
||||
}
|
||||
|
||||
ePub.CFI = EpubCFI;
|
||||
ePub.Book = Book;
|
||||
ePub.Rendition = Rendition;
|
||||
ePub.Contents = Contents;
|
||||
ePub.utils = core;
|
||||
|
||||
ePub.ViewManagers = {};
|
||||
ePub.Views = {};
|
||||
/**
|
||||
* Register Managers and Views
|
||||
*/
|
||||
ePub.register = {
|
||||
/**
|
||||
* register a new view manager
|
||||
*/
|
||||
manager : function(name, manager){
|
||||
return ePub.ViewManagers[name] = manager;
|
||||
},
|
||||
/**
|
||||
* register a new view
|
||||
*/
|
||||
view : function(name, view){
|
||||
return ePub.Views[name] = view;
|
||||
}
|
||||
};
|
||||
|
||||
// Default Views
|
||||
ePub.register.view("iframe", IframeView);
|
||||
|
||||
// Default View Managers
|
||||
ePub.register.manager("default", DefaultViewManager);
|
||||
ePub.register.manager("continuous", ContinuousViewManager);
|
||||
ePub.CFI = CFI;
|
||||
ePub.utils = utils;
|
||||
|
||||
export default ePub;
|
||||
|
|
|
@ -10,6 +10,13 @@ import Contents from "./contents";
|
|||
import Annotations from "./annotations";
|
||||
import { EVENTS } from "./utils/constants";
|
||||
|
||||
// Default Views
|
||||
import IframeView from "./managers/views/iframe";
|
||||
|
||||
// Default View Managers
|
||||
import DefaultViewManager from "./managers/default/index";
|
||||
import ContinuousViewManager from "./managers/continuous/index";
|
||||
|
||||
/**
|
||||
* Displays an Epub as a series of Views for each Section.
|
||||
* Requires Manager and View class to handle specifics of rendering
|
||||
|
@ -155,10 +162,11 @@ class Rendition {
|
|||
requireManager(manager) {
|
||||
var viewManager;
|
||||
|
||||
// If manager is a string, try to load from global registered managers
|
||||
if (typeof manager === "string" && typeof ePub != "undefined") {
|
||||
// Use global
|
||||
viewManager = ePub.ViewManagers[manager];
|
||||
// If manager is a string, try to load from imported managers
|
||||
if (typeof manager === "string" && manager === "default") {
|
||||
viewManager = DefaultViewManager;
|
||||
} else if (typeof manager === "string" && manager === "continuous") {
|
||||
viewManager = ContinuousViewManager;
|
||||
} else {
|
||||
// otherwise, assume we were passed a class function
|
||||
viewManager = manager;
|
||||
|
@ -175,10 +183,9 @@ class Rendition {
|
|||
requireView(view) {
|
||||
var View;
|
||||
|
||||
// If view is a string, try to load from global registered views,
|
||||
if (typeof view == "string" && typeof ePub != "undefined") {
|
||||
// Use global
|
||||
View = ePub.Views[view];
|
||||
// If view is a string, try to load from imported views,
|
||||
if (typeof view == "string" && view === "iframe") {
|
||||
View = IframeView;
|
||||
} else {
|
||||
// otherwise, assume we were passed a class function
|
||||
View = view;
|
||||
|
@ -488,7 +495,7 @@ class Rendition {
|
|||
this.settings.width = width;
|
||||
}
|
||||
if (height) {
|
||||
this.settings.height = width;
|
||||
this.settings.height = height;
|
||||
}
|
||||
this.manager.resize(width, height);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue