mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix #clipperInbox, closes #4153
This commit is contained in:
parent
a9cdd93cb4
commit
1d869d25c2
@ -17,21 +17,20 @@ const jsdom = require("jsdom");
|
||||
const { JSDOM } = jsdom;
|
||||
|
||||
function addClipping(req) {
|
||||
// if a note under the clipperInbox as the same 'pageUrl' attribute,
|
||||
// if a note under the clipperInbox has the same 'pageUrl' attribute,
|
||||
// add the content to that note and clone it under today's inbox
|
||||
// otherwise just create a new note under today's inbox
|
||||
let {title, content, pageUrl, images} = req.body;
|
||||
const clipType = 'clippings';
|
||||
|
||||
const clipperInbox = getClipperInboxNote();
|
||||
const dailyNote = dateNoteService.getDayNote(dateUtils.localNowDate());
|
||||
|
||||
pageUrl = htmlSanitizer.sanitizeUrl(pageUrl);
|
||||
let clippingNote = findClippingNote(clipperInbox, pageUrl, clipType);
|
||||
|
||||
if (!clippingNote) {
|
||||
clippingNote = noteService.createNewNote({
|
||||
parentNoteId: dailyNote.noteId,
|
||||
parentNoteId: clipperInbox.noteId,
|
||||
title: title,
|
||||
content: '',
|
||||
type: 'text'
|
||||
@ -48,8 +47,8 @@ function addClipping(req) {
|
||||
|
||||
clippingNote.setContent(`${existingContent}${existingContent.trim() ? "<br>" : ""}${rewrittenContent}`);
|
||||
|
||||
if (clippingNote.parentNoteId !== dailyNote.noteId) {
|
||||
cloneService.cloneNoteToParentNote(clippingNote.noteId, dailyNote.noteId);
|
||||
if (clippingNote.parentNoteId !== clipperInbox.noteId) {
|
||||
cloneService.cloneNoteToParentNote(clippingNote.noteId, clipperInbox.noteId);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -79,7 +78,7 @@ function getClipperInboxNote() {
|
||||
let clipperInbox = attributeService.getNoteWithLabel('clipperInbox');
|
||||
|
||||
if (!clipperInbox) {
|
||||
clipperInbox = dateNoteService.getRootCalendarNote();
|
||||
clipperInbox = dateNoteService.getDayNote(dateUtils.localNowDate());
|
||||
}
|
||||
|
||||
return clipperInbox;
|
||||
|
@ -65,6 +65,7 @@ module.exports = [
|
||||
{ type: 'label', name: 'executeButton'},
|
||||
{ type: 'label', name: 'executeDescription'},
|
||||
{ type: 'label', name: 'newNotesOnTop'},
|
||||
{ type: 'label', name: 'clipperInbox'},
|
||||
|
||||
// relation names
|
||||
{ type: 'relation', name: 'internalLink' },
|
||||
|
Loading…
x
Reference in New Issue
Block a user