diff --git a/common/component/src/main/ets/components/NoteContent.ets b/common/component/src/main/ets/components/NoteContent.ets index e5e97a6..0275b54 100644 --- a/common/component/src/main/ets/components/NoteContent.ets +++ b/common/component/src/main/ets/components/NoteContent.ets @@ -117,9 +117,11 @@ export struct NoteContent { .width(StyleConstants.PERCENTAGE_100) .onClick(() => { // 添加定时器:3s自动保存 - timeID = setInterval(() => { - this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) - }, 3000) + if (timeID == undefined) { + timeID = setInterval(() => { + this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) + }, 3000) + } LogUtil.info(TAG, "setInterval timeID : " + timeID) this.issave = 0 this.editModel = true diff --git a/common/resources/src/main/resources/rawfile/rich_editor.js b/common/resources/src/main/resources/rawfile/rich_editor.js index c8bc40b..ca344c2 100644 --- a/common/resources/src/main/resources/rawfile/rich_editor.js +++ b/common/resources/src/main/resources/rawfile/rich_editor.js @@ -18,7 +18,12 @@ var RICH_EDITOR = {}; RICH_EDITOR.editor = document.getElementById('editorjs'); RICH_EDITOR.setHtml = function(contents) { - RICH_EDITOR.editor.innerHTML = contents.replace(/'/g, "'"); + var base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; + if (base64regex.test(contents)) { + RICH_EDITOR.editor.innerHTML = decodeURIComponent(escape(atob(contents))) + } else { + RICH_EDITOR.editor.innerHTML = contents; + } } RICH_EDITOR.getHtml = function() { @@ -322,7 +327,7 @@ RICH_EDITOR.getSelectedAnchorNode=function(){ function get_html_content() { console.log('get_html_content'); var htmlString = RICH_EDITOR.getHtml() - htmlString = htmlString.replace(/'/g, ''') + htmlString = window.btoa(unescape(encodeURIComponent( htmlString ))) var str = callBackToApp.callbackhtml(htmlString) console.log('get_html_content end'); } @@ -330,7 +335,7 @@ function get_html_content() { function save_html_content() { console.log('save_html_content'); var htmlString = RICH_EDITOR.getHtml() - htmlString = htmlString.replace(/'/g, ''') + htmlString = window.btoa(unescape(encodeURIComponent( htmlString ))) var str = callBackToApp.callbackhtmlSave(htmlString) console.log('save_html_content end'); }