TagSpaces is an offline, open source, document manager with tagging support
removed iframe usage for text extraction
Borislav Sapundzhiev7b8960ffd048
diff --git a/data/ext/viewerHTML/extension.js b/data/ext/viewerHTML/extension.jsindex 94a62b6dc..c102c38ad 100644--- a/data/ext/viewerHTML/extension.js+++ b/data/ext/viewerHTML/extension.js@@ -195,17 +195,15 @@ define(function(require, exports, module) {console.log("Not implemented");};- exports.getTextContent = function(file, loaded) {+ exports.getTextContent = function(file, result) {- var iframe = $('<iframe/>', {- id:'fileIframe',- src: file,- style:'display:none;',- load: function() {- loaded(this.contentWindow.document.body.innerText);- }- });- $('body').append(iframe);+ TSCORE.IO.getFileContent(file, function(buf) {+ var text = TSCORE.Utils.arrayBufferToStr(buf);+ var matched = text.match(/<body[^>]*>([\w|\W]*)<\/body>/im);+ result($(matched[1]).text());+ }, function(err) {+ console.log(err);+ });};// Extension Varsdiff --git a/data/js/utils.js b/data/js/utils.jsindex 55f909d80..738ccdb7f 100644--- a/data/js/utils.js+++ b/data/js/utils.js@@ -40,8 +40,14 @@ define(function(require, exports, module) {return canvas.toDataURL("image/png");}+ function arrayBufferToStr(buf) {+ var s = String.fromCharCode.apply(null, new Uint8Array(buf));+ return decodeURIComponent(escape(s));+ }+exports.arrayBufferToDataURL = arrayBufferToDataURL;exports.base64ToArrayBuffer = base64ToArrayBuffer;exports.dataURLtoBlob = dataURLtoBlob;exports.getBase64Image = getBase64Image;+ exports.arrayBufferToStr = arrayBufferToStr;});