1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Merge branch 'master' of github.com:laurent22/joplin

This commit is contained in:
Laurent Cozic 2020-03-06 23:45:14 +00:00
commit 6e0bb6cf8b
4 changed files with 45 additions and 7 deletions

View File

@ -281,6 +281,8 @@ class Application extends BaseApplication {
if (['NOTE_VISIBLE_PANES_TOGGLE', 'NOTE_VISIBLE_PANES_SET'].indexOf(action.type) >= 0) {
Setting.setValue('noteVisiblePanes', newState.noteVisiblePanes);
const layout = newState.noteVisiblePanes[0];
this.updateMenuItemStates(layout);
}
if (['SIDEBAR_VISIBILITY_TOGGLE', 'SIDEBAR_VISIBILITY_SET'].indexOf(action.type) >= 0) {
@ -292,7 +294,8 @@ class Application extends BaseApplication {
}
if (action.type.indexOf('NOTE_SELECT') === 0 || action.type.indexOf('FOLDER_SELECT') === 0) {
this.updateMenuItemStates(newState);
const layout = newState.noteVisiblePanes[0];
this.updateMenuItemStates(layout, newState);
}
if (['NOTE_DEVTOOLS_TOGGLE', 'NOTE_DEVTOOLS_SET'].indexOf(action.type) >= 0) {
@ -960,6 +963,7 @@ class Application extends BaseApplication {
});
},
}, {
id: 'view:toggleLayout',
label: _('Toggle editor layout'),
screens: ['Main'],
accelerator: 'CommandOrControl+L',
@ -1166,7 +1170,7 @@ class Application extends BaseApplication {
this.lastMenuScreen_ = screen;
}
async updateMenuItemStates(state = null) {
async updateMenuItemStates(layout, state = null) {
if (!this.lastMenuScreen_) return;
if (!this.store() && !state) return;
@ -1178,9 +1182,12 @@ class Application extends BaseApplication {
for (const itemId of ['copy', 'paste', 'cut', 'selectAll', 'bold', 'italic', 'link', 'code', 'insertDateTime', 'commandStartExternalEditing', 'showLocalSearch']) {
const menuItem = Menu.getApplicationMenu().getMenuItemById(`edit:${itemId}`);
if (!menuItem) continue;
menuItem.enabled = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN;
const isHtmlNote = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_HTML;
menuItem.enabled = !isHtmlNote && layout !== 'viewer' && !!note;
}
const toggleLayout = Menu.getApplicationMenu().getMenuItemById('view:toggleLayout');
toggleLayout.enabled = !!note;
const menuItem = Menu.getApplicationMenu().getMenuItemById('help:toggleDevTools');
menuItem.checked = state.devToolsVisible;
}

View File

@ -1504,12 +1504,29 @@ class NoteTextComponent extends React.Component {
this.scheduleSave();
}
toggleWrapSelection(strings1, strings2, defaultText) {
const selection = this.textOffsetSelection();
let string = this.state.note.body.substr(selection.start, selection.end - selection.start);
let replaced = false;
for (var i = 0; i < strings1.length; i++) {
if (string.startsWith(strings1[i]) && string.endsWith(strings1[i])) {
this.wrapSelectionWithStrings('', '', '', string.substr(strings1[i].length, selection.end - selection.start - (2 * strings1[i].length)));
replaced = true;
break;
}
}
if (!replaced) {
this.wrapSelectionWithStrings(strings1[0], strings2[0], defaultText);
}
}
commandTextBold() {
this.wrapSelectionWithStrings('**', '**', _('strong text'));
this.toggleWrapSelection(['**'], ['**'], _('strong text'));
}
commandTextItalic() {
this.wrapSelectionWithStrings('*', '*', _('emphasized text'));
this.toggleWrapSelection(['*', '_'], ['*', '_'], _('emphasized text'));
}
commandDateTime() {
@ -1525,9 +1542,13 @@ class NoteTextComponent extends React.Component {
if (match && match.length > 0) {
// Follow the same newline style
this.wrapSelectionWithStrings(`\`\`\`${match[0]}`, `${match[0]}\`\`\``);
if (string.startsWith('```') && string.endsWith('```')) {
this.wrapSelectionWithStrings('', '', '', string.substr(4, selection.end - selection.start - 8));
} else {
this.wrapSelectionWithStrings(`\`\`\`${match[0]}`, `${match[0]}\`\`\``);
}
} else {
this.wrapSelectionWithStrings('`', '`');
this.toggleWrapSelection(['`'], ['`'], '');
}
}

View File

@ -14,6 +14,7 @@ class TagListComponent extends React.Component {
style.borderBottom = `1px solid ${theme.dividerColor}`;
style.boxSizing = 'border-box';
style.fontSize = theme.fontSize;
style.whiteSpace = 'nowrap';
const tagItems = [];
if (tags && tags.length > 0) {

View File

@ -2,6 +2,8 @@ package net.cozic.joplin;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.webkit.WebView;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
@ -51,6 +53,13 @@ public class MainApplication extends Application implements ReactApplication {
public void onCreate() {
super.onCreate();
// Enable debugging with the WebView we use to display notes
// Changes are made as recommended by folks at `react-native-webview`
// https://github.com/react-native-community/react-native-webview/blob/master/docs/Debugging.md
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
// To try to fix the error "Row too big to fit into CursorWindow"
// https://github.com/andpor/react-native-sqlite-storage/issues/364#issuecomment-526423153
// https://github.com/laurent22/joplin/issues/1767#issuecomment-515617991