mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 01:36:24 +01:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25ce2e4253 | ||
|
|
c27f573eed | ||
|
|
1d99c4e80b | ||
|
|
dc7c64a94d | ||
|
|
dc6a530d8c | ||
|
|
a674a12706 | ||
|
|
c29f1af48f | ||
|
|
a8d72c46e4 | ||
|
|
ec36fbd83e | ||
|
|
aedb05cbab | ||
|
|
bb16840a72 | ||
|
|
7b5d44a329 | ||
|
|
a53a65be1f | ||
|
|
44af431a93 | ||
|
|
caa11b8f7e | ||
|
|
41cce4dcb9 | ||
|
|
858072cc10 | ||
|
|
855c5e0e67 | ||
|
|
f0cc3d0bcd |
3
.idea/vcs.xml
generated
3
.idea/vcs.xml
generated
@@ -2,6 +2,5 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -10,7 +10,7 @@ fi
|
||||
|
||||
cd dist
|
||||
wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
tar xvfJ node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
tar xfJ node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
rm node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
cd ..
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ if [[ $# -eq 0 ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
npm run webpack
|
||||
n exec 12 npm run webpack
|
||||
|
||||
DIR=$1
|
||||
|
||||
@@ -27,7 +27,7 @@ cp -r electron.js $DIR/
|
||||
cp webpack-* $DIR/
|
||||
|
||||
# run in subshell (so we return to original dir)
|
||||
(cd $DIR && npm install --only=prod)
|
||||
(cd $DIR && n exec 12 npm install --only=prod)
|
||||
|
||||
# cleanup of useless files in dependencies
|
||||
rm -r $DIR/node_modules/image-q/demo
|
||||
|
||||
@@ -55,47 +55,20 @@ echo "Creating release in GitHub"
|
||||
EXTRA=
|
||||
|
||||
if [[ $TAG == *"beta"* ]]; then
|
||||
EXTRA=--pre-release
|
||||
EXTRA=--prerelease
|
||||
fi
|
||||
|
||||
github-release release \
|
||||
--tag $TAG \
|
||||
--name "$TAG release" $EXTRA
|
||||
echo "$GITHUB_CLI_AUTH_TOKEN" | gh auth login --with-token
|
||||
|
||||
echo "Uploading debian x64 package"
|
||||
|
||||
github-release upload \
|
||||
--tag $TAG \
|
||||
--name "$DEBIAN_X64_BUILD" \
|
||||
--file "dist/$DEBIAN_X64_BUILD"
|
||||
|
||||
echo "Uploading linux x64 build"
|
||||
|
||||
github-release upload \
|
||||
--tag $TAG \
|
||||
--name "$LINUX_X64_BUILD" \
|
||||
--file "dist/$LINUX_X64_BUILD"
|
||||
|
||||
echo "Uploading windows x64 build"
|
||||
|
||||
github-release upload \
|
||||
--tag $TAG \
|
||||
--name "$WINDOWS_X64_BUILD" \
|
||||
--file "dist/$WINDOWS_X64_BUILD"
|
||||
|
||||
echo "Uploading mac x64 build"
|
||||
|
||||
github-release upload \
|
||||
--tag $TAG \
|
||||
--name "$MAC_X64_BUILD" \
|
||||
--file "dist/$MAC_X64_BUILD"
|
||||
|
||||
echo "Uploading linux x64 server build"
|
||||
|
||||
github-release upload \
|
||||
--tag $TAG \
|
||||
--name "$SERVER_BUILD" \
|
||||
--file "dist/$SERVER_BUILD"
|
||||
gh release create "$TAG" \
|
||||
--title "$TAG release" \
|
||||
--notes "" \
|
||||
$EXTRA \
|
||||
"dist/$DEBIAN_X64_BUILD" \
|
||||
"dist/$LINUX_X64_BUILD" \
|
||||
"dist/$WINDOWS_X64_BUILD" \
|
||||
"dist/$MAC_X64_BUILD" \
|
||||
"dist/$SERVER_BUILD"
|
||||
|
||||
echo "Building docker image"
|
||||
|
||||
@@ -105,4 +78,4 @@ echo "Pushing docker image to dockerhub"
|
||||
|
||||
bin/push-docker-image.sh $VERSION
|
||||
|
||||
echo "Release finished!"
|
||||
echo "Release finished!"
|
||||
|
||||
BIN
db/demo.zip
BIN
db/demo.zip
Binary file not shown.
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.46.5",
|
||||
"version": "0.46.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "trilium",
|
||||
"productName": "Trilium Notes",
|
||||
"description": "Trilium Notes",
|
||||
"version": "0.46.7",
|
||||
"version": "0.46.9",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "electron.js",
|
||||
"bin": {
|
||||
@@ -51,10 +51,11 @@
|
||||
"is-animated": "^2.0.1",
|
||||
"is-svg": "4.2.1",
|
||||
"jimp": "0.16.1",
|
||||
"joplin-turndown-plugin-gfm": "1.0.12",
|
||||
"jsdom": "16.5.0",
|
||||
"mime-types": "2.1.29",
|
||||
"multer": "1.4.2",
|
||||
"node-abi": "2.21.0",
|
||||
"node-abi": "2.26.0",
|
||||
"open": "7.4.2",
|
||||
"portscanner": "2.2.0",
|
||||
"rand-token": "1.0.1",
|
||||
@@ -70,7 +71,6 @@
|
||||
"striptags": "3.1.1",
|
||||
"tmp": "^0.2.1",
|
||||
"turndown": "7.0.0",
|
||||
"joplin-turndown-plugin-gfm": "1.0.12",
|
||||
"unescape": "1.0.1",
|
||||
"ws": "7.4.4",
|
||||
"yauzl": "2.10.0",
|
||||
|
||||
@@ -87,14 +87,16 @@ describe("Lexer expression", () => {
|
||||
.toEqual(["#label", "*=*", "text"]);
|
||||
});
|
||||
|
||||
it("simple label operator with in quotes and without", () => {
|
||||
it("simple label operator with in quotes", () => {
|
||||
expect(lex("#label*=*'text'").expressionTokens)
|
||||
.toEqual([
|
||||
{token: "#label", inQuotes: false, startIndex: 0, endIndex: 5},
|
||||
{token: "*=*", inQuotes: false, startIndex: 6, endIndex: 8},
|
||||
{token: "text", inQuotes: true, startIndex: 10, endIndex: 13}
|
||||
]);
|
||||
});
|
||||
|
||||
it("simple label operator with param without quotes", () => {
|
||||
expect(lex("#label*=*text").expressionTokens)
|
||||
.toEqual([
|
||||
{token: "#label", inQuotes: false, startIndex: 0, endIndex: 5},
|
||||
@@ -103,6 +105,16 @@ describe("Lexer expression", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("simple label operator with empty string param", () => {
|
||||
expect(lex("#label = ''").expressionTokens)
|
||||
.toEqual([
|
||||
{token: "#label", inQuotes: false, startIndex: 0, endIndex: 5},
|
||||
{token: "=", inQuotes: false, startIndex: 7, endIndex: 7},
|
||||
// weird case for empty strings which ends up with endIndex < startIndex :-(
|
||||
{token: "", inQuotes: true, startIndex: 10, endIndex: 9}
|
||||
]);
|
||||
});
|
||||
|
||||
it("note. prefix also separates fulltext from expression", () => {
|
||||
expect(lex(`hello fulltext note.labels.capital = Prague`).expressionTokens.map(t => t.token))
|
||||
.toEqual(["note", ".", "labels", ".", "capital", "=", "prague"]);
|
||||
|
||||
@@ -19,6 +19,13 @@ function tokens(toks, cur = 0) {
|
||||
});
|
||||
}
|
||||
|
||||
function assertIsArchived(exp) {
|
||||
expect(exp.constructor.name).toEqual("PropertyComparisonExp");
|
||||
expect(exp.propertyName).toEqual("isArchived");
|
||||
expect(exp.operator).toEqual("=");
|
||||
expect(exp.comparedValue).toEqual("false");
|
||||
}
|
||||
|
||||
describe("Parser", () => {
|
||||
it("fulltext parser without content", () => {
|
||||
const rootExp = parse({
|
||||
@@ -29,8 +36,9 @@ describe("Parser", () => {
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
expect(rootExp.subExpressions[0].constructor.name).toEqual("PropertyComparisonExp");
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||
expect(rootExp.subExpressions[1].tokens).toEqual(["hello", "hi"]);
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("OrExp");
|
||||
expect(rootExp.subExpressions[1].subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||
expect(rootExp.subExpressions[1].subExpressions[0].tokens).toEqual(["hello", "hi"]);
|
||||
});
|
||||
|
||||
it("fulltext parser with content", () => {
|
||||
@@ -40,9 +48,12 @@ describe("Parser", () => {
|
||||
searchContext: new SearchContext({includeNoteContent: true})
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("OrExp");
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
|
||||
const subs = rootExp.subExpressions;
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("OrExp");
|
||||
|
||||
const subs = rootExp.subExpressions[1].subExpressions;
|
||||
|
||||
expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||
expect(subs[0].tokens).toEqual(["hello", "hi"]);
|
||||
@@ -61,10 +72,12 @@ describe("Parser", () => {
|
||||
searchContext: new SearchContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(rootExp.attributeType).toEqual("label");
|
||||
expect(rootExp.attributeName).toEqual("mylabel");
|
||||
expect(rootExp.comparator).toBeTruthy();
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(rootExp.subExpressions[1].attributeType).toEqual("label");
|
||||
expect(rootExp.subExpressions[1].attributeName).toEqual("mylabel");
|
||||
expect(rootExp.subExpressions[1].comparator).toBeTruthy();
|
||||
});
|
||||
|
||||
it("simple attribute negation", () => {
|
||||
@@ -74,10 +87,12 @@ describe("Parser", () => {
|
||||
searchContext: new SearchContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("NotExp");
|
||||
expect(rootExp.subExpression.constructor.name).toEqual("AttributeExistsExp");
|
||||
expect(rootExp.subExpression.attributeType).toEqual("label");
|
||||
expect(rootExp.subExpression.attributeName).toEqual("mylabel");
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("NotExp");
|
||||
expect(rootExp.subExpressions[1].subExpression.constructor.name).toEqual("AttributeExistsExp");
|
||||
expect(rootExp.subExpressions[1].subExpression.attributeType).toEqual("label");
|
||||
expect(rootExp.subExpressions[1].subExpression.attributeName).toEqual("mylabel");
|
||||
|
||||
rootExp = parse({
|
||||
fulltextTokens: [],
|
||||
@@ -85,10 +100,12 @@ describe("Parser", () => {
|
||||
searchContext: new SearchContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("NotExp");
|
||||
expect(rootExp.subExpression.constructor.name).toEqual("AttributeExistsExp");
|
||||
expect(rootExp.subExpression.attributeType).toEqual("relation");
|
||||
expect(rootExp.subExpression.attributeName).toEqual("myrelation");
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("NotExp");
|
||||
expect(rootExp.subExpressions[1].subExpression.constructor.name).toEqual("AttributeExistsExp");
|
||||
expect(rootExp.subExpressions[1].subExpression.attributeType).toEqual("relation");
|
||||
expect(rootExp.subExpressions[1].subExpression.attributeName).toEqual("myrelation");
|
||||
});
|
||||
|
||||
it("simple label AND", () => {
|
||||
@@ -99,7 +116,10 @@ describe("Parser", () => {
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions;
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("AndExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions[1].subExpressions;
|
||||
|
||||
expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(firstSub.attributeName).toEqual("first");
|
||||
@@ -116,7 +136,10 @@ describe("Parser", () => {
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions;
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("AndExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions[1].subExpressions;
|
||||
|
||||
expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(firstSub.attributeName).toEqual("first");
|
||||
@@ -132,8 +155,11 @@ describe("Parser", () => {
|
||||
searchContext: new SearchContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("OrExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions;
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("OrExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions[1].subExpressions;
|
||||
|
||||
expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(firstSub.attributeName).toEqual("first");
|
||||
@@ -155,8 +181,9 @@ describe("Parser", () => {
|
||||
expect(firstSub.constructor.name).toEqual("PropertyComparisonExp");
|
||||
expect(firstSub.propertyName).toEqual('isArchived');
|
||||
|
||||
expect(secondSub.constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||
expect(secondSub.tokens).toEqual(["hello"]);
|
||||
expect(secondSub.constructor.name).toEqual("OrExp");
|
||||
expect(secondSub.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||
expect(secondSub.subExpressions[0].tokens).toEqual(["hello"]);
|
||||
|
||||
expect(thirdSub.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(thirdSub.attributeName).toEqual("mylabel");
|
||||
@@ -169,8 +196,11 @@ describe("Parser", () => {
|
||||
searchContext: new SearchContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("OrExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions;
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("OrExp");
|
||||
const [firstSub, secondSub] = rootExp.subExpressions[1].subExpressions;
|
||||
|
||||
expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(firstSub.attributeName).toEqual("first");
|
||||
@@ -232,10 +262,12 @@ describe("Invalid expressions", () => {
|
||||
searchContext: new SearchContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(rootExp.attributeType).toEqual("label");
|
||||
expect(rootExp.attributeName).toEqual("first");
|
||||
expect(rootExp.comparator).toBeTruthy();
|
||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||
assertIsArchived(rootExp.subExpressions[0]);
|
||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(rootExp.subExpressions[1].attributeType).toEqual("label");
|
||||
expect(rootExp.subExpressions[1].attributeName).toEqual("first");
|
||||
expect(rootExp.subExpressions[1].comparator).toBeTruthy();
|
||||
});
|
||||
|
||||
it("searching by relation without note property", () => {
|
||||
|
||||
@@ -562,8 +562,8 @@ describe("Search", () => {
|
||||
expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Austria");
|
||||
expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Italy");
|
||||
|
||||
searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy #capital DESC limit 0', searchContext);
|
||||
expect(searchResults.length).toEqual(0);
|
||||
searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy #capital DESC limit 1', searchContext);
|
||||
expect(searchResults.length).toEqual(1);
|
||||
|
||||
searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy #capital DESC limit 1000', searchContext);
|
||||
expect(searchResults.length).toEqual(4);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const {note} = require('./note_cache_mocking.js');
|
||||
const ValueExtractor = require('../../src/services/search/value_extractor.js');
|
||||
const noteCache = require('../../src/services/note_cache/note_cache.js');
|
||||
const SearchContext = require("../../src/services/search/search_context.js");
|
||||
|
||||
const dsc = new SearchContext();
|
||||
|
||||
describe("Value extractor", () => {
|
||||
beforeEach(() => {
|
||||
@@ -10,7 +13,7 @@ describe("Value extractor", () => {
|
||||
it("simple title extraction", async () => {
|
||||
const europe = note("Europe").note;
|
||||
|
||||
const valueExtractor = new ValueExtractor(["note", "title"]);
|
||||
const valueExtractor = new ValueExtractor(dsc, ["note", "title"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(europe)).toEqual("Europe");
|
||||
@@ -21,12 +24,12 @@ describe("Value extractor", () => {
|
||||
.label("Capital", "Vienna")
|
||||
.note;
|
||||
|
||||
let valueExtractor = new ValueExtractor(["note", "labels", "capital"]);
|
||||
let valueExtractor = new ValueExtractor(dsc, ["note", "labels", "capital"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(austria)).toEqual("Vienna");
|
||||
|
||||
valueExtractor = new ValueExtractor(["#capital"]);
|
||||
valueExtractor = new ValueExtractor(dsc, ["#capital"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(austria)).toEqual("Vienna");
|
||||
@@ -38,12 +41,12 @@ describe("Value extractor", () => {
|
||||
.child(note("Austria")
|
||||
.child(vienna));
|
||||
|
||||
let valueExtractor = new ValueExtractor(["note", "children", "children", "title"]);
|
||||
let valueExtractor = new ValueExtractor(dsc, ["note", "children", "children", "title"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(europe.note)).toEqual("Vienna");
|
||||
|
||||
valueExtractor = new ValueExtractor(["note", "parents", "parents", "title"]);
|
||||
valueExtractor = new ValueExtractor(dsc, ["note", "parents", "parents", "title"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(vienna.note)).toEqual("Europe");
|
||||
@@ -56,12 +59,12 @@ describe("Value extractor", () => {
|
||||
.relation('neighbor', czechRepublic.note)
|
||||
.relation('neighbor', slovakia.note);
|
||||
|
||||
let valueExtractor = new ValueExtractor(["note", "relations", "neighbor", "labels", "capital"]);
|
||||
let valueExtractor = new ValueExtractor(dsc, ["note", "relations", "neighbor", "labels", "capital"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(austria.note)).toEqual("Prague");
|
||||
|
||||
valueExtractor = new ValueExtractor(["~neighbor", "labels", "capital"]);
|
||||
valueExtractor = new ValueExtractor(dsc, ["~neighbor", "labels", "capital"]);
|
||||
|
||||
expect(valueExtractor.validate()).toBeFalsy();
|
||||
expect(valueExtractor.extract(austria.note)).toEqual("Prague");
|
||||
@@ -70,17 +73,17 @@ describe("Value extractor", () => {
|
||||
|
||||
describe("Invalid value extractor property path", () => {
|
||||
it('each path must start with "note" (or label/relation)',
|
||||
() => expect(new ValueExtractor(["neighbor"]).validate()).toBeTruthy());
|
||||
() => expect(new ValueExtractor(dsc, ["neighbor"]).validate()).toBeTruthy());
|
||||
|
||||
it("extra path element after terminal label",
|
||||
() => expect(new ValueExtractor(["~neighbor", "labels", "capital", "noteId"]).validate()).toBeTruthy());
|
||||
() => expect(new ValueExtractor(dsc, ["~neighbor", "labels", "capital", "noteId"]).validate()).toBeTruthy());
|
||||
|
||||
it("extra path element after terminal title",
|
||||
() => expect(new ValueExtractor(["note", "title", "isProtected"]).validate()).toBeTruthy());
|
||||
() => expect(new ValueExtractor(dsc, ["note", "title", "isProtected"]).validate()).toBeTruthy());
|
||||
|
||||
it("relation name and note property is missing",
|
||||
() => expect(new ValueExtractor(["note", "relations"]).validate()).toBeTruthy());
|
||||
() => expect(new ValueExtractor(dsc, ["note", "relations"]).validate()).toBeTruthy());
|
||||
|
||||
it("relation is specified but target note property is not specified",
|
||||
() => expect(new ValueExtractor(["note", "relations", "myrel"]).validate()).toBeTruthy());
|
||||
() => expect(new ValueExtractor(dsc, ["note", "relations", "myrel"]).validate()).toBeTruthy());
|
||||
});
|
||||
|
||||
@@ -370,7 +370,6 @@ class Note extends Entity {
|
||||
WHERE attributes.isDeleted = 0
|
||||
AND attributes.type = 'relation'
|
||||
AND attributes.name = 'template'
|
||||
AND (treeWithAttrs.level = 0 OR attributes.isInheritable = 1)
|
||||
)
|
||||
SELECT attributes.* FROM attributes JOIN treeWithAttrs ON attributes.noteId = treeWithAttrs.noteId
|
||||
WHERE attributes.isDeleted = 0 AND (attributes.isInheritable = 1 OR treeWithAttrs.level = 0)
|
||||
|
||||
@@ -382,8 +382,6 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
}
|
||||
else {
|
||||
node.setActive();
|
||||
|
||||
this.clearSelectedNodes();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -393,6 +391,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
// click event won't propagate so let's close context menu manually
|
||||
contextMenu.hide();
|
||||
|
||||
this.clearSelectedNodes();
|
||||
|
||||
const notePath = treeService.getNotePath(data.node);
|
||||
|
||||
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
||||
@@ -1144,11 +1144,12 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
}
|
||||
|
||||
if (node) {
|
||||
node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
||||
|
||||
if (activeNodeFocused) {
|
||||
node.setFocus(true);
|
||||
// needed by Firefox: https://github.com/zadam/trilium/issues/1865
|
||||
this.tree.$container.focus();
|
||||
}
|
||||
|
||||
await node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
||||
}
|
||||
else {
|
||||
// this is used when original note has been deleted and we want to move the focus to the note above/below
|
||||
|
||||
@@ -5,7 +5,7 @@ const TPL = `
|
||||
<td colspan="2">
|
||||
<span class="bx bx-trash"></span>
|
||||
|
||||
Delete matched note
|
||||
Delete matched notes
|
||||
</td>
|
||||
<td class="button-column">
|
||||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||||
|
||||
@@ -5,24 +5,47 @@ import linkService from "../../services/link.js";
|
||||
import noteContentRenderer from "../../services/note_content_renderer.js";
|
||||
|
||||
export default class AbstractTextTypeWidget extends TypeWidget {
|
||||
doRender() {
|
||||
this.$widget.on("dblclick", "img", e => {
|
||||
const $img = $(e.target);
|
||||
const src = $img.prop("src");
|
||||
setupImageOpening(singleClickOpens) {
|
||||
this.$widget.on("dblclick", "img", e => this.openImageInCurrentTab($(e.target)));
|
||||
|
||||
const match = src.match(/\/api\/images\/([A-Za-z0-9]+)\//);
|
||||
|
||||
if (match) {
|
||||
const noteId = match[1];
|
||||
|
||||
appContext.tabManager.getActiveTabContext().setNote(noteId);
|
||||
this.$widget.on("click", "img", e => {
|
||||
if ((e.which === 1 && e.ctrlKey) || e.which === 2) {
|
||||
this.openImageInNewTab($(e.target));
|
||||
}
|
||||
else {
|
||||
window.open(src, '_blank');
|
||||
else if (e.which === 1 && singleClickOpens) {
|
||||
this.openImageInCurrentTab($(e.target));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openImageInCurrentTab($img) {
|
||||
const imgSrc = $img.prop("src");
|
||||
const noteId = this.getNoteIdFromImage(imgSrc);
|
||||
|
||||
if (noteId) {
|
||||
appContext.tabManager.getActiveTabContext().setNote(noteId);
|
||||
} else {
|
||||
window.open(imgSrc, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
openImageInNewTab($img) {
|
||||
const imgSrc = $img.prop("src");
|
||||
const noteId = this.getNoteIdFromImage(imgSrc);
|
||||
|
||||
if (noteId) {
|
||||
appContext.tabManager.openTabWithNoteWithHoisting(noteId);
|
||||
} else {
|
||||
window.open(imgSrc, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
getNoteIdFromImage(imgSrc) {
|
||||
const match = imgSrc.match(/\/api\/images\/([A-Za-z0-9]+)\//);
|
||||
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
async loadIncludedNote(noteId, $el) {
|
||||
const note = await treeCache.getNote(noteId);
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
|
||||
keyboardActionService.setupActionsForElement('text-detail', this.$widget, this);
|
||||
|
||||
this.setupImageOpening(false);
|
||||
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ const TPL = `
|
||||
|
||||
.note-detail-readonly-text img {
|
||||
max-width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.edit-text-note-container {
|
||||
@@ -66,6 +67,8 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
|
||||
this.triggerEvent('textPreviewDisabled', {tabContext: this.tabContext});
|
||||
});
|
||||
|
||||
this.setupImageOpening(true);
|
||||
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,11 @@ function processContent(images, note, content) {
|
||||
const filename = path.basename(src);
|
||||
|
||||
if (!dataUrl || !dataUrl.startsWith("data:image")) {
|
||||
log.info("Image could not be recognized as data URL:", dataUrl.substr(0, Math.min(100, dataUrl.length)));
|
||||
const excerpt = dataUrl
|
||||
? dataUrl.substr(0, Math.min(100, dataUrl.length))
|
||||
: "null";
|
||||
|
||||
log.info("Image could not be recognized as data URL: " + excerpt);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,9 +200,7 @@ function queueSector(req) {
|
||||
const entityName = utils.sanitizeSqlIdentifier(req.params.entityName);
|
||||
const sector = utils.sanitizeSqlIdentifier(req.params.sector);
|
||||
|
||||
const entityPrimaryKey = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;
|
||||
|
||||
entityChangesService.addEntityChangesForSector(entityName, entityPrimaryKey, sector);
|
||||
entityChangesService.addEntityChangesForSector(entityName, sector);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = { buildDate:"2021-04-03T22:37:04+02:00", buildRevision: "ef37a52a06b471e60f9c0f11da704283bbcef6ab" };
|
||||
module.exports = { buildDate:"2021-04-22T20:50:22+02:00", buildRevision: "c27f573eed8905fc1d958adf5bdee0efc3aff593" };
|
||||
|
||||
@@ -53,22 +53,14 @@ function moveEntityChangeToTop(entityName, entityId) {
|
||||
addEntityChange(entityName, entityId, hash, null, isSynced);
|
||||
}
|
||||
|
||||
function addEntityChangesForSector(entityName, entityPrimaryKey, sector) {
|
||||
function addEntityChangesForSector(entityName, sector) {
|
||||
const startTime = Date.now();
|
||||
const repository = require('./repository');
|
||||
|
||||
const entityChanges = sql.getRows(`SELECT * FROM entity_changes WHERE entityName = ? AND SUBSTR(entityId, 1, 1) = ?`, [entityName, sector]);
|
||||
|
||||
sql.transactional(() => {
|
||||
const entityIds = sql.getColumn(`SELECT ${entityPrimaryKey} FROM ${entityName} WHERE SUBSTR(${entityPrimaryKey}, 1, 1) = ?`, [sector]);
|
||||
|
||||
for (const entityId of entityIds) {
|
||||
// retrieving entity one by one to avoid memory issues with note_contents
|
||||
const entity = repository.getEntity(`SELECT * FROM ${entityName} WHERE ${entityPrimaryKey} = ?`, [entityId]);
|
||||
|
||||
if (entityName === 'options' && !entity.isSynced) {
|
||||
continue
|
||||
}
|
||||
|
||||
insertEntityChange(entityName, entityId, entity.generateHash(), false, entity.getUtcDateChanged(), 'content-check', true);
|
||||
for (const ec of entityChanges) {
|
||||
insertEntityChange(entityName, ec.entityId, ec.hash, ec.isErased, ec.utcDateChanged, ec.sourceId, ec.isSynced);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ function lex(str) {
|
||||
}
|
||||
}
|
||||
|
||||
function finishWord(endIndex) {
|
||||
if (currentWord === '') {
|
||||
function finishWord(endIndex, createAlsoForEmptyWords = false) {
|
||||
if (currentWord === '' && !createAlsoForEmptyWords) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ function lex(str) {
|
||||
}
|
||||
}
|
||||
else if (quotes === chr) {
|
||||
finishWord(i - 1);
|
||||
finishWord(i - 1, true);
|
||||
|
||||
quotes = false;
|
||||
}
|
||||
|
||||
@@ -245,9 +245,7 @@ async function checkContentHash(syncContext) {
|
||||
const failedChecks = contentHashService.checkContentHashes(resp.entityHashes);
|
||||
|
||||
for (const {entityName, sector} of failedChecks) {
|
||||
const entityPrimaryKey = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;
|
||||
|
||||
entityChangesService.addEntityChangesForSector(entityName, entityPrimaryKey, sector);
|
||||
entityChangesService.addEntityChangesForSector(entityName, sector);
|
||||
|
||||
await syncRequest(syncContext, 'POST', `/api/sync/queue-sector/${entityName}/${sector}`);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/public" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/public/app-dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/libraries" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/docs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/bin/better-sqlite3" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
||||
Reference in New Issue
Block a user