fix saving note

This commit is contained in:
ammarahm-ed
2021-02-05 10:15:16 +05:00
parent cdf38bf5bf
commit 046b832620
8 changed files with 56 additions and 13 deletions

View File

@@ -71,7 +71,10 @@ export default class NotesnookShare extends Component {
let add = async () => {
await db.notes.add({
title: this.state.title,
content: `<${tag}>${this.state.text}<${tag}/>`,
content: {
type:'tiny',
data:`<${tag}>${this.state.text}<${tag}/>`
},
id: null,
});
};

View File

@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />

View File

@@ -12,6 +12,8 @@ function reactNativeEventHandler(type, value) {
}
let changeTimer = null;
let isLoading = true;
function init_tiny(size) {
tinymce.init({
selector: '#tiny_textarea',
@@ -46,7 +48,12 @@ function init_tiny(size) {
reactNativeEventHandler('status', true);
editor.on('SelectionChange', function (e) {
clearTimeout(changeTimer);
if (isLoading) {
isLoading = false;
return;
}
changeTimer = setTimeout(() => {
if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -60,7 +67,13 @@ function init_tiny(size) {
});
editor.on('Change', function (e) {
clearTimeout(changeTimer);
if (isLoading) {
isLoading = false;
return;
}
changeTimer = setTimeout(() => {
if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -70,7 +83,7 @@ function init_tiny(size) {
}, 5);
});
editor.on('ExecCommand', function (e) {
reactNativeEventHandler(e);
//reactNativeEventHandler(e);
});
},
});

View File

@@ -12,6 +12,8 @@ function reactNativeEventHandler(type, value) {
}
let changeTimer = null;
let isLoading = true;
function init_tiny(size) {
tinymce.init({
selector: '#tiny_textarea',
@@ -46,7 +48,12 @@ function init_tiny(size) {
reactNativeEventHandler('status', true);
editor.on('SelectionChange', function (e) {
clearTimeout(changeTimer);
if (isLoading) {
isLoading = false;
return;
}
changeTimer = setTimeout(() => {
if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -60,7 +67,13 @@ function init_tiny(size) {
});
editor.on('Change', function (e) {
clearTimeout(changeTimer);
if (isLoading) {
isLoading = false;
return;
}
changeTimer = setTimeout(() => {
if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -70,7 +83,7 @@ function init_tiny(size) {
}, 5);
});
editor.on('ExecCommand', function (e) {
reactNativeEventHandler(e);
//reactNativeEventHandler(e);
});
},
});

View File

@@ -549,7 +549,7 @@ export const ActionSheetComponent = ({
{note.type === 'notebook' && note.description
? note.description
: null}
{note.type === 'note'
{note.type === 'note' && item.headline
? note.headline[item.headline.length - 1] === '\n'
? note.headline.slice(0, note.headline.length - 1)
: note.headline

View File

@@ -128,11 +128,13 @@ export default class NoteItem extends React.Component {
{item.title.replace('\n', '')}
</Heading>
{item.headline && (
<Paragraph numberOfLines={2}>
{item.headline[item.headline.length - 1] === '\n'
? item.headline.slice(0, item.headline.length - 1)
: item.headline}
</Paragraph>
)}
<View
style={{

View File

@@ -238,8 +238,12 @@ export const _onMessage = async (evt) => {
case 'history':
eSendEvent('historyEvent', message.value);
break;
case 'change':
content = message;
case 'tiny':
console.log('change',message);
content = {
type:message.type,
data:message.value
};
onNoteChange();
break;
case 'title':
@@ -299,6 +303,7 @@ function onNoteChange() {
}
export async function clearEditor() {
tiny.call(EditorWebView,tiny.isLoading);
clearTimer();
tiny.call(EditorWebView, tiny.reset);
if (noteEdited && id) {
@@ -386,6 +391,8 @@ export async function saveNote() {
return;
}
let locked = id ? db.notes.note(id).data.locked : null;
console.log(content,"SAVE Content");
let noteData = {
title,
content: {

View File

@@ -103,7 +103,12 @@ const updateTheme = (value) => `
`;
const isLoading =`
isLoading = true;
`;
const html = (value) => `
isLoading = true;
editor.setContent("${value}");
info.querySelector('#infowords').innerText =
editor.plugins.wordcount.getCount() + " words";
@@ -151,5 +156,6 @@ export default {
updateSavingState,
updateTheme,
setTitle,
restoreRange
restoreRange,
isLoading
};