mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Added several usage examples, fixed bugs, turned off restore by default
This commit is contained in:
parent
0e08b734ec
commit
416f7ab6a0
112 changed files with 23903 additions and 3348 deletions
39
libs/annotator/lib/plugin/markdown.js
Normal file
39
libs/annotator/lib/plugin/markdown.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Generated by CoffeeScript 1.6.3
|
||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
Annotator.Plugin.Markdown = (function(_super) {
|
||||
__extends(Markdown, _super);
|
||||
|
||||
Markdown.prototype.events = {
|
||||
'annotationViewerTextField': 'updateTextField'
|
||||
};
|
||||
|
||||
function Markdown(element, options) {
|
||||
this.updateTextField = __bind(this.updateTextField, this);
|
||||
if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) {
|
||||
Markdown.__super__.constructor.apply(this, arguments);
|
||||
this.converter = new Showdown.converter();
|
||||
} else {
|
||||
console.error(Annotator._t("To use the Markdown plugin, you must include Showdown into the page first."));
|
||||
}
|
||||
}
|
||||
|
||||
Markdown.prototype.updateTextField = function(field, annotation) {
|
||||
var text;
|
||||
text = Annotator.Util.escape(annotation.text || '');
|
||||
return $(field).html(this.convert(text));
|
||||
};
|
||||
|
||||
Markdown.prototype.convert = function(text) {
|
||||
return this.converter.makeHtml(text);
|
||||
};
|
||||
|
||||
return Markdown;
|
||||
|
||||
})(Annotator.Plugin);
|
||||
|
||||
/*
|
||||
//@ sourceMappingURL=markdown.map
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue