Skip to content

TagSpaces is an offline, open source, document manager with tagging support

handle editor changes

Borislav Sapundzhievf7ad5dc16e33
diff --git a/data/ext/editorNext/editor.js b/data/ext/editorNext/editor.js
index 8fdf5b751..0ebff459b 100644
--- a/data/ext/editorNext/editor.js
+++ b/data/ext/editorNext/editor.js
@@ -1,19 +1,22 @@
"use strict";
-
+var contentVersion = 0;
var isCordova = parent.isCordova;
var editor = null;
+
function initEditor() {
-
- editor = woofmark(document.querySelector('textarea'), {
+ var el = document.querySelector("textarea");
+ editor = woofmark(el, {
parseMarkdown: megamark,
parseHTML: domador
});
editor.setMode("html");
+
+ $(el).on("change keyup cut paste", function(event) {
+ contentVersion++;
+ });
}
-var contentVersion = 0;
-
function resetContentVersion() {
contentVersion = 0;
}
diff --git a/data/ext/editorNext/extension.js b/data/ext/editorNext/extension.js
index ec63a5448..f05e96ec9 100644
--- a/data/ext/editorNext/extension.js
+++ b/data/ext/editorNext/extension.js
@@ -66,11 +66,18 @@ define(function(require, exports, module) {
if (typeof contentWindow.setContent === "function") {
contentWindow.setContent(cleanedBodyContent);
} else {
- alert("TODO optimize setTimeout");
+ console.log("editor is not initalized");
}
};
+ var contentVersion = 0;
+
+ function resetContentVersion() {
+ contentVersion = 0;
+ document.getElementById("iframeViewer").contentWindow.resetContentVersion();
+ }
+
exports.getContent = function() {
var content = $("#iframeViewer").contents().find("textarea").val();
@@ -102,7 +109,7 @@ define(function(require, exports, module) {
var htmlContent = currentContent.replace(/\<body[^>]*\>([^]*)\<\/body>/m, cleanedContent); // jshint ignore:line
//console.log("Final html "+htmlContent);
- //resetContentVersion();
+ resetContentVersion();
return htmlContent;
};
});