mirror of
https://github.com/openharmony/applications_notes.git
synced 2026-07-19 21:24:33 -04:00
+1
-1
@@ -53,4 +53,4 @@
|
||||
"srcPath": "./features",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"license":"ISC",
|
||||
"types":"",
|
||||
"devDependencies":{},
|
||||
"name":"@ohos/resources",
|
||||
"description":"a npm package which contains arkUI2.0 page",
|
||||
"ohos":{
|
||||
"org":""
|
||||
"license": "ISC",
|
||||
"types": "",
|
||||
"devDependencies": {},
|
||||
"name": "@ohos/resources",
|
||||
"description": "a npm package which contains arkUI2.0 page",
|
||||
"ohos": {
|
||||
"org": ""
|
||||
},
|
||||
"main":"index.ets",
|
||||
"repository":{},
|
||||
"version":"1.0.0",
|
||||
"dependencies":{}
|
||||
}
|
||||
"main": "index.ets",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"editorJs"
|
||||
</title>
|
||||
|
||||
|
||||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="editor_style.css">
|
||||
|
||||
@@ -15,19 +15,19 @@
|
||||
<body onload="load()">
|
||||
<div class="edit-box">
|
||||
|
||||
|
||||
<div id="editorjs" contenteditable="true"></div>
|
||||
<div id="editorjs_box" contenteditable="true">
|
||||
</div>
|
||||
<div class="button-box" id="buttonBox">
|
||||
<div id="addToDo">
|
||||
<img id="img1" src="icon/todo1.svg">
|
||||
<img id="img1" src="icon/todo1.png">
|
||||
<span id="lable1">清单</span>
|
||||
</div>
|
||||
<div id="chooseStyle">
|
||||
<img id="img2" src="icon/styles.svg">
|
||||
<img id="img2" src="icon/styles.png">
|
||||
<span id="lable2">样式</span>
|
||||
</div>
|
||||
<div id="openAlbum">
|
||||
<img id="img3"src="icon/picture_white.svg">
|
||||
<img id="img3"src="icon/picture_white.png">
|
||||
<span id="lable3">相册</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -26,19 +26,18 @@ body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#editorjs {
|
||||
padding-left: 1px;
|
||||
padding-right: 24px;
|
||||
|
||||
#editorjs_box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
height: 90%;
|
||||
outline: 0px solid transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
color: #182431;
|
||||
opacity: 0.9;
|
||||
overflow: scroll;
|
||||
user-select: none;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
#editorjs[placeholder]:empty:not(:focus):before {
|
||||
@@ -51,8 +50,6 @@ body {
|
||||
background: #F88805;
|
||||
border: 1px solid #F88805;
|
||||
outline: none;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@ -68,8 +65,6 @@ body {
|
||||
-webkit-user-select: none;
|
||||
border-radius: 50%;
|
||||
font-size: 0.8rem;
|
||||
margin-left: 0px;
|
||||
margin-top: 0px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 6px;
|
||||
outline: none;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -15,485 +15,495 @@
|
||||
|
||||
var RICH_EDITOR = {};
|
||||
|
||||
RICH_EDITOR.editor = document.getElementById('editorjs');
|
||||
RICH_EDITOR.editor = document.getElementById('editorjs_box');
|
||||
|
||||
RICH_EDITOR.setHtml = function (contents) {
|
||||
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;
|
||||
}
|
||||
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 () {
|
||||
return RICH_EDITOR.editor.innerHTML;
|
||||
return document.getElementById('editorjs_box').innerHTML;
|
||||
};
|
||||
|
||||
RICH_EDITOR.undo = function () {
|
||||
document.execCommand('undo', false, null);
|
||||
document.execCommand('undo', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.redo = function () {
|
||||
document.execCommand('redo', false, null);
|
||||
document.execCommand('redo', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setBold = function () {
|
||||
document.execCommand('bold');
|
||||
document.execCommand('bold');
|
||||
};
|
||||
|
||||
RICH_EDITOR.setItalic = function () {
|
||||
document.execCommand('italic', false, null);
|
||||
document.execCommand('italic', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setSubscript = function () {
|
||||
document.execCommand('subscript', false, null);
|
||||
document.execCommand('subscript', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setSuperscript = function () {
|
||||
document.execCommand('superscript', false, null);
|
||||
document.execCommand('superscript', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setStrikeThrough = function () {
|
||||
document.execCommand('strikeThrough', false, null);
|
||||
document.execCommand('strikeThrough', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setUnderline = function () {
|
||||
document.execCommand('underline', false, null);
|
||||
document.execCommand('underline', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.getListStyle = function () {
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
console.info('insertOrderedList');
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
return child.style['list-style'];
|
||||
}
|
||||
if (child.nodeName === 'UL') {
|
||||
console.info('insertUnorderedList');
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
return child.style['list-style'];
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
console.info('insertOrderedList');
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
return child.style['list-style'];
|
||||
}
|
||||
if (child.nodeName === 'UL') {
|
||||
console.info('insertUnorderedList');
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
return child.style['list-style'];
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
RICH_EDITOR.setNumbers = function () {
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'decimal') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
child.style['list-style'] = 'decimal';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'decimal') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
child.style['list-style'] = 'decimal';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
RICH_EDITOR.setABC = function () {
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'lower-alpha') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
child.style['list-style'] = 'lower-alpha';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'lower-alpha') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'OL') {
|
||||
child.style['list-style'] = 'lower-alpha';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
RICH_EDITOR.setBullets = function () {
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'disc') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'UL') {
|
||||
child.style['list-style'] = 'disc';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'disc') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'UL') {
|
||||
child.style['list-style'] = 'disc';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
RICH_EDITOR.setSquare = function () {
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'square') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'UL') {
|
||||
child.style['list-style'] = 'square';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
let listStyle = RICH_EDITOR.getListStyle();
|
||||
if (listStyle === 'square') {
|
||||
return;
|
||||
}
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection;
|
||||
var type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (!selection) {
|
||||
return
|
||||
}
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName === 'UL') {
|
||||
child.style['list-style'] = 'square';
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
RICH_EDITOR.setTextColor = function (color) {
|
||||
document.execCommand('foreColor', false, color);
|
||||
document.execCommand('foreColor', false, color);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setFontSize = function (fontSize) {
|
||||
document.execCommand('fontSize', false, fontSize);
|
||||
document.execCommand('fontSize', false, fontSize);
|
||||
};
|
||||
|
||||
RICH_EDITOR.execFontSize = function (size, unit) {
|
||||
if (size === '12') {
|
||||
document.execCommand('fontSize', false, 3);
|
||||
} else if (size === '16') {
|
||||
document.execCommand('fontSize', false, 4);
|
||||
} else if (size === '20') {
|
||||
document.execCommand('fontSize', false, 5);
|
||||
} else if (size === '24') {
|
||||
document.execCommand('fontSize', false, 6);
|
||||
} else if (size === '28') {
|
||||
document.execCommand('fontSize', false, 7);
|
||||
}
|
||||
if (size === '12') {
|
||||
document.execCommand('fontSize', false, 3);
|
||||
} else if (size === '16') {
|
||||
document.execCommand('fontSize', false, 4);
|
||||
} else if (size === '20') {
|
||||
document.execCommand('fontSize', false, 5);
|
||||
} else if (size === '24') {
|
||||
document.execCommand('fontSize', false, 6);
|
||||
} else if (size === '28') {
|
||||
document.execCommand('fontSize', false, 7);
|
||||
}
|
||||
};
|
||||
|
||||
var pad = 24;
|
||||
RICH_EDITOR.setIndent = function () {
|
||||
var parents = document.getElementById('editorjs');
|
||||
parents.removeAttribute('padding-left');
|
||||
pad = pad + 24;
|
||||
parents.style.paddingLeft = pad + 'px';
|
||||
var parents = document.getElementById('editorjs_box');
|
||||
parents.removeAttribute('padding-left');
|
||||
if (pad >= 408) {
|
||||
return
|
||||
}
|
||||
pad = pad + 24;
|
||||
parents.style.paddingLeft = pad + 'px';
|
||||
};
|
||||
|
||||
RICH_EDITOR.setOutdent = function () {
|
||||
var parents = document.getElementById('editorjs');
|
||||
parents.removeAttribute('padding-left');
|
||||
if (pad === 24) {
|
||||
parents.style.paddingLeft = 24 + 'px';
|
||||
} else {
|
||||
pad = pad - 24;
|
||||
parents.style.paddingLeft = pad + 'px';
|
||||
}
|
||||
var parents = document.getElementById('editorjs_box');
|
||||
parents.removeAttribute('padding-left');
|
||||
if (pad === 24) {
|
||||
parents.style.paddingLeft = 24 + 'px';
|
||||
} else {
|
||||
pad = pad - 24;
|
||||
parents.style.paddingLeft = pad + 'px';
|
||||
}
|
||||
};
|
||||
|
||||
RICH_EDITOR.setJustifyLeft = function () {
|
||||
document.execCommand('justifyLeft', false, null);
|
||||
document.execCommand('justifyLeft', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setJustifyCenter = function () {
|
||||
document.execCommand('justifyCenter', false, null);
|
||||
document.execCommand('justifyCenter', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setJustifyRight = function () {
|
||||
document.execCommand('justifyRight', false, null);
|
||||
document.execCommand('justifyRight', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.insertImage = function (url) {
|
||||
var 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>';
|
||||
RICH_EDITOR.insertHTML(html);
|
||||
RICH_EDITOR.editor.scrollIntoView(false);
|
||||
var 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
|
||||
document.getElementById('editorjs_box').scrollIntoView(false);
|
||||
};
|
||||
|
||||
RICH_EDITOR.insertHTML = function (html) {
|
||||
document.execCommand('insertHTML', false, html);
|
||||
document.execCommand('insertHTML', false, html);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setDone = function () {
|
||||
var html = '<input type="checkbox" checked="checked"/> ';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
var html = '<input type="checkbox" checked="checked"/> ';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
};
|
||||
|
||||
RICH_EDITOR.addTodo = function (e) {
|
||||
var KEY_ENTER;
|
||||
KEY_ENTER = 13;
|
||||
if (e.which === KEY_ENTER) {
|
||||
var node = RICH_EDITOR.getSelectedAnchorNode();
|
||||
if (node && node.nodeName === '#text') {
|
||||
node = node.parentElement;
|
||||
}
|
||||
if (node && node.nodeName === 'SPAN' && node.previousElementSibling
|
||||
&& node.previousElementSibling.className === 'note-checkbox') {
|
||||
RICH_EDITOR.setTodo();
|
||||
e.preventDefault();
|
||||
}
|
||||
var KEY_ENTER;
|
||||
KEY_ENTER = 13;
|
||||
if (e.which === KEY_ENTER) {
|
||||
var node = RICH_EDITOR.getSelectedAnchorNode();
|
||||
if (node && node.nodeName === '#text') {
|
||||
node = node.parentElement;
|
||||
}
|
||||
if (node && node.nodeName === 'SPAN' && node.previousElementSibling
|
||||
&& node.previousElementSibling.className === 'note-checkbox') {
|
||||
RICH_EDITOR.setTodo();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RICH_EDITOR.setTodo = function () {
|
||||
var parent = document.getElementById('editorjs');
|
||||
var isContentEmpty = parent.innerHTML.trim().length === 0 || parent.innerHTML === '<br>';
|
||||
var html = (isContentEmpty ? '' : '<br/>')
|
||||
+ '<input name="checkbox" type="checkbox" onclick="onCheckChange(this)" class="note-checkbox">'
|
||||
+ '<span class="note-checkbox-txt"> </span>';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
var parent = document.getElementById('editorjs_box');
|
||||
var isContentEmpty = parent.innerHTML.trim().length === 0 || parent.innerHTML === '<br>';
|
||||
var html = (isContentEmpty ? '' : '<br/>')
|
||||
+ '<input name="checkbox" type="checkbox" onclick="onCheckChange(this)" class="note-checkbox">'
|
||||
+ '<span class="note-checkbox-txt"> </span>';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
};
|
||||
|
||||
function onCheckChange(checkbox) {
|
||||
if (checkbox.checked === true) {
|
||||
checkbox.setAttribute('checked', 'checked');
|
||||
} else {
|
||||
checkbox.removeAttribute('checked');
|
||||
}
|
||||
if (checkbox.checked === true) {
|
||||
checkbox.setAttribute('checked', 'checked');
|
||||
} else {
|
||||
checkbox.removeAttribute('checked');
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.restorerange = function () {
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var 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);
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var 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);
|
||||
};
|
||||
|
||||
// 获取光标开始位置归属节点
|
||||
|
||||
RICH_EDITOR.getSelectedAnchorNode = function () {
|
||||
var node;
|
||||
var 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();
|
||||
node = range.commonAncestorContainer ? range.commonAncestorContainer : range.parentElement
|
||||
? range.parentElement() : range.item(0);
|
||||
}
|
||||
return node;
|
||||
var node;
|
||||
var 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();
|
||||
node = range.commonAncestorContainer ? range.commonAncestorContainer : range.parentElement
|
||||
? range.parentElement() : range.item(0);
|
||||
}
|
||||
return node;
|
||||
};
|
||||
|
||||
RICH_EDITOR.cancelSelection = function () {
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
|
||||
var callBackToApp;
|
||||
|
||||
function getHtmlContent() {
|
||||
console.log('getHtmlContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackhtml(htmlString);
|
||||
console.log('getHtmlContent end');
|
||||
console.log('getHtmlContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackhtml(htmlString);
|
||||
console.log('getHtmlContent end');
|
||||
}
|
||||
|
||||
function saveHtmlContent() {
|
||||
console.log('saveHtmlContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
console.log('saveHtmlContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackhtmlSave(htmlString);
|
||||
console.log('saveHtmlContent end');
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackhtmlSave(htmlString);
|
||||
console.log('saveHtmlContent end');
|
||||
}
|
||||
|
||||
function getImagePathFromContent(contentInfo) {
|
||||
let imgReg = /<img[^>]+>/g;
|
||||
let imgName = "";
|
||||
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
|
||||
let imgArray = contentInfo.match(imgReg);
|
||||
// 取第一张图片做为标题栏后的缩略图
|
||||
if (imgArray && imgArray.length > 0) {
|
||||
let src = imgArray[0].match(srcReg);
|
||||
if (src != null && src.length > 1) {
|
||||
imgName = src[1];
|
||||
if (imgName.indexOf('shuxue.png') >= 0 || imgName.indexOf('cake.png') >= 0) {
|
||||
imgName = "/res/" + imgName;
|
||||
}
|
||||
}
|
||||
let imgReg = /<img[^>]+>/g;
|
||||
let imgName = "";
|
||||
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
|
||||
let imgArray = contentInfo.match(imgReg);
|
||||
// 取第一张图片做为标题栏后的缩略图
|
||||
if (imgArray && imgArray.length > 0) {
|
||||
let src = imgArray[0].match(srcReg);
|
||||
if (src != null && src.length > 1) {
|
||||
imgName = src[1];
|
||||
if (imgName.indexOf('shuxue.png') >= 0 || imgName.indexOf('cake.png') >= 0) {
|
||||
imgName = "/res/" + imgName;
|
||||
}
|
||||
}
|
||||
return imgName;
|
||||
}
|
||||
return imgName;
|
||||
}
|
||||
|
||||
function scheduledSaveContent() {
|
||||
console.info('scheduledSaveContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackScheduledSave(htmlString);
|
||||
console.info('scheduledSaveContent end');
|
||||
console.info('scheduledSaveContent');
|
||||
var htmlString = RICH_EDITOR.getHtml();
|
||||
let imgName = getImagePathFromContent(htmlString);
|
||||
htmlString = window.btoa(unescape(encodeURIComponent(htmlString)));
|
||||
callBackToApp.callbackImagePath(imgName);
|
||||
var str = callBackToApp.callbackScheduledSave(htmlString);
|
||||
console.info('scheduledSaveContent end');
|
||||
}
|
||||
|
||||
document.body.addEventListener('paste', (event) => {
|
||||
let length = event.clipboardData.items.length;
|
||||
if (length > 0) {
|
||||
let file = event.clipboardData.items[0].getAsFile();
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => {
|
||||
callBackToApp.callbackPasteImage(reader.result);
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
event.preventDefault();
|
||||
let length = event.clipboardData.items.length;
|
||||
if (length > 0) {
|
||||
let file = event.clipboardData.items[0].getAsFile();
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => {
|
||||
callBackToApp.callbackPasteImage(reader.result);
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
document.execCommand('fontSize', false, null);
|
||||
var fontElements = window.getSelection().anchorNode.parentNode;
|
||||
var getSize = parseInt(window.getComputedStyle(fontElements, null).fontSize)
|
||||
var str = callBackToApp.callbackGetSize(getSize);
|
||||
};
|
||||
|
||||
RICH_EDITOR.insertImageHtml = function (contents) {
|
||||
let selection = window.getSelection();
|
||||
if (!selection.rangeCount)
|
||||
return false;
|
||||
selection.deleteFromDocument();
|
||||
let img = document.createElement('img');
|
||||
img.src = contents;
|
||||
selection.getRangeAt(0).insertNode(img);
|
||||
let selection = window.getSelection();
|
||||
if (!selection.rangeCount)
|
||||
return false;
|
||||
selection.deleteFromDocument();
|
||||
let img = document.createElement('img');
|
||||
img.src = contents;
|
||||
selection.getRangeAt(0).insertNode(img);
|
||||
};
|
||||
|
||||
document.addEventListener('click', (e) => {
|
||||
console.info(`lsq: e is ${JSON.stringify(e)}`)
|
||||
var parent = document.getElementById('editorjs');
|
||||
if (parent.id !== 'editorjs') {
|
||||
e.preventDefault()
|
||||
}
|
||||
console.info(`lsq: e is ${JSON.stringify(e)}`)
|
||||
var parent = document.getElementById('editorjs_box');
|
||||
if (parent.id !== 'editorjs_box') {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
document.getElementById('addToDo').addEventListener('click', () => {
|
||||
callBackToApp.addToDo()
|
||||
callBackToApp.addToDo()
|
||||
})
|
||||
|
||||
document.getElementById('chooseStyle').addEventListener('click', () => {
|
||||
callBackToApp.chooseStyle()
|
||||
callBackToApp.chooseStyle()
|
||||
})
|
||||
|
||||
document.getElementById('openAlbum').addEventListener('click', () => {
|
||||
callBackToApp.openAlbum()
|
||||
callBackToApp.openAlbum()
|
||||
})
|
||||
|
||||
function changeSizeToRk() {
|
||||
document.getElementById('img1').style.width = '40px';
|
||||
document.getElementById('img1').style.height = '40px';
|
||||
document.getElementById('img2').style.width = '40px';
|
||||
document.getElementById('img2').style.height = '40px';
|
||||
document.getElementById('img3').style.width = '40px';
|
||||
document.getElementById('img3').style.height = '40px';
|
||||
document.getElementById('lable1').style.fontSize = '20px';
|
||||
document.getElementById('lable2').style.fontSize = '20px';
|
||||
document.getElementById('lable3').style.fontSize = '20px';
|
||||
document.getElementById('img1').style.width = '40px';
|
||||
document.getElementById('img1').style.height = '40px';
|
||||
document.getElementById('img2').style.width = '40px';
|
||||
document.getElementById('img2').style.height = '40px';
|
||||
document.getElementById('img3').style.width = '40px';
|
||||
document.getElementById('img3').style.height = '40px';
|
||||
document.getElementById('lable1').style.fontSize = '20px';
|
||||
document.getElementById('lable2').style.fontSize = '20px';
|
||||
document.getElementById('lable3').style.fontSize = '20px';
|
||||
}
|
||||
|
||||
function changeSizeToPhone() {
|
||||
document.getElementById('img1').style.width = '24px';
|
||||
document.getElementById('img1').style.height = '24px';
|
||||
document.getElementById('img2').style.width = '24px';
|
||||
document.getElementById('img2').style.height = '24px';
|
||||
document.getElementById('img3').style.width = '24px';
|
||||
document.getElementById('img3').style.height = '24px';
|
||||
document.getElementById('lable1').style.fontSize = '12px';
|
||||
document.getElementById('lable2').style.fontSize = '12px';
|
||||
document.getElementById('lable3').style.fontSize = '12px';
|
||||
document.getElementById('img1').style.width = '24px';
|
||||
document.getElementById('img1').style.height = '24px';
|
||||
document.getElementById('img2').style.width = '24px';
|
||||
document.getElementById('img2').style.height = '24px';
|
||||
document.getElementById('img3').style.width = '24px';
|
||||
document.getElementById('img3').style.height = '24px';
|
||||
document.getElementById('lable1').style.fontSize = '12px';
|
||||
document.getElementById('lable2').style.fontSize = '12px';
|
||||
document.getElementById('lable3').style.fontSize = '12px';
|
||||
}
|
||||
|
||||
function changeSizeToTablet() {
|
||||
document.getElementById('img1').style.width = '28px';
|
||||
document.getElementById('img1').style.height = '28px';
|
||||
document.getElementById('img2').style.width = '28px';
|
||||
document.getElementById('img2').style.height = '28px';
|
||||
document.getElementById('img3').style.width = '28px';
|
||||
document.getElementById('img3').style.height = '28px';
|
||||
document.getElementById('lable1').style.fontSize = '12px';
|
||||
document.getElementById('lable2').style.fontSize = '12px';
|
||||
document.getElementById('lable3').style.fontSize = '12px';
|
||||
document.getElementById('img1').style.width = '28px';
|
||||
document.getElementById('img1').style.height = '28px';
|
||||
document.getElementById('img2').style.width = '28px';
|
||||
document.getElementById('img2').style.height = '28px';
|
||||
document.getElementById('img3').style.width = '28px';
|
||||
document.getElementById('img3').style.height = '28px';
|
||||
document.getElementById('lable1').style.fontSize = '12px';
|
||||
document.getElementById('lable2').style.fontSize = '12px';
|
||||
document.getElementById('lable3').style.fontSize = '12px';
|
||||
}
|
||||
|
||||
function hiddenButton() {
|
||||
document.getElementById('buttonBox').style.display = 'none';
|
||||
document.getElementById('buttonBox').style.display = 'none';
|
||||
}
|
||||
|
||||
RICH_EDITOR.getFocus = function() {
|
||||
return document.getElementById('editorjs').focus();
|
||||
RICH_EDITOR.getFocus = function () {
|
||||
return document.getElementById('editorjs_box').focus();
|
||||
}
|
||||
|
||||
document.getElementById('editorjs').addEventListener('click', () => {
|
||||
if (callBackToApp.getBreakPoint() === 'sm') {
|
||||
document.getElementById('buttonBox').style.display = 'flex';
|
||||
}
|
||||
document.getElementById('editorjs_box').addEventListener('click', () => {
|
||||
if (callBackToApp.getBreakPoint() === 'sm') {
|
||||
document.getElementById('buttonBox').style.display = 'flex';
|
||||
}
|
||||
})
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
import {LogUtil} from './LogUtil'
|
||||
import GlobalResourceManager from './GlobalResourceManager'
|
||||
|
||||
const TAG = "DateUtil"
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import FolderData from '../model/databaseModel/FolderData'
|
||||
import NoteData from '../model/databaseModel/NoteData'
|
||||
import {SysDefFolderUuid, FolderType, Favorite, Delete} from '../model/databaseModel/EnumData'
|
||||
import GlobalResourceManager from './GlobalResourceManager'
|
||||
import StyleConstants from '../constants/StyleConstants'
|
||||
import {LogUtil} from './LogUtil'
|
||||
|
||||
const TAG = "FolderUtil"
|
||||
@@ -38,6 +37,7 @@ export class FolderUtil {
|
||||
})
|
||||
if (folderData == undefined) {
|
||||
LogUtil.info(TAG, "no folder get " + folderUuid)
|
||||
folderData = new FolderData(0, "", new Date().getTime() + "", "", FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime())
|
||||
}
|
||||
return folderData
|
||||
}
|
||||
|
||||
@@ -13,15 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {WidthWeightMessage, unSelectedNoteBgColorMap, selectedNoteBgColorMap, folderTextMap, widthWeightMessageMap} from '../model/NoteBaseData'
|
||||
import FolderData from '../model/databaseModel/FolderData'
|
||||
import NoteData from '../model/databaseModel/NoteData'
|
||||
import {SysDefFolderUuid, FolderType, Favorite, Delete} from '../model/databaseModel/EnumData'
|
||||
import GlobalResourceManager from './GlobalResourceManager'
|
||||
import StyleConstants from '../constants/StyleConstants'
|
||||
import {WidthWeightMessage, widthWeightMessageMap} from '../model/NoteBaseData'
|
||||
import {LogUtil} from './LogUtil'
|
||||
import FolderUtil from './FolderUtil'
|
||||
import NoteUtil from './NoteUtil'
|
||||
|
||||
const TAG = "LayoutUtil"
|
||||
|
||||
|
||||
@@ -13,18 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {WidthWeightMessage, unSelectedNoteBgColorMap, selectedNoteBgColorMap, folderTextMap, widthWeightMessageMap
|
||||
} from '../model/NoteBaseData'
|
||||
import {unSelectedNoteBgColorMap, selectedNoteBgColorMap} from '../model/NoteBaseData'
|
||||
import FolderData from '../model/databaseModel/FolderData'
|
||||
import NoteData from '../model/databaseModel/NoteData'
|
||||
import {SysDefFolderUuid, FolderType, Favorite, Delete, TableName, NoteTableColumn,
|
||||
} from '../model/databaseModel/EnumData'
|
||||
import GlobalResourceManager from './GlobalResourceManager'
|
||||
import StyleConstants from '../constants/StyleConstants'
|
||||
import {LogUtil} from './LogUtil'
|
||||
import FolderUtil from './FolderUtil'
|
||||
import RdbStoreUtil from './RdbStoreUtil'
|
||||
import prompt from '@system.prompt'
|
||||
|
||||
const TAG = "NoteUtil"
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
import { atob } from 'js-base64'
|
||||
import ohosDataRdb from '@ohos.data.rdb'
|
||||
import fileio from '@ohos.fileio'
|
||||
import { LogUtil } from './LogUtil'
|
||||
import FolderUtil from './FolderUtil'
|
||||
@@ -24,6 +23,7 @@ import FolderData from '../model/databaseModel/FolderData'
|
||||
import NoteData from '../model/databaseModel/NoteData'
|
||||
import { TableSql, TableName, FolderTableColumn, NoteTableColumn, SysDefFolderUuid
|
||||
} from '../model/databaseModel/EnumData'
|
||||
import relationalStore from '@ohos.data.relationalStore'
|
||||
|
||||
const TAG = "RdbStoreUtil"
|
||||
|
||||
@@ -38,7 +38,7 @@ export default {
|
||||
* create db and table
|
||||
*/
|
||||
createRdbStore(context) {
|
||||
ohosDataRdb.getRdbStore(context, SysDefData.dbInfo.db_name, SysDefData.dbInfo.db_verison)
|
||||
relationalStore.getRdbStore(context, SysDefData.dbInfo.db_name)
|
||||
.then(async (store) => {
|
||||
LogUtil.info(TAG, "createRdbStore, store is " + store)
|
||||
globalThis.rdbStore = store
|
||||
@@ -170,13 +170,13 @@ export default {
|
||||
initAppStorage(context) {
|
||||
let folderDataArray = []
|
||||
let noteDataArray = []
|
||||
ohosDataRdb.getRdbStore(context, SysDefData.dbInfo.db_name, SysDefData.dbInfo.db_verison)
|
||||
relationalStore.getRdbStore(context, SysDefData.dbInfo.db_name)
|
||||
.then(async (store) => {
|
||||
LogUtil.info(TAG, "initAppStorage, store is " + store)
|
||||
globalThis.rdbStore = store
|
||||
// query folder
|
||||
let columns_folder = []
|
||||
let predicates_folder = new ohosDataRdb.RdbPredicates(TableName.FolderTable)
|
||||
let predicates_folder = new relationalStore.RdbPredicates(TableName.FolderTable)
|
||||
let resultSet_folder = await globalThis.rdbStore.query(predicates_folder, columns_folder)
|
||||
while (resultSet_folder.goToNextRow()) {
|
||||
let id = resultSet_folder.getLong(resultSet_folder.getColumnIndex(FolderTableColumn.Id))
|
||||
@@ -190,10 +190,11 @@ export default {
|
||||
let folderData = new FolderData(id, name, uuid, color, folder_type, is_deleted, created_time, modified_time)
|
||||
folderDataArray.push(folderData)
|
||||
}
|
||||
resultSet_folder.close();
|
||||
LogUtil.info(TAG, "folderDataArray[query] : " + folderDataArray.length)
|
||||
// query note
|
||||
let columns_note = []
|
||||
let predicates_note = new ohosDataRdb.RdbPredicates(TableName.NoteTable)
|
||||
let predicates_note = new relationalStore.RdbPredicates(TableName.NoteTable)
|
||||
let resultSet_note = await globalThis.rdbStore.query(predicates_note, columns_note)
|
||||
while (resultSet_note.goToNextRow()) {
|
||||
let id = resultSet_note.getLong(resultSet_note.getColumnIndex(NoteTableColumn.Id))
|
||||
@@ -220,6 +221,7 @@ export default {
|
||||
let noteData = new NoteData(id, title, uuid, folder_uuid, content_text, content_img, noteType, is_top, is_favorite, is_deleted, created_time, modified_time, deleted_time, slider_value)
|
||||
noteDataArray.push(noteData)
|
||||
}
|
||||
resultSet_note.close();
|
||||
LogUtil.info(TAG, "noteDataArray[query] : " + noteDataArray.length)
|
||||
|
||||
AppStorage.SetOrCreate('AllFolderArray', folderDataArray)
|
||||
@@ -476,7 +478,7 @@ export default {
|
||||
* @param tableName
|
||||
*/
|
||||
getRdbPredicates(tableName) {
|
||||
return new ohosDataRdb.RdbPredicates(tableName)
|
||||
return new relationalStore.RdbPredicates(tableName)
|
||||
},
|
||||
|
||||
updataNoteImage(noteData: NoteData): string {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import {SysDefFolder, SysDefFolderUuid, FolderType, NoteType, Favorite, Top, Delete} from './EnumData'
|
||||
import relationalStore from '@ohos.data.relationalStore'
|
||||
|
||||
export default {
|
||||
/**
|
||||
@@ -21,7 +22,8 @@ export default {
|
||||
*/
|
||||
dbInfo: {
|
||||
db_name: {
|
||||
name: "note.db" // 数据库名称
|
||||
name: "note.db", // 数据库名称
|
||||
securityLevel: relationalStore.SecurityLevel.S1
|
||||
},
|
||||
db_verison: 1 // 数据库版本
|
||||
},
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
|
||||
import {LogUtil} from '../../baseUtil/LogUtil'
|
||||
import NoteData from '../../model/databaseModel/NoteData'
|
||||
import ohosDataRdb from '@ohos.data.rdb';
|
||||
import {TableName, NoteTableColumn} from '../../model/databaseModel/EnumData'
|
||||
import NoteUtil from '../../baseUtil/NoteUtil'
|
||||
import RdbStoreUtil from '../../baseUtil/RdbStoreUtil'
|
||||
import SysDefData from '../../model/databaseModel/SysDefData'
|
||||
import util from '@ohos.util'
|
||||
|
||||
const TAG = "SearchModel"
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
"name": "ohosTest",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"license": "ISC",
|
||||
"types": "",
|
||||
"devDependencies": {},
|
||||
"name": "@ohos/component",
|
||||
"description": "a npm package which contains arkUI2.0 page",
|
||||
"ohos": {
|
||||
"org": ""
|
||||
},
|
||||
"main": "index.ets",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/utils": "file:../common/utils",
|
||||
"@ohos/source": "file:../common/resources"
|
||||
}
|
||||
"license": "ISC",
|
||||
"types": "",
|
||||
"devDependencies": {},
|
||||
"name": "@ohos/component",
|
||||
"description": "a npm package which contains arkUI2.0 page",
|
||||
"ohos": {
|
||||
"org": ""
|
||||
},
|
||||
"main": "index.ets",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/utils": "file:../common/utils",
|
||||
"@ohos/source": "file:../common/resources"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
DeleteFileType
|
||||
} from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'
|
||||
import { NewOrEditFolderDialog, DeleteDialog } from './CusDialogComp'
|
||||
import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants'
|
||||
import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
|
||||
import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil'
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
|
||||
@@ -38,7 +37,7 @@ export struct FolderListComp {
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
@Consume('ExpandStatus') expandStatus: boolean // 笔记本折叠展开状态
|
||||
@StorageLink('breakPoint') breakPoints: string = 'lg'
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
TAG = "FolderListComp"
|
||||
@Consume('AsideWidth') asideWidth: number
|
||||
|
||||
@@ -174,7 +173,7 @@ export struct NoteAndCreateComp {
|
||||
|
||||
@Component
|
||||
struct FolderItemComp {
|
||||
@State folderItem: FolderData = undefined
|
||||
@State folderItem: FolderData = new FolderData(0, "", new Date().getTime() + "", "", FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime())
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = []
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@@ -184,7 +183,7 @@ struct FolderItemComp {
|
||||
@Consume('Longpress') longpress: boolean
|
||||
@Consume('SelectedColor') selectedColor: string
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
@State isLongPress: boolean = false
|
||||
TAG = "FolderListComp"
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
@@ -278,9 +277,9 @@ struct FolderItemComp {
|
||||
}
|
||||
// 刷新web界面
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
@@ -374,7 +373,7 @@ struct FolderItemComp {
|
||||
|
||||
build() {
|
||||
Flex() {
|
||||
if (this.folderItem.folder_type == FolderType.CusDef) {
|
||||
if (this.folderItem?.folder_type == FolderType.CusDef) {
|
||||
Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Row() {
|
||||
Image(FolderUtil.getFolderIcon(this.folderItem.uuid))
|
||||
@@ -423,9 +422,9 @@ struct FolderItemComp {
|
||||
}
|
||||
// 刷新web界面
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
@@ -482,9 +481,9 @@ struct FolderItemComp {
|
||||
}
|
||||
// 刷新web界面
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
|
||||
@@ -26,14 +26,11 @@ import {
|
||||
Delete
|
||||
} from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'
|
||||
import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants'
|
||||
import { EditContentDialog, DeleteDialog, EditTitleDialog } from './CusDialogComp'
|
||||
import { EditContentDialog, EditTitleDialog } from './CusDialogComp'
|
||||
import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil'
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
|
||||
import prompt from '@system.prompt'
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationUtils'
|
||||
import mediaquery from '@ohos.mediaquery'
|
||||
import router from '@system.router';
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import { folderTextMap } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
@@ -49,7 +46,7 @@ export struct NoteContent {
|
||||
@Provide('Issave') issave: number = 0
|
||||
@Provide('EditModel') editModel: boolean = false
|
||||
@StorageLink('dpi') dpi: number = 240
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
private editContentFlag = false
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
|
||||
|
||||
@@ -57,6 +54,7 @@ export struct NoteContent {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight())
|
||||
}
|
||||
|
||||
restoreScrollTop() {
|
||||
@@ -67,6 +65,9 @@ export struct NoteContent {
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript(
|
||||
'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight() * scrollTopPercent
|
||||
)
|
||||
AppStorage.Delete('remoteScrollTopPercent')
|
||||
}
|
||||
|
||||
@@ -146,7 +147,7 @@ export struct NoteContent {
|
||||
realHtml = "file://" + filePath
|
||||
}
|
||||
LogUtil.info(TAG, 'paste info11' + realHtml)
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')")
|
||||
} else {
|
||||
LogUtil.info(TAG, 'paste info22223')
|
||||
}
|
||||
@@ -187,28 +188,28 @@ export struct NoteContent {
|
||||
})
|
||||
.onPageEnd((e) => {
|
||||
if (this.dpi <= 240) {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToRk()" })
|
||||
this.controllerShow.runJavaScript("changeSizeToRk()")
|
||||
} else if (this.dpi <= 320 && this.dpi > 240) {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToPhone()" })
|
||||
this.controllerShow.runJavaScript("changeSizeToPhone()")
|
||||
} else {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToTablet()" })
|
||||
this.controllerShow.runJavaScript("changeSizeToTablet()")
|
||||
}
|
||||
if (AppStorage.Get('breakPoint') !== 'sm') {
|
||||
this.controllerShow.runJavaScript({ script: "hiddenButton()" })
|
||||
this.controllerShow.runJavaScript("hiddenButton()")
|
||||
}
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
if (this.selectedNoteData) {
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
callback: () => {
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
() => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function () {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
.zoomAccess(false)
|
||||
@@ -216,7 +217,7 @@ export struct NoteContent {
|
||||
.onlineImageAccess(true)
|
||||
.fileAccess(true)
|
||||
.domStorageAccess(true)
|
||||
.height('70%')
|
||||
.height('88%')
|
||||
.width('100%')
|
||||
.onScroll((event) => {
|
||||
this.storeScrollTop(event.yOffset)
|
||||
@@ -227,7 +228,7 @@ export struct NoteContent {
|
||||
clearInterval(timeID)
|
||||
}
|
||||
timeID = setInterval(() => {
|
||||
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
|
||||
this.controllerShow.runJavaScript("scheduledSaveContent()")
|
||||
}, 3000)
|
||||
LogUtil.info(TAG, "setInterval timeID : " + timeID)
|
||||
this.issave = 0
|
||||
@@ -235,7 +236,6 @@ export struct NoteContent {
|
||||
})
|
||||
}
|
||||
.margin({ left: 12, right: 24, top: 16 })
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
@@ -261,7 +261,7 @@ export struct ToolBarComp {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('Issave') issave: number
|
||||
@Consume('EditModel') editModel: boolean
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
editContentDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: EditContentDialog({ confirm: this.confirm.bind(this) }),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
@@ -270,7 +270,7 @@ export struct ToolBarComp {
|
||||
})
|
||||
|
||||
confirm(excuteJs: string) {
|
||||
this.controllerShow.runJavaScript({ script: excuteJs })
|
||||
this.controllerShow.runJavaScript(excuteJs)
|
||||
}
|
||||
|
||||
build() {
|
||||
@@ -280,8 +280,8 @@ export struct ToolBarComp {
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)")
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
// 清除定时器
|
||||
if (timeID != undefined) {
|
||||
LogUtil.info(TAG, "zoom, clearInterval timeID : " + timeID)
|
||||
@@ -322,7 +322,7 @@ export struct ToolBarComp {
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
// 清单
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.setTodo()")
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -364,19 +364,19 @@ export struct ToolBarComp {
|
||||
let imageUri = ""
|
||||
if (param != null && param != undefined) {
|
||||
let uri = param['select-item-list'];
|
||||
imageUri = uri;
|
||||
imageUri = uri[0];
|
||||
}
|
||||
// 拷贝
|
||||
if (imageUri != null && imageUri != "") {
|
||||
OperationUtils.copy(imageUri).then((uriPath) => {
|
||||
var path = "file://" + uriPath
|
||||
LogUtil.info(TAG, 'image uri is:' + path)
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "javascript:RICH_EDITOR.insertImage('" + path + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"javascript:RICH_EDITOR.insertImage('" + path + "')"
|
||||
)
|
||||
this.issave = 1
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ export struct ToolBarComp {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.undo()")
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -410,7 +410,7 @@ export struct ToolBarComp {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.redo()")
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -426,7 +426,7 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
this.issave = 1
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
|
||||
@@ -35,6 +35,7 @@ import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationU
|
||||
import mediaquery from '@ohos.mediaquery'
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import { folderTextMap } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
|
||||
const TAG = "NoteContentComp"
|
||||
|
||||
@@ -55,7 +56,7 @@ export struct NoteContentComp {
|
||||
@Consume('Issave') issave: number
|
||||
@Consume('Search') search: boolean
|
||||
@StorageLink('dpi') dpi: number = 240
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
private editContentFlag = false
|
||||
@State uri1: string = ""
|
||||
private context = getContext(this)
|
||||
@@ -68,7 +69,7 @@ export struct NoteContentComp {
|
||||
if (!this.refreshCurrentNote) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')")
|
||||
this.refreshCurrentNote = false
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ export struct NoteContentComp {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight())
|
||||
}
|
||||
|
||||
restoreScrollTop() {
|
||||
@@ -86,6 +88,9 @@ export struct NoteContentComp {
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript(
|
||||
'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight() * scrollTopPercent
|
||||
)
|
||||
}
|
||||
|
||||
restoreFocus() {
|
||||
@@ -181,7 +186,7 @@ export struct NoteContentComp {
|
||||
realHtml = "file://" + filePath
|
||||
}
|
||||
LogUtil.info(TAG, 'paste info11-' + realHtml)
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')")
|
||||
LogUtil.info(TAG, 'paste info11--' + realHtml)
|
||||
} else {
|
||||
LogUtil.info(TAG, 'paste info22225')
|
||||
@@ -224,34 +229,35 @@ export struct NoteContentComp {
|
||||
methodList: ["callbackhtml", "callbackhtmlSave", "callbackScheduledSave", "callbackGetSize", "callbackPasteImage", "callbackImagePath"],
|
||||
controller: this.controllerShow
|
||||
})
|
||||
.enabled(this.sectionStatus !== 1 ? false : true)
|
||||
.onPageEnd((e) => {
|
||||
if (this.dpi <= 240) {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToRk()" })
|
||||
this.controllerShow.runJavaScript("changeSizeToRk()")
|
||||
} else if (this.dpi <= 320 && this.dpi > 240) {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToPhone()" })
|
||||
this.controllerShow.runJavaScript("changeSizeToPhone()")
|
||||
} else {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToTablet()" })
|
||||
this.controllerShow.runJavaScript("changeSizeToTablet()")
|
||||
}
|
||||
if (AppStorage.Get('breakPoint') !== 'sm') {
|
||||
this.controllerShow.runJavaScript({ script: "hiddenButton()" })
|
||||
this.controllerShow.runJavaScript("hiddenButton()")
|
||||
}
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
if (this.selectedNoteData) {
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
callback: () => {
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
() => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function () {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
// 初次加载为为小屏预览模式
|
||||
if (this.sectionStatus != 1) {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)")
|
||||
}
|
||||
})
|
||||
.imageAccess(true)
|
||||
@@ -278,13 +284,13 @@ export struct NoteContentComp {
|
||||
this.asideWidth = 0
|
||||
this.lastSectionStatus = this.sectionStatus
|
||||
this.sectionStatus = 1
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(true)")
|
||||
// 添加定时器:3s自动保存
|
||||
if (timeId) {
|
||||
clearInterval(timeId)
|
||||
}
|
||||
timeId = setInterval(() => {
|
||||
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
|
||||
this.controllerShow.runJavaScript("scheduledSaveContent()")
|
||||
}, 3000)
|
||||
LogUtil.info(TAG, "setInterval timeId : " + timeId)
|
||||
// save continue data
|
||||
@@ -333,7 +339,7 @@ export struct NoteContentOverViewComp {
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
NoteDataMoveArray: FolderData[]
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
editTitleDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: EditTitleDialog({ confirm: this.confirm.bind(this) }),
|
||||
alignment: DialogAlignment.Center,
|
||||
@@ -374,9 +380,9 @@ export struct NoteContentOverViewComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
if (this.sectionStatus != 1) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
} else {
|
||||
this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), item.uuid)
|
||||
@@ -407,8 +413,6 @@ export struct NoteContentOverViewComp {
|
||||
.fontSize(30)
|
||||
.margin({ left: 0, right: 24 })
|
||||
.onClick(() => {
|
||||
this.editModel = true
|
||||
this.sectionStatus = 1
|
||||
clearInterval(timeId)
|
||||
this.editTitleDialogCtl.open()
|
||||
// save continue data
|
||||
@@ -465,7 +469,7 @@ export struct ToolBarComp {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('EditModel') editModel: boolean
|
||||
@Consume('Issave') issave: number
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
private context = getContext(this)
|
||||
noteDataDeleteDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: DeleteDialog({ onConfirm: this.onDeleteConfirm.bind(this) }),
|
||||
@@ -492,7 +496,7 @@ export struct ToolBarComp {
|
||||
}
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')")
|
||||
this.chooseNote = false
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
@@ -509,7 +513,7 @@ export struct ToolBarComp {
|
||||
})
|
||||
|
||||
confirm(excuteJs: string) {
|
||||
this.controllerShow.runJavaScript({ script: excuteJs })
|
||||
this.controllerShow.runJavaScript(excuteJs)
|
||||
}
|
||||
|
||||
build() {
|
||||
@@ -523,16 +527,16 @@ export struct ToolBarComp {
|
||||
this.lastSectionStatus = this.sectionStatus
|
||||
this.sectionStatus = 1
|
||||
this.asideWidth = 0
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(true)")
|
||||
} else {
|
||||
if (this.lastSectionStatus != undefined) {
|
||||
this.asideWidth = 200
|
||||
// 切换为小屏预览模式
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)")
|
||||
this.sectionStatus = this.lastSectionStatus
|
||||
// 退出全屏时存库
|
||||
LogUtil.info(TAG, "close note" + this.selectedNoteData.uuid)
|
||||
this.controllerShow.runJavaScript({ script: "saveHtmlContent()" })
|
||||
this.controllerShow.runJavaScript("saveHtmlContent()")
|
||||
//退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
@@ -589,9 +593,9 @@ export struct ToolBarComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
@@ -607,7 +611,7 @@ export struct ToolBarComp {
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
// 清单
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.setTodo()")
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
@@ -642,7 +646,9 @@ export struct ToolBarComp {
|
||||
"ohos.permission.WRITE_MEDIA",
|
||||
]
|
||||
let context: any = getContext(this);
|
||||
await context.requestPermissionsFromUser(permissionList).then((data) => {
|
||||
let AtManager = abilityAccessCtrl.createAtManager();
|
||||
// @ts-ignore
|
||||
await AtManager.requestPermissionsFromUser(context, permissionList).then((data) => {
|
||||
LogUtil.info(TAG, 'data permissions : ' + data.permissions)
|
||||
LogUtil.info(TAG, 'data result: ' + data.authResults)
|
||||
let sum = 0
|
||||
@@ -676,12 +682,12 @@ export struct ToolBarComp {
|
||||
OperationUtils.copy(imageUri).then((uriPath) => {
|
||||
var path = "file://" + uriPath
|
||||
LogUtil.info(TAG, 'image uri is:' + path)
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "javascript:RICH_EDITOR.insertImage('" + path + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"javascript:RICH_EDITOR.insertImage('" + path + "')"
|
||||
)
|
||||
this.issave = 1
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -701,7 +707,7 @@ export struct ToolBarComp {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.undo()")
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -716,7 +722,7 @@ export struct ToolBarComp {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.redo()")
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -731,7 +737,7 @@ export struct ToolBarComp {
|
||||
.fillColor(this.issave == 0 ? Color.Black : Color.Grey)
|
||||
.onClick(() => {
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") {
|
||||
LogUtil.info(TAG, "note is empty,save note failed")
|
||||
}
|
||||
@@ -756,9 +762,9 @@ export struct ToolBarComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites)
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
|
||||
@@ -35,7 +35,7 @@ import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationU
|
||||
import router from '@system.router'
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import { folderTextMap } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
import rs from '@ohos.resourceManager'
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
|
||||
var time_id: number
|
||||
|
||||
@@ -57,7 +57,7 @@ export struct NoteContentCompPortrait {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Provide('EditModel') editModel: boolean = false
|
||||
@StorageLink('dpi') dpi: number = 240
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
private editContentFlag = false
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
|
||||
editContentDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
@@ -68,23 +68,32 @@ export struct NoteContentCompPortrait {
|
||||
})
|
||||
|
||||
confirm(excuteJs: string) {
|
||||
this.controllerShow.runJavaScript({ script: excuteJs })
|
||||
this.controllerShow.runJavaScript(excuteJs)
|
||||
}
|
||||
|
||||
storeScrollTop(scrollTop: number) {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight())
|
||||
}
|
||||
|
||||
restoreScrollTop() {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
return
|
||||
}
|
||||
var scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
try {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
return
|
||||
}
|
||||
var scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript(
|
||||
'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight() * scrollTopPercent
|
||||
)
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'restoreScrollTop error')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
restoreFocus() {
|
||||
@@ -160,7 +169,7 @@ export struct NoteContentCompPortrait {
|
||||
realHtml = "file://" + filePath
|
||||
}
|
||||
LogUtil.info(TAG, 'paste info11' + realHtml)
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')")
|
||||
} else {
|
||||
LogUtil.info(TAG, 'paste info22224')
|
||||
}
|
||||
@@ -180,7 +189,7 @@ export struct NoteContentCompPortrait {
|
||||
},
|
||||
addToDo: () => {
|
||||
// 清单
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.setTodo()")
|
||||
},
|
||||
chooseStyle: () => {
|
||||
this.editContentDialogCtl.open()
|
||||
@@ -191,7 +200,9 @@ export struct NoteContentCompPortrait {
|
||||
"ohos.permission.WRITE_MEDIA",
|
||||
]
|
||||
let context: any = getContext(this);
|
||||
await context.requestPermissionsFromUser(permissionList).then((data) => {
|
||||
let AtManager = abilityAccessCtrl.createAtManager();
|
||||
// @ts-ignore
|
||||
await AtManager.requestPermissionsFromUser(context, permissionList).then((data) => {
|
||||
LogUtil.info(TAG, 'data permissions : ' + data.permissions)
|
||||
LogUtil.info(TAG, 'data result: ' + data.authResults)
|
||||
let sum = 0
|
||||
@@ -214,7 +225,7 @@ export struct NoteContentCompPortrait {
|
||||
let imageUri = ""
|
||||
if (param != null && param != undefined) {
|
||||
let uri = param['select-item-list'];
|
||||
imageUri = uri;
|
||||
imageUri = uri[0];
|
||||
}
|
||||
LogUtil.info(TAG, "image url" + imageUri)
|
||||
// 拷贝
|
||||
@@ -222,8 +233,8 @@ export struct NoteContentCompPortrait {
|
||||
OperationUtils.copy(imageUri).then((uriPath) => {
|
||||
var path = "file://" + uriPath
|
||||
LogUtil.info(TAG, 'image uri is:' + path)
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.getFocus()" })
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImage('" + path + "')" })
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.getFocus()")
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImage('" + path + "')")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -241,10 +252,12 @@ export struct NoteContentCompPortrait {
|
||||
Column() {
|
||||
ToolBarComp({ controllerShow: this.controllerShow })
|
||||
NoteContentOverViewComp()
|
||||
.enabled(this.selectedNoteData && this.selectedNoteData.is_deleted == Delete.Yes ? false : true)
|
||||
}
|
||||
|
||||
Column() {
|
||||
Web({ src: $rawfile('editor.html'), controller: this.controllerShow })
|
||||
.overviewModeAccess(false)
|
||||
.javaScriptAccess(true)
|
||||
.javaScriptProxy({
|
||||
object: this.noteContent,
|
||||
@@ -253,25 +266,30 @@ export struct NoteContentCompPortrait {
|
||||
controller: this.controllerShow
|
||||
})
|
||||
.onPageEnd((e) => {
|
||||
if (this.dpi <= 240) {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToRk()" })
|
||||
} else if (this.dpi <= 320 && this.dpi > 240) {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToPhone()" })
|
||||
} else {
|
||||
this.controllerShow.runJavaScript({ script: "changeSizeToTablet()" })
|
||||
}
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
callback: () => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function () {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
try {
|
||||
if (this.dpi <= 240) {
|
||||
this.controllerShow.runJavaScript("changeSizeToRk()")
|
||||
} else if (this.dpi <= 320 && this.dpi > 240) {
|
||||
this.controllerShow.runJavaScript("changeSizeToPhone()")
|
||||
} else {
|
||||
this.controllerShow.runJavaScript("changeSizeToTablet()")
|
||||
}
|
||||
})
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
() => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function () {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'onPageEnd error')
|
||||
}
|
||||
|
||||
})
|
||||
.imageAccess(true)
|
||||
.onlineImageAccess(true)
|
||||
@@ -283,19 +301,24 @@ export struct NoteContentCompPortrait {
|
||||
.onScroll((event) => {
|
||||
this.storeScrollTop(event.yOffset)
|
||||
})
|
||||
.onClick(() => {
|
||||
if (time_id) {
|
||||
clearInterval(time_id)
|
||||
}
|
||||
// 添加定时器:3s自动保存
|
||||
time_id = setInterval(() => {
|
||||
try {
|
||||
this.controllerShow.runJavaScript("scheduledSaveContent()")
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'setInterval error')
|
||||
}
|
||||
}, 3000)
|
||||
LogUtil.info(TAG, "setInterval time_id : " + time_id)
|
||||
this.editModel = true
|
||||
})
|
||||
}
|
||||
.enabled(this.selectedNoteData && this.selectedNoteData.is_deleted == Delete.Yes ? false : true)
|
||||
.flexShrink(1)
|
||||
.onClick(() => {
|
||||
if (time_id) {
|
||||
clearInterval(time_id)
|
||||
}
|
||||
// 添加定时器:3s自动保存
|
||||
time_id = setInterval(() => {
|
||||
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
|
||||
}, 3000)
|
||||
LogUtil.info(TAG, "setInterval time_id : " + time_id)
|
||||
this.editModel = true
|
||||
})
|
||||
.margin({ top: 16 })
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
@@ -437,7 +460,7 @@ export struct ToolBarComp {
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('EditModel') editModel: boolean
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
|
||||
onDeleteConfirm() {
|
||||
if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
|
||||
@@ -475,14 +498,18 @@ export struct ToolBarComp {
|
||||
.width(24)
|
||||
.responseRegion({ width: 54, height: 54 })
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
// 清除定时器
|
||||
if (time_id != undefined) {
|
||||
LogUtil.info(TAG, "back, clearInterval time_id : " + time_id)
|
||||
clearInterval(time_id)
|
||||
try {
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
// 清除定时器
|
||||
if (time_id != undefined) {
|
||||
LogUtil.info(TAG, "back, clearInterval time_id : " + time_id)
|
||||
clearInterval(time_id)
|
||||
}
|
||||
router.back()
|
||||
NoteUtil.refreshAll()
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'back error')
|
||||
}
|
||||
router.back()
|
||||
NoteUtil.refreshAll()
|
||||
})
|
||||
|
||||
if (this.editModel == false) {
|
||||
@@ -490,22 +517,26 @@ export struct ToolBarComp {
|
||||
Image(this.selectedNoteData.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel'))
|
||||
.height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes)
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites)
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "ToolBarComp, set continue note success")
|
||||
try {
|
||||
this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes)
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites)
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "ToolBarComp, set continue note success")
|
||||
}
|
||||
NoteUtil.refreshAll()
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'favorite error')
|
||||
}
|
||||
NoteUtil.refreshAll()
|
||||
})
|
||||
Image($r('app.media.delete')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
@@ -518,10 +549,14 @@ export struct ToolBarComp {
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.undo')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.undo()" })
|
||||
try {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.undo()")
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'undo error')
|
||||
}
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -531,10 +566,14 @@ export struct ToolBarComp {
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.todo')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.redo()" })
|
||||
try {
|
||||
// 退出键盘
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.redo()")
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'todo error')
|
||||
}
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
@@ -544,9 +583,13 @@ export struct ToolBarComp {
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.tick_thin')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
this.editModel = false
|
||||
try {
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
this.editModel = false
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'tick_thin error')
|
||||
}
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
|
||||
@@ -30,11 +30,9 @@ import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil
|
||||
import prompt from '@system.prompt'
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
|
||||
import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil'
|
||||
import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants'
|
||||
import SearchModel from '@ohos/utils/src/main/ets/default/model/searchModel/SearchModel'
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import router from '@system.router';
|
||||
import rs from '@ohos.resourceManager'
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
|
||||
const TAG = "NoteListComp"
|
||||
@@ -56,7 +54,7 @@ export struct NoteListComp {
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('Search') search: boolean
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
@Consume('AsideWidth') asideWidth: number
|
||||
|
||||
build() {
|
||||
@@ -103,10 +101,20 @@ struct NoteOverViewComp {
|
||||
@Consume('ExpandStatus') expandStatus: boolean
|
||||
@Consume('Search') search: boolean
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
@State noteNumber: number = undefined
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
@StorageLink('isUpdate') @Watch('notesNumberChange') isUpdate: boolean = false
|
||||
@Consume('AsideWidth') asideWidth: number
|
||||
@State isShow: boolean = false
|
||||
|
||||
notesNumberChange() {
|
||||
let noteNumbers = FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
if (noteNumbers == 0) {
|
||||
this.isShow = false
|
||||
} else {
|
||||
this.isShow = true
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
@@ -163,7 +171,7 @@ struct NoteOverViewComp {
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
}
|
||||
.margin({ top: 5 })
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
|
||||
.visibility(this.isShow ? Visibility.Visible : Visibility.None)
|
||||
}.visibility(this.longpress ? Visibility.None : Visibility.Visible)
|
||||
|
||||
Row() {
|
||||
@@ -210,7 +218,7 @@ struct NoteOverViewComp {
|
||||
export struct NoteItemComp {
|
||||
public noteItem: NoteData
|
||||
public spans: any[]
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@@ -340,9 +348,12 @@ export struct NoteItemComp {
|
||||
LogUtil.info(TAG, "NoteItemComp, set continue note success")
|
||||
}
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.cancelSelection()"
|
||||
)
|
||||
}
|
||||
if (this.portraitModel == true) {
|
||||
AppStorage.SetOrCreate<NoteData>('NewNote', this.selectedNoteData)
|
||||
@@ -382,7 +393,7 @@ export struct NoteItemListComp {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@State dateList: NoteData[] = []
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
@StorageLink('isUpdate') @Watch('updateList') isUpdate: boolean = false
|
||||
|
||||
updateList() {
|
||||
@@ -394,6 +405,8 @@ export struct NoteItemListComp {
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
LogUtil.info(TAG, "inputKeyWord:" + this.inputKeyword)
|
||||
this.inputKeyword = ''
|
||||
this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
}
|
||||
|
||||
@@ -411,9 +424,9 @@ export struct NoteItemListComp {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
}
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
@@ -524,7 +537,7 @@ export struct OperateNoteComp {
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@Consume('selectedAll') selectedAll: boolean
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
noteDataMoveDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: NoteDataMoveDialog({ onConfirm: this.onMoveConfirm.bind(this) }),
|
||||
alignment: DialogAlignment.Center,
|
||||
@@ -546,7 +559,7 @@ export struct OperateNoteComp {
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "onMoveConfirm, set continue note success")
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')")
|
||||
}
|
||||
this.longpress = false
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
@@ -585,7 +598,7 @@ export struct OperateNoteComp {
|
||||
this.longpress = false
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')")
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
@@ -700,7 +713,7 @@ export struct AddNoteComp {
|
||||
@Consume('EditModel') editModel: boolean
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
|
||||
build() {
|
||||
Image($r('app.media.addNote'))
|
||||
@@ -723,9 +736,9 @@ export struct AddNoteComp {
|
||||
this.selectedNoteData = noteData
|
||||
AppStorage.SetOrCreate<NoteData>('NewNote', noteData)
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
}
|
||||
if (this.portraitModel == true) {
|
||||
this.editModel = true
|
||||
|
||||
Generated
-1236
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -11,10 +11,10 @@
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/hypium": "1.0.2",
|
||||
"@ohos/hvigor": "1.2.2",
|
||||
"@ohos/hvigor-ohos-plugin": "1.2.2",
|
||||
"hypium": "^1.0.0",
|
||||
"@ohos/hvigor": "1.2.2",
|
||||
"js-base64": "^3.7.2"
|
||||
"js-base64": "^3.7.2",
|
||||
"@ohos/hypium": "1.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "default",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/utils": "file:../../common/utils",
|
||||
"@ohos/component": "file:../../features",
|
||||
"@ohos/source": "file:../../common/resources"
|
||||
}
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "default",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/utils": "file:../../common/utils",
|
||||
"@ohos/component": "file:../../features",
|
||||
"@ohos/source": "file:../../common/resources"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import AbilityStage from "@ohos.app.ability.AbilityStage"
|
||||
import AbilityStage from '@ohos.app.ability.AbilityStage';
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Ability from '@ohos.app.ability.UIAbility'
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant'
|
||||
import fileio from '@ohos.fileio'
|
||||
@@ -25,7 +25,7 @@ import window from '@ohos.window';
|
||||
|
||||
globalThis.rdbStore = undefined
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
export default class MainAbility extends UIAbility {
|
||||
private Tag = "MainAbility_Tablet"
|
||||
|
||||
onCreate(want, launchParam) {
|
||||
|
||||
@@ -14,15 +14,14 @@
|
||||
*/
|
||||
|
||||
import fileio from '@ohos.fileio'
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import { NoteHomeComp } from './NoteHome'
|
||||
import { NoteHomePortraitComp } from './NoteHomePortrait'
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
|
||||
import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import router from '@system.router';
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
import webview from '@ohos.web.webview';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@@ -30,7 +29,7 @@ export struct MyNoteHomeComp {
|
||||
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
|
||||
@Provide('PortraitModel') portraitModel: boolean = true
|
||||
@Provide('RefreshFlag') refreshFlag: number = 0
|
||||
private controllerShow: WebController = new WebController()
|
||||
private controllerShow: WebviewController = new webview.WebviewController()
|
||||
private context = getContext(this)
|
||||
TAG = "MyNoteHomeComp_Tablet"
|
||||
@StorageLink('breakPoint') @Watch('onBreakPointChange') breakPoints: string = 'lg'
|
||||
@@ -70,8 +69,25 @@ export struct MyNoteHomeComp {
|
||||
LogUtil.warn(this.TAG, "context is error")
|
||||
return
|
||||
}
|
||||
|
||||
let permissionList: Array<string> = [
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
]
|
||||
LogUtil.info(this.TAG, 'permissions need to require from user')
|
||||
let context: any = getContext(this);
|
||||
let AtManager = abilityAccessCtrl.createAtManager();
|
||||
//requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
|
||||
// @ts-ignore
|
||||
AtManager.requestPermissionsFromUser(context, ["ohos.permission.MANAGE_DISPOSED_APP_STATUS"]).then((data) => {
|
||||
LogUtil.info(this.TAG, 'data permissions : ' + data.permissions)
|
||||
LogUtil.info(this.TAG, 'data result: ' + data.authResults)
|
||||
let sum = 0
|
||||
for (let i = 0; i < data.authResults.length; i++) {
|
||||
sum += data.authResults[i]
|
||||
}
|
||||
LogUtil.info(this.TAG, 'request permissions sum: ' + sum)
|
||||
}).catch((err) => {
|
||||
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
|
||||
})
|
||||
let dbExist = false;
|
||||
let dbPath = context.databaseDir + "/db/note.db"
|
||||
try {
|
||||
|
||||
@@ -19,12 +19,13 @@ import { NoteContent } from '@ohos/component/src/main/ets/components/NoteContent
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
|
||||
import inputMethod from '@ohos.inputMethod'
|
||||
import webview from '@ohos.web.webview';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct NoteContentHome {
|
||||
@Provide('RefreshFlag') refreshFlag: number = 0
|
||||
private controllerShow: WebController = new WebController()
|
||||
private controllerShow: WebviewController = new webview.WebviewController()
|
||||
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
|
||||
@StorageLink('breakPoint') breakPoints: string = 'lg'
|
||||
TAG = "NoteContentHome_Tablet"
|
||||
@@ -47,12 +48,16 @@ struct NoteContentHome {
|
||||
}
|
||||
|
||||
onBackPress(): void {
|
||||
LogUtil.info(this.TAG, "onBackPress")
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
if (deviceInfo.deviceType !== 'phone' && deviceInfo.deviceType !== 'default') {
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
try {
|
||||
LogUtil.info(this.TAG, "onBackPress")
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)")
|
||||
this.controllerShow.runJavaScript("getHtmlContent()")
|
||||
if (deviceInfo.deviceType !== 'phone' && deviceInfo.deviceType !== 'default') {
|
||||
// @ts-ignore
|
||||
inputMethod.getController().stopInputSession();
|
||||
}
|
||||
} catch (error) {
|
||||
LogUtil.info(this.TAG, 'onBackPress error')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import { circleColorArray } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
import FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData'
|
||||
import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
|
||||
import { SysDefFolderUuid } from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'
|
||||
import LayoutUtil from '@ohos/utils/src/main/ets/default/baseUtil/LayoutUtil'
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
|
||||
import mediaquery from '@ohos.mediaquery'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@@ -45,7 +42,7 @@ export struct NoteHomeComp {
|
||||
@Provide('EditModel') editModel: boolean = false //编辑模式:临时方案
|
||||
@Provide('Issave') issave: number = 0
|
||||
@StorageLink('breakPoint') breakPoints: string = 'lg'
|
||||
controllerShow: WebController
|
||||
controllerShow: WebviewController
|
||||
TAG = "NoteHomeComp_Tablet"
|
||||
@Provide('AsideWidth') asideWidth: number = 200
|
||||
|
||||
|
||||
@@ -15,15 +15,11 @@
|
||||
|
||||
import { FolderListComp } from '@ohos/component/src/main/ets/components/FolderListComp'
|
||||
import { NoteListComp } from '@ohos/component/src/main/ets/components/NoteListComp'
|
||||
import { NoteContentCompPortrait } from '@ohos/component/src/main/ets/components/NoteContentCompPortrait'
|
||||
import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants'
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import { circleColorArray } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
import FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData'
|
||||
import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
|
||||
import { SysDefFolderUuid } from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'
|
||||
import LayoutUtil from '@ohos/utils/src/main/ets/default/baseUtil/LayoutUtil'
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
||||
Reference in New Issue
Block a user