Merge remote-tracking branch 'origin/stable'

This commit is contained in:
zadam
2020-09-30 22:50:33 +02:00
41 changed files with 2438 additions and 2843 deletions

View File

@@ -373,6 +373,7 @@ class Note extends Entity {
return false;
}
// FIXME: this code is quite questionable, one problem is that other caches (TreeCache, NoteCache) have nothing like that
if (attr.isDefinition()) {
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);

View File

@@ -205,7 +205,16 @@ class NoteShort {
}
}
noteAttributeCache.attributes[this.noteId] = attrArrs.flat();
noteAttributeCache.attributes[this.noteId] = [];
const addedAttributeIds = new Set();
for (const attr of attrArrs.flat()) {
if (!addedAttributeIds.has(attr.attributeId)) {
addedAttributeIds.add(attr.attributeId);
noteAttributeCache.attributes[this.noteId].push(attr);
}
}
}
return noteAttributeCache.attributes[this.noteId];

View File

@@ -85,7 +85,9 @@ function goToLink(e) {
}
}
else {
if (e.which === 1) {
if ((e.which === 1 && e.ctrlKey) || e.which === 2
|| $link.hasClass("ck-link-actions__preview") // within edit link dialog single click suffices
) {
const address = $link.attr('href');
if (address && address.startsWith('http')) {

View File

@@ -34,6 +34,10 @@ const TPL = `
cursor: pointer;
}
.note-detail-editable-text a[href^="http://"], .note-detail-editable-text a[href^="https://"] {
cursor: text !important;
}
.note-detail-editable-text h1 { font-size: 2.0em; }
.note-detail-editable-text h2 { font-size: 1.8em; }
.note-detail-editable-text h3 { font-size: 1.6em; }

View File

@@ -852,9 +852,12 @@ ul.fancytree-container li {
contain: layout paint;
}
/** ckeditor's autocomplete */
/**
ckeditor's autocomplete
should be higher than 1070 of tooltip
*/
.ck.ck-balloon-panel {
z-index: 10001;
z-index: 1101;
}
.area-expander {

View File

@@ -249,7 +249,7 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* @method
* @deprecated please use createNewNote() API method instead
* @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs
*
* @param {string} parentNoteId - create new note under this parent
* @param {string} title
@@ -276,7 +276,7 @@ function BackendScriptApi(currentNote, apiParams) {
extraOptions.content = content;
}
sql.transactional(() => {
return sql.transactional(() => {
const {note, branch} = noteService.createNewNote(extraOptions);
for (const attr of extraOptions.attributes || []) {

View File

@@ -92,7 +92,18 @@ class Note {
}
}
this.attributeCache = parentAttributes.concat(templateAttributes);
this.attributeCache = [];
const addedAttributeIds = new Set();
for (const attr of parentAttributes.concat(templateAttributes)) {
if (!addedAttributeIds.has(attr.attributeId)) {
addedAttributeIds.add(attr.attributeId);
this.attributeCache.push(attr);
}
}
this.inheritableAttributeCache = [];
for (const attr of this.attributeCache) {

View File

@@ -106,6 +106,10 @@ function buildRewardMap(note) {
addToRewardMap(attr.name, reward);
}
if (attr.name === 'cliptype') {
reward /= 2;
}
let value = attr.value;
if (value.startsWith('http')) {

View File

@@ -123,6 +123,7 @@ function highlightSearchResults(searchResults, highlightedTokens) {
// we remove < signs because they can cause trouble in matching and overwriting existing highlighted chunks
// which would make the resulting HTML string invalid.
// { and } are used for marking <b> and </b> tag (to avoid matches on single 'b' character)
// < and > are used for marking <small> and </small>
highlightedTokens = highlightedTokens.map(token => token.replace('/[<\{\}]/g', ''));
// sort by the longest so we first highlight longest matches
@@ -131,19 +132,19 @@ function highlightSearchResults(searchResults, highlightedTokens) {
for (const result of searchResults) {
const note = noteCache.notes[result.noteId];
result.highlightedNotePathTitle = result.notePathTitle;
result.highlightedNotePathTitle = result.notePathTitle.replace('/[<\{\}]/g', '');
if (highlightedTokens.find(token => note.type.includes(token))) {
result.highlightedNotePathTitle += ` <small>type: ${note.type}</small>`;
result.highlightedNotePathTitle += ` <type: ${note.type}>`;
}
if (highlightedTokens.find(token => note.mime.includes(token))) {
result.highlightedNotePathTitle += ` <small>mime: ${note.mime}</small>`;
result.highlightedNotePathTitle += ` <mime: ${note.mime}>`;
}
for (const attr of note.attributes) {
if (highlightedTokens.find(token => attr.name.includes(token) || attr.value.includes(token))) {
result.highlightedNotePathTitle += ` <small>${formatAttribute(attr)}</small>`;
result.highlightedNotePathTitle += ` <${formatAttribute(attr)}>`;
}
}
}
@@ -158,6 +159,8 @@ function highlightSearchResults(searchResults, highlightedTokens) {
for (const result of searchResults) {
result.highlightedNotePathTitle = result.highlightedNotePathTitle
.replace(/</g, "<small>")
.replace(/>/g, "</small>")
.replace(/{/g, "<b>")
.replace(/}/g, "</b>");
}