A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix note loading in editor
ammarahm-edbe777a68d002
diff --git a/apps/mobile/html/Web.bundle/site/constants.js b/apps/mobile/html/Web.bundle/site/constants.jsindex 59f3ba6fd..911134bb8 100755--- a/apps/mobile/html/Web.bundle/site/constants.js+++ b/apps/mobile/html/Web.bundle/site/constants.js@@ -120,6 +120,7 @@ function setTheme() {light();}addStyle();+let css = document.createElement('style');css.type = 'text/css';@@ -364,7 +365,7 @@ code {}`;-+ if (!tinymce.activeEditor) return;let editorHead =tinymce.activeEditor.contentDocument.getElementsByTagName('head')[0];let css2 = document.createElement('style');diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.htmlindex 436fb719f..657628116 100644--- a/apps/mobile/html/Web.bundle/site/index.html+++ b/apps/mobile/html/Web.bundle/site/index.html@@ -32,6 +32,7 @@let editor = null;let isLoading = true;let regex = /\n/gm;+ let sessionId = null;</script><script src="./compressor.min.js"></script><script src="./listeners.js"></script>@@ -40,7 +41,6 @@<script src="./init.js"></script><script>attachMessageListener()- init_tiny("calc(100vh - 55px)");</script></body>diff --git a/apps/mobile/html/Web.bundle/site/init.js b/apps/mobile/html/Web.bundle/site/init.jsindex 83692caa7..51b4770e2 100755--- a/apps/mobile/html/Web.bundle/site/init.js+++ b/apps/mobile/html/Web.bundle/site/init.js@@ -2,10 +2,12 @@ attachTitleInputListeners();autosize();function reactNativeEventHandler(type, value) {if (window.ReactNativeWebView) {+ console.log('type', type, 'id:', sessionId);window.ReactNativeWebView.postMessage(JSON.stringify({type: type,- value: value+ value: value,+ sessionId: sessionId}));}@@ -59,8 +61,9 @@ const collapsibleTags = {HR: 1, H2: 2, H3: 3, H4: 4, H5: 5, H6: 6};let styleElement;function addStyle() {+ if (!tinymce.activeEditor) return;if (!styleElement) {- let doc = editor.dom.doc;+ let doc = tinymce.activeEditor.dom.doc;styleElement = doc.head.appendChild(document.createElement('style'));}styleElement.innerHTML = `@@ -112,14 +115,212 @@ function onUndoChange() {clearTimeout(undoTimer);undoTimer = setTimeout(function () {reactNativeEventHandler('history', {- undo: editor.undoManager.hasUndo(),- redo: editor.undoManager.hasRedo()+ undo: tinymce.activeEditor.undoManager.hasUndo(),+ redo: tinymce.activeEditor.undoManager.hasRedo()});}, 1000);}+function init_callback(_editor) {+ editor = _editor;+ console.log('init_call',editor);+ setTheme();++ editor.on('SelectionChange', function (e) {+ selectchange();+ });++ editor.on('ClearUndos', onUndoChange);+ editor.on('Undo', onUndoChange);+ editor.on('Redo', onUndoChange);+ editor.on('TypingUndos', onUndoChange);+ editor.on('BeforeAddUndo', onUndoChange);+ editor.on('AddUndo', onUndoChange);+ editor.on('cut', function () {+ onChange({type: 'cut'});+ onUndoChange();+ });+ editor.on('copy', onUndoChange);+ editor.on('paste', function () {+ onChange({type: 'paste'});+ });++ editor.on('focus', function () {+ reactNativeEventHandler('focus', 'editor');+ });++ editor.on('SetContent', function (event) {+ if (globalThis.isClearingNoteData) {+ globalThis.isClearingNoteData = false;+ return;+ }+ setTimeout(function () {+ editor.undoManager.transact(function () {});+ }, 1000);+ if (!event.paste) {+ reactNativeEventHandler('noteLoaded', true);+ }+ });++ editor.on('NewBlock', function (e) {+ console.log('New Block');+ const {newBlock} = e;+ let target;+ if (newBlock) {+ target = newBlock.previousElementSibling;+ }+ if (target && target.classList.contains(COLLAPSED_KEY)) {+ target.classList.remove(COLLAPSED_KEY);+ collapseElement(target);+ }+ });++ editor.on('touchstart mousedown', function (e) {+ const {target} = e;+ if (+ e.offsetX < 6 &&+ collapsibleTags[target.tagName] &&+ target.parentElement &&+ target.parentElement.tagName === 'BODY'+ ) {+ e.preventDefault();+ e.stopImmediatePropagation();+ e.stopPropagation();+ editor.undoManager.transact(function () {+ if (target.classList.contains(COLLAPSED_KEY)) {+ target.classList.remove(COLLAPSED_KEY);+ } else {+ target.classList.add(COLLAPSED_KEY);+ }+ collapseElement(target);+ editor.getHTML().then(function (html) {+ reactNativeEventHandler('tiny', html);+ });+ });+ }+ });++ editor.on('tap', function (e) {+ if (+ e.target.classList.contains('mce-content-body') &&+ !e.target.innerText.length > 0+ ) {+ e.preventDefault();+ }+ });+ editor.on('ScrollIntoView', function (e) {+ e.preventDefault();+ e.elm.scrollIntoView({+ behavior: 'smooth',+ block: 'nearest'+ });+ });+ editor.on('input', onChange);+ editor.on('keyup', onChange);+ editor.on('NodeChange', onChange);+ editor.on('compositionend', onChange);+}++const plugins = [+ 'checklist advlist autolink textpattern hr lists link noneditable image',+ 'searchreplace codeblock inlinecode keyboardquirks attachmentshandler',+ 'media imagetools table paste wordcount autoresize directionality blockescape contenthandler'+];++const content_style = `+body: {+ font-family:"Open Sans";+}+.mce-content-body h2::before,+h3::before,+h4::before,+h5::before,+h6::before {+ font-size: 11px;+ font-weight: normal;+ letter-spacing: 1.1px;+ padding: 1px 3px 1px 3px;+ margin-left: -12px;+ margin-right: 5px;+ cursor: row-resize;+ margin-top:-3px;+ vertical-align:middle;+ }++ .mce-content-body h2::before {+ content: "H2";+ }++ .mce-content-body h3::before {+ content: "H3";+ }++ .mce-content-body h4::before {+ content: "H4";+ }++ .mce-content-body h5::before {+ content: "H5";+ }++ .h {+ display: none;+ }+span.diff-del {+ background-color: #FDB0C0;+}+span.diff-ins {+ background-color: #CAFFFB;+}+pre.codeblock {+ overflow-x:auto;+}+img {+ max-width:100% !important;+ height:auto !important;+ border-radius:5px !important;+}+.tox .tox-edit-area__iframe {+ background-color:transparent !important;+}++.tox .tox-tbtn--select {+ min-width: 120px;+}++body {+ background-color:transparent !important;+ font-size:${DEFAULT_FONT_SIZE}+}+iframe {+ max-width:100% !important;+ background-color:transparent !important;+}+table {+ display: block !important;+ overflow-x: auto !important;+ white-space: nowrap !important;+ max-width:100% !important;+ width:100% !important;+ height:auto !important;+}+td {+ min-width:10vw !important;+}+h1,+h2,+h3,+h4,+h5,+h6,+strong {+ font-weight:600 !important;+}+`;+function init_tiny(size) {loadFontSize();+ console.log('init tinymce');tinymce.init({selector: '#tiny_textarea',menubar: false,@@ -130,13 +331,10 @@ function init_tiny(size) {attachmenthandler_download_attachment: hash => {reactNativeEventHandler('attachment_download', hash);},- plugins: [- 'checklist advlist autolink textpattern hr lists link noneditable image',- 'searchreplace codeblock inlinecode keyboardquirks attachmentshandler',- 'media imagetools table paste wordcount autoresize directionality blockescape contenthandler'- ],+ custom_undo_redo_levels : 10,+ plugins: plugins,toolbar: false,- keep_styles:false,+ keep_styles: false,paste_data_images: true,statusbar: false,textpattern_patterns: markdownPatterns,@@ -145,96 +343,7 @@ function init_tiny(size) {invalid_styles: {span: `--progress`},- content_style: `- body: {- font-family:"Open Sans";- }- .mce-content-body h2::before,- h3::before,- h4::before,- h5::before,- h6::before {- font-size: 11px;- font-weight: normal;- letter-spacing: 1.1px;- padding: 1px 3px 1px 3px;- margin-left: -12px;- margin-right: 5px;- cursor: row-resize;- margin-top:-3px;- vertical-align:middle;- }-- .mce-content-body h2::before {- content: "H2";- }-- .mce-content-body h3::before {- content: "H3";- }-- .mce-content-body h4::before {- content: "H4";- }-- .mce-content-body h5::before {- content: "H5";- }-- .h {- display: none;- }- span.diff-del {- background-color: #FDB0C0;- }- span.diff-ins {- background-color: #CAFFFB;- }- pre.codeblock {- overflow-x:auto;- }- img {- max-width:100% !important;- height:auto !important;- border-radius:5px !important;- }- .tox .tox-edit-area__iframe {- background-color:transparent !important;- }-- .tox .tox-tbtn--select {- min-width: 120px;- }-- body {- background-color:transparent !important;- font-size:${DEFAULT_FONT_SIZE}- }- iframe {- max-width:100% !important;- background-color:transparent !important;- }- table {- display: block !important;- overflow-x: auto !important;- white-space: nowrap !important;- max-width:100% !important;- width:100% !important;- height:auto !important;- }- td {- min-width:10vw !important;- }- h1,- h2,- h3,- h4,- h5,- h6,- strong {- font-weight:600 !important;- }-`,+ content_style: content_style,browser_spellcheck: true,autoresize_bottom_margin: 120,table_toolbar:@@ -264,206 +373,112 @@ function init_tiny(size) {console.error(e);}},- init_instance_callback: function (_editor) {- editor = _editor;- setTheme();-- editor.on('SelectionChange', function (e) {- selectchange();- });-- editor.on('ClearUndos', onUndoChange);- editor.on('Undo', onUndoChange);- editor.on('Redo', onUndoChange);- editor.on('TypingUndos', onUndoChange);- editor.on('BeforeAddUndo', onUndoChange);- editor.on('AddUndo', onUndoChange);- editor.on('cut', function () {- onChange({type: 'cut'});- onUndoChange();- });- editor.on('copy', onUndoChange);- editor.on('paste', function () {- onChange({type: 'paste'});- });-- editor.on('focus', function () {- reactNativeEventHandler('focus', 'editor');- });+ init_instance_callback: init_callback,+ setup: setup_tiny+ });+}- editor.on('SetContent', function (event) {- if (globalThis.isClearingNoteData) {- globalThis.isClearingNoteData = false;- return;- }- setTimeout(function () {- editor.undoManager.transact(function () {});- }, 1000);- if (!event.paste) {- reactNativeEventHandler('noteLoaded', true);- }+function setup_tiny(_editor) {+ editor = _editor;+ editor.ui.registry.addButton('deleteimage', {+ icon: 'remove',+ tooltip: 'Remove image',+ onAction: function () {+ editor.undoManager.transact(function () {+ tinymce.activeEditor.execCommand('Delete');});-- editor.on('NewBlock', function (e) {- console.log('New Block');- const {newBlock} = e;- let target;- if (newBlock) {- target = newBlock.previousElementSibling;- }- if (target && target.classList.contains(COLLAPSED_KEY)) {- target.classList.remove(COLLAPSED_KEY);- collapseElement(target);- }+ },+ onclick: function () {+ editor.undoManager.transact(function () {+ tinymce.activeEditor.execCommand('Delete');});+ }+ });- editor.on('touchstart mousedown', function (e) {- const {target} = e;- if (- e.offsetX < 6 &&- collapsibleTags[target.tagName] &&- target.parentElement &&- target.parentElement.tagName === 'BODY'- ) {- e.preventDefault();- e.stopImmediatePropagation();- e.stopPropagation();- editor.undoManager.transact(function () {- if (target.classList.contains(COLLAPSED_KEY)) {- target.classList.remove(COLLAPSED_KEY);- } else {- target.classList.add(COLLAPSED_KEY);- }- collapseElement(target);- editor.getHTML().then(function (html) {- reactNativeEventHandler('tiny', html);- });- });- }- });+ editor.on('init', function (e) {+ reactNativeEventHandler('status', true);+ });- editor.on('tap', function (e) {- if (- e.target.classList.contains('mce-content-body') &&- !e.target.innerText.length > 0- ) {- e.preventDefault();- }- });- editor.on('ScrollIntoView', function (e) {- e.preventDefault();- e.elm.scrollIntoView({- behavior: 'smooth',- block: 'nearest'- });+ editor.ui.registry.addButton('deletevideo', {+ icon: 'remove',+ tooltip: 'Remove iframe',+ onAction: function () {+ editor.undoManager.transact(function () {+ tinymce.activeEditor.execCommand('Delete');});- editor.on('input', onChange);- editor.on('keyup', onChange);- editor.on('NodeChange', onChange);- editor.on('compositionend', onChange);},- setup: function (_editor) {- editor = _editor;- editor.ui.registry.addButton('deleteimage', {- icon: 'remove',- tooltip: 'Remove image',- onAction: function () {- editor.undoManager.transact(function () {- tinymce.activeEditor.execCommand('Delete');- });- },- onclick: function () {- editor.undoManager.transact(function () {- tinymce.activeEditor.execCommand('Delete');- });- }- });-- editor.on('init', function (e) {- reactNativeEventHandler('status', true);- });-- editor.ui.registry.addButton('deletevideo', {- icon: 'remove',- tooltip: 'Remove iframe',- onAction: function () {- editor.undoManager.transact(function () {- tinymce.activeEditor.execCommand('Delete');- });- },- onclick: function () {- editor.undoManager.transact(function () {- tinymce.activeEditor.execCommand('Delete');- });- }+ onclick: function () {+ editor.undoManager.transact(function () {+ tinymce.activeEditor.execCommand('Delete');});+ }+ });- editor.ui.registry.addContextToolbar('iframecontrols', {- predicate: function (node) {- return node.getAttribute('data-mce-object') === 'iframe';- },- items: 'deletevideo',- position: 'node',- scope: 'node'- });+ editor.ui.registry.addContextToolbar('iframecontrols', {+ predicate: function (node) {+ return node.getAttribute('data-mce-object') === 'iframe';+ },+ items: 'deletevideo',+ position: 'node',+ scope: 'node'+ });- editor.ui.registry.addButton('imageopts', {- icon: 'image-options',- tooltip: 'Image properties',- onAction: function () {- reactNativeEventHandler('imageoptions');- },- onclick: function () {- reactNativeEventHandler('imageoptions');- }- });+ editor.ui.registry.addButton('imageopts', {+ icon: 'image-options',+ tooltip: 'Image properties',+ onAction: function () {+ reactNativeEventHandler('imageoptions');+ },+ onclick: function () {+ reactNativeEventHandler('imageoptions');+ }+ });- editor.ui.registry.addButton('imagedownload', {- icon: 'save',- tooltip: 'Download image',- onAction: function () {- let node = tinymce.activeEditor.selection.getNode();- if (node.tagName === 'IMG' && node.dataset && node.dataset.hash) {- window.ReactNativeWebView.postMessage(- JSON.stringify({- type: 'attachment_download',- value: node.dataset.hash- })- );- }- },- onclick: function () {}- });+ editor.ui.registry.addButton('imagedownload', {+ icon: 'save',+ tooltip: 'Download image',+ onAction: function () {+ let node = tinymce.activeEditor.selection.getNode();+ if (node.tagName === 'IMG' && node.dataset && node.dataset.hash) {+ window.ReactNativeWebView.postMessage(+ JSON.stringify({+ type: 'attachment_download',+ value: node.dataset.hash,+ sessionId: sessionId+ })+ );+ }+ },+ onclick: function () {}+ });- editor.ui.registry.addButton('imagepreview', {- icon: 'fullscreen',- tooltip: 'Preview image',- onAction: function () {- if (tinymce.activeEditor.selection.getNode().tagName === 'IMG') {- var xhr = new XMLHttpRequest();- xhr.responseType = 'blob';-- xhr.onload = function () {- var recoveredBlob = xhr.response;- var reader = new FileReader();- reader.onload = function () {- var blobAsDataUrl = reader.result;- reactNativeEventHandler('imagepreview', blobAsDataUrl);- reader.abort();- xhr.abort();- };- reader.readAsDataURL(recoveredBlob);- };- xhr.open(- 'GET',- tinymce.activeEditor.selection.getNode().getAttribute('src')- );- xhr.send();- }- },- onclick: function () {}- });- }+ editor.ui.registry.addButton('imagepreview', {+ icon: 'fullscreen',+ tooltip: 'Preview image',+ onAction: function () {+ if (tinymce.activeEditor.selection.getNode().tagName === 'IMG') {+ var xhr = new XMLHttpRequest();+ xhr.responseType = 'blob';++ xhr.onload = function () {+ var recoveredBlob = xhr.response;+ var reader = new FileReader();+ reader.onload = function () {+ var blobAsDataUrl = reader.result;+ reactNativeEventHandler('imagepreview', blobAsDataUrl);+ reader.abort();+ xhr.abort();+ };+ reader.readAsDataURL(recoveredBlob);+ };+ xhr.open(+ 'GET',+ tinymce.activeEditor.selection.getNode().getAttribute('src')+ );+ xhr.send();+ }+ },+ onclick: function () {}});}diff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.jsindex 6a792ece0..da5ed04e2 100755--- a/apps/mobile/html/Web.bundle/site/listeners.js+++ b/apps/mobile/html/Web.bundle/site/listeners.js@@ -16,7 +16,8 @@ function onDomContentLoaded() {JSON.stringify({visible: event.target.documentElement.scrollTop,title: document.getElementById('titleInput').value,- type: 'scroll'+ type: 'scroll',+ sessionId:sessionId}));@@ -46,7 +47,8 @@ function attachTitleInputListeners() {window.ReactNativeWebView.postMessage(JSON.stringify({type: 'focus',- value: 'title'+ value: 'title',+ sessionId:sessionId}));}@@ -70,7 +72,8 @@ function onTitleChange() {}let titleMessage = {type: 'title',- value: titleInput.value+ value: titleInput.value,+ sessionId:sessionId};info = document.querySelector(infoBar);@@ -143,6 +146,7 @@ function attachMessageListener() {let message = JSON.parse(data.data);let type = message.type;let value = message.value;+ sessionId = message.sessionId;switch (type) {case 'inject':diff --git a/apps/mobile/src/components/NoteItem/wrapper.js b/apps/mobile/src/components/NoteItem/wrapper.jsindex 3c22d2b69..876921ff0 100644--- a/apps/mobile/src/components/NoteItem/wrapper.js+++ b/apps/mobile/src/components/NoteItem/wrapper.js@@ -5,10 +5,11 @@ import { useSelectionStore, useTrashStore } from '../../provider/stores';import { DDS } from '../../services/DeviceDetection';import { eSendEvent, openVault, ToastEvent } from '../../services/EventManager';import Navigation from '../../services/Navigation';-import { history } from '../../utils';+import { editing, history } from '../../utils';import { db } from '../../utils/database';import { eOnLoadNote, eShowMergeDialog } from '../../utils/Events';import { tabBarRef } from '../../utils/Refs';+import { sleep } from '../../utils/TimeUtils';import { presentDialog } from '../Dialog/functions';import SelectionWrapper from '../SelectionWrapper';@@ -17,7 +18,13 @@ export const NoteWrapper = React.memo(({item, index,tags,compactMode}) => {const setSelectedItem = useSelectionStore(state => state.setSelectedItem);const onPress = async () => {-+ // let diff = !editing.lastClosedTime ? 0 : (editing.lastClosedTime + 800) - Date.now();+ // console.log('diff:',diff);+ // if (diff > 0) {+ // console.log('sleeping');+ // await sleep(diff + 10);+ // }+let _note = item;if (!isTrash) {_note = db.notes.note(item.id).data;diff --git a/apps/mobile/src/navigation/RootView.js b/apps/mobile/src/navigation/RootView.jsindex 91be70371..b950784cb 100644--- a/apps/mobile/src/navigation/RootView.js+++ b/apps/mobile/src/navigation/RootView.js@@ -46,6 +46,10 @@ const onChangeTab = async obj => {!editing.isRestoringState &&(!editing.currentlyEditing || !getNote())) {+ if (editing.overlay) {+ editing.overlay = false;+ return;+ }eSendEvent(eOnLoadNote, {type: 'new'});editing.currentlyEditing = true;}diff --git a/apps/mobile/src/provider/interfaces.ts b/apps/mobile/src/provider/interfaces.tsindex 8742cfbbd..03fc1d8e1 100644--- a/apps/mobile/src/provider/interfaces.ts+++ b/apps/mobile/src/provider/interfaces.ts@@ -113,6 +113,8 @@ export interface MenuStore extends State {export interface EditorStore extends State {currentEditingNote: string | null,setCurrentlyEditingNote: (note: string) => void,+ sessionId:string,+ setSessionId:(sessionId:string) => void}diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/provider/stores.tsindex ea1320f3c..5cea00161 100644--- a/apps/mobile/src/provider/stores.ts+++ b/apps/mobile/src/provider/stores.ts@@ -275,7 +275,12 @@ export const useMenuStore = create<MenuStore>((set, get) => ({export const useEditorStore = create<EditorStore>((set, get) => ({currentEditingNote: null,- setCurrentlyEditingNote: note => set({currentEditingNote: note})+ setCurrentlyEditingNote: note => set({currentEditingNote: note}),+ sessionId:null,+ setSessionId:(sessionId) => {+ console.log(sessionId,'session id');+ set({sessionId});+ }}));export const useSearchStore = create<SearchStore>((set, get) => ({diff --git a/apps/mobile/src/utils/Colors.js b/apps/mobile/src/utils/Colors.jsindex 9a7b6fe7a..c66a8ec86 100644--- a/apps/mobile/src/utils/Colors.js+++ b/apps/mobile/src/utils/Colors.js@@ -62,6 +62,7 @@ export const COLOR_SCHEME_LIGHT = {pri: '#505050',sec: '#ffffff',light: '#ffffff',+ transGray: '#00000010',};export const COLOR_SCHEME_DARK = {...fixedColors,@@ -74,6 +75,7 @@ export const COLOR_SCHEME_DARK = {pri: '#C0C0C0',sec: 'black',light: '#ffffff',+ transGray: '#ffffff10',};export function getCurrentColors() {diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.jsindex 560ffcbfd..dbac84807 100644--- a/apps/mobile/src/views/Editor/EditorHeader.js+++ b/apps/mobile/src/views/Editor/EditorHeader.js@@ -65,44 +65,55 @@ const EditorHeader = () => {const insets = useSafeAreaInsets();const handleBack = useRef();const keyboardListener = useRef();+ const closing = useRef(false);useEffect(() => {setColors(colors);}, [colors]);const _onBackPress = async () => {- if (deviceMode !== 'mobile' && fullscreen) {- eSendEvent(eCloseFullscreenEditor);- return;- }+ editing.lastClosedTime = Date.now();if (deviceMode === 'mobile') {- editing.movedAway = true;- }- eSendEvent('showTooltip');- toolbarRef.current?.scrollTo({- x: 0,- y: 0,- animated: false- });- editing.isFocused = false;- editing.currentlyEditing = false;- if (deviceMode !== 'mobile') {- if (fullscreen) {+ startClosingSession();+ };+ setTimeout(async () => {+ closing.current = true;+ if (deviceMode !== 'mobile' && fullscreen) {eSendEvent(eCloseFullscreenEditor);+ return;}- } else {- startClosingSession();if (deviceMode === 'mobile') {- tabBarRef.current?.goToPage(0);+ editing.movedAway = true;}- eSendEvent('historyEvent', {- undo: 0,- redo: 0+ eSendEvent('showTooltip');+ toolbarRef.current?.scrollTo({+ x: 0,+ y: 0,+ animated: false});- useEditorStore.getState().setCurrentlyEditingNote(null);- await clearEditor(true, true, false);- keyboardListener.current?.remove();- }+ editing.isFocused = false;+ editing.currentlyEditing = false;+ editing.focusType = null;+ safeKeyboardDismiss();+ if (deviceMode !== 'mobile') {+ if (fullscreen) {+ eSendEvent(eCloseFullscreenEditor);+ }+ } else {+ startClosingSession();+ if (deviceMode === 'mobile') {+ tabBarRef.current?.goToPage(0);+ }+ eSendEvent('historyEvent', {+ undo: 0,+ redo: 0+ });+ useEditorStore.getState().setCurrentlyEditingNote(null);+ keyboardListener.current?.remove();+ await clearEditor(true, true, true);+ }+ closing.current = false;+ }, 1);};const publishNote = async () => {@@ -211,6 +222,7 @@ const EditorHeader = () => {}, [fullscreen]);const load = async item => {+ console.log(item.id);await loadNote(item);InteractionManager.runAfterInteractions(() => {keyboardListener.current = Keyboard.addListener(@@ -297,7 +309,7 @@ const EditorHeader = () => {}}/>)}- {fullscreen? <View style={{width: 20}} /> : null}+ {fullscreen ? <View style={{width: 20}} /> : null}{deviceMode !== 'mobile' ? <EditorTitle /> : null}</View><View@@ -316,11 +328,6 @@ const EditorHeader = () => {}}top={50}onPress={async () => {- let note = getNote();- clearEditor(true, true, true);- await loadNote(note);-- return;if (editing.isFocused) {safeKeyboardDismiss();editing.isFocused = true;diff --git a/apps/mobile/src/views/Editor/EditorOverlay.js b/apps/mobile/src/views/Editor/EditorOverlay.jsindex 840c1a95a..09e4a1ba5 100644--- a/apps/mobile/src/views/Editor/EditorOverlay.js+++ b/apps/mobile/src/views/Editor/EditorOverlay.js@@ -10,6 +10,8 @@ import {eSubscribeEvent,eUnSubscribeEvent} from '../../services/EventManager';+import {editing} from '../../utils';+import {eOnLoadNote} from '../../utils/Events';import {SIZE} from '../../utils/SizeUtils';import {sleep, timeConverter} from '../../utils/TimeUtils';@@ -24,6 +26,7 @@ const EditorOverlay = () => {const opacity = useValue(1);const load = async _loading => {+ editing.overlay = true;clearTimeout(timer);clearTimeout(timerError);clearTimeout(timerClosing);@@ -31,6 +34,12 @@ const EditorOverlay = () => {opacity.setValue(1);setLoading(_loading);timerError = setTimeout(() => {+ if (_loading) {+ console.log('could not load');+ let _n = _loading;+ _n.forced = true;+ eSendEvent(eOnLoadNote, _n);+ }setError(true);}, 4000);} else {@@ -38,6 +47,7 @@ const EditorOverlay = () => {clearTimeout(timerError);clearTimeout(timerClosing);setError(false);+ editing.overlay = false;timing(opacity, {toValue: 0,duration: 150,@@ -74,7 +84,7 @@ const EditorOverlay = () => {],zIndex: 100}}>- <View+ <Animated.Viewstyle={{width: '90%',justifyContent: 'center',@@ -119,7 +129,7 @@ const EditorOverlay = () => {{timeConverter(loading.dateEdited)}</Paragraph>) : null}- </View>+ </Animated.View>{error && (<Viewdiff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.jsindex ac9acd091..b5e1e53dc 100644--- a/apps/mobile/src/views/Editor/EditorWrapper.js+++ b/apps/mobile/src/views/Editor/EditorWrapper.js@@ -1,19 +1,26 @@-import React, { useEffect } from 'react';-import { KeyboardAvoidingView, Platform, SafeAreaView, View } from 'react-native';-import { PanGestureHandler, State } from 'react-native-gesture-handler';-import Animated, { Easing } from 'react-native-reanimated';-import { useSafeAreaInsets } from 'react-native-safe-area-context';+import React, {useEffect} from 'react';+import {+ KeyboardAvoidingView,+ Platform,+ SafeAreaView,+ TextInput,+ View+} from 'react-native';+import {PanGestureHandler, State} from 'react-native-gesture-handler';+import Animated, {Easing} from 'react-native-reanimated';+import {useSafeAreaInsets} from 'react-native-safe-area-context';import Editor from '.';-import { GetPremium } from '../../components/ActionSheetComponent/GetPremium';+import {GetPremium} from '../../components/ActionSheetComponent/GetPremium';import Paragraph from '../../components/Typography/Paragraph';-import { useTracked } from '../../provider';-import { useNoteStore, useSettingStore } from '../../provider/stores';-import { DDS } from '../../services/DeviceDetection';-import { eSendEvent } from '../../services/EventManager';-import { eOnLoadNote } from '../../utils/Events';-import { editorRef } from '../../utils/Refs';+import {useTracked} from '../../provider';+import {useNoteStore, useSettingStore} from '../../provider/stores';+import {DDS} from '../../services/DeviceDetection';+import {eSendEvent} from '../../services/EventManager';+import {eOnLoadNote} from '../../utils/Events';+import {editorRef} from '../../utils/Refs';import useIsFloatingKeyboard from '../../utils/use-is-floating-keyboard';import EditorOverlay from './EditorOverlay';+import {textInput} from './Functions';let prevVal = 0;let finalValue = 80;let anim2 = new Animated.Value(0);@@ -21,7 +28,7 @@ const op1 = new Animated.Value(1);const op2 = new Animated.Value(0);const op3 = new Animated.Value(0);-const onHandlerStateChange = (evt) => {+const onHandlerStateChange = evt => {console.log('handler here');if (evt.nativeEvent.state === State.END) {if (evt.nativeEvent.translationY >= finalValue) {@@ -42,8 +49,8 @@ const onHandlerStateChange = (evt) => {}};-const onGestureEvent = (event) => {- console.log('gesture event');+const onGestureEvent = event => {+ console.log('gesture event');if (event.nativeEvent.translationY < 0) return;let v = event.nativeEvent.translationY;@@ -63,7 +70,7 @@ function animation(a) {Animated.timing(anim2, {toValue: a,duration: 150,- easing: Easing.inOut(Easing.ease),+ easing: Easing.inOut(Easing.ease)}).start();}@@ -71,34 +78,32 @@ function opacityAnim(a, b, c) {Animated.timing(op1, {toValue: a,duration: 50,- easing: Easing.inOut(Easing.ease),+ easing: Easing.inOut(Easing.ease)}).start();Animated.timing(op2, {toValue: b,duration: 300,- easing: Easing.inOut(Easing.ease),+ easing: Easing.inOut(Easing.ease)}).start();Animated.timing(op3, {toValue: c,duration: 300,- easing: Easing.inOut(Easing.ease),+ easing: Easing.inOut(Easing.ease)}).start();}-const AnimatedKeyboardView = Animated.createAnimatedComponent(- KeyboardAvoidingView,-);+const AnimatedKeyboardView =+ Animated.createAnimatedComponent(KeyboardAvoidingView);-export const EditorWrapper = ({width,dimensions}) => {+export const EditorWrapper = ({width, dimensions}) => {const [state] = useTracked();const {colors} = state;- const deviceMode = useSettingStore(state => state.deviceMode)+ const deviceMode = useSettingStore(state => state.deviceMode);const loading = useNoteStore(state => state.loading);const insets = useSafeAreaInsets();const floating = useIsFloatingKeyboard();-return (<Viewref={editorRef}@@ -107,12 +112,12 @@ export const EditorWrapper = ({width,dimensions}) => {height: '100%',backgroundColor: state.colors.bg,borderLeftWidth: 1,- borderLeftColor: DDS.isTab ? colors.nav : 'transparent',+ borderLeftColor: DDS.isTab ? colors.nav : 'transparent'}}><SafeAreaViewstyle={{width: '100%',- height: '100%',+ height: '100%'}}><GetPremium context="editor" offset={50 + insets.top} /><View@@ -122,12 +127,11 @@ export const EditorWrapper = ({width,dimensions}) => {height: insets.top,top: 0,width: dimensions.width,- backgroundColor: colors.bg,+ backgroundColor: colors.bg}}/><PanGestureHandlerminPointers={2}-onHandlerStateChange={onHandlerStateChange}onGestureEvent={onGestureEvent}><AnimatedKeyboardView@@ -136,11 +140,11 @@ export const EditorWrapper = ({width,dimensions}) => {style={{transform: [{- translateY: anim2,- },+ translateY: anim2+ }],height: '100%',- width: '100%',+ width: '100%'}}><Viewstyle={{@@ -153,15 +157,15 @@ export const EditorWrapper = ({width,dimensions}) => {zIndex: 10,transform: [{- translateY: Platform.OS === 'ios' ? -80 : -80 + insets.top,- },- ],+ translateY: Platform.OS === 'ios' ? -80 : -80 + insets.top+ }+ ]}}><Animated.Textstyle={{position: 'absolute',opacity: op1,- bottom: 10,+ bottom: 10}}><Paragraph color="white">Keep swiping down to start a new note.@@ -171,7 +175,7 @@ export const EditorWrapper = ({width,dimensions}) => {<Animated.Textstyle={{position: 'absolute',- opacity: op3,+ opacity: op3}}><Paragraph color="white">Release to load new note</Paragraph></Animated.Text>@@ -179,12 +183,16 @@ export const EditorWrapper = ({width,dimensions}) => {<Animated.Textstyle={{position: 'absolute',- opacity: op2,+ opacity: op2}}><Paragraph color="white">Loading a new note</Paragraph></Animated.Text></View>-+ <TextInput+ ref={textInput}+ style={{height: 1, padding: 0, width: 1, position: 'absolute'}}+ blurOnSubmit={false}+ />{loading ? null : <Editor />}<EditorOverlay /></AnimatedKeyboardView>diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.jsindex aab40c4b9..21cc101ef 100644--- a/apps/mobile/src/views/Editor/Functions.js+++ b/apps/mobile/src/views/Editor/Functions.js@@ -59,6 +59,7 @@ let isSaving = false;let waitForContent = false;let prevNoteContent = null;let timerForEditor = null;+let sessionId = null;export function startClosingSession() {closingSession = true;@@ -124,7 +125,6 @@ export async function clearTimer(clear) {content.data?.trim().length > 0) ||(title && title?.trim().length > 0)) {- console.log('saving note after edit');await saveNote(true);}}@@ -139,6 +139,7 @@ export const CHECK_STATUS = `(function() {let msg = JSON.stringify({data: true,type: 'running',+ sessionId:sessionId});window.ReactNativeWebView.postMessage(msg)})();`;@@ -150,7 +151,8 @@ const request_content = `(function() {JSON.stringify({type: 'tiny',value:html,- caller:"request_content"+ caller:"request_content",+ sessionId:sessionId}));})@@ -170,10 +172,10 @@ export const textInput = createRef();export function post(type, value = null) {let message = {type,- value+ value,+ sessionId: sessionId};if (type === 'html') {- console.log('message type', type);}EditorWebView.current?.postMessage(JSON.stringify(message));@@ -223,7 +225,6 @@ function clearNote() {note = null;title = '';noteEdited = false;- console.log('closing note id', id);prevNoteContent = content.data;id = null;content = {@@ -231,36 +232,62 @@ function clearNote() {type: 'tiny'};}+function randId(prefix) {+ return Math.random()+ .toString(36)+ .replace('0.', prefix || '');+}++function makeSessionId(item) {+ sessionId = item?.id ? item.id + randId('_session_') : randId('session_');+}+let loading_queue;+let loading_note = false;export const loadNote = async item => {- console.log('.....OPEN NOTE.....');+ console.log('loading_note', loading_note);+ if (loading_note && id) {+ loading_queue = item;+ check_session_status();+ return;+ } else {+ loading_queue = null;+ }++ loading_note = true;+editing.currentlyEditing = true;editing.movedAway = false;if (closingSession) {eSendEvent('loadingNote', item);- console.log('waiting item');await waitForEvent('session_ended');- console.log('session ended');}+closingSession = true;if (editing.isFocused) {tiny.call(EditorWebView, tiny.blur);}-if (item && item.type === 'new') {if (getNote()) {+ eSendEvent('loadingNote', item);await clearEditor(true, true, true);}+ eSendEvent('loadingNote');closingSession = false;disableSaving = false;lastEditTime = 0;clearNote();noteEdited = false;+ loading_queue = null;+ makeSessionId(item);+ useEditorStore.getState().setSessionId(sessionId);if (Platform.OS === 'android') {- await sleep(300);- textInput.current?.focus();EditorWebView.current?.requestFocus();- tiny.call(EditorWebView, tiny.focusEditor);+ setTimeout(() => {+ textInput.current?.focus();+ EditorWebView.current?.requestFocus();+ tiny.call(EditorWebView, tiny.focusEditor);+ }, 150);} else {await sleep(150);tiny.call(EditorWebView, tiny.focusEditor);@@ -273,8 +300,10 @@ export const loadNote = async item => {: `tinymce.activeEditor.execCommand('mceDirectionLTR');`);}+ updateSessionStatus();- if (!webviewInit) {+ if (!(await checkStatus(true))) {+ console.log('reload editor');EditorWebView.current?.reload();}@@ -282,30 +311,42 @@ export const loadNote = async item => {checkStatus();} else {if (id === item.id && !item.forced) {- console.log('return from here duhh.');return;}eSendEvent('loadingNote', item);if (getNote()) {- console.log('clearing');- await clearEditor(true, false, true);+ await clearEditor(true, true, true);}- console.log('done clearing');+closingSession = false;disableSaving = false;noteEdited = false;await setNote(item);webviewInit = false;editing.isFocused = false;- console.log('opening note');+ if (+ loading_queue &&+ (loading_queue?.id !== item?.id || loading_queue?.type === 'new')+ ) {+ clearNote();+ loading_note = false;+ loadNote(loading_queue);++ return;+ }+ makeSessionId(item);+ useEditorStore.getState().setSessionId(sessionId);setTimeout(async () => {requestedReload = true;- EditorWebView.current?.reload();+ if (await checkStatus(true)) {+ updateSessionStatus();+ } else {+ EditorWebView.current?.reload();+ }}, 1);- setTimeout(() => {- useEditorStore.getState().setCurrentlyEditingNote(item.id);- }, 300);+ useEditorStore.getState().setCurrentlyEditingNote(item.id);}+ loading_note = false;};const checkStatus = async noreset => {@@ -330,9 +371,7 @@ const checkStatus = async noreset => {);webviewTimer = setTimeout(() => {- console.log('timeout has ended');if (!webviewOK && !noreset) {- console.log('webview not ok', 'ERROR');webviewInit = false;EditorWebView = createRef();eSendEvent('webviewreset');@@ -342,6 +381,44 @@ const checkStatus = async noreset => {});};+function updateSessionStatus() {+ tiny.call(+ EditorWebView,+ `(function() {+ sessionId = "${sessionId}";+ let msg = JSON.stringify({+ data: true,+ type: 'status',+ sessionId:sessionId+ });+ window.ReactNativeWebView.postMessage(msg)+})();`+ );+}++function check_session_status() {+ tiny.call(+ EditorWebView,+ `(function() {+ if (window.ReactNativeWebView) {+ if (!editor) {+ return;+ }+ editor.getHTML().then(function(value) {+ let status = value === '' || value === '<p></p>' || value === '<p><br></p>' || value === '<p> </p>';+ window.ReactNativeWebView.postMessage(+ JSON.stringify({+ type: 'content_not_loaded',+ value:status,+ sessionId:sessionId+ })+ );+ })+ }+ })();`+ );+}+export const _onMessage = async evt => {if (!evt || !evt.nativeEvent || !evt.nativeEvent.data) return;let message = evt.nativeEvent.data;@@ -351,11 +428,13 @@ export const _onMessage = async evt => {} catch (e) {return;}+switch (message.type) {case 'history':eSendEvent('historyEvent', message.value);break;case 'tiny':+ if (message.sessionId !== sessionId) return;if (message.value === '<br>') return;if (message.value !== content.data) {if (prevNoteContent && message.value === prevNoteContent) {@@ -377,6 +456,7 @@ export const _onMessage = async evt => {}break;case 'title':+ if (message.sessionId !== sessionId) return;if (message.value !== title) {noteEdited = true;lastEditTime = Date.now();@@ -395,9 +475,7 @@ export const _onMessage = async evt => {break;case 'noteLoaded':tiny.call(EditorWebView, tiny.notLoading);- setTimeout(() => {- eSendEvent('loadingNote');- }, 150);+ eSendEvent('loadingNote');break;case 'premium':let user = await db.user.getUser();@@ -413,18 +491,52 @@ export const _onMessage = async evt => {}break;case 'status':- if (!requestedReload && getNote()) return;+ if (sessionId !== message.sessionId) {+ if (!sessionId) makeSessionId({id});+ updateSessionStatus();+ return;+ }++ if (!requestedReload && getNote()) {+ check_session_status();+ return;+ }requestedReload = false;setColors(COLOR_SCHEME);eSendEvent('webviewOk');+ loading_note = false;webviewInit = true;webviewOK = true;- if (PremiumService.get()) {- tiny.call(EditorWebView, tiny.setMarkdown, true);- } else {- tiny.call(EditorWebView, tiny.removeMarkdown, true);+ setTimeout(() => {+ if (PremiumService.get()) {+ tiny.call(EditorWebView, tiny.setMarkdown, true);+ } else {+ tiny.call(EditorWebView, tiny.removeMarkdown, true);+ }+ }, 300);+ await loadNoteInEditor();+ setTimeout(() => {+ check_session_status();+ }, 1500);+ break;+ case 'content_not_loaded':+ loading_note = false;+ if (message.sessionId !== sessionId) {+ updateSessionStatus();+ return;+ }+ if (!id) {+ console.log('no note loaded',id);+ return;+ }+ console.log('content not loaded');+ if (message.value) {+ console.log('reloading');+ await loadNoteInEditor();+ setTimeout(() => {+ check_session_status();+ }, 1500);}- loadNoteInEditor();break;case 'running':eSendEvent('webviewOk');@@ -479,11 +591,8 @@ export async function clearEditor(closingSession = true;tiny.call(EditorWebView, tiny.isLoading);if (clear) {- console.log('clearing content start');waitForContent = true;-await clearTimer(true);- console.log('clearing content end');}disableSaving = true;db.fs.cancel(getNote()?.id);@@ -495,7 +604,11 @@ export async function clearEditor(let func = async () => {try {reset && EditorWebView.current?.reload();-+ // if (DDS.isTab) {+ // await waitForEvent('webviewOk');+ // } else {+ // await sleep(1000);+ // }editing.focusType = null;eSendEvent('historyEvent', {undo: 0,@@ -503,16 +616,14 @@ export async function clearEditor(});saveCounter = 0;useEditorStore.getState().setCurrentlyEditingNote(null);- } catch (e) {- console.log('reset error', e);- }+ } catch (e) {}};if (immediate) {await func();} else {cTimeout = setTimeout(func, 500);}- console.log('closing ended');+eSendEvent('session_ended');closingSession = false;}@@ -644,22 +755,19 @@ export async function saveNote(preventUpdate) {);tiny.call(EditorWebView, tiny.updateSavingState(!n ? '' : 'Saved'));}- } catch (e) {- console.log('note save error', e, e.stack);- }+ } catch (e) {}isSaving = false;}export async function onWebViewLoad(premium, colors) {- if (premium) {- tiny.call(EditorWebView, tiny.setMarkdown, true);- } else {- tiny.call(EditorWebView, tiny.removeMarkdown, true);- }+ setTimeout(() => {+ if (premium) {+ tiny.call(EditorWebView, tiny.setMarkdown, true);+ } else {+ tiny.call(EditorWebView, tiny.removeMarkdown, true);+ }+ }, 300);- if (getNote()?.id) {- loadNoteInEditor();- }setColors(colors);}@@ -707,49 +815,46 @@ export const presentResolveConflictDialog = _note => {};const loadNoteInEditor = async (keepHistory = true) => {- clearTimeout(timerForEditor);- timerForEditor = setTimeout(async () => {- if (!webviewInit) return;-- console.log('loading note', id, webviewInit);- if (note?.id) {- post('title', title);- intent = false;- if (!content || !content.data || content?.data?.length === 0) {- tiny.call(- EditorWebView,- `+ if (!webviewInit) return;+ if (note?.id) {+ post('title', title);+ intent = false;+ if (!content || !content.data || content?.data?.length === 0) {+ tiny.call(+ EditorWebView,+ `+ sessionId = "${sessionId}"globalThis.isClearingNoteData = false;window.ReactNativeWebView.postMessage(JSON.stringify({type: 'noteLoaded',value: true,+ sessionId:sessionId}),);`- );- } else {- post('html', content.data);- }- if (id) {- db.attachments.downloadImages(id);- }-- setColors();- tiny.call(- EditorWebView,- tiny.updateDateEdited(timeConverter(note.dateEdited)));- tiny.call(EditorWebView, tiny.updateSavingState('Saved'));} else {- await restoreEditorState();+ post('html', content.data);}- loadingNote = null;- disableSaving = false;- if (keepHistory) {- tiny.call(EditorWebView, tiny.clearHistory);+ if (id) {+ db.attachments.downloadImages(id);}- }, 50);++ setColors();+ tiny.call(+ EditorWebView,+ tiny.updateDateEdited(timeConverter(note.dateEdited))+ );+ tiny.call(EditorWebView, tiny.updateSavingState('Saved'));+ } else {+ await restoreEditorState();+ }+ loadingNote = null;+ disableSaving = false;+ if (keepHistory) {+ tiny.call(EditorWebView, tiny.clearHistory);+ }};export async function updateNoteInEditor() {@@ -765,7 +870,6 @@ export async function updateNoteInEditor() {if (content.data.indexOf(data.data) !== -1) return;if (note.dateEdited === _note.dateEdited) return;- console.log('injecting note in editor', lastEditTime, _note.dateEdited);title = note.title;content.data = data.data;note = _note;diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.jsindex f58988dd5..2073d0cfb 100755--- a/apps/mobile/src/views/Editor/index.js+++ b/apps/mobile/src/views/Editor/index.js@@ -2,13 +2,14 @@ import React, {useEffect, useState} from 'react';import {Platform, ScrollView, TextInput, View} from 'react-native';import WebView from 'react-native-webview';import {notesnook} from '../../../e2e/test.ids';-import {useUserStore} from '../../provider/stores';+import {useEditorStore, useUserStore} from '../../provider/stores';import {eSendEvent,eSubscribeEvent,eUnSubscribeEvent} from '../../services/EventManager';import {getCurrentColors} from '../../utils/Colors';+import { eOnLoadNote } from '../../utils/Events';import {normalize} from '../../utils/SizeUtils';import {sleep} from '../../utils/TimeUtils';import EditorHeader from './EditorHeader';@@ -39,11 +40,12 @@ const CustomView = Platform.OS === 'ios' ? ScrollView : View;const Editor = React.memo(() => {const premiumUser = useUserStore(state => state.premium);-+ const sessionId = useEditorStore(state => state.sessionId);const [resetting, setResetting] = useState(false);const onLoad = async () => {await onWebViewLoad(premiumUser, getCurrentColors());};+ console.log(sessionId, 'updated id');useEffect(() => {if (premiumUser) {@@ -55,6 +57,7 @@ const Editor = React.memo(setResetting(true);await sleep(30);setResetting(false);+ eSendEvent(eOnLoadNote, getNote() ? getNote() : {type: 'new'});if (!getNote()) {await sleep(10);eSendEvent('loadingNote', null);@@ -70,12 +73,6 @@ const Editor = React.memo(return resetting ? null : (<>- <TextInput- ref={textInput}- style={{height: 1, padding: 0, width: 1, position: 'absolute'}}- blurOnSubmit={false}- />-<CustomViewstyle={{height: '100%',@@ -103,6 +100,22 @@ const Editor = React.memo(onRenderProcessGone={event => {onResetRequested();}}+ injectedJavaScript={`+ sessionId="${sessionId}";+ console.log(sessionId);+ (function() {+ const func = function() {+ setTimeout(function() {+ if (tinymce) {+ init_tiny("calc(100vh - 55px)");+ } else {+ console.log('tinymce is not ready');+ func();+ }+ },10);+ }+ func();+ })();`}javaScriptEnabled={true}focusable={true}keyboardDisplayRequiresUserAction={false}@@ -113,11 +126,13 @@ const Editor = React.memo(bounces={false}allowFileAccess={true}scalesPageToFit={true}+ renderLoading={() => <View/>}+ startInLoadingStateallowingReadAccessToURL={Platform.OS === 'android' ? true : null}allowFileAccessFromFileURLs={true}allowUniversalAccessFromFileURLs={true}originWhitelist={['*']}- source={source}+ source={{uri: "http://192.168.10.6:3000/index.html"}}style={style}autoManageStatusBarEnabled={false}onMessage={_onMessage}@@ -131,3 +146,7 @@ const Editor = React.memo();export default Editor;++// test uri "http://192.168.10.8:3000/index.html"++diff --git a/apps/mobile/src/views/Editor/tiny/tiny.js b/apps/mobile/src/views/Editor/tiny/tiny.jsindex a3222e41d..96b194870 100644--- a/apps/mobile/src/views/Editor/tiny/tiny.js+++ b/apps/mobile/src/views/Editor/tiny/tiny.js@@ -20,11 +20,14 @@ window.blur();`;const removeMarkdown = `- tinymce.activeEditor.plugins.textpattern.setPatterns("")-`;+if (tinymce && tinymce.activeEditor) {+ tinymce.activeEditor.plugins.textpattern.setPatterns("")+}`;+const setMarkdown = `- tinymce.activeEditor.plugins.textpattern.setPatterns(markdownPatterns)-`;+if (tinymce && tinymce.activeEditor) {+ tinymce.activeEditor.plugins.textpattern.setPatterns(markdownPatterns);+}`;const keyboardStateChanged = `(function() {setTimeout(function() {@@ -138,8 +141,13 @@ export const nomenu = enabled => `const updateTheme = value => `(function() {let v = ${value}- pageTheme.colors = v;- setTheme();+ if (pageTheme) {+ pageTheme.colors = v;+ }+ if (tinymce && tinymce.activeEditor) {+ setTheme();+ }+})();`;