From e01a17528a63d0f3b9d32e934714e3d0df0c8da5 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 12 Jul 2021 14:00:51 +0100 Subject: [PATCH] Mobile: Removed old editor code --- .../app-mobile/components/screens/Note.tsx | 95 ++++--------------- 1 file changed, 17 insertions(+), 78 deletions(-) diff --git a/packages/app-mobile/components/screens/Note.tsx b/packages/app-mobile/components/screens/Note.tsx index c132fbb38..7bf6d0fca 100644 --- a/packages/app-mobile/components/screens/Note.tsx +++ b/packages/app-mobile/components/screens/Note.tsx @@ -210,12 +210,6 @@ class NoteScreenComponent extends BaseScreenComponent { } }; - this.useBetaEditor = () => { - // Disable for now - return false; - // return Setting.value('editor.beta') && Platform.OS !== 'android'; - }; - this.takePhoto_onPress = this.takePhoto_onPress.bind(this); this.cameraView_onPhoto = this.cameraView_onPhoto.bind(this); this.cameraView_onCancel = this.cameraView_onCancel.bind(this); @@ -678,7 +672,7 @@ class NoteScreenComponent extends BaseScreenComponent { const newNote = Object.assign({}, this.state.note); - if (this.state.mode == 'edit' && !this.useBetaEditor() && !!this.selection) { + if (this.state.mode == 'edit' && !!this.selection) { const prefix = newNote.body.substring(0, this.selection.start); const suffix = newNote.body.substring(this.selection.end); newNote.body = `${prefix}\n${resourceTag}\n${suffix}`; @@ -1034,7 +1028,7 @@ class NoteScreenComponent extends BaseScreenComponent { const keywords = this.props.searchQuery && !!this.props.ftsEnabled ? this.props.highlightedWords : emptyArray; let bodyComponent = null; - if (this.state.mode == 'view' && !this.useBetaEditor()) { + if (this.state.mode == 'view') { // Note: as of 2018-12-29 it's important not to display the viewer if the note body is empty, // to avoid the HACK_webviewLoadingState related bug. bodyComponent = @@ -1057,76 +1051,21 @@ class NoteScreenComponent extends BaseScreenComponent { /> ); } else { - // bodyComponent = this.useBetaEditor() - // // Note: blurOnSubmit is necessary to get multiline to work. - // // See https://github.com/facebook/react-native/issues/12717#issuecomment-327001997 - // // - // // 2020-10-16: As of React Native 0.63, the Markdown Editor no longer crashes in Android, however the - // // cursor is still too unreliable to be usable, so we disable it in Android. - // ? this.body_changeText(text)} - // blurOnSubmit={false} - // selectionColor={theme.textSelectionColor} - // keyboardAppearance={theme.keyboardAppearance} - // placeholder={_('Add body')} - // placeholderTextColor={theme.colorFaded} - // noteBodyViewer={{ - // onJoplinLinkClick: this.onJoplinLinkClick_, - // style: this.styles().noteBodyViewerPreview, - // paddingBottom: 0, - // webViewStyle: theme, - // noteBody: note.body, - // noteMarkupLanguage: note.markup_language, - // noteResources: this.state.noteResources, - // highlightedKeywords: keywords, - // themeId: this.props.themeId, - // noteHash: this.props.noteHash, - // onCheckboxChange: this.onBodyViewerCheckboxChange, - // onMarkForDownload: this.onMarkForDownload, - // onLoadEnd: this.onBodyViewerLoadEnd, - // }} - - // /> - // : - // // Note: In theory ScrollView can be used to provide smoother scrolling of the TextInput. - // // However it causes memory or rendering issues on older Android devices, probably because - // // the whole text input has to be in memory for the scrollview to work. So we keep it as - // // a plain TextInput for now. - // // See https://github.com/laurent22/joplin/issues/3041 - - // // IMPORTANT: The TextInput selection is unreliable and cannot be used in a controlled component - // // context. In other words, the selection should be considered read-only. For example, if the seleciton - // // is saved to the state in onSelectionChange and the current text in onChangeText, then set - // // back in `selection` and `value` props, it will mostly work. But when typing fast, sooner or - // // later the real selection will be different from what is stored in the state, thus making - // // the cursor jump around. Eg, when typing "abcdef", it will do this: - // // abcd| - // // abcde| - // // abcde|f - // ( - // this.body_changeText(text)} - // onSelectionChange={this.body_selectionChange} - // blurOnSubmit={false} - // selectionColor={theme.textSelectionColor} - // keyboardAppearance={theme.keyboardAppearance} - // placeholder={_('Add body')} - // placeholderTextColor={theme.colorFaded} - // /> - // ); + // Note: In theory ScrollView can be used to provide smoother scrolling of the TextInput. + // However it causes memory or rendering issues on older Android devices, probably because + // the whole text input has to be in memory for the scrollview to work. So we keep it as + // a plain TextInput for now. + // See https://github.com/laurent22/joplin/issues/3041 + // IMPORTANT: The TextInput selection is unreliable and cannot be used in a controlled component + // context. In other words, the selection should be considered read-only. For example, if the seleciton + // is saved to the state in onSelectionChange and the current text in onChangeText, then set + // back in `selection` and `value` props, it will mostly work. But when typing fast, sooner or + // later the real selection will be different from what is stored in the state, thus making + // the cursor jump around. Eg, when typing "abcdef", it will do this: + // abcd| + // abcde| + // abcde|f bodyComponent = ( {titleComp} {bodyComponent} - {!this.useBetaEditor() && actionButtonComp} + {actionButtonComp}