1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Mobile: Removed old editor code

This commit is contained in:
Laurent Cozic 2021-07-12 14:00:51 +01:00
parent b929a44bd5
commit e01a17528a

View File

@ -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.
// ? <MarkdownEditor
// ref={this.markdownEditorRef} // For focusing the Markdown editor
// editorFont={editorFont(this.props.editorFont)}
// style={this.styles().bodyTextInput}
// previewStyles={this.styles().noteBodyViewer}
// value={note.body}
// borderColor={this.styles().markdownButtons.borderColor}
// markdownButtonsColor={this.styles().markdownButtons.color}
// saveText={(text:string) => 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
// (
// <TextInput
// autoCapitalize="sentences"
// style={this.styles().bodyTextInput}
// ref="noteBodyTextField"
// multiline={true}
// value={note.body}
// onChangeText={(text:string) => 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 = (
<TextInput
autoCapitalize="sentences"
@ -1218,7 +1157,7 @@ class NoteScreenComponent extends BaseScreenComponent {
/>
{titleComp}
{bodyComponent}
{!this.useBetaEditor() && actionButtonComp}
{actionButtonComp}
<SelectDateTimeDialog themeId={this.props.themeId} shown={this.state.alarmDialogShown} date={dueDate} onAccept={this.onAlarmDialogAccept} onReject={this.onAlarmDialogReject} />