mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
Compare commits
2221 Commits
v0.94.1
...
feat/bette
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5024e27885 | ||
|
|
78c27dbe04 | ||
|
|
384a89b0e3 | ||
|
|
e7fd9371b6 | ||
|
|
aa83429816 | ||
|
|
221ab02c24 | ||
|
|
0c4b751e8f | ||
|
|
43fd0924a1 | ||
|
|
7a036fc777 | ||
|
|
54efa6b38c | ||
|
|
6e37c9ee5a | ||
|
|
963f4586f3 | ||
|
|
4d0edebed3 | ||
|
|
cb39e8d0f8 | ||
|
|
a336f472b8 | ||
|
|
0a097e72be | ||
|
|
077f10af7b | ||
|
|
9317658fc7 | ||
|
|
21a13f2124 | ||
|
|
db6658c05f | ||
|
|
653af0bc06 | ||
|
|
93c5281af7 | ||
|
|
ce28fbc968 | ||
|
|
eb41c45711 | ||
|
|
17ab14e098 | ||
|
|
a42f7b4ece | ||
|
|
c7d69fa66b | ||
|
|
1da5c083ee | ||
|
|
4fb911da40 | ||
|
|
881417f860 | ||
|
|
9748b8bf94 | ||
|
|
337326da2b | ||
|
|
a088134d9b | ||
|
|
e49100f3f4 | ||
|
|
3c638e1574 | ||
|
|
9131edf021 | ||
|
|
52a1318475 | ||
|
|
5a7483d7c7 | ||
|
|
41f2748829 | ||
|
|
66bd5268ca | ||
|
|
ebef134af7 | ||
|
|
1173bf22ab | ||
|
|
e8f6828168 | ||
|
|
02c9339f9c | ||
|
|
c72bf42684 | ||
|
|
f42eeb7ee8 | ||
|
|
3d876121cc | ||
|
|
f9bcd7d90a | ||
|
|
b3af14fccb | ||
|
|
d224f33913 | ||
|
|
3a5f33ba91 | ||
|
|
e1ae8701b2 | ||
|
|
aff5a4d0d5 | ||
|
|
17467a9c29 | ||
|
|
ebed661863 | ||
|
|
c2e9f4764b | ||
|
|
7e5b87f00a | ||
|
|
70182e863c | ||
|
|
f0d30c4e34 | ||
|
|
013e7a6aa4 | ||
|
|
1b25b18d9e | ||
|
|
72ff384187 | ||
|
|
bac048f60f | ||
|
|
d8d0a64134 | ||
|
|
b2db87db4e | ||
|
|
1baaee582e | ||
|
|
9212b72351 | ||
|
|
24af820477 | ||
|
|
6c4c2d22c6 | ||
|
|
2e9b20be71 | ||
|
|
3216de5d89 | ||
|
|
4bf7cb8099 | ||
|
|
4871dbd7ef | ||
|
|
e125809fe0 | ||
|
|
27b80b573f | ||
|
|
38d6ae87b6 | ||
|
|
1a7cbc13e0 | ||
|
|
8e4691d4a4 | ||
|
|
b371337ed2 | ||
|
|
4d4b76ce39 | ||
|
|
289d3e9882 | ||
|
|
a57eb8f27f | ||
|
|
27023f1fd5 | ||
|
|
20a152993f | ||
|
|
ba7636db75 | ||
|
|
e3e51a2e1f | ||
|
|
93b601fe98 | ||
|
|
203ebb0e7a | ||
|
|
041c2e5693 | ||
|
|
258c0d511e | ||
|
|
15705553c7 | ||
|
|
27f023e399 | ||
|
|
0d2242171c | ||
|
|
0c62ecda65 | ||
|
|
7cd7fec93b | ||
|
|
cfab5e6217 | ||
|
|
0c313e8b8f | ||
|
|
61366061e6 | ||
|
|
b2c0685c09 | ||
|
|
e3ee284e91 | ||
|
|
58901855af | ||
|
|
c7f8a49c47 | ||
|
|
10685fe183 | ||
|
|
9e514fe95e | ||
|
|
f28a319e26 | ||
|
|
decfb58142 | ||
|
|
415bbc3b0a | ||
|
|
5b669ca287 | ||
|
|
1700217241 | ||
|
|
f00c0d5d73 | ||
|
|
64ce0d2911 | ||
|
|
82dce7a0d3 | ||
|
|
b94f67aa72 | ||
|
|
1ff77a1464 | ||
|
|
adb0e1e844 | ||
|
|
2043a06a48 | ||
|
|
738ebb66ac | ||
|
|
abf1f6c041 | ||
|
|
7db0e90506 | ||
|
|
400f9cf911 | ||
|
|
2d3b99c959 | ||
|
|
fd1ea05c78 | ||
|
|
d7c4b8f530 | ||
|
|
238f358d6a | ||
|
|
50afdca150 | ||
|
|
b5555d94f5 | ||
|
|
3d81633214 | ||
|
|
5db7997a17 | ||
|
|
71dd428919 | ||
|
|
a20d66a6b5 | ||
|
|
3caefa5409 | ||
|
|
a6e56be55a | ||
|
|
6d582f09be | ||
|
|
40cd46cd09 | ||
|
|
3cc59149cf | ||
|
|
e659266d62 | ||
|
|
14e09f5ea0 | ||
|
|
11f6462a31 | ||
|
|
48eebbe2fe | ||
|
|
f7093c035b | ||
|
|
b25e9cdee6 | ||
|
|
5cd7e4707a | ||
|
|
861374bb87 | ||
|
|
d3519b3059 | ||
|
|
da1f18c60f | ||
|
|
b7482f2a6a | ||
|
|
fd616cafca | ||
|
|
b262a5181f | ||
|
|
adb54a9054 | ||
|
|
5eb05f5550 | ||
|
|
2950c5eaa4 | ||
|
|
16fd67c070 | ||
|
|
9e3559f97c | ||
|
|
83eea30ea0 | ||
|
|
6ceccf1c7a | ||
|
|
31e1c4c712 | ||
|
|
fa97ec6c72 | ||
|
|
cd5467bf5c | ||
|
|
899f85f4e7 | ||
|
|
7c79fbefa6 | ||
|
|
18c6fe7ebd | ||
|
|
6f6643d758 | ||
|
|
356adebbce | ||
|
|
5c8e4fd6fd | ||
|
|
5be9bb47a7 | ||
|
|
60c5dc525b | ||
|
|
abfffcec07 | ||
|
|
09b12052f0 | ||
|
|
78bb0ab016 | ||
|
|
4cd4c2f607 | ||
|
|
f95b5d6f14 | ||
|
|
4a53be1e33 | ||
|
|
cbbe845d7b | ||
|
|
b2b52e92a4 | ||
|
|
15a97a4675 | ||
|
|
a01f25ec12 | ||
|
|
2f175765ec | ||
|
|
6a7ae72b1b | ||
|
|
e396bb1641 | ||
|
|
baedac4746 | ||
|
|
268ef626ca | ||
|
|
40c7ad4b46 | ||
|
|
54f9ce87f9 | ||
|
|
12b8a70e5c | ||
|
|
acf204d0e3 | ||
|
|
ee19f9ccaa | ||
|
|
34c0cf33b9 | ||
|
|
34ec624e46 | ||
|
|
056d3f9f36 | ||
|
|
040673af0b | ||
|
|
48fb0c5e21 | ||
|
|
4c1a55708f | ||
|
|
6e1951b356 | ||
|
|
3dd6b05d2e | ||
|
|
05f1ae01f3 | ||
|
|
3975041798 | ||
|
|
3a29d65777 | ||
|
|
eeeecb3988 | ||
|
|
28ababcbb9 | ||
|
|
f382943af3 | ||
|
|
fa38332a6c | ||
|
|
5a58fcde96 | ||
|
|
62d048433b | ||
|
|
db4ba53449 | ||
|
|
da20916767 | ||
|
|
b1e12182ce | ||
|
|
80b2061935 | ||
|
|
8ce92f8c93 | ||
|
|
05cd8cb547 | ||
|
|
6e7d0bc51b | ||
|
|
b9aede23e6 | ||
|
|
1d52988826 | ||
|
|
ebe29f41f9 | ||
|
|
598591a2da | ||
|
|
32c2860b68 | ||
|
|
d975790e79 | ||
|
|
3e1f74ae93 | ||
|
|
81a8908b98 | ||
|
|
892dfe2340 | ||
|
|
fd175eb8a8 | ||
|
|
c98f6d96d5 | ||
|
|
35b628e799 | ||
|
|
49b79c016d | ||
|
|
4d28df7a89 | ||
|
|
25a9a8a724 | ||
|
|
313a61ec48 | ||
|
|
a2eab03ee2 | ||
|
|
a563b1c9a0 | ||
|
|
20018b9c21 | ||
|
|
0a9bd5f6d1 | ||
|
|
911fee0213 | ||
|
|
ffe4b53eee | ||
|
|
cd5a68d230 | ||
|
|
95a2a69e0a | ||
|
|
360b5d6de4 | ||
|
|
bf50883e40 | ||
|
|
8e04690568 | ||
|
|
bd6c690160 | ||
|
|
c0d7278827 | ||
|
|
f9eb0a20f7 | ||
|
|
8d27a5aa39 | ||
|
|
90f9416524 | ||
|
|
ae0af8b9c7 | ||
|
|
a03a0f8a75 | ||
|
|
f0f27a9065 | ||
|
|
181d5ee36a | ||
|
|
2758a230ac | ||
|
|
a46d32ed75 | ||
|
|
b2bcae8b74 | ||
|
|
49d662afba | ||
|
|
a593ce7c40 | ||
|
|
31fbf2cb57 | ||
|
|
c0d3027e65 | ||
|
|
bde270b73f | ||
|
|
edd18b53d0 | ||
|
|
2ad4b26c9e | ||
|
|
f39a5c55ba | ||
|
|
0af5feab79 | ||
|
|
68dd54a100 | ||
|
|
7a0f148d28 | ||
|
|
958b1592f8 | ||
|
|
7ac0828ae7 | ||
|
|
f7e7b38551 | ||
|
|
33e3112290 | ||
|
|
2a27666c53 | ||
|
|
f2d45cb780 | ||
|
|
c4b91c9777 | ||
|
|
fa06f56f5d | ||
|
|
519b962af3 | ||
|
|
31e6ac2349 | ||
|
|
ed3ba2745f | ||
|
|
f5b7648d6d | ||
|
|
2d537b82f6 | ||
|
|
073354fe04 | ||
|
|
165d093928 | ||
|
|
e8cf3f4a10 | ||
|
|
2a40d6bb7e | ||
|
|
f196a78728 | ||
|
|
523c7ac273 | ||
|
|
c36b00994b | ||
|
|
76b856bfe5 | ||
|
|
7b084035a3 | ||
|
|
59fbdaa879 | ||
|
|
ce324586f8 | ||
|
|
35bd210062 | ||
|
|
0cfe3351bb | ||
|
|
7202f47716 | ||
|
|
bde4545afc | ||
|
|
b3c81ce5f2 | ||
|
|
02b0d1fb5e | ||
|
|
87d9ea06f3 | ||
|
|
a4e6a964c9 | ||
|
|
79c5d479fc | ||
|
|
8f0a9f91c1 | ||
|
|
93fae9cc8c | ||
|
|
1046321117 | ||
|
|
00fc92764b | ||
|
|
dea8bc307e | ||
|
|
18a4fbaa4b | ||
|
|
3efc4b13d5 | ||
|
|
952456a69c | ||
|
|
bde8e17fe6 | ||
|
|
9023ba1d0a | ||
|
|
61f9a86685 | ||
|
|
5520cfed5d | ||
|
|
43df984732 | ||
|
|
3f398c1a00 | ||
|
|
ad35e3b48f | ||
|
|
73ee44e177 | ||
|
|
18414cd155 | ||
|
|
652d78ac68 | ||
|
|
9a3ab05d73 | ||
|
|
fe238b8afd | ||
|
|
94492c7535 | ||
|
|
47caf970a1 | ||
|
|
3e75ab39c2 | ||
|
|
72aacdbf6f | ||
|
|
5461dafe02 | ||
|
|
30f9f66b8b | ||
|
|
19de803142 | ||
|
|
11b247fe07 | ||
|
|
faa40494d8 | ||
|
|
796802aea0 | ||
|
|
06af5cf6d5 | ||
|
|
81a99c1e44 | ||
|
|
1b384f35d2 | ||
|
|
c1259f2ea2 | ||
|
|
92d9c82d97 | ||
|
|
064f0ef921 | ||
|
|
e9a9b462d4 | ||
|
|
98888d5f1d | ||
|
|
134c869b07 | ||
|
|
beb0487513 | ||
|
|
aa9ffb8f6b | ||
|
|
18eb704b81 | ||
|
|
83fb62d4df | ||
|
|
cb650b70cb | ||
|
|
d5e42318dd | ||
|
|
24ed474c8c | ||
|
|
a9c25b4edd | ||
|
|
c89737ae7b | ||
|
|
e619a6ef7c | ||
|
|
6a2a096348 | ||
|
|
bf34ef2009 | ||
|
|
583ab8dc92 | ||
|
|
db1619af31 | ||
|
|
9cddb9ac1d | ||
|
|
d72d3db2a0 | ||
|
|
22740a6c8d | ||
|
|
e9409577db | ||
|
|
9cef8c8e70 | ||
|
|
53bcec602d | ||
|
|
a62f12b427 | ||
|
|
e20816a7ce | ||
|
|
58535df676 | ||
|
|
057040af06 | ||
|
|
c603783a44 | ||
|
|
1928356ad5 | ||
|
|
e53ad2c62a | ||
|
|
bca397e3e4 | ||
|
|
14b3bea203 | ||
|
|
05c26d17d3 | ||
|
|
51360d855a | ||
|
|
ae7d03e3c7 | ||
|
|
164feaa3ec | ||
|
|
4d09fabad8 | ||
|
|
87e1ce64d1 | ||
|
|
04913394c6 | ||
|
|
f8b563704f | ||
|
|
5d9bd0f6d3 | ||
|
|
1229c26098 | ||
|
|
77818d5453 | ||
|
|
f9c7c5637b | ||
|
|
5d55b0b0a8 | ||
|
|
b2d7fbbcad | ||
|
|
fbc6734e08 | ||
|
|
a83172390f | ||
|
|
4b1fd5e4a0 | ||
|
|
51495b282f | ||
|
|
b645d21fcd | ||
|
|
8f99ce7d14 | ||
|
|
6eb650bb22 | ||
|
|
a7f5702221 | ||
|
|
efeb9b90ca | ||
|
|
3361a2e4ab | ||
|
|
425ade5212 | ||
|
|
384ab1d1f3 | ||
|
|
70b1a37285 | ||
|
|
61a878e2a0 | ||
|
|
319cb8384c | ||
|
|
2d358342c5 | ||
|
|
dd7ee05388 | ||
|
|
6c79be881d | ||
|
|
51a8937c64 | ||
|
|
c436455b32 | ||
|
|
f740edae91 | ||
|
|
18f89b979d | ||
|
|
8094259c78 | ||
|
|
b4f503b81e | ||
|
|
4db04519bd | ||
|
|
464c2bdf28 | ||
|
|
8007bac8b8 | ||
|
|
7a1ec266ad | ||
|
|
42fedaa241 | ||
|
|
4387bd4c6f | ||
|
|
51e1367b82 | ||
|
|
8bea3f4422 | ||
|
|
0eb2e405ff | ||
|
|
5dbd4a765f | ||
|
|
f6961c7e06 | ||
|
|
8d3ba90072 | ||
|
|
3772412d82 | ||
|
|
84389f467e | ||
|
|
eb41e0f96f | ||
|
|
2d44dff997 | ||
|
|
1483bf3d46 | ||
|
|
064cf6a3ee | ||
|
|
0c0d5eaa0a | ||
|
|
afecb33b5c | ||
|
|
fbb1e3a302 | ||
|
|
8704350359 | ||
|
|
d09e725d98 | ||
|
|
8be5b149c4 | ||
|
|
faeea6af18 | ||
|
|
3fa5ea1010 | ||
|
|
6aa31ae125 | ||
|
|
27f2e9c286 | ||
|
|
67cc36fdd2 | ||
|
|
ef7297e03b | ||
|
|
97a5314cdb | ||
|
|
a1195a2856 | ||
|
|
81419c6fe3 | ||
|
|
b8da793353 | ||
|
|
8140fa79cc | ||
|
|
abff4fe67d | ||
|
|
ec8f737eba | ||
|
|
cc6688ea00 | ||
|
|
c448b29be7 | ||
|
|
61bde294b3 | ||
|
|
acab81c61e | ||
|
|
1dd965973b | ||
|
|
d61981033f | ||
|
|
30197ba7ce | ||
|
|
1b6c957334 | ||
|
|
fb7a397bf9 | ||
|
|
133c9c5a7b | ||
|
|
8a587d4d21 | ||
|
|
29b813fa3b | ||
|
|
1dfe27d3df | ||
|
|
cda8fc7146 | ||
|
|
acb16f751b | ||
|
|
a1ac276be5 | ||
|
|
54e3ab5139 | ||
|
|
baf341b312 | ||
|
|
5b074c2e22 | ||
|
|
11d086ef12 | ||
|
|
0e6b10e400 | ||
|
|
0240222998 | ||
|
|
7fc739487f | ||
|
|
f6e275709f | ||
|
|
7e01dfd220 | ||
|
|
d5866a99ec | ||
|
|
5289d41b12 | ||
|
|
030178cad2 | ||
|
|
5d00630452 | ||
|
|
eb805bfa2a | ||
|
|
ee3a8e105e | ||
|
|
97fb273e7f | ||
|
|
2ef9009384 | ||
|
|
27c7888628 | ||
|
|
b4de37a9f4 | ||
|
|
1c5ebb54f8 | ||
|
|
f3e69dd6bd | ||
|
|
66364f5ce0 | ||
|
|
f25a1fb865 | ||
|
|
62c5b8b1fc | ||
|
|
2b0de37fc0 | ||
|
|
23ef73fe2f | ||
|
|
92ac3ee4ef | ||
|
|
a3ba5ca109 | ||
|
|
5b4e81cf18 | ||
|
|
772e6f5ebc | ||
|
|
60a9428b8b | ||
|
|
a7752a8421 | ||
|
|
aefa2315b7 | ||
|
|
37a79aeeab | ||
|
|
5bc4bdaeef | ||
|
|
5e28df883d | ||
|
|
0a57748075 | ||
|
|
45e3eee642 | ||
|
|
d724a80c2a | ||
|
|
5ea8c94d18 | ||
|
|
769bc760b3 | ||
|
|
f04f45ea62 | ||
|
|
a5cab6a2a2 | ||
|
|
138611beaf | ||
|
|
e1b608057a | ||
|
|
fed6d8329f | ||
|
|
9d03d52f28 | ||
|
|
055e11174d | ||
|
|
8fda2dd7f1 | ||
|
|
ea03695c75 | ||
|
|
17b206fc72 | ||
|
|
4ec8c5963a | ||
|
|
ab2d8accf5 | ||
|
|
de8b7e9ebe | ||
|
|
18d11523a6 | ||
|
|
7a0ab3c025 | ||
|
|
3575a7dc93 | ||
|
|
bb9e7b1c6e | ||
|
|
115e9e0202 | ||
|
|
e341de70c0 | ||
|
|
1d1a0ac4fd | ||
|
|
d48470ffb1 | ||
|
|
6574ca42a3 | ||
|
|
303ff35a76 | ||
|
|
e0850958b0 | ||
|
|
13115b9ed1 | ||
|
|
933a11e9db | ||
|
|
6915993a35 | ||
|
|
237a4e9a74 | ||
|
|
1565a0fd80 | ||
|
|
e8b16287e0 | ||
|
|
c09e124805 | ||
|
|
b6f55b0e1a | ||
|
|
964bc74b83 | ||
|
|
fa9b142cb7 | ||
|
|
7e3f412c84 | ||
|
|
82e16a5624 | ||
|
|
757488a95b | ||
|
|
d7f154cfd1 | ||
|
|
3517715aab | ||
|
|
d10bbdd7a7 | ||
|
|
c4ec27bb1e | ||
|
|
0b24553ace | ||
|
|
793867269b | ||
|
|
9508e92676 | ||
|
|
89378eae7b | ||
|
|
ace166a925 | ||
|
|
d59d544c0f | ||
|
|
37461d0eb3 | ||
|
|
126152ff63 | ||
|
|
60e19de0d1 | ||
|
|
3247a9facc | ||
|
|
7b114bed26 | ||
|
|
30ffbc760e | ||
|
|
4420913049 | ||
|
|
3762690c5f | ||
|
|
d684ac40d8 | ||
|
|
d217379644 | ||
|
|
d5f7fa2fe5 | ||
|
|
3e0ef10b25 | ||
|
|
28f88f2407 | ||
|
|
e525a7a0ff | ||
|
|
3415f38e0a | ||
|
|
910c0faade | ||
|
|
4ad1bb5e3a | ||
|
|
97f6f0a945 | ||
|
|
bc78c17a11 | ||
|
|
b8e813f7bd | ||
|
|
db3581eb26 | ||
|
|
d23230df68 | ||
|
|
b29781b614 | ||
|
|
7d7c3e7cdb | ||
|
|
cbd8cb80ab | ||
|
|
bfcdc34faf | ||
|
|
c728e6047d | ||
|
|
4c53a9ba8c | ||
|
|
e10a7da7e3 | ||
|
|
5cc431b1bf | ||
|
|
734aa2fcb5 | ||
|
|
5e37319d9b | ||
|
|
2e9eb6e3e9 | ||
|
|
9ce57b123a | ||
|
|
e793168afa | ||
|
|
d1513424e7 | ||
|
|
1436a01dbe | ||
|
|
b9b936b92a | ||
|
|
adf14bec31 | ||
|
|
ca1403ffea | ||
|
|
06672e439e | ||
|
|
e851701a9e | ||
|
|
9589164008 | ||
|
|
a88b067081 | ||
|
|
b3777e6900 | ||
|
|
d2646e291d | ||
|
|
99ab9ee66b | ||
|
|
08678e74e6 | ||
|
|
62de52ab17 | ||
|
|
d9820d9725 | ||
|
|
fe8a8eeac9 | ||
|
|
dfeb414aff | ||
|
|
69f12a2916 | ||
|
|
2b062e938e | ||
|
|
e0299bd1ae | ||
|
|
ac2f1b56fe | ||
|
|
06d98f6fcf | ||
|
|
bb660d15b2 | ||
|
|
4d73cdefef | ||
|
|
313ba3df80 | ||
|
|
15377c32c2 | ||
|
|
22b52f7c4a | ||
|
|
7055f77c91 | ||
|
|
051fe67176 | ||
|
|
90accfcc48 | ||
|
|
4f99db0c90 | ||
|
|
aeb356bf54 | ||
|
|
0dffa0f333 | ||
|
|
d17f5b8447 | ||
|
|
b5a57b3c66 | ||
|
|
987a3404a9 | ||
|
|
eddc30769f | ||
|
|
4d455650ba | ||
|
|
e2157aab26 | ||
|
|
b277f4bf3f | ||
|
|
4047452b0f | ||
|
|
cb37724879 | ||
|
|
8890893412 | ||
|
|
d0cbda7c0d | ||
|
|
60e7b9ffb0 | ||
|
|
45457c6f76 | ||
|
|
737f41d92b | ||
|
|
180841f364 | ||
|
|
bea40d4c2f | ||
|
|
5f9a054441 | ||
|
|
f90bf1ce7c | ||
|
|
8c4ed2d4da | ||
|
|
0e590a1bbf | ||
|
|
218a096135 | ||
|
|
8407bce370 | ||
|
|
43229f0b99 | ||
|
|
84fa0002b9 | ||
|
|
e79c705b20 | ||
|
|
894d7ce15d | ||
|
|
5830880582 | ||
|
|
caab0f70ff | ||
|
|
641966fcdd | ||
|
|
24c22e9bbf | ||
|
|
795f597bda | ||
|
|
2228663a7e | ||
|
|
0c97df357d | ||
|
|
19f63f1be0 | ||
|
|
fc000caf73 | ||
|
|
78929e0293 | ||
|
|
71e22da987 | ||
|
|
24e99d9654 | ||
|
|
98299da424 | ||
|
|
7014af66b6 | ||
|
|
659bd90027 | ||
|
|
146b0c284b | ||
|
|
4a0ac8807f | ||
|
|
d67734832e | ||
|
|
1673bf026a | ||
|
|
1f29b000a9 | ||
|
|
a6d024123e | ||
|
|
fb1a7239ce | ||
|
|
4f71d508cb | ||
|
|
2072bd61d1 | ||
|
|
6021178b7d | ||
|
|
179b0be2bb | ||
|
|
bf2b45dd4a | ||
|
|
513561234c | ||
|
|
33da990ae7 | ||
|
|
4003946e68 | ||
|
|
21f8d40789 | ||
|
|
d6c698e1d6 | ||
|
|
6c227852ae | ||
|
|
29cb22c4fd | ||
|
|
d040bc9e2d | ||
|
|
abb92f23a6 | ||
|
|
da5c86bb69 | ||
|
|
a0d428b12c | ||
|
|
e22fe20e23 | ||
|
|
1e6659aff9 | ||
|
|
60b32d5b05 | ||
|
|
e2ee9053a0 | ||
|
|
d2f0422ecc | ||
|
|
bfd97da626 | ||
|
|
1fd163f0bb | ||
|
|
d15ce575df | ||
|
|
9999ff5a89 | ||
|
|
4653941082 | ||
|
|
fa509661ab | ||
|
|
d9a289bf18 | ||
|
|
98c76b713d | ||
|
|
05ed917a56 | ||
|
|
b833806ec7 | ||
|
|
7fdef3418a | ||
|
|
49e14ec542 | ||
|
|
efd9244684 | ||
|
|
318f2d1f8c | ||
|
|
92fa1cf052 | ||
|
|
17c6eb1680 | ||
|
|
7c6af568d8 | ||
|
|
23c9c6826e | ||
|
|
b08fda5e10 | ||
|
|
5ec3a49377 | ||
|
|
1c728ae432 | ||
|
|
fd25c735c1 | ||
|
|
7de33907c5 | ||
|
|
ec021be16c | ||
|
|
8b6826ffa4 | ||
|
|
00cc1ffe74 | ||
|
|
2384fdbaad | ||
|
|
08a93d81d7 | ||
|
|
86911100df | ||
|
|
ff01656268 | ||
|
|
d0ea6d9e8d | ||
|
|
96ca3d5e38 | ||
|
|
3a569499cb | ||
|
|
545b19f978 | ||
|
|
d98be19c9a | ||
|
|
4826898c55 | ||
|
|
482b592f77 | ||
|
|
939ebfe47b | ||
|
|
c6dee1339b | ||
|
|
23f8c3ad3c | ||
|
|
81c1b88376 | ||
|
|
c4a85db698 | ||
|
|
e6eda45c04 | ||
|
|
a3014434cf | ||
|
|
3ebab2c126 | ||
|
|
954619bd36 | ||
|
|
eb76362de4 | ||
|
|
1cde14859b | ||
|
|
c752b98995 | ||
|
|
1f792ca418 | ||
|
|
b22e08b1eb | ||
|
|
2b5029cc38 | ||
|
|
9e936cb57b | ||
|
|
e8fd2c1b3c | ||
|
|
977fbf54ee | ||
|
|
3e5c91415d | ||
|
|
d60b855f74 | ||
|
|
4146192b6d | ||
|
|
26ee0ff48f | ||
|
|
6995fbfd06 | ||
|
|
1763d80d5f | ||
|
|
a594e5147c | ||
|
|
e51ea1a619 | ||
|
|
83b72eafa6 | ||
|
|
757a6777be | ||
|
|
37c9260dca | ||
|
|
e1a8f4f5db | ||
|
|
b7b0b39afc | ||
|
|
af797489e8 | ||
|
|
d003e91b89 | ||
|
|
4a35df745a | ||
|
|
b1b756b179 | ||
|
|
9e3372df72 | ||
|
|
657df7a728 | ||
|
|
944f0b694b | ||
|
|
efd409da17 | ||
|
|
08d60c554c | ||
|
|
a428ea7beb | ||
|
|
f69878b082 | ||
|
|
c5ffc2882b | ||
|
|
765691751a | ||
|
|
f19e5977c2 | ||
|
|
8f8b9af862 | ||
|
|
3e7dc71995 | ||
|
|
2a25cd8686 | ||
|
|
7664839135 | ||
|
|
47daebc65a | ||
|
|
0d18b944b6 | ||
|
|
951b5384a3 | ||
|
|
11547ecaa3 | ||
|
|
713a0f5b09 | ||
|
|
2cf9c98b43 | ||
|
|
d7af196a0c | ||
|
|
c363be57b7 | ||
|
|
10645790de | ||
|
|
8b18cf382c | ||
|
|
7a131e0bcc | ||
|
|
3d264379cc | ||
|
|
f405682ec1 | ||
|
|
3debf3ce1c | ||
|
|
5a76883969 | ||
|
|
6f51c5e0cc | ||
|
|
2c730d1f0b | ||
|
|
d487da0b2f | ||
|
|
cb8a5cbb62 | ||
|
|
ceb08593d8 | ||
|
|
9dd0eb7b9b | ||
|
|
ebff644d24 | ||
|
|
beb1c15fa5 | ||
|
|
40a5eee211 | ||
|
|
8f393d0bae | ||
|
|
94dad49e2f | ||
|
|
409638151c | ||
|
|
0d3de92890 | ||
|
|
5d619131ec | ||
|
|
e2c8443778 | ||
|
|
daa4743967 | ||
|
|
56553078ef | ||
|
|
5584a06cb3 | ||
|
|
cfeb69ace6 | ||
|
|
b0c8f110de | ||
|
|
aba1266c45 | ||
|
|
c331e0103d | ||
|
|
13978574e0 | ||
|
|
be85963558 | ||
|
|
8c19261ced | ||
|
|
7ca17fa609 | ||
|
|
3d107572df | ||
|
|
f7488655a7 | ||
|
|
876e0a29d4 | ||
|
|
af74375695 | ||
|
|
896965fec5 | ||
|
|
ba5ef93c1a | ||
|
|
ef1153d336 | ||
|
|
0d347f8823 | ||
|
|
897cdc26ae | ||
|
|
aba621c099 | ||
|
|
839813ebde | ||
|
|
545e2ddbfc | ||
|
|
1d63a5903a | ||
|
|
2b34c00a0c | ||
|
|
123068062a | ||
|
|
9a668e8709 | ||
|
|
f6f8937d64 | ||
|
|
c9f53a2880 | ||
|
|
2887e712c3 | ||
|
|
5d3a0ed1b4 | ||
|
|
334b6319de | ||
|
|
4c118c0fd4 | ||
|
|
db00d60684 | ||
|
|
25b74af363 | ||
|
|
eb57cf97ad | ||
|
|
c92e24363f | ||
|
|
8d5d00ac0f | ||
|
|
8b457384ba | ||
|
|
fab2d53ece | ||
|
|
774f27d8d2 | ||
|
|
d7f02ef1b3 | ||
|
|
97eaa6294c | ||
|
|
dc02bb0850 | ||
|
|
2c8c041e1c | ||
|
|
874b1c6654 | ||
|
|
fb982c7097 | ||
|
|
b7f5ce600e | ||
|
|
91604c9e26 | ||
|
|
c874333a37 | ||
|
|
1298b968f2 | ||
|
|
6fe5a854a7 | ||
|
|
aba3b5cb19 | ||
|
|
282aed22b5 | ||
|
|
669a3d9dcf | ||
|
|
9d7455d28a | ||
|
|
4f0c8b081c | ||
|
|
a5db5298a0 | ||
|
|
876c6e9252 | ||
|
|
aef824d262 | ||
|
|
a25ce42490 | ||
|
|
8b0fdaccf4 | ||
|
|
bd840a2421 | ||
|
|
27d515f289 | ||
|
|
df3b9faf8d | ||
|
|
0f129734ae | ||
|
|
275aacfba9 | ||
|
|
e7f47a0663 | ||
|
|
66486541fe | ||
|
|
34f1a84769 | ||
|
|
2244f0368f | ||
|
|
9d85005255 | ||
|
|
ad8629dca6 | ||
|
|
cccfe0e05a | ||
|
|
a8874257e8 | ||
|
|
f689c55f56 | ||
|
|
853c7be8b8 | ||
|
|
823df1e12d | ||
|
|
7570f818e9 | ||
|
|
03aa5aea2c | ||
|
|
a4e86ac353 | ||
|
|
cf6efc050a | ||
|
|
3e0802176b | ||
|
|
697954d4d9 | ||
|
|
741f6c1114 | ||
|
|
b2237ffa51 | ||
|
|
7b6d11bffa | ||
|
|
97565e8f36 | ||
|
|
c0dfee8439 | ||
|
|
fc98240614 | ||
|
|
169d1203c2 | ||
|
|
f3350bc8f5 | ||
|
|
504a19275c | ||
|
|
14cdc52670 | ||
|
|
cf8063f311 | ||
|
|
aa8902f5b9 | ||
|
|
7cd0e664ac | ||
|
|
a04804d3fa | ||
|
|
86f90e6685 | ||
|
|
8131a4b3d2 | ||
|
|
b91a3e13b0 | ||
|
|
5a7a0d32d1 | ||
|
|
3f5df18d6c | ||
|
|
df2cede075 | ||
|
|
4321c161ac | ||
|
|
b1f0c64ef2 | ||
|
|
c9b37dcc77 | ||
|
|
ab093ed9a0 | ||
|
|
cf31367acd | ||
|
|
e3d306cac3 | ||
|
|
960d321019 | ||
|
|
2d4ac93221 | ||
|
|
d4a4f15416 | ||
|
|
504a842d37 | ||
|
|
ded5b1f5d2 | ||
|
|
fcbbc21a80 | ||
|
|
38fce25b86 | ||
|
|
4cc2fa5300 | ||
|
|
4a82c3f65a | ||
|
|
b255d70e18 | ||
|
|
caa842cd55 | ||
|
|
cd338085fb | ||
|
|
e703ce92a8 | ||
|
|
84479a2c2a | ||
|
|
c13969217c | ||
|
|
402540f483 | ||
|
|
8c56315313 | ||
|
|
b29c3eff6e | ||
|
|
ec7dacfc9b | ||
|
|
5f9a6a9f76 | ||
|
|
28f4aea3d5 | ||
|
|
8d29c5fe1b | ||
|
|
ccd935b562 | ||
|
|
d77a49857b | ||
|
|
e30478e5d4 | ||
|
|
71863752cd | ||
|
|
e4a2a8e56d | ||
|
|
0f1c505823 | ||
|
|
1ecce11113 | ||
|
|
2287d67fb5 | ||
|
|
5b4f17ef3d | ||
|
|
3720ab6df6 | ||
|
|
3c893d69e5 | ||
|
|
b93a4a3e42 | ||
|
|
23cef0ab94 | ||
|
|
c8ffb8d694 | ||
|
|
08e08d8920 | ||
|
|
7acd300163 | ||
|
|
d8d95db4ec | ||
|
|
af97d3ef1d | ||
|
|
c65ec14943 | ||
|
|
adfdc7edb4 | ||
|
|
8cced607eb | ||
|
|
5dd5af90c2 | ||
|
|
7a48333b4f | ||
|
|
7044533398 | ||
|
|
560aad8df6 | ||
|
|
36c2099b2e | ||
|
|
6c157675d7 | ||
|
|
458d66cb21 | ||
|
|
201e8911c5 | ||
|
|
1b1ed2408f | ||
|
|
62487d21d8 | ||
|
|
bc752bdb0b | ||
|
|
9e00d421fb | ||
|
|
e7f02fe22b | ||
|
|
6d694f8e53 | ||
|
|
977befd0a7 | ||
|
|
1566ae4fbd | ||
|
|
4e97490cc6 | ||
|
|
446d5a0fcc | ||
|
|
1fd6465012 | ||
|
|
6cea8e3b87 | ||
|
|
28a63e0326 | ||
|
|
b73da46111 | ||
|
|
abafa8c2d2 | ||
|
|
4ae3272cdf | ||
|
|
6aa3b8dbd7 | ||
|
|
395e9b2228 | ||
|
|
be33f68c52 | ||
|
|
29d96381fa | ||
|
|
da8eecf774 | ||
|
|
de91326c12 | ||
|
|
ee1c3c35d7 | ||
|
|
70eece1429 | ||
|
|
b4f2be332b | ||
|
|
23fe76989b | ||
|
|
275d07659d | ||
|
|
a901e92573 | ||
|
|
6ead31b45f | ||
|
|
d4ce12dca9 | ||
|
|
bb6e22cdb7 | ||
|
|
2c9fc4812e | ||
|
|
60f4554afa | ||
|
|
3c486bfd1b | ||
|
|
26b9a95bb2 | ||
|
|
f7c9217cea | ||
|
|
e92022b73c | ||
|
|
61ff2353c8 | ||
|
|
c8cca26ca4 | ||
|
|
aa556ed4d5 | ||
|
|
5d694a7bdf | ||
|
|
c4787dae23 | ||
|
|
9f5f329c53 | ||
|
|
f82b96fcc4 | ||
|
|
d4b24fa427 | ||
|
|
c852f67c59 | ||
|
|
92c228a3c9 | ||
|
|
42f948e2b3 | ||
|
|
13e8932117 | ||
|
|
910d34bd42 | ||
|
|
b204ba29e7 | ||
|
|
d49244cbc8 | ||
|
|
ef2f2f17b4 | ||
|
|
b9f21dcf4c | ||
|
|
808fe690cc | ||
|
|
901eec04e5 | ||
|
|
9272394ada | ||
|
|
4457982fae | ||
|
|
7f67b2b461 | ||
|
|
7f3934f4c3 | ||
|
|
a3b80a2cc4 | ||
|
|
6d967e5e51 | ||
|
|
b674ca90d1 | ||
|
|
95edb60a84 | ||
|
|
40add78ccb | ||
|
|
1029c24c06 | ||
|
|
94d94fe8fb | ||
|
|
49489c0f45 | ||
|
|
215833a2c9 | ||
|
|
a7471a3d47 | ||
|
|
909aaefbd7 | ||
|
|
15c2f56bf2 | ||
|
|
84cdfec415 | ||
|
|
91572ab8b9 | ||
|
|
ed758f4c92 | ||
|
|
f1fc15e115 | ||
|
|
22300e8151 | ||
|
|
292646e14a | ||
|
|
b4921a20d8 | ||
|
|
54be79a725 | ||
|
|
4fc47370fe | ||
|
|
9e30bcf233 | ||
|
|
e5712c54e6 | ||
|
|
2a4fe21a39 | ||
|
|
b259558f0f | ||
|
|
e2f6d9e0d6 | ||
|
|
4fc2b0fa5e | ||
|
|
8dca79ecf2 | ||
|
|
c7f49f0e21 | ||
|
|
bce2094fb2 | ||
|
|
65c33e1aa0 | ||
|
|
8e108bc5e2 | ||
|
|
4e75ce7fdb | ||
|
|
1e42574d28 | ||
|
|
85ebaf6afa | ||
|
|
661c7e4056 | ||
|
|
1e8ea54dbc | ||
|
|
ddbe7e9936 | ||
|
|
cab86175ef | ||
|
|
ec7414b174 | ||
|
|
8343a5d1dd | ||
|
|
18c55784c7 | ||
|
|
39eac83d38 | ||
|
|
55bd6fb57d | ||
|
|
6fdec52332 | ||
|
|
824a3c5fcc | ||
|
|
87da644027 | ||
|
|
4f42f543d8 | ||
|
|
97ea3ac3fc | ||
|
|
f04b75fd36 | ||
|
|
f5bffc38f1 | ||
|
|
27738acefc | ||
|
|
59ce2072c5 | ||
|
|
ed68dda70b | ||
|
|
892ab02f06 | ||
|
|
7d9196d5e1 | ||
|
|
dccdb5ceb7 | ||
|
|
f961698e44 | ||
|
|
278fe3262e | ||
|
|
1fc860b052 | ||
|
|
88a8311173 | ||
|
|
63dc5697dd | ||
|
|
b595d1fade | ||
|
|
d91c59b7d0 | ||
|
|
aa2ab0da31 | ||
|
|
91f94106fb | ||
|
|
308f319138 | ||
|
|
fa0c01591a | ||
|
|
cb5a771490 | ||
|
|
0c17a13462 | ||
|
|
04593cb2d7 | ||
|
|
b6f50b6af0 | ||
|
|
fc454cba03 | ||
|
|
6f165df29e | ||
|
|
d16468071d | ||
|
|
20a492523f | ||
|
|
1216f51c78 | ||
|
|
ea3ac1041b | ||
|
|
d838e8baf0 | ||
|
|
60a7347d7d | ||
|
|
4e05e79426 | ||
|
|
aa872f47f2 | ||
|
|
fbd833ad86 | ||
|
|
bee65ed32c | ||
|
|
5adca76a9a | ||
|
|
e7467f6446 | ||
|
|
e49473fbd3 | ||
|
|
bfec44aa5a | ||
|
|
55b3bf6036 | ||
|
|
c9c07f0cb0 | ||
|
|
e25727441d | ||
|
|
51b7955ccd | ||
|
|
196bba9cda | ||
|
|
430ed78d85 | ||
|
|
2d11ed805d | ||
|
|
f55426bdb0 | ||
|
|
87b5068fec | ||
|
|
9ddd1a4ae2 | ||
|
|
736bc9c9bd | ||
|
|
5a2da62992 | ||
|
|
1a72eb91ee | ||
|
|
0d3c5b06e2 | ||
|
|
035b72a08d | ||
|
|
fc4a595725 | ||
|
|
444969bcf4 | ||
|
|
2cb6b14eca | ||
|
|
468b5022a4 | ||
|
|
c1897563ca | ||
|
|
5e533896b9 | ||
|
|
d3ceb7cfc1 | ||
|
|
731f74f421 | ||
|
|
46d82651a3 | ||
|
|
b3108c7e2b | ||
|
|
0cb988470e | ||
|
|
5a030014b0 | ||
|
|
2a43ef4dae | ||
|
|
6b5f9fc6ff | ||
|
|
b3a156c20d | ||
|
|
24340d3a8e | ||
|
|
2fac2a8c5e | ||
|
|
decb0c702d | ||
|
|
d45ff6cca5 | ||
|
|
83833e668c | ||
|
|
2cc181d1ac | ||
|
|
a946ce3534 | ||
|
|
3e9f476b37 | ||
|
|
de65c748a4 | ||
|
|
8a2bfb9d7b | ||
|
|
a1ced31fea | ||
|
|
989a9f506e | ||
|
|
59d55e2489 | ||
|
|
2b312a9234 | ||
|
|
16d9b982c2 | ||
|
|
a5600e75f5 | ||
|
|
f91dea62b6 | ||
|
|
4915ffcf2a | ||
|
|
9dbea2aa18 | ||
|
|
45f6a70fb8 | ||
|
|
96b4c611cc | ||
|
|
4e559d6594 | ||
|
|
db1a599f95 | ||
|
|
040964bbb7 | ||
|
|
dc6a303154 | ||
|
|
f88f14c983 | ||
|
|
f870649256 | ||
|
|
ed4dc30a6e | ||
|
|
ce9010ff13 | ||
|
|
994e9fa852 | ||
|
|
9df7d6227e | ||
|
|
242a576548 | ||
|
|
c1a5808f37 | ||
|
|
5c6bb99d78 | ||
|
|
63c408c45b | ||
|
|
2a665dffbc | ||
|
|
6509acd6ee | ||
|
|
4853d45609 | ||
|
|
fe78c1fee3 | ||
|
|
8102172557 | ||
|
|
a1341e6036 | ||
|
|
d31af2ddc2 | ||
|
|
a563330136 | ||
|
|
a58e5789bc | ||
|
|
68e258f23b | ||
|
|
dd18866156 | ||
|
|
1b1f1957c3 | ||
|
|
ff6b4effbd | ||
|
|
06fa59239c | ||
|
|
557bfbd1d6 | ||
|
|
f5a6dfa629 | ||
|
|
ce33dfb003 | ||
|
|
7b1c058d29 | ||
|
|
04c8f8a123 | ||
|
|
d15fccb1d8 | ||
|
|
229dd9cd18 | ||
|
|
a4faaa406b | ||
|
|
b6d2de54b2 | ||
|
|
d5e81d77a2 | ||
|
|
939e99637f | ||
|
|
579a261612 | ||
|
|
6d03304cbb | ||
|
|
b8d41b3421 | ||
|
|
6a5bb1f5c8 | ||
|
|
cd742a4617 | ||
|
|
54063b97ad | ||
|
|
7abb67e737 | ||
|
|
00fd1ba137 | ||
|
|
7ea37b9eb9 | ||
|
|
b749de8fe1 | ||
|
|
8efef6842d | ||
|
|
dc206f38d5 | ||
|
|
29a00a6c0e | ||
|
|
fe678230a8 | ||
|
|
9cdbeb061f | ||
|
|
6c308f35c1 | ||
|
|
34b89cf2e8 | ||
|
|
b566a188dc | ||
|
|
998432e236 | ||
|
|
1af8edfe4d | ||
|
|
5bf01106c5 | ||
|
|
a45289e385 | ||
|
|
4ffd005b09 | ||
|
|
e6ca89fea8 | ||
|
|
2225aea756 | ||
|
|
bfc4a84020 | ||
|
|
5390bfdcab | ||
|
|
301211ff41 | ||
|
|
64139e4e08 | ||
|
|
e6485cde92 | ||
|
|
891f6ba66f | ||
|
|
5d3c1e3fec | ||
|
|
087e755390 | ||
|
|
025dc1ce75 | ||
|
|
703200338d | ||
|
|
377c93ca0b | ||
|
|
69394ffe29 | ||
|
|
f85231d74a | ||
|
|
b93d8b0159 | ||
|
|
67b9329903 | ||
|
|
c0edd4ea4f | ||
|
|
8eaf2786e8 | ||
|
|
25622df464 | ||
|
|
a48900e178 | ||
|
|
ac8b0535d2 | ||
|
|
6ce25a825b | ||
|
|
b3f56851b8 | ||
|
|
4b86fedce1 | ||
|
|
1ebb70c4d2 | ||
|
|
3de7b81be8 | ||
|
|
d08225339c | ||
|
|
ba22d0706f | ||
|
|
ef80f104c0 | ||
|
|
af296a1e4e | ||
|
|
28a755306a | ||
|
|
461e085eff | ||
|
|
fbda049c32 | ||
|
|
4ded5e2b98 | ||
|
|
63537aff20 | ||
|
|
0f7a2adf15 | ||
|
|
60963abe2c | ||
|
|
08cf95aa38 | ||
|
|
e5b10ab16a | ||
|
|
7f5a1ee45a | ||
|
|
15c593f68e | ||
|
|
5f8ef0395b | ||
|
|
513636e1e0 | ||
|
|
ae9b2c08a9 | ||
|
|
d5327b3b4a | ||
|
|
323e3d3cac | ||
|
|
01b2257063 | ||
|
|
c69ef611a0 | ||
|
|
dcad23316d | ||
|
|
e411f9932f | ||
|
|
854969e1b8 | ||
|
|
4ac7b6e9e8 | ||
|
|
ac70908c5a | ||
|
|
45ac70b78f | ||
|
|
a4664576fe | ||
|
|
b293643398 | ||
|
|
a2e197facd | ||
|
|
8614d39ef4 | ||
|
|
6456bb34ae | ||
|
|
f5dc4de1c1 | ||
|
|
d869056910 | ||
|
|
821e4b17cb | ||
|
|
d8cb5efd2d | ||
|
|
f90e2fb484 | ||
|
|
2c9a7144da | ||
|
|
88d1af7210 | ||
|
|
300e5a5528 | ||
|
|
4418fefe4b | ||
|
|
fe5d1cac9a | ||
|
|
49d17fff9b | ||
|
|
557c6d2d8b | ||
|
|
45fc62357d | ||
|
|
840e3cc22f | ||
|
|
c158c7fc88 | ||
|
|
bc6f8fc2dd | ||
|
|
117730acb2 | ||
|
|
595a7dac83 | ||
|
|
64a4d70df4 | ||
|
|
be36199fe1 | ||
|
|
e46ad25677 | ||
|
|
d5ee663922 | ||
|
|
a7ab4be055 | ||
|
|
6bbf29e75a | ||
|
|
0a06c60cb7 | ||
|
|
03658575eb | ||
|
|
38114bddb9 | ||
|
|
0711a197db | ||
|
|
f8f818b211 | ||
|
|
988932209c | ||
|
|
2aa56cec30 | ||
|
|
93d493650c | ||
|
|
c6162ddcb4 | ||
|
|
038517eda4 | ||
|
|
30a9db73ab | ||
|
|
a50aa41bdb | ||
|
|
cbb322fdb8 | ||
|
|
026e2a020d | ||
|
|
07aab1d005 | ||
|
|
26f0f7b188 | ||
|
|
1efde3b86b | ||
|
|
8c1318f379 | ||
|
|
40e67e8e17 | ||
|
|
04466f52fd | ||
|
|
06baa5fb57 | ||
|
|
04e1657628 | ||
|
|
7816c8cab0 | ||
|
|
6636e658a4 | ||
|
|
2a06f0daef | ||
|
|
883cfa588c | ||
|
|
68011a0b5a | ||
|
|
5247d1a371 | ||
|
|
cabdd528d4 | ||
|
|
2bacbb796b | ||
|
|
aa0ed6434a | ||
|
|
5b2215d646 | ||
|
|
0e760e25f2 | ||
|
|
acbb85b409 | ||
|
|
ea1d4b97ad | ||
|
|
a81839c13f | ||
|
|
b9d4668d4d | ||
|
|
42b27f5965 | ||
|
|
9cc8222b1c | ||
|
|
e8479338df | ||
|
|
fa9e6c9fc0 | ||
|
|
5366173b52 | ||
|
|
63520c55b3 | ||
|
|
86f6d9b14a | ||
|
|
5270cf6284 | ||
|
|
4f46d81e1b | ||
|
|
294a2e6fdb | ||
|
|
b20a8bc90b | ||
|
|
68bdd1336f | ||
|
|
e62ccd932d | ||
|
|
d6c188df6e | ||
|
|
004000b5d2 | ||
|
|
633c8a3444 | ||
|
|
2f59a20b6b | ||
|
|
593c435f75 | ||
|
|
20ec45be57 | ||
|
|
d2a0e12409 | ||
|
|
33eebe117b | ||
|
|
ef0cfc2e7c | ||
|
|
b6e17ae543 | ||
|
|
8a33e2be89 | ||
|
|
5f91097987 | ||
|
|
0fd4f02951 | ||
|
|
106e78ed62 | ||
|
|
8855868b27 | ||
|
|
bfc3e8a907 | ||
|
|
154371e052 | ||
|
|
ab4a4d3d72 | ||
|
|
5a4de02db7 | ||
|
|
43cbc8c6e8 | ||
|
|
5938aa7b50 | ||
|
|
a49252b2f5 | ||
|
|
0be885d9bf | ||
|
|
ae1e8353f2 | ||
|
|
98fe88581f | ||
|
|
d66475576f | ||
|
|
65ff7be776 | ||
|
|
190b079494 | ||
|
|
b020a30bd4 | ||
|
|
81f8453c38 | ||
|
|
533e3cf42d | ||
|
|
69ee73492d | ||
|
|
4a902d04b2 | ||
|
|
2e48e316c2 | ||
|
|
bbe5dddb83 | ||
|
|
7c943fe4ac | ||
|
|
2cbb49681a | ||
|
|
84db4ed57c | ||
|
|
e155642ce4 | ||
|
|
87c4df60d3 | ||
|
|
ff412835e4 | ||
|
|
ad15828157 | ||
|
|
b2fc7f934e | ||
|
|
2fac4d91d6 | ||
|
|
125cd96354 | ||
|
|
af02e6b714 | ||
|
|
0c87b25244 | ||
|
|
e87ada6e79 | ||
|
|
282c8e58bd | ||
|
|
475b66b115 | ||
|
|
5bb971e61a | ||
|
|
ebad9ba723 | ||
|
|
6ece2a839e | ||
|
|
8d6527fb75 | ||
|
|
6bfff38182 | ||
|
|
9e446717fa | ||
|
|
408b48f606 | ||
|
|
8d077ad46d | ||
|
|
db72465e0b | ||
|
|
ba9f5e1688 | ||
|
|
caf40cd272 | ||
|
|
3edccd224a | ||
|
|
f48931a969 | ||
|
|
84f23aa997 | ||
|
|
1965da6a85 | ||
|
|
57649d47ec | ||
|
|
089ae04542 | ||
|
|
441ae3e25b | ||
|
|
1016f98867 | ||
|
|
1f022aea4e | ||
|
|
7f612711a0 | ||
|
|
92eb4aa822 | ||
|
|
08ec522ae7 | ||
|
|
c5cc1fcc1e | ||
|
|
cedf91ea1a | ||
|
|
51b462f043 | ||
|
|
727eeb6c74 | ||
|
|
a114fba062 | ||
|
|
cf322b5c2a | ||
|
|
92116f1671 | ||
|
|
bc479248d7 | ||
|
|
8ee12f2950 | ||
|
|
dcea4c30ef | ||
|
|
e7ca56e061 | ||
|
|
09b800b9ad | ||
|
|
9a6a8580de | ||
|
|
a31ac17792 | ||
|
|
0e27cd0801 | ||
|
|
bc36676fa1 | ||
|
|
3d2db23f33 | ||
|
|
56d366a286 | ||
|
|
4a26f30d65 | ||
|
|
8e51469de5 | ||
|
|
50ebcd552c | ||
|
|
ada39cd3c7 | ||
|
|
b2d20af51a | ||
|
|
f528fa25d1 | ||
|
|
e09a7fb6e0 | ||
|
|
30f7939616 | ||
|
|
16b9375b9d | ||
|
|
4ef93569a1 | ||
|
|
1ce2aaeaf1 | ||
|
|
6bfe8dfcf0 | ||
|
|
8d8f4795e2 | ||
|
|
6f6d06377b | ||
|
|
f22823fcf6 | ||
|
|
93ce57ee1a | ||
|
|
97dd747252 | ||
|
|
bc8c136458 | ||
|
|
0774252dc1 | ||
|
|
ae30ae4be6 | ||
|
|
a2b8935763 | ||
|
|
703efb74d3 | ||
|
|
b2c6062e9a | ||
|
|
c9e7e461b1 | ||
|
|
6aaddfc5a4 | ||
|
|
7f2c41940d | ||
|
|
d31ba39a91 | ||
|
|
c058673e33 | ||
|
|
44ce6a5169 | ||
|
|
0fb0be4ffc | ||
|
|
e70ba00929 | ||
|
|
fe1dbb4cbf | ||
|
|
31df2341c3 | ||
|
|
9d99da14e1 | ||
|
|
f8e10f36db | ||
|
|
bb0f384a39 | ||
|
|
6a0b24f032 | ||
|
|
80d5536503 | ||
|
|
9dcd79bd94 | ||
|
|
c5020b8884 | ||
|
|
0b74de275c | ||
|
|
e66aef17df | ||
|
|
19eff5e6d6 | ||
|
|
88b4fc73de | ||
|
|
70694542eb | ||
|
|
360e5e3102 | ||
|
|
06b507fdc5 | ||
|
|
256ffe39f2 | ||
|
|
6e89a232e6 | ||
|
|
45a3fb15e6 | ||
|
|
4139a401e6 | ||
|
|
4d617ccdb3 | ||
|
|
57039ae8f2 | ||
|
|
9a4dcda985 | ||
|
|
c13ae40ea4 | ||
|
|
0b963db405 | ||
|
|
78b946b208 | ||
|
|
4e8ddef915 | ||
|
|
0aa08cd297 | ||
|
|
a89ce5d931 | ||
|
|
fe3350f39f | ||
|
|
f32f9d4326 | ||
|
|
2ed24e8f9c | ||
|
|
537c282156 | ||
|
|
61f253787a | ||
|
|
ddad800771 | ||
|
|
69c24ef806 | ||
|
|
df7fe2bf13 | ||
|
|
c47d3514be | ||
|
|
2b979f46ab | ||
|
|
edc47eba05 | ||
|
|
f3b46d6bc7 | ||
|
|
69d6d6a4fd | ||
|
|
5916b7d2a3 | ||
|
|
fbb2c67edb | ||
|
|
7e1712712e | ||
|
|
aa846e9703 | ||
|
|
6ed9ec0851 | ||
|
|
3a0a79119d | ||
|
|
ecd3b7039f | ||
|
|
4a22e3d2d4 | ||
|
|
dcb4ebe5d9 | ||
|
|
dd379bf18d | ||
|
|
c9b556160f | ||
|
|
168e224d3e | ||
|
|
9e57c14130 | ||
|
|
9c137a1c48 | ||
|
|
ccb9b7e5fb | ||
|
|
c7b16cd043 | ||
|
|
7e20e41521 | ||
|
|
66761a69d3 | ||
|
|
fb32d26479 | ||
|
|
b6398fdb5d | ||
|
|
d9443527ee | ||
|
|
7c175da9f1 | ||
|
|
05aa087851 | ||
|
|
592e968f9f | ||
|
|
894a26cc67 | ||
|
|
1b5dd4638d | ||
|
|
a19186c508 | ||
|
|
5450bdeae9 | ||
|
|
fcd71957ff | ||
|
|
1ff7228ca5 | ||
|
|
f0f79b65e2 | ||
|
|
63610fd579 | ||
|
|
eab84bd34e | ||
|
|
72f4c40a8a | ||
|
|
482356206b | ||
|
|
5aa09fd881 | ||
|
|
81f50c46ed | ||
|
|
938dfe7f38 | ||
|
|
ea71439f27 | ||
|
|
9dc157b970 | ||
|
|
b7f5c0e07a | ||
|
|
3988bb5321 | ||
|
|
ba94616b87 | ||
|
|
1ac086b88e | ||
|
|
3b4efef4f0 | ||
|
|
9dc0807f78 | ||
|
|
22783662c5 | ||
|
|
64086592ef | ||
|
|
2bebed1b0f | ||
|
|
2262d300f7 | ||
|
|
dba98d6fc1 | ||
|
|
d8b85aad7c | ||
|
|
5a3503c577 | ||
|
|
18c96cd2bc | ||
|
|
b1bb1ed9af | ||
|
|
bc1ea98827 | ||
|
|
b984d612fd | ||
|
|
f53eecbf88 | ||
|
|
1a2c2dbfb8 | ||
|
|
78a0637283 | ||
|
|
e01858c86b | ||
|
|
ee080638be | ||
|
|
6db7ef415d | ||
|
|
cf171ff0b1 | ||
|
|
fdddc29092 | ||
|
|
d6545e1280 | ||
|
|
759fe04e37 | ||
|
|
e0c5f15480 | ||
|
|
f529cfd928 | ||
|
|
2a1a099dc9 | ||
|
|
26d0ba04ab | ||
|
|
f85ef444f4 | ||
|
|
87aa4422c0 | ||
|
|
f497b71d37 | ||
|
|
24ba17b3f3 | ||
|
|
e8cbce855e | ||
|
|
f97bd77117 | ||
|
|
962066fd60 | ||
|
|
ff917e93c9 | ||
|
|
a7091779b7 | ||
|
|
520b862551 | ||
|
|
5fbd34c7c1 | ||
|
|
c827b20e26 | ||
|
|
a150047432 | ||
|
|
4f6729857b | ||
|
|
ce305f0f45 | ||
|
|
3a50ffede1 | ||
|
|
41e88614d7 | ||
|
|
002c567ae9 | ||
|
|
a9c07af402 | ||
|
|
3048c39877 | ||
|
|
a95dc14d24 | ||
|
|
24c82fa7b6 | ||
|
|
02a0624e8f | ||
|
|
e6e276a0cf | ||
|
|
8d90231f76 | ||
|
|
4a40b22c9a | ||
|
|
79b3b92ec9 | ||
|
|
ae1a4fbbf6 | ||
|
|
3190aa6fe6 | ||
|
|
1c3cd9e7ca | ||
|
|
c61713333d | ||
|
|
a861defbee | ||
|
|
ea0b570910 | ||
|
|
8d46ab3806 | ||
|
|
058b3f8241 | ||
|
|
57a688b6b6 | ||
|
|
ad18d853e2 | ||
|
|
8f5be936a7 | ||
|
|
f2c02f869e | ||
|
|
cf28777119 | ||
|
|
cca8504796 | ||
|
|
09391a92e5 | ||
|
|
50db8ef9c3 | ||
|
|
8ab21f3bab | ||
|
|
efdf79feaa | ||
|
|
9418055b69 | ||
|
|
5070633257 | ||
|
|
764917562e | ||
|
|
54290a1373 | ||
|
|
0325bee425 | ||
|
|
e280968271 | ||
|
|
b809137c93 | ||
|
|
248f6d6a7d | ||
|
|
0744a85421 | ||
|
|
e5a6f53f98 | ||
|
|
751de1d43c | ||
|
|
2704b1546b | ||
|
|
acd68817e9 | ||
|
|
8b841c5aa7 | ||
|
|
a37af29c6c | ||
|
|
ade0d4bb1a | ||
|
|
d79c491777 | ||
|
|
f9cf542e66 | ||
|
|
609ed6274e | ||
|
|
7faaefee20 | ||
|
|
578310a1c0 | ||
|
|
93f544a221 | ||
|
|
9c80ab22af | ||
|
|
7decbc34c7 | ||
|
|
e606276f19 | ||
|
|
a78e4d7a58 | ||
|
|
426c9a377a | ||
|
|
d2a3ae2a6f | ||
|
|
fbd6b7d22b | ||
|
|
a42375931f | ||
|
|
d894bff2a0 | ||
|
|
4515ed600c | ||
|
|
4df3cdd975 | ||
|
|
5fc0a0460d | ||
|
|
74851a859b | ||
|
|
9bb94513ca | ||
|
|
bb74aa7976 | ||
|
|
12318b38ee | ||
|
|
bb70c2a3fa | ||
|
|
b47180a219 | ||
|
|
4eb64357a1 | ||
|
|
0fe89115d1 | ||
|
|
330932adde | ||
|
|
b9daca5b9c | ||
|
|
c6c48d84ab | ||
|
|
2c87721953 | ||
|
|
45a446d0f6 | ||
|
|
40086434ec | ||
|
|
bde3f0a55c | ||
|
|
9adae105e2 | ||
|
|
60dbf9dd67 | ||
|
|
374309a40c | ||
|
|
dcccb5ad30 | ||
|
|
47eaee8b70 | ||
|
|
9687a9d8ff | ||
|
|
fa11295693 | ||
|
|
7e399cc10c | ||
|
|
59e0857bb5 | ||
|
|
4f9bd970af | ||
|
|
3e40a35c19 | ||
|
|
97799bfacc | ||
|
|
fb1a74a96d | ||
|
|
9f82e0a6d6 | ||
|
|
421e125882 | ||
|
|
17ede00fb2 | ||
|
|
502638bae7 | ||
|
|
af8a905150 | ||
|
|
6c2a228267 | ||
|
|
f9ecfd1ad0 | ||
|
|
2c3cbcb1f9 | ||
|
|
d1583ca091 | ||
|
|
3c21d97a8a | ||
|
|
8f7468cd60 | ||
|
|
6668e639d5 | ||
|
|
bcc689cae3 | ||
|
|
20173d544b | ||
|
|
e90d4cf86f | ||
|
|
1de02b85b3 | ||
|
|
dab43d9372 | ||
|
|
3b579a3b7b | ||
|
|
a4a5e0bdf0 | ||
|
|
9cb227c1ca | ||
|
|
c4c7321f60 | ||
|
|
cce27900b8 | ||
|
|
32f4d7be39 | ||
|
|
bbeb4e25f3 | ||
|
|
88f78f3e32 | ||
|
|
36581ba882 | ||
|
|
1a64b3ce8e | ||
|
|
32ee75ea43 | ||
|
|
06ebe0a9b3 | ||
|
|
6069518749 | ||
|
|
c09a9aa7d3 | ||
|
|
13afcb8a49 | ||
|
|
9bfff03cff | ||
|
|
8780debc90 | ||
|
|
6f386f50ff | ||
|
|
43eff08004 | ||
|
|
3a0b616800 | ||
|
|
cb65d02dc6 | ||
|
|
bef485c676 | ||
|
|
9e4d350848 | ||
|
|
ccc7a8010e | ||
|
|
7269c46de3 | ||
|
|
178df38377 | ||
|
|
1201f7138a | ||
|
|
9ff4be8871 | ||
|
|
0a17fb586c | ||
|
|
1f8713f57e | ||
|
|
507fc17701 | ||
|
|
26ad428b24 | ||
|
|
26af3a9d68 | ||
|
|
8ecf6ad78e | ||
|
|
45977efd5f | ||
|
|
c0b746e03f | ||
|
|
a13e4d5d79 | ||
|
|
e8f2f0f577 | ||
|
|
f56ba7295a | ||
|
|
8cdb1859e3 | ||
|
|
6bfc78e148 | ||
|
|
cc97ec332d | ||
|
|
f2e4dad318 | ||
|
|
9c45e9fa1a | ||
|
|
e1e2afc3cd | ||
|
|
b9ae226569 | ||
|
|
e23e5227a4 | ||
|
|
dd647dbb0b | ||
|
|
04794c38d8 | ||
|
|
8d868b77d0 | ||
|
|
3435f20baa | ||
|
|
7427507aca | ||
|
|
3d7784ca18 | ||
|
|
0414500c17 | ||
|
|
385ebb486e | ||
|
|
cbcc219f1f | ||
|
|
58e2bc2b6c | ||
|
|
c1e53c09d6 | ||
|
|
f7a6a10c7a | ||
|
|
e739aee95f | ||
|
|
1b6c2cdad1 | ||
|
|
e56d7e3aa0 | ||
|
|
354c4ff8db | ||
|
|
681b61e166 | ||
|
|
74c6c5d8cf | ||
|
|
8746df4907 | ||
|
|
acbd4c5c3e | ||
|
|
edd1571c4e | ||
|
|
8289dff3e8 | ||
|
|
d654bb5d16 | ||
|
|
b985796139 | ||
|
|
99fd7b275b | ||
|
|
161671e112 | ||
|
|
02a0173c91 | ||
|
|
4f7069a7c3 | ||
|
|
fa4e17c273 | ||
|
|
7edd20d179 | ||
|
|
f423d3a145 | ||
|
|
3aba961f5e | ||
|
|
d2cfb5e94f | ||
|
|
cb22c2cc7f | ||
|
|
3280123414 | ||
|
|
82be37b4af | ||
|
|
0e51a35842 | ||
|
|
86dc3762b6 | ||
|
|
edc341f024 | ||
|
|
f2bef879ce | ||
|
|
a5c6a8e0a9 | ||
|
|
641d2b0527 | ||
|
|
e7d129f2f7 | ||
|
|
bfc778f002 | ||
|
|
8d2d5504dd | ||
|
|
17f27e520c | ||
|
|
f8c1dabfd5 | ||
|
|
f3b6817aa7 | ||
|
|
61d405da68 | ||
|
|
d4be6b1de0 | ||
|
|
d199fc322e | ||
|
|
42ccdd1646 | ||
|
|
185652fb6e | ||
|
|
4a579863d1 | ||
|
|
882b2418d6 | ||
|
|
1dce202d21 | ||
|
|
2d5754c005 | ||
|
|
9f694fad8b | ||
|
|
9a2264c7f6 | ||
|
|
77497dbc28 | ||
|
|
1848d5dc96 | ||
|
|
6f5c66f324 | ||
|
|
296c95e800 | ||
|
|
6416c6b947 | ||
|
|
30320f6d84 | ||
|
|
b58d0f6663 | ||
|
|
56dc1b7e49 | ||
|
|
cef832fda4 | ||
|
|
7066fc3092 | ||
|
|
235f7c8aec | ||
|
|
f0ce728982 | ||
|
|
be7fe9610f | ||
|
|
49cd0d44ac | ||
|
|
45a053dfbf | ||
|
|
cf47abe849 | ||
|
|
6e97b08256 | ||
|
|
668706a6d9 | ||
|
|
68dc81ac96 | ||
|
|
58a099dbc7 | ||
|
|
740e65a791 | ||
|
|
d3aabadb66 | ||
|
|
571c93c610 | ||
|
|
168f9b54ba | ||
|
|
65e207648b | ||
|
|
cb6cb97326 | ||
|
|
450fa5311c | ||
|
|
4edd701c29 | ||
|
|
630aade97a | ||
|
|
c97098d60d | ||
|
|
7d0a555999 | ||
|
|
2c4d0d800c | ||
|
|
c7ed63a0e3 | ||
|
|
3cc69849db | ||
|
|
32ef25a868 | ||
|
|
437e8875d8 | ||
|
|
652e91586e | ||
|
|
4946a50ebd | ||
|
|
c69ecb768b | ||
|
|
88abb895ff | ||
|
|
09dd8f9828 | ||
|
|
7dd6c1a6cc | ||
|
|
9eda9b1399 | ||
|
|
e66e70f7f2 | ||
|
|
77213a0dbe | ||
|
|
73b1aa7c6c | ||
|
|
c43a7df781 | ||
|
|
97d6d1a5d2 | ||
|
|
925a674de6 | ||
|
|
297aef788c | ||
|
|
6ecc67c8cf | ||
|
|
0f4b26fa6f | ||
|
|
8704b01f4c | ||
|
|
5c3a69984a | ||
|
|
1dec510120 | ||
|
|
4da7fd2c87 | ||
|
|
143209307f | ||
|
|
e300f9087a | ||
|
|
26afab03ce | ||
|
|
2f3275474f | ||
|
|
41eff6de17 | ||
|
|
07bb0644b2 | ||
|
|
5b6c003888 | ||
|
|
d93e66665c | ||
|
|
f0c696d6fd | ||
|
|
9713864bb6 | ||
|
|
c6c59c63bb | ||
|
|
0a81e26e7e | ||
|
|
2c032d54c1 | ||
|
|
a635131f47 | ||
|
|
8edbbe27f8 | ||
|
|
db3c008c07 | ||
|
|
a20a06c994 | ||
|
|
fe1f4a4294 | ||
|
|
b4d2d21620 | ||
|
|
f6bba436f4 | ||
|
|
79aae8fb43 | ||
|
|
c34c0c49db | ||
|
|
59296f3045 | ||
|
|
df68ed33bc | ||
|
|
369eb7844d | ||
|
|
b3270ae7c8 | ||
|
|
995de2b740 | ||
|
|
be718ce4e0 | ||
|
|
63ce62a67d | ||
|
|
fc84c06346 | ||
|
|
3ccd5b52fa | ||
|
|
bd3f74c17b | ||
|
|
10e063b39e | ||
|
|
6876337f5f | ||
|
|
c43a654f8e | ||
|
|
40a7890b45 | ||
|
|
b8115fed70 | ||
|
|
b1f7a8e932 | ||
|
|
5514fbd113 | ||
|
|
2fe34b1b0d | ||
|
|
efb0050e57 | ||
|
|
cfd68f41eb | ||
|
|
5090b38f9c | ||
|
|
57ad6065d8 | ||
|
|
65b7c2d82f | ||
|
|
7863a5e09c | ||
|
|
94e3586555 | ||
|
|
ac14a22a43 | ||
|
|
14179f3bd3 | ||
|
|
988a2b8d29 | ||
|
|
9c38398ae3 | ||
|
|
c4226ea454 | ||
|
|
19668d1931 | ||
|
|
23c45ee219 | ||
|
|
ed5505e093 | ||
|
|
fb9f5a7584 | ||
|
|
825c2c1fe9 | ||
|
|
7c2a29edce | ||
|
|
26f44ea1f8 | ||
|
|
6dbdf336aa | ||
|
|
89d32db601 | ||
|
|
65f9b1c4ef | ||
|
|
6596431154 | ||
|
|
9bab8f0bdb | ||
|
|
892c27c945 | ||
|
|
bb762cfab6 | ||
|
|
9d296dd692 | ||
|
|
0da05a7dbe | ||
|
|
dab9b02990 | ||
|
|
5b4ceb27c5 | ||
|
|
51d06ec40d | ||
|
|
e7285573ac | ||
|
|
509e3284ed | ||
|
|
c8530bca75 | ||
|
|
b27d017174 | ||
|
|
963c7386b1 | ||
|
|
e032e6f217 | ||
|
|
00c5497d93 | ||
|
|
8ed62398fa | ||
|
|
fff87aec87 | ||
|
|
6ef71b9209 | ||
|
|
e401c8c930 | ||
|
|
ba9f034694 | ||
|
|
adbc906f9e | ||
|
|
3041af7fe2 | ||
|
|
23ce896681 | ||
|
|
5249624486 | ||
|
|
3f5024dc6d | ||
|
|
1afb971877 | ||
|
|
0d605cbc74 | ||
|
|
cc7c175b45 | ||
|
|
c6f48d1dc0 | ||
|
|
3ddde700fb | ||
|
|
22450519a4 | ||
|
|
9ece11ae9b | ||
|
|
c3796dcdb0 | ||
|
|
c0b9bb282c | ||
|
|
97a904e4b4 | ||
|
|
411875ac5f | ||
|
|
7b43cfc563 | ||
|
|
d6c250111a | ||
|
|
fdd70e4403 | ||
|
|
bcd7c29db4 | ||
|
|
d3c2315e2d | ||
|
|
a7c115cdf5 | ||
|
|
4bd5644258 | ||
|
|
5b98277f3c | ||
|
|
ddbd268a66 | ||
|
|
dd58685455 | ||
|
|
5ad3d7d077 | ||
|
|
3e0f420eec | ||
|
|
0f47a4988b | ||
|
|
0f9fe0367a | ||
|
|
b2b6654846 | ||
|
|
83c136174e | ||
|
|
e1e1eb4f51 | ||
|
|
61958a35c2 | ||
|
|
5558d6e149 | ||
|
|
3a56a16a58 | ||
|
|
e7ab96538c | ||
|
|
cbc57c3a77 | ||
|
|
2bcaf7d8a8 | ||
|
|
db80ebe6dd | ||
|
|
72217253be | ||
|
|
12ef314ab7 | ||
|
|
ce38f47bee | ||
|
|
36f0de888e | ||
|
|
e440f31cb5 | ||
|
|
94cd0fc5d1 | ||
|
|
ee9267775e | ||
|
|
885cdc8c97 | ||
|
|
9d347ecf74 | ||
|
|
23238a6ca0 | ||
|
|
9dc067564e | ||
|
|
7936e2d124 | ||
|
|
3e73fc03e6 | ||
|
|
ff19bab496 | ||
|
|
12c4ca5f08 | ||
|
|
7b0ab4ee83 | ||
|
|
1feb4d42b7 | ||
|
|
17ff0e8afc | ||
|
|
7fcbb83dbe | ||
|
|
8ee6c7114c | ||
|
|
ceb6134af2 | ||
|
|
0ff8b7edd8 | ||
|
|
8e73c5906d | ||
|
|
4216a71a85 | ||
|
|
64e857362f | ||
|
|
8e4bf1538d | ||
|
|
0ea60fa9d7 | ||
|
|
6667167b26 | ||
|
|
fd06046be5 | ||
|
|
f20d4cbed2 | ||
|
|
18e6981e9a | ||
|
|
d68d0b5dd8 | ||
|
|
3b81d00de7 | ||
|
|
dd6660a6cd | ||
|
|
8cb7dc7a7e | ||
|
|
dc5bb627ed | ||
|
|
4d5a0e7832 | ||
|
|
0e88818220 | ||
|
|
ea015bc2cf | ||
|
|
02fe7c97ca | ||
|
|
0cba323091 | ||
|
|
89e931bca6 | ||
|
|
ace7e67c00 | ||
|
|
1bcb811835 | ||
|
|
fba29249b0 | ||
|
|
496c36fde8 | ||
|
|
54ffeeaed9 | ||
|
|
828da2aabf | ||
|
|
a61d76deed | ||
|
|
2238fed1b7 | ||
|
|
50777faa02 | ||
|
|
157b4f9398 | ||
|
|
091ffdeb59 | ||
|
|
0b3846fc35 | ||
|
|
c2e0640ea8 | ||
|
|
3cd4b1b67e | ||
|
|
41edab3857 | ||
|
|
12dbf36358 | ||
|
|
d630d407ca | ||
|
|
8bdf3626f0 | ||
|
|
3def1a1e57 | ||
|
|
4fcb186022 | ||
|
|
7451c2701e | ||
|
|
098cd19b18 | ||
|
|
2827126be7 | ||
|
|
e6c2f729f4 | ||
|
|
7e443e7b8d | ||
|
|
d6bb790e26 | ||
|
|
2d3265136d | ||
|
|
11853962b7 | ||
|
|
c6ffa53f0b | ||
|
|
2544c9b483 | ||
|
|
8557159273 | ||
|
|
a4192cf061 | ||
|
|
d37491e95a | ||
|
|
e93e32d01c | ||
|
|
ff1030332c | ||
|
|
f48d17cb22 | ||
|
|
ca4b8fa5ec | ||
|
|
c155b8651f | ||
|
|
199c047c28 | ||
|
|
ff603b2fab | ||
|
|
949ff17776 | ||
|
|
de4f0f7d6f | ||
|
|
a23b0c5ec9 | ||
|
|
96000a8a72 | ||
|
|
b2ccf126ed | ||
|
|
b779577f9b | ||
|
|
21e2a7e2cd | ||
|
|
583356cf89 | ||
|
|
e96fdbf72f | ||
|
|
41906abaf9 | ||
|
|
ca6277f6e9 | ||
|
|
e98fabcc9d | ||
|
|
f5ad5b875e | ||
|
|
daa32e4355 | ||
|
|
95a33ba3c0 | ||
|
|
b28387bada | ||
|
|
93cf868dcf | ||
|
|
224cae6db2 | ||
|
|
0c44dd0e63 | ||
|
|
d60e795421 | ||
|
|
c6f2124e9d | ||
|
|
04f4933e97 | ||
|
|
fa5cd150d9 | ||
|
|
9469433143 | ||
|
|
881a015f68 | ||
|
|
8e27d877a1 | ||
|
|
eea3163f51 | ||
|
|
c1bcb73337 | ||
|
|
d8f0709bce | ||
|
|
40cad2e886 | ||
|
|
a8faf5d699 | ||
|
|
d7f26fa27c | ||
|
|
b379f89a7a | ||
|
|
10abb50971 | ||
|
|
e011c56715 | ||
|
|
d7abd3a8ed | ||
|
|
be447b4139 | ||
|
|
48613da57f | ||
|
|
ef111c36c0 | ||
|
|
765601bb75 | ||
|
|
e87789d92b | ||
|
|
a95acd5529 | ||
|
|
34bc4c9c8c | ||
|
|
e3d0a73459 | ||
|
|
93b5fc2236 | ||
|
|
8c25b59bed | ||
|
|
fb8f3d1d29 | ||
|
|
3f1007e904 | ||
|
|
916e855ed0 | ||
|
|
5b154d2544 | ||
|
|
6734dae956 | ||
|
|
6b844063b6 | ||
|
|
5313ce7843 | ||
|
|
34fa770748 | ||
|
|
ee1e0da156 | ||
|
|
48a310e0aa | ||
|
|
7ef610b702 | ||
|
|
29d9c9834a | ||
|
|
055b34fb46 | ||
|
|
858801502d | ||
|
|
f83d33754e | ||
|
|
a3c655ffc5 | ||
|
|
cf9f59304c | ||
|
|
cc089c245e | ||
|
|
c6062f453a | ||
|
|
414781936b | ||
|
|
0ce5307c0b | ||
|
|
313c624871 | ||
|
|
d8bbece02a | ||
|
|
bb483558b0 | ||
|
|
b6b88dff86 | ||
|
|
7f9ad04b57 | ||
|
|
c2eed44150 | ||
|
|
ebb1654d0e | ||
|
|
ff37050470 | ||
|
|
b0d804da08 | ||
|
|
4550c12c6e | ||
|
|
44a2e7df21 | ||
|
|
bed3c61142 | ||
|
|
44a45780b7 | ||
|
|
cedf6cc631 | ||
|
|
7281233012 | ||
|
|
4def18e882 | ||
|
|
03024ef7a9 | ||
|
|
9907f7f60f | ||
|
|
ebeabe2b54 | ||
|
|
0bc91349f6 | ||
|
|
23297c9860 | ||
|
|
086bd10f84 | ||
|
|
70cdc100d9 | ||
|
|
17c2ae1177 | ||
|
|
497a851ebe | ||
|
|
9a48547232 | ||
|
|
97dfd454b8 | ||
|
|
2d8317887d | ||
|
|
5dc4f0eae6 | ||
|
|
8849d482b0 | ||
|
|
bffb47645c | ||
|
|
4cafd83c25 | ||
|
|
db3bf4c12c | ||
|
|
fa44a5343b | ||
|
|
e5cc58b4e2 | ||
|
|
dbaee4d29b | ||
|
|
a6d1fd3d9f | ||
|
|
c8b3cdf01b | ||
|
|
5a53fbbb01 | ||
|
|
17885f6091 | ||
|
|
537ad1c1e5 | ||
|
|
a38c091d73 | ||
|
|
f723ca65d1 | ||
|
|
6d416cfe65 | ||
|
|
ea1bce4e7b | ||
|
|
6508ef4fce | ||
|
|
7b1c6807ba | ||
|
|
be8ee350cb | ||
|
|
99d26b794d | ||
|
|
b721bb4cfc | ||
|
|
8349204982 | ||
|
|
2cdd2a0a54 | ||
|
|
01a8d0f864 | ||
|
|
81e986db30 | ||
|
|
3dc3f1579b | ||
|
|
a7ed566645 | ||
|
|
2485f20d5c | ||
|
|
465468a5a3 | ||
|
|
930632e6fe | ||
|
|
0016b43c09 | ||
|
|
5391521c08 | ||
|
|
e7a3f6d17e | ||
|
|
074ac0b725 | ||
|
|
bde6d83625 | ||
|
|
bdfe86ba1a | ||
|
|
a8bb2f110b | ||
|
|
4147f2b8d8 | ||
|
|
a7edc5e03e | ||
|
|
1a40658345 | ||
|
|
124fd480b7 | ||
|
|
667cd64f3b | ||
|
|
2ae6d4c5a4 | ||
|
|
d9e33270b0 | ||
|
|
ad59080307 | ||
|
|
34fa9a1f01 | ||
|
|
cb19ed36bc | ||
|
|
039a5ac2e3 | ||
|
|
568ea271a4 | ||
|
|
a584a5c296 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -2,3 +2,5 @@
|
||||
|
||||
github: [eliandoran]
|
||||
custom: ["https://paypal.me/eliandoran"]
|
||||
liberapay: ElianDoran
|
||||
buy_me_a_coffee: eliandoran
|
||||
|
||||
2
.github/actions/build-electron/action.yml
vendored
2
.github/actions/build-electron/action.yml
vendored
@@ -85,7 +85,7 @@ runs:
|
||||
APPLE_ID: ${{ env.APPLE_ID }}
|
||||
APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }}
|
||||
WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }}
|
||||
TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
|
||||
TRILIUM_ARTIFACT_NAME_HINT: TriliumNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
|
||||
run: pnpm nx --project=desktop electron-forge:make -- --arch=${{ inputs.arch }} --platform=${{ inputs.forge_platform }}
|
||||
|
||||
# Add DMG signing step
|
||||
|
||||
2
.github/actions/build-server/action.yml
vendored
2
.github/actions/build-server/action.yml
vendored
@@ -30,4 +30,4 @@ runs:
|
||||
mkdir -p upload
|
||||
file=$(find ./apps/server/out -name '*.tar.xz' -print -quit)
|
||||
name=${{ github.ref_name }}
|
||||
cp "$file" "upload/TriliumNextNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz"
|
||||
cp "$file" "upload/TriliumNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz"
|
||||
|
||||
2
.github/actions/report-size/action.yml
vendored
2
.github/actions/report-size/action.yml
vendored
@@ -44,7 +44,7 @@ runs:
|
||||
steps:
|
||||
# Checkout branch to compare to [required]
|
||||
- name: Checkout base branch
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ inputs.branch }}
|
||||
path: br-base
|
||||
|
||||
40
.github/instructions/nx.instructions.md
vendored
Normal file
40
.github/instructions/nx.instructions.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
applyTo: '**'
|
||||
---
|
||||
|
||||
// This file is automatically generated by Nx Console
|
||||
|
||||
You are in an nx workspace using Nx 21.3.9 and pnpm as the package manager.
|
||||
|
||||
You have access to the Nx MCP server and the tools it provides. Use them. Follow these guidelines in order to best help the user:
|
||||
|
||||
# General Guidelines
|
||||
- When answering questions, use the nx_workspace tool first to gain an understanding of the workspace architecture
|
||||
- For questions around nx configuration, best practices or if you're unsure, use the nx_docs tool to get relevant, up-to-date docs!! Always use this instead of assuming things about nx configuration
|
||||
- If the user needs help with an Nx configuration or project graph error, use the 'nx_workspace' tool to get any errors
|
||||
- To help answer questions about the workspace structure or simply help with demonstrating how tasks depend on each other, use the 'nx_visualize_graph' tool
|
||||
|
||||
# Generation Guidelines
|
||||
If the user wants to generate something, use the following flow:
|
||||
|
||||
- learn about the nx workspace and any specifics the user needs by using the 'nx_workspace' tool and the 'nx_project_details' tool if applicable
|
||||
- get the available generators using the 'nx_generators' tool
|
||||
- decide which generator to use. If no generators seem relevant, check the 'nx_available_plugins' tool to see if the user could install a plugin to help them
|
||||
- get generator details using the 'nx_generator_schema' tool
|
||||
- you may use the 'nx_docs' tool to learn more about a specific generator or technology if you're unsure
|
||||
- decide which options to provide in order to best complete the user's request. Don't make any assumptions and keep the options minimalistic
|
||||
- open the generator UI using the 'nx_open_generate_ui' tool
|
||||
- wait for the user to finish the generator
|
||||
- read the generator log file using the 'nx_read_generator_log' tool
|
||||
- use the information provided in the log file to answer the user's question or continue with what they were doing
|
||||
|
||||
# Running Tasks Guidelines
|
||||
If the user wants help with tasks or commands (which include keywords like "test", "build", "lint", or other similar actions), use the following flow:
|
||||
- Use the 'nx_current_running_tasks_details' tool to get the list of tasks (this can include tasks that were completed, stopped or failed).
|
||||
- If there are any tasks, ask the user if they would like help with a specific task then use the 'nx_current_running_task_output' tool to get the terminal output for that task/command
|
||||
- Use the terminal output from 'nx_current_running_task_output' to see what's wrong and help the user fix their problem. Use the appropriate tools if necessary
|
||||
- If the user would like to rerun the task or command, always use `nx run <taskId>` to rerun in the terminal. This will ensure that the task will run in the nx context and will be run the same way it originally executed
|
||||
- If the task was marked as "continuous" do not offer to rerun the task. This task is already running and the user can see the output in the terminal. You can use 'nx_current_running_task_output' to get the output of the task to verify the output.
|
||||
|
||||
|
||||
|
||||
17
.github/workflows/checks.yml
vendored
Normal file
17
.github/workflows/checks.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: Checks
|
||||
on:
|
||||
push:
|
||||
pull_request_target:
|
||||
types: [synchronize]
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Check if PRs have conflicts
|
||||
uses: eps1lon/actions-label-merge-conflict@v3
|
||||
with:
|
||||
dirtyLabel: "merge-conflicts"
|
||||
repoToken: "${{ secrets.MERGE_CONFLICT_LABEL_PAT }}"
|
||||
6
.github/workflows/codeql.yml
vendored
6
.github/workflows/codeql.yml
vendored
@@ -13,9 +13,9 @@ name: "CodeQL Advanced"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "develop" ]
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "develop" ]
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '20 7 * * 0'
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
# Add any setup steps before running the `github/codeql-action/init` action.
|
||||
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
||||
|
||||
97
.github/workflows/dev.yml
vendored
97
.github/workflows/dev.yml
vendored
@@ -1,9 +1,9 @@
|
||||
name: Dev
|
||||
on:
|
||||
push:
|
||||
branches: [ develop ]
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
branches: [ main ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -12,8 +12,8 @@ concurrency:
|
||||
env:
|
||||
GHCR_REGISTRY: ghcr.io
|
||||
DOCKERHUB_REGISTRY: docker.io
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/notes
|
||||
TEST_TAG: ${{ github.repository_owner }}/notes:test
|
||||
IMAGE_NAME: ${{ github.repository}}
|
||||
TEST_TAG: ${{ github.repository}}:test
|
||||
|
||||
permissions:
|
||||
pull-requests: write # for PR comments
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0 # needed for https://github.com/marketplace/actions/nx-set-shas
|
||||
|
||||
@@ -39,76 +39,7 @@ jobs:
|
||||
|
||||
- uses: nrwl/nx-set-shas@v4
|
||||
- name: Check affected
|
||||
run: pnpm nx affected --verbose -t typecheck build rebuild-deps
|
||||
|
||||
report-electron-size:
|
||||
name: Report Electron size
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- check-affected
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run the build
|
||||
uses: ./.github/actions/build-electron
|
||||
with:
|
||||
os: linux
|
||||
arch: x64
|
||||
shell: bash
|
||||
forge_platform: linux
|
||||
|
||||
- name: Run the Electron size report
|
||||
uses: ./.github/actions/report-size
|
||||
with:
|
||||
paths: 'upload/**/*'
|
||||
onlyDiff: 'true'
|
||||
branch: 'develop'
|
||||
header: 'Electron size report'
|
||||
unit: "MB"
|
||||
ghToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
report-server-size:
|
||||
name: Report server size
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- check-affected
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: "pnpm"
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run the build
|
||||
uses: ./.github/actions/build-server
|
||||
with:
|
||||
os: linux
|
||||
arch: x64
|
||||
|
||||
- name: Run the server size report
|
||||
uses: ./.github/actions/report-size
|
||||
with:
|
||||
paths: 'upload/**/*'
|
||||
onlyDiff: 'true'
|
||||
branch: 'develop'
|
||||
header: 'Server size report'
|
||||
unit: "MB"
|
||||
ghToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: pnpm nx affected --verbose -t typecheck build rebuild-deps test-build
|
||||
|
||||
test_dev:
|
||||
name: Test development
|
||||
@@ -117,7 +48,7 @@ jobs:
|
||||
- check-affected
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Set up node & dependencies
|
||||
@@ -137,13 +68,21 @@ jobs:
|
||||
- test_dev
|
||||
- check-affected
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Update build info
|
||||
run: pnpm run chore:update-build-info
|
||||
- name: Trigger build
|
||||
- name: Trigger client build
|
||||
run: pnpm nx run client:build
|
||||
- name: Send client bundle stats to RelativeCI
|
||||
if: false
|
||||
uses: relative-ci/agent-action@v3
|
||||
with:
|
||||
webpackStatsFile: ./apps/client/dist/webpack-stats.json
|
||||
key: ${{ secrets.RELATIVE_CI_CLIENT_KEY }}
|
||||
- name: Trigger server build
|
||||
run: pnpm nx run server:build
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/build-push-action@v6
|
||||
@@ -164,7 +103,7 @@ jobs:
|
||||
- dockerfile: Dockerfile
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Install dependencies
|
||||
|
||||
24
.github/workflows/main-docker.yml
vendored
24
.github/workflows/main-docker.yml
vendored
@@ -1,7 +1,7 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "develop"
|
||||
- "main"
|
||||
- "feature/update**"
|
||||
- "feature/server_esm**"
|
||||
paths-ignore:
|
||||
@@ -14,8 +14,8 @@ on:
|
||||
env:
|
||||
GHCR_REGISTRY: ghcr.io
|
||||
DOCKERHUB_REGISTRY: docker.io
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/notes
|
||||
TEST_TAG: ${{ github.repository_owner }}/notes:test
|
||||
IMAGE_NAME: ${{ github.repository}}
|
||||
TEST_TAG: ${{ github.repository}}:test
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
- dockerfile: Dockerfile
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Set IMAGE_NAME to lowercase
|
||||
run: echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
run: pnpx playwright install --with-deps
|
||||
run: pnpm exec playwright install --with-deps
|
||||
|
||||
- name: Run the TypeScript build
|
||||
run: pnpm run server:build
|
||||
@@ -82,7 +82,15 @@ jobs:
|
||||
require-healthy: true
|
||||
|
||||
- name: Run Playwright tests
|
||||
run: TRILIUM_DOCKER=1 TRILIUM_PORT=8082 pnpx nx run server-e2e:e2e
|
||||
run: TRILIUM_DOCKER=1 TRILIUM_PORT=8082 pnpm exec nx run server-e2e:e2e
|
||||
|
||||
- name: Upload Playwright trace
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Playwright trace (${{ matrix.dockerfile }})
|
||||
path: test-output/playwright/output
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
@@ -133,7 +141,7 @@ jobs:
|
||||
run: echo "TEST_TAG=${TEST_TAG,,}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
@@ -215,7 +223,7 @@ jobs:
|
||||
- build
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digests-*
|
||||
|
||||
15
.github/workflows/nightly.yml
vendored
15
.github/workflows/nightly.yml
vendored
@@ -11,7 +11,8 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/actions/build-electron/*
|
||||
- forge.config.cjs
|
||||
- .github/workflows/nightly.yml
|
||||
- forge.config.ts
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -26,6 +27,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
nightly-electron:
|
||||
if: github.repository == 'TriliumNext/Trilium'
|
||||
name: Deploy nightly
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -46,7 +48,7 @@ jobs:
|
||||
forge_platform: win32
|
||||
runs-on: ${{ matrix.os.image }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
@@ -76,7 +78,7 @@ jobs:
|
||||
WINDOWS_SIGN_EXECUTABLE: ${{ vars.WINDOWS_SIGN_EXECUTABLE }}
|
||||
|
||||
- name: Publish release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
with:
|
||||
make_latest: false
|
||||
@@ -91,10 +93,11 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
with:
|
||||
name: TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}
|
||||
name: TriliumNotes ${{ matrix.os.name }} ${{ matrix.arch }}
|
||||
path: apps/desktop/upload
|
||||
|
||||
nightly-server:
|
||||
if: github.repository == 'TriliumNext/Trilium'
|
||||
name: Deploy server nightly
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -107,7 +110,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Run the build
|
||||
uses: ./.github/actions/build-server
|
||||
@@ -116,7 +119,7 @@ jobs:
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
- name: Publish release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
with:
|
||||
make_latest: false
|
||||
|
||||
8
.github/workflows/playwright.yml
vendored
8
.github/workflows/playwright.yml
vendored
@@ -3,7 +3,7 @@ name: playwright
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
filter: tree:0
|
||||
fetch-depth: 0
|
||||
@@ -33,11 +33,11 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- run: pnpx playwright install --with-deps
|
||||
- run: pnpm exec playwright install --with-deps
|
||||
- uses: nrwl/nx-set-shas@v4
|
||||
|
||||
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
|
||||
# - run: npx nx-cloud record -- echo Hello World
|
||||
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
|
||||
# When you enable task distribution, run the e2e-ci task instead of e2e
|
||||
- run: pnpx nx affected -t e2e
|
||||
- run: pnpm exec nx affected -t e2e --exclude desktop-e2e
|
||||
|
||||
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
shell: bash
|
||||
forge_platform: darwin
|
||||
- name: linux
|
||||
image: ubuntu-latest
|
||||
image: ubuntu-22.04
|
||||
shell: bash
|
||||
forge_platform: linux
|
||||
- name: windows
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
forge_platform: win32
|
||||
runs-on: ${{ matrix.os.image }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Run the build
|
||||
uses: ./.github/actions/build-server
|
||||
@@ -101,26 +101,26 @@ jobs:
|
||||
steps:
|
||||
- run: mkdir upload
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
sparse-checkout: |
|
||||
docs/Release Notes
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
merge-multiple: true
|
||||
pattern: release-*
|
||||
path: upload
|
||||
|
||||
- name: Publish stable release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
with:
|
||||
draft: false
|
||||
body_path: docs/Release Notes/Release Notes/${{ github.ref_name }}.md
|
||||
fail_on_unmatched_files: true
|
||||
files: upload/*.*
|
||||
discussion_category_name: Announcements
|
||||
discussion_category_name: Releases
|
||||
make_latest: ${{ !contains(github.ref, 'rc') }}
|
||||
prerelease: ${{ !contains(github.ref, 'rc') }}
|
||||
prerelease: ${{ contains(github.ref, 'rc') }}
|
||||
token: ${{ secrets.RELEASE_PAT }}
|
||||
|
||||
11
.github/workflows/unblock_signing.yml
vendored
Normal file
11
.github/workflows/unblock_signing.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: Unblock signing
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
unblock-win-signing:
|
||||
runs-on: win-signing
|
||||
steps:
|
||||
- run: |
|
||||
cat ${{ vars.WINDOWS_SIGN_ERROR_LOG }}
|
||||
rm ${{ vars.WINDOWS_SIGN_ERROR_LOG }}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,6 +10,7 @@ node_modules
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
@@ -46,3 +47,4 @@ upload
|
||||
*.tsbuildinfo
|
||||
|
||||
/result
|
||||
.svelte-kit
|
||||
6
.idea/.gitignore
generated
vendored
6
.idea/.gitignore
generated
vendored
@@ -1,6 +0,0 @@
|
||||
# Default ignored files
|
||||
/workspace.xml
|
||||
|
||||
# Datasource local storage ignored files
|
||||
/dataSources.local.xml
|
||||
/dataSources/
|
||||
15
.idea/codeStyles/Project.xml
generated
15
.idea/codeStyles/Project.xml
generated
@@ -1,15 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="OTHER_INDENT_OPTIONS">
|
||||
<value>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
5
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
12
.idea/dataSources.xml
generated
12
.idea/dataSources.xml
generated
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="document.db" uuid="2a4ac1e6-b828-4a2a-8e4a-3f59f10aff26">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/data/document.db</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
4
.idea/encodings.xml
generated
4
.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
||||
15
.idea/git_toolbox_prj.xml
generated
15
.idea/git_toolbox_prj.xml
generated
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitToolBoxProjectSettings">
|
||||
<option name="commitMessageIssueKeyValidationOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
<option name="commitMessageValidationEnabledOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
11
.idea/inspectionProfiles/Project_Default.xml
generated
11
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,11 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
6
.idea/jsLibraryMappings.xml
generated
6
.idea/jsLibraryMappings.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<includedPredefinedLibrary name="Node.js Core" />
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/jsLinters/jslint.xml
generated
9
.idea/jsLinters/jslint.xml
generated
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JSLintConfiguration">
|
||||
<option devel="true" />
|
||||
<option es6="true" />
|
||||
<option maxerr="50" />
|
||||
<option node="true" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/misc.xml
generated
8
.idea/misc.xml
generated
@@ -1,8 +0,0 @@
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/trilium.iml" filepath="$PROJECT_DIR$/trilium.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/sqldialects.xml
generated
7
.idea/sqldialects.xml
generated
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$" dialect="SQLite" />
|
||||
<file url="PROJECT" dialect="SQLite" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
4
.mailmap
4
.mailmap
@@ -1,2 +1,2 @@
|
||||
Adam Zivner <adam.zivner@gmail.com>
|
||||
Adam Zivner <zadam.apps@gmail.com>
|
||||
zadam <adam.zivner@gmail.com>
|
||||
zadam <zadam.apps@gmail.com>
|
||||
@@ -1,7 +1,2 @@
|
||||
_regroup
|
||||
_regroup_monorepo
|
||||
|
||||
# Asset copying respects .gitignore / .nxignore for some reason.
|
||||
# See https://github.com/nrwl/nx/issues/20309
|
||||
!dist
|
||||
!node_modules
|
||||
4
.vscode/extensions.json
vendored
4
.vscode/extensions.json
vendored
@@ -9,6 +9,8 @@
|
||||
"redhat.vscode-yaml",
|
||||
"tobermory.es6-string-html",
|
||||
"vitest.explorer",
|
||||
"yzhang.markdown-all-in-one"
|
||||
"yzhang.markdown-all-in-one",
|
||||
"svelte.svelte-vscode",
|
||||
"bradlc.vscode-tailwindcss"
|
||||
]
|
||||
}
|
||||
|
||||
2
.vscode/i18n-ally-custom-framework.yml
vendored
2
.vscode/i18n-ally-custom-framework.yml
vendored
@@ -3,6 +3,7 @@
|
||||
languageIds:
|
||||
- javascript
|
||||
- typescript
|
||||
- typescriptreact
|
||||
- html
|
||||
|
||||
# An array of RegExes to find the key usage. **The key should be captured in the first match group**.
|
||||
@@ -25,6 +26,7 @@ scopeRangeRegex: "useTranslation\\(\\s*\\[?\\s*['\"`](.*?)['\"`]"
|
||||
# The "$1" will be replaced by the keypath specified.
|
||||
refactorTemplates:
|
||||
- t("$1")
|
||||
- {t("$1")}
|
||||
- ${t("$1")}
|
||||
- <%= t("$1") %>
|
||||
|
||||
|
||||
8
.vscode/mcp.json
vendored
Normal file
8
.vscode/mcp.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"servers": {
|
||||
"nx-mcp": {
|
||||
"type": "http",
|
||||
"url": "http://localhost:9461/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@@ -28,5 +28,13 @@
|
||||
"typescript.validate.enable": true,
|
||||
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
"docs/**/*.html": true,
|
||||
"docs/**/*.png": true,
|
||||
"apps/server/src/assets/doc_notes/**": true,
|
||||
"apps/edit-docs/demo/**": true
|
||||
},
|
||||
"nxConsole.generateAiAgentRules": true
|
||||
}
|
||||
161
CLAUDE.md
Normal file
161
CLAUDE.md
Normal file
@@ -0,0 +1,161 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Overview
|
||||
|
||||
Trilium Notes is a hierarchical note-taking application with advanced features like synchronization, scripting, and rich text editing. It's built as a TypeScript monorepo using NX, with multiple applications and shared packages.
|
||||
|
||||
## Development Commands
|
||||
|
||||
### Setup
|
||||
- `pnpm install` - Install all dependencies
|
||||
- `corepack enable` - Enable pnpm if not available
|
||||
|
||||
### Running Applications
|
||||
- `pnpm run server:start` - Start development server (http://localhost:8080)
|
||||
- `pnpm nx run server:serve` - Alternative server start command
|
||||
- `pnpm nx run desktop:serve` - Run desktop Electron app
|
||||
- `pnpm run server:start-prod` - Run server in production mode
|
||||
|
||||
### Building
|
||||
- `pnpm nx build <project>` - Build specific project (server, client, desktop, etc.)
|
||||
- `pnpm run client:build` - Build client application
|
||||
- `pnpm run server:build` - Build server application
|
||||
- `pnpm run electron:build` - Build desktop application
|
||||
|
||||
### Testing
|
||||
- `pnpm test:all` - Run all tests (parallel + sequential)
|
||||
- `pnpm test:parallel` - Run tests that can run in parallel
|
||||
- `pnpm test:sequential` - Run tests that must run sequentially (server, ckeditor5-mermaid, ckeditor5-math)
|
||||
- `pnpm nx test <project>` - Run tests for specific project
|
||||
- `pnpm coverage` - Generate coverage reports
|
||||
|
||||
### Linting & Type Checking
|
||||
- `pnpm nx run <project>:lint` - Lint specific project
|
||||
- `pnpm nx run <project>:typecheck` - Type check specific project
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
### Monorepo Structure
|
||||
- **apps/**: Runnable applications
|
||||
- `client/` - Frontend application (shared by server and desktop)
|
||||
- `server/` - Node.js server with web interface
|
||||
- `desktop/` - Electron desktop application
|
||||
- `web-clipper/` - Browser extension for saving web content
|
||||
- Additional tools: `db-compare`, `dump-db`, `edit-docs`
|
||||
|
||||
- **packages/**: Shared libraries
|
||||
- `commons/` - Shared interfaces and utilities
|
||||
- `ckeditor5/` - Custom rich text editor with Trilium-specific plugins
|
||||
- `codemirror/` - Code editor customizations
|
||||
- `highlightjs/` - Syntax highlighting
|
||||
- Custom CKEditor plugins: `ckeditor5-admonition`, `ckeditor5-footnotes`, `ckeditor5-math`, `ckeditor5-mermaid`
|
||||
|
||||
### Core Architecture Patterns
|
||||
|
||||
#### Three-Layer Cache System
|
||||
- **Becca** (Backend Cache): Server-side entity cache (`apps/server/src/becca/`)
|
||||
- **Froca** (Frontend Cache): Client-side mirror of backend data (`apps/client/src/services/froca.ts`)
|
||||
- **Shaca** (Share Cache): Optimized cache for shared/published notes (`apps/server/src/share/`)
|
||||
|
||||
#### Entity System
|
||||
Core entities are defined in `apps/server/src/becca/entities/`:
|
||||
- `BNote` - Notes with content and metadata
|
||||
- `BBranch` - Hierarchical relationships between notes (allows multiple parents)
|
||||
- `BAttribute` - Key-value metadata attached to notes
|
||||
- `BRevision` - Note version history
|
||||
- `BOption` - Application configuration
|
||||
|
||||
#### Widget-Based UI
|
||||
Frontend uses a widget system (`apps/client/src/widgets/`):
|
||||
- `BasicWidget` - Base class for all UI components
|
||||
- `NoteContextAwareWidget` - Widgets that respond to note changes
|
||||
- `RightPanelWidget` - Widgets displayed in the right panel
|
||||
- Type-specific widgets in `type_widgets/` directory
|
||||
|
||||
#### API Architecture
|
||||
- **Internal API**: REST endpoints in `apps/server/src/routes/api/`
|
||||
- **ETAPI**: External API for third-party integrations (`apps/server/src/etapi/`)
|
||||
- **WebSocket**: Real-time synchronization (`apps/server/src/services/ws.ts`)
|
||||
|
||||
### Key Files for Understanding Architecture
|
||||
|
||||
1. **Application Entry Points**:
|
||||
- `apps/server/src/main.ts` - Server startup
|
||||
- `apps/client/src/desktop.ts` - Client initialization
|
||||
|
||||
2. **Core Services**:
|
||||
- `apps/server/src/becca/becca.ts` - Backend data management
|
||||
- `apps/client/src/services/froca.ts` - Frontend data synchronization
|
||||
- `apps/server/src/services/backend_script_api.ts` - Scripting API
|
||||
|
||||
3. **Database Schema**:
|
||||
- `apps/server/src/assets/db/schema.sql` - Core database structure
|
||||
|
||||
4. **Configuration**:
|
||||
- `nx.json` - NX workspace configuration
|
||||
- `package.json` - Project dependencies and scripts
|
||||
|
||||
## Note Types and Features
|
||||
|
||||
Trilium supports multiple note types, each with specialized widgets:
|
||||
- **Text**: Rich text with CKEditor5 (markdown import/export)
|
||||
- **Code**: Syntax-highlighted code editing with CodeMirror
|
||||
- **File**: Binary file attachments
|
||||
- **Image**: Image display with editing capabilities
|
||||
- **Canvas**: Drawing/diagramming with Excalidraw
|
||||
- **Mermaid**: Diagram generation
|
||||
- **Relation Map**: Visual note relationship mapping
|
||||
- **Web View**: Embedded web pages
|
||||
- **Doc/Book**: Hierarchical documentation structure
|
||||
|
||||
## Development Guidelines
|
||||
|
||||
### Testing Strategy
|
||||
- Server tests run sequentially due to shared database
|
||||
- Client tests can run in parallel
|
||||
- E2E tests use Playwright for both server and desktop apps
|
||||
- Build validation tests check artifact integrity
|
||||
|
||||
### Scripting System
|
||||
Trilium provides powerful user scripting capabilities:
|
||||
- Frontend scripts run in browser context
|
||||
- Backend scripts run in Node.js context with full API access
|
||||
- Script API documentation available in `docs/Script API/`
|
||||
|
||||
### Internationalization
|
||||
- Translation files in `apps/client/src/translations/`
|
||||
- Supported languages: English, German, Spanish, French, Romanian, Chinese
|
||||
|
||||
### Security Considerations
|
||||
- Per-note encryption with granular protected sessions
|
||||
- CSRF protection for API endpoints
|
||||
- OpenID and TOTP authentication support
|
||||
- Sanitization of user-generated content
|
||||
|
||||
## Common Development Tasks
|
||||
|
||||
### Adding New Note Types
|
||||
1. Create widget in `apps/client/src/widgets/type_widgets/`
|
||||
2. Register in `apps/client/src/services/note_types.ts`
|
||||
3. Add backend handling in `apps/server/src/services/notes.ts`
|
||||
|
||||
### Extending Search
|
||||
- Search expressions handled in `apps/server/src/services/search/`
|
||||
- Add new search operators in search context files
|
||||
|
||||
### Custom CKEditor Plugins
|
||||
- Create new package in `packages/` following existing plugin structure
|
||||
- Register in `packages/ckeditor5/src/plugins.ts`
|
||||
|
||||
### Database Migrations
|
||||
- Add migration scripts in `apps/server/src/migrations/`
|
||||
- Update schema in `apps/server/src/assets/db/schema.sql`
|
||||
|
||||
## Build System Notes
|
||||
- Uses NX for monorepo management with build caching
|
||||
- Vite for fast development builds
|
||||
- ESBuild for production optimization
|
||||
- pnpm workspaces for dependency management
|
||||
- Docker support with multi-stage builds
|
||||
37
README.md
37
README.md
@@ -1,10 +1,13 @@
|
||||
# TriliumNext Notes
|
||||
# Trilium Notes
|
||||
|
||||
  
|
||||
 
|
||||

|
||||

|
||||
[](https://app.relative-ci.com/projects/Di5q7dz9daNDZ9UXi0Bp) [](https://hosted.weblate.org/engage/trilium/)
|
||||
|
||||
[English](./README.md) | [Chinese](./docs/README-ZH_CN.md) | [Russian](./docs/README.ru.md) | [Japanese](./docs/README.ja.md) | [Italian](./docs/README.it.md) | [Spanish](./docs/README.es.md)
|
||||
|
||||
TriliumNext Notes is a free and open-source, cross-platform hierarchical note taking application with focus on building large personal knowledge bases.
|
||||
Trilium Notes is a free and open-source, cross-platform hierarchical note taking application with focus on building large personal knowledge bases.
|
||||
|
||||
See [screenshots](https://triliumnext.github.io/Docs/Wiki/screenshot-tour) for quick overview:
|
||||
|
||||
@@ -19,7 +22,7 @@ See [screenshots](https://triliumnext.github.io/Docs/Wiki/screenshot-tour) for q
|
||||
* Seamless [note versioning](https://triliumnext.github.io/Docs/Wiki/note-revisions)
|
||||
* Note [attributes](https://triliumnext.github.io/Docs/Wiki/attributes) can be used for note organization, querying and advanced [scripting](https://triliumnext.github.io/Docs/Wiki/scripts)
|
||||
* UI available in English, German, Spanish, French, Romanian, and Chinese (simplified and traditional)
|
||||
* Direct [OpenID and TOTP integration](.docs/User%20Guide/User%20Guide/Installation%20%26%20Setup/Server%20Installation/Multi-Factor%20Authentication.md") for more secure login
|
||||
* Direct [OpenID and TOTP integration](./docs/User%20Guide/User%20Guide/Installation%20%26%20Setup/Server%20Installation/Multi-Factor%20Authentication.md) for more secure login
|
||||
* [Synchronization](https://triliumnext.github.io/Docs/Wiki/synchronization) with self-hosted sync server
|
||||
* there's a [3rd party service for hosting synchronisation server](https://trilium.cc/paid-hosting)
|
||||
* [Sharing](https://triliumnext.github.io/Docs/Wiki/sharing) (publishing) notes to public internet
|
||||
@@ -79,7 +82,7 @@ Feel free to join our official conversations. We would love to hear what feature
|
||||
|
||||
### Windows / MacOS
|
||||
|
||||
Download the binary release for your platform from the [latest release page](https://github.com/TriliumNext/Notes/releases/latest), unzip the package and run the `trilium` executable.
|
||||
Download the binary release for your platform from the [latest release page](https://github.com/TriliumNext/Trilium/releases/latest), unzip the package and run the `trilium` executable.
|
||||
|
||||
### Linux
|
||||
|
||||
@@ -87,7 +90,7 @@ If your distribution is listed in the table below, use your distribution's packa
|
||||
|
||||
[](https://repology.org/project/triliumnext/versions)
|
||||
|
||||
You may also download the binary release for your platform from the [latest release page](https://github.com/TriliumNext/Notes/releases/latest), unzip the package and run the `trilium` executable.
|
||||
You may also download the binary release for your platform from the [latest release page](https://github.com/TriliumNext/Trilium/releases/latest), unzip the package and run the `trilium` executable.
|
||||
|
||||
TriliumNext is also provided as a Flatpak, but not yet published on FlatHub.
|
||||
|
||||
@@ -112,12 +115,20 @@ To install TriliumNext on your own server (including via Docker from [Dockerhub]
|
||||
|
||||
## 💻 Contribute
|
||||
|
||||
### Translations
|
||||
|
||||
If you are a native speaker, help us translate Trilium by heading over to our [Weblate page](https://hosted.weblate.org/engage/trilium/).
|
||||
|
||||
Here's the language coverage we have so far:
|
||||
|
||||
[](https://hosted.weblate.org/engage/trilium/)
|
||||
|
||||
### Code
|
||||
|
||||
Download the repository, install dependencies using `pnpm` and then run the server (available at http://localhost:8080):
|
||||
```shell
|
||||
git clone https://github.com/TriliumNext/Notes.git
|
||||
cd Notes
|
||||
git clone https://github.com/TriliumNext/Trilium.git
|
||||
cd Trilium
|
||||
pnpm install
|
||||
pnpm run server:start
|
||||
```
|
||||
@@ -126,8 +137,8 @@ pnpm run server:start
|
||||
|
||||
Download the repository, install dependencies using `pnpm` and then run the environment required to edit the documentation:
|
||||
```shell
|
||||
git clone https://github.com/TriliumNext/Notes.git
|
||||
cd Notes
|
||||
git clone https://github.com/TriliumNext/Trilium.git
|
||||
cd Trilium
|
||||
pnpm install
|
||||
pnpm nx run edit-docs:edit-docs
|
||||
```
|
||||
@@ -135,8 +146,8 @@ pnpm nx run edit-docs:edit-docs
|
||||
### Building the Executable
|
||||
Download the repository, install dependencies using `pnpm` and then build the desktop app for Windows:
|
||||
```shell
|
||||
git clone https://github.com/TriliumNext/Notes.git
|
||||
cd Notes
|
||||
git clone https://github.com/TriliumNext/Trilium.git
|
||||
cd Trilium
|
||||
pnpm install
|
||||
pnpm nx --project=desktop electron-forge:make -- --arch=x64 --platform=win32
|
||||
```
|
||||
@@ -150,7 +161,7 @@ Please view the [documentation guide](./docs/Developer%20Guide/Developer%20Guide
|
||||
## 👏 Shoutouts
|
||||
|
||||
* [CKEditor 5](https://github.com/ckeditor/ckeditor5) - best WYSIWYG editor on the market, very interactive and listening team
|
||||
* [FancyTree](https://github.com/mar10/fancytree) - very feature rich tree library without real competition. TriliumNext Notes would not be the same without it.
|
||||
* [FancyTree](https://github.com/mar10/fancytree) - very feature rich tree library without real competition. Trilium Notes would not be the same without it.
|
||||
* [CodeMirror](https://github.com/codemirror/CodeMirror) - code editor with support for huge amount of languages
|
||||
* [jsPlumb](https://github.com/jsplumb/jsplumb) - visual connectivity library without competition. Used in [relation maps](https://triliumnext.github.io/Docs/Wiki/relation-map.html) and [link maps](https://triliumnext.github.io/Docs/Wiki/note-map.html#link-map)
|
||||
|
||||
|
||||
@@ -91,5 +91,5 @@ async function start() {
|
||||
}
|
||||
|
||||
// @TriliumNextTODO sqlInit.dbReady never seems to resolve so program hangs
|
||||
// see https://github.com/TriliumNext/Notes/issues/1020
|
||||
// see https://github.com/TriliumNext/Trilium/issues/1020
|
||||
sqlInit.dbReady.then(cls.wrap(start)).catch((err) => console.error(err));
|
||||
|
||||
@@ -24,7 +24,7 @@ if ! git diff-index --quiet HEAD --; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASE_BRANCH=master
|
||||
BASE_BRANCH=main
|
||||
|
||||
if [[ "$VERSION" == *"beta"* ]]; then
|
||||
BASE_BRANCH=beta
|
||||
|
||||
@@ -47,11 +47,3 @@ echo "Tagging commit with $TAG"
|
||||
|
||||
git tag $TAG
|
||||
git push origin $TAG
|
||||
|
||||
echo "Updating master"
|
||||
|
||||
git fetch
|
||||
git checkout master
|
||||
git reset --hard origin/master
|
||||
git merge origin/develop
|
||||
git push
|
||||
@@ -25,9 +25,10 @@ stats() {
|
||||
# Print the number of existing strings on the JSON files for each locale
|
||||
s=$(number_of_keys "${paths[0]}/en/server.json")
|
||||
c=$(number_of_keys "${paths[1]}/en/translation.json")
|
||||
echo "| locale |server strings |client strings |"
|
||||
echo "|--------|---------------|---------------|"
|
||||
echo "| locale | server strings | client strings |"
|
||||
echo "|--------|----------------|----------------|"
|
||||
echo "| en | ${s} | ${c} |"
|
||||
echo "|--------|----------------|----------------|"
|
||||
for locale in "${locales[@]}"; do
|
||||
s=$(number_of_keys "${paths[0]}/${locale}/server.json")
|
||||
c=$(number_of_keys "${paths[1]}/${locale}/translation.json")
|
||||
@@ -78,7 +79,10 @@ file_path="$(
|
||||
cd -- "$(dirname "${0}")" >/dev/null 2>&1 || exit
|
||||
pwd -P
|
||||
)"
|
||||
paths=("${file_path}/../translations/" "${file_path}/../src/public/translations/")
|
||||
paths=(
|
||||
"${file_path}/../../apps/server/src/assets/translations/"
|
||||
"${file_path}/../../apps/client/src/translations/"
|
||||
)
|
||||
locales=(cn de es fr pt_br ro tw)
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
|
||||
@@ -44,7 +44,6 @@ export default tseslint.config(
|
||||
"dist/*",
|
||||
"docs/*",
|
||||
"demo/*",
|
||||
"libraries/*",
|
||||
"src/public/app-dist/*",
|
||||
"src/public/app/doc_notes/*"
|
||||
]
|
||||
|
||||
@@ -38,7 +38,6 @@ export default [
|
||||
"dist/*",
|
||||
"docs/*",
|
||||
"demo/*",
|
||||
"libraries/*",
|
||||
// TriliumNextTODO: check if we want to format packages here as well - for now skipping it
|
||||
"packages/*",
|
||||
"src/public/app-dist/*",
|
||||
|
||||
@@ -8,5 +8,5 @@ test("Displays update badge when there is a version available", async ({ page })
|
||||
await page.getByText(`Version ${expectedVersion} is available,`).click();
|
||||
|
||||
const page1 = await page.waitForEvent("popup");
|
||||
expect(page1.url()).toBe(`https://github.com/TriliumNext/Notes/releases/tag/v${expectedVersion}`);
|
||||
expect(page1.url()).toBe(`https://github.com/TriliumNext/Trilium/releases/tag/v${expectedVersion}`);
|
||||
});
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
"chore:generate-openapi": "tsx bin/generate-openapi.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.52.0",
|
||||
"@stylistic/eslint-plugin": "4.4.1",
|
||||
"@types/express": "5.0.1",
|
||||
"@types/node": "22.15.30",
|
||||
"@playwright/test": "1.54.2",
|
||||
"@stylistic/eslint-plugin": "5.2.3",
|
||||
"@types/express": "5.0.3",
|
||||
"@types/node": "22.17.1",
|
||||
"@types/yargs": "17.0.33",
|
||||
"@vitest/coverage-v8": "3.2.2",
|
||||
"eslint": "9.28.0",
|
||||
"@vitest/coverage-v8": "3.2.4",
|
||||
"eslint": "9.33.0",
|
||||
"eslint-plugin-simple-import-sort": "12.1.1",
|
||||
"esm": "3.2.25",
|
||||
"jsdoc": "4.0.4",
|
||||
@@ -49,8 +49,8 @@
|
||||
"rcedit": "4.0.1",
|
||||
"rimraf": "6.0.1",
|
||||
"tslib": "2.8.1",
|
||||
"typedoc": "0.28.5",
|
||||
"typedoc-plugin-missing-exports": "4.0.0"
|
||||
"typedoc": "0.28.10",
|
||||
"typedoc-plugin-missing-exports": "4.1.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"appdmg": "0.6.6"
|
||||
|
||||
5
apps/client/.env
Normal file
5
apps/client/.env
Normal file
@@ -0,0 +1,5 @@
|
||||
# The development license key for premium CKEditor features.
|
||||
# Note: This key must only be used for the Trilium Notes project.
|
||||
# Expires on: 2025-09-13
|
||||
VITE_CKEDITOR_KEY=eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE3NTc3MjE1OTksImp0aSI6ImFiN2E0NjZmLWJlZGMtNDNiYy1iMzU4LTk0NGQ0YWJhY2I3ZiIsImRpc3RyaWJ1dGlvbkNoYW5uZWwiOlsic2giLCJkcnVwYWwiXSwid2hpdGVMYWJlbCI6dHJ1ZSwiZmVhdHVyZXMiOlsiRFJVUCIsIkNNVCIsIkRPIiwiRlAiLCJTQyIsIlRPQyIsIlRQTCIsIlBPRSIsIkNDIiwiTUYiLCJTRUUiLCJFQ0giLCJFSVMiXSwidmMiOiI1MzlkOWY5YyJ9.2rvKPql4hmukyXhEtWPZ8MLxKvzPIwzCdykO653g7IxRRZy2QJpeRszElZx9DakKYZKXekVRAwQKgHxwkgbE_w
|
||||
VITE_CKEDITOR_ENABLE_INSPECTOR=false
|
||||
1
apps/client/.env.production
Normal file
1
apps/client/.env.production
Normal file
@@ -0,0 +1 @@
|
||||
VITE_CKEDITOR_ENABLE_INSPECTOR=false
|
||||
@@ -1,43 +1,44 @@
|
||||
{
|
||||
"name": "@triliumnext/client",
|
||||
"version": "0.94.1",
|
||||
"version": "0.97.2",
|
||||
"description": "JQuery-based client for TriliumNext, used for both web and desktop (via Electron)",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"author": {
|
||||
"name": "TriliumNext Notes Team",
|
||||
"name": "Trilium Notes Team",
|
||||
"email": "contact@eliandoran.me",
|
||||
"url": "https://github.com/TriliumNext/Notes"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/js": "9.28.0",
|
||||
"@eslint/js": "9.33.0",
|
||||
"@excalidraw/excalidraw": "0.18.0",
|
||||
"@fullcalendar/core": "6.1.17",
|
||||
"@fullcalendar/daygrid": "6.1.17",
|
||||
"@fullcalendar/interaction": "6.1.17",
|
||||
"@fullcalendar/list": "6.1.17",
|
||||
"@fullcalendar/multimonth": "6.1.17",
|
||||
"@fullcalendar/timegrid": "6.1.17",
|
||||
"@mermaid-js/layout-elk": "0.1.7",
|
||||
"@mind-elixir/node-menu": "1.0.5",
|
||||
"@fullcalendar/core": "6.1.19",
|
||||
"@fullcalendar/daygrid": "6.1.19",
|
||||
"@fullcalendar/interaction": "6.1.19",
|
||||
"@fullcalendar/list": "6.1.19",
|
||||
"@fullcalendar/multimonth": "6.1.19",
|
||||
"@fullcalendar/timegrid": "6.1.19",
|
||||
"@maplibre/maplibre-gl-leaflet": "0.1.3",
|
||||
"@mermaid-js/layout-elk": "0.1.8",
|
||||
"@mind-elixir/node-menu": "5.0.0",
|
||||
"@popperjs/core": "2.11.8",
|
||||
"@triliumnext/ckeditor5": "workspace:*",
|
||||
"@triliumnext/codemirror": "workspace:*",
|
||||
"@triliumnext/commons": "workspace:*",
|
||||
"@triliumnext/highlightjs": "workspace:*",
|
||||
"@triliumnext/share-theme": "workspace:*",
|
||||
"autocomplete.js": "0.38.1",
|
||||
"bootstrap": "5.3.6",
|
||||
"bootstrap": "5.3.7",
|
||||
"boxicons": "2.1.4",
|
||||
"dayjs": "1.11.13",
|
||||
"dayjs-plugin-utc": "0.1.2",
|
||||
"debounce": "2.2.0",
|
||||
"draggabilly": "3.0.0",
|
||||
"force-graph": "1.49.6",
|
||||
"globals": "16.2.0",
|
||||
"i18next": "25.2.1",
|
||||
"force-graph": "1.50.1",
|
||||
"globals": "16.3.0",
|
||||
"i18next": "25.3.4",
|
||||
"i18next-http-backend": "3.0.2",
|
||||
"jquery": "3.7.1",
|
||||
"jquery-hotkeys": "0.2.2",
|
||||
"jquery.fancytree": "2.38.5",
|
||||
"jsplumb": "2.15.6",
|
||||
"katex": "0.16.22",
|
||||
@@ -45,32 +46,43 @@
|
||||
"leaflet": "1.9.4",
|
||||
"leaflet-gpx": "2.2.0",
|
||||
"mark.js": "8.11.1",
|
||||
"marked": "15.0.12",
|
||||
"mermaid": "11.6.0",
|
||||
"mind-elixir": "4.6.0",
|
||||
"marked": "16.1.2",
|
||||
"mermaid": "11.9.0",
|
||||
"mind-elixir": "5.0.5",
|
||||
"normalize.css": "8.0.1",
|
||||
"panzoom": "9.4.3",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"preact": "10.27.0",
|
||||
"split.js": "1.6.5",
|
||||
"svg-pan-zoom": "3.6.2",
|
||||
"vanilla-js-wheel-zoom": "9.0.4"
|
||||
"tabulator-tables": "6.3.1",
|
||||
"vanilla-js-wheel-zoom": "9.0.4",
|
||||
"photoswipe": "^5.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ckeditor/ckeditor5-inspector": "4.1.0",
|
||||
"@ckeditor/ckeditor5-inspector": "5.0.0",
|
||||
"@preact/preset-vite": "2.10.2",
|
||||
"@types/bootstrap": "5.2.10",
|
||||
"@types/jquery": "3.5.32",
|
||||
"@types/leaflet": "1.9.18",
|
||||
"@types/leaflet": "1.9.20",
|
||||
"@types/leaflet-gpx": "1.3.7",
|
||||
"@types/mark.js": "8.11.12",
|
||||
"@types/react": "19.1.6",
|
||||
"@types/react-dom": "19.1.6",
|
||||
"copy-webpack-plugin": "13.0.0",
|
||||
"happy-dom": "17.6.3",
|
||||
"@types/tabulator-tables": "6.2.10",
|
||||
"copy-webpack-plugin": "13.0.1",
|
||||
"happy-dom": "18.0.1",
|
||||
"script-loader": "0.7.2",
|
||||
"vite-plugin-static-copy": "3.0.0"
|
||||
"vite-plugin-static-copy": "3.1.1"
|
||||
},
|
||||
"nx": {
|
||||
"name": "client"
|
||||
"name": "client",
|
||||
"targets": {
|
||||
"serve": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
]
|
||||
},
|
||||
"circular-deps": {
|
||||
"command": "pnpx dpdm -T {projectRoot}/src/**/*.ts --tree=false --warning=false --skip-dynamic-imports=circular"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,424 +0,0 @@
|
||||
/*
|
||||
* Remove template code below
|
||||
*/
|
||||
html {
|
||||
-webkit-text-size-adjust: 100%;
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
||||
'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
|
||||
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
||||
'Noto Color Emoji';
|
||||
line-height: 1.5;
|
||||
tab-size: 4;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
body {
|
||||
font-family: inherit;
|
||||
line-height: inherit;
|
||||
margin: 0;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
p,
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
*,
|
||||
::before,
|
||||
::after {
|
||||
box-sizing: border-box;
|
||||
border-width: 0;
|
||||
border-style: solid;
|
||||
border-color: currentColor;
|
||||
}
|
||||
h1,
|
||||
h2 {
|
||||
font-size: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
pre {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
||||
'Liberation Mono', 'Courier New', monospace;
|
||||
}
|
||||
svg {
|
||||
display: block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
svg {
|
||||
shape-rendering: auto;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
pre {
|
||||
background-color: rgba(55, 65, 81, 1);
|
||||
border-radius: 0.25rem;
|
||||
color: rgba(229, 231, 235, 1);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
||||
'Liberation Mono', 'Courier New', monospace;
|
||||
overflow: scroll;
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
box-shadow: 0 0 #0000, 0 0 #0000, 0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
.rounded {
|
||||
border-radius: 1.5rem;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
.container {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 768px;
|
||||
padding-bottom: 3rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
color: rgba(55, 65, 81, 1);
|
||||
width: 100%;
|
||||
}
|
||||
#welcome {
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
#welcome h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: -0.025em;
|
||||
line-height: 1;
|
||||
}
|
||||
#welcome span {
|
||||
display: block;
|
||||
font-size: 1.875rem;
|
||||
font-weight: 300;
|
||||
line-height: 2.25rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
#hero {
|
||||
align-items: center;
|
||||
background-color: hsla(214, 62%, 21%, 1);
|
||||
border: none;
|
||||
box-sizing: border-box;
|
||||
color: rgba(55, 65, 81, 1);
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
margin-top: 3.5rem;
|
||||
}
|
||||
#hero .text-container {
|
||||
color: rgba(255, 255, 255, 1);
|
||||
padding: 3rem 2rem;
|
||||
}
|
||||
#hero .text-container h2 {
|
||||
font-size: 1.5rem;
|
||||
line-height: 2rem;
|
||||
position: relative;
|
||||
}
|
||||
#hero .text-container h2 svg {
|
||||
color: hsla(162, 47%, 50%, 1);
|
||||
height: 2rem;
|
||||
left: -0.25rem;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 2rem;
|
||||
}
|
||||
#hero .text-container h2 span {
|
||||
margin-left: 2.5rem;
|
||||
}
|
||||
#hero .text-container a {
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
border-radius: 0.75rem;
|
||||
color: rgba(55, 65, 81, 1);
|
||||
display: inline-block;
|
||||
margin-top: 1.5rem;
|
||||
padding: 1rem 2rem;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
#hero .logo-container {
|
||||
display: none;
|
||||
justify-content: center;
|
||||
padding-left: 2rem;
|
||||
padding-right: 2rem;
|
||||
}
|
||||
#hero .logo-container svg {
|
||||
color: rgba(255, 255, 255, 1);
|
||||
width: 66.666667%;
|
||||
}
|
||||
|
||||
#middle-content {
|
||||
align-items: flex-start;
|
||||
display: grid;
|
||||
gap: 4rem;
|
||||
grid-template-columns: 1fr;
|
||||
margin-top: 3.5rem;
|
||||
}
|
||||
|
||||
#learning-materials {
|
||||
padding: 2.5rem 2rem;
|
||||
}
|
||||
#learning-materials h2 {
|
||||
font-weight: 500;
|
||||
font-size: 1.25rem;
|
||||
letter-spacing: -0.025em;
|
||||
line-height: 1.75rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
.list-item-link {
|
||||
align-items: center;
|
||||
border-radius: 0.75rem;
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
padding: 1rem;
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
width: 100%;
|
||||
}
|
||||
.list-item-link svg:first-child {
|
||||
margin-right: 1rem;
|
||||
height: 1.5rem;
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
width: 1.5rem;
|
||||
}
|
||||
.list-item-link > span {
|
||||
flex-grow: 1;
|
||||
font-weight: 400;
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
}
|
||||
.list-item-link > span > span {
|
||||
color: rgba(107, 114, 128, 1);
|
||||
display: block;
|
||||
flex-grow: 1;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
line-height: 1rem;
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
}
|
||||
.list-item-link svg:last-child {
|
||||
height: 1rem;
|
||||
transition-property: all;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
width: 1rem;
|
||||
}
|
||||
.list-item-link:hover {
|
||||
color: rgba(255, 255, 255, 1);
|
||||
background-color: hsla(162, 47%, 50%, 1);
|
||||
}
|
||||
.list-item-link:hover > span {
|
||||
}
|
||||
.list-item-link:hover > span > span {
|
||||
color: rgba(243, 244, 246, 1);
|
||||
}
|
||||
.list-item-link:hover svg:last-child {
|
||||
transform: translateX(0.25rem);
|
||||
}
|
||||
|
||||
#other-links {
|
||||
}
|
||||
.button-pill {
|
||||
padding: 1.5rem 2rem;
|
||||
transition-duration: 300ms;
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
.button-pill svg {
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
flex-shrink: 0;
|
||||
width: 3rem;
|
||||
}
|
||||
.button-pill > span {
|
||||
letter-spacing: -0.025em;
|
||||
font-weight: 400;
|
||||
font-size: 1.125rem;
|
||||
line-height: 1.75rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
.button-pill span span {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 300;
|
||||
line-height: 1.25rem;
|
||||
}
|
||||
.button-pill:hover svg,
|
||||
.button-pill:hover {
|
||||
color: rgba(255, 255, 255, 1) !important;
|
||||
}
|
||||
#nx-console:hover {
|
||||
background-color: rgba(0, 122, 204, 1);
|
||||
}
|
||||
#nx-console svg {
|
||||
color: rgba(0, 122, 204, 1);
|
||||
}
|
||||
#nx-console-jetbrains {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
#nx-console-jetbrains:hover {
|
||||
background-color: rgba(255, 49, 140, 1);
|
||||
}
|
||||
#nx-console-jetbrains svg {
|
||||
color: rgba(255, 49, 140, 1);
|
||||
}
|
||||
#nx-repo:hover {
|
||||
background-color: rgba(24, 23, 23, 1);
|
||||
}
|
||||
#nx-repo svg {
|
||||
color: rgba(24, 23, 23, 1);
|
||||
}
|
||||
|
||||
#nx-cloud {
|
||||
margin-bottom: 2rem;
|
||||
margin-top: 2rem;
|
||||
padding: 2.5rem 2rem;
|
||||
}
|
||||
#nx-cloud > div {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
#nx-cloud > div svg {
|
||||
border-radius: 0.375rem;
|
||||
flex-shrink: 0;
|
||||
width: 3rem;
|
||||
}
|
||||
#nx-cloud > div h2 {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 400;
|
||||
letter-spacing: -0.025em;
|
||||
line-height: 1.75rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
#nx-cloud > div h2 span {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 300;
|
||||
line-height: 1.25rem;
|
||||
}
|
||||
#nx-cloud p {
|
||||
font-size: 1rem;
|
||||
line-height: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
#nx-cloud pre {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
#nx-cloud a {
|
||||
color: rgba(107, 114, 128, 1);
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.25rem;
|
||||
margin-top: 1.5rem;
|
||||
text-align: right;
|
||||
}
|
||||
#nx-cloud a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#commands {
|
||||
padding: 2.5rem 2rem;
|
||||
|
||||
margin-top: 3.5rem;
|
||||
}
|
||||
#commands h2 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 400;
|
||||
letter-spacing: -0.025em;
|
||||
line-height: 1.75rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
#commands p {
|
||||
font-size: 1rem;
|
||||
font-weight: 300;
|
||||
line-height: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
details {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
width: 100%;
|
||||
}
|
||||
details pre > span {
|
||||
color: rgba(181, 181, 181, 1);
|
||||
}
|
||||
summary {
|
||||
border-radius: 0.5rem;
|
||||
display: flex;
|
||||
font-weight: 400;
|
||||
padding: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition-property: background-color, border-color, color, fill, stroke,
|
||||
opacity, box-shadow, transform, filter, backdrop-filter,
|
||||
-webkit-backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 150ms;
|
||||
}
|
||||
summary:hover {
|
||||
background-color: rgba(243, 244, 246, 1);
|
||||
}
|
||||
summary svg {
|
||||
height: 1.5rem;
|
||||
margin-right: 1rem;
|
||||
width: 1.5rem;
|
||||
}
|
||||
|
||||
#love {
|
||||
color: rgba(107, 114, 128, 1);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.25rem;
|
||||
margin-top: 3.5rem;
|
||||
opacity: 0.6;
|
||||
text-align: center;
|
||||
}
|
||||
#love svg {
|
||||
color: rgba(252, 165, 165, 1);
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
display: inline;
|
||||
margin-top: -0.25rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
#hero {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
#hero .logo-container {
|
||||
display: flex;
|
||||
}
|
||||
#middle-content {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { AppElement } from './app.element';
|
||||
|
||||
describe('AppElement', () => {
|
||||
let app: AppElement;
|
||||
|
||||
beforeEach(() => {
|
||||
app = new AppElement();
|
||||
});
|
||||
|
||||
it('should create successfully', () => {
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should have a greeting', () => {
|
||||
app.connectedCallback();
|
||||
|
||||
expect(app.querySelector('h1').innerHTML).toContain(
|
||||
'Welcome @triliumnext/client'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,409 +0,0 @@
|
||||
import './app.element.css';
|
||||
|
||||
export class AppElement extends HTMLElement {
|
||||
public static observedAttributes = [
|
||||
|
||||
];
|
||||
|
||||
connectedCallback() {
|
||||
const title = '@triliumnext/client';
|
||||
this.innerHTML = `
|
||||
<div class="wrapper">
|
||||
<div class="container">
|
||||
<!-- WELCOME -->
|
||||
<div id="welcome">
|
||||
<h1>
|
||||
<span> Hello there, </span>
|
||||
Welcome ${title} 👋
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<!-- HERO -->
|
||||
<div id="hero" class="rounded">
|
||||
<div class="text-container">
|
||||
<h2>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"
|
||||
/>
|
||||
</svg>
|
||||
<span>You're up and running</span>
|
||||
</h2>
|
||||
<a href="#commands"> What's next? </a>
|
||||
</div>
|
||||
<div class="logo-container">
|
||||
<svg
|
||||
fill="currentColor"
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M11.987 14.138l-3.132 4.923-5.193-8.427-.012 8.822H0V4.544h3.691l5.247 8.833.005-3.998 3.044 4.759zm.601-5.761c.024-.048 0-3.784.008-3.833h-3.65c.002.059-.005 3.776-.003 3.833h3.645zm5.634 4.134a2.061 2.061 0 0 0-1.969 1.336 1.963 1.963 0 0 1 2.343-.739c.396.161.917.422 1.33.283a2.1 2.1 0 0 0-1.704-.88zm3.39 1.061c-.375-.13-.8-.277-1.109-.681-.06-.08-.116-.17-.176-.265a2.143 2.143 0 0 0-.533-.642c-.294-.216-.68-.322-1.18-.322a2.482 2.482 0 0 0-2.294 1.536 2.325 2.325 0 0 1 4.002.388.75.75 0 0 0 .836.334c.493-.105.46.36 1.203.518v-.133c-.003-.446-.246-.55-.75-.733zm2.024 1.266a.723.723 0 0 0 .347-.638c-.01-2.957-2.41-5.487-5.37-5.487a5.364 5.364 0 0 0-4.487 2.418c-.01-.026-1.522-2.39-1.538-2.418H8.943l3.463 5.423-3.379 5.32h3.54l1.54-2.366 1.568 2.366h3.541l-3.21-5.052a.7.7 0 0 1-.084-.32 2.69 2.69 0 0 1 2.69-2.691h.001c1.488 0 1.736.89 2.057 1.308.634.826 1.9.464 1.9 1.541a.707.707 0 0 0 1.066.596zm.35.133c-.173.372-.56.338-.755.639-.176.271.114.412.114.412s.337.156.538-.311c.104-.231.14-.488.103-.74z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MIDDLE CONTENT -->
|
||||
<div id="middle-content">
|
||||
<div id="learning-materials" class="rounded shadow">
|
||||
<h2>Learning materials</h2>
|
||||
<a href="https://nx.dev/getting-started/intro?utm_source=nx-project" target="_blank" rel="noreferrer" class="list-item-link">
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
Documentation
|
||||
<span> Everything is in there </span>
|
||||
</span>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5l7 7-7 7"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="https://nx.dev/blog/?utm_source=nx-project" target="_blank" rel="noreferrer" class="list-item-link">
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
Blog
|
||||
<span> Changelog, features & events </span>
|
||||
</span>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5l7 7-7 7"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="https://www.youtube.com/@NxDevtools/videos?utm_source=nx-project&sub_confirmation=1" target="_blank" rel="noreferrer" class="list-item-link">
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<title>YouTube</title>
|
||||
<path
|
||||
d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
YouTube channel
|
||||
<span> Nx Show, talks & tutorials </span>
|
||||
</span>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5l7 7-7 7"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="https://nx.dev/react-tutorial/1-code-generation?utm_source=nx-project" target="_blank" rel="noreferrer" class="list-item-link">
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
Interactive tutorials
|
||||
<span> Create an app, step-by-step </span>
|
||||
</span>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5l7 7-7 7"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="https://nxplaybook.com/?utm_source=nx-project" target="_blank" rel="noreferrer" class="list-item-link">
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path d="M12 14l9-5-9-5-9 5 9 5z" />
|
||||
<path
|
||||
d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"
|
||||
/>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
Video courses
|
||||
<span> Nx custom courses </span>
|
||||
</span>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5l7 7-7 7"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
<div id="other-links">
|
||||
<a id="nx-console" class="button-pill rounded shadow" href="https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console&utm_source=nx-project" target="_blank" rel="noreferrer">
|
||||
<svg
|
||||
fill="currentColor"
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<title>Visual Studio Code</title>
|
||||
<path
|
||||
d="M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
Install Nx Console for VSCode
|
||||
<span>The official VSCode extension for Nx.</span>
|
||||
</span>
|
||||
</a>
|
||||
<a
|
||||
id="nx-console-jetbrains"
|
||||
class="button-pill rounded shadow"
|
||||
href="https://plugins.jetbrains.com/plugin/21060-nx-console"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<svg
|
||||
height="48"
|
||||
width="48"
|
||||
viewBox="20 20 60 60"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path d="m22.5 22.5h60v60h-60z" />
|
||||
<g fill="#fff">
|
||||
<path d="m29.03 71.25h22.5v3.75h-22.5z" />
|
||||
<path d="m28.09 38 1.67-1.58a1.88 1.88 0 0 0 1.47.87c.64 0 1.06-.44 1.06-1.31v-5.98h2.58v6a3.48 3.48 0 0 1 -.87 2.6 3.56 3.56 0 0 1 -2.57.95 3.84 3.84 0 0 1 -3.34-1.55z" />
|
||||
<path d="m36 30h7.53v2.19h-5v1.44h4.49v2h-4.42v1.49h5v2.21h-7.6z" />
|
||||
<path d="m47.23 32.29h-2.8v-2.29h8.21v2.27h-2.81v7.1h-2.6z" />
|
||||
<path d="m29.13 43.08h4.42a3.53 3.53 0 0 1 2.55.83 2.09 2.09 0 0 1 .6 1.53 2.16 2.16 0 0 1 -1.44 2.09 2.27 2.27 0 0 1 1.86 2.29c0 1.61-1.31 2.59-3.55 2.59h-4.44zm5 2.89c0-.52-.42-.8-1.18-.8h-1.29v1.64h1.24c.79 0 1.25-.26 1.25-.81zm-.9 2.66h-1.57v1.73h1.62c.8 0 1.24-.31 1.24-.86 0-.5-.4-.87-1.27-.87z" />
|
||||
<path d="m38 43.08h4.1a4.19 4.19 0 0 1 3 1 2.93 2.93 0 0 1 .9 2.19 3 3 0 0 1 -1.93 2.89l2.24 3.27h-3l-1.88-2.84h-.87v2.84h-2.56zm4 4.5c.87 0 1.39-.43 1.39-1.11 0-.75-.54-1.12-1.4-1.12h-1.44v2.26z" />
|
||||
<path d="m49.59 43h2.5l4 9.44h-2.79l-.67-1.69h-3.63l-.67 1.69h-2.71zm2.27 5.73-1-2.65-1.06 2.65z" />
|
||||
<path d="m56.46 43.05h2.6v9.37h-2.6z" />
|
||||
<path d="m60.06 43.05h2.42l3.37 5v-5h2.57v9.37h-2.26l-3.53-5.14v5.14h-2.57z" />
|
||||
<path d="m68.86 51 1.45-1.73a4.84 4.84 0 0 0 3 1.13c.71 0 1.08-.24 1.08-.65 0-.4-.31-.6-1.59-.91-2-.46-3.53-1-3.53-2.93 0-1.74 1.37-3 3.62-3a5.89 5.89 0 0 1 3.86 1.25l-1.26 1.84a4.63 4.63 0 0 0 -2.62-.92c-.63 0-.94.25-.94.6 0 .42.32.61 1.63.91 2.14.46 3.44 1.16 3.44 2.91 0 1.91-1.51 3-3.79 3a6.58 6.58 0 0 1 -4.35-1.5z" />
|
||||
</g>
|
||||
</svg>
|
||||
<span>
|
||||
Install Nx Console for JetBrains
|
||||
<span>
|
||||
Available for WebStorm, Intellij IDEA Ultimate and more!
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
<div id="nx-cloud" class="rounded shadow">
|
||||
<div>
|
||||
<svg id="nx-cloud-logo" role="img" xmlns="http://www.w3.org/2000/svg" stroke="currentColor" fill="transparent" viewBox="0 0 24 24">
|
||||
<path stroke-width="2" d="M23 3.75V6.5c-3.036 0-5.5 2.464-5.5 5.5s-2.464 5.5-5.5 5.5-5.5 2.464-5.5 5.5H3.75C2.232 23 1 21.768 1 20.25V3.75C1 2.232 2.232 1 3.75 1h16.5C21.768 1 23 2.232 23 3.75Z" />
|
||||
<path stroke-width="2" d="M23 6v14.1667C23 21.7307 21.7307 23 20.1667 23H6c0-3.128 2.53867-5.6667 5.6667-5.6667 3.128 0 5.6666-2.5386 5.6666-5.6666C17.3333 8.53867 19.872 6 23 6Z" />
|
||||
</svg>
|
||||
<h2>
|
||||
Nx Cloud
|
||||
<span>
|
||||
Enable faster CI & better DX
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
<p>
|
||||
You can activate distributed tasks executions and caching by
|
||||
running:
|
||||
</p>
|
||||
<pre>nx connect</pre>
|
||||
<a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
|
||||
</div>
|
||||
<a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
|
||||
<svg
|
||||
fill="currentColor"
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
|
||||
/>
|
||||
</svg>
|
||||
<span>
|
||||
Nx is open source
|
||||
<span> Love Nx? Give us a star! </span>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- COMMANDS -->
|
||||
<div id="commands" class="rounded shadow">
|
||||
<h2>Next steps</h2>
|
||||
<p>Here are some things you can do with Nx:</p>
|
||||
<details>
|
||||
<summary>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||
/>
|
||||
</svg>
|
||||
Add UI library
|
||||
</summary>
|
||||
<pre><span># Generate UI lib</span>
|
||||
nx g @nx/angular:lib ui
|
||||
|
||||
<span># Add a component</span>
|
||||
nx g @nx/angular:component ui/src/lib/button</pre>
|
||||
</details>
|
||||
<details>
|
||||
<summary>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||
/>
|
||||
</svg>
|
||||
View interactive project graph
|
||||
</summary>
|
||||
<pre>nx graph</pre>
|
||||
</details>
|
||||
<details>
|
||||
<summary>
|
||||
<svg
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||
/>
|
||||
</svg>
|
||||
Run affected commands
|
||||
</summary>
|
||||
<pre><span># see what's been affected by changes</span>
|
||||
nx affected:graph
|
||||
|
||||
<span># run tests for current changes</span>
|
||||
nx affected:test
|
||||
|
||||
<span># run e2e tests for current changes</span>
|
||||
nx affected:e2e</pre>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<p id="love">
|
||||
Carefully crafted with
|
||||
<svg
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
|
||||
/>
|
||||
</svg>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
customElements.define('triliumnext-root', AppElement);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Client</title>
|
||||
<base href="/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<triliumnext-root></triliumnext-root>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
import './app/app.element';
|
||||
@@ -1 +0,0 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
@@ -1,5 +1,4 @@
|
||||
import froca from "../services/froca.js";
|
||||
import bundleService from "../services/bundle.js";
|
||||
import RootCommandExecutor from "./root_command_executor.js";
|
||||
import Entrypoints, { type SqlExecuteResults } from "./entrypoints.js";
|
||||
import options from "../services/options.js";
|
||||
@@ -28,6 +27,10 @@ import type { NativeImage, TouchBar } from "electron";
|
||||
import TouchBarComponent from "./touch_bar.js";
|
||||
import type { CKTextEditor } from "@triliumnext/ckeditor5";
|
||||
import type CodeMirror from "@triliumnext/codemirror";
|
||||
import { StartupChecks } from "./startup_checks.js";
|
||||
import type { CreateNoteOpts } from "../services/note_create.js";
|
||||
import { ColumnComponent } from "tabulator-tables";
|
||||
import { ChooseNoteTypeCallback } from "../widgets/dialogs/note_type_chooser.jsx";
|
||||
|
||||
interface Layout {
|
||||
getRootWidget: (appContext: AppContext) => RootWidget;
|
||||
@@ -90,7 +93,9 @@ export type CommandMappings = {
|
||||
closeTocCommand: CommandData;
|
||||
closeHlt: CommandData;
|
||||
showLaunchBarSubtree: CommandData;
|
||||
showRevisions: CommandData;
|
||||
showRevisions: CommandData & {
|
||||
noteId?: string | null;
|
||||
};
|
||||
showLlmChat: CommandData;
|
||||
createAiChat: CommandData;
|
||||
showOptions: CommandData & {
|
||||
@@ -122,13 +127,17 @@ export type CommandMappings = {
|
||||
showImportDialog: CommandData & { noteId: string };
|
||||
openNewNoteSplit: NoteCommandData;
|
||||
openInWindow: NoteCommandData;
|
||||
openInPopup: CommandData & { noteIdOrPath: string; };
|
||||
openNoteInNewTab: CommandData;
|
||||
openNoteInNewSplit: CommandData;
|
||||
openNoteInNewWindow: CommandData;
|
||||
openAboutDialog: CommandData;
|
||||
hideFloatingButtons: {};
|
||||
hideLeftPane: CommandData;
|
||||
showCpuArchWarning: CommandData;
|
||||
showLeftPane: CommandData;
|
||||
showAttachments: CommandData;
|
||||
showSearchHistory: CommandData;
|
||||
hoistNote: CommandData & { noteId: string };
|
||||
leaveProtectedSession: CommandData;
|
||||
enterProtectedSession: CommandData;
|
||||
@@ -139,6 +148,7 @@ export type CommandMappings = {
|
||||
};
|
||||
openInTab: ContextMenuCommandData;
|
||||
openNoteInSplit: ContextMenuCommandData;
|
||||
openNoteInPopup: ContextMenuCommandData;
|
||||
toggleNoteHoisting: ContextMenuCommandData;
|
||||
insertNoteAfter: ContextMenuCommandData;
|
||||
insertChildNote: ContextMenuCommandData;
|
||||
@@ -168,7 +178,7 @@ export type CommandMappings = {
|
||||
deleteNotes: ContextMenuCommandData;
|
||||
importIntoNote: ContextMenuCommandData;
|
||||
exportNote: ContextMenuCommandData;
|
||||
searchInSubtree: ContextMenuCommandData;
|
||||
searchInSubtree: CommandData & { notePath: string; };
|
||||
moveNoteUp: ContextMenuCommandData;
|
||||
moveNoteDown: ContextMenuCommandData;
|
||||
moveNoteUpInHierarchy: ContextMenuCommandData;
|
||||
@@ -257,10 +267,76 @@ export type CommandMappings = {
|
||||
closeThisNoteSplit: CommandData;
|
||||
moveThisNoteSplit: CommandData & { isMovingLeft: boolean };
|
||||
jumpToNote: CommandData;
|
||||
commandPalette: CommandData;
|
||||
|
||||
// Keyboard shortcuts
|
||||
backInNoteHistory: CommandData;
|
||||
forwardInNoteHistory: CommandData;
|
||||
forceSaveRevision: CommandData;
|
||||
scrollToActiveNote: CommandData;
|
||||
quickSearch: CommandData;
|
||||
collapseTree: CommandData;
|
||||
createNoteAfter: CommandData;
|
||||
createNoteInto: CommandData;
|
||||
addNoteAboveToSelection: CommandData;
|
||||
addNoteBelowToSelection: CommandData;
|
||||
openNewTab: CommandData;
|
||||
activateNextTab: CommandData;
|
||||
activatePreviousTab: CommandData;
|
||||
openNewWindow: CommandData;
|
||||
toggleTray: CommandData;
|
||||
firstTab: CommandData;
|
||||
secondTab: CommandData;
|
||||
thirdTab: CommandData;
|
||||
fourthTab: CommandData;
|
||||
fifthTab: CommandData;
|
||||
sixthTab: CommandData;
|
||||
seventhTab: CommandData;
|
||||
eigthTab: CommandData;
|
||||
ninthTab: CommandData;
|
||||
lastTab: CommandData;
|
||||
showNoteSource: CommandData;
|
||||
showSQLConsole: CommandData;
|
||||
showBackendLog: CommandData;
|
||||
showCheatsheet: CommandData;
|
||||
showHelp: CommandData;
|
||||
addLinkToText: CommandData;
|
||||
followLinkUnderCursor: CommandData;
|
||||
insertDateTimeToText: CommandData;
|
||||
pasteMarkdownIntoText: CommandData;
|
||||
cutIntoNote: CommandData;
|
||||
addIncludeNoteToText: CommandData;
|
||||
editReadOnlyNote: CommandData;
|
||||
toggleRibbonTabClassicEditor: CommandData;
|
||||
toggleRibbonTabBasicProperties: CommandData;
|
||||
toggleRibbonTabBookProperties: CommandData;
|
||||
toggleRibbonTabFileProperties: CommandData;
|
||||
toggleRibbonTabImageProperties: CommandData;
|
||||
toggleRibbonTabOwnedAttributes: CommandData;
|
||||
toggleRibbonTabInheritedAttributes: CommandData;
|
||||
toggleRibbonTabPromotedAttributes: CommandData;
|
||||
toggleRibbonTabNoteMap: CommandData;
|
||||
toggleRibbonTabNoteInfo: CommandData;
|
||||
toggleRibbonTabNotePaths: CommandData;
|
||||
toggleRibbonTabSimilarNotes: CommandData;
|
||||
toggleRightPane: CommandData;
|
||||
printActiveNote: CommandData;
|
||||
exportAsPdf: CommandData;
|
||||
openNoteExternally: CommandData;
|
||||
renderActiveNote: CommandData;
|
||||
unhoist: CommandData;
|
||||
reloadFrontendApp: CommandData;
|
||||
openDevTools: CommandData;
|
||||
findInText: CommandData;
|
||||
toggleLeftPane: CommandData;
|
||||
toggleFullscreen: CommandData;
|
||||
zoomOut: CommandData;
|
||||
zoomIn: CommandData;
|
||||
zoomReset: CommandData;
|
||||
copyWithoutFormatting: CommandData;
|
||||
|
||||
// Geomap
|
||||
deleteFromMap: { noteId: string };
|
||||
openGeoLocation: { noteId: string; event: JQuery.MouseDownEvent };
|
||||
|
||||
toggleZenMode: CommandData;
|
||||
|
||||
@@ -274,11 +350,30 @@ export type CommandMappings = {
|
||||
|
||||
geoMapCreateChildNote: CommandData;
|
||||
|
||||
// Table view
|
||||
addNewRow: CommandData & {
|
||||
customOpts: CreateNoteOpts;
|
||||
parentNotePath?: string;
|
||||
};
|
||||
addNewTableColumn: CommandData & {
|
||||
columnToEdit?: ColumnComponent;
|
||||
referenceColumn?: ColumnComponent;
|
||||
direction?: "before" | "after";
|
||||
type?: "label" | "relation";
|
||||
};
|
||||
deleteTableColumn: CommandData & {
|
||||
columnToDelete?: ColumnComponent;
|
||||
};
|
||||
|
||||
buildTouchBar: CommandData & {
|
||||
TouchBar: typeof TouchBar;
|
||||
buildIcon(name: string): NativeImage;
|
||||
};
|
||||
refreshTouchBar: CommandData;
|
||||
reloadTextEditor: CommandData;
|
||||
chooseNoteType: CommandData & {
|
||||
callback: ChooseNoteTypeCallback
|
||||
}
|
||||
};
|
||||
|
||||
type EventMappings = {
|
||||
@@ -467,13 +562,21 @@ export class AppContext extends Component {
|
||||
|
||||
this.tabManager.loadTabs();
|
||||
|
||||
const bundleService = (await import("../services/bundle.js")).default;
|
||||
setTimeout(() => bundleService.executeStartupBundles(), 2000);
|
||||
}
|
||||
|
||||
initComponents() {
|
||||
this.tabManager = new TabManager();
|
||||
|
||||
this.components = [this.tabManager, new RootCommandExecutor(), new Entrypoints(), new MainTreeExecutors(), new ShortcutComponent()];
|
||||
this.components = [
|
||||
this.tabManager,
|
||||
new RootCommandExecutor(),
|
||||
new Entrypoints(),
|
||||
new MainTreeExecutors(),
|
||||
new ShortcutComponent(),
|
||||
new StartupChecks()
|
||||
];
|
||||
|
||||
if (utils.isMobile()) {
|
||||
this.components.push(new MobileScreenSwitcherExecutor());
|
||||
|
||||
@@ -93,11 +93,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {
|
||||
|
||||
if (fun) {
|
||||
return this.callMethod(fun, data);
|
||||
} else {
|
||||
if (!this.parent) {
|
||||
throw new Error(`Component "${this.componentId}" does not have a parent attached to propagate a command.`);
|
||||
}
|
||||
|
||||
} else if (this.parent) {
|
||||
return this.parent.triggerCommand(name, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,6 @@ interface CreateChildrenResponse {
|
||||
export default class Entrypoints extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
if (jQuery.hotkeys) {
|
||||
// hot keys are active also inside inputs and content editables
|
||||
jQuery.hotkeys.options.filterInputAcceptingElements = false;
|
||||
jQuery.hotkeys.options.filterContentEditable = false;
|
||||
jQuery.hotkeys.options.filterTextInputs = false;
|
||||
}
|
||||
}
|
||||
|
||||
openDevToolsCommand() {
|
||||
@@ -113,7 +106,9 @@ export default class Entrypoints extends Component {
|
||||
if (win.isFullScreenable()) {
|
||||
win.setFullScreen(!win.isFullScreen());
|
||||
}
|
||||
} // outside of electron this is handled by the browser
|
||||
} else {
|
||||
document.documentElement.requestFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
reloadFrontendAppCommand() {
|
||||
|
||||
@@ -12,6 +12,7 @@ import type FNote from "../entities/fnote.js";
|
||||
import type TypeWidget from "../widgets/type_widgets/type_widget.js";
|
||||
import type { CKTextEditor } from "@triliumnext/ckeditor5";
|
||||
import type CodeMirror from "@triliumnext/codemirror";
|
||||
import { closeActiveDialog } from "../services/dialog.js";
|
||||
|
||||
export interface SetNoteOpts {
|
||||
triggerSwitchEvent?: unknown;
|
||||
@@ -83,7 +84,7 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
|
||||
|
||||
await this.triggerEvent("beforeNoteSwitch", { noteContext: this });
|
||||
|
||||
utils.closeActiveDialog();
|
||||
closeActiveDialog();
|
||||
|
||||
this.notePath = resolvedNotePath;
|
||||
this.viewScope = opts.viewScope;
|
||||
@@ -314,14 +315,39 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
|
||||
}
|
||||
|
||||
hasNoteList() {
|
||||
return (
|
||||
this.note &&
|
||||
["default", "contextual-help"].includes(this.viewScope?.viewMode ?? "") &&
|
||||
(this.note.hasChildren() || this.note.getLabelValue("viewType") === "calendar") &&
|
||||
["book", "text", "code"].includes(this.note.type) &&
|
||||
this.note.mime !== "text/x-sqlite;schema=trilium" &&
|
||||
!this.note.isLabelTruthy("hideChildrenOverview")
|
||||
);
|
||||
const note = this.note;
|
||||
|
||||
if (!note) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!["default", "contextual-help"].includes(this.viewScope?.viewMode ?? "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Collections must always display a note list, even if no children.
|
||||
const viewType = note.getLabelValue("viewType") ?? "grid";
|
||||
if (!["list", "grid"].includes(viewType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!note.hasChildren()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!["book", "text", "code"].includes(note.type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (note.mime === "text/x-sqlite;schema=trilium") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (note.isLabelTruthy("hideChildrenOverview")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async getTextEditor(callback?: GetTextEditorCallback) {
|
||||
|
||||
26
apps/client/src/components/startup_checks.ts
Normal file
26
apps/client/src/components/startup_checks.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import server from "../services/server";
|
||||
import Component from "./component";
|
||||
|
||||
// TODO: Deduplicate.
|
||||
interface CpuArchResponse {
|
||||
isCpuArchMismatch: boolean;
|
||||
}
|
||||
|
||||
export class StartupChecks extends Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.checkCpuArchMismatch();
|
||||
}
|
||||
|
||||
async checkCpuArchMismatch() {
|
||||
try {
|
||||
const response = await server.get("system-checks") as CpuArchResponse;
|
||||
if (response.isCpuArchMismatch) {
|
||||
this.triggerCommand("showCpuArchWarning", {});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Could not check CPU arch status:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -688,7 +688,7 @@ export default class TabManager extends Component {
|
||||
const titleFragments = [
|
||||
// it helps to navigate in history if note title is included in the title
|
||||
await activeNoteContext.getNavigationTitle(),
|
||||
"TriliumNext Notes"
|
||||
"Trilium Notes"
|
||||
].filter(Boolean);
|
||||
|
||||
document.title = titleFragments.join(" - ");
|
||||
|
||||
@@ -8,11 +8,13 @@ import electronContextMenu from "./menus/electron_context_menu.js";
|
||||
import glob from "./services/glob.js";
|
||||
import { t } from "./services/i18n.js";
|
||||
import options from "./services/options.js";
|
||||
import server from "./services/server.js";
|
||||
import type ElectronRemote from "@electron/remote";
|
||||
import type Electron from "electron";
|
||||
import "./stylesheets/bootstrap.scss";
|
||||
import "boxicons/css/boxicons.min.css";
|
||||
import "jquery-hotkeys";
|
||||
import "./stylesheets/media-viewer.css";
|
||||
import "./styles/gallery.css";
|
||||
import "autocomplete.js/index_jquery.js";
|
||||
|
||||
await appContext.earlyInit();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import server from "../services/server.js";
|
||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||
import ws from "../services/ws.js";
|
||||
import froca from "../services/froca.js";
|
||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||
import cssClassManager from "../services/css_class_manager.js";
|
||||
import type { Froca } from "../services/froca-interface.js";
|
||||
@@ -28,7 +27,6 @@ const NOTE_TYPE_ICONS = {
|
||||
doc: "bx bxs-file-doc",
|
||||
contentWidget: "bx bxs-widget",
|
||||
mindMap: "bx bx-sitemap",
|
||||
geoMap: "bx bx-map-alt",
|
||||
aiChat: "bx bx-bot"
|
||||
};
|
||||
|
||||
@@ -37,7 +35,7 @@ const NOTE_TYPE_ICONS = {
|
||||
* end user. Those types should be used only for checking against, they are
|
||||
* not for direct use.
|
||||
*/
|
||||
export type NoteType = "file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code" | "mindMap" | "geoMap" | "aiChat";
|
||||
export type NoteType = "file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code" | "mindMap" | "aiChat";
|
||||
|
||||
export interface NotePathRecord {
|
||||
isArchived: boolean;
|
||||
@@ -258,6 +256,20 @@ class FNote {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
async getSubtreeNoteIds() {
|
||||
let noteIds: (string | string[])[] = [];
|
||||
for (const child of await this.getChildNotes()) {
|
||||
noteIds.push(child.noteId);
|
||||
noteIds.push(await child.getSubtreeNoteIds());
|
||||
}
|
||||
return noteIds.flat();
|
||||
}
|
||||
|
||||
async getSubtreeNotes() {
|
||||
const noteIds = await this.getSubtreeNoteIds();
|
||||
return this.froca.getNotes(noteIds);
|
||||
}
|
||||
|
||||
async getChildNotes() {
|
||||
return await this.froca.getNotes(this.children);
|
||||
}
|
||||
@@ -410,8 +422,8 @@ class FNote {
|
||||
const notePaths: NotePathRecord[] = this.getAllNotePaths().map((path) => ({
|
||||
notePath: path,
|
||||
isInHoistedSubTree: isHoistedRoot || path.includes(hoistedNoteId),
|
||||
isArchived: path.some((noteId) => froca.notes[noteId].isArchived),
|
||||
isSearch: path.some((noteId) => froca.notes[noteId].type === "search"),
|
||||
isArchived: path.some((noteId) => this.froca.notes[noteId].isArchived),
|
||||
isSearch: path.some((noteId) => this.froca.notes[noteId].type === "search"),
|
||||
isHidden: path.includes("_hidden")
|
||||
}));
|
||||
|
||||
@@ -982,7 +994,7 @@ class FNote {
|
||||
continue;
|
||||
}
|
||||
|
||||
const parentNote = froca.notes[parentNoteId];
|
||||
const parentNote = this.froca.notes[parentNoteId];
|
||||
|
||||
if (!parentNote || parentNote.type === "search") {
|
||||
continue;
|
||||
|
||||
@@ -46,28 +46,7 @@ import SharedInfoWidget from "../widgets/shared_info.js";
|
||||
import FindWidget from "../widgets/find.js";
|
||||
import TocWidget from "../widgets/toc.js";
|
||||
import HighlightsListWidget from "../widgets/highlights_list.js";
|
||||
import BulkActionsDialog from "../widgets/dialogs/bulk_actions.js";
|
||||
import AboutDialog from "../widgets/dialogs/about.js";
|
||||
import HelpDialog from "../widgets/dialogs/help.js";
|
||||
import RecentChangesDialog from "../widgets/dialogs/recent_changes.js";
|
||||
import BranchPrefixDialog from "../widgets/dialogs/branch_prefix.js";
|
||||
import SortChildNotesDialog from "../widgets/dialogs/sort_child_notes.js";
|
||||
import PasswordNoteSetDialog from "../widgets/dialogs/password_not_set.js";
|
||||
import IncludeNoteDialog from "../widgets/dialogs/include_note.js";
|
||||
import NoteTypeChooserDialog from "../widgets/dialogs/note_type_chooser.js";
|
||||
import JumpToNoteDialog from "../widgets/dialogs/jump_to_note.js";
|
||||
import AddLinkDialog from "../widgets/dialogs/add_link.js";
|
||||
import CloneToDialog from "../widgets/dialogs/clone_to.js";
|
||||
import MoveToDialog from "../widgets/dialogs/move_to.js";
|
||||
import ImportDialog from "../widgets/dialogs/import.js";
|
||||
import ExportDialog from "../widgets/dialogs/export.js";
|
||||
import MarkdownImportDialog from "../widgets/dialogs/markdown_import.js";
|
||||
import ProtectedSessionPasswordDialog from "../widgets/dialogs/protected_session_password.js";
|
||||
import RevisionsDialog from "../widgets/dialogs/revisions.js";
|
||||
import DeleteNotesDialog from "../widgets/dialogs/delete_notes.js";
|
||||
import InfoDialog from "../widgets/dialogs/info.js";
|
||||
import ConfirmDialog from "../widgets/dialogs/confirm.js";
|
||||
import PromptDialog from "../widgets/dialogs/prompt.js";
|
||||
import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js";
|
||||
import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.js";
|
||||
import SvgExportButton from "../widgets/floating_buttons/svg_export_button.js";
|
||||
@@ -83,7 +62,7 @@ import CopyImageReferenceButton from "../widgets/floating_buttons/copy_image_ref
|
||||
import ScrollPaddingWidget from "../widgets/scroll_padding.js";
|
||||
import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbar.js";
|
||||
import options from "../services/options.js";
|
||||
import utils, { hasTouchBar } from "../services/utils.js";
|
||||
import utils from "../services/utils.js";
|
||||
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
|
||||
import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";
|
||||
import CloseZenButton from "../widgets/close_zen_button.js";
|
||||
@@ -229,7 +208,7 @@ export default class DesktopLayout {
|
||||
.child(new PromotedAttributesWidget())
|
||||
.child(new SqlTableSchemasWidget())
|
||||
.child(new NoteDetailWidget())
|
||||
.child(new NoteListWidget())
|
||||
.child(new NoteListWidget(false))
|
||||
.child(new SearchResultWidget())
|
||||
.child(new SqlResultWidget())
|
||||
.child(new ScrollPaddingWidget())
|
||||
|
||||
@@ -21,6 +21,16 @@ import ConfirmDialog from "../widgets/dialogs/confirm.js";
|
||||
import RevisionsDialog from "../widgets/dialogs/revisions.js";
|
||||
import DeleteNotesDialog from "../widgets/dialogs/delete_notes.js";
|
||||
import InfoDialog from "../widgets/dialogs/info.js";
|
||||
import IncorrectCpuArchDialog from "../widgets/dialogs/incorrect_cpu_arch.js";
|
||||
import PopupEditorDialog from "../widgets/dialogs/popup_editor.js";
|
||||
import FlexContainer from "../widgets/containers/flex_container.js";
|
||||
import NoteIconWidget from "../widgets/note_icon.js";
|
||||
import NoteTitleWidget from "../widgets/note_title.js";
|
||||
import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbar.js";
|
||||
import PromotedAttributesWidget from "../widgets/ribbon_widgets/promoted_attributes.js";
|
||||
import NoteDetailWidget from "../widgets/note_detail.js";
|
||||
import NoteListWidget from "../widgets/note_list.js";
|
||||
import { CallToActionDialog } from "../widgets/dialogs/call_to_action.jsx";
|
||||
|
||||
export function applyModals(rootContainer: RootContainer) {
|
||||
rootContainer
|
||||
@@ -45,4 +55,17 @@ export function applyModals(rootContainer: RootContainer) {
|
||||
.child(new InfoDialog())
|
||||
.child(new ConfirmDialog())
|
||||
.child(new PromptDialog())
|
||||
.child(new IncorrectCpuArchDialog())
|
||||
.child(new PopupEditorDialog()
|
||||
.child(new FlexContainer("row")
|
||||
.class("title-row")
|
||||
.css("align-items", "center")
|
||||
.cssBlock(".title-row > * { margin: 5px; }")
|
||||
.child(new NoteIconWidget())
|
||||
.child(new NoteTitleWidget()))
|
||||
.child(new ClassicEditorToolbar())
|
||||
.child(new PromotedAttributesWidget())
|
||||
.child(new NoteDetailWidget())
|
||||
.child(new NoteListWidget(true)))
|
||||
.child(new CallToActionDialog());
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import TabRowWidget from "../widgets/tab_row.js";
|
||||
import RefreshButton from "../widgets/floating_buttons/refresh_button.js";
|
||||
import MobileEditorToolbar from "../widgets/ribbon_widgets/mobile_editor_toolbar.js";
|
||||
import { applyModals } from "./layout_commons.js";
|
||||
import CloseZenButton from "../widgets/close_zen_button.js";
|
||||
|
||||
const MOBILE_CSS = `
|
||||
<style>
|
||||
@@ -162,7 +163,7 @@ export default class MobileLayout {
|
||||
.filling()
|
||||
.contentSized()
|
||||
.child(new NoteDetailWidget())
|
||||
.child(new NoteListWidget())
|
||||
.child(new NoteListWidget(false))
|
||||
.child(new FilePropertiesWidget().css("font-size", "smaller"))
|
||||
)
|
||||
.child(new MobileEditorToolbar())
|
||||
@@ -174,7 +175,8 @@ export default class MobileLayout {
|
||||
.id("mobile-bottom-bar")
|
||||
.child(new TabRowWidget().css("height", "40px"))
|
||||
.child(new FlexContainer("row").class("horizontal").css("height", "53px").child(new LauncherContainer(true)).child(new GlobalMenuWidget(true)).id("launcher-pane"))
|
||||
);
|
||||
)
|
||||
.child(new CloseZenButton());
|
||||
applyModals(rootContainer);
|
||||
return rootContainer;
|
||||
}
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
// Source: https://github.com/codemirror/codemirror5/pull/7080/files
|
||||
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
||||
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("hcl", function (config) {
|
||||
var indentUnit = config.indentUnit;
|
||||
|
||||
var keywords = {
|
||||
"resource": true,
|
||||
"variable": true,
|
||||
"output": true,
|
||||
"module": true,
|
||||
"provider": true,
|
||||
"data": true,
|
||||
"locals": true,
|
||||
"terraform": true,
|
||||
"if": true,
|
||||
"else": true,
|
||||
"for": true,
|
||||
"foreach": true,
|
||||
"in": true,
|
||||
"true": true,
|
||||
"false": true,
|
||||
"null": true,
|
||||
};
|
||||
|
||||
var atoms = {
|
||||
"true": true,
|
||||
"false": true,
|
||||
"null": true,
|
||||
};
|
||||
|
||||
var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'" || ch == "`") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\d\.]/.test(ch)) {
|
||||
if (ch == ".") {
|
||||
stream.match(/^[0-9_]+([eE][\-+]?[0-9_]+)?/);
|
||||
} else {
|
||||
stream.match(/^[0-9_]*\.?[0-9_]*([eE][\-+]?[0-9_]+)?/);
|
||||
}
|
||||
return "number";
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
return "keyword";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function (stream, state) {
|
||||
var escaped = false,
|
||||
next,
|
||||
end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && quote != "`" && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || quote == "`"))
|
||||
state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
if (!state.context.prev) return;
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function (basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function (stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}" && ctx.type == "}") popContext(state);
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function (state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (firstChar == "#" || firstChar == ";") return 0;
|
||||
if (stream.sol()) {
|
||||
if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
|
||||
state.context.type = "}";
|
||||
return ctx.indented;
|
||||
}
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
}
|
||||
},
|
||||
|
||||
electricChars: "{}):",
|
||||
closeBrackets: "()[]{}''\"\"``",
|
||||
fold: "brace",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-hcl", "hcl");
|
||||
CodeMirror.modeInfo.push({
|
||||
ext: [ "hcl " ],
|
||||
mime: "text/x-hcl",
|
||||
mode: "hcl",
|
||||
name: "Terraform (HCL)"
|
||||
});
|
||||
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import keyboardActionService from "../services/keyboard_actions.js";
|
||||
import note_tooltip from "../services/note_tooltip.js";
|
||||
import utils from "../services/utils.js";
|
||||
|
||||
interface ContextMenuOptions<T> {
|
||||
export interface ContextMenuOptions<T> {
|
||||
x: number;
|
||||
y: number;
|
||||
orientation?: "left";
|
||||
@@ -17,17 +17,30 @@ interface MenuSeparatorItem {
|
||||
title: "----";
|
||||
}
|
||||
|
||||
export interface MenuItemBadge {
|
||||
title: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export interface MenuCommandItem<T> {
|
||||
title: string;
|
||||
command?: T;
|
||||
type?: string;
|
||||
/**
|
||||
* The icon to display in the menu item.
|
||||
*
|
||||
* If not set, no icon is displayed and the item will appear shifted slightly to the left if there are other items with icons. To avoid this, use `bx bx-empty`.
|
||||
*/
|
||||
uiIcon?: string;
|
||||
badges?: MenuItemBadge[];
|
||||
templateNoteId?: string;
|
||||
enabled?: boolean;
|
||||
handler?: MenuHandler<T>;
|
||||
items?: MenuItem<T>[] | null;
|
||||
shortcut?: string;
|
||||
spellingSuggestion?: string;
|
||||
checked?: boolean;
|
||||
columns?: number;
|
||||
}
|
||||
|
||||
export type MenuItem<T> = MenuCommandItem<T> | MenuSeparatorItem;
|
||||
@@ -146,17 +159,32 @@ class ContextMenu {
|
||||
} else {
|
||||
const $icon = $("<span>");
|
||||
|
||||
if ("uiIcon" in item && item.uiIcon) {
|
||||
$icon.addClass(item.uiIcon);
|
||||
if ("uiIcon" in item || "checked" in item) {
|
||||
const icon = (item.checked ? "bx bx-check" : item.uiIcon);
|
||||
if (icon) {
|
||||
$icon.addClass(icon);
|
||||
} else {
|
||||
$icon.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
const $link = $("<span>")
|
||||
.append($icon)
|
||||
.append(" ") // some space between icon and text
|
||||
.append(item.title);
|
||||
|
||||
if ("badges" in item && item.badges) {
|
||||
for (let badge of item.badges) {
|
||||
const badgeElement = $(`<span class="badge">`).text(badge.title);
|
||||
|
||||
if (badge.className) {
|
||||
badgeElement.addClass(badge.className);
|
||||
}
|
||||
|
||||
$link.append(badgeElement);
|
||||
}
|
||||
}
|
||||
|
||||
if ("shortcut" in item && item.shortcut) {
|
||||
$link.append($("<kbd>").text(item.shortcut));
|
||||
}
|
||||
@@ -194,14 +222,15 @@ class ContextMenu {
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!this.isMobile) {
|
||||
$item.on("mouseup", (e) =>{
|
||||
$item.on("mouseup", (e) => {
|
||||
// Prevent submenu from failing to expand on mobile
|
||||
if (!this.isMobile || !("items" in item && item.items)) {
|
||||
e.stopPropagation();
|
||||
// Hide the content menu on mouse up to prevent the mouse event from propagating to the elements below.
|
||||
this.hide();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if ("enabled" in item && item.enabled !== undefined && !item.enabled) {
|
||||
$item.addClass("disabled");
|
||||
@@ -212,6 +241,9 @@ class ContextMenu {
|
||||
$link.addClass("dropdown-toggle");
|
||||
|
||||
const $subMenu = $("<ul>").addClass("dropdown-menu");
|
||||
if (!this.isMobile && item.columns) {
|
||||
$subMenu.css("column-count", item.columns);
|
||||
}
|
||||
|
||||
this.addItems($subMenu, item.items);
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ import { t } from "../services/i18n.js";
|
||||
import utils from "../services/utils.js";
|
||||
import contextMenu from "./context_menu.js";
|
||||
import imageService from "../services/image.js";
|
||||
import mediaViewer from "../services/media_viewer.js";
|
||||
import type { MediaItem } from "../services/media_viewer.js";
|
||||
|
||||
const PROP_NAME = "imageContextMenuInstalled";
|
||||
|
||||
@@ -18,6 +20,12 @@ function setupContextMenu($image: JQuery<HTMLElement>) {
|
||||
x: e.pageX,
|
||||
y: e.pageY,
|
||||
items: [
|
||||
{
|
||||
title: "View in Lightbox",
|
||||
command: "viewInLightbox",
|
||||
uiIcon: "bx bx-expand",
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
title: t("image_context_menu.copy_reference_to_clipboard"),
|
||||
command: "copyImageReferenceToClipboard",
|
||||
@@ -30,7 +38,48 @@ function setupContextMenu($image: JQuery<HTMLElement>) {
|
||||
}
|
||||
],
|
||||
selectMenuItemHandler: async ({ command }) => {
|
||||
if (command === "copyImageReferenceToClipboard") {
|
||||
if (command === "viewInLightbox") {
|
||||
const src = $image.attr("src");
|
||||
const alt = $image.attr("alt");
|
||||
const title = $image.attr("title");
|
||||
|
||||
if (!src) {
|
||||
console.error("Missing image source");
|
||||
return;
|
||||
}
|
||||
|
||||
const item: MediaItem = {
|
||||
src: src,
|
||||
alt: alt || "Image",
|
||||
title: title || alt,
|
||||
element: $image[0] as HTMLElement
|
||||
};
|
||||
|
||||
// Try to get actual dimensions
|
||||
const imgElement = $image[0] as HTMLImageElement;
|
||||
if (imgElement.naturalWidth && imgElement.naturalHeight) {
|
||||
item.width = imgElement.naturalWidth;
|
||||
item.height = imgElement.naturalHeight;
|
||||
}
|
||||
|
||||
mediaViewer.openSingle(item, {
|
||||
bgOpacity: 0.95,
|
||||
showHideOpacity: true,
|
||||
pinchToClose: true,
|
||||
closeOnScroll: false,
|
||||
closeOnVerticalDrag: true,
|
||||
wheelToZoom: true,
|
||||
getThumbBoundsFn: () => {
|
||||
// Get position for zoom animation
|
||||
const rect = imgElement.getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left,
|
||||
y: rect.top,
|
||||
w: rect.width
|
||||
};
|
||||
}
|
||||
});
|
||||
} else if (command === "copyImageReferenceToClipboard") {
|
||||
imageService.copyImageReferenceToClipboard($image);
|
||||
} else if (command === "copyImageToClipboard") {
|
||||
try {
|
||||
|
||||
@@ -16,7 +16,8 @@ function getItems(): MenuItem<CommandNames>[] {
|
||||
return [
|
||||
{ title: t("link_context_menu.open_note_in_new_tab"), command: "openNoteInNewTab", uiIcon: "bx bx-link-external" },
|
||||
{ title: t("link_context_menu.open_note_in_new_split"), command: "openNoteInNewSplit", uiIcon: "bx bx-dock-right" },
|
||||
{ title: t("link_context_menu.open_note_in_new_window"), command: "openNoteInNewWindow", uiIcon: "bx bx-window-open" }
|
||||
{ title: t("link_context_menu.open_note_in_new_window"), command: "openNoteInNewWindow", uiIcon: "bx bx-window-open" },
|
||||
{ title: t("link_context_menu.open_note_in_popup"), command: "openNoteInPopup", uiIcon: "bx bx-edit" }
|
||||
];
|
||||
}
|
||||
|
||||
@@ -40,6 +41,8 @@ function handleLinkContextMenuItem(command: string | undefined, notePath: string
|
||||
appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath, hoistedNoteId, viewScope });
|
||||
} else if (command === "openNoteInNewWindow") {
|
||||
appContext.triggerCommand("openInWindow", { notePath, hoistedNoteId, viewScope });
|
||||
} else if (command === "openNoteInPopup") {
|
||||
appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ let lastTargetNode: HTMLElement | null = null;
|
||||
|
||||
// This will include all commands that implement ContextMenuCommandData, but it will not work if it additional options are added via the `|` operator,
|
||||
// so they need to be added manually.
|
||||
export type TreeCommandNames = FilteredCommandNames<ContextMenuCommandData> | "openBulkActionsDialog";
|
||||
export type TreeCommandNames = FilteredCommandNames<ContextMenuCommandData> | "openBulkActionsDialog" | "searchInSubtree";
|
||||
|
||||
export default class TreeContextMenu implements SelectMenuItemEventListener<TreeCommandNames> {
|
||||
private treeWidget: NoteTreeWidget;
|
||||
@@ -70,8 +70,8 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
|
||||
const items: (MenuItem<TreeCommandNames> | null)[] = [
|
||||
{ title: `${t("tree-context-menu.open-in-a-new-tab")}`, command: "openInTab", uiIcon: "bx bx-link-external", enabled: noSelectedNotes },
|
||||
|
||||
{ title: t("tree-context-menu.open-in-a-new-split"), command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes },
|
||||
{ title: t("tree-context-menu.open-in-popup"), command: "openNoteInPopup", uiIcon: "bx bx-edit", enabled: noSelectedNotes },
|
||||
|
||||
isHoisted
|
||||
? null
|
||||
@@ -92,7 +92,8 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
command: "insertNoteAfter",
|
||||
uiIcon: "bx bx-plus",
|
||||
items: insertNoteAfterEnabled ? await noteTypesService.getNoteTypeItems("insertNoteAfter") : null,
|
||||
enabled: insertNoteAfterEnabled && noSelectedNotes && notOptionsOrHelp
|
||||
enabled: insertNoteAfterEnabled && noSelectedNotes && notOptionsOrHelp,
|
||||
columns: 2
|
||||
},
|
||||
|
||||
{
|
||||
@@ -100,7 +101,8 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
command: "insertChildNote",
|
||||
uiIcon: "bx bx-plus",
|
||||
items: notSearch ? await noteTypesService.getNoteTypeItems("insertChildNote") : null,
|
||||
enabled: notSearch && noSelectedNotes && notOptionsOrHelp
|
||||
enabled: notSearch && noSelectedNotes && notOptionsOrHelp,
|
||||
columns: 2
|
||||
},
|
||||
|
||||
{ title: "----" },
|
||||
@@ -127,12 +129,6 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
enabled: isNotRoot && parentNotSearch && noSelectedNotes && notOptionsOrHelp
|
||||
},
|
||||
{ title: t("tree-context-menu.convert-to-attachment"), command: "convertNoteToAttachment", uiIcon: "bx bx-paperclip", enabled: isNotRoot && !isHoisted && notOptionsOrHelp },
|
||||
{
|
||||
title: `${t("tree-context-menu.duplicate-subtree")} <kbd data-command="duplicateSubtree">`,
|
||||
command: "duplicateSubtree",
|
||||
uiIcon: "bx bx-outline",
|
||||
enabled: parentNotSearch && isNotRoot && !isHoisted && notOptionsOrHelp
|
||||
},
|
||||
|
||||
{ title: "----" },
|
||||
|
||||
@@ -186,6 +182,13 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
|
||||
{ title: `${t("tree-context-menu.clone-to")} <kbd data-command="cloneNotesTo"></kbd>`, command: "cloneNotesTo", uiIcon: "bx bx-duplicate", enabled: isNotRoot && !isHoisted },
|
||||
|
||||
{
|
||||
title: `${t("tree-context-menu.duplicate")} <kbd data-command="duplicateSubtree">`,
|
||||
command: "duplicateSubtree",
|
||||
uiIcon: "bx bx-outline",
|
||||
enabled: parentNotSearch && isNotRoot && !isHoisted && notOptionsOrHelp
|
||||
},
|
||||
|
||||
{
|
||||
title: `${t("tree-context-menu.delete")} <kbd data-command="deleteNotes"></kbd>`,
|
||||
command: "deleteNotes",
|
||||
@@ -244,6 +247,8 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
const { ntxId } = subContexts?.[subContexts.length - 1] ?? {};
|
||||
|
||||
this.treeWidget.triggerCommand("openNewNoteSplit", { ntxId, notePath });
|
||||
} else if (command === "openNoteInPopup") {
|
||||
appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath })
|
||||
} else if (command === "convertNoteToAttachment") {
|
||||
if (!(await dialogService.confirm(t("tree-context-menu.convert-to-attachment-confirm")))) {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ import noteAutocompleteService from "./services/note_autocomplete.js";
|
||||
import glob from "./services/glob.js";
|
||||
import "./stylesheets/bootstrap.scss";
|
||||
import "boxicons/css/boxicons.min.css";
|
||||
import "./stylesheets/media-viewer.css";
|
||||
import "autocomplete.js/index_jquery.js";
|
||||
|
||||
glob.setupGlobs();
|
||||
|
||||
@@ -23,4 +23,4 @@ export interface EntityChange {
|
||||
instanceId?: string | null;
|
||||
}
|
||||
|
||||
export type EntityType = "notes" | "branches" | "attributes" | "note_reordering" | "revisions" | "options" | "attachments" | "blobs" | "etapi_tokens" | "note_embeddings";
|
||||
export type EntityType = "notes" | "branches" | "attributes" | "note_reordering" | "revisions" | "options" | "attachments" | "blobs" | "etapi_tokens";
|
||||
|
||||
@@ -79,7 +79,19 @@ async function renderAttributes(attributes: FAttribute[], renderIsInheritable: b
|
||||
return $container;
|
||||
}
|
||||
|
||||
const HIDDEN_ATTRIBUTES = ["originalFileName", "fileSize", "template", "inherit", "cssClass", "iconClass", "pageSize", "viewType", "geolocation", "docName"];
|
||||
const HIDDEN_ATTRIBUTES = [
|
||||
"originalFileName",
|
||||
"fileSize",
|
||||
"template",
|
||||
"inherit",
|
||||
"cssClass",
|
||||
"iconClass",
|
||||
"pageSize",
|
||||
"viewType",
|
||||
"geolocation",
|
||||
"docName",
|
||||
"webViewSrc"
|
||||
];
|
||||
|
||||
async function renderNormalAttributes(note: FNote) {
|
||||
const promotedDefinitionAttributes = note.getPromotedDefinitionAttributes();
|
||||
|
||||
@@ -3,19 +3,21 @@ import froca from "./froca.js";
|
||||
import type FNote from "../entities/fnote.js";
|
||||
import type { AttributeRow } from "./load_results.js";
|
||||
|
||||
async function addLabel(noteId: string, name: string, value: string = "") {
|
||||
async function addLabel(noteId: string, name: string, value: string = "", isInheritable = false) {
|
||||
await server.put(`notes/${noteId}/attribute`, {
|
||||
type: "label",
|
||||
name: name,
|
||||
value: value
|
||||
value: value,
|
||||
isInheritable
|
||||
});
|
||||
}
|
||||
|
||||
async function setLabel(noteId: string, name: string, value: string = "") {
|
||||
export async function setLabel(noteId: string, name: string, value: string = "", isInheritable = false) {
|
||||
await server.put(`notes/${noteId}/set-attribute`, {
|
||||
type: "label",
|
||||
name: name,
|
||||
value: value
|
||||
value: value,
|
||||
isInheritable
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,7 +51,7 @@ function removeOwnedLabelByName(note: FNote, labelName: string) {
|
||||
* @param name the name of the attribute to set.
|
||||
* @param value the value of the attribute to set.
|
||||
*/
|
||||
async function setAttribute(note: FNote, type: "label" | "relation", name: string, value: string | null | undefined) {
|
||||
export async function setAttribute(note: FNote, type: "label" | "relation", name: string, value: string | null | undefined) {
|
||||
if (value) {
|
||||
// Create or update the attribute.
|
||||
await server.put(`notes/${note.noteId}/set-attribute`, { type, name, value });
|
||||
|
||||
@@ -95,7 +95,15 @@ async function moveToParentNote(branchIdsToMove: string[], newParentBranchId: st
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteNotes(branchIdsToDelete: string[], forceDeleteAllClones = false) {
|
||||
/**
|
||||
* Shows the delete confirmation screen
|
||||
*
|
||||
* @param branchIdsToDelete the list of branch IDs to delete.
|
||||
* @param forceDeleteAllClones whether to check by default the "Delete also all clones" checkbox.
|
||||
* @param moveToParent whether to automatically go to the parent note path after a succesful delete. Usually makes sense if deleting the active note(s).
|
||||
* @returns promise that returns false if the operation was cancelled or there was nothing to delete, true if the operation succeeded.
|
||||
*/
|
||||
async function deleteNotes(branchIdsToDelete: string[], forceDeleteAllClones = false, moveToParent = true) {
|
||||
branchIdsToDelete = filterRootNote(branchIdsToDelete);
|
||||
|
||||
if (branchIdsToDelete.length === 0) {
|
||||
@@ -110,11 +118,13 @@ async function deleteNotes(branchIdsToDelete: string[], forceDeleteAllClones = f
|
||||
return false;
|
||||
}
|
||||
|
||||
if (moveToParent) {
|
||||
try {
|
||||
await activateParentNotePath();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
const taskId = utils.randomString(10);
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import AddRelationBulkAction from "../widgets/bulk_actions/relation/add_relation
|
||||
import RenameNoteBulkAction from "../widgets/bulk_actions/note/rename_note.js";
|
||||
import { t } from "./i18n.js";
|
||||
import type FNote from "../entities/fnote.js";
|
||||
import toast from "./toast.js";
|
||||
import { BulkAction } from "@triliumnext/commons";
|
||||
|
||||
const ACTION_GROUPS = [
|
||||
{
|
||||
@@ -89,6 +91,17 @@ function parseActions(note: FNote) {
|
||||
.filter((action) => !!action);
|
||||
}
|
||||
|
||||
export async function executeBulkActions(targetNoteIds: string[], actions: BulkAction[], includeDescendants = false) {
|
||||
await server.post("bulk-action/execute", {
|
||||
noteIds: targetNoteIds,
|
||||
includeDescendants,
|
||||
actions
|
||||
});
|
||||
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
toast.showMessage(t("bulk_actions.bulk_actions_executed"), 3000);
|
||||
}
|
||||
|
||||
export default {
|
||||
addAction,
|
||||
parseActions,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ScriptContext from "./script_context.js";
|
||||
import server from "./server.js";
|
||||
import toastService from "./toast.js";
|
||||
import toastService, { showError } from "./toast.js";
|
||||
import froca from "./froca.js";
|
||||
import utils from "./utils.js";
|
||||
import { t } from "./i18n.js";
|
||||
@@ -37,7 +37,9 @@ async function executeBundle(bundle: Bundle, originEntity?: Entity | null, $cont
|
||||
} catch (e: any) {
|
||||
const note = await froca.getNote(bundle.noteId);
|
||||
|
||||
toastService.showAndLogError(`Execution of JS note "${note?.title}" with ID ${bundle.noteId} failed with error: ${e?.message}`);
|
||||
const message = `Execution of JS note "${note?.title}" with ID ${bundle.noteId} failed with error: ${e?.message}`;
|
||||
showError(message);
|
||||
logError(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
521
apps/client/src/services/ckeditor_photoswipe_integration.ts
Normal file
521
apps/client/src/services/ckeditor_photoswipe_integration.ts
Normal file
@@ -0,0 +1,521 @@
|
||||
/**
|
||||
* CKEditor PhotoSwipe Integration
|
||||
* Handles click-to-lightbox functionality for images in CKEditor content
|
||||
*/
|
||||
|
||||
import mediaViewer from './media_viewer.js';
|
||||
import galleryManager from './gallery_manager.js';
|
||||
import appContext from '../components/app_context.js';
|
||||
import type { MediaItem } from './media_viewer.js';
|
||||
import type { GalleryItem } from './gallery_manager.js';
|
||||
|
||||
/**
|
||||
* Configuration for CKEditor PhotoSwipe integration
|
||||
*/
|
||||
interface CKEditorPhotoSwipeConfig {
|
||||
enableGalleryMode?: boolean;
|
||||
showHints?: boolean;
|
||||
hintDelay?: number;
|
||||
excludeSelector?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Integration manager for CKEditor and PhotoSwipe
|
||||
*/
|
||||
class CKEditorPhotoSwipeIntegration {
|
||||
private static instance: CKEditorPhotoSwipeIntegration;
|
||||
private config: Required<CKEditorPhotoSwipeConfig>;
|
||||
private observers: Map<HTMLElement, MutationObserver> = new Map();
|
||||
private processedImages: WeakSet<HTMLImageElement> = new WeakSet();
|
||||
private containerGalleries: Map<HTMLElement, GalleryItem[]> = new Map();
|
||||
private hintPool: HTMLElement[] = [];
|
||||
private activeHints: Map<string, HTMLElement> = new Map();
|
||||
private hintTimeouts: Map<string, number> = new Map();
|
||||
|
||||
private constructor() {
|
||||
this.config = {
|
||||
enableGalleryMode: true,
|
||||
showHints: true,
|
||||
hintDelay: 2000,
|
||||
excludeSelector: '.no-lightbox, .cke_widget_element'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get singleton instance
|
||||
*/
|
||||
static getInstance(): CKEditorPhotoSwipeIntegration {
|
||||
if (!CKEditorPhotoSwipeIntegration.instance) {
|
||||
CKEditorPhotoSwipeIntegration.instance = new CKEditorPhotoSwipeIntegration();
|
||||
}
|
||||
return CKEditorPhotoSwipeIntegration.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup integration for a CKEditor content container
|
||||
*/
|
||||
setupContainer(container: HTMLElement | JQuery<HTMLElement>, config?: Partial<CKEditorPhotoSwipeConfig>): void {
|
||||
const element = container instanceof $ ? container[0] : container;
|
||||
if (!element) return;
|
||||
|
||||
// Merge configuration
|
||||
if (config) {
|
||||
this.config = { ...this.config, ...config };
|
||||
}
|
||||
|
||||
// Process existing images
|
||||
this.processImages(element);
|
||||
|
||||
// Setup mutation observer for dynamically added images
|
||||
this.observeContainer(element);
|
||||
|
||||
// Setup gallery if enabled
|
||||
if (this.config.enableGalleryMode) {
|
||||
this.setupGalleryMode(element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process all images in a container
|
||||
*/
|
||||
private processImages(container: HTMLElement): void {
|
||||
const images = container.querySelectorAll<HTMLImageElement>(`img:not(${this.config.excludeSelector})`);
|
||||
|
||||
images.forEach(img => {
|
||||
if (!this.processedImages.has(img)) {
|
||||
this.setupImageLightbox(img);
|
||||
this.processedImages.add(img);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup lightbox for a single image
|
||||
*/
|
||||
private setupImageLightbox(img: HTMLImageElement): void {
|
||||
// Skip if already processed or is a CKEditor widget element
|
||||
if (img.closest('.cke_widget_element') || img.closest('.ck-widget')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make image clickable and mark it as PhotoSwipe-enabled
|
||||
img.style.cursor = 'zoom-in';
|
||||
img.style.transition = 'opacity 0.2s';
|
||||
img.classList.add('photoswipe-enabled');
|
||||
img.setAttribute('data-photoswipe', 'true');
|
||||
|
||||
// Store event handlers for cleanup
|
||||
const mouseEnterHandler = () => {
|
||||
img.style.opacity = '0.9';
|
||||
if (this.config.showHints) {
|
||||
this.showHint(img);
|
||||
}
|
||||
};
|
||||
|
||||
const mouseLeaveHandler = () => {
|
||||
img.style.opacity = '1';
|
||||
this.hideHint(img);
|
||||
};
|
||||
|
||||
// Add hover effect with cleanup tracking
|
||||
img.addEventListener('mouseenter', mouseEnterHandler);
|
||||
img.addEventListener('mouseleave', mouseLeaveHandler);
|
||||
|
||||
// Store handlers for cleanup
|
||||
(img as any)._photoswipeHandlers = { mouseEnterHandler, mouseLeaveHandler };
|
||||
|
||||
// Add double-click handler to prevent default navigation behavior
|
||||
const dblClickHandler = (e: MouseEvent) => {
|
||||
// Only prevent double-click in specific contexts to avoid breaking other features
|
||||
if (img.closest('.attachment-detail-wrapper') ||
|
||||
img.closest('.note-detail-editable-text') ||
|
||||
img.closest('.note-detail-readonly-text')) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
// Trigger the same behavior as single click (open lightbox)
|
||||
img.click();
|
||||
}
|
||||
};
|
||||
|
||||
img.addEventListener('dblclick', dblClickHandler, true); // Use capture phase to ensure we get it first
|
||||
(img as any)._photoswipeHandlers.dblClickHandler = dblClickHandler;
|
||||
|
||||
// Add click handler
|
||||
img.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Check if we should open as gallery
|
||||
const container = img.closest('.note-detail-editable-text, .note-detail-readonly-text');
|
||||
if (container && this.config.enableGalleryMode) {
|
||||
const gallery = this.containerGalleries.get(container as HTMLElement);
|
||||
if (gallery && gallery.length > 1) {
|
||||
// Find index of clicked image
|
||||
const index = gallery.findIndex(item => {
|
||||
const itemElement = document.querySelector(`img[src="${item.src}"]`);
|
||||
return itemElement === img;
|
||||
});
|
||||
|
||||
galleryManager.openGallery(gallery, index >= 0 ? index : 0, {
|
||||
showThumbnails: true,
|
||||
showCounter: true,
|
||||
enableKeyboardNav: true,
|
||||
loop: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Open single image
|
||||
this.openSingleImage(img);
|
||||
});
|
||||
|
||||
// Add keyboard support
|
||||
img.setAttribute('tabindex', '0');
|
||||
img.setAttribute('role', 'button');
|
||||
img.setAttribute('aria-label', 'Click to view in lightbox');
|
||||
|
||||
img.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
img.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a single image in lightbox
|
||||
*/
|
||||
private openSingleImage(img: HTMLImageElement): void {
|
||||
const item: MediaItem = {
|
||||
src: img.src,
|
||||
alt: img.alt || 'Image',
|
||||
title: img.title || img.alt,
|
||||
element: img,
|
||||
width: img.naturalWidth || undefined,
|
||||
height: img.naturalHeight || undefined
|
||||
};
|
||||
|
||||
mediaViewer.openSingle(item, {
|
||||
bgOpacity: 0.95,
|
||||
showHideOpacity: true,
|
||||
pinchToClose: true,
|
||||
closeOnScroll: false,
|
||||
closeOnVerticalDrag: true,
|
||||
wheelToZoom: true,
|
||||
getThumbBoundsFn: () => {
|
||||
const rect = img.getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left,
|
||||
y: rect.top,
|
||||
w: rect.width
|
||||
};
|
||||
}
|
||||
}, {
|
||||
onClose: () => {
|
||||
// Check if we're in attachment detail view and need to reset viewScope
|
||||
const activeContext = appContext.tabManager.getActiveContext();
|
||||
if (activeContext?.viewScope?.viewMode === 'attachments') {
|
||||
// Get the note ID from the image source
|
||||
const attachmentMatch = img.src.match(/\/api\/attachments\/([A-Za-z0-9_]+)\/image\//);
|
||||
if (attachmentMatch) {
|
||||
const currentAttachmentId = activeContext.viewScope.attachmentId;
|
||||
if (currentAttachmentId === attachmentMatch[1]) {
|
||||
// Actually reset the viewScope instead of just logging
|
||||
try {
|
||||
if (activeContext.note) {
|
||||
activeContext.setNote(activeContext.note.noteId, {
|
||||
viewScope: { viewMode: 'default' }
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to reset viewScope after PhotoSwipe close:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Restore focus to the image
|
||||
img.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup gallery mode for a container
|
||||
*/
|
||||
private setupGalleryMode(container: HTMLElement): void {
|
||||
const images = container.querySelectorAll<HTMLImageElement>(`img:not(${this.config.excludeSelector})`);
|
||||
if (images.length <= 1) return;
|
||||
|
||||
const galleryItems: GalleryItem[] = [];
|
||||
|
||||
images.forEach((img, index) => {
|
||||
// Skip CKEditor widget elements
|
||||
if (img.closest('.cke_widget_element') || img.closest('.ck-widget')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const item: GalleryItem = {
|
||||
src: img.src,
|
||||
alt: img.alt || `Image ${index + 1}`,
|
||||
title: img.title || img.alt,
|
||||
element: img,
|
||||
index: index,
|
||||
width: img.naturalWidth || undefined,
|
||||
height: img.naturalHeight || undefined
|
||||
};
|
||||
|
||||
// Check for caption
|
||||
const figure = img.closest('figure');
|
||||
if (figure) {
|
||||
const caption = figure.querySelector('figcaption');
|
||||
if (caption) {
|
||||
item.caption = caption.textContent || undefined;
|
||||
}
|
||||
}
|
||||
|
||||
galleryItems.push(item);
|
||||
});
|
||||
|
||||
if (galleryItems.length > 0) {
|
||||
this.containerGalleries.set(container, galleryItems);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Observe container for dynamic changes
|
||||
*/
|
||||
private observeContainer(container: HTMLElement): void {
|
||||
// Disconnect existing observer if any
|
||||
const existingObserver = this.observers.get(container);
|
||||
if (existingObserver) {
|
||||
existingObserver.disconnect();
|
||||
}
|
||||
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
let hasNewImages = false;
|
||||
|
||||
mutations.forEach(mutation => {
|
||||
if (mutation.type === 'childList') {
|
||||
mutation.addedNodes.forEach(node => {
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
const element = node as HTMLElement;
|
||||
if (element.tagName === 'IMG') {
|
||||
hasNewImages = true;
|
||||
} else if (element.querySelector('img')) {
|
||||
hasNewImages = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (hasNewImages) {
|
||||
// Process new images
|
||||
this.processImages(container);
|
||||
|
||||
// Update gallery if enabled
|
||||
if (this.config.enableGalleryMode) {
|
||||
this.setupGalleryMode(container);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(container, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
this.observers.set(container, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create a hint element from the pool
|
||||
*/
|
||||
private getHintFromPool(): HTMLElement {
|
||||
let hint = this.hintPool.pop();
|
||||
if (!hint) {
|
||||
hint = document.createElement('div');
|
||||
hint.className = 'ckeditor-image-hint';
|
||||
hint.textContent = 'Click to view in lightbox';
|
||||
hint.style.cssText = `
|
||||
position: absolute;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: white;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
display: none;
|
||||
`;
|
||||
}
|
||||
return hint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return hint to pool
|
||||
*/
|
||||
private returnHintToPool(hint: HTMLElement): void {
|
||||
hint.style.opacity = '0';
|
||||
hint.style.display = 'none';
|
||||
if (this.hintPool.length < 10) { // Keep max 10 hints in pool
|
||||
this.hintPool.push(hint);
|
||||
} else {
|
||||
hint.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show hint for an image
|
||||
*/
|
||||
private showHint(img: HTMLImageElement): void {
|
||||
// Check if hint already exists
|
||||
const imgId = img.dataset.imgId || `img-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
||||
if (!img.dataset.imgId) {
|
||||
img.dataset.imgId = imgId;
|
||||
}
|
||||
|
||||
// Clear any existing timeout
|
||||
const existingTimeout = this.hintTimeouts.get(imgId);
|
||||
if (existingTimeout) {
|
||||
clearTimeout(existingTimeout);
|
||||
this.hintTimeouts.delete(imgId);
|
||||
}
|
||||
|
||||
let hint = this.activeHints.get(imgId);
|
||||
if (hint) {
|
||||
hint.style.opacity = '1';
|
||||
return;
|
||||
}
|
||||
|
||||
// Get hint from pool
|
||||
hint = this.getHintFromPool();
|
||||
this.activeHints.set(imgId, hint);
|
||||
|
||||
// Position and show hint
|
||||
if (!hint.parentElement) {
|
||||
document.body.appendChild(hint);
|
||||
}
|
||||
|
||||
const imgRect = img.getBoundingClientRect();
|
||||
hint.style.display = 'block';
|
||||
hint.style.left = `${imgRect.left + (imgRect.width - hint.offsetWidth) / 2}px`;
|
||||
hint.style.top = `${imgRect.top - hint.offsetHeight - 5}px`;
|
||||
|
||||
// Show hint
|
||||
requestAnimationFrame(() => {
|
||||
hint.style.opacity = '1';
|
||||
});
|
||||
|
||||
// Auto-hide after delay
|
||||
const timeout = window.setTimeout(() => {
|
||||
this.hideHint(img);
|
||||
}, this.config.hintDelay);
|
||||
this.hintTimeouts.set(imgId, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide hint for an image
|
||||
*/
|
||||
private hideHint(img: HTMLImageElement): void {
|
||||
const imgId = img.dataset.imgId;
|
||||
if (!imgId) return;
|
||||
|
||||
// Clear timeout
|
||||
const timeout = this.hintTimeouts.get(imgId);
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
this.hintTimeouts.delete(imgId);
|
||||
}
|
||||
|
||||
const hint = this.activeHints.get(imgId);
|
||||
if (hint) {
|
||||
hint.style.opacity = '0';
|
||||
this.activeHints.delete(imgId);
|
||||
|
||||
setTimeout(() => {
|
||||
this.returnHintToPool(hint);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup integration for a container
|
||||
*/
|
||||
cleanupContainer(container: HTMLElement | JQuery<HTMLElement>): void {
|
||||
const element = container instanceof $ ? container[0] : container;
|
||||
if (!element) return;
|
||||
|
||||
// Disconnect observer
|
||||
const observer = this.observers.get(element);
|
||||
if (observer) {
|
||||
observer.disconnect();
|
||||
this.observers.delete(element);
|
||||
}
|
||||
|
||||
// Clear gallery
|
||||
this.containerGalleries.delete(element);
|
||||
|
||||
// Remove event handlers and hints
|
||||
const images = element.querySelectorAll<HTMLImageElement>('img');
|
||||
images.forEach(img => {
|
||||
this.hideHint(img);
|
||||
|
||||
// Remove event handlers
|
||||
const handlers = (img as any)._photoswipeHandlers;
|
||||
if (handlers) {
|
||||
img.removeEventListener('mouseenter', handlers.mouseEnterHandler);
|
||||
img.removeEventListener('mouseleave', handlers.mouseLeaveHandler);
|
||||
if (handlers.dblClickHandler) {
|
||||
img.removeEventListener('dblclick', handlers.dblClickHandler, true);
|
||||
}
|
||||
delete (img as any)._photoswipeHandlers;
|
||||
}
|
||||
|
||||
// Mark as unprocessed
|
||||
this.processedImages.delete(img);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update configuration
|
||||
*/
|
||||
updateConfig(config: Partial<CKEditorPhotoSwipeConfig>): void {
|
||||
this.config = { ...this.config, ...config };
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup all integrations
|
||||
*/
|
||||
cleanup(): void {
|
||||
// Disconnect all observers
|
||||
this.observers.forEach(observer => observer.disconnect());
|
||||
this.observers.clear();
|
||||
|
||||
// Clear all galleries
|
||||
this.containerGalleries.clear();
|
||||
|
||||
// Clear all hints
|
||||
this.activeHints.forEach(hint => hint.remove());
|
||||
this.activeHints.clear();
|
||||
|
||||
// Clear all timeouts
|
||||
this.hintTimeouts.forEach(timeout => clearTimeout(timeout));
|
||||
this.hintTimeouts.clear();
|
||||
|
||||
// Clear hint pool
|
||||
this.hintPool.forEach(hint => hint.remove());
|
||||
this.hintPool = [];
|
||||
|
||||
// Clear processed images
|
||||
this.processedImages = new WeakSet();
|
||||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
export default CKEditorPhotoSwipeIntegration.getInstance();
|
||||
@@ -4,7 +4,7 @@ import froca from "./froca.js";
|
||||
import linkService from "./link.js";
|
||||
import utils from "./utils.js";
|
||||
import { t } from "./i18n.js";
|
||||
import toast from "./toast.js";
|
||||
import { throwError } from "./ws.js";
|
||||
|
||||
let clipboardBranchIds: string[] = [];
|
||||
let clipboardMode: string | null = null;
|
||||
@@ -37,7 +37,7 @@ async function pasteAfter(afterBranchId: string) {
|
||||
|
||||
// copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places
|
||||
} else {
|
||||
toastService.throwError(`Unrecognized clipboard mode=${clipboardMode}`);
|
||||
throwError(`Unrecognized clipboard mode=${clipboardMode}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ async function pasteInto(parentBranchId: string) {
|
||||
|
||||
// copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places
|
||||
} else {
|
||||
toastService.throwError(`Unrecognized clipboard mode=${clipboardMode}`);
|
||||
throwError(`Unrecognized clipboard mode=${clipboardMode}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,39 +109,6 @@ function isClipboardEmpty() {
|
||||
return clipboardBranchIds.length === 0;
|
||||
}
|
||||
|
||||
export function copyText(text: string) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
let succeeded = false;
|
||||
|
||||
try {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text);
|
||||
succeeded = true;
|
||||
} else {
|
||||
// Fallback method: https://stackoverflow.com/a/72239825
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
succeeded = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
succeeded = false;
|
||||
}
|
||||
|
||||
if (succeeded) {
|
||||
toast.showMessage(t("clipboard.copy_success"));
|
||||
} else {
|
||||
toast.showError(t("clipboard.copy_failed"));
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
pasteAfter,
|
||||
pasteInto,
|
||||
|
||||
37
apps/client/src/services/clipboard_ext.ts
Normal file
37
apps/client/src/services/clipboard_ext.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export function copyText(text: string) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} else {
|
||||
// Fallback method: https://stackoverflow.com/a/72239825
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
try {
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
return document.execCommand('copy');
|
||||
} finally {
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function copyTextWithToast(text: string) {
|
||||
const t = (await import("./i18n.js")).t;
|
||||
const toast = (await import("./toast.js")).default;
|
||||
|
||||
if (copyText(text)) {
|
||||
toast.showMessage(t("clipboard.copy_success"));
|
||||
} else {
|
||||
toast.showError(t("clipboard.copy_failed"));
|
||||
}
|
||||
}
|
||||
295
apps/client/src/services/command_registry.ts
Normal file
295
apps/client/src/services/command_registry.ts
Normal file
@@ -0,0 +1,295 @@
|
||||
import { ActionKeyboardShortcut } from "@triliumnext/commons";
|
||||
import appContext, { type CommandNames } from "../components/app_context.js";
|
||||
import type NoteTreeWidget from "../widgets/note_tree.js";
|
||||
import { t, translationsInitializedPromise } from "./i18n.js";
|
||||
import keyboardActions from "./keyboard_actions.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
export interface CommandDefinition {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
shortcut?: string;
|
||||
commandName?: CommandNames;
|
||||
handler?: () => Promise<unknown> | null | undefined | void;
|
||||
aliases?: string[];
|
||||
source?: "manual" | "keyboard-action";
|
||||
/** Reference to the original keyboard action for scope checking. */
|
||||
keyboardAction?: ActionKeyboardShortcut;
|
||||
}
|
||||
|
||||
class CommandRegistry {
|
||||
private commands: Map<string, CommandDefinition> = new Map();
|
||||
private aliases: Map<string, string> = new Map();
|
||||
|
||||
constructor() {
|
||||
this.loadCommands();
|
||||
}
|
||||
|
||||
private async loadCommands() {
|
||||
await translationsInitializedPromise;
|
||||
this.registerDefaultCommands();
|
||||
await this.loadKeyboardActionsAsync();
|
||||
}
|
||||
|
||||
private registerDefaultCommands() {
|
||||
this.register({
|
||||
id: "export-note",
|
||||
name: t("command_palette.export_note_title"),
|
||||
description: t("command_palette.export_note_description"),
|
||||
icon: "bx bx-export",
|
||||
handler: () => {
|
||||
const notePath = appContext.tabManager.getActiveContextNotePath();
|
||||
if (notePath) {
|
||||
appContext.triggerCommand("showExportDialog", {
|
||||
notePath,
|
||||
defaultType: "single"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.register({
|
||||
id: "show-attachments",
|
||||
name: t("command_palette.show_attachments_title"),
|
||||
description: t("command_palette.show_attachments_description"),
|
||||
icon: "bx bx-paperclip",
|
||||
handler: () => appContext.triggerCommand("showAttachments")
|
||||
});
|
||||
|
||||
// Special search commands with custom logic
|
||||
this.register({
|
||||
id: "search-notes",
|
||||
name: t("command_palette.search_notes_title"),
|
||||
description: t("command_palette.search_notes_description"),
|
||||
icon: "bx bx-search",
|
||||
handler: () => appContext.triggerCommand("searchNotes", {})
|
||||
});
|
||||
|
||||
this.register({
|
||||
id: "search-in-subtree",
|
||||
name: t("command_palette.search_subtree_title"),
|
||||
description: t("command_palette.search_subtree_description"),
|
||||
icon: "bx bx-search-alt",
|
||||
handler: () => {
|
||||
const notePath = appContext.tabManager.getActiveContextNotePath();
|
||||
if (notePath) {
|
||||
appContext.triggerCommand("searchInSubtree", { notePath });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.register({
|
||||
id: "show-search-history",
|
||||
name: t("command_palette.search_history_title"),
|
||||
description: t("command_palette.search_history_description"),
|
||||
icon: "bx bx-history",
|
||||
handler: () => appContext.triggerCommand("showSearchHistory")
|
||||
});
|
||||
|
||||
this.register({
|
||||
id: "show-launch-bar",
|
||||
name: t("command_palette.configure_launch_bar_title"),
|
||||
description: t("command_palette.configure_launch_bar_description"),
|
||||
icon: "bx bx-sidebar",
|
||||
handler: () => appContext.triggerCommand("showLaunchBarSubtree")
|
||||
});
|
||||
}
|
||||
|
||||
private async loadKeyboardActionsAsync() {
|
||||
try {
|
||||
const actions = await keyboardActions.getActions();
|
||||
this.registerKeyboardActions(actions);
|
||||
} catch (error) {
|
||||
console.error("Failed to load keyboard actions:", error);
|
||||
}
|
||||
}
|
||||
|
||||
private registerKeyboardActions(actions: ActionKeyboardShortcut[]) {
|
||||
for (const action of actions) {
|
||||
// Skip actions that we've already manually registered
|
||||
if (this.commands.has(action.actionName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip actions that don't have a description (likely separators)
|
||||
if (!action.description) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip Electron-only actions if not in Electron environment
|
||||
if (action.isElectronOnly && !utils.isElectron()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip actions that should not appear in the command palette
|
||||
if (action.ignoreFromCommandPalette) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the primary shortcut (first one in the list)
|
||||
const primaryShortcut = action.effectiveShortcuts?.[0];
|
||||
|
||||
let name = action.friendlyName;
|
||||
if (action.scope === "note-tree") {
|
||||
name = t("command_palette.tree-action-name", { name: action.friendlyName });
|
||||
}
|
||||
|
||||
// Create a command definition from the keyboard action
|
||||
const commandDef: CommandDefinition = {
|
||||
id: action.actionName,
|
||||
name,
|
||||
description: action.description,
|
||||
icon: action.iconClass,
|
||||
shortcut: primaryShortcut ? this.formatShortcut(primaryShortcut) : undefined,
|
||||
commandName: action.actionName as CommandNames,
|
||||
source: "keyboard-action",
|
||||
keyboardAction: action
|
||||
};
|
||||
|
||||
this.register(commandDef);
|
||||
}
|
||||
}
|
||||
|
||||
private formatShortcut(shortcut: string): string {
|
||||
// Convert electron accelerator format to display format
|
||||
return shortcut
|
||||
.replace(/CommandOrControl/g, 'Ctrl')
|
||||
.replace(/\+/g, ' + ');
|
||||
}
|
||||
|
||||
register(command: CommandDefinition) {
|
||||
this.commands.set(command.id, command);
|
||||
|
||||
// Register aliases
|
||||
if (command.aliases) {
|
||||
for (const alias of command.aliases) {
|
||||
this.aliases.set(alias.toLowerCase(), command.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getCommand(id: string): CommandDefinition | undefined {
|
||||
return this.commands.get(id);
|
||||
}
|
||||
|
||||
getAllCommands(): CommandDefinition[] {
|
||||
const commands = Array.from(this.commands.values());
|
||||
|
||||
// Sort commands by name
|
||||
commands.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
searchCommands(query: string): CommandDefinition[] {
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
const results: { command: CommandDefinition; score: number }[] = [];
|
||||
|
||||
for (const command of this.commands.values()) {
|
||||
let score = 0;
|
||||
|
||||
// Exact match on name
|
||||
if (command.name.toLowerCase() === normalizedQuery) {
|
||||
score = 100;
|
||||
}
|
||||
// Name starts with query
|
||||
else if (command.name.toLowerCase().startsWith(normalizedQuery)) {
|
||||
score = 80;
|
||||
}
|
||||
// Name contains query
|
||||
else if (command.name.toLowerCase().includes(normalizedQuery)) {
|
||||
score = 60;
|
||||
}
|
||||
// Description contains query
|
||||
else if (command.description?.toLowerCase().includes(normalizedQuery)) {
|
||||
score = 40;
|
||||
}
|
||||
// Check aliases
|
||||
else if (command.aliases?.some(alias => alias.toLowerCase().includes(normalizedQuery))) {
|
||||
score = 50;
|
||||
}
|
||||
|
||||
if (score > 0) {
|
||||
results.push({ command, score });
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by score (highest first) and then by name
|
||||
results.sort((a, b) => {
|
||||
if (a.score !== b.score) {
|
||||
return b.score - a.score;
|
||||
}
|
||||
return a.command.name.localeCompare(b.command.name);
|
||||
});
|
||||
|
||||
return results.map(r => r.command);
|
||||
}
|
||||
|
||||
async executeCommand(commandId: string) {
|
||||
const command = this.getCommand(commandId);
|
||||
if (!command) {
|
||||
console.error(`Command not found: ${commandId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute custom handler if provided
|
||||
if (command.handler) {
|
||||
await command.handler();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle keyboard action with scope-aware execution
|
||||
if (command.keyboardAction && command.commandName) {
|
||||
if (command.keyboardAction.scope === "note-tree") {
|
||||
this.executeWithNoteTreeFocus(command.commandName);
|
||||
} else if (command.keyboardAction.scope === "text-detail") {
|
||||
this.executeWithTextDetail(command.commandName);
|
||||
} else {
|
||||
appContext.triggerCommand(command.commandName, {
|
||||
ntxId: appContext.tabManager.activeNtxId
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback for commands without keyboard action reference
|
||||
if (command.commandName) {
|
||||
appContext.triggerCommand(command.commandName, {
|
||||
ntxId: appContext.tabManager.activeNtxId
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(`Command ${commandId} has no handler or commandName`);
|
||||
}
|
||||
|
||||
private executeWithNoteTreeFocus(actionName: CommandNames) {
|
||||
const tree = document.querySelector(".tree-wrapper") as HTMLElement;
|
||||
if (!tree) {
|
||||
return;
|
||||
}
|
||||
|
||||
const treeComponent = appContext.getComponentByEl(tree) as NoteTreeWidget;
|
||||
const activeNode = treeComponent.getActiveNode();
|
||||
treeComponent.triggerCommand(actionName, {
|
||||
ntxId: appContext.tabManager.activeNtxId,
|
||||
node: activeNode
|
||||
});
|
||||
}
|
||||
|
||||
private async executeWithTextDetail(actionName: CommandNames) {
|
||||
const typeWidget = await appContext.tabManager.getActiveContext()?.getTypeWidget();
|
||||
if (!typeWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
typeWidget.triggerCommand(actionName, {
|
||||
ntxId: appContext.tabManager.activeNtxId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const commandRegistry = new CommandRegistry();
|
||||
export default commandRegistry;
|
||||
@@ -65,6 +65,9 @@ async function getRenderedContent(this: {} | { ctx: string }, entity: FNote | FA
|
||||
|
||||
$renderedContent.append($("<div>").append("<div>This note is protected and to access it you need to enter password.</div>").append("<br/>").append($button));
|
||||
} else if (entity instanceof FNote) {
|
||||
$renderedContent
|
||||
.css("display", "flex")
|
||||
.css("flex-direction", "column");
|
||||
$renderedContent.append(
|
||||
$("<div>")
|
||||
.css("display", "flex")
|
||||
@@ -72,8 +75,33 @@ async function getRenderedContent(this: {} | { ctx: string }, entity: FNote | FA
|
||||
.css("align-items", "center")
|
||||
.css("height", "100%")
|
||||
.css("font-size", "500%")
|
||||
.css("flex-grow", "1")
|
||||
.append($("<span>").addClass(entity.getIcon()))
|
||||
);
|
||||
|
||||
if (entity.type === "webView" && entity.hasLabel("webViewSrc")) {
|
||||
const $footer = $("<footer>")
|
||||
.addClass("webview-footer");
|
||||
const $openButton = $(`
|
||||
<button class="file-open btn btn-primary" type="button">
|
||||
<span class="bx bx-link-external"></span>
|
||||
${t("content_renderer.open_externally")}
|
||||
</button>
|
||||
`)
|
||||
.appendTo($footer)
|
||||
.on("click", () => {
|
||||
const webViewSrc = entity.getLabelValue("webViewSrc");
|
||||
if (webViewSrc) {
|
||||
if (utils.isElectron()) {
|
||||
const electron = utils.dynamicRequire("electron");
|
||||
electron.shell.openExternal(webViewSrc);
|
||||
} else {
|
||||
window.open(webViewSrc, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
}
|
||||
});
|
||||
$footer.appendTo($renderedContent);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof FNote) {
|
||||
@@ -118,8 +146,17 @@ async function renderText(note: FNote | FAttachment, $renderedContent: JQuery<HT
|
||||
async function renderCode(note: FNote | FAttachment, $renderedContent: JQuery<HTMLElement>) {
|
||||
const blob = await note.getBlob();
|
||||
|
||||
let content = blob?.content || "";
|
||||
if (note.mime === "application/json") {
|
||||
try {
|
||||
content = JSON.stringify(JSON.parse(content), null, 4);
|
||||
} catch (e) {
|
||||
// Ignore JSON parsing errors.
|
||||
}
|
||||
}
|
||||
|
||||
const $codeBlock = $("<code>");
|
||||
$codeBlock.text(blob?.content || "");
|
||||
$codeBlock.text(content);
|
||||
$renderedContent.append($("<pre>").append($codeBlock));
|
||||
await applySingleBlockSyntaxHighlight($codeBlock, normalizeMimeTypeForCKEditor(note.mime));
|
||||
}
|
||||
@@ -301,7 +338,7 @@ function getRenderingType(entity: FNote | FAttachment) {
|
||||
|
||||
if (type === "file" && mime === "application/pdf") {
|
||||
type = "pdf";
|
||||
} else if (type === "file" && mime && CODE_MIME_TYPES.has(mime)) {
|
||||
} else if ((type === "file" || type === "viewConfig") && mime && CODE_MIME_TYPES.has(mime)) {
|
||||
type = "code";
|
||||
} else if (type === "file" && mime && mime.startsWith("audio/")) {
|
||||
type = "audio";
|
||||
|
||||
@@ -1,13 +1,54 @@
|
||||
import { Modal } from "bootstrap";
|
||||
import appContext from "../components/app_context.js";
|
||||
import type { ConfirmDialogOptions, ConfirmDialogResult, ConfirmWithMessageOptions } from "../widgets/dialogs/confirm.js";
|
||||
import type { PromptDialogOptions } from "../widgets/dialogs/prompt.js";
|
||||
import { focusSavedElement, saveFocusedElement } from "./focus.js";
|
||||
|
||||
export async function openDialog($dialog: JQuery<HTMLElement>, closeActDialog = true, config?: Partial<Modal.Options>) {
|
||||
if (closeActDialog) {
|
||||
closeActiveDialog();
|
||||
glob.activeDialog = $dialog;
|
||||
}
|
||||
|
||||
saveFocusedElement();
|
||||
Modal.getOrCreateInstance($dialog[0], config).show();
|
||||
|
||||
$dialog.on("hidden.bs.modal", () => {
|
||||
const $autocompleteEl = $(".aa-input");
|
||||
if ("autocomplete" in $autocompleteEl) {
|
||||
$autocompleteEl.autocomplete("close");
|
||||
}
|
||||
|
||||
if (!glob.activeDialog || glob.activeDialog === $dialog) {
|
||||
focusSavedElement();
|
||||
}
|
||||
});
|
||||
|
||||
const keyboardActionsService = (await import("./keyboard_actions.js")).default;
|
||||
keyboardActionsService.updateDisplayedShortcuts($dialog);
|
||||
|
||||
return $dialog;
|
||||
}
|
||||
|
||||
export function closeActiveDialog() {
|
||||
if (glob.activeDialog) {
|
||||
Modal.getOrCreateInstance(glob.activeDialog[0]).hide();
|
||||
glob.activeDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function info(message: string) {
|
||||
return new Promise((res) => appContext.triggerCommand("showInfoDialog", { message, callback: res }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a confirmation dialog with the given message.
|
||||
*
|
||||
* @param message the message to display in the dialog.
|
||||
* @returns A promise that resolves to true if the user confirmed, false otherwise.
|
||||
*/
|
||||
async function confirm(message: string) {
|
||||
return new Promise((res) =>
|
||||
return new Promise<boolean>((res) =>
|
||||
appContext.triggerCommand("showConfirmDialog", <ConfirmWithMessageOptions>{
|
||||
message,
|
||||
callback: (x: false | ConfirmDialogOptions) => res(x && x.confirmed)
|
||||
|
||||
29
apps/client/src/services/focus.ts
Normal file
29
apps/client/src/services/focus.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
let $lastFocusedElement: JQuery<HTMLElement> | null;
|
||||
|
||||
// perhaps there should be saved focused element per tab?
|
||||
export function saveFocusedElement() {
|
||||
$lastFocusedElement = $(":focus");
|
||||
}
|
||||
|
||||
export function focusSavedElement() {
|
||||
if (!$lastFocusedElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($lastFocusedElement.hasClass("ck")) {
|
||||
// must handle CKEditor separately because of this bug: https://github.com/ckeditor/ckeditor5/issues/607
|
||||
// the bug manifests itself in resetting the cursor position to the first character - jumping above
|
||||
|
||||
const editor = $lastFocusedElement.closest(".ck-editor__editable").prop("ckeditorInstance");
|
||||
|
||||
if (editor) {
|
||||
editor.editing.view.focus();
|
||||
} else {
|
||||
console.log("Could not find CKEditor instance to focus last element");
|
||||
}
|
||||
} else {
|
||||
$lastFocusedElement.focus();
|
||||
}
|
||||
|
||||
$lastFocusedElement = null;
|
||||
}
|
||||
@@ -245,6 +245,10 @@ class FrocaImpl implements Froca {
|
||||
}
|
||||
|
||||
async getNotes(noteIds: string[] | JQuery<string>, silentNotFoundError = false): Promise<FNote[]> {
|
||||
if (noteIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
noteIds = Array.from(new Set(noteIds)); // make unique
|
||||
const missingNoteIds = noteIds.filter((noteId) => !this.notes[noteId]);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ async function processEntityChanges(entityChanges: EntityChange[]) {
|
||||
loadResults.addOption(attributeEntity.name);
|
||||
} else if (ec.entityName === "attachments") {
|
||||
processAttachment(loadResults, ec);
|
||||
} else if (ec.entityName === "blobs" || ec.entityName === "etapi_tokens" || ec.entityName === "note_embeddings") {
|
||||
} else if (ec.entityName === "blobs" || ec.entityName === "etapi_tokens") {
|
||||
// NOOP - these entities are handled at the backend level and don't require frontend processing
|
||||
} else {
|
||||
throw new Error(`Unknown entityName '${ec.entityName}'`);
|
||||
|
||||
387
apps/client/src/services/gallery_manager.spec.ts
Normal file
387
apps/client/src/services/gallery_manager.spec.ts
Normal file
@@ -0,0 +1,387 @@
|
||||
/**
|
||||
* Tests for Gallery Manager
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import galleryManager from './gallery_manager';
|
||||
import mediaViewer from './media_viewer';
|
||||
import type { GalleryItem, GalleryConfig } from './gallery_manager';
|
||||
import type { MediaViewerCallbacks } from './media_viewer';
|
||||
|
||||
// Mock media viewer
|
||||
vi.mock('./media_viewer', () => ({
|
||||
default: {
|
||||
open: vi.fn(),
|
||||
openSingle: vi.fn(),
|
||||
close: vi.fn(),
|
||||
next: vi.fn(),
|
||||
prev: vi.fn(),
|
||||
goTo: vi.fn(),
|
||||
getCurrentIndex: vi.fn(() => 0),
|
||||
isOpen: vi.fn(() => false),
|
||||
getImageDimensions: vi.fn(() => Promise.resolve({ width: 800, height: 600 }))
|
||||
}
|
||||
}));
|
||||
|
||||
// Mock froca
|
||||
vi.mock('./froca', () => ({
|
||||
default: {
|
||||
getNoteComplement: vi.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
// Mock utils
|
||||
vi.mock('./utils', () => ({
|
||||
default: {
|
||||
createImageSrcUrl: vi.fn((note: any) => `/api/images/${note.noteId}`),
|
||||
randomString: vi.fn(() => 'test123')
|
||||
}
|
||||
}));
|
||||
|
||||
describe('GalleryManager', () => {
|
||||
let mockItems: GalleryItem[];
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset mocks
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Create mock gallery items
|
||||
mockItems = [
|
||||
{
|
||||
src: '/api/images/note1/image1.jpg',
|
||||
alt: 'Image 1',
|
||||
title: 'First Image',
|
||||
noteId: 'note1',
|
||||
index: 0,
|
||||
width: 800,
|
||||
height: 600
|
||||
},
|
||||
{
|
||||
src: '/api/images/note1/image2.jpg',
|
||||
alt: 'Image 2',
|
||||
title: 'Second Image',
|
||||
noteId: 'note1',
|
||||
index: 1,
|
||||
width: 1024,
|
||||
height: 768
|
||||
},
|
||||
{
|
||||
src: '/api/images/note1/image3.jpg',
|
||||
alt: 'Image 3',
|
||||
title: 'Third Image',
|
||||
noteId: 'note1',
|
||||
index: 2,
|
||||
width: 1920,
|
||||
height: 1080
|
||||
}
|
||||
];
|
||||
|
||||
// Setup DOM
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Cleanup
|
||||
galleryManager.cleanup();
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
describe('Gallery Creation', () => {
|
||||
it('should create gallery from container with images', async () => {
|
||||
// Create container with images
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML = `
|
||||
<img src="/api/images/note1/image1.jpg" alt="Image 1" />
|
||||
<img src="/api/images/note1/image2.jpg" alt="Image 2" />
|
||||
<img src="/api/images/note1/image3.jpg" alt="Image 3" />
|
||||
`;
|
||||
document.body.appendChild(container);
|
||||
|
||||
// Create gallery from container
|
||||
const items = await galleryManager.createGalleryFromContainer(container);
|
||||
|
||||
expect(items).toHaveLength(3);
|
||||
expect(items[0].src).toBe('/api/images/note1/image1.jpg');
|
||||
expect(items[0].alt).toBe('Image 1');
|
||||
expect(items[0].index).toBe(0);
|
||||
});
|
||||
|
||||
it('should extract captions from figure elements', async () => {
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML = `
|
||||
<figure>
|
||||
<img src="/api/images/note1/image1.jpg" alt="Image 1" />
|
||||
<figcaption>This is a caption</figcaption>
|
||||
</figure>
|
||||
`;
|
||||
document.body.appendChild(container);
|
||||
|
||||
const items = await galleryManager.createGalleryFromContainer(container);
|
||||
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0].caption).toBe('This is a caption');
|
||||
});
|
||||
|
||||
it('should handle images without dimensions', async () => {
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML = `<img src="/api/images/note1/image1.jpg" alt="Image 1" />`;
|
||||
document.body.appendChild(container);
|
||||
|
||||
const items = await galleryManager.createGalleryFromContainer(container);
|
||||
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0].width).toBe(800); // From mocked getImageDimensions
|
||||
expect(items[0].height).toBe(600);
|
||||
expect(mediaViewer.getImageDimensions).toHaveBeenCalledWith('/api/images/note1/image1.jpg');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Gallery Opening', () => {
|
||||
it('should open gallery with multiple items', () => {
|
||||
const callbacks: MediaViewerCallbacks = {
|
||||
onOpen: vi.fn(),
|
||||
onClose: vi.fn(),
|
||||
onChange: vi.fn()
|
||||
};
|
||||
|
||||
galleryManager.openGallery(mockItems, 0, {}, callbacks);
|
||||
|
||||
expect(mediaViewer.open).toHaveBeenCalledWith(
|
||||
mockItems,
|
||||
0,
|
||||
expect.objectContaining({
|
||||
loop: true,
|
||||
allowPanToNext: true,
|
||||
preload: [2, 2]
|
||||
}),
|
||||
expect.objectContaining({
|
||||
onOpen: expect.any(Function),
|
||||
onClose: expect.any(Function),
|
||||
onChange: expect.any(Function)
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle empty items array', () => {
|
||||
galleryManager.openGallery([], 0);
|
||||
expect(mediaViewer.open).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should apply custom configuration', () => {
|
||||
const config: GalleryConfig = {
|
||||
showThumbnails: false,
|
||||
autoPlay: true,
|
||||
slideInterval: 5000,
|
||||
loop: false
|
||||
};
|
||||
|
||||
galleryManager.openGallery(mockItems, 0, config);
|
||||
|
||||
expect(mediaViewer.open).toHaveBeenCalledWith(
|
||||
mockItems,
|
||||
0,
|
||||
expect.objectContaining({
|
||||
loop: false
|
||||
}),
|
||||
expect.any(Object)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Gallery Navigation', () => {
|
||||
beforeEach(() => {
|
||||
// Open a gallery first
|
||||
galleryManager.openGallery(mockItems, 0);
|
||||
});
|
||||
|
||||
it('should navigate to next slide', () => {
|
||||
galleryManager.nextSlide();
|
||||
expect(mediaViewer.next).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should navigate to previous slide', () => {
|
||||
galleryManager.previousSlide();
|
||||
expect(mediaViewer.prev).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should go to specific slide', () => {
|
||||
galleryManager.goToSlide(2);
|
||||
expect(mediaViewer.goTo).toHaveBeenCalledWith(2);
|
||||
});
|
||||
|
||||
it('should not navigate to invalid slide index', () => {
|
||||
const state = galleryManager.getGalleryState();
|
||||
if (state) {
|
||||
// Try to go to invalid index
|
||||
galleryManager.goToSlide(-1);
|
||||
expect(mediaViewer.goTo).not.toHaveBeenCalled();
|
||||
|
||||
galleryManager.goToSlide(10);
|
||||
expect(mediaViewer.goTo).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Slideshow Functionality', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
galleryManager.openGallery(mockItems, 0, { autoPlay: false });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('should start slideshow', () => {
|
||||
const state = galleryManager.getGalleryState();
|
||||
expect(state?.isPlaying).toBe(false);
|
||||
|
||||
galleryManager.startSlideshow();
|
||||
|
||||
const updatedState = galleryManager.getGalleryState();
|
||||
expect(updatedState?.isPlaying).toBe(true);
|
||||
});
|
||||
|
||||
it('should stop slideshow', () => {
|
||||
galleryManager.startSlideshow();
|
||||
galleryManager.stopSlideshow();
|
||||
|
||||
const state = galleryManager.getGalleryState();
|
||||
expect(state?.isPlaying).toBe(false);
|
||||
});
|
||||
|
||||
it('should toggle slideshow', () => {
|
||||
const initialState = galleryManager.getGalleryState();
|
||||
expect(initialState?.isPlaying).toBe(false);
|
||||
|
||||
galleryManager.toggleSlideshow();
|
||||
expect(galleryManager.getGalleryState()?.isPlaying).toBe(true);
|
||||
|
||||
galleryManager.toggleSlideshow();
|
||||
expect(galleryManager.getGalleryState()?.isPlaying).toBe(false);
|
||||
});
|
||||
|
||||
it('should advance slides automatically in slideshow', () => {
|
||||
galleryManager.startSlideshow();
|
||||
|
||||
// Fast-forward time
|
||||
vi.advanceTimersByTime(4000); // Default interval
|
||||
|
||||
expect(mediaViewer.goTo).toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
||||
it('should update slideshow interval', () => {
|
||||
galleryManager.startSlideshow();
|
||||
galleryManager.updateSlideshowInterval(5000);
|
||||
|
||||
const state = galleryManager.getGalleryState();
|
||||
expect(state?.config.slideInterval).toBe(5000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Gallery State', () => {
|
||||
it('should track gallery state', () => {
|
||||
expect(galleryManager.getGalleryState()).toBeNull();
|
||||
|
||||
galleryManager.openGallery(mockItems, 1);
|
||||
|
||||
const state = galleryManager.getGalleryState();
|
||||
expect(state).not.toBeNull();
|
||||
expect(state?.items).toEqual(mockItems);
|
||||
expect(state?.currentIndex).toBe(1);
|
||||
});
|
||||
|
||||
it('should check if gallery is open', () => {
|
||||
expect(galleryManager.isGalleryOpen()).toBe(false);
|
||||
|
||||
vi.mocked(mediaViewer.isOpen).mockReturnValue(true);
|
||||
galleryManager.openGallery(mockItems, 0);
|
||||
|
||||
expect(galleryManager.isGalleryOpen()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Gallery Cleanup', () => {
|
||||
it('should close gallery on cleanup', () => {
|
||||
galleryManager.openGallery(mockItems, 0);
|
||||
galleryManager.cleanup();
|
||||
|
||||
expect(mediaViewer.close).toHaveBeenCalled();
|
||||
expect(galleryManager.getGalleryState()).toBeNull();
|
||||
});
|
||||
|
||||
it('should stop slideshow on close', () => {
|
||||
galleryManager.openGallery(mockItems, 0, { autoPlay: true });
|
||||
|
||||
const state = galleryManager.getGalleryState();
|
||||
expect(state?.isPlaying).toBe(true);
|
||||
|
||||
galleryManager.closeGallery();
|
||||
expect(mediaViewer.close).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('UI Enhancements', () => {
|
||||
beforeEach(() => {
|
||||
// Create PhotoSwipe container mock
|
||||
const pswpElement = document.createElement('div');
|
||||
pswpElement.className = 'pswp';
|
||||
document.body.appendChild(pswpElement);
|
||||
});
|
||||
|
||||
it('should add thumbnail strip when enabled', (done) => {
|
||||
galleryManager.openGallery(mockItems, 0, { showThumbnails: true });
|
||||
|
||||
// Wait for UI setup
|
||||
setTimeout(() => {
|
||||
const thumbnailStrip = document.querySelector('.gallery-thumbnail-strip');
|
||||
expect(thumbnailStrip).toBeTruthy();
|
||||
|
||||
const thumbnails = document.querySelectorAll('.gallery-thumbnail');
|
||||
expect(thumbnails).toHaveLength(3);
|
||||
|
||||
done();
|
||||
}, 150);
|
||||
});
|
||||
|
||||
it('should add slideshow controls', (done) => {
|
||||
galleryManager.openGallery(mockItems, 0);
|
||||
|
||||
setTimeout(() => {
|
||||
const controls = document.querySelector('.gallery-slideshow-controls');
|
||||
expect(controls).toBeTruthy();
|
||||
|
||||
const playPauseBtn = document.querySelector('.slideshow-play-pause');
|
||||
expect(playPauseBtn).toBeTruthy();
|
||||
|
||||
done();
|
||||
}, 150);
|
||||
});
|
||||
|
||||
it('should add image counter when enabled', (done) => {
|
||||
galleryManager.openGallery(mockItems, 0, { showCounter: true });
|
||||
|
||||
setTimeout(() => {
|
||||
const counter = document.querySelector('.gallery-counter');
|
||||
expect(counter).toBeTruthy();
|
||||
expect(counter?.textContent).toContain('1');
|
||||
expect(counter?.textContent).toContain('3');
|
||||
|
||||
done();
|
||||
}, 150);
|
||||
});
|
||||
|
||||
it('should add keyboard hints', (done) => {
|
||||
galleryManager.openGallery(mockItems, 0);
|
||||
|
||||
setTimeout(() => {
|
||||
const hints = document.querySelector('.gallery-keyboard-hints');
|
||||
expect(hints).toBeTruthy();
|
||||
expect(hints?.textContent).toContain('Navigate');
|
||||
expect(hints?.textContent).toContain('ESC');
|
||||
|
||||
done();
|
||||
}, 150);
|
||||
});
|
||||
});
|
||||
});
|
||||
987
apps/client/src/services/gallery_manager.ts
Normal file
987
apps/client/src/services/gallery_manager.ts
Normal file
@@ -0,0 +1,987 @@
|
||||
/**
|
||||
* Gallery Manager for PhotoSwipe integration in Trilium Notes
|
||||
* Handles multi-image galleries, slideshow mode, and navigation features
|
||||
*/
|
||||
|
||||
import mediaViewer, { MediaItem, MediaViewerCallbacks, MediaViewerConfig } from './media_viewer.js';
|
||||
import utils from './utils.js';
|
||||
import froca from './froca.js';
|
||||
import type FNote from '../entities/fnote.js';
|
||||
|
||||
/**
|
||||
* Gallery configuration options
|
||||
*/
|
||||
export interface GalleryConfig {
|
||||
showThumbnails?: boolean;
|
||||
thumbnailHeight?: number;
|
||||
autoPlay?: boolean;
|
||||
slideInterval?: number; // in milliseconds
|
||||
showCounter?: boolean;
|
||||
enableKeyboardNav?: boolean;
|
||||
enableSwipeGestures?: boolean;
|
||||
preloadCount?: number;
|
||||
loop?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gallery item with additional metadata
|
||||
*/
|
||||
export interface GalleryItem extends MediaItem {
|
||||
noteId?: string;
|
||||
attachmentId?: string;
|
||||
caption?: string;
|
||||
description?: string;
|
||||
index?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gallery state management
|
||||
*/
|
||||
interface GalleryState {
|
||||
items: GalleryItem[];
|
||||
currentIndex: number;
|
||||
isPlaying: boolean;
|
||||
slideshowTimer?: number;
|
||||
config: Required<GalleryConfig>;
|
||||
}
|
||||
|
||||
/**
|
||||
* GalleryManager handles multi-image galleries with slideshow and navigation features
|
||||
*/
|
||||
class GalleryManager {
|
||||
private static instance: GalleryManager;
|
||||
private currentGallery: GalleryState | null = null;
|
||||
private defaultConfig: Required<GalleryConfig> = {
|
||||
showThumbnails: true,
|
||||
thumbnailHeight: 80,
|
||||
autoPlay: false,
|
||||
slideInterval: 4000,
|
||||
showCounter: true,
|
||||
enableKeyboardNav: true,
|
||||
enableSwipeGestures: true,
|
||||
preloadCount: 2,
|
||||
loop: true
|
||||
};
|
||||
|
||||
private slideshowCallbacks: Set<() => void> = new Set();
|
||||
private $thumbnailStrip?: JQuery<HTMLElement>;
|
||||
private $slideshowControls?: JQuery<HTMLElement>;
|
||||
|
||||
// Track all dynamically created elements for proper cleanup
|
||||
private createdElements: Map<string, HTMLElement | JQuery<HTMLElement>> = new Map();
|
||||
private setupTimeout?: number;
|
||||
|
||||
private constructor() {
|
||||
// Cleanup on window unload
|
||||
window.addEventListener('beforeunload', () => this.cleanup());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get singleton instance
|
||||
*/
|
||||
static getInstance(): GalleryManager {
|
||||
if (!GalleryManager.instance) {
|
||||
GalleryManager.instance = new GalleryManager();
|
||||
}
|
||||
return GalleryManager.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create gallery from images in a note's content
|
||||
*/
|
||||
async createGalleryFromNote(note: FNote, config?: GalleryConfig): Promise<GalleryItem[]> {
|
||||
const items: GalleryItem[] = [];
|
||||
|
||||
try {
|
||||
// Parse note content to find images
|
||||
const parser = new DOMParser();
|
||||
const content = await note.getContent();
|
||||
const doc = parser.parseFromString(content || '', 'text/html');
|
||||
const images = doc.querySelectorAll('img');
|
||||
|
||||
for (let i = 0; i < images.length; i++) {
|
||||
const img = images[i];
|
||||
const src = img.getAttribute('src');
|
||||
|
||||
if (!src) continue;
|
||||
|
||||
// Convert relative URLs to absolute
|
||||
const absoluteSrc = this.resolveImageSrc(src, note.noteId);
|
||||
|
||||
const item: GalleryItem = {
|
||||
src: absoluteSrc,
|
||||
alt: img.getAttribute('alt') || `Image ${i + 1} from ${note.title}`,
|
||||
title: img.getAttribute('title') || img.getAttribute('alt') || undefined,
|
||||
caption: img.getAttribute('data-caption') || undefined,
|
||||
noteId: note.noteId,
|
||||
index: i,
|
||||
width: parseInt(img.getAttribute('width') || '0') || undefined,
|
||||
height: parseInt(img.getAttribute('height') || '0') || undefined
|
||||
};
|
||||
|
||||
// Try to get thumbnail from data attribute or create one
|
||||
const thumbnailSrc = img.getAttribute('data-thumbnail');
|
||||
if (thumbnailSrc) {
|
||||
item.msrc = this.resolveImageSrc(thumbnailSrc, note.noteId);
|
||||
}
|
||||
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
// Also check for image attachments
|
||||
const attachmentItems = await this.getAttachmentImages(note);
|
||||
items.push(...attachmentItems);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to create gallery from note:', error);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image attachments from a note
|
||||
*/
|
||||
private async getAttachmentImages(note: FNote): Promise<GalleryItem[]> {
|
||||
const items: GalleryItem[] = [];
|
||||
|
||||
try {
|
||||
// Get child notes that are images
|
||||
const childNotes = await note.getChildNotes();
|
||||
|
||||
for (const childNote of childNotes) {
|
||||
if (childNote.type === 'image') {
|
||||
const item: GalleryItem = {
|
||||
src: utils.createImageSrcUrl(childNote),
|
||||
alt: childNote.title,
|
||||
title: childNote.title,
|
||||
noteId: childNote.noteId,
|
||||
index: items.length
|
||||
};
|
||||
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to get attachment images:', error);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create gallery from a container element with images
|
||||
*/
|
||||
async createGalleryFromContainer(
|
||||
container: HTMLElement | JQuery<HTMLElement>,
|
||||
selector: string = 'img',
|
||||
config?: GalleryConfig
|
||||
): Promise<GalleryItem[]> {
|
||||
const $container = $(container);
|
||||
const images = $container.find(selector);
|
||||
const items: GalleryItem[] = [];
|
||||
|
||||
for (let i = 0; i < images.length; i++) {
|
||||
const img = images[i] as HTMLImageElement;
|
||||
|
||||
const item: GalleryItem = {
|
||||
src: img.src,
|
||||
alt: img.alt || `Image ${i + 1}`,
|
||||
title: img.title || img.alt || undefined,
|
||||
element: img,
|
||||
index: i,
|
||||
width: img.naturalWidth || undefined,
|
||||
height: img.naturalHeight || undefined
|
||||
};
|
||||
|
||||
// Try to extract caption from nearby elements
|
||||
const $img = $(img);
|
||||
const $figure = $img.closest('figure');
|
||||
if ($figure.length) {
|
||||
const $caption = $figure.find('figcaption');
|
||||
if ($caption.length) {
|
||||
item.caption = $caption.text();
|
||||
}
|
||||
}
|
||||
|
||||
// Check for data attributes
|
||||
item.noteId = $img.data('note-id');
|
||||
item.attachmentId = $img.data('attachment-id');
|
||||
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open gallery with specified items
|
||||
*/
|
||||
openGallery(
|
||||
items: GalleryItem[],
|
||||
startIndex: number = 0,
|
||||
config?: GalleryConfig,
|
||||
callbacks?: MediaViewerCallbacks
|
||||
): void {
|
||||
if (!items || items.length === 0) {
|
||||
console.warn('No items provided to gallery');
|
||||
return;
|
||||
}
|
||||
|
||||
// Close any existing gallery
|
||||
this.closeGallery();
|
||||
|
||||
// Merge configuration
|
||||
const finalConfig = { ...this.defaultConfig, ...config };
|
||||
|
||||
// Initialize gallery state
|
||||
this.currentGallery = {
|
||||
items,
|
||||
currentIndex: startIndex,
|
||||
isPlaying: finalConfig.autoPlay,
|
||||
config: finalConfig
|
||||
};
|
||||
|
||||
// Enhanced PhotoSwipe configuration for gallery
|
||||
const photoSwipeConfig: Partial<MediaViewerConfig> = {
|
||||
bgOpacity: 0.95,
|
||||
showHideOpacity: true,
|
||||
allowPanToNext: true,
|
||||
spacing: 0.12,
|
||||
loop: finalConfig.loop,
|
||||
arrowKeys: finalConfig.enableKeyboardNav,
|
||||
pinchToClose: finalConfig.enableSwipeGestures,
|
||||
closeOnVerticalDrag: finalConfig.enableSwipeGestures,
|
||||
preload: [finalConfig.preloadCount, finalConfig.preloadCount],
|
||||
wheelToZoom: true,
|
||||
// Enable mobile and accessibility enhancements
|
||||
mobileA11y: {
|
||||
touch: {
|
||||
hapticFeedback: true,
|
||||
multiTouchEnabled: true
|
||||
},
|
||||
a11y: {
|
||||
enableKeyboardNav: finalConfig.enableKeyboardNav,
|
||||
enableScreenReaderAnnouncements: true,
|
||||
keyboardShortcutsEnabled: true
|
||||
},
|
||||
mobileUI: {
|
||||
bottomSheetEnabled: true,
|
||||
adaptiveToolbar: true,
|
||||
swipeIndicators: true,
|
||||
gestureHints: true
|
||||
},
|
||||
performance: {
|
||||
adaptiveQuality: true,
|
||||
batteryOptimization: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Enhanced callbacks
|
||||
const enhancedCallbacks: MediaViewerCallbacks = {
|
||||
onOpen: () => {
|
||||
this.onGalleryOpen();
|
||||
callbacks?.onOpen?.();
|
||||
},
|
||||
onClose: () => {
|
||||
this.onGalleryClose();
|
||||
callbacks?.onClose?.();
|
||||
},
|
||||
onChange: (index) => {
|
||||
this.onSlideChange(index);
|
||||
callbacks?.onChange?.(index);
|
||||
},
|
||||
onImageLoad: callbacks?.onImageLoad,
|
||||
onImageError: callbacks?.onImageError
|
||||
};
|
||||
|
||||
// Open with media viewer
|
||||
mediaViewer.open(items, startIndex, photoSwipeConfig, enhancedCallbacks);
|
||||
|
||||
// Setup gallery UI enhancements
|
||||
this.setupGalleryUI();
|
||||
|
||||
// Start slideshow if configured
|
||||
if (finalConfig.autoPlay) {
|
||||
this.startSlideshow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup gallery UI enhancements
|
||||
*/
|
||||
private setupGalleryUI(): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
// Clear any existing timeout
|
||||
if (this.setupTimeout) {
|
||||
clearTimeout(this.setupTimeout);
|
||||
}
|
||||
|
||||
// Add gallery-specific UI elements to PhotoSwipe
|
||||
this.setupTimeout = window.setTimeout(() => {
|
||||
// Validate gallery is still open before manipulating DOM
|
||||
if (!this.currentGallery || !this.isGalleryOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// PhotoSwipe needs a moment to initialize
|
||||
const pswpElement = document.querySelector('.pswp');
|
||||
if (!pswpElement) return;
|
||||
|
||||
// Add thumbnail strip if enabled
|
||||
if (this.currentGallery.config.showThumbnails) {
|
||||
this.addThumbnailStrip(pswpElement);
|
||||
}
|
||||
|
||||
// Add slideshow controls
|
||||
this.addSlideshowControls(pswpElement);
|
||||
|
||||
// Add image counter if enabled
|
||||
if (this.currentGallery.config.showCounter) {
|
||||
this.addImageCounter(pswpElement);
|
||||
}
|
||||
|
||||
// Add keyboard hints
|
||||
this.addKeyboardHints(pswpElement);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add thumbnail strip navigation
|
||||
*/
|
||||
private addThumbnailStrip(container: Element): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
// Create thumbnail strip container safely using DOM APIs
|
||||
const stripDiv = document.createElement('div');
|
||||
stripDiv.className = 'gallery-thumbnail-strip';
|
||||
stripDiv.setAttribute('style', `
|
||||
position: absolute;
|
||||
bottom: 60px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
border-radius: 8px;
|
||||
max-width: 90%;
|
||||
overflow-x: auto;
|
||||
z-index: 100;
|
||||
`);
|
||||
|
||||
// Create thumbnails safely
|
||||
this.currentGallery.items.forEach((item, index) => {
|
||||
const thumbDiv = document.createElement('div');
|
||||
thumbDiv.className = 'gallery-thumbnail';
|
||||
thumbDiv.dataset.index = index.toString();
|
||||
thumbDiv.setAttribute('style', `
|
||||
width: ${this.currentGallery!.config.thumbnailHeight}px;
|
||||
height: ${this.currentGallery!.config.thumbnailHeight}px;
|
||||
cursor: pointer;
|
||||
border: 2px solid ${index === this.currentGallery!.currentIndex ? '#fff' : 'transparent'};
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
opacity: ${index === this.currentGallery!.currentIndex ? '1' : '0.6'};
|
||||
transition: all 0.2s;
|
||||
`);
|
||||
|
||||
const img = document.createElement('img');
|
||||
// Sanitize src URLs
|
||||
const src = this.sanitizeUrl(item.msrc || item.src);
|
||||
img.src = src;
|
||||
// Use textContent for safe text insertion
|
||||
img.alt = this.sanitizeText(item.alt || '');
|
||||
img.setAttribute('style', `
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
`);
|
||||
|
||||
thumbDiv.appendChild(img);
|
||||
stripDiv.appendChild(thumbDiv);
|
||||
});
|
||||
|
||||
this.$thumbnailStrip = $(stripDiv);
|
||||
$(container).append(this.$thumbnailStrip);
|
||||
this.createdElements.set('thumbnailStrip', this.$thumbnailStrip);
|
||||
|
||||
// Handle thumbnail clicks
|
||||
this.$thumbnailStrip.on('click', '.gallery-thumbnail', (e) => {
|
||||
const index = parseInt($(e.currentTarget).data('index'));
|
||||
this.goToSlide(index);
|
||||
});
|
||||
|
||||
// Handle hover effect
|
||||
this.$thumbnailStrip.on('mouseenter', '.gallery-thumbnail', (e) => {
|
||||
if (!$(e.currentTarget).hasClass('active')) {
|
||||
$(e.currentTarget).css('opacity', '0.8');
|
||||
}
|
||||
});
|
||||
|
||||
this.$thumbnailStrip.on('mouseleave', '.gallery-thumbnail', (e) => {
|
||||
if (!$(e.currentTarget).hasClass('active')) {
|
||||
$(e.currentTarget).css('opacity', '0.6');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize text content to prevent XSS
|
||||
*/
|
||||
private sanitizeText(text: string): string {
|
||||
// Remove any HTML tags and entities
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize URL to prevent XSS
|
||||
*/
|
||||
private sanitizeUrl(url: string): string {
|
||||
// Only allow safe protocols
|
||||
const allowedProtocols = ['http:', 'https:', 'data:'];
|
||||
try {
|
||||
const urlObj = new URL(url, window.location.href);
|
||||
|
||||
// Special validation for data URLs
|
||||
if (urlObj.protocol === 'data:') {
|
||||
// Only allow image MIME types for data URLs
|
||||
const allowedImageTypes = [
|
||||
'data:image/jpeg',
|
||||
'data:image/jpg',
|
||||
'data:image/png',
|
||||
'data:image/gif',
|
||||
'data:image/webp',
|
||||
'data:image/svg+xml',
|
||||
'data:image/bmp'
|
||||
];
|
||||
|
||||
// Check if data URL starts with an allowed image type
|
||||
const isAllowedImage = allowedImageTypes.some(type =>
|
||||
url.toLowerCase().startsWith(type)
|
||||
);
|
||||
|
||||
if (!isAllowedImage) {
|
||||
console.warn('Rejected non-image data URL:', url.substring(0, 50));
|
||||
return '';
|
||||
}
|
||||
|
||||
// Additional check for base64 encoding
|
||||
if (!url.includes(';base64,') && !url.includes(';charset=')) {
|
||||
console.warn('Rejected data URL with invalid encoding');
|
||||
return '';
|
||||
}
|
||||
} else if (!allowedProtocols.includes(urlObj.protocol)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return urlObj.href;
|
||||
} catch {
|
||||
// If URL parsing fails, check if it's a relative path
|
||||
if (url.startsWith('/') || url.startsWith('api/')) {
|
||||
return url;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add slideshow controls
|
||||
*/
|
||||
private addSlideshowControls(container: Element): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
const controlsHtml = `
|
||||
<div class="gallery-slideshow-controls" style="
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
z-index: 100;
|
||||
">
|
||||
<button class="slideshow-play-pause" style="
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
" aria-label="${this.currentGallery.isPlaying ? 'Pause slideshow' : 'Play slideshow'}">
|
||||
<i class="bx ${this.currentGallery.isPlaying ? 'bx-pause' : 'bx-play'}"></i>
|
||||
</button>
|
||||
|
||||
<button class="slideshow-settings" style="
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
" aria-label="Slideshow settings">
|
||||
<i class="bx bx-cog"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="slideshow-interval-selector" style="
|
||||
position: absolute;
|
||||
top: 80px;
|
||||
right: 20px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
display: none;
|
||||
z-index: 101;
|
||||
">
|
||||
<label style="display: block; margin-bottom: 5px;">Slide interval:</label>
|
||||
<select class="interval-select" style="
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
padding: 4px;
|
||||
border-radius: 3px;
|
||||
">
|
||||
<option value="3000">3 seconds</option>
|
||||
<option value="4000" selected>4 seconds</option>
|
||||
<option value="5000">5 seconds</option>
|
||||
<option value="7000">7 seconds</option>
|
||||
<option value="10000">10 seconds</option>
|
||||
</select>
|
||||
</div>
|
||||
`;
|
||||
|
||||
this.$slideshowControls = $(controlsHtml);
|
||||
$(container).append(this.$slideshowControls);
|
||||
this.createdElements.set('slideshowControls', this.$slideshowControls);
|
||||
|
||||
// Handle play/pause button
|
||||
this.$slideshowControls.find('.slideshow-play-pause').on('click', () => {
|
||||
this.toggleSlideshow();
|
||||
});
|
||||
|
||||
// Handle settings button
|
||||
this.$slideshowControls.find('.slideshow-settings').on('click', () => {
|
||||
const $selector = this.$slideshowControls?.find('.slideshow-interval-selector');
|
||||
$selector?.toggle();
|
||||
});
|
||||
|
||||
// Handle interval change
|
||||
this.$slideshowControls.find('.interval-select').on('change', (e) => {
|
||||
const interval = parseInt($(e.target).val() as string);
|
||||
this.updateSlideshowInterval(interval);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add image counter
|
||||
*/
|
||||
private addImageCounter(container: Element): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
// Create counter element safely
|
||||
const counterDiv = document.createElement('div');
|
||||
counterDiv.className = 'gallery-counter';
|
||||
counterDiv.setAttribute('style', `
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
z-index: 100;
|
||||
`);
|
||||
|
||||
const currentSpan = document.createElement('span');
|
||||
currentSpan.className = 'current-index';
|
||||
currentSpan.textContent = String(this.currentGallery.currentIndex + 1);
|
||||
|
||||
const separatorSpan = document.createElement('span');
|
||||
separatorSpan.textContent = ' / ';
|
||||
|
||||
const totalSpan = document.createElement('span');
|
||||
totalSpan.className = 'total-count';
|
||||
totalSpan.textContent = String(this.currentGallery.items.length);
|
||||
|
||||
counterDiv.appendChild(currentSpan);
|
||||
counterDiv.appendChild(separatorSpan);
|
||||
counterDiv.appendChild(totalSpan);
|
||||
|
||||
container.appendChild(counterDiv);
|
||||
this.createdElements.set('counter', counterDiv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add keyboard hints overlay
|
||||
*/
|
||||
private addKeyboardHints(container: Element): void {
|
||||
// Create hints element safely
|
||||
const hintsDiv = document.createElement('div');
|
||||
hintsDiv.className = 'gallery-keyboard-hints';
|
||||
hintsDiv.setAttribute('style', `
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 20px;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
z-index: 100;
|
||||
`);
|
||||
|
||||
// Create hint items
|
||||
const hints = [
|
||||
{ key: '←/→', action: 'Navigate' },
|
||||
{ key: 'Space', action: 'Play/Pause' },
|
||||
{ key: 'ESC', action: 'Close' }
|
||||
];
|
||||
|
||||
hints.forEach(hint => {
|
||||
const hintItem = document.createElement('div');
|
||||
const kbd = document.createElement('kbd');
|
||||
kbd.style.cssText = 'background: rgba(255,255,255,0.2); padding: 2px 4px; border-radius: 2px;';
|
||||
kbd.textContent = hint.key;
|
||||
hintItem.appendChild(kbd);
|
||||
hintItem.appendChild(document.createTextNode(' ' + hint.action));
|
||||
hintsDiv.appendChild(hintItem);
|
||||
});
|
||||
|
||||
container.appendChild(hintsDiv);
|
||||
this.createdElements.set('keyboardHints', hintsDiv);
|
||||
|
||||
const $hints = $(hintsDiv);
|
||||
|
||||
// Show hints on hover with scoped selector
|
||||
const handleMouseEnter = () => {
|
||||
if (this.currentGallery) {
|
||||
$hints.css('opacity', '0.6');
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
$hints.css('opacity', '0');
|
||||
};
|
||||
|
||||
$(container).on('mouseenter.galleryHints', handleMouseEnter);
|
||||
$(container).on('mouseleave.galleryHints', handleMouseLeave);
|
||||
|
||||
// Track cleanup callback
|
||||
this.slideshowCallbacks.add(() => {
|
||||
$(container).off('.galleryHints');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle gallery open event
|
||||
*/
|
||||
private onGalleryOpen(): void {
|
||||
// Add keyboard listener for slideshow control
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === ' ') {
|
||||
e.preventDefault();
|
||||
this.toggleSlideshow();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
this.slideshowCallbacks.add(() => {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle gallery close event
|
||||
*/
|
||||
private onGalleryClose(): void {
|
||||
this.stopSlideshow();
|
||||
|
||||
// Clear setup timeout if exists
|
||||
if (this.setupTimeout) {
|
||||
clearTimeout(this.setupTimeout);
|
||||
this.setupTimeout = undefined;
|
||||
}
|
||||
|
||||
// Cleanup event listeners
|
||||
this.slideshowCallbacks.forEach(callback => callback());
|
||||
this.slideshowCallbacks.clear();
|
||||
|
||||
// Remove all tracked UI elements
|
||||
this.createdElements.forEach((element, key) => {
|
||||
if (element instanceof HTMLElement) {
|
||||
element.remove();
|
||||
} else if (element instanceof $) {
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
this.createdElements.clear();
|
||||
|
||||
// Clear jQuery references
|
||||
this.$thumbnailStrip = undefined;
|
||||
this.$slideshowControls = undefined;
|
||||
|
||||
// Clear state
|
||||
this.currentGallery = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle slide change event
|
||||
*/
|
||||
private onSlideChange(index: number): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
this.currentGallery.currentIndex = index;
|
||||
|
||||
// Update thumbnail highlighting
|
||||
if (this.$thumbnailStrip) {
|
||||
this.$thumbnailStrip.find('.gallery-thumbnail').each((i, el) => {
|
||||
const $thumb = $(el);
|
||||
if (i === index) {
|
||||
$thumb.css({
|
||||
'border-color': '#fff',
|
||||
'opacity': '1'
|
||||
});
|
||||
|
||||
// Scroll thumbnail into view
|
||||
const thumbLeft = $thumb.position().left;
|
||||
const thumbWidth = $thumb.outerWidth() || 0;
|
||||
const stripWidth = this.$thumbnailStrip!.width() || 0;
|
||||
const scrollLeft = this.$thumbnailStrip!.scrollLeft() || 0;
|
||||
|
||||
if (thumbLeft < 0) {
|
||||
this.$thumbnailStrip!.scrollLeft(scrollLeft + thumbLeft - 10);
|
||||
} else if (thumbLeft + thumbWidth > stripWidth) {
|
||||
this.$thumbnailStrip!.scrollLeft(scrollLeft + (thumbLeft + thumbWidth - stripWidth) + 10);
|
||||
}
|
||||
} else {
|
||||
$thumb.css({
|
||||
'border-color': 'transparent',
|
||||
'opacity': '0.6'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update counter using tracked element
|
||||
const counterElement = this.createdElements.get('counter');
|
||||
if (counterElement instanceof HTMLElement) {
|
||||
const currentIndexElement = counterElement.querySelector('.current-index');
|
||||
if (currentIndexElement) {
|
||||
currentIndexElement.textContent = String(index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start slideshow
|
||||
*/
|
||||
startSlideshow(): void {
|
||||
if (!this.currentGallery || this.currentGallery.isPlaying) return;
|
||||
|
||||
// Validate gallery state before starting slideshow
|
||||
if (!this.isGalleryOpen() || this.currentGallery.items.length === 0) {
|
||||
console.warn('Cannot start slideshow: gallery not ready');
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure PhotoSwipe is ready
|
||||
if (!mediaViewer.isOpen()) {
|
||||
console.warn('Cannot start slideshow: PhotoSwipe not ready');
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentGallery.isPlaying = true;
|
||||
|
||||
// Update button icon
|
||||
this.$slideshowControls?.find('.slideshow-play-pause i')
|
||||
.removeClass('bx-play')
|
||||
.addClass('bx-pause');
|
||||
|
||||
// Start timer
|
||||
this.scheduleNextSlide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop slideshow
|
||||
*/
|
||||
stopSlideshow(): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
this.currentGallery.isPlaying = false;
|
||||
|
||||
// Clear timer
|
||||
if (this.currentGallery.slideshowTimer) {
|
||||
clearTimeout(this.currentGallery.slideshowTimer);
|
||||
this.currentGallery.slideshowTimer = undefined;
|
||||
}
|
||||
|
||||
// Update button icon
|
||||
this.$slideshowControls?.find('.slideshow-play-pause i')
|
||||
.removeClass('bx-pause')
|
||||
.addClass('bx-play');
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle slideshow play/pause
|
||||
*/
|
||||
toggleSlideshow(): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
if (this.currentGallery.isPlaying) {
|
||||
this.stopSlideshow();
|
||||
} else {
|
||||
this.startSlideshow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule next slide in slideshow
|
||||
*/
|
||||
private scheduleNextSlide(): void {
|
||||
if (!this.currentGallery || !this.currentGallery.isPlaying) return;
|
||||
|
||||
// Clear any existing timer
|
||||
if (this.currentGallery.slideshowTimer) {
|
||||
clearTimeout(this.currentGallery.slideshowTimer);
|
||||
}
|
||||
|
||||
this.currentGallery.slideshowTimer = window.setTimeout(() => {
|
||||
if (!this.currentGallery || !this.currentGallery.isPlaying) return;
|
||||
|
||||
// Go to next slide
|
||||
const nextIndex = (this.currentGallery.currentIndex + 1) % this.currentGallery.items.length;
|
||||
this.goToSlide(nextIndex);
|
||||
|
||||
// Schedule next transition
|
||||
this.scheduleNextSlide();
|
||||
}, this.currentGallery.config.slideInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update slideshow interval
|
||||
*/
|
||||
updateSlideshowInterval(interval: number): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
this.currentGallery.config.slideInterval = interval;
|
||||
|
||||
// Restart slideshow with new interval if playing
|
||||
if (this.currentGallery.isPlaying) {
|
||||
this.stopSlideshow();
|
||||
this.startSlideshow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to specific slide
|
||||
*/
|
||||
goToSlide(index: number): void {
|
||||
if (!this.currentGallery) return;
|
||||
|
||||
if (index >= 0 && index < this.currentGallery.items.length) {
|
||||
mediaViewer.goTo(index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to next slide
|
||||
*/
|
||||
nextSlide(): void {
|
||||
mediaViewer.next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to previous slide
|
||||
*/
|
||||
previousSlide(): void {
|
||||
mediaViewer.prev();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close gallery
|
||||
*/
|
||||
closeGallery(): void {
|
||||
mediaViewer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if gallery is open
|
||||
*/
|
||||
isGalleryOpen(): boolean {
|
||||
return this.currentGallery !== null && mediaViewer.isOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current gallery state
|
||||
*/
|
||||
getGalleryState(): GalleryState | null {
|
||||
return this.currentGallery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve image source URL
|
||||
*/
|
||||
private resolveImageSrc(src: string, noteId: string): string {
|
||||
// Handle different image source formats
|
||||
if (src.startsWith('http://') || src.startsWith('https://')) {
|
||||
return src;
|
||||
}
|
||||
|
||||
if (src.startsWith('api/images/')) {
|
||||
return `/${src}`;
|
||||
}
|
||||
|
||||
if (src.startsWith('/')) {
|
||||
return src;
|
||||
}
|
||||
|
||||
// Assume it's a note ID or attachment reference
|
||||
return `/api/images/${noteId}/${src}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup resources
|
||||
*/
|
||||
cleanup(): void {
|
||||
// Clear any pending timeouts
|
||||
if (this.setupTimeout) {
|
||||
clearTimeout(this.setupTimeout);
|
||||
this.setupTimeout = undefined;
|
||||
}
|
||||
|
||||
this.closeGallery();
|
||||
|
||||
// Ensure all elements are removed
|
||||
this.createdElements.forEach((element) => {
|
||||
if (element instanceof HTMLElement) {
|
||||
element.remove();
|
||||
} else if (element instanceof $) {
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
this.createdElements.clear();
|
||||
|
||||
this.slideshowCallbacks.clear();
|
||||
this.currentGallery = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
export default GalleryManager.getInstance();
|
||||
@@ -26,12 +26,18 @@ function setupGlobs() {
|
||||
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
||||
const string = String(msg).toLowerCase();
|
||||
|
||||
let errorObjectString = "";
|
||||
try {
|
||||
errorObjectString = JSON.stringify(error);
|
||||
} catch (e: any) {
|
||||
errorObjectString = e.toString();
|
||||
}
|
||||
let message = "Uncaught error: ";
|
||||
|
||||
if (string.includes("script error")) {
|
||||
message += "No details available";
|
||||
} else {
|
||||
message += [`Message: ${msg}`, `URL: ${url}`, `Line: ${lineNo}`, `Column: ${columnNo}`, `Error object: ${JSON.stringify(error)}`, `Stack: ${error && error.stack}`].join(", ");
|
||||
message += [`Message: ${msg}`, `URL: ${url}`, `Line: ${lineNo}`, `Column: ${columnNo}`, `Error object: ${errorObjectString}`, `Stack: ${error && error.stack}`].join(", ");
|
||||
}
|
||||
|
||||
ws.logError(message);
|
||||
@@ -43,6 +49,13 @@ function setupGlobs() {
|
||||
const string = e?.reason?.message?.toLowerCase();
|
||||
|
||||
let message = "Uncaught error: ";
|
||||
let errorObjectString;
|
||||
|
||||
try {
|
||||
errorObjectString = JSON.stringify(e.reason)
|
||||
} catch (error: any) {
|
||||
errorObjectString = error.toString();
|
||||
}
|
||||
|
||||
if (string?.includes("script error")) {
|
||||
message += "No details available";
|
||||
@@ -51,7 +64,7 @@ function setupGlobs() {
|
||||
`Message: ${e.reason.message}`,
|
||||
`Line: ${e.reason.lineNumber}`,
|
||||
`Column: ${e.reason.columnNumber}`,
|
||||
`Error object: ${JSON.stringify(e.reason)}`,
|
||||
`Error object: ${errorObjectString}`,
|
||||
`Stack: ${e.reason && e.reason.stack}`
|
||||
].join(", ");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { LOCALES } from "@triliumnext/commons";
|
||||
import { readFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("i18n", () => {
|
||||
it("translations are valid JSON", () => {
|
||||
|
||||
@@ -6,6 +6,11 @@ import type { Locale } from "@triliumnext/commons";
|
||||
|
||||
let locales: Locale[] | null;
|
||||
|
||||
/**
|
||||
* A deferred promise that resolves when translations are initialized.
|
||||
*/
|
||||
export let translationsInitializedPromise = $.Deferred();
|
||||
|
||||
export async function initLocale() {
|
||||
const locale = (options.get("locale") as string) || "en";
|
||||
|
||||
@@ -19,6 +24,8 @@ export async function initLocale() {
|
||||
},
|
||||
returnEmptyString: false
|
||||
});
|
||||
|
||||
translationsInitializedPromise.resolve();
|
||||
}
|
||||
|
||||
export function getAvailableLocales() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { t } from "./i18n.js";
|
||||
import toastService from "./toast.js";
|
||||
import toastService, { showError } from "./toast.js";
|
||||
|
||||
function copyImageReferenceToClipboard($imageWrapper: JQuery<HTMLElement>) {
|
||||
try {
|
||||
@@ -11,7 +11,9 @@ function copyImageReferenceToClipboard($imageWrapper: JQuery<HTMLElement>) {
|
||||
if (success) {
|
||||
toastService.showMessage(t("image.copied-to-clipboard"));
|
||||
} else {
|
||||
toastService.showAndLogError(t("image.cannot-copy"));
|
||||
const message = t("image.cannot-copy");
|
||||
showError(message);
|
||||
logError(message);
|
||||
}
|
||||
} finally {
|
||||
window.getSelection()?.removeAllRanges();
|
||||
|
||||
597
apps/client/src/services/image_annotations.ts
Normal file
597
apps/client/src/services/image_annotations.ts
Normal file
@@ -0,0 +1,597 @@
|
||||
/**
|
||||
* Image Annotations Module for PhotoSwipe
|
||||
* Provides ability to add, display, and manage annotations on images
|
||||
*/
|
||||
|
||||
import froca from './froca.js';
|
||||
import server from './server.js';
|
||||
import type FNote from '../entities/fnote.js';
|
||||
import type FAttribute from '../entities/fattribute.js';
|
||||
import { ImageValidator, withErrorBoundary, ImageError, ImageErrorType } from './image_error_handler.js';
|
||||
|
||||
/**
|
||||
* Annotation position and data
|
||||
*/
|
||||
export interface ImageAnnotation {
|
||||
id: string;
|
||||
noteId: string;
|
||||
x: number; // Percentage from left (0-100)
|
||||
y: number; // Percentage from top (0-100)
|
||||
text: string;
|
||||
author?: string;
|
||||
created: Date;
|
||||
modified?: Date;
|
||||
color?: string;
|
||||
icon?: string;
|
||||
type?: 'comment' | 'marker' | 'region';
|
||||
width?: number; // For region type
|
||||
height?: number; // For region type
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotation configuration
|
||||
*/
|
||||
export interface AnnotationConfig {
|
||||
enableAnnotations: boolean;
|
||||
showByDefault: boolean;
|
||||
allowEditing: boolean;
|
||||
defaultColor: string;
|
||||
defaultIcon: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageAnnotationsService manages image annotations using Trilium's attribute system
|
||||
*/
|
||||
class ImageAnnotationsService {
|
||||
private static instance: ImageAnnotationsService;
|
||||
private activeAnnotations: Map<string, ImageAnnotation[]> = new Map();
|
||||
private annotationElements: Map<string, HTMLElement> = new Map();
|
||||
private isEditMode: boolean = false;
|
||||
private selectedAnnotation: ImageAnnotation | null = null;
|
||||
|
||||
private config: AnnotationConfig = {
|
||||
enableAnnotations: true,
|
||||
showByDefault: true,
|
||||
allowEditing: true,
|
||||
defaultColor: '#ffeb3b',
|
||||
defaultIcon: 'bx-comment'
|
||||
};
|
||||
|
||||
// Annotation attribute prefix in Trilium
|
||||
private readonly ANNOTATION_PREFIX = 'imageAnnotation';
|
||||
|
||||
private constructor() {}
|
||||
|
||||
static getInstance(): ImageAnnotationsService {
|
||||
if (!ImageAnnotationsService.instance) {
|
||||
ImageAnnotationsService.instance = new ImageAnnotationsService();
|
||||
}
|
||||
return ImageAnnotationsService.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load annotations for an image note
|
||||
*/
|
||||
async loadAnnotations(noteId: string): Promise<ImageAnnotation[]> {
|
||||
return await withErrorBoundary(async () => {
|
||||
// Validate note ID
|
||||
if (!noteId || typeof noteId !== 'string') {
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
'Invalid note ID provided'
|
||||
);
|
||||
}
|
||||
const note = await froca.getNote(noteId);
|
||||
if (!note) return [];
|
||||
|
||||
const attributes = note.getAttributes();
|
||||
const annotations: ImageAnnotation[] = [];
|
||||
|
||||
// Parse annotation attributes
|
||||
for (const attr of attributes) {
|
||||
if (attr.name.startsWith(this.ANNOTATION_PREFIX)) {
|
||||
try {
|
||||
const annotationData = JSON.parse(attr.value);
|
||||
annotations.push({
|
||||
...annotationData,
|
||||
id: attr.attributeId,
|
||||
noteId: noteId,
|
||||
created: new Date(annotationData.created),
|
||||
modified: annotationData.modified ? new Date(annotationData.modified) : undefined
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to parse annotation:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by creation date
|
||||
annotations.sort((a, b) => a.created.getTime() - b.created.getTime());
|
||||
|
||||
this.activeAnnotations.set(noteId, annotations);
|
||||
return annotations;
|
||||
}) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a new annotation
|
||||
*/
|
||||
async saveAnnotation(annotation: Omit<ImageAnnotation, 'id' | 'created'>): Promise<ImageAnnotation> {
|
||||
return await withErrorBoundary(async () => {
|
||||
// Validate annotation data
|
||||
if (!annotation.text || !annotation.noteId) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
'Invalid annotation data'
|
||||
);
|
||||
}
|
||||
|
||||
// Sanitize text
|
||||
annotation.text = this.sanitizeText(annotation.text);
|
||||
const note = await froca.getNote(annotation.noteId);
|
||||
if (!note) {
|
||||
throw new Error('Note not found');
|
||||
}
|
||||
|
||||
const newAnnotation: ImageAnnotation = {
|
||||
...annotation,
|
||||
id: this.generateId(),
|
||||
created: new Date()
|
||||
};
|
||||
|
||||
// Save as note attribute
|
||||
const attributeName = `${this.ANNOTATION_PREFIX}_${newAnnotation.id}`;
|
||||
const attributeValue = JSON.stringify({
|
||||
x: newAnnotation.x,
|
||||
y: newAnnotation.y,
|
||||
text: newAnnotation.text,
|
||||
author: newAnnotation.author,
|
||||
created: newAnnotation.created.toISOString(),
|
||||
color: newAnnotation.color,
|
||||
icon: newAnnotation.icon,
|
||||
type: newAnnotation.type,
|
||||
width: newAnnotation.width,
|
||||
height: newAnnotation.height
|
||||
});
|
||||
|
||||
await server.put(`notes/${annotation.noteId}/attributes`, {
|
||||
attributes: [{
|
||||
type: 'label',
|
||||
name: attributeName,
|
||||
value: attributeValue
|
||||
}]
|
||||
});
|
||||
|
||||
// Update cache
|
||||
const annotations = this.activeAnnotations.get(annotation.noteId) || [];
|
||||
annotations.push(newAnnotation);
|
||||
this.activeAnnotations.set(annotation.noteId, annotations);
|
||||
|
||||
return newAnnotation;
|
||||
}) as Promise<ImageAnnotation>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing annotation
|
||||
*/
|
||||
async updateAnnotation(annotation: ImageAnnotation): Promise<void> {
|
||||
try {
|
||||
const note = await froca.getNote(annotation.noteId);
|
||||
if (!note) {
|
||||
throw new Error('Note not found');
|
||||
}
|
||||
|
||||
annotation.modified = new Date();
|
||||
|
||||
// Update attribute
|
||||
const attributeName = `${this.ANNOTATION_PREFIX}_${annotation.id}`;
|
||||
const attributeValue = JSON.stringify({
|
||||
x: annotation.x,
|
||||
y: annotation.y,
|
||||
text: annotation.text,
|
||||
author: annotation.author,
|
||||
created: annotation.created.toISOString(),
|
||||
modified: annotation.modified.toISOString(),
|
||||
color: annotation.color,
|
||||
icon: annotation.icon,
|
||||
type: annotation.type,
|
||||
width: annotation.width,
|
||||
height: annotation.height
|
||||
});
|
||||
|
||||
// Find and update the attribute
|
||||
const attributes = note.getAttributes();
|
||||
const attr = attributes.find(a => a.name === attributeName);
|
||||
|
||||
if (attr) {
|
||||
await server.put(`notes/${annotation.noteId}/attributes/${attr.attributeId}`, {
|
||||
value: attributeValue
|
||||
});
|
||||
}
|
||||
|
||||
// Update cache
|
||||
const annotations = this.activeAnnotations.get(annotation.noteId) || [];
|
||||
const index = annotations.findIndex(a => a.id === annotation.id);
|
||||
if (index !== -1) {
|
||||
annotations[index] = annotation;
|
||||
this.activeAnnotations.set(annotation.noteId, annotations);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to update annotation:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an annotation
|
||||
*/
|
||||
async deleteAnnotation(noteId: string, annotationId: string): Promise<void> {
|
||||
try {
|
||||
const note = await froca.getNote(noteId);
|
||||
if (!note) return;
|
||||
|
||||
const attributeName = `${this.ANNOTATION_PREFIX}_${annotationId}`;
|
||||
const attributes = note.getAttributes();
|
||||
const attr = attributes.find(a => a.name === attributeName);
|
||||
|
||||
if (attr) {
|
||||
await server.remove(`notes/${noteId}/attributes/${attr.attributeId}`);
|
||||
}
|
||||
|
||||
// Update cache
|
||||
const annotations = this.activeAnnotations.get(noteId) || [];
|
||||
const filtered = annotations.filter(a => a.id !== annotationId);
|
||||
this.activeAnnotations.set(noteId, filtered);
|
||||
|
||||
// Remove element if exists
|
||||
const element = this.annotationElements.get(annotationId);
|
||||
if (element) {
|
||||
element.remove();
|
||||
this.annotationElements.delete(annotationId);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to delete annotation:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render annotations on an image container
|
||||
*/
|
||||
renderAnnotations(container: HTMLElement, noteId: string, imageElement: HTMLImageElement): void {
|
||||
const annotations = this.activeAnnotations.get(noteId) || [];
|
||||
|
||||
// Clear existing annotation elements
|
||||
this.clearAnnotationElements();
|
||||
|
||||
// Create annotation overlay container
|
||||
const overlay = this.createOverlayContainer(container, imageElement);
|
||||
|
||||
// Render each annotation
|
||||
annotations.forEach(annotation => {
|
||||
const element = this.createAnnotationElement(annotation, overlay);
|
||||
this.annotationElements.set(annotation.id, element);
|
||||
});
|
||||
|
||||
// Add click handler for creating new annotations
|
||||
if (this.config.allowEditing && this.isEditMode) {
|
||||
this.setupAnnotationCreation(overlay, noteId);
|
||||
}
|
||||
|
||||
// Add ARIA attributes for accessibility
|
||||
overlay.setAttribute('role', 'img');
|
||||
overlay.setAttribute('aria-label', 'Image with annotations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create overlay container for annotations
|
||||
*/
|
||||
private createOverlayContainer(container: HTMLElement, imageElement: HTMLImageElement): HTMLElement {
|
||||
let overlay = container.querySelector('.annotation-overlay') as HTMLElement;
|
||||
|
||||
if (!overlay) {
|
||||
overlay = document.createElement('div');
|
||||
overlay.className = 'annotation-overlay';
|
||||
overlay.style.cssText = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: ${this.isEditMode ? 'auto' : 'none'};
|
||||
z-index: 10;
|
||||
`;
|
||||
|
||||
// Position overlay over the image
|
||||
const rect = imageElement.getBoundingClientRect();
|
||||
const containerRect = container.getBoundingClientRect();
|
||||
overlay.style.top = `${rect.top - containerRect.top}px`;
|
||||
overlay.style.left = `${rect.left - containerRect.left}px`;
|
||||
overlay.style.width = `${rect.width}px`;
|
||||
overlay.style.height = `${rect.height}px`;
|
||||
|
||||
container.appendChild(overlay);
|
||||
}
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create annotation element
|
||||
*/
|
||||
private createAnnotationElement(annotation: ImageAnnotation, container: HTMLElement): HTMLElement {
|
||||
const element = document.createElement('div');
|
||||
element.className = `annotation-marker annotation-${annotation.type || 'comment'}`;
|
||||
element.dataset.annotationId = annotation.id;
|
||||
|
||||
// Position based on percentage
|
||||
element.style.cssText = `
|
||||
position: absolute;
|
||||
left: ${annotation.x}%;
|
||||
top: ${annotation.y}%;
|
||||
transform: translate(-50%, -50%);
|
||||
cursor: pointer;
|
||||
z-index: 20;
|
||||
pointer-events: auto;
|
||||
`;
|
||||
|
||||
// Create marker based on type
|
||||
if (annotation.type === 'region') {
|
||||
// Region annotation
|
||||
element.style.cssText += `
|
||||
width: ${annotation.width || 20}%;
|
||||
height: ${annotation.height || 20}%;
|
||||
border: 2px solid ${annotation.color || this.config.defaultColor};
|
||||
background: ${annotation.color || this.config.defaultColor}33;
|
||||
border-radius: 4px;
|
||||
`;
|
||||
} else {
|
||||
// Point annotation
|
||||
const marker = document.createElement('div');
|
||||
marker.style.cssText = `
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: ${annotation.color || this.config.defaultColor};
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
||||
`;
|
||||
|
||||
const icon = document.createElement('i');
|
||||
icon.className = `bx ${annotation.icon || this.config.defaultIcon}`;
|
||||
icon.style.cssText = `
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
`;
|
||||
|
||||
marker.appendChild(icon);
|
||||
element.appendChild(marker);
|
||||
|
||||
// Add ARIA attributes for accessibility
|
||||
element.setAttribute('role', 'button');
|
||||
element.setAttribute('aria-label', `Annotation: ${this.sanitizeText(annotation.text)}`);
|
||||
element.setAttribute('tabindex', '0');
|
||||
}
|
||||
|
||||
// Add tooltip
|
||||
const tooltip = document.createElement('div');
|
||||
tooltip.className = 'annotation-tooltip';
|
||||
tooltip.style.cssText = `
|
||||
position: absolute;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(0,0,0,0.9);
|
||||
color: white;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
max-width: 200px;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
margin-bottom: 8px;
|
||||
`;
|
||||
// Use textContent to prevent XSS
|
||||
tooltip.textContent = this.sanitizeText(annotation.text);
|
||||
element.appendChild(tooltip);
|
||||
|
||||
// Show tooltip on hover
|
||||
element.addEventListener('mouseenter', () => {
|
||||
tooltip.style.opacity = '1';
|
||||
});
|
||||
|
||||
element.addEventListener('mouseleave', () => {
|
||||
tooltip.style.opacity = '0';
|
||||
});
|
||||
|
||||
// Handle click for editing
|
||||
element.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
this.selectAnnotation(annotation);
|
||||
});
|
||||
|
||||
container.appendChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup annotation creation on click
|
||||
*/
|
||||
private setupAnnotationCreation(overlay: HTMLElement, noteId: string): void {
|
||||
overlay.addEventListener('click', async (e) => {
|
||||
if (!this.isEditMode) return;
|
||||
|
||||
const rect = overlay.getBoundingClientRect();
|
||||
const x = ((e.clientX - rect.left) / rect.width) * 100;
|
||||
const y = ((e.clientY - rect.top) / rect.height) * 100;
|
||||
|
||||
// Show annotation creation dialog
|
||||
const text = prompt('Enter annotation text:');
|
||||
if (text) {
|
||||
await this.saveAnnotation({
|
||||
noteId,
|
||||
x,
|
||||
y,
|
||||
text,
|
||||
author: 'current_user', // TODO: Get from session
|
||||
type: 'comment'
|
||||
});
|
||||
|
||||
// Reload annotations
|
||||
await this.loadAnnotations(noteId);
|
||||
|
||||
// Re-render
|
||||
const imageElement = overlay.parentElement?.querySelector('img') as HTMLImageElement;
|
||||
if (imageElement && overlay.parentElement) {
|
||||
this.renderAnnotations(overlay.parentElement, noteId, imageElement);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select an annotation for editing
|
||||
*/
|
||||
private selectAnnotation(annotation: ImageAnnotation): void {
|
||||
this.selectedAnnotation = annotation;
|
||||
|
||||
// Highlight selected annotation
|
||||
this.annotationElements.forEach((element, id) => {
|
||||
if (id === annotation.id) {
|
||||
element.classList.add('selected');
|
||||
element.style.outline = '2px solid #2196F3';
|
||||
} else {
|
||||
element.classList.remove('selected');
|
||||
element.style.outline = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Show edit options
|
||||
if (this.isEditMode) {
|
||||
this.showEditDialog(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show edit dialog for annotation
|
||||
*/
|
||||
private showEditDialog(annotation: ImageAnnotation): void {
|
||||
// Simple implementation - could be replaced with a proper modal
|
||||
const newText = prompt('Edit annotation:', annotation.text);
|
||||
if (newText !== null) {
|
||||
annotation.text = newText;
|
||||
this.updateAnnotation(annotation);
|
||||
|
||||
// Update tooltip with sanitized text
|
||||
const element = this.annotationElements.get(annotation.id);
|
||||
if (element) {
|
||||
const tooltip = element.querySelector('.annotation-tooltip');
|
||||
if (tooltip) {
|
||||
// Use textContent to prevent XSS
|
||||
tooltip.textContent = this.sanitizeText(newText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle edit mode
|
||||
*/
|
||||
toggleEditMode(): void {
|
||||
this.isEditMode = !this.isEditMode;
|
||||
|
||||
// Update overlay pointer events
|
||||
document.querySelectorAll('.annotation-overlay').forEach(overlay => {
|
||||
(overlay as HTMLElement).style.pointerEvents = this.isEditMode ? 'auto' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all annotation elements
|
||||
*/
|
||||
private clearAnnotationElements(): void {
|
||||
this.annotationElements.forEach(element => element.remove());
|
||||
this.annotationElements.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate unique ID
|
||||
*/
|
||||
private generateId(): string {
|
||||
return `ann_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export annotations as JSON
|
||||
*/
|
||||
exportAnnotations(noteId: string): string {
|
||||
const annotations = this.activeAnnotations.get(noteId) || [];
|
||||
return JSON.stringify(annotations, null, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import annotations from JSON
|
||||
*/
|
||||
async importAnnotations(noteId: string, json: string): Promise<void> {
|
||||
try {
|
||||
const annotations = JSON.parse(json) as ImageAnnotation[];
|
||||
|
||||
for (const annotation of annotations) {
|
||||
await this.saveAnnotation({
|
||||
noteId,
|
||||
x: annotation.x,
|
||||
y: annotation.y,
|
||||
text: annotation.text,
|
||||
author: annotation.author,
|
||||
color: annotation.color,
|
||||
icon: annotation.icon,
|
||||
type: annotation.type,
|
||||
width: annotation.width,
|
||||
height: annotation.height
|
||||
});
|
||||
}
|
||||
|
||||
await this.loadAnnotations(noteId);
|
||||
} catch (error) {
|
||||
console.error('Failed to import annotations:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize text to prevent XSS
|
||||
*/
|
||||
private sanitizeText(text: string): string {
|
||||
if (!text) return '';
|
||||
|
||||
// Remove any HTML tags and dangerous characters
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
|
||||
// Additional validation
|
||||
const sanitized = div.textContent || '';
|
||||
|
||||
// Remove any remaining special characters that could be dangerous
|
||||
return sanitized
|
||||
.replace(/<script[^>]*>.*?<\/script>/gi, '')
|
||||
.replace(/<iframe[^>]*>.*?<\/iframe>/gi, '')
|
||||
.replace(/javascript:/gi, '')
|
||||
.replace(/on\w+\s*=/gi, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup resources
|
||||
*/
|
||||
cleanup(): void {
|
||||
this.clearAnnotationElements();
|
||||
this.activeAnnotations.clear();
|
||||
this.selectedAnnotation = null;
|
||||
this.isEditMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageAnnotationsService.getInstance();
|
||||
877
apps/client/src/services/image_comparison.ts
Normal file
877
apps/client/src/services/image_comparison.ts
Normal file
@@ -0,0 +1,877 @@
|
||||
/**
|
||||
* Image Comparison Module for Trilium Notes
|
||||
* Provides side-by-side and overlay comparison modes for images
|
||||
*/
|
||||
|
||||
import mediaViewer from './media_viewer.js';
|
||||
import utils from './utils.js';
|
||||
|
||||
/**
|
||||
* Comparison mode types
|
||||
*/
|
||||
export type ComparisonMode = 'side-by-side' | 'overlay' | 'swipe' | 'difference';
|
||||
|
||||
/**
|
||||
* Image comparison configuration
|
||||
*/
|
||||
export interface ComparisonConfig {
|
||||
mode: ComparisonMode;
|
||||
syncZoom: boolean;
|
||||
syncPan: boolean;
|
||||
showLabels: boolean;
|
||||
swipePosition?: number; // For swipe mode (0-100)
|
||||
opacity?: number; // For overlay mode (0-1)
|
||||
highlightDifferences?: boolean; // For difference mode
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparison state
|
||||
*/
|
||||
interface ComparisonState {
|
||||
leftImage: ComparisonImage;
|
||||
rightImage: ComparisonImage;
|
||||
config: ComparisonConfig;
|
||||
container?: HTMLElement;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image data for comparison
|
||||
*/
|
||||
export interface ComparisonImage {
|
||||
src: string;
|
||||
title?: string;
|
||||
noteId?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageComparisonService provides various comparison modes for images
|
||||
*/
|
||||
class ImageComparisonService {
|
||||
private static instance: ImageComparisonService;
|
||||
private currentComparison: ComparisonState | null = null;
|
||||
private comparisonContainer?: HTMLElement;
|
||||
private leftCanvas?: HTMLCanvasElement;
|
||||
private rightCanvas?: HTMLCanvasElement;
|
||||
private leftContext?: CanvasRenderingContext2D;
|
||||
private rightContext?: CanvasRenderingContext2D;
|
||||
private swipeHandle?: HTMLElement;
|
||||
private isDraggingSwipe: boolean = false;
|
||||
private currentZoom: number = 1;
|
||||
private panX: number = 0;
|
||||
private panY: number = 0;
|
||||
|
||||
private defaultConfig: ComparisonConfig = {
|
||||
mode: 'side-by-side',
|
||||
syncZoom: true,
|
||||
syncPan: true,
|
||||
showLabels: true,
|
||||
swipePosition: 50,
|
||||
opacity: 0.5,
|
||||
highlightDifferences: false
|
||||
};
|
||||
|
||||
private constructor() {}
|
||||
|
||||
static getInstance(): ImageComparisonService {
|
||||
if (!ImageComparisonService.instance) {
|
||||
ImageComparisonService.instance = new ImageComparisonService();
|
||||
}
|
||||
return ImageComparisonService.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start image comparison
|
||||
*/
|
||||
async startComparison(
|
||||
leftImage: ComparisonImage,
|
||||
rightImage: ComparisonImage,
|
||||
container: HTMLElement,
|
||||
config?: Partial<ComparisonConfig>
|
||||
): Promise<void> {
|
||||
try {
|
||||
// Close any existing comparison
|
||||
this.closeComparison();
|
||||
|
||||
// Merge configuration
|
||||
const finalConfig = { ...this.defaultConfig, ...config };
|
||||
|
||||
// Initialize state
|
||||
this.currentComparison = {
|
||||
leftImage,
|
||||
rightImage,
|
||||
config: finalConfig,
|
||||
container,
|
||||
isActive: true
|
||||
};
|
||||
|
||||
// Load images
|
||||
await this.loadImages(leftImage, rightImage);
|
||||
|
||||
// Create comparison UI based on mode
|
||||
switch (finalConfig.mode) {
|
||||
case 'side-by-side':
|
||||
await this.createSideBySideComparison(container);
|
||||
break;
|
||||
case 'overlay':
|
||||
await this.createOverlayComparison(container);
|
||||
break;
|
||||
case 'swipe':
|
||||
await this.createSwipeComparison(container);
|
||||
break;
|
||||
case 'difference':
|
||||
await this.createDifferenceComparison(container);
|
||||
break;
|
||||
}
|
||||
|
||||
// Add controls
|
||||
this.addComparisonControls(container);
|
||||
} catch (error) {
|
||||
console.error('Failed to start image comparison:', error);
|
||||
this.closeComparison();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load images and get dimensions
|
||||
*/
|
||||
private async loadImages(leftImage: ComparisonImage, rightImage: ComparisonImage): Promise<void> {
|
||||
const loadImage = (src: string): Promise<HTMLImageElement> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onload = () => resolve(img);
|
||||
img.onerror = () => reject(new Error(`Failed to load image: ${src}`));
|
||||
img.src = src;
|
||||
});
|
||||
};
|
||||
|
||||
const [leftImg, rightImg] = await Promise.all([
|
||||
loadImage(leftImage.src),
|
||||
loadImage(rightImage.src)
|
||||
]);
|
||||
|
||||
// Update dimensions
|
||||
leftImage.width = leftImg.naturalWidth;
|
||||
leftImage.height = leftImg.naturalHeight;
|
||||
rightImage.width = rightImg.naturalWidth;
|
||||
rightImage.height = rightImg.naturalHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create side-by-side comparison
|
||||
*/
|
||||
private async createSideBySideComparison(container: HTMLElement): Promise<void> {
|
||||
if (!this.currentComparison) return;
|
||||
|
||||
// Clear container
|
||||
container.innerHTML = '';
|
||||
container.style.cssText = `
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
background: #1a1a1a;
|
||||
`;
|
||||
|
||||
// Create left panel
|
||||
const leftPanel = document.createElement('div');
|
||||
leftPanel.className = 'comparison-panel comparison-left';
|
||||
leftPanel.style.cssText = `
|
||||
flex: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-right: 2px solid #333;
|
||||
`;
|
||||
|
||||
// Create right panel
|
||||
const rightPanel = document.createElement('div');
|
||||
rightPanel.className = 'comparison-panel comparison-right';
|
||||
rightPanel.style.cssText = `
|
||||
flex: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
// Add images
|
||||
const leftImg = await this.createImageElement(this.currentComparison.leftImage);
|
||||
const rightImg = await this.createImageElement(this.currentComparison.rightImage);
|
||||
|
||||
leftPanel.appendChild(leftImg);
|
||||
rightPanel.appendChild(rightImg);
|
||||
|
||||
// Add labels if enabled
|
||||
if (this.currentComparison.config.showLabels) {
|
||||
this.addImageLabel(leftPanel, this.currentComparison.leftImage.title || 'Image 1');
|
||||
this.addImageLabel(rightPanel, this.currentComparison.rightImage.title || 'Image 2');
|
||||
}
|
||||
|
||||
container.appendChild(leftPanel);
|
||||
container.appendChild(rightPanel);
|
||||
|
||||
// Setup synchronized zoom and pan if enabled
|
||||
if (this.currentComparison.config.syncZoom || this.currentComparison.config.syncPan) {
|
||||
this.setupSynchronizedControls(leftPanel, rightPanel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create overlay comparison
|
||||
*/
|
||||
private async createOverlayComparison(container: HTMLElement): Promise<void> {
|
||||
if (!this.currentComparison) return;
|
||||
|
||||
container.innerHTML = '';
|
||||
container.style.cssText = `
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #1a1a1a;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
// Create base image
|
||||
const baseImg = await this.createImageElement(this.currentComparison.leftImage);
|
||||
baseImg.style.position = 'absolute';
|
||||
baseImg.style.zIndex = '1';
|
||||
|
||||
// Create overlay image
|
||||
const overlayImg = await this.createImageElement(this.currentComparison.rightImage);
|
||||
overlayImg.style.position = 'absolute';
|
||||
overlayImg.style.zIndex = '2';
|
||||
overlayImg.style.opacity = String(this.currentComparison.config.opacity || 0.5);
|
||||
|
||||
container.appendChild(baseImg);
|
||||
container.appendChild(overlayImg);
|
||||
|
||||
// Add opacity slider
|
||||
this.addOpacityControl(container, overlayImg);
|
||||
|
||||
// Add labels
|
||||
if (this.currentComparison.config.showLabels) {
|
||||
const labelContainer = document.createElement('div');
|
||||
labelContainer.style.cssText = `
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
`;
|
||||
|
||||
const baseLabel = this.createLabel(this.currentComparison.leftImage.title || 'Base', '#4CAF50');
|
||||
const overlayLabel = this.createLabel(this.currentComparison.rightImage.title || 'Overlay', '#2196F3');
|
||||
|
||||
labelContainer.appendChild(baseLabel);
|
||||
labelContainer.appendChild(overlayLabel);
|
||||
container.appendChild(labelContainer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create swipe comparison
|
||||
*/
|
||||
private async createSwipeComparison(container: HTMLElement): Promise<void> {
|
||||
if (!this.currentComparison) return;
|
||||
|
||||
container.innerHTML = '';
|
||||
container.style.cssText = `
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #1a1a1a;
|
||||
overflow: hidden;
|
||||
cursor: ew-resize;
|
||||
`;
|
||||
|
||||
// Create images
|
||||
const leftImg = await this.createImageElement(this.currentComparison.leftImage);
|
||||
const rightImg = await this.createImageElement(this.currentComparison.rightImage);
|
||||
|
||||
leftImg.style.position = 'absolute';
|
||||
leftImg.style.zIndex = '1';
|
||||
|
||||
// Create clipping container for right image
|
||||
const clipContainer = document.createElement('div');
|
||||
clipContainer.className = 'swipe-clip-container';
|
||||
clipContainer.style.cssText = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: ${this.currentComparison.config.swipePosition}%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
z-index: 2;
|
||||
`;
|
||||
|
||||
rightImg.style.position = 'absolute';
|
||||
clipContainer.appendChild(rightImg);
|
||||
|
||||
// Create swipe handle
|
||||
this.swipeHandle = document.createElement('div');
|
||||
this.swipeHandle.className = 'swipe-handle';
|
||||
this.swipeHandle.style.cssText = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: ${this.currentComparison.config.swipePosition}%;
|
||||
width: 4px;
|
||||
height: 100%;
|
||||
background: white;
|
||||
cursor: ew-resize;
|
||||
z-index: 3;
|
||||
transform: translateX(-50%);
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.5);
|
||||
`;
|
||||
|
||||
// Add handle icon
|
||||
const handleIcon = document.createElement('div');
|
||||
handleIcon.style.cssText = `
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.3);
|
||||
`;
|
||||
handleIcon.innerHTML = '<i class="bx bx-move-horizontal" style="font-size: 24px; color: #333;"></i>';
|
||||
this.swipeHandle.appendChild(handleIcon);
|
||||
|
||||
container.appendChild(leftImg);
|
||||
container.appendChild(clipContainer);
|
||||
container.appendChild(this.swipeHandle);
|
||||
|
||||
// Setup swipe interaction
|
||||
this.setupSwipeInteraction(container, clipContainer);
|
||||
|
||||
// Add labels
|
||||
if (this.currentComparison.config.showLabels) {
|
||||
this.addSwipeLabels(container);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create difference comparison using canvas
|
||||
*/
|
||||
private async createDifferenceComparison(container: HTMLElement): Promise<void> {
|
||||
if (!this.currentComparison) return;
|
||||
|
||||
container.innerHTML = '';
|
||||
container.style.cssText = `
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #1a1a1a;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
// Create canvas for difference visualization
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.className = 'difference-canvas';
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
if (!ctx) {
|
||||
throw new Error('Failed to get canvas context');
|
||||
}
|
||||
|
||||
// Load images
|
||||
const leftImg = new Image();
|
||||
const rightImg = new Image();
|
||||
|
||||
await Promise.all([
|
||||
new Promise((resolve) => {
|
||||
leftImg.onload = resolve;
|
||||
leftImg.src = this.currentComparison!.leftImage.src;
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
rightImg.onload = resolve;
|
||||
rightImg.src = this.currentComparison!.rightImage.src;
|
||||
})
|
||||
]);
|
||||
|
||||
// Set canvas size
|
||||
const maxWidth = Math.max(leftImg.width, rightImg.width);
|
||||
const maxHeight = Math.max(leftImg.height, rightImg.height);
|
||||
canvas.width = maxWidth;
|
||||
canvas.height = maxHeight;
|
||||
|
||||
// Calculate difference
|
||||
this.calculateImageDifference(ctx, leftImg, rightImg, maxWidth, maxHeight);
|
||||
|
||||
// Style canvas
|
||||
canvas.style.cssText = `
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
`;
|
||||
|
||||
container.appendChild(canvas);
|
||||
|
||||
// Add difference statistics
|
||||
this.addDifferenceStatistics(container, ctx, maxWidth, maxHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate and visualize image difference
|
||||
*/
|
||||
private calculateImageDifference(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
leftImg: HTMLImageElement,
|
||||
rightImg: HTMLImageElement,
|
||||
width: number,
|
||||
height: number
|
||||
): void {
|
||||
// Draw left image
|
||||
ctx.drawImage(leftImg, 0, 0, width, height);
|
||||
const leftData = ctx.getImageData(0, 0, width, height);
|
||||
|
||||
// Draw right image
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
ctx.drawImage(rightImg, 0, 0, width, height);
|
||||
const rightData = ctx.getImageData(0, 0, width, height);
|
||||
|
||||
// Calculate difference
|
||||
const diffData = ctx.createImageData(width, height);
|
||||
let totalDiff = 0;
|
||||
|
||||
for (let i = 0; i < leftData.data.length; i += 4) {
|
||||
const rDiff = Math.abs(leftData.data[i] - rightData.data[i]);
|
||||
const gDiff = Math.abs(leftData.data[i + 1] - rightData.data[i + 1]);
|
||||
const bDiff = Math.abs(leftData.data[i + 2] - rightData.data[i + 2]);
|
||||
|
||||
const avgDiff = (rDiff + gDiff + bDiff) / 3;
|
||||
totalDiff += avgDiff;
|
||||
|
||||
if (this.currentComparison?.config.highlightDifferences && avgDiff > 30) {
|
||||
// Highlight differences in red
|
||||
diffData.data[i] = 255; // Red
|
||||
diffData.data[i + 1] = 0; // Green
|
||||
diffData.data[i + 2] = 0; // Blue
|
||||
diffData.data[i + 3] = Math.min(255, avgDiff * 2); // Alpha based on difference
|
||||
} else {
|
||||
// Show original image with reduced opacity for non-different areas
|
||||
diffData.data[i] = leftData.data[i];
|
||||
diffData.data[i + 1] = leftData.data[i + 1];
|
||||
diffData.data[i + 2] = leftData.data[i + 2];
|
||||
diffData.data[i + 3] = avgDiff > 10 ? 255 : 128;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.putImageData(diffData, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add difference statistics overlay
|
||||
*/
|
||||
private addDifferenceStatistics(
|
||||
container: HTMLElement,
|
||||
ctx: CanvasRenderingContext2D,
|
||||
width: number,
|
||||
height: number
|
||||
): void {
|
||||
const imageData = ctx.getImageData(0, 0, width, height);
|
||||
let changedPixels = 0;
|
||||
const threshold = 30;
|
||||
|
||||
for (let i = 0; i < imageData.data.length; i += 4) {
|
||||
const r = imageData.data[i];
|
||||
const g = imageData.data[i + 1];
|
||||
const b = imageData.data[i + 2];
|
||||
|
||||
if (r > threshold || g > threshold || b > threshold) {
|
||||
changedPixels++;
|
||||
}
|
||||
}
|
||||
|
||||
const totalPixels = width * height;
|
||||
const changePercentage = ((changedPixels / totalPixels) * 100).toFixed(2);
|
||||
|
||||
const statsDiv = document.createElement('div');
|
||||
statsDiv.className = 'difference-stats';
|
||||
statsDiv.style.cssText = `
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
`;
|
||||
|
||||
statsDiv.innerHTML = `
|
||||
<div><strong>Difference Analysis</strong></div>
|
||||
<div>Changed pixels: ${changedPixels.toLocaleString()}</div>
|
||||
<div>Total pixels: ${totalPixels.toLocaleString()}</div>
|
||||
<div>Difference: ${changePercentage}%</div>
|
||||
`;
|
||||
|
||||
container.appendChild(statsDiv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create image element
|
||||
*/
|
||||
private async createImageElement(image: ComparisonImage): Promise<HTMLImageElement> {
|
||||
const img = document.createElement('img');
|
||||
img.src = image.src;
|
||||
img.alt = image.title || 'Comparison image';
|
||||
img.style.cssText = `
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
`;
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
img.onload = resolve;
|
||||
img.onerror = reject;
|
||||
});
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add image label
|
||||
*/
|
||||
private addImageLabel(container: HTMLElement, text: string): void {
|
||||
const label = document.createElement('div');
|
||||
label.className = 'image-label';
|
||||
label.style.cssText = `
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
padding: 6px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
`;
|
||||
label.textContent = text;
|
||||
container.appendChild(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create label element
|
||||
*/
|
||||
private createLabel(text: string, color: string): HTMLElement {
|
||||
const label = document.createElement('div');
|
||||
label.style.cssText = `
|
||||
background: ${color};
|
||||
color: white;
|
||||
padding: 4px 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
`;
|
||||
label.textContent = text;
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add swipe labels
|
||||
*/
|
||||
private addSwipeLabels(container: HTMLElement): void {
|
||||
if (!this.currentComparison) return;
|
||||
|
||||
const leftLabel = document.createElement('div');
|
||||
leftLabel.style.cssText = `
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
background: rgba(76, 175, 80, 0.9);
|
||||
color: white;
|
||||
padding: 6px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
`;
|
||||
leftLabel.textContent = this.currentComparison.leftImage.title || 'Left';
|
||||
|
||||
const rightLabel = document.createElement('div');
|
||||
rightLabel.style.cssText = `
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background: rgba(33, 150, 243, 0.9);
|
||||
color: white;
|
||||
padding: 6px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
`;
|
||||
rightLabel.textContent = this.currentComparison.rightImage.title || 'Right';
|
||||
|
||||
container.appendChild(leftLabel);
|
||||
container.appendChild(rightLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup swipe interaction
|
||||
*/
|
||||
private setupSwipeInteraction(container: HTMLElement, clipContainer: HTMLElement): void {
|
||||
if (!this.swipeHandle) return;
|
||||
|
||||
let startX = 0;
|
||||
let startPosition = this.currentComparison?.config.swipePosition || 50;
|
||||
|
||||
const handleMouseMove = (e: MouseEvent) => {
|
||||
if (!this.isDraggingSwipe) return;
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const percentage = Math.max(0, Math.min(100, (x / rect.width) * 100));
|
||||
|
||||
clipContainer.style.width = `${percentage}%`;
|
||||
if (this.swipeHandle) {
|
||||
this.swipeHandle.style.left = `${percentage}%`;
|
||||
}
|
||||
|
||||
if (this.currentComparison) {
|
||||
this.currentComparison.config.swipePosition = percentage;
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseUp = () => {
|
||||
this.isDraggingSwipe = false;
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
container.style.cursor = 'default';
|
||||
};
|
||||
|
||||
this.swipeHandle.addEventListener('mousedown', (e) => {
|
||||
this.isDraggingSwipe = true;
|
||||
startX = e.clientX;
|
||||
startPosition = this.currentComparison?.config.swipePosition || 50;
|
||||
container.style.cursor = 'ew-resize';
|
||||
|
||||
document.addEventListener('mousemove', handleMouseMove);
|
||||
document.addEventListener('mouseup', handleMouseUp);
|
||||
});
|
||||
|
||||
// Also allow dragging anywhere in the container
|
||||
container.addEventListener('mousedown', (e) => {
|
||||
if (e.target === this.swipeHandle || (e.target as HTMLElement).parentElement === this.swipeHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const percentage = (x / rect.width) * 100;
|
||||
|
||||
clipContainer.style.width = `${percentage}%`;
|
||||
if (this.swipeHandle) {
|
||||
this.swipeHandle.style.left = `${percentage}%`;
|
||||
}
|
||||
|
||||
if (this.currentComparison) {
|
||||
this.currentComparison.config.swipePosition = percentage;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add opacity control for overlay mode
|
||||
*/
|
||||
private addOpacityControl(container: HTMLElement, overlayImg: HTMLImageElement): void {
|
||||
const control = document.createElement('div');
|
||||
control.className = 'opacity-control';
|
||||
control.style.cssText = `
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
`;
|
||||
|
||||
const label = document.createElement('label');
|
||||
label.textContent = 'Opacity:';
|
||||
label.style.color = 'white';
|
||||
label.style.fontSize = '12px';
|
||||
|
||||
const slider = document.createElement('input');
|
||||
slider.type = 'range';
|
||||
slider.min = '0';
|
||||
slider.max = '100';
|
||||
slider.value = String((this.currentComparison?.config.opacity || 0.5) * 100);
|
||||
slider.style.width = '150px';
|
||||
|
||||
const value = document.createElement('span');
|
||||
value.textContent = `${slider.value}%`;
|
||||
value.style.color = 'white';
|
||||
value.style.fontSize = '12px';
|
||||
value.style.minWidth = '35px';
|
||||
|
||||
slider.addEventListener('input', () => {
|
||||
const opacity = parseInt(slider.value) / 100;
|
||||
overlayImg.style.opacity = String(opacity);
|
||||
value.textContent = `${slider.value}%`;
|
||||
|
||||
if (this.currentComparison) {
|
||||
this.currentComparison.config.opacity = opacity;
|
||||
}
|
||||
});
|
||||
|
||||
control.appendChild(label);
|
||||
control.appendChild(slider);
|
||||
control.appendChild(value);
|
||||
container.appendChild(control);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup synchronized controls for side-by-side mode
|
||||
*/
|
||||
private setupSynchronizedControls(leftPanel: HTMLElement, rightPanel: HTMLElement): void {
|
||||
const leftImg = leftPanel.querySelector('img') as HTMLImageElement;
|
||||
const rightImg = rightPanel.querySelector('img') as HTMLImageElement;
|
||||
|
||||
if (!leftImg || !rightImg) return;
|
||||
|
||||
// Synchronize scroll
|
||||
if (this.currentComparison?.config.syncPan) {
|
||||
leftPanel.addEventListener('scroll', () => {
|
||||
rightPanel.scrollLeft = leftPanel.scrollLeft;
|
||||
rightPanel.scrollTop = leftPanel.scrollTop;
|
||||
});
|
||||
|
||||
rightPanel.addEventListener('scroll', () => {
|
||||
leftPanel.scrollLeft = rightPanel.scrollLeft;
|
||||
leftPanel.scrollTop = rightPanel.scrollTop;
|
||||
});
|
||||
}
|
||||
|
||||
// Synchronize zoom with wheel events
|
||||
if (this.currentComparison?.config.syncZoom) {
|
||||
const handleWheel = (e: WheelEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const delta = e.deltaY < 0 ? 1.1 : 0.9;
|
||||
this.currentZoom = Math.max(0.5, Math.min(5, this.currentZoom * delta));
|
||||
|
||||
leftImg.style.transform = `scale(${this.currentZoom})`;
|
||||
rightImg.style.transform = `scale(${this.currentZoom})`;
|
||||
};
|
||||
|
||||
leftPanel.addEventListener('wheel', handleWheel);
|
||||
rightPanel.addEventListener('wheel', handleWheel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add comparison controls toolbar
|
||||
*/
|
||||
private addComparisonControls(container: HTMLElement): void {
|
||||
const toolbar = document.createElement('div');
|
||||
toolbar.className = 'comparison-toolbar';
|
||||
toolbar.style.cssText = `
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
z-index: 100;
|
||||
`;
|
||||
|
||||
// Mode switcher
|
||||
const modes: ComparisonMode[] = ['side-by-side', 'overlay', 'swipe', 'difference'];
|
||||
modes.forEach(mode => {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = `mode-btn mode-${mode}`;
|
||||
btn.style.cssText = `
|
||||
background: ${this.currentComparison?.config.mode === mode ? '#2196F3' : 'rgba(255,255,255,0.1)'};
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 6px 10px;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
`;
|
||||
btn.textContent = mode.replace('-', ' ').replace(/\b\w/g, l => l.toUpperCase());
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
if (this.currentComparison && this.currentComparison.container) {
|
||||
this.currentComparison.config.mode = mode;
|
||||
await this.startComparison(
|
||||
this.currentComparison.leftImage,
|
||||
this.currentComparison.rightImage,
|
||||
this.currentComparison.container,
|
||||
this.currentComparison.config
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
toolbar.appendChild(btn);
|
||||
});
|
||||
|
||||
// Close button
|
||||
const closeBtn = document.createElement('button');
|
||||
closeBtn.style.cssText = `
|
||||
background: rgba(255,0,0,0.5);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 6px 10px;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
margin-left: 10px;
|
||||
`;
|
||||
closeBtn.textContent = 'Close';
|
||||
closeBtn.addEventListener('click', () => this.closeComparison());
|
||||
|
||||
toolbar.appendChild(closeBtn);
|
||||
container.appendChild(toolbar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close comparison
|
||||
*/
|
||||
closeComparison(): void {
|
||||
if (this.currentComparison?.container) {
|
||||
this.currentComparison.container.innerHTML = '';
|
||||
}
|
||||
|
||||
this.currentComparison = null;
|
||||
this.comparisonContainer = undefined;
|
||||
this.leftCanvas = undefined;
|
||||
this.rightCanvas = undefined;
|
||||
this.leftContext = undefined;
|
||||
this.rightContext = undefined;
|
||||
this.swipeHandle = undefined;
|
||||
this.isDraggingSwipe = false;
|
||||
this.currentZoom = 1;
|
||||
this.panX = 0;
|
||||
this.panY = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if comparison is active
|
||||
*/
|
||||
isComparisonActive(): boolean {
|
||||
return this.currentComparison?.isActive || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current comparison state
|
||||
*/
|
||||
getComparisonState(): ComparisonState | null {
|
||||
return this.currentComparison;
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageComparisonService.getInstance();
|
||||
874
apps/client/src/services/image_editor.ts
Normal file
874
apps/client/src/services/image_editor.ts
Normal file
@@ -0,0 +1,874 @@
|
||||
/**
|
||||
* Basic Image Editor Module for Trilium Notes
|
||||
* Provides non-destructive image editing capabilities
|
||||
*/
|
||||
|
||||
import server from './server.js';
|
||||
import toastService from './toast.js';
|
||||
import { ImageValidator, withErrorBoundary, MemoryMonitor, ImageError, ImageErrorType } from './image_error_handler.js';
|
||||
|
||||
/**
|
||||
* Edit operation types
|
||||
*/
|
||||
export type EditOperation =
|
||||
| 'rotate'
|
||||
| 'crop'
|
||||
| 'brightness'
|
||||
| 'contrast'
|
||||
| 'saturation'
|
||||
| 'blur'
|
||||
| 'sharpen';
|
||||
|
||||
/**
|
||||
* Edit history entry
|
||||
*/
|
||||
export interface EditHistoryEntry {
|
||||
operation: EditOperation;
|
||||
params: any;
|
||||
timestamp: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop area definition
|
||||
*/
|
||||
export interface CropArea {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor state
|
||||
*/
|
||||
interface EditorState {
|
||||
originalImage: HTMLImageElement | null;
|
||||
currentImage: HTMLImageElement | null;
|
||||
canvas: HTMLCanvasElement;
|
||||
context: CanvasRenderingContext2D;
|
||||
history: EditHistoryEntry[];
|
||||
historyIndex: number;
|
||||
isEditing: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter parameters
|
||||
*/
|
||||
export interface FilterParams {
|
||||
brightness?: number; // -100 to 100
|
||||
contrast?: number; // -100 to 100
|
||||
saturation?: number; // -100 to 100
|
||||
blur?: number; // 0 to 20
|
||||
sharpen?: number; // 0 to 100
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageEditorService provides basic image editing capabilities
|
||||
*/
|
||||
class ImageEditorService {
|
||||
private static instance: ImageEditorService;
|
||||
private editorState: EditorState;
|
||||
private tempCanvas: HTMLCanvasElement;
|
||||
private tempContext: CanvasRenderingContext2D;
|
||||
private cropOverlay?: HTMLElement;
|
||||
private cropHandles?: HTMLElement[];
|
||||
private cropArea: CropArea | null = null;
|
||||
private isDraggingCrop: boolean = false;
|
||||
private dragStartX: number = 0;
|
||||
private dragStartY: number = 0;
|
||||
private currentFilters: FilterParams = {};
|
||||
|
||||
// Canvas size limits for security and memory management
|
||||
private readonly MAX_CANVAS_SIZE = 8192; // Maximum width/height
|
||||
private readonly MAX_CANVAS_AREA = 50000000; // 50 megapixels
|
||||
|
||||
private constructor() {
|
||||
// Initialize canvases
|
||||
this.editorState = {
|
||||
originalImage: null,
|
||||
currentImage: null,
|
||||
canvas: document.createElement('canvas'),
|
||||
context: null as any,
|
||||
history: [],
|
||||
historyIndex: -1,
|
||||
isEditing: false
|
||||
};
|
||||
|
||||
const ctx = this.editorState.canvas.getContext('2d');
|
||||
if (!ctx) {
|
||||
throw new Error('Failed to get canvas context');
|
||||
}
|
||||
this.editorState.context = ctx;
|
||||
|
||||
this.tempCanvas = document.createElement('canvas');
|
||||
const tempCtx = this.tempCanvas.getContext('2d');
|
||||
if (!tempCtx) {
|
||||
throw new Error('Failed to get temp canvas context');
|
||||
}
|
||||
this.tempContext = tempCtx;
|
||||
}
|
||||
|
||||
static getInstance(): ImageEditorService {
|
||||
if (!ImageEditorService.instance) {
|
||||
ImageEditorService.instance = new ImageEditorService();
|
||||
}
|
||||
return ImageEditorService.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start editing an image
|
||||
*/
|
||||
async startEditing(src: string | HTMLImageElement): Promise<HTMLCanvasElement> {
|
||||
return await withErrorBoundary(async () => {
|
||||
// Validate input
|
||||
if (typeof src === 'string') {
|
||||
ImageValidator.validateUrl(src);
|
||||
}
|
||||
// Load image
|
||||
let img: HTMLImageElement;
|
||||
if (typeof src === 'string') {
|
||||
img = await this.loadImage(src);
|
||||
} else {
|
||||
img = src;
|
||||
}
|
||||
|
||||
// Validate image dimensions
|
||||
ImageValidator.validateDimensions(img.naturalWidth, img.naturalHeight);
|
||||
|
||||
// Check memory availability
|
||||
const estimatedMemory = MemoryMonitor.estimateImageMemory(img.naturalWidth, img.naturalHeight);
|
||||
if (!MemoryMonitor.checkMemoryAvailable(estimatedMemory)) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.MEMORY_ERROR,
|
||||
'Insufficient memory to process image',
|
||||
{ estimatedMemory }
|
||||
);
|
||||
}
|
||||
|
||||
if (img.naturalWidth > this.MAX_CANVAS_SIZE ||
|
||||
img.naturalHeight > this.MAX_CANVAS_SIZE ||
|
||||
img.naturalWidth * img.naturalHeight > this.MAX_CANVAS_AREA) {
|
||||
|
||||
// Scale down if too large
|
||||
const scale = Math.min(
|
||||
this.MAX_CANVAS_SIZE / Math.max(img.naturalWidth, img.naturalHeight),
|
||||
Math.sqrt(this.MAX_CANVAS_AREA / (img.naturalWidth * img.naturalHeight))
|
||||
);
|
||||
|
||||
const scaledWidth = Math.floor(img.naturalWidth * scale);
|
||||
const scaledHeight = Math.floor(img.naturalHeight * scale);
|
||||
|
||||
console.warn(`Image too large (${img.naturalWidth}x${img.naturalHeight}), scaling to ${scaledWidth}x${scaledHeight}`);
|
||||
|
||||
// Create scaled image
|
||||
const scaledCanvas = document.createElement('canvas');
|
||||
scaledCanvas.width = scaledWidth;
|
||||
scaledCanvas.height = scaledHeight;
|
||||
const scaledCtx = scaledCanvas.getContext('2d');
|
||||
if (!scaledCtx) throw new Error('Failed to get scaled canvas context');
|
||||
|
||||
scaledCtx.drawImage(img, 0, 0, scaledWidth, scaledHeight);
|
||||
|
||||
// Create new image from scaled canvas
|
||||
const scaledImg = new Image();
|
||||
scaledImg.src = scaledCanvas.toDataURL();
|
||||
await new Promise(resolve => scaledImg.onload = resolve);
|
||||
img = scaledImg;
|
||||
|
||||
// Clean up scaled canvas
|
||||
scaledCanvas.width = 0;
|
||||
scaledCanvas.height = 0;
|
||||
}
|
||||
|
||||
// Store original
|
||||
this.editorState.originalImage = img;
|
||||
this.editorState.currentImage = img;
|
||||
this.editorState.isEditing = true;
|
||||
this.editorState.history = [];
|
||||
this.editorState.historyIndex = -1;
|
||||
this.currentFilters = {};
|
||||
|
||||
// Setup canvas with validated dimensions
|
||||
this.editorState.canvas.width = img.naturalWidth;
|
||||
this.editorState.canvas.height = img.naturalHeight;
|
||||
this.editorState.context.drawImage(img, 0, 0);
|
||||
|
||||
return this.editorState.canvas;
|
||||
}, (error) => {
|
||||
this.stopEditing();
|
||||
throw error;
|
||||
}) || this.editorState.canvas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate image by degrees (90, 180, 270)
|
||||
*/
|
||||
rotate(degrees: 90 | 180 | 270 | -90): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
const { canvas, context } = this.editorState;
|
||||
const { width, height } = canvas;
|
||||
|
||||
// Setup temp canvas
|
||||
if (degrees === 90 || degrees === -90 || degrees === 270) {
|
||||
this.tempCanvas.width = height;
|
||||
this.tempCanvas.height = width;
|
||||
} else {
|
||||
this.tempCanvas.width = width;
|
||||
this.tempCanvas.height = height;
|
||||
}
|
||||
|
||||
// Clear temp canvas
|
||||
this.tempContext.clearRect(0, 0, this.tempCanvas.width, this.tempCanvas.height);
|
||||
|
||||
// Rotate
|
||||
this.tempContext.save();
|
||||
|
||||
if (degrees === 90) {
|
||||
this.tempContext.translate(height, 0);
|
||||
this.tempContext.rotate(Math.PI / 2);
|
||||
} else if (degrees === 180) {
|
||||
this.tempContext.translate(width, height);
|
||||
this.tempContext.rotate(Math.PI);
|
||||
} else if (degrees === 270 || degrees === -90) {
|
||||
this.tempContext.translate(0, width);
|
||||
this.tempContext.rotate(-Math.PI / 2);
|
||||
}
|
||||
|
||||
this.tempContext.drawImage(canvas, 0, 0);
|
||||
this.tempContext.restore();
|
||||
|
||||
// Copy back to main canvas
|
||||
canvas.width = this.tempCanvas.width;
|
||||
canvas.height = this.tempCanvas.height;
|
||||
context.drawImage(this.tempCanvas, 0, 0);
|
||||
|
||||
// Add to history
|
||||
this.addToHistory('rotate', { degrees });
|
||||
}
|
||||
|
||||
/**
|
||||
* Start crop selection
|
||||
*/
|
||||
startCrop(container: HTMLElement): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
// Create crop overlay
|
||||
this.cropOverlay = document.createElement('div');
|
||||
this.cropOverlay.className = 'crop-overlay';
|
||||
this.cropOverlay.style.cssText = `
|
||||
position: absolute;
|
||||
border: 2px dashed #fff;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
cursor: move;
|
||||
z-index: 1000;
|
||||
`;
|
||||
|
||||
// Create resize handles
|
||||
this.cropHandles = [];
|
||||
const handlePositions = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
|
||||
|
||||
handlePositions.forEach(pos => {
|
||||
const handle = document.createElement('div');
|
||||
handle.className = `crop-handle crop-handle-${pos}`;
|
||||
handle.dataset.position = pos;
|
||||
handle.style.cssText = `
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: white;
|
||||
border: 1px solid #333;
|
||||
z-index: 1001;
|
||||
`;
|
||||
|
||||
// Position handles
|
||||
switch (pos) {
|
||||
case 'nw':
|
||||
handle.style.top = '-5px';
|
||||
handle.style.left = '-5px';
|
||||
handle.style.cursor = 'nw-resize';
|
||||
break;
|
||||
case 'n':
|
||||
handle.style.top = '-5px';
|
||||
handle.style.left = '50%';
|
||||
handle.style.transform = 'translateX(-50%)';
|
||||
handle.style.cursor = 'n-resize';
|
||||
break;
|
||||
case 'ne':
|
||||
handle.style.top = '-5px';
|
||||
handle.style.right = '-5px';
|
||||
handle.style.cursor = 'ne-resize';
|
||||
break;
|
||||
case 'e':
|
||||
handle.style.top = '50%';
|
||||
handle.style.right = '-5px';
|
||||
handle.style.transform = 'translateY(-50%)';
|
||||
handle.style.cursor = 'e-resize';
|
||||
break;
|
||||
case 'se':
|
||||
handle.style.bottom = '-5px';
|
||||
handle.style.right = '-5px';
|
||||
handle.style.cursor = 'se-resize';
|
||||
break;
|
||||
case 's':
|
||||
handle.style.bottom = '-5px';
|
||||
handle.style.left = '50%';
|
||||
handle.style.transform = 'translateX(-50%)';
|
||||
handle.style.cursor = 's-resize';
|
||||
break;
|
||||
case 'sw':
|
||||
handle.style.bottom = '-5px';
|
||||
handle.style.left = '-5px';
|
||||
handle.style.cursor = 'sw-resize';
|
||||
break;
|
||||
case 'w':
|
||||
handle.style.top = '50%';
|
||||
handle.style.left = '-5px';
|
||||
handle.style.transform = 'translateY(-50%)';
|
||||
handle.style.cursor = 'w-resize';
|
||||
break;
|
||||
}
|
||||
|
||||
this.cropOverlay.appendChild(handle);
|
||||
this.cropHandles!.push(handle);
|
||||
});
|
||||
|
||||
// Set initial crop area (80% of image)
|
||||
const canvasRect = this.editorState.canvas.getBoundingClientRect();
|
||||
const initialSize = Math.min(canvasRect.width, canvasRect.height) * 0.8;
|
||||
const initialX = (canvasRect.width - initialSize) / 2;
|
||||
const initialY = (canvasRect.height - initialSize) / 2;
|
||||
|
||||
this.cropArea = {
|
||||
x: initialX,
|
||||
y: initialY,
|
||||
width: initialSize,
|
||||
height: initialSize
|
||||
};
|
||||
|
||||
this.updateCropOverlay();
|
||||
container.appendChild(this.cropOverlay);
|
||||
|
||||
// Setup drag handlers
|
||||
this.setupCropHandlers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup crop interaction handlers
|
||||
*/
|
||||
private setupCropHandlers(): void {
|
||||
if (!this.cropOverlay) return;
|
||||
|
||||
// Drag to move
|
||||
this.cropOverlay.addEventListener('mousedown', (e) => {
|
||||
if ((e.target as HTMLElement).classList.contains('crop-handle')) return;
|
||||
|
||||
this.isDraggingCrop = true;
|
||||
this.dragStartX = e.clientX;
|
||||
this.dragStartY = e.clientY;
|
||||
|
||||
const handleMove = (e: MouseEvent) => {
|
||||
if (!this.isDraggingCrop || !this.cropArea) return;
|
||||
|
||||
const deltaX = e.clientX - this.dragStartX;
|
||||
const deltaY = e.clientY - this.dragStartY;
|
||||
|
||||
this.cropArea.x += deltaX;
|
||||
this.cropArea.y += deltaY;
|
||||
|
||||
this.dragStartX = e.clientX;
|
||||
this.dragStartY = e.clientY;
|
||||
|
||||
this.updateCropOverlay();
|
||||
};
|
||||
|
||||
const handleUp = () => {
|
||||
this.isDraggingCrop = false;
|
||||
document.removeEventListener('mousemove', handleMove);
|
||||
document.removeEventListener('mouseup', handleUp);
|
||||
};
|
||||
|
||||
document.addEventListener('mousemove', handleMove);
|
||||
document.addEventListener('mouseup', handleUp);
|
||||
});
|
||||
|
||||
// Resize handles
|
||||
this.cropHandles?.forEach(handle => {
|
||||
handle.addEventListener('mousedown', (e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
const position = handle.dataset.position!;
|
||||
const startX = e.clientX;
|
||||
const startY = e.clientY;
|
||||
const startCrop = { ...this.cropArea! };
|
||||
|
||||
const handleResize = (e: MouseEvent) => {
|
||||
if (!this.cropArea) return;
|
||||
|
||||
const deltaX = e.clientX - startX;
|
||||
const deltaY = e.clientY - startY;
|
||||
|
||||
switch (position) {
|
||||
case 'nw':
|
||||
this.cropArea.x = startCrop.x + deltaX;
|
||||
this.cropArea.y = startCrop.y + deltaY;
|
||||
this.cropArea.width = startCrop.width - deltaX;
|
||||
this.cropArea.height = startCrop.height - deltaY;
|
||||
break;
|
||||
case 'n':
|
||||
this.cropArea.y = startCrop.y + deltaY;
|
||||
this.cropArea.height = startCrop.height - deltaY;
|
||||
break;
|
||||
case 'ne':
|
||||
this.cropArea.y = startCrop.y + deltaY;
|
||||
this.cropArea.width = startCrop.width + deltaX;
|
||||
this.cropArea.height = startCrop.height - deltaY;
|
||||
break;
|
||||
case 'e':
|
||||
this.cropArea.width = startCrop.width + deltaX;
|
||||
break;
|
||||
case 'se':
|
||||
this.cropArea.width = startCrop.width + deltaX;
|
||||
this.cropArea.height = startCrop.height + deltaY;
|
||||
break;
|
||||
case 's':
|
||||
this.cropArea.height = startCrop.height + deltaY;
|
||||
break;
|
||||
case 'sw':
|
||||
this.cropArea.x = startCrop.x + deltaX;
|
||||
this.cropArea.width = startCrop.width - deltaX;
|
||||
this.cropArea.height = startCrop.height + deltaY;
|
||||
break;
|
||||
case 'w':
|
||||
this.cropArea.x = startCrop.x + deltaX;
|
||||
this.cropArea.width = startCrop.width - deltaX;
|
||||
break;
|
||||
}
|
||||
|
||||
// Ensure minimum size
|
||||
this.cropArea.width = Math.max(50, this.cropArea.width);
|
||||
this.cropArea.height = Math.max(50, this.cropArea.height);
|
||||
|
||||
this.updateCropOverlay();
|
||||
};
|
||||
|
||||
const handleUp = () => {
|
||||
document.removeEventListener('mousemove', handleResize);
|
||||
document.removeEventListener('mouseup', handleUp);
|
||||
};
|
||||
|
||||
document.addEventListener('mousemove', handleResize);
|
||||
document.addEventListener('mouseup', handleUp);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update crop overlay position
|
||||
*/
|
||||
private updateCropOverlay(): void {
|
||||
if (!this.cropOverlay || !this.cropArea) return;
|
||||
|
||||
this.cropOverlay.style.left = `${this.cropArea.x}px`;
|
||||
this.cropOverlay.style.top = `${this.cropArea.y}px`;
|
||||
this.cropOverlay.style.width = `${this.cropArea.width}px`;
|
||||
this.cropOverlay.style.height = `${this.cropArea.height}px`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply crop
|
||||
*/
|
||||
applyCrop(): void {
|
||||
if (!this.editorState.isEditing || !this.cropArea) return;
|
||||
|
||||
const { canvas, context } = this.editorState;
|
||||
const canvasRect = canvas.getBoundingClientRect();
|
||||
|
||||
// Convert crop area from screen to canvas coordinates
|
||||
const scaleX = canvas.width / canvasRect.width;
|
||||
const scaleY = canvas.height / canvasRect.height;
|
||||
|
||||
const cropX = this.cropArea.x * scaleX;
|
||||
const cropY = this.cropArea.y * scaleY;
|
||||
const cropWidth = this.cropArea.width * scaleX;
|
||||
const cropHeight = this.cropArea.height * scaleY;
|
||||
|
||||
// Get cropped image data
|
||||
const imageData = context.getImageData(cropX, cropY, cropWidth, cropHeight);
|
||||
|
||||
// Resize canvas and put cropped image
|
||||
canvas.width = cropWidth;
|
||||
canvas.height = cropHeight;
|
||||
context.putImageData(imageData, 0, 0);
|
||||
|
||||
// Clean up crop overlay
|
||||
this.cancelCrop();
|
||||
|
||||
// Add to history
|
||||
this.addToHistory('crop', {
|
||||
x: cropX,
|
||||
y: cropY,
|
||||
width: cropWidth,
|
||||
height: cropHeight
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel crop
|
||||
*/
|
||||
cancelCrop(): void {
|
||||
if (this.cropOverlay) {
|
||||
this.cropOverlay.remove();
|
||||
this.cropOverlay = undefined;
|
||||
}
|
||||
this.cropHandles = undefined;
|
||||
this.cropArea = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply brightness adjustment
|
||||
*/
|
||||
applyBrightness(value: number): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
this.currentFilters.brightness = value;
|
||||
this.applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply contrast adjustment
|
||||
*/
|
||||
applyContrast(value: number): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
this.currentFilters.contrast = value;
|
||||
this.applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply saturation adjustment
|
||||
*/
|
||||
applySaturation(value: number): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
this.currentFilters.saturation = value;
|
||||
this.applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply all filters
|
||||
*/
|
||||
private applyFilters(): void {
|
||||
const { canvas, context, originalImage } = this.editorState;
|
||||
|
||||
if (!originalImage) return;
|
||||
|
||||
// Clear canvas and redraw original
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
context.drawImage(originalImage, 0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Get image data
|
||||
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||
const data = imageData.data;
|
||||
|
||||
// Apply brightness
|
||||
if (this.currentFilters.brightness) {
|
||||
const brightness = this.currentFilters.brightness * 2.55; // Convert to 0-255 range
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
data[i] = Math.min(255, Math.max(0, data[i] + brightness));
|
||||
data[i + 1] = Math.min(255, Math.max(0, data[i + 1] + brightness));
|
||||
data[i + 2] = Math.min(255, Math.max(0, data[i + 2] + brightness));
|
||||
}
|
||||
}
|
||||
|
||||
// Apply contrast
|
||||
if (this.currentFilters.contrast) {
|
||||
const factor = (259 * (this.currentFilters.contrast + 255)) / (255 * (259 - this.currentFilters.contrast));
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
data[i] = Math.min(255, Math.max(0, factor * (data[i] - 128) + 128));
|
||||
data[i + 1] = Math.min(255, Math.max(0, factor * (data[i + 1] - 128) + 128));
|
||||
data[i + 2] = Math.min(255, Math.max(0, factor * (data[i + 2] - 128) + 128));
|
||||
}
|
||||
}
|
||||
|
||||
// Apply saturation
|
||||
if (this.currentFilters.saturation) {
|
||||
const saturation = this.currentFilters.saturation / 100;
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
const gray = 0.2989 * data[i] + 0.5870 * data[i + 1] + 0.1140 * data[i + 2];
|
||||
data[i] = Math.min(255, Math.max(0, gray + saturation * (data[i] - gray)));
|
||||
data[i + 1] = Math.min(255, Math.max(0, gray + saturation * (data[i + 1] - gray)));
|
||||
data[i + 2] = Math.min(255, Math.max(0, gray + saturation * (data[i + 2] - gray)));
|
||||
}
|
||||
}
|
||||
|
||||
// Put modified image data back
|
||||
context.putImageData(imageData, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply blur effect
|
||||
*/
|
||||
applyBlur(radius: number): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
const { canvas, context } = this.editorState;
|
||||
|
||||
// Use CSS filter for performance
|
||||
context.filter = `blur(${radius}px)`;
|
||||
context.drawImage(canvas, 0, 0);
|
||||
context.filter = 'none';
|
||||
|
||||
this.addToHistory('blur', { radius });
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply sharpen effect
|
||||
*/
|
||||
applySharpen(amount: number): void {
|
||||
if (!this.editorState.isEditing) return;
|
||||
|
||||
const { canvas, context } = this.editorState;
|
||||
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||
const data = imageData.data;
|
||||
const width = canvas.width;
|
||||
const height = canvas.height;
|
||||
|
||||
// Create copy of original data
|
||||
const original = new Uint8ClampedArray(data);
|
||||
|
||||
// Sharpen kernel
|
||||
const kernel = [
|
||||
0, -1, 0,
|
||||
-1, 5 + amount / 25, -1,
|
||||
0, -1, 0
|
||||
];
|
||||
|
||||
// Apply convolution
|
||||
for (let y = 1; y < height - 1; y++) {
|
||||
for (let x = 1; x < width - 1; x++) {
|
||||
const idx = (y * width + x) * 4;
|
||||
|
||||
for (let c = 0; c < 3; c++) {
|
||||
let sum = 0;
|
||||
for (let ky = -1; ky <= 1; ky++) {
|
||||
for (let kx = -1; kx <= 1; kx++) {
|
||||
const kidx = ((y + ky) * width + (x + kx)) * 4;
|
||||
sum += original[kidx + c] * kernel[(ky + 1) * 3 + (kx + 1)];
|
||||
}
|
||||
}
|
||||
data[idx + c] = Math.min(255, Math.max(0, sum));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.putImageData(imageData, 0, 0);
|
||||
this.addToHistory('sharpen', { amount });
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo last operation
|
||||
*/
|
||||
undo(): void {
|
||||
if (!this.editorState.isEditing || this.editorState.historyIndex <= 0) return;
|
||||
|
||||
this.editorState.historyIndex--;
|
||||
this.replayHistory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redo operation
|
||||
*/
|
||||
redo(): void {
|
||||
if (!this.editorState.isEditing ||
|
||||
this.editorState.historyIndex >= this.editorState.history.length - 1) return;
|
||||
|
||||
this.editorState.historyIndex++;
|
||||
this.replayHistory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replay history up to current index
|
||||
*/
|
||||
private replayHistory(): void {
|
||||
const { canvas, context, originalImage, history, historyIndex } = this.editorState;
|
||||
|
||||
if (!originalImage) return;
|
||||
|
||||
// Reset to original
|
||||
canvas.width = originalImage.naturalWidth;
|
||||
canvas.height = originalImage.naturalHeight;
|
||||
context.drawImage(originalImage, 0, 0);
|
||||
|
||||
// Replay operations
|
||||
for (let i = 0; i <= historyIndex; i++) {
|
||||
const entry = history[i];
|
||||
// Apply operation based on entry
|
||||
// Note: This is simplified - actual implementation would need to store and replay exact operations
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add operation to history
|
||||
*/
|
||||
private addToHistory(operation: EditOperation, params: any): void {
|
||||
// Remove any operations after current index
|
||||
this.editorState.history = this.editorState.history.slice(0, this.editorState.historyIndex + 1);
|
||||
|
||||
// Add new operation
|
||||
this.editorState.history.push({
|
||||
operation,
|
||||
params,
|
||||
timestamp: new Date()
|
||||
});
|
||||
|
||||
this.editorState.historyIndex++;
|
||||
|
||||
// Limit history size
|
||||
if (this.editorState.history.length > 50) {
|
||||
this.editorState.history.shift();
|
||||
this.editorState.historyIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save edited image
|
||||
*/
|
||||
async saveImage(noteId?: string): Promise<Blob> {
|
||||
if (!this.editorState.isEditing) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
'No image being edited'
|
||||
);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.editorState.canvas.toBlob((blob) => {
|
||||
if (blob) {
|
||||
resolve(blob);
|
||||
|
||||
if (noteId) {
|
||||
// Optionally save to server
|
||||
this.saveToServer(noteId, blob);
|
||||
}
|
||||
} else {
|
||||
reject(new Error('Failed to create blob'));
|
||||
}
|
||||
}, 'image/png');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Save edited image to server
|
||||
*/
|
||||
private async saveToServer(noteId: string, blob: Blob): Promise<void> {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('image', blob, 'edited.png');
|
||||
|
||||
await server.upload(`notes/${noteId}/image`, formData);
|
||||
toastService.showMessage('Image saved successfully');
|
||||
} catch (error) {
|
||||
console.error('Failed to save image:', error);
|
||||
toastService.showError('Failed to save image');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset to original image
|
||||
*/
|
||||
reset(): void {
|
||||
if (!this.editorState.isEditing || !this.editorState.originalImage) return;
|
||||
|
||||
const { canvas, context, originalImage } = this.editorState;
|
||||
|
||||
canvas.width = originalImage.naturalWidth;
|
||||
canvas.height = originalImage.naturalHeight;
|
||||
context.drawImage(originalImage, 0, 0);
|
||||
|
||||
this.currentFilters = {};
|
||||
this.editorState.history = [];
|
||||
this.editorState.historyIndex = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop editing and clean up resources
|
||||
*/
|
||||
stopEditing(): void {
|
||||
this.cancelCrop();
|
||||
|
||||
// Request garbage collection after cleanup
|
||||
MemoryMonitor.requestGarbageCollection();
|
||||
|
||||
// Clean up canvas memory
|
||||
if (this.editorState.canvas) {
|
||||
this.editorState.context.clearRect(0, 0, this.editorState.canvas.width, this.editorState.canvas.height);
|
||||
this.editorState.canvas.width = 0;
|
||||
this.editorState.canvas.height = 0;
|
||||
}
|
||||
|
||||
if (this.tempCanvas) {
|
||||
this.tempContext.clearRect(0, 0, this.tempCanvas.width, this.tempCanvas.height);
|
||||
this.tempCanvas.width = 0;
|
||||
this.tempCanvas.height = 0;
|
||||
}
|
||||
|
||||
// Release image references
|
||||
if (this.editorState.originalImage) {
|
||||
this.editorState.originalImage.src = '';
|
||||
}
|
||||
if (this.editorState.currentImage) {
|
||||
this.editorState.currentImage.src = '';
|
||||
}
|
||||
|
||||
this.editorState.isEditing = false;
|
||||
this.editorState.originalImage = null;
|
||||
this.editorState.currentImage = null;
|
||||
this.editorState.history = [];
|
||||
this.editorState.historyIndex = -1;
|
||||
this.currentFilters = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image from URL
|
||||
*/
|
||||
private loadImage(src: string): Promise<HTMLImageElement> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.crossOrigin = 'anonymous';
|
||||
img.onload = () => resolve(img);
|
||||
img.onerror = () => reject(new Error(`Failed to load image: ${src}`));
|
||||
img.src = src;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if can undo
|
||||
*/
|
||||
canUndo(): boolean {
|
||||
return this.editorState.historyIndex > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if can redo
|
||||
*/
|
||||
canRedo(): boolean {
|
||||
return this.editorState.historyIndex < this.editorState.history.length - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current canvas
|
||||
*/
|
||||
getCanvas(): HTMLCanvasElement {
|
||||
return this.editorState.canvas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if editing
|
||||
*/
|
||||
isEditing(): boolean {
|
||||
return this.editorState.isEditing;
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageEditorService.getInstance();
|
||||
369
apps/client/src/services/image_error_handler.ts
Normal file
369
apps/client/src/services/image_error_handler.ts
Normal file
@@ -0,0 +1,369 @@
|
||||
/**
|
||||
* Error Handler for Image Processing Operations
|
||||
* Provides error boundaries and validation for image-related operations
|
||||
*/
|
||||
|
||||
import toastService from './toast.js';
|
||||
|
||||
/**
|
||||
* Error types for image operations
|
||||
*/
|
||||
export enum ImageErrorType {
|
||||
INVALID_INPUT = 'INVALID_INPUT',
|
||||
SIZE_LIMIT_EXCEEDED = 'SIZE_LIMIT_EXCEEDED',
|
||||
MEMORY_ERROR = 'MEMORY_ERROR',
|
||||
PROCESSING_ERROR = 'PROCESSING_ERROR',
|
||||
NETWORK_ERROR = 'NETWORK_ERROR',
|
||||
SECURITY_ERROR = 'SECURITY_ERROR'
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom error class for image operations
|
||||
*/
|
||||
export class ImageError extends Error {
|
||||
constructor(
|
||||
public type: ImageErrorType,
|
||||
message: string,
|
||||
public details?: any
|
||||
) {
|
||||
super(message);
|
||||
this.name = 'ImageError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Input validation utilities
|
||||
*/
|
||||
export class ImageValidator {
|
||||
private static readonly MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
||||
private static readonly ALLOWED_MIME_TYPES = [
|
||||
'image/jpeg',
|
||||
'image/jpg',
|
||||
'image/png',
|
||||
'image/gif',
|
||||
'image/webp',
|
||||
'image/svg+xml',
|
||||
'image/bmp'
|
||||
];
|
||||
private static readonly MAX_DIMENSION = 16384;
|
||||
private static readonly MAX_AREA = 100000000; // 100 megapixels
|
||||
|
||||
/**
|
||||
* Validate file input
|
||||
*/
|
||||
static validateFile(file: File): void {
|
||||
// Check file size
|
||||
if (file.size > this.MAX_FILE_SIZE) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.SIZE_LIMIT_EXCEEDED,
|
||||
`File size exceeds maximum allowed size of ${this.MAX_FILE_SIZE / 1024 / 1024}MB`,
|
||||
{ fileSize: file.size, maxSize: this.MAX_FILE_SIZE }
|
||||
);
|
||||
}
|
||||
|
||||
// Check MIME type
|
||||
if (!this.ALLOWED_MIME_TYPES.includes(file.type)) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
`File type ${file.type} is not supported`,
|
||||
{ fileType: file.type, allowedTypes: this.ALLOWED_MIME_TYPES }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate image dimensions
|
||||
*/
|
||||
static validateDimensions(width: number, height: number): void {
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
'Invalid image dimensions',
|
||||
{ width, height }
|
||||
);
|
||||
}
|
||||
|
||||
if (width > this.MAX_DIMENSION || height > this.MAX_DIMENSION) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.SIZE_LIMIT_EXCEEDED,
|
||||
`Image dimensions exceed maximum allowed size of ${this.MAX_DIMENSION}px`,
|
||||
{ width, height, maxDimension: this.MAX_DIMENSION }
|
||||
);
|
||||
}
|
||||
|
||||
if (width * height > this.MAX_AREA) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.SIZE_LIMIT_EXCEEDED,
|
||||
`Image area exceeds maximum allowed area of ${this.MAX_AREA / 1000000} megapixels`,
|
||||
{ area: width * height, maxArea: this.MAX_AREA }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate URL
|
||||
*/
|
||||
static validateUrl(url: string): void {
|
||||
try {
|
||||
const parsedUrl = new URL(url);
|
||||
|
||||
// Check protocol
|
||||
if (!['http:', 'https:', 'data:', 'blob:'].includes(parsedUrl.protocol)) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.SECURITY_ERROR,
|
||||
`Unsupported protocol: ${parsedUrl.protocol}`,
|
||||
{ url, protocol: parsedUrl.protocol }
|
||||
);
|
||||
}
|
||||
|
||||
// Additional security checks for data URLs
|
||||
if (parsedUrl.protocol === 'data:') {
|
||||
const [header] = url.split(',');
|
||||
if (!header.includes('image/')) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
'Data URL does not contain image data',
|
||||
{ url: url.substring(0, 100) }
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof ImageError) {
|
||||
throw error;
|
||||
}
|
||||
throw new ImageError(
|
||||
ImageErrorType.INVALID_INPUT,
|
||||
'Invalid URL format',
|
||||
{ url, originalError: error }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize filename
|
||||
*/
|
||||
static sanitizeFilename(filename: string): string {
|
||||
// Remove path traversal attempts
|
||||
filename = filename.replace(/\.\./g, '');
|
||||
filename = filename.replace(/[\/\\]/g, '_');
|
||||
|
||||
// Remove special characters except dots and dashes
|
||||
filename = filename.replace(/[^a-zA-Z0-9._-]/g, '_');
|
||||
|
||||
// Limit length
|
||||
if (filename.length > 255) {
|
||||
const ext = filename.split('.').pop();
|
||||
filename = filename.substring(0, 250) + '.' + ext;
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error boundary wrapper for async operations
|
||||
*/
|
||||
export async function withErrorBoundary<T>(
|
||||
operation: () => Promise<T>,
|
||||
errorHandler?: (error: Error) => void
|
||||
): Promise<T | null> {
|
||||
try {
|
||||
return await operation();
|
||||
} catch (error) {
|
||||
const imageError = error instanceof ImageError
|
||||
? error
|
||||
: new ImageError(
|
||||
ImageErrorType.PROCESSING_ERROR,
|
||||
error instanceof Error ? error.message : 'Unknown error occurred',
|
||||
{ originalError: error }
|
||||
);
|
||||
|
||||
// Log error
|
||||
console.error('[Image Error]', imageError.type, imageError.message, imageError.details);
|
||||
|
||||
// Show user-friendly message
|
||||
switch (imageError.type) {
|
||||
case ImageErrorType.SIZE_LIMIT_EXCEEDED:
|
||||
toastService.showError('Image is too large to process');
|
||||
break;
|
||||
case ImageErrorType.INVALID_INPUT:
|
||||
toastService.showError('Invalid image or input provided');
|
||||
break;
|
||||
case ImageErrorType.MEMORY_ERROR:
|
||||
toastService.showError('Not enough memory to process image');
|
||||
break;
|
||||
case ImageErrorType.SECURITY_ERROR:
|
||||
toastService.showError('Security violation detected');
|
||||
break;
|
||||
case ImageErrorType.NETWORK_ERROR:
|
||||
toastService.showError('Network error occurred');
|
||||
break;
|
||||
default:
|
||||
toastService.showError('Failed to process image');
|
||||
}
|
||||
|
||||
// Call custom error handler if provided
|
||||
if (errorHandler) {
|
||||
errorHandler(imageError);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory monitoring utilities
|
||||
*/
|
||||
export class MemoryMonitor {
|
||||
private static readonly WARNING_THRESHOLD = 0.8; // 80% of available memory
|
||||
|
||||
/**
|
||||
* Check if memory is available for operation
|
||||
*/
|
||||
static checkMemoryAvailable(estimatedBytes: number): boolean {
|
||||
if ('memory' in performance && (performance as any).memory) {
|
||||
const memory = (performance as any).memory;
|
||||
const used = memory.usedJSHeapSize;
|
||||
const limit = memory.jsHeapSizeLimit;
|
||||
const available = limit - used;
|
||||
|
||||
if (estimatedBytes > available * this.WARNING_THRESHOLD) {
|
||||
console.warn(`Memory warning: Estimated ${estimatedBytes} bytes needed, ${available} bytes available`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate memory needed for image
|
||||
*/
|
||||
static estimateImageMemory(width: number, height: number, channels: number = 4): number {
|
||||
// Each pixel uses 4 bytes (RGBA) or specified channels
|
||||
return width * height * channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force garbage collection if available
|
||||
*/
|
||||
static requestGarbageCollection(): void {
|
||||
if (typeof (globalThis as any).gc === 'function') {
|
||||
(globalThis as any).gc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Web Worker support for heavy operations
|
||||
*/
|
||||
export class ImageWorkerPool {
|
||||
private workers: Worker[] = [];
|
||||
private taskQueue: Array<{
|
||||
data: any;
|
||||
resolve: (value: any) => void;
|
||||
reject: (error: any) => void;
|
||||
}> = [];
|
||||
private busyWorkers = new Set<Worker>();
|
||||
|
||||
constructor(
|
||||
private workerScript: string,
|
||||
private poolSize: number = navigator.hardwareConcurrency || 4
|
||||
) {
|
||||
this.initializeWorkers();
|
||||
}
|
||||
|
||||
private initializeWorkers(): void {
|
||||
for (let i = 0; i < this.poolSize; i++) {
|
||||
try {
|
||||
const worker = new Worker(this.workerScript);
|
||||
worker.addEventListener('message', (e) => this.handleWorkerMessage(worker, e));
|
||||
worker.addEventListener('error', (e) => this.handleWorkerError(worker, e));
|
||||
this.workers.push(worker);
|
||||
} catch (error) {
|
||||
console.error('Failed to create worker:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleWorkerMessage(worker: Worker, event: MessageEvent): void {
|
||||
this.busyWorkers.delete(worker);
|
||||
|
||||
// Process next task if available
|
||||
if (this.taskQueue.length > 0) {
|
||||
const task = this.taskQueue.shift()!;
|
||||
this.executeTask(worker, task);
|
||||
}
|
||||
}
|
||||
|
||||
private handleWorkerError(worker: Worker, event: ErrorEvent): void {
|
||||
this.busyWorkers.delete(worker);
|
||||
console.error('Worker error:', event);
|
||||
}
|
||||
|
||||
private executeTask(
|
||||
worker: Worker,
|
||||
task: { data: any; resolve: (value: any) => void; reject: (error: any) => void }
|
||||
): void {
|
||||
this.busyWorkers.add(worker);
|
||||
|
||||
const messageHandler = (e: MessageEvent) => {
|
||||
worker.removeEventListener('message', messageHandler);
|
||||
worker.removeEventListener('error', errorHandler);
|
||||
this.busyWorkers.delete(worker);
|
||||
task.resolve(e.data);
|
||||
|
||||
// Process next task
|
||||
if (this.taskQueue.length > 0) {
|
||||
const nextTask = this.taskQueue.shift()!;
|
||||
this.executeTask(worker, nextTask);
|
||||
}
|
||||
};
|
||||
|
||||
const errorHandler = (e: ErrorEvent) => {
|
||||
worker.removeEventListener('message', messageHandler);
|
||||
worker.removeEventListener('error', errorHandler);
|
||||
this.busyWorkers.delete(worker);
|
||||
task.reject(e);
|
||||
|
||||
// Process next task
|
||||
if (this.taskQueue.length > 0) {
|
||||
const nextTask = this.taskQueue.shift()!;
|
||||
this.executeTask(worker, nextTask);
|
||||
}
|
||||
};
|
||||
|
||||
worker.addEventListener('message', messageHandler);
|
||||
worker.addEventListener('error', errorHandler);
|
||||
worker.postMessage(task.data);
|
||||
}
|
||||
|
||||
async process(data: any): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Find available worker
|
||||
const availableWorker = this.workers.find(w => !this.busyWorkers.has(w));
|
||||
|
||||
if (availableWorker) {
|
||||
this.executeTask(availableWorker, { data, resolve, reject });
|
||||
} else {
|
||||
// Queue task
|
||||
this.taskQueue.push({ data, resolve, reject });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
terminate(): void {
|
||||
this.workers.forEach(worker => worker.terminate());
|
||||
this.workers = [];
|
||||
this.taskQueue = [];
|
||||
this.busyWorkers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
ImageError,
|
||||
ImageErrorType,
|
||||
ImageValidator,
|
||||
MemoryMonitor,
|
||||
ImageWorkerPool,
|
||||
withErrorBoundary
|
||||
};
|
||||
839
apps/client/src/services/image_exif.ts
Normal file
839
apps/client/src/services/image_exif.ts
Normal file
@@ -0,0 +1,839 @@
|
||||
/**
|
||||
* EXIF Data Viewer Module for Trilium Notes
|
||||
* Extracts and displays EXIF metadata from images
|
||||
*/
|
||||
|
||||
/**
|
||||
* EXIF data structure
|
||||
*/
|
||||
export interface ExifData {
|
||||
// Image information
|
||||
make?: string;
|
||||
model?: string;
|
||||
software?: string;
|
||||
dateTime?: Date;
|
||||
dateTimeOriginal?: Date;
|
||||
dateTimeDigitized?: Date;
|
||||
|
||||
// Camera settings
|
||||
exposureTime?: string;
|
||||
fNumber?: number;
|
||||
exposureProgram?: string;
|
||||
iso?: number;
|
||||
shutterSpeedValue?: string;
|
||||
apertureValue?: number;
|
||||
brightnessValue?: number;
|
||||
exposureBiasValue?: number;
|
||||
maxApertureValue?: number;
|
||||
meteringMode?: string;
|
||||
flash?: string;
|
||||
focalLength?: number;
|
||||
focalLengthIn35mm?: number;
|
||||
|
||||
// Image properties
|
||||
imageWidth?: number;
|
||||
imageHeight?: number;
|
||||
orientation?: number;
|
||||
xResolution?: number;
|
||||
yResolution?: number;
|
||||
resolutionUnit?: string;
|
||||
colorSpace?: string;
|
||||
whiteBalance?: string;
|
||||
|
||||
// GPS information
|
||||
gpsLatitude?: number;
|
||||
gpsLongitude?: number;
|
||||
gpsAltitude?: number;
|
||||
gpsTimestamp?: Date;
|
||||
gpsSpeed?: number;
|
||||
gpsDirection?: number;
|
||||
|
||||
// Other metadata
|
||||
artist?: string;
|
||||
copyright?: string;
|
||||
userComment?: string;
|
||||
imageDescription?: string;
|
||||
lensModel?: string;
|
||||
lensMake?: string;
|
||||
|
||||
// Raw data
|
||||
raw?: Record<string, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* EXIF tag definitions
|
||||
*/
|
||||
const EXIF_TAGS: Record<number, string> = {
|
||||
0x010F: 'make',
|
||||
0x0110: 'model',
|
||||
0x0131: 'software',
|
||||
0x0132: 'dateTime',
|
||||
0x829A: 'exposureTime',
|
||||
0x829D: 'fNumber',
|
||||
0x8822: 'exposureProgram',
|
||||
0x8827: 'iso',
|
||||
0x9003: 'dateTimeOriginal',
|
||||
0x9004: 'dateTimeDigitized',
|
||||
0x9201: 'shutterSpeedValue',
|
||||
0x9202: 'apertureValue',
|
||||
0x9203: 'brightnessValue',
|
||||
0x9204: 'exposureBiasValue',
|
||||
0x9205: 'maxApertureValue',
|
||||
0x9207: 'meteringMode',
|
||||
0x9209: 'flash',
|
||||
0x920A: 'focalLength',
|
||||
0xA002: 'imageWidth',
|
||||
0xA003: 'imageHeight',
|
||||
0x0112: 'orientation',
|
||||
0x011A: 'xResolution',
|
||||
0x011B: 'yResolution',
|
||||
0x0128: 'resolutionUnit',
|
||||
0xA001: 'colorSpace',
|
||||
0xA403: 'whiteBalance',
|
||||
0x8298: 'copyright',
|
||||
0x013B: 'artist',
|
||||
0x9286: 'userComment',
|
||||
0x010E: 'imageDescription',
|
||||
0xA434: 'lensModel',
|
||||
0xA433: 'lensMake',
|
||||
0xA432: 'focalLengthIn35mm'
|
||||
};
|
||||
|
||||
/**
|
||||
* GPS tag definitions
|
||||
*/
|
||||
const GPS_TAGS: Record<number, string> = {
|
||||
0x0001: 'gpsLatitudeRef',
|
||||
0x0002: 'gpsLatitude',
|
||||
0x0003: 'gpsLongitudeRef',
|
||||
0x0004: 'gpsLongitude',
|
||||
0x0005: 'gpsAltitudeRef',
|
||||
0x0006: 'gpsAltitude',
|
||||
0x0007: 'gpsTimestamp',
|
||||
0x000D: 'gpsSpeed',
|
||||
0x0010: 'gpsDirection'
|
||||
};
|
||||
|
||||
/**
|
||||
* ImageExifService extracts and manages EXIF metadata from images
|
||||
*/
|
||||
class ImageExifService {
|
||||
private static instance: ImageExifService;
|
||||
private exifCache: Map<string, ExifData> = new Map();
|
||||
private cacheOrder: string[] = []; // Track cache insertion order for LRU
|
||||
private readonly MAX_CACHE_SIZE = 50; // Maximum number of cached entries
|
||||
private readonly MAX_BUFFER_SIZE = 100 * 1024 * 1024; // 100MB max buffer size
|
||||
|
||||
private constructor() {}
|
||||
|
||||
static getInstance(): ImageExifService {
|
||||
if (!ImageExifService.instance) {
|
||||
ImageExifService.instance = new ImageExifService();
|
||||
}
|
||||
return ImageExifService.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract EXIF data from image URL or file
|
||||
*/
|
||||
async extractExifData(source: string | File | Blob): Promise<ExifData | null> {
|
||||
try {
|
||||
// Check cache if URL
|
||||
if (typeof source === 'string' && this.exifCache.has(source)) {
|
||||
// Move to end for LRU
|
||||
this.updateCacheOrder(source);
|
||||
return this.exifCache.get(source)!;
|
||||
}
|
||||
|
||||
// Get array buffer with size validation
|
||||
const buffer = await this.getArrayBuffer(source);
|
||||
|
||||
// Validate buffer size
|
||||
if (buffer.byteLength > this.MAX_BUFFER_SIZE) {
|
||||
console.error('Buffer size exceeds maximum allowed size');
|
||||
return null;
|
||||
}
|
||||
|
||||
// Parse EXIF data
|
||||
const exifData = this.parseExifData(buffer);
|
||||
|
||||
// Cache if URL with LRU eviction
|
||||
if (typeof source === 'string' && exifData) {
|
||||
this.addToCache(source, exifData);
|
||||
}
|
||||
|
||||
return exifData;
|
||||
} catch (error) {
|
||||
console.error('Failed to extract EXIF data:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array buffer from various sources
|
||||
*/
|
||||
private async getArrayBuffer(source: string | File | Blob): Promise<ArrayBuffer> {
|
||||
if (source instanceof File || source instanceof Blob) {
|
||||
return source.arrayBuffer();
|
||||
} else {
|
||||
const response = await fetch(source);
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse EXIF data from array buffer
|
||||
*/
|
||||
private parseExifData(buffer: ArrayBuffer): ExifData | null {
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// Check for JPEG SOI marker
|
||||
if (dataView.getUint16(0) !== 0xFFD8) {
|
||||
return null; // Not a JPEG
|
||||
}
|
||||
|
||||
// Find APP1 marker (EXIF)
|
||||
let offset = 2;
|
||||
let marker;
|
||||
|
||||
while (offset < dataView.byteLength) {
|
||||
marker = dataView.getUint16(offset);
|
||||
|
||||
if (marker === 0xFFE1) {
|
||||
// Found EXIF marker
|
||||
return this.parseExifSegment(dataView, offset + 2);
|
||||
}
|
||||
|
||||
if ((marker & 0xFF00) !== 0xFF00) {
|
||||
break; // Invalid marker
|
||||
}
|
||||
|
||||
offset += 2 + dataView.getUint16(offset + 2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse EXIF segment with bounds checking
|
||||
*/
|
||||
private parseExifSegment(dataView: DataView, offset: number): ExifData | null {
|
||||
// Bounds check
|
||||
if (offset + 2 > dataView.byteLength) {
|
||||
console.error('Invalid offset for EXIF segment');
|
||||
return null;
|
||||
}
|
||||
|
||||
const length = dataView.getUint16(offset);
|
||||
|
||||
// Validate segment length
|
||||
if (offset + length > dataView.byteLength) {
|
||||
console.error('EXIF segment length exceeds buffer size');
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check for "Exif\0\0" identifier with bounds check
|
||||
if (offset + 6 > dataView.byteLength) {
|
||||
console.error('Invalid EXIF header offset');
|
||||
return null;
|
||||
}
|
||||
|
||||
const exifHeader = String.fromCharCode(
|
||||
dataView.getUint8(offset + 2),
|
||||
dataView.getUint8(offset + 3),
|
||||
dataView.getUint8(offset + 4),
|
||||
dataView.getUint8(offset + 5)
|
||||
);
|
||||
|
||||
if (exifHeader !== 'Exif') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TIFF header offset
|
||||
const tiffOffset = offset + 8;
|
||||
|
||||
// Check byte order
|
||||
const byteOrder = dataView.getUint16(tiffOffset);
|
||||
const littleEndian = byteOrder === 0x4949; // 'II' for Intel
|
||||
|
||||
if (byteOrder !== 0x4949 && byteOrder !== 0x4D4D) {
|
||||
return null; // Invalid byte order
|
||||
}
|
||||
|
||||
// Parse IFD
|
||||
const ifdOffset = this.getUint32(dataView, tiffOffset + 4, littleEndian);
|
||||
const exifData = this.parseIFD(dataView, tiffOffset, tiffOffset + ifdOffset, littleEndian);
|
||||
|
||||
// Parse GPS data if available
|
||||
if (exifData.raw?.gpsIFDPointer) {
|
||||
const gpsData = this.parseGPSIFD(
|
||||
dataView,
|
||||
tiffOffset,
|
||||
tiffOffset + exifData.raw.gpsIFDPointer,
|
||||
littleEndian
|
||||
);
|
||||
Object.assign(exifData, gpsData);
|
||||
}
|
||||
|
||||
return this.formatExifData(exifData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse IFD (Image File Directory) with bounds checking
|
||||
*/
|
||||
private parseIFD(
|
||||
dataView: DataView,
|
||||
tiffOffset: number,
|
||||
ifdOffset: number,
|
||||
littleEndian: boolean
|
||||
): ExifData {
|
||||
// Bounds check for IFD offset
|
||||
if (ifdOffset + 2 > dataView.byteLength) {
|
||||
console.error('Invalid IFD offset');
|
||||
return { raw: {} };
|
||||
}
|
||||
|
||||
const numEntries = this.getUint16(dataView, ifdOffset, littleEndian);
|
||||
|
||||
// Validate number of entries
|
||||
if (numEntries > 1000) { // Reasonable limit
|
||||
console.error('Too many IFD entries');
|
||||
return { raw: {} };
|
||||
}
|
||||
|
||||
const data: ExifData = { raw: {} };
|
||||
|
||||
for (let i = 0; i < numEntries; i++) {
|
||||
const entryOffset = ifdOffset + 2 + (i * 12);
|
||||
|
||||
// Bounds check for entry
|
||||
if (entryOffset + 12 > dataView.byteLength) {
|
||||
console.warn('IFD entry exceeds buffer bounds');
|
||||
break;
|
||||
}
|
||||
|
||||
const tag = this.getUint16(dataView, entryOffset, littleEndian);
|
||||
const type = this.getUint16(dataView, entryOffset + 2, littleEndian);
|
||||
const count = this.getUint32(dataView, entryOffset + 4, littleEndian);
|
||||
const valueOffset = entryOffset + 8;
|
||||
|
||||
const value = this.getTagValue(
|
||||
dataView,
|
||||
tiffOffset,
|
||||
type,
|
||||
count,
|
||||
valueOffset,
|
||||
littleEndian
|
||||
);
|
||||
|
||||
const tagName = EXIF_TAGS[tag];
|
||||
if (tagName) {
|
||||
(data as any)[tagName] = value;
|
||||
}
|
||||
|
||||
// Store raw value
|
||||
data.raw![tag] = value;
|
||||
|
||||
// Check for EXIF IFD pointer
|
||||
if (tag === 0x8769) {
|
||||
const exifIFDOffset = tiffOffset + value;
|
||||
const exifData = this.parseIFD(dataView, tiffOffset, exifIFDOffset, littleEndian);
|
||||
Object.assign(data, exifData);
|
||||
}
|
||||
|
||||
// Store GPS IFD pointer
|
||||
if (tag === 0x8825) {
|
||||
data.raw!.gpsIFDPointer = value;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse GPS IFD
|
||||
*/
|
||||
private parseGPSIFD(
|
||||
dataView: DataView,
|
||||
tiffOffset: number,
|
||||
ifdOffset: number,
|
||||
littleEndian: boolean
|
||||
): Partial<ExifData> {
|
||||
const numEntries = this.getUint16(dataView, ifdOffset, littleEndian);
|
||||
const gpsData: any = {};
|
||||
|
||||
for (let i = 0; i < numEntries; i++) {
|
||||
const entryOffset = ifdOffset + 2 + (i * 12);
|
||||
|
||||
// Bounds check for entry
|
||||
if (entryOffset + 12 > dataView.byteLength) {
|
||||
console.warn('IFD entry exceeds buffer bounds');
|
||||
break;
|
||||
}
|
||||
|
||||
const tag = this.getUint16(dataView, entryOffset, littleEndian);
|
||||
const type = this.getUint16(dataView, entryOffset + 2, littleEndian);
|
||||
const count = this.getUint32(dataView, entryOffset + 4, littleEndian);
|
||||
const valueOffset = entryOffset + 8;
|
||||
|
||||
const value = this.getTagValue(
|
||||
dataView,
|
||||
tiffOffset,
|
||||
type,
|
||||
count,
|
||||
valueOffset,
|
||||
littleEndian
|
||||
);
|
||||
|
||||
const tagName = GPS_TAGS[tag];
|
||||
if (tagName) {
|
||||
gpsData[tagName] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert GPS coordinates
|
||||
const result: Partial<ExifData> = {};
|
||||
|
||||
if (gpsData.gpsLatitude && gpsData.gpsLatitudeRef) {
|
||||
result.gpsLatitude = this.convertGPSCoordinate(
|
||||
gpsData.gpsLatitude,
|
||||
gpsData.gpsLatitudeRef
|
||||
);
|
||||
}
|
||||
|
||||
if (gpsData.gpsLongitude && gpsData.gpsLongitudeRef) {
|
||||
result.gpsLongitude = this.convertGPSCoordinate(
|
||||
gpsData.gpsLongitude,
|
||||
gpsData.gpsLongitudeRef
|
||||
);
|
||||
}
|
||||
|
||||
if (gpsData.gpsAltitude) {
|
||||
result.gpsAltitude = gpsData.gpsAltitude;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tag value based on type
|
||||
*/
|
||||
private getTagValue(
|
||||
dataView: DataView,
|
||||
tiffOffset: number,
|
||||
type: number,
|
||||
count: number,
|
||||
offset: number,
|
||||
littleEndian: boolean
|
||||
): any {
|
||||
switch (type) {
|
||||
case 1: // BYTE
|
||||
case 7: // UNDEFINED
|
||||
if (count === 1) {
|
||||
return dataView.getUint8(offset);
|
||||
}
|
||||
const bytes = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
bytes.push(dataView.getUint8(offset + i));
|
||||
}
|
||||
return bytes;
|
||||
|
||||
case 2: // ASCII
|
||||
const stringOffset = count > 4
|
||||
? tiffOffset + this.getUint32(dataView, offset, littleEndian)
|
||||
: offset;
|
||||
let str = '';
|
||||
for (let i = 0; i < count - 1; i++) {
|
||||
const char = dataView.getUint8(stringOffset + i);
|
||||
if (char === 0) break;
|
||||
str += String.fromCharCode(char);
|
||||
}
|
||||
return str;
|
||||
|
||||
case 3: // SHORT
|
||||
if (count === 1) {
|
||||
return this.getUint16(dataView, offset, littleEndian);
|
||||
}
|
||||
const shorts = [];
|
||||
const shortOffset = count > 2
|
||||
? tiffOffset + this.getUint32(dataView, offset, littleEndian)
|
||||
: offset;
|
||||
for (let i = 0; i < count; i++) {
|
||||
shorts.push(this.getUint16(dataView, shortOffset + i * 2, littleEndian));
|
||||
}
|
||||
return shorts;
|
||||
|
||||
case 4: // LONG
|
||||
if (count === 1) {
|
||||
return this.getUint32(dataView, offset, littleEndian);
|
||||
}
|
||||
const longs = [];
|
||||
const longOffset = tiffOffset + this.getUint32(dataView, offset, littleEndian);
|
||||
for (let i = 0; i < count; i++) {
|
||||
longs.push(this.getUint32(dataView, longOffset + i * 4, littleEndian));
|
||||
}
|
||||
return longs;
|
||||
|
||||
case 5: // RATIONAL
|
||||
const ratOffset = tiffOffset + this.getUint32(dataView, offset, littleEndian);
|
||||
if (count === 1) {
|
||||
const num = this.getUint32(dataView, ratOffset, littleEndian);
|
||||
const den = this.getUint32(dataView, ratOffset + 4, littleEndian);
|
||||
return den === 0 ? 0 : num / den;
|
||||
}
|
||||
const rationals = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const num = this.getUint32(dataView, ratOffset + i * 8, littleEndian);
|
||||
const den = this.getUint32(dataView, ratOffset + i * 8 + 4, littleEndian);
|
||||
rationals.push(den === 0 ? 0 : num / den);
|
||||
}
|
||||
return rationals;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert GPS coordinate to decimal degrees
|
||||
*/
|
||||
private convertGPSCoordinate(coord: number[], ref: string): number {
|
||||
if (!coord || coord.length !== 3) return 0;
|
||||
|
||||
const degrees = coord[0];
|
||||
const minutes = coord[1];
|
||||
const seconds = coord[2];
|
||||
|
||||
let decimal = degrees + minutes / 60 + seconds / 3600;
|
||||
|
||||
if (ref === 'S' || ref === 'W') {
|
||||
decimal = -decimal;
|
||||
}
|
||||
|
||||
return decimal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format EXIF data for display
|
||||
*/
|
||||
private formatExifData(data: ExifData): ExifData {
|
||||
const formatted: ExifData = { ...data };
|
||||
|
||||
// Format dates
|
||||
if (formatted.dateTime) {
|
||||
formatted.dateTime = this.parseExifDate(formatted.dateTime as any);
|
||||
}
|
||||
if (formatted.dateTimeOriginal) {
|
||||
formatted.dateTimeOriginal = this.parseExifDate(formatted.dateTimeOriginal as any);
|
||||
}
|
||||
if (formatted.dateTimeDigitized) {
|
||||
formatted.dateTimeDigitized = this.parseExifDate(formatted.dateTimeDigitized as any);
|
||||
}
|
||||
|
||||
// Format exposure time
|
||||
if (formatted.exposureTime) {
|
||||
const time = formatted.exposureTime as any;
|
||||
if (typeof time === 'number') {
|
||||
if (time < 1) {
|
||||
formatted.exposureTime = `1/${Math.round(1 / time)}`;
|
||||
} else {
|
||||
formatted.exposureTime = `${time}s`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Format exposure program
|
||||
if (formatted.exposureProgram) {
|
||||
const programs = [
|
||||
'Not defined',
|
||||
'Manual',
|
||||
'Normal program',
|
||||
'Aperture priority',
|
||||
'Shutter priority',
|
||||
'Creative program',
|
||||
'Action program',
|
||||
'Portrait mode',
|
||||
'Landscape mode'
|
||||
];
|
||||
const index = formatted.exposureProgram as any;
|
||||
formatted.exposureProgram = programs[index] || 'Unknown';
|
||||
}
|
||||
|
||||
// Format metering mode
|
||||
if (formatted.meteringMode) {
|
||||
const modes = [
|
||||
'Unknown',
|
||||
'Average',
|
||||
'Center-weighted average',
|
||||
'Spot',
|
||||
'Multi-spot',
|
||||
'Pattern',
|
||||
'Partial'
|
||||
];
|
||||
const index = formatted.meteringMode as any;
|
||||
formatted.meteringMode = modes[index] || 'Unknown';
|
||||
}
|
||||
|
||||
// Format flash
|
||||
if (formatted.flash !== undefined) {
|
||||
const flash = formatted.flash as any;
|
||||
formatted.flash = (flash & 1) ? 'Flash fired' : 'Flash did not fire';
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse EXIF date string
|
||||
*/
|
||||
private parseExifDate(dateStr: string): Date {
|
||||
// EXIF date format: "YYYY:MM:DD HH:MM:SS"
|
||||
const parts = dateStr.split(' ');
|
||||
if (parts.length !== 2) return new Date(dateStr);
|
||||
|
||||
const dateParts = parts[0].split(':');
|
||||
const timeParts = parts[1].split(':');
|
||||
|
||||
if (dateParts.length !== 3 || timeParts.length !== 3) {
|
||||
return new Date(dateStr);
|
||||
}
|
||||
|
||||
return new Date(
|
||||
parseInt(dateParts[0]),
|
||||
parseInt(dateParts[1]) - 1,
|
||||
parseInt(dateParts[2]),
|
||||
parseInt(timeParts[0]),
|
||||
parseInt(timeParts[1]),
|
||||
parseInt(timeParts[2])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uint16 with endianness and bounds checking
|
||||
*/
|
||||
private getUint16(dataView: DataView, offset: number, littleEndian: boolean): number {
|
||||
if (offset + 2 > dataView.byteLength) {
|
||||
console.error('Uint16 read exceeds buffer bounds');
|
||||
return 0;
|
||||
}
|
||||
return dataView.getUint16(offset, littleEndian);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uint32 with endianness and bounds checking
|
||||
*/
|
||||
private getUint32(dataView: DataView, offset: number, littleEndian: boolean): number {
|
||||
if (offset + 4 > dataView.byteLength) {
|
||||
console.error('Uint32 read exceeds buffer bounds');
|
||||
return 0;
|
||||
}
|
||||
return dataView.getUint32(offset, littleEndian);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create EXIF display panel
|
||||
*/
|
||||
createExifPanel(exifData: ExifData): HTMLElement {
|
||||
const panel = document.createElement('div');
|
||||
panel.className = 'exif-panel';
|
||||
panel.style.cssText = `
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
color: white;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
max-width: 400px;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
font-size: 12px;
|
||||
`;
|
||||
|
||||
const sections = [
|
||||
{
|
||||
title: 'Camera',
|
||||
fields: ['make', 'model', 'lensModel']
|
||||
},
|
||||
{
|
||||
title: 'Settings',
|
||||
fields: ['exposureTime', 'fNumber', 'iso', 'focalLength', 'exposureProgram', 'meteringMode', 'flash']
|
||||
},
|
||||
{
|
||||
title: 'Image',
|
||||
fields: ['imageWidth', 'imageHeight', 'orientation', 'colorSpace', 'whiteBalance']
|
||||
},
|
||||
{
|
||||
title: 'Date/Time',
|
||||
fields: ['dateTimeOriginal', 'dateTime']
|
||||
},
|
||||
{
|
||||
title: 'Location',
|
||||
fields: ['gpsLatitude', 'gpsLongitude', 'gpsAltitude']
|
||||
},
|
||||
{
|
||||
title: 'Other',
|
||||
fields: ['software', 'artist', 'copyright', 'imageDescription']
|
||||
}
|
||||
];
|
||||
|
||||
sections.forEach(section => {
|
||||
const hasData = section.fields.some(field => (exifData as any)[field]);
|
||||
if (!hasData) return;
|
||||
|
||||
const sectionDiv = document.createElement('div');
|
||||
sectionDiv.style.marginBottom = '15px';
|
||||
|
||||
const title = document.createElement('h4');
|
||||
// Use textContent for safe title insertion
|
||||
title.textContent = section.title;
|
||||
title.style.cssText = 'margin: 0 0 8px 0; color: #4CAF50;';
|
||||
title.setAttribute('aria-label', `Section: ${section.title}`);
|
||||
sectionDiv.appendChild(title);
|
||||
|
||||
section.fields.forEach(field => {
|
||||
const value = (exifData as any)[field];
|
||||
if (!value) return;
|
||||
|
||||
const row = document.createElement('div');
|
||||
row.style.cssText = 'display: flex; justify-content: space-between; margin: 4px 0;';
|
||||
|
||||
const label = document.createElement('span');
|
||||
// Use textContent for safe text insertion
|
||||
label.textContent = this.formatFieldName(field) + ':';
|
||||
label.style.color = '#aaa';
|
||||
|
||||
const val = document.createElement('span');
|
||||
// Use textContent for safe value insertion
|
||||
val.textContent = this.formatFieldValue(field, value);
|
||||
val.style.textAlign = 'right';
|
||||
|
||||
row.appendChild(label);
|
||||
row.appendChild(val);
|
||||
sectionDiv.appendChild(row);
|
||||
});
|
||||
|
||||
panel.appendChild(sectionDiv);
|
||||
});
|
||||
|
||||
// Add GPS map link if coordinates available
|
||||
if (exifData.gpsLatitude && exifData.gpsLongitude) {
|
||||
const mapLink = document.createElement('a');
|
||||
mapLink.href = `https://www.google.com/maps?q=${exifData.gpsLatitude},${exifData.gpsLongitude}`;
|
||||
mapLink.target = '_blank';
|
||||
mapLink.textContent = 'View on Map';
|
||||
mapLink.style.cssText = `
|
||||
display: inline-block;
|
||||
margin-top: 10px;
|
||||
padding: 8px 12px;
|
||||
background: #4CAF50;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
`;
|
||||
panel.appendChild(mapLink);
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format field name for display
|
||||
*/
|
||||
private formatFieldName(field: string): string {
|
||||
const names: Record<string, string> = {
|
||||
make: 'Camera Make',
|
||||
model: 'Camera Model',
|
||||
lensModel: 'Lens',
|
||||
exposureTime: 'Shutter Speed',
|
||||
fNumber: 'Aperture',
|
||||
iso: 'ISO',
|
||||
focalLength: 'Focal Length',
|
||||
exposureProgram: 'Mode',
|
||||
meteringMode: 'Metering',
|
||||
flash: 'Flash',
|
||||
imageWidth: 'Width',
|
||||
imageHeight: 'Height',
|
||||
orientation: 'Orientation',
|
||||
colorSpace: 'Color Space',
|
||||
whiteBalance: 'White Balance',
|
||||
dateTimeOriginal: 'Date Taken',
|
||||
dateTime: 'Date Modified',
|
||||
gpsLatitude: 'Latitude',
|
||||
gpsLongitude: 'Longitude',
|
||||
gpsAltitude: 'Altitude',
|
||||
software: 'Software',
|
||||
artist: 'Artist',
|
||||
copyright: 'Copyright',
|
||||
imageDescription: 'Description'
|
||||
};
|
||||
return names[field] || field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format field value for display
|
||||
*/
|
||||
private formatFieldValue(field: string, value: any): string {
|
||||
if (value instanceof Date) {
|
||||
return value.toLocaleString();
|
||||
}
|
||||
|
||||
switch (field) {
|
||||
case 'fNumber':
|
||||
return `f/${value}`;
|
||||
case 'focalLength':
|
||||
return `${value}mm`;
|
||||
case 'gpsLatitude':
|
||||
case 'gpsLongitude':
|
||||
return value.toFixed(6) + '°';
|
||||
case 'gpsAltitude':
|
||||
return `${value.toFixed(1)}m`;
|
||||
case 'imageWidth':
|
||||
case 'imageHeight':
|
||||
return `${value}px`;
|
||||
default:
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to cache with LRU eviction
|
||||
*/
|
||||
private addToCache(key: string, data: ExifData): void {
|
||||
// Remove from order if exists
|
||||
const existingIndex = this.cacheOrder.indexOf(key);
|
||||
if (existingIndex !== -1) {
|
||||
this.cacheOrder.splice(existingIndex, 1);
|
||||
}
|
||||
|
||||
// Add to end
|
||||
this.cacheOrder.push(key);
|
||||
this.exifCache.set(key, data);
|
||||
|
||||
// Evict oldest if over limit
|
||||
while (this.cacheOrder.length > this.MAX_CACHE_SIZE) {
|
||||
const oldestKey = this.cacheOrder.shift();
|
||||
if (oldestKey) {
|
||||
this.exifCache.delete(oldestKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cache order for LRU
|
||||
*/
|
||||
private updateCacheOrder(key: string): void {
|
||||
const index = this.cacheOrder.indexOf(key);
|
||||
if (index !== -1) {
|
||||
this.cacheOrder.splice(index, 1);
|
||||
this.cacheOrder.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear EXIF cache
|
||||
*/
|
||||
clearCache(): void {
|
||||
this.exifCache.clear();
|
||||
this.cacheOrder = [];
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageExifService.getInstance();
|
||||
681
apps/client/src/services/image_sharing.ts
Normal file
681
apps/client/src/services/image_sharing.ts
Normal file
@@ -0,0 +1,681 @@
|
||||
/**
|
||||
* Image Sharing and Export Module for Trilium Notes
|
||||
* Provides functionality for sharing, downloading, and exporting images
|
||||
*/
|
||||
|
||||
import server from './server.js';
|
||||
import utils from './utils.js';
|
||||
import toastService from './toast.js';
|
||||
import type FNote from '../entities/fnote.js';
|
||||
import { ImageValidator, withErrorBoundary, MemoryMonitor, ImageError, ImageErrorType } from './image_error_handler.js';
|
||||
|
||||
/**
|
||||
* Export format options
|
||||
*/
|
||||
export type ExportFormat = 'original' | 'jpeg' | 'png' | 'webp';
|
||||
|
||||
/**
|
||||
* Export size presets
|
||||
*/
|
||||
export type SizePreset = 'original' | 'thumbnail' | 'small' | 'medium' | 'large' | 'custom';
|
||||
|
||||
/**
|
||||
* Export configuration
|
||||
*/
|
||||
export interface ExportConfig {
|
||||
format: ExportFormat;
|
||||
quality: number; // 0-100 for JPEG/WebP
|
||||
size: SizePreset;
|
||||
customWidth?: number;
|
||||
customHeight?: number;
|
||||
maintainAspectRatio: boolean;
|
||||
addWatermark: boolean;
|
||||
watermarkText?: string;
|
||||
watermarkPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
|
||||
watermarkOpacity?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share options
|
||||
*/
|
||||
export interface ShareOptions {
|
||||
method: 'link' | 'email' | 'social';
|
||||
expiresIn?: number; // Hours
|
||||
password?: string;
|
||||
allowDownload: boolean;
|
||||
trackViews: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share link data
|
||||
*/
|
||||
export interface ShareLink {
|
||||
url: string;
|
||||
shortUrl?: string;
|
||||
expiresAt?: Date;
|
||||
password?: string;
|
||||
views: number;
|
||||
maxViews?: number;
|
||||
created: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Size presets in pixels
|
||||
*/
|
||||
const SIZE_PRESETS = {
|
||||
thumbnail: { width: 150, height: 150 },
|
||||
small: { width: 400, height: 400 },
|
||||
medium: { width: 800, height: 800 },
|
||||
large: { width: 1600, height: 1600 }
|
||||
};
|
||||
|
||||
/**
|
||||
* ImageSharingService handles image sharing, downloading, and exporting
|
||||
*/
|
||||
class ImageSharingService {
|
||||
private static instance: ImageSharingService;
|
||||
private activeShares: Map<string, ShareLink> = new Map();
|
||||
private downloadCanvas?: HTMLCanvasElement;
|
||||
private downloadContext?: CanvasRenderingContext2D;
|
||||
|
||||
// Canvas size limits for security and memory management
|
||||
private readonly MAX_CANVAS_SIZE = 8192; // Maximum width/height
|
||||
private readonly MAX_CANVAS_AREA = 50000000; // 50 megapixels
|
||||
|
||||
private defaultExportConfig: ExportConfig = {
|
||||
format: 'original',
|
||||
quality: 90,
|
||||
size: 'original',
|
||||
maintainAspectRatio: true,
|
||||
addWatermark: false,
|
||||
watermarkPosition: 'bottom-right',
|
||||
watermarkOpacity: 0.5
|
||||
};
|
||||
|
||||
private constructor() {
|
||||
// Initialize download canvas
|
||||
this.downloadCanvas = document.createElement('canvas');
|
||||
this.downloadContext = this.downloadCanvas.getContext('2d') || undefined;
|
||||
}
|
||||
|
||||
static getInstance(): ImageSharingService {
|
||||
if (!ImageSharingService.instance) {
|
||||
ImageSharingService.instance = new ImageSharingService();
|
||||
}
|
||||
return ImageSharingService.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download image with options
|
||||
*/
|
||||
async downloadImage(
|
||||
src: string,
|
||||
filename: string,
|
||||
config?: Partial<ExportConfig>
|
||||
): Promise<void> {
|
||||
await withErrorBoundary(async () => {
|
||||
// Validate inputs
|
||||
ImageValidator.validateUrl(src);
|
||||
const sanitizedFilename = ImageValidator.sanitizeFilename(filename);
|
||||
const finalConfig = { ...this.defaultExportConfig, ...config };
|
||||
|
||||
// Load image
|
||||
const img = await this.loadImage(src);
|
||||
|
||||
// Process image based on config
|
||||
const processedBlob = await this.processImage(img, finalConfig);
|
||||
|
||||
// Create download link
|
||||
const url = URL.createObjectURL(processedBlob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
|
||||
// Determine filename with extension
|
||||
const extension = finalConfig.format === 'original'
|
||||
? this.getOriginalExtension(sanitizedFilename)
|
||||
: finalConfig.format;
|
||||
const finalFilename = this.ensureExtension(sanitizedFilename, extension);
|
||||
|
||||
link.download = finalFilename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
// Cleanup
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
toastService.showMessage(`Downloaded ${finalFilename}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Process image according to export configuration
|
||||
*/
|
||||
private async processImage(img: HTMLImageElement, config: ExportConfig): Promise<Blob> {
|
||||
if (!this.downloadCanvas || !this.downloadContext) {
|
||||
throw new Error('Canvas not initialized');
|
||||
}
|
||||
|
||||
// Calculate dimensions
|
||||
const { width, height } = this.calculateDimensions(
|
||||
img.naturalWidth,
|
||||
img.naturalHeight,
|
||||
config
|
||||
);
|
||||
|
||||
// Validate canvas dimensions
|
||||
ImageValidator.validateDimensions(width, height);
|
||||
|
||||
// Check memory availability
|
||||
const estimatedMemory = MemoryMonitor.estimateImageMemory(width, height);
|
||||
if (!MemoryMonitor.checkMemoryAvailable(estimatedMemory)) {
|
||||
throw new ImageError(
|
||||
ImageErrorType.MEMORY_ERROR,
|
||||
'Insufficient memory to process image',
|
||||
{ width, height, estimatedMemory }
|
||||
);
|
||||
}
|
||||
|
||||
// Set canvas size
|
||||
this.downloadCanvas.width = width;
|
||||
this.downloadCanvas.height = height;
|
||||
|
||||
// Clear canvas
|
||||
this.downloadContext.fillStyle = 'white';
|
||||
this.downloadContext.fillRect(0, 0, width, height);
|
||||
|
||||
// Draw image
|
||||
this.downloadContext.drawImage(img, 0, 0, width, height);
|
||||
|
||||
// Add watermark if enabled
|
||||
if (config.addWatermark && config.watermarkText) {
|
||||
this.addWatermark(this.downloadContext, width, height, config);
|
||||
}
|
||||
|
||||
// Convert to blob
|
||||
return new Promise((resolve, reject) => {
|
||||
const mimeType = this.getMimeType(config.format);
|
||||
const quality = config.quality / 100;
|
||||
|
||||
this.downloadCanvas!.toBlob(
|
||||
(blob) => {
|
||||
if (blob) {
|
||||
resolve(blob);
|
||||
} else {
|
||||
reject(new Error('Failed to create blob'));
|
||||
}
|
||||
},
|
||||
mimeType,
|
||||
quality
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate dimensions based on size preset
|
||||
*/
|
||||
private calculateDimensions(
|
||||
originalWidth: number,
|
||||
originalHeight: number,
|
||||
config: ExportConfig
|
||||
): { width: number; height: number } {
|
||||
if (config.size === 'original') {
|
||||
return { width: originalWidth, height: originalHeight };
|
||||
}
|
||||
|
||||
if (config.size === 'custom' && config.customWidth && config.customHeight) {
|
||||
if (config.maintainAspectRatio) {
|
||||
const aspectRatio = originalWidth / originalHeight;
|
||||
const targetRatio = config.customWidth / config.customHeight;
|
||||
|
||||
if (aspectRatio > targetRatio) {
|
||||
return {
|
||||
width: config.customWidth,
|
||||
height: Math.round(config.customWidth / aspectRatio)
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
width: Math.round(config.customHeight * aspectRatio),
|
||||
height: config.customHeight
|
||||
};
|
||||
}
|
||||
}
|
||||
return { width: config.customWidth, height: config.customHeight };
|
||||
}
|
||||
|
||||
// Use preset
|
||||
const preset = SIZE_PRESETS[config.size as keyof typeof SIZE_PRESETS];
|
||||
if (!preset) {
|
||||
return { width: originalWidth, height: originalHeight };
|
||||
}
|
||||
|
||||
if (config.maintainAspectRatio) {
|
||||
const aspectRatio = originalWidth / originalHeight;
|
||||
const maxWidth = preset.width;
|
||||
const maxHeight = preset.height;
|
||||
|
||||
let width = originalWidth;
|
||||
let height = originalHeight;
|
||||
|
||||
if (width > maxWidth) {
|
||||
width = maxWidth;
|
||||
height = Math.round(width / aspectRatio);
|
||||
}
|
||||
|
||||
if (height > maxHeight) {
|
||||
height = maxHeight;
|
||||
width = Math.round(height * aspectRatio);
|
||||
}
|
||||
|
||||
return { width, height };
|
||||
}
|
||||
|
||||
return preset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add watermark to canvas
|
||||
*/
|
||||
private addWatermark(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
width: number,
|
||||
height: number,
|
||||
config: ExportConfig
|
||||
): void {
|
||||
if (!config.watermarkText) return;
|
||||
|
||||
ctx.save();
|
||||
|
||||
// Set watermark style
|
||||
ctx.globalAlpha = config.watermarkOpacity || 0.5;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.strokeStyle = 'black';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.font = `${Math.min(width, height) * 0.05}px Arial`;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
// Calculate position
|
||||
let x = width / 2;
|
||||
let y = height / 2;
|
||||
|
||||
switch (config.watermarkPosition) {
|
||||
case 'top-left':
|
||||
x = width * 0.1;
|
||||
y = height * 0.1;
|
||||
ctx.textAlign = 'left';
|
||||
break;
|
||||
case 'top-right':
|
||||
x = width * 0.9;
|
||||
y = height * 0.1;
|
||||
ctx.textAlign = 'right';
|
||||
break;
|
||||
case 'bottom-left':
|
||||
x = width * 0.1;
|
||||
y = height * 0.9;
|
||||
ctx.textAlign = 'left';
|
||||
break;
|
||||
case 'bottom-right':
|
||||
x = width * 0.9;
|
||||
y = height * 0.9;
|
||||
ctx.textAlign = 'right';
|
||||
break;
|
||||
}
|
||||
|
||||
// Draw watermark with outline
|
||||
ctx.strokeText(config.watermarkText, x, y);
|
||||
ctx.fillText(config.watermarkText, x, y);
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate shareable link for image
|
||||
*/
|
||||
async generateShareLink(
|
||||
noteId: string,
|
||||
options?: Partial<ShareOptions>
|
||||
): Promise<ShareLink> {
|
||||
try {
|
||||
const finalOptions = {
|
||||
method: 'link' as const,
|
||||
allowDownload: true,
|
||||
trackViews: false,
|
||||
...options
|
||||
};
|
||||
|
||||
// Create share token on server
|
||||
const response = await server.post(`notes/${noteId}/share`, {
|
||||
type: 'image',
|
||||
expiresIn: finalOptions.expiresIn,
|
||||
password: finalOptions.password,
|
||||
allowDownload: finalOptions.allowDownload,
|
||||
trackViews: finalOptions.trackViews
|
||||
});
|
||||
|
||||
const shareLink: ShareLink = {
|
||||
url: `${window.location.origin}/share/${response.token}`,
|
||||
shortUrl: response.shortUrl,
|
||||
expiresAt: response.expiresAt ? new Date(response.expiresAt) : undefined,
|
||||
password: finalOptions.password,
|
||||
views: 0,
|
||||
maxViews: response.maxViews,
|
||||
created: new Date()
|
||||
};
|
||||
|
||||
// Store in active shares
|
||||
this.activeShares.set(response.token, shareLink);
|
||||
|
||||
return shareLink;
|
||||
} catch (error) {
|
||||
console.error('Failed to generate share link:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy image or link to clipboard
|
||||
*/
|
||||
async copyToClipboard(
|
||||
src: string,
|
||||
type: 'image' | 'link' = 'link'
|
||||
): Promise<void> {
|
||||
await withErrorBoundary(async () => {
|
||||
// Validate URL
|
||||
ImageValidator.validateUrl(src);
|
||||
if (type === 'link') {
|
||||
// Copy URL to clipboard
|
||||
await navigator.clipboard.writeText(src);
|
||||
toastService.showMessage('Link copied to clipboard');
|
||||
} else {
|
||||
// Copy image data to clipboard
|
||||
const img = await this.loadImage(src);
|
||||
|
||||
if (!this.downloadCanvas || !this.downloadContext) {
|
||||
throw new Error('Canvas not initialized');
|
||||
}
|
||||
|
||||
// Validate dimensions before setting
|
||||
ImageValidator.validateDimensions(img.naturalWidth, img.naturalHeight);
|
||||
|
||||
this.downloadCanvas.width = img.naturalWidth;
|
||||
this.downloadCanvas.height = img.naturalHeight;
|
||||
this.downloadContext.drawImage(img, 0, 0);
|
||||
|
||||
this.downloadCanvas.toBlob(async (blob) => {
|
||||
if (blob) {
|
||||
try {
|
||||
const item = new ClipboardItem({ 'image/png': blob });
|
||||
await navigator.clipboard.write([item]);
|
||||
toastService.showMessage('Image copied to clipboard');
|
||||
} catch (error) {
|
||||
console.error('Failed to copy image to clipboard:', error);
|
||||
// Fallback to copying link
|
||||
await navigator.clipboard.writeText(src);
|
||||
toastService.showMessage('Image link copied to clipboard');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Share via native share API (mobile)
|
||||
*/
|
||||
async shareNative(
|
||||
src: string,
|
||||
title: string,
|
||||
text?: string
|
||||
): Promise<void> {
|
||||
if (!navigator.share) {
|
||||
throw new Error('Native share not supported');
|
||||
}
|
||||
|
||||
try {
|
||||
// Try to share with file
|
||||
const img = await this.loadImage(src);
|
||||
const blob = await this.processImage(img, this.defaultExportConfig);
|
||||
const file = new File([blob], `${title}.${this.defaultExportConfig.format}`, {
|
||||
type: this.getMimeType(this.defaultExportConfig.format)
|
||||
});
|
||||
|
||||
await navigator.share({
|
||||
title,
|
||||
text: text || `Check out this image: ${title}`,
|
||||
files: [file]
|
||||
});
|
||||
} catch (error) {
|
||||
// Fallback to sharing URL
|
||||
try {
|
||||
await navigator.share({
|
||||
title,
|
||||
text: text || `Check out this image: ${title}`,
|
||||
url: src
|
||||
});
|
||||
} catch (shareError) {
|
||||
console.error('Failed to share:', shareError);
|
||||
throw shareError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export multiple images as ZIP
|
||||
*/
|
||||
async exportBatch(
|
||||
images: Array<{ src: string; filename: string }>,
|
||||
config?: Partial<ExportConfig>
|
||||
): Promise<void> {
|
||||
try {
|
||||
// Dynamic import of JSZip
|
||||
const JSZip = (await import('jszip')).default;
|
||||
const zip = new JSZip();
|
||||
|
||||
const finalConfig = { ...this.defaultExportConfig, ...config };
|
||||
|
||||
// Process each image
|
||||
for (const { src, filename } of images) {
|
||||
try {
|
||||
const img = await this.loadImage(src);
|
||||
const blob = await this.processImage(img, finalConfig);
|
||||
const extension = finalConfig.format === 'original'
|
||||
? this.getOriginalExtension(filename)
|
||||
: finalConfig.format;
|
||||
const finalFilename = this.ensureExtension(filename, extension);
|
||||
|
||||
zip.file(finalFilename, blob);
|
||||
} catch (error) {
|
||||
console.error(`Failed to process image ${filename}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate and download ZIP
|
||||
const zipBlob = await zip.generateAsync({ type: 'blob' });
|
||||
const url = URL.createObjectURL(zipBlob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `images_${Date.now()}.zip`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
toastService.showMessage(`Exported ${images.length} images`);
|
||||
} catch (error) {
|
||||
console.error('Failed to export images:', error);
|
||||
toastService.showError('Failed to export images');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open share dialog
|
||||
*/
|
||||
openShareDialog(
|
||||
src: string,
|
||||
title: string,
|
||||
noteId?: string
|
||||
): void {
|
||||
// Create modal dialog
|
||||
const dialog = document.createElement('div');
|
||||
dialog.className = 'share-dialog-overlay';
|
||||
dialog.style.cssText = `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 10000;
|
||||
`;
|
||||
|
||||
const content = document.createElement('div');
|
||||
content.className = 'share-dialog';
|
||||
content.style.cssText = `
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
width: 400px;
|
||||
max-width: 90%;
|
||||
`;
|
||||
|
||||
content.innerHTML = `
|
||||
<h3 style="margin: 0 0 15px 0;">Share Image</h3>
|
||||
<div class="share-options" style="display: flex; flex-direction: column; gap: 10px;">
|
||||
<button class="share-copy-link" style="padding: 10px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer;">
|
||||
<i class="bx bx-link"></i> Copy Link
|
||||
</button>
|
||||
<button class="share-copy-image" style="padding: 10px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer;">
|
||||
<i class="bx bx-copy"></i> Copy Image
|
||||
</button>
|
||||
<button class="share-download" style="padding: 10px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer;">
|
||||
<i class="bx bx-download"></i> Download
|
||||
</button>
|
||||
${navigator.share ? `
|
||||
<button class="share-native" style="padding: 10px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer;">
|
||||
<i class="bx bx-share"></i> Share...
|
||||
</button>
|
||||
` : ''}
|
||||
${noteId ? `
|
||||
<button class="share-generate-link" style="padding: 10px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer;">
|
||||
<i class="bx bx-link-external"></i> Generate Share Link
|
||||
</button>
|
||||
` : ''}
|
||||
</div>
|
||||
<button class="close-dialog" style="margin-top: 15px; padding: 8px 16px; background: #f0f0f0; border: none; border-radius: 4px; cursor: pointer;">
|
||||
Close
|
||||
</button>
|
||||
`;
|
||||
|
||||
// Add event handlers
|
||||
content.querySelector('.share-copy-link')?.addEventListener('click', () => {
|
||||
this.copyToClipboard(src, 'link');
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
content.querySelector('.share-copy-image')?.addEventListener('click', () => {
|
||||
this.copyToClipboard(src, 'image');
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
content.querySelector('.share-download')?.addEventListener('click', () => {
|
||||
this.downloadImage(src, title);
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
content.querySelector('.share-native')?.addEventListener('click', () => {
|
||||
this.shareNative(src, title);
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
content.querySelector('.share-generate-link')?.addEventListener('click', async () => {
|
||||
if (noteId) {
|
||||
const link = await this.generateShareLink(noteId);
|
||||
await this.copyToClipboard(link.url, 'link');
|
||||
dialog.remove();
|
||||
}
|
||||
});
|
||||
|
||||
content.querySelector('.close-dialog')?.addEventListener('click', () => {
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
dialog.appendChild(content);
|
||||
document.body.appendChild(dialog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image from URL
|
||||
*/
|
||||
private loadImage(src: string): Promise<HTMLImageElement> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.crossOrigin = 'anonymous';
|
||||
img.onload = () => resolve(img);
|
||||
img.onerror = () => reject(new Error(`Failed to load image: ${src}`));
|
||||
img.src = src;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MIME type for format
|
||||
*/
|
||||
private getMimeType(format: ExportFormat): string {
|
||||
switch (format) {
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'webp':
|
||||
return 'image/webp';
|
||||
default:
|
||||
return 'image/png';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get original extension from filename
|
||||
*/
|
||||
private getOriginalExtension(filename: string): string {
|
||||
const parts = filename.split('.');
|
||||
if (parts.length > 1) {
|
||||
return parts[parts.length - 1].toLowerCase();
|
||||
}
|
||||
return 'png';
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure filename has correct extension
|
||||
*/
|
||||
private ensureExtension(filename: string, extension: string): string {
|
||||
const parts = filename.split('.');
|
||||
if (parts.length > 1) {
|
||||
parts[parts.length - 1] = extension;
|
||||
return parts.join('.');
|
||||
}
|
||||
return `${filename}.${extension}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup resources
|
||||
*/
|
||||
cleanup(): void {
|
||||
this.activeShares.clear();
|
||||
|
||||
// Clean up canvas memory
|
||||
if (this.downloadCanvas && this.downloadContext) {
|
||||
this.downloadContext.clearRect(0, 0, this.downloadCanvas.width, this.downloadCanvas.height);
|
||||
this.downloadCanvas.width = 0;
|
||||
this.downloadCanvas.height = 0;
|
||||
}
|
||||
|
||||
this.downloadCanvas = undefined;
|
||||
this.downloadContext = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageSharingService.getInstance();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user