mirror of
https://gitee.com/openharmony/applications_notes
synced 2024-11-23 07:30:27 +00:00
备忘录告警处理
Signed-off-by: zwx1126739 <zhanghong121@huawei.com>
This commit is contained in:
parent
c7d1b56716
commit
0b417127a9
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var RICH_EDITOR = {};
|
||||
let RICH_EDITOR = {};
|
||||
let storage = window.localStorage;
|
||||
RICH_EDITOR.editor = document.getElementById('editorjs_box');
|
||||
|
||||
@ -22,7 +22,7 @@ RICH_EDITOR.setHtml = function (contents) {
|
||||
if (contents) {
|
||||
RICH_EDITOR.editor.style.paddingLeft = paddingLeft + 'px';
|
||||
}
|
||||
var base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
||||
let 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 {
|
||||
@ -67,18 +67,18 @@ RICH_EDITOR.setUnderline = function () {
|
||||
};
|
||||
|
||||
RICH_EDITOR.getListStyle = function () {
|
||||
var selection;
|
||||
var type;
|
||||
let selection;
|
||||
let type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
let range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
let child = range.commonAncestorContainer;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
console.info('insertOrderedList');
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
@ -107,18 +107,18 @@ RICH_EDITOR.setNumbers = function () {
|
||||
let fontSize = document.queryCommandValue('fontSize');
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
document.execCommand('fontSize', false, fontSize);
|
||||
var selection;
|
||||
var type;
|
||||
let selection;
|
||||
let type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
let range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
let child = range.commonAncestorContainer;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
child.style['list-style'] = 'decimal';
|
||||
break;
|
||||
@ -140,18 +140,18 @@ RICH_EDITOR.setABC = function () {
|
||||
let fontSize = document.queryCommandValue('fontSize');
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
document.execCommand('fontSize', false, fontSize);
|
||||
var selection;
|
||||
var type;
|
||||
let selection;
|
||||
let type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
let range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
let child = range.commonAncestorContainer;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
child.style['list-style'] = 'lower-alpha';
|
||||
break;
|
||||
@ -173,18 +173,18 @@ RICH_EDITOR.setBullets = function () {
|
||||
let fontSize = document.queryCommandValue('fontSize');
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
document.execCommand('fontSize', false, fontSize);
|
||||
var selection;
|
||||
var type;
|
||||
let selection;
|
||||
let type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
let range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
let child = range.commonAncestorContainer;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'UL') {
|
||||
child.style['list-style'] = 'disc';
|
||||
break;
|
||||
@ -206,18 +206,18 @@ RICH_EDITOR.setSquare = function () {
|
||||
let fontSize = document.queryCommandValue('fontSize');
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
document.execCommand('fontSize', false, fontSize);
|
||||
var selection;
|
||||
var type;
|
||||
let selection;
|
||||
let type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
let range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
let child = range.commonAncestorContainer;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'UL') {
|
||||
child.style['list-style'] = 'square';
|
||||
break;
|
||||
@ -253,9 +253,9 @@ RICH_EDITOR.execFontSize = function (size, unit) {
|
||||
}
|
||||
};
|
||||
|
||||
var pad = 24;
|
||||
let pad = 24;
|
||||
RICH_EDITOR.setIndent = function () {
|
||||
var parents = document.getElementById('editorjs_box');
|
||||
let parents = document.getElementById('editorjs_box');
|
||||
parents.removeAttribute('padding-left');
|
||||
if (pad >= 408) {
|
||||
return;
|
||||
@ -269,7 +269,7 @@ RICH_EDITOR.setIndent = function () {
|
||||
};
|
||||
|
||||
RICH_EDITOR.setOutdent = function () {
|
||||
var parents = document.getElementById('editorjs_box');
|
||||
let parents = document.getElementById('editorjs_box');
|
||||
parents.removeAttribute('padding-left');
|
||||
if (pad === 24) {
|
||||
parents.style.paddingLeft = 24 + 'px';
|
||||
@ -306,7 +306,7 @@ RICH_EDITOR.setJustifyRight = function () {
|
||||
};
|
||||
|
||||
RICH_EDITOR.insertImage = function (url) {
|
||||
var html = '<br></br><img src="' + url +
|
||||
let html = '<br></br><img src="' + url +
|
||||
'" alt="picvision" style="margin:0px auto;width:90%;display:table-cell;' +
|
||||
'vertical-align:middle;border-radius:10px;max-width:90%" /><br></br>';
|
||||
document.getElementById('editorjs_box').innerHTML += html;
|
||||
@ -318,15 +318,15 @@ RICH_EDITOR.insertHTML = function (html) {
|
||||
};
|
||||
|
||||
RICH_EDITOR.setDone = function () {
|
||||
var html = '<input type="checkbox" checked="checked"/> ';
|
||||
let html = '<input type="checkbox" checked="checked"/> ';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
};
|
||||
|
||||
RICH_EDITOR.addTodo = function (e) {
|
||||
var KEY_ENTER;
|
||||
let KEY_ENTER;
|
||||
KEY_ENTER = 13;
|
||||
if (e.which === KEY_ENTER) {
|
||||
var node = RICH_EDITOR.getSelectedAnchorNode();
|
||||
let node = RICH_EDITOR.getSelectedAnchorNode();
|
||||
if (node && node.nodeName === '#text') {
|
||||
node = node.parentElement;
|
||||
}
|
||||
@ -339,9 +339,9 @@ RICH_EDITOR.addTodo = function (e) {
|
||||
};
|
||||
|
||||
RICH_EDITOR.setTodo = function () {
|
||||
var parent = document.getElementById('editorjs_box');
|
||||
var isContentEmpty = parent.innerHTML.trim().length === 0 || parent.innerHTML === '<br>';
|
||||
var html = (isContentEmpty ? '' : '<br/>') +
|
||||
let parent = document.getElementById('editorjs_box');
|
||||
let isContentEmpty = parent.innerHTML.trim().length === 0 || parent.innerHTML === '<br>';
|
||||
let html = (isContentEmpty ? '' : '<br/>') +
|
||||
'<span> </span>' +
|
||||
'<input name="checkbox" type="checkbox" onclick="onCheckChange(this)" class="note-checkbox">' +
|
||||
'<span class="note-checkbox-txt"> </span>';
|
||||
@ -357,9 +357,9 @@ function onCheckChange(checkbox) {
|
||||
}
|
||||
|
||||
RICH_EDITOR.restorerange = function () {
|
||||
var selection = window.getSelection();
|
||||
let selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
let range = document.createRange();
|
||||
range.setStart(RICH_EDITOR.currentSelection.startContainer, RICH_EDITOR.currentSelection.startOffset);
|
||||
range.setEnd(RICH_EDITOR.currentSelection.endContainer, RICH_EDITOR.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
@ -368,15 +368,15 @@ RICH_EDITOR.restorerange = function () {
|
||||
// 获取光标开始位置归属节点
|
||||
|
||||
RICH_EDITOR.getSelectedAnchorNode = function () {
|
||||
var node;
|
||||
var selection;
|
||||
let node;
|
||||
let selection;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
node = selection.anchorNode;
|
||||
}
|
||||
if (!node && document.selection) {
|
||||
selection = document.selection;
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
let range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
node = range.commonAncestorContainer ? range.commonAncestorContainer : range.parentElement
|
||||
? range.parentElement() : range.item(0);
|
||||
}
|
||||
@ -384,30 +384,30 @@ RICH_EDITOR.getSelectedAnchorNode = function () {
|
||||
};
|
||||
|
||||
RICH_EDITOR.cancelSelection = function () {
|
||||
var selection = window.getSelection();
|
||||
let selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
};
|
||||
|
||||
var callBackToApp;
|
||||
let callBackToApp = window.callBackToApp;
|
||||
|
||||
function getHtmlContent() {
|
||||
console.log('getHtmlContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackhtml(htmlString);
|
||||
let str = callBackToApp.callbackhtml(htmlString);
|
||||
console.log('getHtmlContent end');
|
||||
}
|
||||
|
||||
function saveHtmlContent() {
|
||||
console.log('saveHtmlContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackhtmlSave(htmlString);
|
||||
let str = callBackToApp.callbackhtmlSave(htmlString);
|
||||
console.log('saveHtmlContent end');
|
||||
}
|
||||
|
||||
@ -432,11 +432,11 @@ function getImagePathFromContent(contentInfo) {
|
||||
function scheduledSaveContent() {
|
||||
if (callBackToApp !== undefined) {
|
||||
console.info('scheduledSaveContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackScheduledSave(htmlString);
|
||||
let str = callBackToApp.callbackScheduledSave(htmlString);
|
||||
console.info('scheduledSaveContent end');
|
||||
}
|
||||
}
|
||||
@ -456,9 +456,9 @@ document.body.addEventListener('paste', (event) => {
|
||||
|
||||
RICH_EDITOR.getFontSizes = function () {
|
||||
document.execCommand('fontSize', false, null);
|
||||
var fontElements = window.getSelection().anchorNode.parentNode;
|
||||
var getSize = parseInt(window.getComputedStyle(fontElements, null).fontSize);
|
||||
var str = callBackToApp.callbackGetSize(getSize);
|
||||
let fontElements = window.getSelection().anchorNode.parentNode;
|
||||
let getSize = parseInt(window.getComputedStyle(fontElements, null).fontSize);
|
||||
let str = callBackToApp.callbackGetSize(getSize);
|
||||
};
|
||||
|
||||
RICH_EDITOR.insertImageHtml = function (contents) {
|
||||
@ -470,11 +470,12 @@ RICH_EDITOR.insertImageHtml = function (contents) {
|
||||
let img = document.createElement('img');
|
||||
img.src = contents;
|
||||
selection.getRangeAt(0).insertNode(img);
|
||||
return true;
|
||||
};
|
||||
|
||||
document.addEventListener('click', (e) => {
|
||||
console.info(`lsq: e is ${JSON.stringify(e)}`);
|
||||
var parent = document.getElementById('editorjs_box');
|
||||
let parent = document.getElementById('editorjs_box');
|
||||
if (parent.id !== 'editorjs_box') {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user