mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
implemented "rawContent", #1637
This commit is contained in:
parent
50bcf45113
commit
66c5606d46
@ -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 notes
|
||||
content = striptags(content);
|
||||
}
|
||||
|
||||
|
@ -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 notes
|
||||
content = striptags(content);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user