Merge pull request #3676 from jrao1/allow-labels-when-adding-notes-via-clipper

Allow arbitrary labels to be added via web clipper
This commit is contained in:
zadam 2023-03-07 22:53:11 +01:00 committed by GitHub
commit ef90f1ff3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,7 +75,7 @@ function addClipping(req) {
}
function createNote(req) {
let {title, content, pageUrl, images, clipType} = req.body;
let {title, content, pageUrl, images, clipType, labels} = req.body;
if (!title || !title.trim()) {
title = `Clipped note from ${pageUrl}`;
@ -101,6 +101,13 @@ function createNote(req) {
note.setLabel('iconClass', 'bx bx-globe');
}
if (labels) {
for (const labelName in labels) {
const labelValue = htmlSanitizer.sanitize(labels[labelName]);
note.setLabel(labelName, labelValue);
}
}
const rewrittenContent = processContent(images, note, content);
note.setContent(rewrittenContent);