mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	Compare commits
	
		
			87 Commits
		
	
	
		
			v0.41.1-be
			...
			v0.42.1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | df11b076bc | ||
|  | 54ecd2ee75 | ||
|  | 2369bcf9fc | ||
|  | 5d8808a2ad | ||
|  | 62b993f06f | ||
|  | 8aa5608085 | ||
|  | b452d7e5c5 | ||
|  | 9b9d6d86d0 | ||
|  | 7f2755d4a0 | ||
|  | 3b268cc8eb | ||
|  | 6dfe335707 | ||
|  | c7125d2b50 | ||
|  | e8a33a5ee7 | ||
|  | deb0b24c4c | ||
|  | cafcb67a8a | ||
|  | 4c6e9480e4 | ||
|  | 109bead1c7 | ||
|  | ae1220b970 | ||
|  | b89a2df462 | ||
|  | 8b5536ee3a | ||
|  | 647790885d | ||
|  | 227c3e4dcc | ||
|  | 4eb2407c73 | ||
|  | 43e12fbea2 | ||
|  | 2a3091f788 | ||
|  | 742df25bc2 | ||
|  | 9be1d1f697 | ||
|  | ed52f93bbb | ||
|  | 3466a19397 | ||
|  | fe53e2351c | ||
|  | 5c35b870eb | ||
|  | 90d091aedb | ||
|  | 0a05a40186 | ||
|  | 7482ed063b | ||
|  | 70e343f2fc | ||
|  | 358f3a7291 | ||
|  | 6161b1c193 | ||
|  | 94b57dadd7 | ||
|  | 81fbefb9cd | ||
|  | 6d6695e3a9 | ||
|  | 4c308ad68f | ||
|  | 989a003d2f | ||
|  | ccdb41841e | ||
|  | 0a94622413 | ||
|  | 5769587305 | ||
|  | ffbfccb701 | ||
|  | 56ce23fc36 | ||
|  | cba7e5a59f | ||
|  | 86cf8f3202 | ||
|  | 907cdd8fcb | ||
|  | 7ea53d468e | ||
|  | 586d6b4557 | ||
|  | 8f68ff1932 | ||
|  | a1ea2c9115 | ||
|  | e8ce81a133 | ||
|  | aff12950f0 | ||
|  | 75c58cbf79 | ||
|  | 87a1e98fa2 | ||
|  | d1eacbb574 | ||
|  | 71d248cd87 | ||
|  | ac608b9334 | ||
|  | 32020d78b5 | ||
|  | ff853c7d0a | ||
|  | 8526cb2315 | ||
|  | dc89f72e75 | ||
|  | 657ff16267 | ||
|  | ed759f5585 | ||
|  | a86177bb59 | ||
|  | 9f1b3cc892 | ||
|  | 8473f72ec8 | ||
|  | 666d202a3a | ||
|  | 988fae50cb | ||
|  | 98bbd17920 | ||
|  | dadcc93ae3 | ||
|  | 48e19d0149 | ||
|  | f97c9e3619 | ||
|  | 61167f6646 | ||
|  | 29cec8112e | ||
|  | 48aadc8309 | ||
|  | b2508db9af | ||
|  | 87510fd72b | ||
|  | 339f212e4c | ||
|  | 3c311cd2a4 | ||
|  | b5bf581bd9 | ||
|  | 242f139be4 | ||
|  | 6c76d862d2 | ||
|  | 62bc05134e | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| .DS_Store | ||||
| node_modules/ | ||||
| dist/ | ||||
| src/public/app-dist/ | ||||
| npm-debug.log | ||||
| yarn-error.log | ||||
| *.db | ||||
|   | ||||
							
								
								
									
										2
									
								
								.idea/dataSources.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/dataSources.xml
									
									
									
										generated
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| <?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="a2c75661-f9e2-478f-a69f-6a9409e69997"> | ||||
|     <data-source source="LOCAL" name="SQLite - document.db" uuid="d0fd879f-1e1d-4d5c-9c21-0e5cf9ab2976"> | ||||
|       <driver-ref>sqlite.xerial</driver-ref> | ||||
|       <synchronize>true</synchronize> | ||||
|       <jdbc-driver>org.sqlite.JDBC</jdbc-driver> | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <dataSource name="document.db"> | ||||
|   <database-model serializer="dbm" dbms="SQLITE" family-id="SQLITE" format-version="4.17"> | ||||
|   <database-model serializer="dbm" dbms="SQLITE" family-id="SQLITE" format-version="4.18"> | ||||
|     <root id="1"> | ||||
|       <ServerVersion>3.25.1</ServerVersion> | ||||
|       <ServerVersion>3.16.1</ServerVersion> | ||||
|     </root> | ||||
|     <schema id="2" parent="1" name="main"> | ||||
|       <Current>1</Current> | ||||
| @@ -57,6 +57,7 @@ | ||||
|     <index id="24" parent="6" name="sqlite_autoindex_api_tokens_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>apiTokenId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <key id="25" parent="6"> | ||||
| @@ -130,17 +131,21 @@ | ||||
|     <index id="38" parent="7" name="sqlite_autoindex_attributes_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>attributeId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <index id="39" parent="7" name="IDX_attributes_noteId_index"> | ||||
|       <ColNames>noteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="40" parent="7" name="IDX_attributes_name_value"> | ||||
|       <ColNames>name | ||||
| value</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="41" parent="7" name="IDX_attributes_value_index"> | ||||
|       <ColNames>value</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <key id="42" parent="7"> | ||||
|       <ColNames>attributeId</ColNames> | ||||
| @@ -207,14 +212,17 @@ value</ColNames> | ||||
|     <index id="54" parent="8" name="sqlite_autoindex_branches_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>branchId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <index id="55" parent="8" name="IDX_branches_noteId_parentNoteId"> | ||||
|       <ColNames>noteId | ||||
| parentNoteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="56" parent="8" name="IDX_branches_parentNoteId"> | ||||
|       <ColNames>parentNoteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <key id="57" parent="8"> | ||||
|       <ColNames>branchId</ColNames> | ||||
| @@ -245,6 +253,7 @@ parentNoteId</ColNames> | ||||
|     <index id="62" parent="9" name="sqlite_autoindex_note_contents_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>noteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <key id="63" parent="9"> | ||||
| @@ -275,6 +284,7 @@ parentNoteId</ColNames> | ||||
|     <index id="68" parent="10" name="sqlite_autoindex_note_revision_contents_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>noteRevisionId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <key id="69" parent="10"> | ||||
| @@ -359,22 +369,28 @@ parentNoteId</ColNames> | ||||
|     <index id="84" parent="11" name="sqlite_autoindex_note_revisions_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>noteRevisionId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <index id="85" parent="11" name="IDX_note_revisions_noteId"> | ||||
|       <ColNames>noteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="86" parent="11" name="IDX_note_revisions_utcDateLastEdited"> | ||||
|       <ColNames>utcDateLastEdited</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="87" parent="11" name="IDX_note_revisions_utcDateCreated"> | ||||
|       <ColNames>utcDateCreated</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="88" parent="11" name="IDX_note_revisions_dateLastEdited"> | ||||
|       <ColNames>dateLastEdited</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="89" parent="11" name="IDX_note_revisions_dateCreated"> | ||||
|       <ColNames>dateCreated</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <key id="90" parent="11"> | ||||
|       <ColNames>noteRevisionId</ColNames> | ||||
| @@ -461,28 +477,36 @@ parentNoteId</ColNames> | ||||
|     <index id="105" parent="12" name="sqlite_autoindex_notes_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>noteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <index id="106" parent="12" name="IDX_notes_title"> | ||||
|       <ColNames>title</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="107" parent="12" name="IDX_notes_type"> | ||||
|       <ColNames>type</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="108" parent="12" name="IDX_notes_isDeleted"> | ||||
|       <ColNames>isDeleted</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="109" parent="12" name="IDX_notes_dateCreated"> | ||||
|       <ColNames>dateCreated</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="110" parent="12" name="IDX_notes_dateModified"> | ||||
|       <ColNames>dateModified</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="111" parent="12" name="IDX_notes_utcDateCreated"> | ||||
|       <ColNames>utcDateCreated</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <index id="112" parent="12" name="IDX_notes_utcDateModified"> | ||||
|       <ColNames>utcDateModified</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <key id="113" parent="12"> | ||||
|       <ColNames>noteId</ColNames> | ||||
| @@ -523,6 +547,7 @@ parentNoteId</ColNames> | ||||
|     <index id="120" parent="13" name="sqlite_autoindex_options_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>name</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <key id="121" parent="13"> | ||||
| @@ -558,6 +583,7 @@ parentNoteId</ColNames> | ||||
|     <index id="127" parent="14" name="sqlite_autoindex_recent_notes_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>noteId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <key id="128" parent="14"> | ||||
| @@ -578,10 +604,12 @@ parentNoteId</ColNames> | ||||
|     <index id="131" parent="15" name="sqlite_autoindex_source_ids_1"> | ||||
|       <NameSurrogate>1</NameSurrogate> | ||||
|       <ColNames>sourceId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <index id="132" parent="15" name="IDX_source_ids_utcDateCreated"> | ||||
|       <ColNames>utcDateCreated</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <key id="133" parent="15"> | ||||
|       <ColNames>sourceId</ColNames> | ||||
| @@ -602,7 +630,7 @@ parentNoteId</ColNames> | ||||
|     </column> | ||||
|     <column id="137" parent="16" name="rootpage"> | ||||
|       <Position>4</Position> | ||||
|       <DataType>int|0s</DataType> | ||||
|       <DataType>integer|0s</DataType> | ||||
|     </column> | ||||
|     <column id="138" parent="16" name="sql"> | ||||
|       <Position>5</Position> | ||||
| @@ -649,10 +677,12 @@ parentNoteId</ColNames> | ||||
|     <index id="147" parent="18" name="IDX_sync_entityName_entityId"> | ||||
|       <ColNames>entityName | ||||
| entityId</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|       <Unique>1</Unique> | ||||
|     </index> | ||||
|     <index id="148" parent="18" name="IDX_sync_utcSyncDate"> | ||||
|       <ColNames>utcSyncDate</ColNames> | ||||
|       <ColumnCollations></ColumnCollations> | ||||
|     </index> | ||||
|     <key id="149" parent="18"> | ||||
|       <ColNames>id</ColNames> | ||||
|   | ||||
							
								
								
									
										1
									
								
								.idea/inspectionProfiles/Project_Default.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								.idea/inspectionProfiles/Project_Default.xml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| <component name="InspectionProjectProfileManager"> | ||||
|   <profile version="1.0"> | ||||
|     <option name="myName" value="Project Default" /> | ||||
|     <inspection_tool class="JSUnfilteredForInLoop" enabled="false" level="WARNING" enabled_by_default="false" /> | ||||
|     <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false"> | ||||
|       <option name="processCode" value="true" /> | ||||
|       <option name="processLiterals" value="true" /> | ||||
|   | ||||
							
								
								
									
										1
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
								
							| @@ -2,5 +2,6 @@ | ||||
| <project version="4"> | ||||
|   <component name="VcsDirectoryMappings"> | ||||
|     <mapping directory="" vcs="Git" /> | ||||
|     <mapping directory="$PROJECT_DIR$/../.." vcs="Git" /> | ||||
|   </component> | ||||
| </project> | ||||
| @@ -1,4 +1,4 @@ | ||||
| FROM node:12.16.1-alpine | ||||
| FROM node:12.16.2-alpine | ||||
|  | ||||
| # Create app directory | ||||
| WORKDIR /usr/src/app | ||||
|   | ||||
| @@ -8,7 +8,7 @@ Trilium Notes is a hierarchical note taking application with focus on building l | ||||
| ## Features | ||||
|  | ||||
| * Notes can be arranged into arbitrarily deep tree. Single note can be placed into multiple places in the tree (see [cloning](https://github.com/zadam/trilium/wiki/Cloning-notes)) | ||||
| * Rich WYSIWYG note editing including e.g. tables and images with markdown [autoformat](https://github.com/zadam/trilium/wiki/Text-editor#autoformat) | ||||
| * Rich WYSIWYG note editing including e.g. tables and images with markdown [autoformat](https://github.com/zadam/trilium/wiki/Text-notes#autoformat) | ||||
| * Support for editing [notes with source code](https://github.com/zadam/trilium/wiki/Code-notes), including syntax highlighting | ||||
| * Fast and easy [navigation between notes](https://github.com/zadam/trilium/wiki/Note-navigation), full text search and [note hoisting](https://github.com/zadam/trilium/wiki/Note-hoisting) | ||||
| * Seamless [note versioning](https://github.com/zadam/trilium/wiki/Note-revisions) | ||||
|   | ||||
| @@ -12,6 +12,8 @@ echo "Copying required linux-x64 binaries" | ||||
| rm -r $SRC_DIR/node_modules/sqlite3/lib/binding/* | ||||
| rm -r $SRC_DIR/node_modules/pngquant-bin/vendor/* | ||||
|  | ||||
| rm -r $SRC_DIR/src/public/app-dist/*.mobile.* | ||||
|  | ||||
| cp -r bin/deps/linux-x64/sqlite/* $SRC_DIR/node_modules/sqlite3/lib/binding/ | ||||
| cp bin/deps/linux-x64/image/pngquant $SRC_DIR/node_modules/pngquant-bin/vendor/ | ||||
|  | ||||
| @@ -27,6 +29,9 @@ cp images/app-icons/png/128x128.png $BUILD_DIR/icon.png | ||||
| # removing software WebGL binaries because they are pretty huge and not necessary | ||||
| rm -r $BUILD_DIR/swiftshader | ||||
|  | ||||
| cp bin/tpl/portable-trilium.sh $BUILD_DIR/ | ||||
| chmod 755 $BUILD_DIR/portable-trilium.sh | ||||
|  | ||||
| echo "Packaging linux x64 electron distribution..." | ||||
| VERSION=`jq -r ".version" package.json` | ||||
|  | ||||
|   | ||||
| @@ -19,6 +19,8 @@ cp bin/deps/mac-x64/image/cjpeg $SRC_DIR/node_modules/mozjpeg/vendor/ | ||||
| cp bin/deps/mac-x64/image/pngquant $SRC_DIR/node_modules/pngquant-bin/vendor/ | ||||
| cp bin/deps/mac-x64/image/gifsicle $SRC_DIR/node_modules/giflossy/vendor/ | ||||
|  | ||||
| rm -r $SRC_DIR/src/public/app-dist/*.mobile.* | ||||
|  | ||||
| ./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=darwin --arch=x64 --overwrite --icon=images/app-icons/mac/icon.icns | ||||
|  | ||||
| BUILD_DIR=./dist/trilium-mac-x64 | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| PKG_DIR=dist/trilium-linux-x64-server | ||||
| NODE_VERSION=12.16.1 | ||||
| NODE_VERSION=12.16.2 | ||||
|  | ||||
| if [ "$1" != "DONTCOPY" ] | ||||
| then | ||||
|   | ||||
| @@ -19,6 +19,8 @@ cp bin/deps/win-x64/image/cjpeg.exe $SRC_DIR/node_modules/mozjpeg/vendor/ | ||||
| cp bin/deps/win-x64/image/pngquant.exe $SRC_DIR/node_modules/pngquant-bin/vendor/ | ||||
| cp bin/deps/win-x64/image/gifsicle.exe $SRC_DIR/node_modules/giflossy/vendor/ | ||||
|  | ||||
| rm -r $SRC_DIR/src/public/app-dist/*.mobile.* | ||||
|  | ||||
| ./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=win32  --arch=x64 --overwrite --icon=images/app-icons/win/icon.ico | ||||
|  | ||||
| BUILD_DIR=./dist/trilium-windows-x64 | ||||
| @@ -29,6 +31,8 @@ mv "./dist/Trilium Notes-win32-x64" $BUILD_DIR | ||||
| # removing software WebGL binaries because they are pretty huge and not necessary | ||||
| rm -r $BUILD_DIR/swiftshader | ||||
|  | ||||
| cp bin/tpl/portable-trilium.bat $BUILD_DIR/ | ||||
|  | ||||
| echo "Zipping windows x64 electron distribution..." | ||||
| VERSION=`jq -r ".version" package.json` | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,8 @@ if [[ $# -eq 0 ]] ; then | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| npm run webpack | ||||
|  | ||||
| DIR=$1 | ||||
|  | ||||
| rm -rf $DIR | ||||
| @@ -22,8 +24,14 @@ cp -r README.md $DIR/ | ||||
| cp -r LICENSE $DIR/ | ||||
| cp -r config-sample.ini $DIR/ | ||||
| cp -r electron.js $DIR/ | ||||
| cp webpack-* $DIR/ | ||||
|  | ||||
| # run in subshell (so we return to original dir) | ||||
| (cd $DIR && npm install --only=prod) | ||||
|  | ||||
| find $DIR/libraries -name "*.map" -type f -delete | ||||
| find $DIR/libraries -name "*.map" -type f -delete | ||||
|  | ||||
| rm -r $DIR/src/public/app | ||||
|  | ||||
| sed -i -e 's/app\/desktop.js/app-dist\/desktop.js/g' $DIR/src/views/desktop.ejs | ||||
| sed -i -e 's/app\/mobile.js/app-dist\/mobile.js/g' $DIR/src/views/mobile.ejs | ||||
							
								
								
									
										4
									
								
								bin/tpl/portable-trilium.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								bin/tpl/portable-trilium.bat
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| SET DIR=%~dp0 | ||||
| SET TRILIUM_DATA_DIR=%DIR%\trilium-data | ||||
| cd %DIR% | ||||
| start trilium.exe | ||||
							
								
								
									
										7
									
								
								bin/tpl/portable-trilium.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								bin/tpl/portable-trilium.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| #!/usr/bin/env sh | ||||
|  | ||||
| DIR=`dirname "$0"` | ||||
| export TRILIUM_DATA_DIR="$DIR/trilium-data" | ||||
|  | ||||
| "$DIR/trilium" | ||||
|  | ||||
| @@ -879,7 +879,7 @@ | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -5483,7 +5483,7 @@ Typical use case is when new note has been created, we should wait until it is s | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -507,7 +507,7 @@ | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -6813,7 +6813,7 @@ Cache is note instance scoped. | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -79,7 +79,7 @@ export default Attribute;</code></pre> | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -81,7 +81,7 @@ export default Branch;</code></pre> | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -61,7 +61,7 @@ export default NoteComplement;</code></pre> | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -493,7 +493,7 @@ export default NoteShort;</code></pre> | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -95,6 +95,275 @@ | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|         <h3 class="subsection-title">Methods</h3> | ||||
|  | ||||
|          | ||||
|              | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <h4 class="name" id="decorateWidget"><span class="type-signature"></span>decorateWidget<span class="signature">()</span><span class="type-signature"></span></h4> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
| <div class="description"> | ||||
|     for overriding | ||||
| </div> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| <dl class="details"> | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="widgets_collapsible_widget.js.html">widgets/collapsible_widget.js</a>, <a href="widgets_collapsible_widget.js.html#line93">line 93</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
| </dl> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|          | ||||
|              | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <h4 class="name" id="doRenderBody"><span class="type-signature">(async) </span>doRenderBody<span class="signature">()</span><span class="type-signature"></span></h4> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
| <div class="description"> | ||||
|     for overriding | ||||
| </div> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| <dl class="details"> | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="widgets_collapsible_widget.js.html">widgets/collapsible_widget.js</a>, <a href="widgets_collapsible_widget.js.html#line96">line 96</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
| </dl> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|          | ||||
|              | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <h4 class="name" id="widgetCollapsedStateChangedEvent"><span class="type-signature"></span>widgetCollapsedStateChangedEvent<span class="signature">()</span><span class="type-signature"></span></h4> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
| <div class="description"> | ||||
|     This event is used to synchronize collapsed state of all the tab-cached widgets since they are all rendered | ||||
| separately but should behave uniformly for the user. | ||||
| </div> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| <dl class="details"> | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="widgets_collapsible_widget.js.html">widgets/collapsible_widget.js</a>, <a href="widgets_collapsible_widget.js.html#line86">line 86</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
| </dl> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|          | ||||
|      | ||||
|  | ||||
|      | ||||
| @@ -333,7 +602,7 @@ | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -50,7 +50,7 @@ | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
| @@ -443,7 +443,7 @@ export default FrontendScriptApi;</code></pre> | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|   | ||||
							
								
								
									
										151
									
								
								docs/frontend_api/widgets_collapsible_widget.js.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								docs/frontend_api/widgets_collapsible_widget.js.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,151 @@ | ||||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
|     <meta charset="utf-8"> | ||||
|     <title>JSDoc: Source: widgets/collapsible_widget.js</title> | ||||
|  | ||||
|     <script src="scripts/prettify/prettify.js"> </script> | ||||
|     <script src="scripts/prettify/lang-css.js"> </script> | ||||
|     <!--[if lt IE 9]> | ||||
|       <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||||
|     <![endif]--> | ||||
|     <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||||
|     <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||||
| </head> | ||||
|  | ||||
| <body> | ||||
|  | ||||
| <div id="main"> | ||||
|  | ||||
|     <h1 class="page-title">Source: widgets/collapsible_widget.js</h1> | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
|      | ||||
|     <section> | ||||
|         <article> | ||||
|             <pre class="prettyprint source linenums"><code>import TabAwareWidget from "./tab_aware_widget.js"; | ||||
| import options from "../services/options.js"; | ||||
|  | ||||
| const WIDGET_TPL = ` | ||||
| <div class="card widget"> | ||||
|     <div class="card-header"> | ||||
|         <div>            | ||||
|             <button class="btn btn-sm widget-title" data-toggle="collapse" data-target="#[to be set]"> | ||||
|                 Collapsible Group Item | ||||
|             </button> | ||||
|              | ||||
|             <a class="widget-help external no-arrow bx bx-info-circle"></a> | ||||
|         </div> | ||||
|          | ||||
|         <div class="widget-header-actions"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="[to be set]" class="collapse body-wrapper" style="transition: none; "> | ||||
|         <div class="card-body"></div> | ||||
|     </div> | ||||
| </div>`; | ||||
|  | ||||
| export default class CollapsibleWidget extends TabAwareWidget { | ||||
|     get widgetTitle() { return "Untitled widget"; } | ||||
|  | ||||
|     get headerActions() { return []; } | ||||
|  | ||||
|     get help() { return {}; } | ||||
|  | ||||
|     doRender() { | ||||
|         this.$widget = $(WIDGET_TPL); | ||||
|         this.$widget.find('[data-target]').attr('data-target', "#" + this.componentId); | ||||
|  | ||||
|         this.$bodyWrapper = this.$widget.find('.body-wrapper'); | ||||
|         this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id | ||||
|  | ||||
|         this.widgetName = this.constructor.name; | ||||
|  | ||||
|         if (!options.is(this.widgetName + 'Collapsed')) { | ||||
|             this.$bodyWrapper.collapse("show"); | ||||
|         } | ||||
|  | ||||
|         // using immediate variants of the event so that the previous collapse is not caught | ||||
|         this.$bodyWrapper.on('hide.bs.collapse', () => this.saveCollapsed(true)); | ||||
|         this.$bodyWrapper.on('show.bs.collapse', () => this.saveCollapsed(false)); | ||||
|  | ||||
|         this.$body = this.$bodyWrapper.find('.card-body'); | ||||
|  | ||||
|         this.$title = this.$widget.find('.widget-title'); | ||||
|         this.$title.text(this.widgetTitle); | ||||
|  | ||||
|         this.$help = this.$widget.find('.widget-help'); | ||||
|  | ||||
|         if (this.help.title) { | ||||
|             this.$help.attr("title", this.help.title); | ||||
|             this.$help.attr("href", this.help.url || "javascript:"); | ||||
|  | ||||
|             if (!this.help.url) { | ||||
|                 this.$help.addClass('no-link'); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             this.$help.hide(); | ||||
|         } | ||||
|  | ||||
|         this.$headerActions = this.$widget.find('.widget-header-actions'); | ||||
|         this.$headerActions.append(...this.headerActions); | ||||
|  | ||||
|         this.initialized = this.doRenderBody(); | ||||
|  | ||||
|         this.decorateWidget(); | ||||
|  | ||||
|         return this.$widget; | ||||
|     } | ||||
|  | ||||
|     saveCollapsed(collapse) { | ||||
|         options.save(this.widgetName + 'Collapsed', collapse.toString()); | ||||
|  | ||||
|         this.triggerEvent(`widgetCollapsedStateChanged`, {widgetName: this.widgetName, collapse}); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * This event is used to synchronize collapsed state of all the tab-cached widgets since they are all rendered | ||||
|      * separately but should behave uniformly for the user. | ||||
|      */ | ||||
|     widgetCollapsedStateChangedEvent({widgetName, collapse}) { | ||||
|         if (widgetName === this.widgetName) { | ||||
|             this.$bodyWrapper.toggleClass('show', !collapse); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** for overriding */ | ||||
|     decorateWidget() {} | ||||
|  | ||||
|     /** for overriding */ | ||||
|     async doRenderBody() {} | ||||
|  | ||||
|     isExpanded() { | ||||
|         return this.$bodyWrapper.hasClass("show"); | ||||
|     } | ||||
| }</code></pre> | ||||
|         </article> | ||||
|     </section> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorateWidget">decorateWidget</a></li><li><a href="global.html#doRenderBody">doRenderBody</a></li><li><a href="global.html#widgetCollapsedStateChangedEvent">widgetCollapsedStateChangedEvent</a></li></ul> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|  | ||||
| <footer> | ||||
|     Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> | ||||
| </footer> | ||||
|  | ||||
| <script> prettyPrint(); </script> | ||||
| <script src="scripts/linenumber.js"> </script> | ||||
| </body> | ||||
| </html> | ||||
| @@ -1,4 +1,4 @@ | ||||
| For bug reports, please mention **version of the application** and include **log files** from following location: | ||||
| For bug reports, **PLEASE mention version of Trilium you're using** and also include **log files** from following location: | ||||
|  | ||||
| * `/home/[user]/.local/share/trilium-data/log` for Linux | ||||
| * `C:\Users\[user]\AppData\Roaming\trilium-data\log` for Windows Vista and up | ||||
|   | ||||
							
								
								
									
										2
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -2986,7 +2986,7 @@ var uniqueId = $.fn.extend( { | ||||
| 				self = this, | ||||
| 				wasExpanded = this.isExpanded(); | ||||
|  | ||||
| 			_assert(this.isLazy(), "load() requires a lazy node"); | ||||
| 			//_assert(this.isLazy(), "load() requires a lazy node"); | ||||
| 			// _assert( forceReload || this.isUndefined(), "Pass forceReload=true to re-load a lazy node" ); | ||||
| 			if (!forceReload && !this.isUndefined()) { | ||||
| 				return _getResolvedPromise(this); | ||||
|   | ||||
							
								
								
									
										2393
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2393
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										37
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								package.json
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|   "name": "trilium", | ||||
|   "productName": "Trilium Notes", | ||||
|   "description": "Trilium Notes", | ||||
|   "version": "0.41.1-beta", | ||||
|   "version": "0.42.1", | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "main": "electron.js", | ||||
|   "bin": { | ||||
| @@ -16,27 +16,28 @@ | ||||
|     "start-server": "TRILIUM_ENV=dev node ./src/www", | ||||
|     "start-electron": "TRILIUM_ENV=dev electron .", | ||||
|     "build-backend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/entities/*.js src/services/backend_script_api.js", | ||||
|     "build-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/javascripts/entities/*.js src/public/javascripts/services/frontend_script_api.js", | ||||
|     "build-docs": "npm run build-backend-docs && npm run build-frontend-docs" | ||||
|     "build-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/collapsible_widget.js", | ||||
|     "build-docs": "npm run build-backend-docs && npm run build-frontend-docs", | ||||
|     "webpack": "npx webpack -c webpack-desktop.config.js && npx webpack -c webpack-mobile.config.js && npx webpack -c webpack-setup.config.js" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "async-mutex": "0.2.1", | ||||
|     "async-mutex": "0.2.2", | ||||
|     "axios": "0.19.2", | ||||
|     "body-parser": "1.19.0", | ||||
|     "cls-hooked": "4.2.2", | ||||
|     "commonmark": "0.29.1", | ||||
|     "cookie-parser": "1.4.5", | ||||
|     "csurf": "1.11.0", | ||||
|     "dayjs": "1.8.23", | ||||
|     "dayjs": "1.8.26", | ||||
|     "debug": "4.1.1", | ||||
|     "ejs": "3.0.2", | ||||
|     "ejs": "3.1.2", | ||||
|     "electron-debug": "3.0.1", | ||||
|     "electron-dl": "3.0.0", | ||||
|     "electron-find": "1.0.6", | ||||
|     "electron-window-state": "5.0.3", | ||||
|     "express": "4.17.1", | ||||
|     "express-session": "1.17.0", | ||||
|     "file-type": "14.1.4", | ||||
|     "express-session": "1.17.1", | ||||
|     "file-type": "14.3.0", | ||||
|     "fs-extra": "9.0.0", | ||||
|     "helmet": "3.22.0", | ||||
|     "html": "1.0.0", | ||||
| @@ -50,10 +51,10 @@ | ||||
|     "imagemin-pngquant": "8.0.0", | ||||
|     "ini": "1.3.5", | ||||
|     "is-svg": "4.2.1", | ||||
|     "jimp": "0.10.1", | ||||
|     "mime-types": "2.1.26", | ||||
|     "jimp": "0.10.3", | ||||
|     "mime-types": "2.1.27", | ||||
|     "multer": "1.4.2", | ||||
|     "node-abi": "2.15.0", | ||||
|     "node-abi": "2.16.0", | ||||
|     "open": "7.0.3", | ||||
|     "portscanner": "2.2.0", | ||||
|     "rand-token": "1.0.1", | ||||
| @@ -61,28 +62,30 @@ | ||||
|     "rimraf": "3.0.2", | ||||
|     "sanitize-filename": "1.6.3", | ||||
|     "sax": "1.2.4", | ||||
|     "semver": "7.2.1", | ||||
|     "semver": "7.3.2", | ||||
|     "serve-favicon": "2.5.0", | ||||
|     "session-file-store": "1.4.0", | ||||
|     "simple-node-logger": "18.12.24", | ||||
|     "sqlite": "3.0.6", | ||||
|     "sqlite": "4.0.7", | ||||
|     "sqlite3": "4.1.1", | ||||
|     "string-similarity": "4.0.1", | ||||
|     "tar-stream": "2.1.2", | ||||
|     "turndown": "6.0.0", | ||||
|     "turndown-plugin-gfm": "1.0.2", | ||||
|     "unescape": "1.0.1", | ||||
|     "ws": "7.2.3", | ||||
|     "ws": "7.2.5", | ||||
|     "yauzl": "^2.10.0", | ||||
|     "yazl": "^2.5.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "electron": "9.0.0-beta.14", | ||||
|     "electron-builder": "22.4.1", | ||||
|     "electron": "9.0.0-beta.22", | ||||
|     "electron-builder": "22.6.0", | ||||
|     "electron-packager": "14.2.1", | ||||
|     "electron-rebuild": "1.10.1", | ||||
|     "jsdoc": "3.6.4", | ||||
|     "lorem-ipsum": "2.0.3" | ||||
|     "lorem-ipsum": "2.0.3", | ||||
|     "webpack": "5.0.0-beta.16", | ||||
|     "webpack-cli": "4.0.0-beta.8" | ||||
|   }, | ||||
|   "optionalDependencies": { | ||||
|     "electron-installer-debian": "2.0.1" | ||||
|   | ||||
| @@ -1,76 +1,18 @@ | ||||
| import glob from './services/glob.js'; | ||||
| import link from './services/link.js'; | ||||
| import ws from './services/ws.js'; | ||||
| import noteType from './widgets/note_type.js'; | ||||
| import protectedSessionService from './services/protected_session.js'; | ||||
| import protectedSessionHolder from './services/protected_session_holder.js'; | ||||
| import FrontendScriptApi from './services/frontend_script_api.js'; | ||||
| import ScriptContext from './services/script_context.js'; | ||||
| import sync from './services/sync.js'; | ||||
| import treeService from './services/tree.js'; | ||||
| import branchService from './services/branches.js'; | ||||
| import appContext from "./services/app_context.js"; | ||||
| import utils from './services/utils.js'; | ||||
| import server from './services/server.js'; | ||||
| import Entrypoints from './services/entrypoints.js'; | ||||
| import noteTooltipService from './services/note_tooltip.js'; | ||||
| import bundle from "./services/bundle.js"; | ||||
| import treeCache from "./services/tree_cache.js"; | ||||
| import libraryLoader from "./services/library_loader.js"; | ||||
| import hoistedNoteService from './services/hoisted_note.js'; | ||||
| import noteTypeService from './widgets/note_type.js'; | ||||
| import linkService from './services/link.js'; | ||||
| import bundleService from "./services/bundle.js"; | ||||
| import noteAutocompleteService from './services/note_autocomplete.js'; | ||||
| import macInit from './services/mac_init.js'; | ||||
| import dateNoteService from './services/date_notes.js'; | ||||
| import importService from './services/import.js'; | ||||
| import keyboardActionService from "./services/keyboard_actions.js"; | ||||
| import splitService from "./services/split.js"; | ||||
| import options from "./services/options.js"; | ||||
| import noteContentRenderer from "./services/note_content_renderer.js"; | ||||
| import appContext from "./services/app_context.js"; | ||||
| import FlexContainer from "./widgets/flex_container.js"; | ||||
| import GlobalMenuWidget from "./widgets/global_menu.js"; | ||||
| import TabRowWidget from "./widgets/tab_row.js"; | ||||
| import TitleBarButtonsWidget from "./widgets/title_bar_buttons.js"; | ||||
| import StandardTopWidget from "./widgets/standard_top_widget.js"; | ||||
| import SidePaneContainer from "./widgets/side_pane_container.js"; | ||||
| import GlobalButtonsWidget from "./widgets/global_buttons.js"; | ||||
| import SearchBoxWidget from "./widgets/search_box.js"; | ||||
| import SearchResultsWidget from "./widgets/search_results.js"; | ||||
| import NoteTreeWidget from "./widgets/note_tree.js"; | ||||
| import TabCachingWidget from "./widgets/tab_caching_widget.js"; | ||||
| import NotePathsWidget from "./widgets/note_paths.js"; | ||||
| import NoteTitleWidget from "./widgets/note_title.js"; | ||||
| import RunScriptButtonsWidget from "./widgets/run_script_buttons.js"; | ||||
| import ProtectedNoteSwitchWidget from "./widgets/protected_note_switch.js"; | ||||
| import NoteTypeWidget from "./widgets/note_type.js"; | ||||
| import NoteActionsWidget from "./widgets/note_actions.js"; | ||||
| import PromotedAttributesWidget from "./widgets/promoted_attributes.js"; | ||||
| import NoteDetailWidget from "./widgets/note_detail.js"; | ||||
| import NoteInfoWidget from "./widgets/note_info.js"; | ||||
| import CalendarWidget from "./widgets/calendar.js"; | ||||
| import AttributesWidget from "./widgets/attributes.js"; | ||||
| import LinkMapWidget from "./widgets/link_map.js"; | ||||
| import NoteRevisionsWidget from "./widgets/note_revisions.js"; | ||||
| import SimilarNotesWidget from "./widgets/similar_notes.js"; | ||||
| import WhatLinksHereWidget from "./widgets/what_links_here.js"; | ||||
| import SidePaneToggles from "./widgets/side_pane_toggles.js"; | ||||
| import EmptyTypeWidget from "./widgets/type_widgets/empty.js"; | ||||
| import TextTypeWidget from "./widgets/type_widgets/editable_text.js"; | ||||
| import CodeTypeWidget from "./widgets/type_widgets/code.js"; | ||||
| import FileTypeWidget from "./widgets/type_widgets/file.js"; | ||||
| import ImageTypeWidget from "./widgets/type_widgets/image.js"; | ||||
| import SearchTypeWidget from "./widgets/type_widgets/search.js"; | ||||
| import RenderTypeWidget from "./widgets/type_widgets/render.js"; | ||||
| import RelationMapTypeWidget from "./widgets/type_widgets/relation_map.js"; | ||||
| import ProtectedSessionTypeWidget from "./widgets/type_widgets/protected_session.js"; | ||||
| import BookTypeWidget from "./widgets/type_widgets/book.js"; | ||||
| import contextMenu from "./services/context_menu.js"; | ||||
| import DesktopLayout from "./widgets/desktop_layout.js"; | ||||
| import bundleService from "./services/bundle.js"; | ||||
| import DesktopMainWindowLayout from "./layouts/desktop_main_window_layout.js"; | ||||
| import glob from "./services/glob.js"; | ||||
| import DesktopExtraWindowLayout from "./layouts/desktop_extra_window_layout.js"; | ||||
| 
 | ||||
| glob.setupGlobs(); | ||||
| 
 | ||||
| if (utils.isElectron()) { | ||||
|     require('electron').ipcRenderer.on('globalShortcut', async function(event, actionName) { | ||||
|     utils.dynamicRequire('electron').ipcRenderer.on('globalShortcut', async function(event, actionName) { | ||||
|         appContext.triggerCommand(actionName); | ||||
|     }); | ||||
| } | ||||
| @@ -82,9 +24,11 @@ $('[data-toggle="tooltip"]').tooltip({ | ||||
| macInit.init(); | ||||
| 
 | ||||
| bundleService.getWidgetBundlesByParent().then(widgetBundles => { | ||||
|     const desktopLayout = new DesktopLayout(widgetBundles); | ||||
|     const layout = window.glob.isMainWindow | ||||
|         ? new DesktopMainWindowLayout(widgetBundles) | ||||
|         : new DesktopExtraWindowLayout(widgetBundles); | ||||
| 
 | ||||
|     appContext.setLayout(desktopLayout); | ||||
|     appContext.setLayout(layout); | ||||
|     appContext.start(); | ||||
| }); | ||||
| 
 | ||||
| @@ -93,7 +37,7 @@ noteTooltipService.setupGlobalTooltip(); | ||||
| noteAutocompleteService.init(); | ||||
| 
 | ||||
| if (utils.isElectron()) { | ||||
|     const electron = require('electron'); | ||||
|     const electron = utils.dynamicRequire('electron'); | ||||
|     const {webContents} = electron.remote.getCurrentWindow(); | ||||
| 
 | ||||
|     webContents.on('context-menu', (event, params) => { | ||||
| @@ -141,7 +85,7 @@ if (utils.isElectron()) { | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         if (params.linkURL.length !== 0 && params.mediaType === 'none') { | ||||
|         if (!["", "javascript:", "about:blank#blocked"].includes(params.linkURL) && params.mediaType === 'none') { | ||||
|             items.push({ | ||||
|                 title: `Copy link`, | ||||
|                 uiIcon: "copy", | ||||
| @@ -20,6 +20,14 @@ export async function showDialog(widget) { | ||||
|     updateTitleFormGroupVisibility(); | ||||
|     $addLinkTitleSettings.find('input[type=radio]').on('change', updateTitleFormGroupVisibility); | ||||
| 
 | ||||
|     // with selection hyper link is implied
 | ||||
|     if (textTypeWidget.hasSelection()) { | ||||
|         $addLinkTitleSettings.find("input[value='hyper-link']").prop("checked", true); | ||||
|     } | ||||
|     else { | ||||
|         $addLinkTitleSettings.find("input[value='reference-link']").prop("checked", true); | ||||
|     } | ||||
| 
 | ||||
|     utils.openDialog($dialog); | ||||
| 
 | ||||
|     $autoComplete.val('').trigger('focus'); | ||||
| @@ -25,13 +25,15 @@ async function includeNote(notePath) { | ||||
|     const noteId = treeService.getNoteIdFromNotePath(notePath); | ||||
|     const note = await treeCache.getNote(noteId); | ||||
| 
 | ||||
|     const boxSize = $("input[name='include-note-box-size']:checked").val(); | ||||
| 
 | ||||
|     if (note.type === 'image') { | ||||
|         // there's no benefit to use insert note functionlity for images
 | ||||
|         // so we'll just add an IMG tag
 | ||||
|         textTypeWidget.addImage(noteId); | ||||
|     } | ||||
|     else { | ||||
|         textTypeWidget.addIncludeNote(noteId); | ||||
|         textTypeWidget.addIncludeNote(noteId, boxSize); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @@ -34,7 +34,7 @@ export async function importMarkdownInline() { | ||||
|     } | ||||
| 
 | ||||
|     if (utils.isElectron()) { | ||||
|         const {clipboard} = require('electron'); | ||||
|         const {clipboard} = utils.dynamicRequire('electron'); | ||||
|         const text = clipboard.readText(); | ||||
| 
 | ||||
|         convertMarkdownToHtml(text); | ||||
| @@ -44,7 +44,8 @@ async function loadNoteRevisions(noteId, noteRevId) { | ||||
|     for (const item of revisionItems) { | ||||
|         $list.append($('<a class="dropdown-item" tabindex="0">') | ||||
|             .text(item.dateLastEdited.substr(0, 16) + ` (${item.contentLength} bytes)`) | ||||
|             .attr('data-note-revision-id', item.noteRevisionId)); | ||||
|             .attr('data-note-revision-id', item.noteRevisionId)) | ||||
|             .attr('title', 'This revision was last edited on ' + item.dateLastEdited); | ||||
|     } | ||||
| 
 | ||||
|     $listDropdown.dropdown('show'); | ||||
| @@ -1,4 +1,4 @@ | ||||
| import optionsService from "../../services/options.js"; | ||||
| import utils from "../../services/utils.js"; | ||||
| import server from "../../services/server.js"; | ||||
| import toastService from "../../services/toast.js"; | ||||
| 
 | ||||
| @@ -20,7 +20,9 @@ const TPL = ` | ||||
|         <input type="text" class="form-control" id="spell-check-language-code" placeholder="for example "en-US", "de-AT""> | ||||
|     </div> | ||||
| 
 | ||||
|     <p>Multiple languages can be separated by comman. Changes to the spell check options will take effect after application restart.</p> | ||||
|     <p>Multiple languages can be separated by comma, e.g. <code>en-US, de-DE, cs</code>. Changes to the spell check options will take effect after application restart.</p> | ||||
|      | ||||
|     <p><strong>Available language codes: </strong> <span id="available-language-codes"></span></p> | ||||
| </div> | ||||
| 
 | ||||
| <div> | ||||
| @@ -95,6 +97,14 @@ export default class ProtectedSessionOptions { | ||||
|             return false; | ||||
|         }); | ||||
| 
 | ||||
|         this.$availableLanguageCodes = $("#available-language-codes"); | ||||
| 
 | ||||
|         if (utils.isElectron()) { | ||||
|             const {webContents} = utils.dynamicRequire('electron').remote.getCurrentWindow(); | ||||
| 
 | ||||
|             this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', ')); | ||||
|         } | ||||
| 
 | ||||
|         this.$eraseNotesAfterTimeInSeconds = $("#erase-notes-after-time-in-seconds"); | ||||
| 
 | ||||
|         this.$eraseNotesAfterTimeInSeconds.on('change', () => { | ||||
| @@ -32,10 +32,10 @@ export async function showDialog(ancestorNoteId) { | ||||
|     for (const [dateDay, dayChanges] of groupedByDate) { | ||||
|         const $changesList = $('<ul>'); | ||||
| 
 | ||||
|         const dayEl = $('<div>').append($('<b>').html(utils.formatDate(dateDay))).append($changesList); | ||||
|         const dayEl = $('<div>').append($('<b>').text(dateDay)).append($changesList); | ||||
| 
 | ||||
|         for (const change of dayChanges) { | ||||
|             const formattedTime = utils.formatTime(utils.parseDate(change.date)); | ||||
|             const formattedTime = change.date.substr(11, 5); | ||||
| 
 | ||||
|             let $noteLink; | ||||
| 
 | ||||
| @@ -82,7 +82,12 @@ export async function showDialog(ancestorNoteId) { | ||||
|             } | ||||
| 
 | ||||
|             $changesList.append($('<li>') | ||||
|                 .append(formattedTime + ' - ') | ||||
|                 .append( | ||||
|                     $("<span>") | ||||
|                         .text(formattedTime) | ||||
|                         .attr("title", change.date) | ||||
|                 ) | ||||
|                 .append(' - ') | ||||
|                 .append($noteLink)); | ||||
|         } | ||||
| 
 | ||||
| @@ -92,23 +97,9 @@ export async function showDialog(ancestorNoteId) { | ||||
| 
 | ||||
| function groupByDate(result) { | ||||
|     const groupedByDate = new Map(); | ||||
|     const dayCache = {}; | ||||
| 
 | ||||
|     for (const row of result) { | ||||
|         let dateDay = utils.parseDate(row.date); | ||||
|         dateDay.setHours(0); | ||||
|         dateDay.setMinutes(0); | ||||
|         dateDay.setSeconds(0); | ||||
|         dateDay.setMilliseconds(0); | ||||
| 
 | ||||
|         // this stupidity is to make sure that we always use the same day object because Map uses only
 | ||||
|         // reference equality
 | ||||
|         if (dayCache[dateDay]) { | ||||
|             dateDay = dayCache[dateDay]; | ||||
|         } | ||||
|         else { | ||||
|             dayCache[dateDay] = dateDay; | ||||
|         } | ||||
|         const dateDay = row.date.substr(0, 10); | ||||
| 
 | ||||
|         if (!groupedByDate.has(dateDay)) { | ||||
|             groupedByDate.set(dateDay, []); | ||||
| @@ -1,5 +1,6 @@ | ||||
| import server from '../services/server.js'; | ||||
| import Attribute from './attribute.js'; | ||||
| import noteAttributeCache from "../services/note_attribute_cache.js"; | ||||
| 
 | ||||
| const LABEL = 'label'; | ||||
| const LABEL_DEFINITION = 'label-definition'; | ||||
| @@ -7,6 +8,8 @@ const RELATION = 'relation'; | ||||
| const RELATION_DEFINITION = 'relation-definition'; | ||||
| 
 | ||||
| /** | ||||
|  * FIXME: since there's no "full note" anymore we can rename this to Note | ||||
|  * | ||||
|  * This note's representation is used in note tree and is kept in TreeCache. | ||||
|  */ | ||||
| class NoteShort { | ||||
| @@ -156,9 +159,9 @@ class NoteShort { | ||||
|     getOwnedAttributes(type, name) { | ||||
|         const attrs = this.attributes | ||||
|             .map(attributeId => this.treeCache.attributes[attributeId]) | ||||
|             .filter(attr => !!attr); | ||||
|             .filter(Boolean); // filter out nulls;
 | ||||
| 
 | ||||
|         return this.__filterAttrs(attrs, type, name) | ||||
|         return this.__filterAttrs(attrs, type, name); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @@ -167,43 +170,45 @@ class NoteShort { | ||||
|      * @returns {Attribute[]} all note's attributes, including inherited ones | ||||
|      */ | ||||
|     getAttributes(type, name) { | ||||
|         const ownedAttributes = this.getOwnedAttributes(); | ||||
|         if (!(this.noteId in noteAttributeCache)) { | ||||
|             const ownedAttributes = this.getOwnedAttributes(); | ||||
| 
 | ||||
|         const attrArrs = [ | ||||
|             ownedAttributes | ||||
|         ]; | ||||
|             const attrArrs = [ | ||||
|                 ownedAttributes | ||||
|             ]; | ||||
| 
 | ||||
|         for (const templateAttr of ownedAttributes.filter(oa => oa.type === 'relation' && oa.name === 'template')) { | ||||
|             const templateNote = this.treeCache.getNoteFromCache(templateAttr.value); | ||||
|             for (const templateAttr of ownedAttributes.filter(oa => oa.type === 'relation' && oa.name === 'template')) { | ||||
|                 const templateNote = this.treeCache.notes[templateAttr.value]; | ||||
| 
 | ||||
|             if (templateNote) { | ||||
|                 attrArrs.push(templateNote.getAttributes()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (this.noteId !== 'root') { | ||||
|             for (const parentNote of this.getParentNotes()) { | ||||
|                 // these virtual parent-child relationships are also loaded into frontend tree cache
 | ||||
|                 if (parentNote.type !== 'search') { | ||||
|                     attrArrs.push(parentNote.getInheritableAttributes()); | ||||
|                 if (templateNote) { | ||||
|                     attrArrs.push(templateNote.getAttributes()); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (this.noteId !== 'root') { | ||||
|                 for (const parentNote of this.getParentNotes()) { | ||||
|                     // these virtual parent-child relationships are also loaded into frontend tree cache
 | ||||
|                     if (parentNote.type !== 'search') { | ||||
|                         attrArrs.push(parentNote.getInheritableAttributes()); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             noteAttributeCache.attributes[this.noteId] = attrArrs.flat(); | ||||
|         } | ||||
| 
 | ||||
|         const attributes = attrArrs.flat(); | ||||
| 
 | ||||
|         return this.__filterAttrs(attributes, type, name); | ||||
|         return this.__filterAttrs(noteAttributeCache.attributes[this.noteId], type, name); | ||||
|     } | ||||
| 
 | ||||
|     __filterAttrs(attributes, type, name) { | ||||
|         if (type && name) { | ||||
|         if (!type && !name) { | ||||
|             return attributes; | ||||
|         } else if (type && name) { | ||||
|             return attributes.filter(attr => attr.type === type && attr.name === name); | ||||
|         } else if (type) { | ||||
|             return attributes.filter(attr => attr.type === type); | ||||
|         } else if (name) { | ||||
|             return attributes.filter(attr => attr.name === name); | ||||
|         } else { | ||||
|             return attributes; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
							
								
								
									
										46
									
								
								src/public/app/layouts/desktop_extra_window_layout.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/public/app/layouts/desktop_extra_window_layout.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| import FlexContainer from "../widgets/flex_container.js"; | ||||
| import GlobalMenuWidget from "../widgets/global_menu.js"; | ||||
| import TabRowWidget from "../widgets/tab_row.js"; | ||||
| import TitleBarButtonsWidget from "../widgets/title_bar_buttons.js"; | ||||
| import NoteTreeWidget from "../widgets/note_tree.js"; | ||||
| import TabCachingWidget from "../widgets/tab_caching_widget.js"; | ||||
| import NoteTitleWidget from "../widgets/note_title.js"; | ||||
| import RunScriptButtonsWidget from "../widgets/run_script_buttons.js"; | ||||
| import NoteTypeWidget from "../widgets/note_type.js"; | ||||
| import NoteActionsWidget from "../widgets/note_actions.js"; | ||||
| import PromotedAttributesWidget from "../widgets/promoted_attributes.js"; | ||||
| import NoteDetailWidget from "../widgets/note_detail.js"; | ||||
|  | ||||
| export default class DesktopExtraWindowLayout { | ||||
|     constructor(customWidgets) { | ||||
|         this.customWidgets = customWidgets; | ||||
|     } | ||||
|  | ||||
|     getRootWidget(appContext) { | ||||
|         appContext.mainTreeWidget = new NoteTreeWidget(); | ||||
|  | ||||
|         return new FlexContainer('column') | ||||
|             .setParent(appContext) | ||||
|             .id('root-widget') | ||||
|             .css('height', '100vh') | ||||
|             .child(new FlexContainer('row') | ||||
|                 .child(new GlobalMenuWidget()) | ||||
|                 .child(new TabRowWidget()) | ||||
|                 .child(new TitleBarButtonsWidget())) | ||||
|             .child(new FlexContainer('row') | ||||
|                 .collapsible() | ||||
|                 .child(new FlexContainer('column').id('center-pane').css('flex-grow', '1') | ||||
|                     .child(new FlexContainer('row').class('title-row') | ||||
|                         .cssBlock('.title-row > * { margin: 5px; }') | ||||
|                         .child(new NoteTitleWidget()) | ||||
|                         .child(new RunScriptButtonsWidget().hideInZenMode()) | ||||
|                         .child(new NoteTypeWidget().hideInZenMode()) | ||||
|                         .child(new NoteActionsWidget().hideInZenMode()) | ||||
|                     ) | ||||
|                     .child(new TabCachingWidget(() => new PromotedAttributesWidget())) | ||||
|                     .child(new TabCachingWidget(() => new NoteDetailWidget())) | ||||
|                     .child(...this.customWidgets.get('center-pane')) | ||||
|                 ) | ||||
|             ); | ||||
|     } | ||||
| } | ||||
| @@ -1,30 +1,29 @@ | ||||
| import FlexContainer from "./flex_container.js"; | ||||
| import GlobalMenuWidget from "./global_menu.js"; | ||||
| import TabRowWidget from "./tab_row.js"; | ||||
| import TitleBarButtonsWidget from "./title_bar_buttons.js"; | ||||
| import StandardTopWidget from "./standard_top_widget.js"; | ||||
| import SidePaneContainer from "./side_pane_container.js"; | ||||
| import GlobalButtonsWidget from "./global_buttons.js"; | ||||
| import SearchBoxWidget from "./search_box.js"; | ||||
| import SearchResultsWidget from "./search_results.js"; | ||||
| import NoteTreeWidget from "./note_tree.js"; | ||||
| import TabCachingWidget from "./tab_caching_widget.js"; | ||||
| import NotePathsWidget from "./note_paths.js"; | ||||
| import NoteTitleWidget from "./note_title.js"; | ||||
| import RunScriptButtonsWidget from "./run_script_buttons.js"; | ||||
| import ProtectedNoteSwitchWidget from "./protected_note_switch.js"; | ||||
| import NoteTypeWidget from "./note_type.js"; | ||||
| import NoteActionsWidget from "./note_actions.js"; | ||||
| import PromotedAttributesWidget from "./promoted_attributes.js"; | ||||
| import NoteDetailWidget from "./note_detail.js"; | ||||
| import NoteInfoWidget from "./note_info.js"; | ||||
| import CalendarWidget from "./calendar.js"; | ||||
| import AttributesWidget from "./attributes.js"; | ||||
| import LinkMapWidget from "./link_map.js"; | ||||
| import NoteRevisionsWidget from "./note_revisions.js"; | ||||
| import SimilarNotesWidget from "./similar_notes.js"; | ||||
| import WhatLinksHereWidget from "./what_links_here.js"; | ||||
| import SidePaneToggles from "./side_pane_toggles.js"; | ||||
| import FlexContainer from "../widgets/flex_container.js"; | ||||
| import GlobalMenuWidget from "../widgets/global_menu.js"; | ||||
| import TabRowWidget from "../widgets/tab_row.js"; | ||||
| import TitleBarButtonsWidget from "../widgets/title_bar_buttons.js"; | ||||
| import StandardTopWidget from "../widgets/standard_top_widget.js"; | ||||
| import SidePaneContainer from "../widgets/side_pane_container.js"; | ||||
| import GlobalButtonsWidget from "../widgets/global_buttons.js"; | ||||
| import SearchBoxWidget from "../widgets/search_box.js"; | ||||
| import SearchResultsWidget from "../widgets/search_results.js"; | ||||
| import NoteTreeWidget from "../widgets/note_tree.js"; | ||||
| import TabCachingWidget from "../widgets/tab_caching_widget.js"; | ||||
| import NotePathsWidget from "../widgets/note_paths.js"; | ||||
| import NoteTitleWidget from "../widgets/note_title.js"; | ||||
| import RunScriptButtonsWidget from "../widgets/run_script_buttons.js"; | ||||
| import NoteTypeWidget from "../widgets/note_type.js"; | ||||
| import NoteActionsWidget from "../widgets/note_actions.js"; | ||||
| import PromotedAttributesWidget from "../widgets/promoted_attributes.js"; | ||||
| import NoteDetailWidget from "../widgets/note_detail.js"; | ||||
| import NoteInfoWidget from "../widgets/collapsible_widgets/note_info.js"; | ||||
| import CalendarWidget from "../widgets/collapsible_widgets/calendar.js"; | ||||
| import AttributesWidget from "../widgets/collapsible_widgets/attributes.js"; | ||||
| import LinkMapWidget from "../widgets/collapsible_widgets/link_map.js"; | ||||
| import NoteRevisionsWidget from "../widgets/collapsible_widgets/note_revisions.js"; | ||||
| import SimilarNotesWidget from "../widgets/collapsible_widgets/similar_notes.js"; | ||||
| import WhatLinksHereWidget from "../widgets/collapsible_widgets/what_links_here.js"; | ||||
| import SidePaneToggles from "../widgets/side_pane_toggles.js"; | ||||
| import appContext from "../services/app_context.js"; | ||||
| 
 | ||||
| const RIGHT_PANE_CSS = ` | ||||
| @@ -98,13 +97,13 @@ const RIGHT_PANE_CSS = ` | ||||
| } | ||||
| </style>`; | ||||
| 
 | ||||
| export default class DesktopLayout { | ||||
| export default class DesktopMainWindowLayout { | ||||
|     constructor(customWidgets) { | ||||
|         this.customWidgets = customWidgets; | ||||
|     } | ||||
| 
 | ||||
|     getRootWidget(appContext) { | ||||
|         appContext.mainTreeWidget = new NoteTreeWidget(); | ||||
|         appContext.mainTreeWidget = new NoteTreeWidget("main"); | ||||
| 
 | ||||
|         return new FlexContainer('column') | ||||
|             .setParent(appContext) | ||||
| @@ -132,7 +131,6 @@ export default class DesktopLayout { | ||||
|                         .cssBlock('.title-row > * { margin: 5px; }') | ||||
|                         .child(new NoteTitleWidget()) | ||||
|                         .child(new RunScriptButtonsWidget().hideInZenMode()) | ||||
|                         .child(new ProtectedNoteSwitchWidget().hideInZenMode()) | ||||
|                         .child(new NoteTypeWidget().hideInZenMode()) | ||||
|                         .child(new NoteActionsWidget().hideInZenMode()) | ||||
|                     ) | ||||
| @@ -1,11 +1,11 @@ | ||||
| import FlexContainer from "./flex_container.js"; | ||||
| import NoteTitleWidget from "./note_title.js"; | ||||
| import NoteDetailWidget from "./note_detail.js"; | ||||
| import NoteTreeWidget from "./note_tree.js"; | ||||
| import MobileGlobalButtonsWidget from "./mobile_global_buttons.js"; | ||||
| import CloseDetailButtonWidget from "./close_detail_button.js"; | ||||
| import MobileDetailMenuWidget from "./mobile_detail_menu.js"; | ||||
| import ScreenContainer from "./screen_container.js"; | ||||
| import FlexContainer from "../widgets/flex_container.js"; | ||||
| import NoteTitleWidget from "../widgets/note_title.js"; | ||||
| import NoteDetailWidget from "../widgets/note_detail.js"; | ||||
| import NoteTreeWidget from "../widgets/note_tree.js"; | ||||
| import MobileGlobalButtonsWidget from "../widgets/mobile_widgets/mobile_global_buttons.js"; | ||||
| import CloseDetailButtonWidget from "../widgets/mobile_widgets/close_detail_button.js"; | ||||
| import MobileDetailMenuWidget from "../widgets/mobile_widgets/mobile_detail_menu.js"; | ||||
| import ScreenContainer from "../widgets/mobile_widgets/screen_container.js"; | ||||
| 
 | ||||
| const MOBILE_CSS = ` | ||||
| <style> | ||||
| @@ -73,7 +73,7 @@ export default class MobileLayout { | ||||
|             .child(new ScreenContainer("tree", 'column') | ||||
|                 .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-5 col-md-4 col-lg-4 col-xl-4") | ||||
|                 .child(new MobileGlobalButtonsWidget()) | ||||
|                 .child(new NoteTreeWidget().cssBlock(FANCYTREE_CSS))) | ||||
|                 .child(new NoteTreeWidget("main").cssBlock(FANCYTREE_CSS))) | ||||
|             .child(new ScreenContainer("detail", "column") | ||||
|                 .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-7 col-md-8 col-lg-8") | ||||
|                 .child(new FlexContainer('row') | ||||
							
								
								
									
										8
									
								
								src/public/app/mobile.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/public/app/mobile.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| import appContext from "./services/app_context.js"; | ||||
| import MobileLayout from "./layouts/mobile_layout.js"; | ||||
| import glob from "./services/glob.js"; | ||||
|  | ||||
| glob.setupGlobs(); | ||||
|  | ||||
| appContext.setLayout(new MobileLayout()); | ||||
| appContext.start(); | ||||
| @@ -9,10 +9,16 @@ import TabManager from "./tab_manager.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import Component from "../widgets/component.js"; | ||||
| import keyboardActionsService from "./keyboard_actions.js"; | ||||
| import MobileScreenSwitcherExecutor from "../widgets/mobile_screen_switcher.js"; | ||||
| import MobileScreenSwitcherExecutor from "../widgets/mobile_widgets/mobile_screen_switcher.js"; | ||||
| import MainTreeExecutors from "./main_tree_executors.js"; | ||||
| 
 | ||||
| class AppContext extends Component { | ||||
|     constructor(isMainWindow) { | ||||
|         super(); | ||||
| 
 | ||||
|         this.isMainWindow = isMainWindow; | ||||
|     } | ||||
| 
 | ||||
|     setLayout(layout) { | ||||
|         this.layout = layout; | ||||
|     } | ||||
| @@ -20,11 +26,15 @@ class AppContext extends Component { | ||||
|     async start() { | ||||
|         await Promise.all([treeCache.initializedPromise, options.initializedPromise]); | ||||
| 
 | ||||
|         $("#loading-indicator").hide(); | ||||
| 
 | ||||
|         this.showWidgets(); | ||||
| 
 | ||||
|         this.tabManager.loadTabs(); | ||||
| 
 | ||||
|         setTimeout(() => bundleService.executeStartupBundles(), 2000); | ||||
|         if (utils.isDesktop()) { | ||||
|             setTimeout(() => bundleService.executeStartupBundles(), 2000); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     showWidgets() { | ||||
| @@ -35,10 +45,12 @@ class AppContext extends Component { | ||||
| 
 | ||||
|         $("body").append($renderedWidget); | ||||
| 
 | ||||
|         $renderedWidget.on('click', "[data-trigger-command]", e => { | ||||
|             const commandName = $(e.target).attr('data-trigger-command'); | ||||
|         $renderedWidget.on('click', "[data-trigger-command]", function() { | ||||
|             const commandName = $(this).attr('data-trigger-command'); | ||||
|             const $component = $(this).closest(".component"); | ||||
|             const component = $component.prop("component"); | ||||
| 
 | ||||
|             this.triggerCommand(commandName); | ||||
|             component.triggerCommand(commandName, {$el: $(this)}); | ||||
|         }); | ||||
| 
 | ||||
|         this.tabManager = new TabManager(); | ||||
| @@ -82,6 +94,8 @@ class AppContext extends Component { | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // this might hint at error but sometimes this is used by components which are at different places
 | ||||
|         // in the component tree to communicate with each other
 | ||||
|         console.debug(`Unhandled command ${name}, converting to event.`); | ||||
| 
 | ||||
|         return this.triggerEvent(name, data); | ||||
| @@ -90,15 +104,9 @@ class AppContext extends Component { | ||||
|     getComponentByEl(el) { | ||||
|         return $(el).closest(".component").prop('component'); | ||||
|     } | ||||
| 
 | ||||
|     async protectedSessionStartedEvent() { | ||||
|         await treeCache.loadInitialTree(); | ||||
| 
 | ||||
|         this.triggerEvent('treeCacheReloaded'); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| const appContext = new AppContext(); | ||||
| const appContext = new AppContext(window.glob.isMainWindow); | ||||
| 
 | ||||
| // we should save all outstanding changes before the page/app is closed
 | ||||
| $(window).on('beforeunload', () => { | ||||
| @@ -1,14 +1,13 @@ | ||||
| import utils from "./utils.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import dateNoteService from "./date_notes.js"; | ||||
| import hoistedNoteService from "./hoisted_note.js"; | ||||
| import treeCache from "./tree_cache.js"; | ||||
| import server from "./server.js"; | ||||
| import appContext from "./app_context.js"; | ||||
| import Component from "../widgets/component.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import noteCreateService from "./note_create.js"; | ||||
| import ws from "./ws.js"; | ||||
| import bundleService from "./bundle.js"; | ||||
| 
 | ||||
| export default class Entrypoints extends Component { | ||||
|     constructor() { | ||||
| @@ -36,7 +35,7 @@ export default class Entrypoints extends Component { | ||||
| 
 | ||||
|     openDevToolsCommand() { | ||||
|         if (utils.isElectron()) { | ||||
|             require('electron').remote.getCurrentWindow().toggleDevTools(); | ||||
|             utils.dynamicRequire('electron').remote.getCurrentWindow().toggleDevTools(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @@ -45,8 +44,8 @@ export default class Entrypoints extends Component { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         const {remote} = require('electron'); | ||||
|         const {FindInPage} = require('electron-find'); | ||||
|         const {remote} = utils.dynamicRequire('electron'); | ||||
|         const {FindInPage} = utils.dynamicRequire('electron-find'); | ||||
|         const findInPage = new FindInPage(remote.getCurrentWebContents(), { | ||||
|             offsetTop: 10, | ||||
|             offsetRight: 10, | ||||
| @@ -98,7 +97,7 @@ export default class Entrypoints extends Component { | ||||
| 
 | ||||
|     toggleFullscreenCommand() { | ||||
|         if (utils.isElectron()) { | ||||
|             const win = require('electron').remote.getCurrentWindow(); | ||||
|             const win = utils.dynamicRequire('electron').remote.getCurrentWindow(); | ||||
| 
 | ||||
|             if (win.isFullScreenable()) { | ||||
|                 win.setFullScreen(!win.isFullScreen()); | ||||
| @@ -139,7 +138,7 @@ export default class Entrypoints extends Component { | ||||
|     backInNoteHistoryCommand() { | ||||
|         if (utils.isElectron()) { | ||||
|             // standard JS version does not work completely correctly in electron
 | ||||
|             const webContents = require('electron').remote.getCurrentWebContents(); | ||||
|             const webContents = utils.dynamicRequire('electron').remote.getCurrentWebContents(); | ||||
|             const activeIndex = parseInt(webContents.getActiveIndex()); | ||||
| 
 | ||||
|             webContents.goToIndex(activeIndex - 1); | ||||
| @@ -152,7 +151,7 @@ export default class Entrypoints extends Component { | ||||
|     forwardInNoteHistoryCommand() { | ||||
|         if (utils.isElectron()) { | ||||
|             // standard JS version does not work completely correctly in electron
 | ||||
|             const webContents = require('electron').remote.getCurrentWebContents(); | ||||
|             const webContents = utils.dynamicRequire('electron').remote.getCurrentWebContents(); | ||||
|             const activeIndex = parseInt(webContents.getActiveIndex()); | ||||
| 
 | ||||
|             webContents.goToIndex(activeIndex + 1); | ||||
| @@ -184,4 +183,40 @@ export default class Entrypoints extends Component { | ||||
|     } | ||||
| 
 | ||||
|     createTopLevelNoteCommand() { noteCreateService.createNewTopLevelNote(); } | ||||
| 
 | ||||
|     async openInWindowCommand({notePath}) { | ||||
|         if (utils.isElectron()) { | ||||
|             const {ipcRenderer} = utils.dynamicRequire('electron'); | ||||
| 
 | ||||
|             ipcRenderer.send('create-extra-window', {notePath}); | ||||
|         } | ||||
|         else { | ||||
|             const url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?extra=1#' + notePath; | ||||
| 
 | ||||
|             window.open(url, '', 'width=1000,height=800'); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     async openNewWindowCommand() { | ||||
|         this.openInWindowCommand({notePath: ''}); | ||||
|     } | ||||
| 
 | ||||
|     async runActiveNoteCommand() { | ||||
|         const note = appContext.tabManager.getActiveTabNote(); | ||||
| 
 | ||||
|         // ctrl+enter is also used elsewhere so make sure we're running only when appropriate
 | ||||
|         if (!note || note.type !== 'code') { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         if (note.mime.endsWith("env=frontend")) { | ||||
|             await bundleService.getAndExecuteBundle(note.noteId); | ||||
|         } | ||||
| 
 | ||||
|         if (note.mime.endsWith("env=backend")) { | ||||
|             await server.post('script/run/' + note.noteId); | ||||
|         } | ||||
| 
 | ||||
|         toastService.showMessage("Note executed"); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										94
									
								
								src/public/app/services/glob.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								src/public/app/services/glob.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,94 @@ | ||||
| import utils from "./utils.js"; | ||||
| import appContext from "./app_context.js"; | ||||
| import server from "./server.js"; | ||||
| import libraryLoader from "./library_loader.js"; | ||||
| import ws from "./ws.js"; | ||||
| import protectedSessionHolder from "./protected_session_holder.js"; | ||||
| import treeCache from "./tree_cache.js"; | ||||
|  | ||||
| function setupGlobs() { | ||||
|     window.glob.PROFILING_LOG = false; | ||||
|  | ||||
|     window.glob.isDesktop = utils.isDesktop; | ||||
|     window.glob.isMobile = utils.isMobile; | ||||
|  | ||||
|     window.glob.getComponentByEl = el => appContext.getComponentByEl(el); | ||||
|     window.glob.getHeaders = server.getHeaders; | ||||
|  | ||||
|     // required for ESLint plugin and CKEditor | ||||
|     window.glob.getActiveTabNote = () => appContext.tabManager.getActiveTabNote(); | ||||
|     window.glob.requireLibrary = libraryLoader.requireLibrary; | ||||
|     window.glob.ESLINT = libraryLoader.ESLINT; | ||||
|     window.glob.appContext = appContext; // for debugging | ||||
|     window.glob.treeCache = treeCache; | ||||
|  | ||||
|     // for CKEditor integration (button on block toolbar) | ||||
|     window.glob.importMarkdownInline = async () => { | ||||
|         const dialog = await import("../dialogs/markdown_import.js"); | ||||
|  | ||||
|         dialog.importMarkdownInline(); | ||||
|     }; | ||||
|  | ||||
|     window.glob.SEARCH_HELP_TEXT = ` | ||||
|     <strong>Search tips</strong> - also see <button class="btn btn-sm" type="button" data-help-page="Search">complete help on search</button> | ||||
|     <p> | ||||
|     <ul> | ||||
|         <li>Just enter any text for full text search</li> | ||||
|         <li><code>@abc</code> - returns notes with label abc</li> | ||||
|         <li><code>@year=2019</code> - matches notes with label <code>year</code> having value <code>2019</code></li> | ||||
|         <li><code>@rock @pop</code> - matches notes which have both <code>rock</code> and <code>pop</code> labels</li> | ||||
|         <li><code>@rock or @pop</code> - only one of the labels must be present</li> | ||||
|         <li><code>@year<=2000</code> - numerical comparison (also >, >=, <).</li> | ||||
|         <li><code>@dateCreated>=MONTH-1</code> - notes created in the last month</li> | ||||
|         <li><code>=handler</code> - will execute script defined in <code>handler</code> relation to get results</li> | ||||
|     </ul> | ||||
|     </p>`; | ||||
|  | ||||
|     window.onerror = function (msg, url, lineNo, columnNo, error) { | ||||
|         const string = msg.toLowerCase(); | ||||
|  | ||||
|         let message = "Uncaught error: "; | ||||
|  | ||||
|         if (string.includes("Cannot read property 'defaultView' of undefined")) { | ||||
|             // ignore this specific error which is very common but we don't know where it comes from | ||||
|             // and it seems to be harmless | ||||
|             return true; | ||||
|         } else if (string.includes("script error")) { | ||||
|             message += 'No details available'; | ||||
|         } else { | ||||
|             message += [ | ||||
|                 'Message: ' + msg, | ||||
|                 'URL: ' + url, | ||||
|                 'Line: ' + lineNo, | ||||
|                 'Column: ' + columnNo, | ||||
|                 'Error object: ' + JSON.stringify(error) | ||||
|             ].join(' - '); | ||||
|         } | ||||
|  | ||||
|         ws.logError(message); | ||||
|  | ||||
|         return false; | ||||
|     }; | ||||
|  | ||||
|     protectedSessionHolder.setProtectedSessionId(null); | ||||
|  | ||||
|     for (const appCssNoteId of glob.appCssNoteIds || []) { | ||||
|         libraryLoader.requireCss(`api/notes/download/${appCssNoteId}`); | ||||
|     } | ||||
|  | ||||
|     const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/"; | ||||
|  | ||||
|     $(document).on("click", "button[data-help-page]", e => { | ||||
|         const $button = $(e.target); | ||||
|  | ||||
|         window.open(wikiBaseUrl + $button.attr("data-help-page"), '_blank'); | ||||
|     }); | ||||
|  | ||||
|     $("body").on("click", "a.external", function () { | ||||
|         window.open($(this).attr("href"), '_blank'); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| export default { | ||||
|     setupGlobs | ||||
| } | ||||
| @@ -93,8 +93,8 @@ function updateDisplayedShortcuts($container) { | ||||
| 		} | ||||
| 	}); | ||||
| 
 | ||||
| 	$container.find('button[data-command],a.icon-action[data-command],.kb-in-title').each(async (i, el) => { | ||||
| 		const actionName = $(el).attr('data-command'); | ||||
| 	$container.find('[data-trigger-command]').each(async (i, el) => { | ||||
| 		const actionName = $(el).attr('data-trigger-command'); | ||||
| 		const action = await getAction(actionName, true); | ||||
| 
 | ||||
| 		if (action) { | ||||
| @@ -113,12 +113,16 @@ function newTabContextMenu(e) { | ||||
|         x: e.pageX, | ||||
|         y: e.pageY, | ||||
|         items: [ | ||||
|             {title: "Open note in new tab", command: "openNoteInNewTab", uiIcon: "arrow-up-right"} | ||||
|             {title: "Open note in new tab", command: "openNoteInNewTab", uiIcon: "arrow-up-right"}, | ||||
|             {title: "Open note in new window", command: "openNoteInNewWindow", uiIcon: "window-open"} | ||||
|         ], | ||||
|         selectMenuItemHandler: ({command}) => { | ||||
|             if (command === 'openNoteInNewTab') { | ||||
|                 appContext.tabManager.openTabWithNote(notePath); | ||||
|             } | ||||
|             else if (command === 'openNoteInNewWindow') { | ||||
|                 appContext.openInNewWindow(notePath); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| @@ -162,6 +166,7 @@ $(document).on('contextmenu', 'a.ck-link-actions__preview', newTabContextMenu); | ||||
| $(document).on('contextmenu', '.note-detail-text a', newTabContextMenu); | ||||
| $(document).on('contextmenu', "a[data-action='note']", newTabContextMenu); | ||||
| $(document).on('contextmenu', ".note-detail-render a", newTabContextMenu); | ||||
| $(document).on('contextmenu', ".note-paths-widget a", newTabContextMenu); | ||||
| 
 | ||||
| export default { | ||||
|     getNotePathFromUrl, | ||||
| @@ -101,6 +101,15 @@ export default class LoadResults { | ||||
|         this.options.includes(name); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return {boolean} true if there are changes which could affect the attributes (including inherited ones) | ||||
|      */ | ||||
|     hasAttributeRelatedChanges() { | ||||
|         return Object.keys(this.noteIdToSourceId).length === 0 | ||||
|             && this.branches.length === 0 | ||||
|             && this.attributes.length === 0; | ||||
|     } | ||||
| 
 | ||||
|     isEmpty() { | ||||
|         return Object.keys(this.noteIdToSourceId).length === 0 | ||||
|             && this.branches.length === 0 | ||||
| @@ -38,10 +38,6 @@ export default class MainTreeExecutors extends Component { | ||||
|             isProtected: activeNote.isProtected, | ||||
|             saveSelection: false | ||||
|         }); | ||||
| 
 | ||||
|         await ws.waitForMaxKnownSyncId(); | ||||
| 
 | ||||
|         appContext.tabManager.getActiveTabContext().setNote(note.noteId); | ||||
|     } | ||||
| 
 | ||||
|     async createNoteAfterCommand() { | ||||
| @@ -53,15 +49,11 @@ export default class MainTreeExecutors extends Component { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         const {note} = await noteCreateService.createNote(parentNoteId, { | ||||
|         await noteCreateService.createNote(parentNoteId, { | ||||
|             target: 'after', | ||||
|             targetBranchId: node.data.branchId, | ||||
|             isProtected: isProtected, | ||||
|             saveSelection: true | ||||
|             saveSelection: false | ||||
|         }); | ||||
| 
 | ||||
|         await ws.waitForMaxKnownSyncId(); | ||||
| 
 | ||||
|         appContext.tabManager.getActiveTabContext().setNote(note.noteId); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										20
									
								
								src/public/app/services/note_attribute_cache.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/public/app/services/note_attribute_cache.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| /** | ||||
|  * Purpose of this class is to cache list of attributes for notes. | ||||
|  * | ||||
|  * Cache invalidation granularity is global - whenever a write operation is detected to notes, branches or attributes | ||||
|  * we invalidate the whole cache. That's OK, since the purpose for this is to speed up batch read-only operations, such | ||||
|  * as loading the tree which uses attributes heavily. | ||||
|  */ | ||||
| class NoteAttributeCache { | ||||
|     constructor() { | ||||
|         this.attributes = {}; | ||||
|     } | ||||
|  | ||||
|     invalidate() { | ||||
|         this.attributes = {}; | ||||
|     } | ||||
| } | ||||
|  | ||||
| const noteAttributeCache = new NoteAttributeCache(); | ||||
|  | ||||
| export default noteAttributeCache; | ||||
| @@ -35,7 +35,7 @@ async function getRenderedContent(note) { | ||||
|         $downloadButton.on('click', () => utils.download(getFileUrl())); | ||||
|         $openButton.on('click', () => { | ||||
|             if (utils.isElectron()) { | ||||
|                 const open = require("open"); | ||||
|                 const open = utils.dynamicRequire("open"); | ||||
| 
 | ||||
|                 open(getFileUrl(), {url: true}); | ||||
|             } | ||||
| @@ -48,8 +48,12 @@ async function createNote(parentNoteId, options = {}) { | ||||
|     } | ||||
| 
 | ||||
|     if (options.activate) { | ||||
|         await ws.waitForMaxKnownSyncId(); | ||||
| 
 | ||||
|         const activeTabContext = appContext.tabManager.getActiveTabContext(); | ||||
|         activeTabContext.setNote(note.noteId); | ||||
|         await activeTabContext.setNote(note.noteId); | ||||
| 
 | ||||
|         appContext.triggerCommand('focusAndSelectTitle'); | ||||
|     } | ||||
| 
 | ||||
|     return {note, branch}; | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user