Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
implemented "rawContent", #1637
zadam66c5606d4640
diff --git a/src/services/search/expressions/note_content_protected_fulltext.js b/src/services/search/expressions/note_content_protected_fulltext.jsindex 0ed21eb158..c66645865f 100644--- a/src/services/search/expressions/note_content_protected_fulltext.js+++ b/src/services/search/expressions/note_content_protected_fulltext.js@@ -8,7 +8,7 @@ const protectedSessionService = require('../../protected_session');const striptags = require('striptags');class NoteContentProtectedFulltextExp extends Expression {- constructor(operator, tokens) {+ constructor(operator, tokens, raw) {super();if (operator !== '*=*') {@@ -16,6 +16,7 @@ class NoteContentProtectedFulltextExp extends Expression {}this.tokens = tokens;+ this.raw = !!raw;}execute(inputNoteSet) {@@ -47,7 +48,7 @@ class NoteContentProtectedFulltextExp extends Expression {content = content.toLowerCase();if (type === 'text' && mime === 'text/html') {- if (content.length < 20000) { // striptags is slow for very large notes+ if (!this.raw && content.length < 20000) { // striptags is slow for very large notescontent = striptags(content);}diff --git a/src/services/search/expressions/note_content_unprotected_fulltext.js b/src/services/search/expressions/note_content_unprotected_fulltext.jsindex a9a531269c..aace6a115c 100644--- a/src/services/search/expressions/note_content_unprotected_fulltext.js+++ b/src/services/search/expressions/note_content_unprotected_fulltext.js@@ -6,7 +6,7 @@ const noteCache = require('../../note_cache/note_cache');const striptags = require('striptags');class NoteContentUnprotectedFulltextExp extends Expression {- constructor(operator, tokens) {+ constructor(operator, tokens, raw) {super();if (operator !== '*=*') {@@ -14,6 +14,7 @@ class NoteContentUnprotectedFulltextExp extends Expression {}this.tokens = tokens;+ this.raw = !!raw;}execute(inputNoteSet) {@@ -33,7 +34,7 @@ class NoteContentUnprotectedFulltextExp extends Expression {content = content.toString().toLowerCase();if (type === 'text' && mime === 'text/html') {- if (content.length < 20000) { // striptags is slow for very large notes+ if (!this.raw && content.length < 20000) { // striptags is slow for very large notescontent = striptags(content);}diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.jsindex fa1b3cc344..d6961d618f 100644--- a/src/services/search/services/parse.js+++ b/src/services/search/services/parse.js@@ -125,7 +125,9 @@ function getExpression(tokens, searchContext, level = 0) {i++;- if (tokens[i].token === 'content') {+ if (['content', 'rawcontent'].includes(tokens[i].token)) {+ const raw = tokens[i].token === 'rawcontent';+i += 1;const operator = tokens[i].token;@@ -138,8 +140,8 @@ function getExpression(tokens, searchContext, level = 0) {i++;return new OrExp([- new NoteContentUnprotectedFulltextExp(operator, [tokens[i].token]),- new NoteContentProtectedFulltextExp(operator, [tokens[i].token])+ new NoteContentUnprotectedFulltextExp(operator, [tokens[i].token], raw),+ new NoteContentProtectedFulltextExp(operator, [tokens[i].token], raw)]);}