mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: When deleting note, display title or number of notes
This commit is contained in:
parent
b6ba843d09
commit
efcf5ecef4
@ -9,8 +9,9 @@ const eventManager = require('../../eventManager');
|
||||
const InteropService = require('lib/services/InteropService');
|
||||
const InteropServiceHelper = require('../../InteropServiceHelper.js');
|
||||
const Search = require('lib/models/Search');
|
||||
const Note = require('lib/models/Note');
|
||||
const SearchEngine = require('lib/services/SearchEngine');
|
||||
const { replaceRegexDiacritics, pregQuote } = require('lib/string-utils');
|
||||
const { replaceRegexDiacritics, pregQuote, substrWithEllipsis } = require('lib/string-utils');
|
||||
|
||||
class NoteListUtils {
|
||||
|
||||
@ -116,7 +117,17 @@ class NoteListUtils {
|
||||
|
||||
static async confirmDeleteNotes(noteIds) {
|
||||
if (!noteIds.length) return;
|
||||
const ok = bridge().showConfirmMessageBox(noteIds.length > 1 ? _('Delete notes?') : _('Delete note?'));
|
||||
|
||||
let msg = '';
|
||||
if (noteIds.length === 1) {
|
||||
const note = await Note.load(noteIds[0]);
|
||||
if (!note) return;
|
||||
msg = _('Delete note "%s"?', substrWithEllipsis(note.title, 0, 32));
|
||||
} else {
|
||||
msg = _('Delete these %d notes?', noteIds.length);
|
||||
}
|
||||
|
||||
const ok = bridge().showConfirmMessageBox(msg);
|
||||
if (!ok) return;
|
||||
await Note.batchDelete(noteIds);
|
||||
}
|
||||
|
@ -253,6 +253,11 @@ function surroundKeywords(keywords, text, prefix, suffix) {
|
||||
return text.replace(re, prefix + '$1' + suffix);
|
||||
}
|
||||
|
||||
function substrWithEllipsis(s, start, length) {
|
||||
if (s.length <= length) return s;
|
||||
return s.substr(start, length - 3) + '...';
|
||||
}
|
||||
|
||||
const REGEX_JAPANESE = /[\u3000-\u303f]|[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff00-\uff9f]|[\u4e00-\u9faf]|[\u3400-\u4dbf]/;
|
||||
const REGEX_CHINESE = /[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]|[\uf900-\ufaff]|[\u{2f800}-\u{2fa1f}]/u;
|
||||
const REGEX_KOREAN = /[\uac00-\ud7af]|[\u1100-\u11ff]|[\u3130-\u318f]|[\ua960-\ua97f]|[\ud7b0-\ud7ff]/;
|
||||
@ -265,6 +270,6 @@ function scriptType(s) {
|
||||
}
|
||||
|
||||
module.exports = Object.assign(
|
||||
{ removeDiacritics, escapeFilename, wrap, splitCommandString, padLeft, toTitleCase, urlDecode, escapeHtml, surroundKeywords, scriptType, commandArgumentsToString },
|
||||
{ removeDiacritics, substrWithEllipsis, escapeFilename, wrap, splitCommandString, padLeft, toTitleCase, urlDecode, escapeHtml, surroundKeywords, scriptType, commandArgumentsToString },
|
||||
stringUtilsCommon,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user