From 772079338fb42721f2468a2c0ac0057b1de9e14b Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Sat, 12 Mar 2022 13:35:59 +0530 Subject: [PATCH 01/42] feat: disable autocomplete for search input (#919) --- app/assets/javascripts/components/NotesView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/components/NotesView.tsx b/app/assets/javascripts/components/NotesView.tsx index 6c6a19f23..657eb3ec9 100644 --- a/app/assets/javascripts/components/NotesView.tsx +++ b/app/assets/javascripts/components/NotesView.tsx @@ -194,6 +194,7 @@ export const NotesView: FunctionComponent = observer( onKeyUp={onNoteFilterKeyUp} onFocus={onSearchFocused} onBlur={onSearchBlurred} + autocomplete="off" /> {noteFilterText && ( - - -
- Standard Notes is free on every platform, and comes standard with - sync and encryption. -
- - )} - {(showSignIn || showRegister) && ( -
-
- {showSignIn ? 'Sign In' : 'Register'} -
-
-
- - - {showRegister && ( - - )} -
- -
- {showAdvanced && ( -
-
-
- Advanced Options -
-
- - -
- {showSignIn && ( - - )} -
-
- )} - {!isAuthenticating && ( -
- -
- )} - {showRegister && ( -
-
No Password Reset.
-
- Because your notes are encrypted using your password, Standard - Notes does not have a password reset option. You cannot forget - your password. -
-
- )} - {status && ( -
-
-
-
{status}
-
-
- )} - {!isAuthenticating && ( -
- - {notesAndTagsCount > 0 && ( - - )} -
- )} - -
- )} - - ); -}); - -export default Authentication; diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx index 01f40bea7..fdd399048 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx @@ -102,18 +102,18 @@ export const AttachedFilesButton: FunctionComponent = observer( const deleteFile = async (file: SNFile) => { const shouldDelete = await confirmDialog({ - text: `Are you sure you want to permanently delete "${file.nameWithExt}"?`, + text: `Are you sure you want to permanently delete "${file.name}"?`, confirmButtonStyle: 'danger', }); if (shouldDelete) { const deletingToastId = addToast({ type: ToastType.Loading, - message: `Deleting file "${file.nameWithExt}"...`, + message: `Deleting file "${file.name}"...`, }); await application.deleteItem(file); addToast({ type: ToastType.Success, - message: `Deleted file "${file.nameWithExt}"`, + message: `Deleted file "${file.name}"`, }); dismissToast(deletingToastId); } @@ -160,8 +160,7 @@ export const AttachedFilesButton: FunctionComponent = observer( }; const renameFile = async (file: SNFile, fileName: string) => { - const { name, ext } = parseFileName(fileName); - await application.items.renameFile(file, name, ext); + await application.items.renameFile(file, fileName); }; const handleFileAction = async (action: PopoverFileItemAction) => { diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx index 3d7e23775..a6c0134a4 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx @@ -48,7 +48,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( const filteredList = searchQuery.length > 0 ? filesList.filter( - (file) => file.nameWithExt.toLowerCase().indexOf(searchQuery) !== -1 + (file) => file.name.toLowerCase().indexOf(searchQuery) !== -1 ) : filesList; diff --git a/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx b/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx index 17e051614..96efc9923 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx @@ -61,7 +61,7 @@ export const PopoverFileItem: FunctionComponent = ({ isAttachedToNote, handleFileAction, }) => { - const [fileName, setFileName] = useState(file.nameWithExt); + const [fileName, setFileName] = useState(file.name); const [isRenamingFile, setIsRenamingFile] = useState(false); const fileNameInputRef = useRef(null); @@ -99,7 +99,7 @@ export const PopoverFileItem: FunctionComponent = ({ return (
- {getIconForFileType(file.ext ?? '')} + {getIconForFileType(file.name ?? '')}
{isRenamingFile ? ( = ({ onBlur={handleFileNameInputBlur} /> ) : ( -
{file.nameWithExt}
+
{file.name}
)}
{file.created_at.toLocaleString()} ·{' '} diff --git a/app/assets/javascripts/ui_models/app_state/files_state.ts b/app/assets/javascripts/ui_models/app_state/files_state.ts index 526b48a33..c2cb9bd43 100644 --- a/app/assets/javascripts/ui_models/app_state/files_state.ts +++ b/app/assets/javascripts/ui_models/app_state/files_state.ts @@ -17,7 +17,7 @@ export class FilesState { try { const saver = StreamingFileSaver.available() - ? new StreamingFileSaver(file.nameWithExt) + ? new StreamingFileSaver(file.name) : new ClassicFileSaver(); const isUsingStreamingSaver = saver instanceof StreamingFileSaver; @@ -37,7 +37,7 @@ export class FilesState { if (isUsingStreamingSaver) { await saver.pushBytes(decryptedBytes); } else { - saver.saveFile(file.nameWithExt, decryptedBytes); + saver.saveFile(file.name, decryptedBytes); } } ); @@ -113,8 +113,7 @@ export class FilesState { const uploadedFile = await this.application.files.finishUpload( operation, - fileResult.name, - fileResult.ext + { name: fileResult.name, mimeType: '' } ); uploadedFiles.push(uploadedFile); @@ -122,7 +121,7 @@ export class FilesState { dismissToast(toastId); addToast({ type: ToastType.Success, - message: `Uploaded file "${uploadedFile.nameWithExt}"`, + message: `Uploaded file "${uploadedFile.name}"`, }); } diff --git a/package.json b/package.json index 1ecc7435e..2c8c815a7 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,9 @@ "@babel/preset-typescript": "^7.16.7", "@reach/disclosure": "^0.16.2", "@reach/visually-hidden": "^0.16.0", - "@standardnotes/responses": "1.3.7", - "@standardnotes/services": "1.5.9", - "@standardnotes/stylekit": "5.15.0", + "@standardnotes/responses": "1.3.10", + "@standardnotes/services": "1.5.12", + "@standardnotes/stylekit": "5.16.0", "@svgr/webpack": "^6.2.1", "@types/jest": "^27.4.1", "@types/lodash": "^4.14.179", @@ -44,7 +44,7 @@ "copy-webpack-plugin": "^10.2.4", "css-loader": "^6.7.1", "dotenv": "^16.0.0", - "eslint": "^8.10.0", + "eslint": "^8.11.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-react": "^7.29.3", "eslint-plugin-react-hooks": "^4.3.0", @@ -63,7 +63,7 @@ "serve-static": "^1.14.2", "svg-jest": "^1.0.1", "ts-jest": "^27.1.3", - "ts-loader": "^9.2.7", + "ts-loader": "^9.2.8", "typescript": "4.6.2", "typescript-eslint": "0.0.1-alpha.0", "webpack": "^5.70.0", @@ -79,12 +79,12 @@ "@reach/dialog": "^0.16.2", "@reach/listbox": "^0.16.2", "@reach/tooltip": "^0.16.2", - "@standardnotes/components": "1.7.11", - "@standardnotes/features": "1.34.8", - "@standardnotes/filepicker": "1.8.0", + "@standardnotes/components": "1.7.12", + "@standardnotes/features": "1.34.10", + "@standardnotes/filepicker": "1.10.0", "@standardnotes/settings": "1.12.0", "@standardnotes/sncrypto-web": "1.7.3", - "@standardnotes/snjs": "2.79.5", + "@standardnotes/snjs": "2.81.1", "mobx": "^6.4.2", "mobx-react-lite": "^3.3.0", "preact": "^10.6.6", diff --git a/yarn.lock b/yarn.lock index 07c945748..e4b5937e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1804,16 +1804,16 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.5.tgz#9283c9ce5b289a3c4f61c12757469e59377f81f3" integrity sha512-6nFkfkmSeV/rqSaS4oWHgmpnYw194f6hmWF5is6b0J1naJZoiD0NTc9AiUwPHvWsowkjuHErCZT1wa0jg+BLIA== -"@eslint/eslintrc@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.0.tgz#7ce1547a5c46dfe56e1e45c3c9ed18038c721c6a" - integrity sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w== +"@eslint/eslintrc@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.1.tgz#8b5e1c49f4077235516bc9ec7d41378c0f69b8c6" + integrity sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ== dependencies: ajv "^6.12.4" debug "^4.3.2" espree "^9.3.1" globals "^13.9.0" - ignore "^4.0.6" + ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.0.4" @@ -2313,10 +2313,10 @@ dependencies: "@standardnotes/common" "^1.15.3" -"@standardnotes/auth@^3.17.4": - version "3.17.4" - resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-3.17.4.tgz#ab2449a280ee6ec794fe397c9d8387e105c6c644" - integrity sha512-0710hUiYoRFjABfUFPlyOIyCMx0gC0rlJtFdPYK7WHXf0bfxO0JiSXeWbNSvV0QVGqHIkcUjGmdyE6cJEKTh9g== +"@standardnotes/auth@^3.17.5": + version "3.17.5" + resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-3.17.5.tgz#e5b0ee9a0ed36e90cc3951d3113256c28f568afd" + integrity sha512-c9hoB4tTHvHAWERqsMBqOPJgesNrFp/tWevSPfxgTqVv3HfxLckPYQdWb3RlKevXVreb5ldRy0doHIMnbQDEYg== dependencies: "@standardnotes/common" "^1.15.3" jsonwebtoken "^8.5.1" @@ -2326,60 +2326,60 @@ resolved "https://registry.yarnpkg.com/@standardnotes/common/-/common-1.15.3.tgz#0b8ce48b81b260abe2d405431fb04aacb44b5a01" integrity sha512-9oh/W3sFQYyA5Vabcbu6BUkLVkFq/25Q5EK9KCd4aT9QnDJ9JQlTtzDmTk1jYuM6rnccsJ6SW2pcWjbi9FVniw== -"@standardnotes/components@1.7.11": - version "1.7.11" - resolved "https://registry.yarnpkg.com/@standardnotes/components/-/components-1.7.11.tgz#791c1e1bef5bc223f34c423e4ddd443fe8a699d3" - integrity sha512-V8gtuLMbn0ldRQLZj0iKrm5PRufHdRGbSQ32/u0w1M6dTE42wKUYuMNhPwkn9cNEaYzhhcHRD01L/lYEepBZBQ== +"@standardnotes/components@1.7.12": + version "1.7.12" + resolved "https://registry.yarnpkg.com/@standardnotes/components/-/components-1.7.12.tgz#c87c3c8d90c0030b711d4f59aae47e14c745ea2a" + integrity sha512-geE3xpBagZFJCucvFymUK4qIWT45nb8OXGW8Ck0EJothVSbz4rF3MJJ/W1pvI6+kYKbT12AaUoGecL6uKxi+1Q== -"@standardnotes/domain-events@^2.24.5": - version "2.24.5" - resolved "https://registry.yarnpkg.com/@standardnotes/domain-events/-/domain-events-2.24.5.tgz#f4699b2241e0e51829d88ec8afe1b8d00d5fe37d" - integrity sha512-NrbeaQ0Yl+56cMlXOLSISHCpkiRTAcmmRtIEPAqn0V7RBeRXqKfy6Fo5OUPSuGtYinQfbKBLi5rxIC/rqhMZFg== +"@standardnotes/domain-events@^2.24.7": + version "2.24.7" + resolved "https://registry.yarnpkg.com/@standardnotes/domain-events/-/domain-events-2.24.7.tgz#5a24b8ac1d0f8d51f2e4e014e18900e332237a48" + integrity sha512-2hl5z19Lha+FdtX5ezs8YZwpMaM6gViCoZ7mzT7M0yy97iZDihecmqYk4zaECJXfBrGpcqYK2sxBk9dcMQYTXg== dependencies: - "@standardnotes/auth" "^3.17.4" - "@standardnotes/features" "^1.34.8" + "@standardnotes/auth" "^3.17.5" + "@standardnotes/features" "^1.34.10" -"@standardnotes/features@1.34.8", "@standardnotes/features@^1.34.8": - version "1.34.8" - resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.34.8.tgz#a82b7648706bdf62355eff6df1f4ccadf0b83afa" - integrity sha512-0ttEnBjod7zANER0sU6TzCz0RHSt+p1lQ9xzg9a3z6Azjz8WAJkQAMeIBJNgym8EPVI8QUjKFyz/Rdo0PNAyng== +"@standardnotes/features@1.34.10", "@standardnotes/features@^1.34.10": + version "1.34.10" + resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.34.10.tgz#f7fa88d0b8111119d8105b490fe54333be39cb51" + integrity sha512-7mPZDI33vC6XuEjXeRmm9p0rmymMHVz6DhCTnDOeOy2pV4+P+dbNMla7tr1R1wItpsqmi+J1OShySuYSLHYp6w== dependencies: - "@standardnotes/auth" "^3.17.4" + "@standardnotes/auth" "^3.17.5" "@standardnotes/common" "^1.15.3" -"@standardnotes/filepicker@1.8.0": - version "1.8.0" - resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.8.0.tgz#f8d85350c4b4022235e3017b0b2c7841882eef4f" - integrity sha512-xgFoD+aHFCKV5pAbhKNCyyhUL18G9l2Aep6eiQ5gxB55l8CcNHlLBi5qw5i1we07NdCwIJ3yP3aVKI+7qe22yQ== +"@standardnotes/filepicker@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.10.0.tgz#bd9b283ef2f62989f05913aa79d830e40e073186" + integrity sha512-LhWghEm9d9PaUUoE/kqwYfdE5CCPbKTbVEpY+hZXHLeZgubtHROLtzuEc4HDYkL7yG2aU/pcwsAwsKIqdWbs4A== -"@standardnotes/payloads@^1.4.7": - version "1.4.7" - resolved "https://registry.yarnpkg.com/@standardnotes/payloads/-/payloads-1.4.7.tgz#e722a117a1bb02b76555cc6b164eefdb765bea9f" - integrity sha512-0y7fDqu1OBMhvIrQDkJbsYEzpPqodSM9X8c5s6hVCs4GtriQcw1JAjsekRyV2/9iKd8GiOldNNWBDDYre+78gQ== +"@standardnotes/payloads@^1.4.9": + version "1.4.9" + resolved "https://registry.yarnpkg.com/@standardnotes/payloads/-/payloads-1.4.9.tgz#ee5d8b4c5a3fcd0a236791772db18bd7312b0bb8" + integrity sha512-6zR+h2bjbjmxpl2poA59NbjqKUsKtul+a8hGIBgixwCkLpyUTmlxBCxWIOuSSAo6vKGaG+RVWkEIrLoKfaaZLA== dependencies: "@standardnotes/applications" "^1.1.3" "@standardnotes/common" "^1.15.3" - "@standardnotes/features" "^1.34.8" + "@standardnotes/features" "^1.34.10" "@standardnotes/utils" "^1.2.3" -"@standardnotes/responses@1.3.7", "@standardnotes/responses@^1.3.7": - version "1.3.7" - resolved "https://registry.yarnpkg.com/@standardnotes/responses/-/responses-1.3.7.tgz#6304d55613df77342c21336b8c4000a65d3bb42f" - integrity sha512-RYIWNB6RinZmOSre6lfLmFAdpN0cSWb5PCjmYAThedkor21iK//9yhOG5xKChqIfB+Y+kaKFfnm8+BtONcMD0A== +"@standardnotes/responses@1.3.10", "@standardnotes/responses@^1.3.10": + version "1.3.10" + resolved "https://registry.yarnpkg.com/@standardnotes/responses/-/responses-1.3.10.tgz#33f5ae4e891fe96256d95c0ecee34cfca3838cc7" + integrity sha512-0qMF9JmXt7xyRE72L6vbtGjS/r7vTca2cxCgf8V5YC/ZqncXbeTgqK9bFGvIcF1HQddQbKQflHF/ON2BACZzDg== dependencies: - "@standardnotes/auth" "^3.17.4" + "@standardnotes/auth" "^3.17.5" "@standardnotes/common" "^1.15.3" - "@standardnotes/features" "^1.34.8" - "@standardnotes/payloads" "^1.4.7" + "@standardnotes/features" "^1.34.10" + "@standardnotes/payloads" "^1.4.9" -"@standardnotes/services@1.5.9", "@standardnotes/services@^1.5.9": - version "1.5.9" - resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.5.9.tgz#4356c739659145553fafe87d59f98db6c9dc4ad8" - integrity sha512-EiiAbFGwsqwgb2cFLDKt1Jb9LpuKynrVwYtDUoxZlM9FiRvcmQdK9w+0upS/mthcreaiKHjdkSuQMwJkCaU3rw== +"@standardnotes/services@1.5.12", "@standardnotes/services@^1.5.12": + version "1.5.12" + resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.5.12.tgz#66d5884653fe837acaa6f7a180092f2c56978fd5" + integrity sha512-e2WscL3AXNvTzAFptZbwZaYjyHglstnz3jcyePZ5B+j3v700CNlvfk0vxdvmWqGqr9G3pGIqUj8ug46qcIswzA== dependencies: "@standardnotes/applications" "^1.1.3" "@standardnotes/common" "^1.15.3" - "@standardnotes/responses" "^1.3.7" + "@standardnotes/responses" "^1.3.10" "@standardnotes/utils" "^1.2.3" "@standardnotes/settings@1.12.0", "@standardnotes/settings@^1.12.0": @@ -2401,27 +2401,27 @@ buffer "^6.0.3" libsodium-wrappers "^0.7.9" -"@standardnotes/snjs@2.79.5": - version "2.79.5" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.79.5.tgz#2df9ef88d0c0ffead2e0044249c5a833921d94dc" - integrity sha512-IEZtHg6Ga4/R2QUMbJhD4MEOvkNuBtiNYrokpqrf5kzGGOvL3b/RwcSWUW8zjBS1WxDSGmIo3WBKze3FXhfdEA== +"@standardnotes/snjs@2.81.1": + version "2.81.1" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.81.1.tgz#c6ac1970483743661d4d2227c6a8d1596d737bb7" + integrity sha512-Kc1FtkaUj1K8RuvZbwbsHdx0yrMzMYKVLf2aVKFJJXhMAKwVj9N4d2ZXOjr+1jlx4vc5Z5h76yeksOdKPO0NBA== dependencies: "@standardnotes/applications" "^1.1.3" - "@standardnotes/auth" "^3.17.4" + "@standardnotes/auth" "^3.17.5" "@standardnotes/common" "^1.15.3" - "@standardnotes/domain-events" "^2.24.5" - "@standardnotes/features" "^1.34.8" - "@standardnotes/payloads" "^1.4.7" - "@standardnotes/responses" "^1.3.7" - "@standardnotes/services" "^1.5.9" + "@standardnotes/domain-events" "^2.24.7" + "@standardnotes/features" "^1.34.10" + "@standardnotes/payloads" "^1.4.9" + "@standardnotes/responses" "^1.3.10" + "@standardnotes/services" "^1.5.12" "@standardnotes/settings" "^1.12.0" "@standardnotes/sncrypto-common" "^1.7.3" "@standardnotes/utils" "^1.2.3" -"@standardnotes/stylekit@5.15.0": - version "5.15.0" - resolved "https://registry.yarnpkg.com/@standardnotes/stylekit/-/stylekit-5.15.0.tgz#14c0ff5c4e40d4afa9ea6fec0431934e1184a18f" - integrity sha512-BR78DIdXo8fxzNPruiugiQJfgT7usUFWxJ0CPnjhk3hshYM2/kleHdcrahYdi2Rs5MR7chhbsvUFUWHxykOaRg== +"@standardnotes/stylekit@5.16.0": + version "5.16.0" + resolved "https://registry.yarnpkg.com/@standardnotes/stylekit/-/stylekit-5.16.0.tgz#4403cd704d4f01b0cd3a844d7ff9ee8f21396afb" + integrity sha512-FnpK/3ExnfLoHnw7jKU34P2zjtpeQ1344ark/jJ5+E45gPZGEBtFk0TUvUCt/jSkrVw6OGCTZaF2wIChsP8o4Q== dependencies: "@nanostores/preact" "^0.1.3" "@reach/listbox" "^0.16.2" @@ -4821,12 +4821,12 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@^8.10.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.10.0.tgz#931be395eb60f900c01658b278e05b6dae47199d" - integrity sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw== +eslint@^8.11.0: + version "8.11.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.11.0.tgz#88b91cfba1356fc10bb9eb592958457dfe09fb37" + integrity sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA== dependencies: - "@eslint/eslintrc" "^1.2.0" + "@eslint/eslintrc" "^1.2.1" "@humanwhocodes/config-array" "^0.9.2" ajv "^6.10.0" chalk "^4.0.0" @@ -5779,11 +5779,6 @@ ieee754@^1.2.1: resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - ignore@^5.1.4, ignore@^5.1.8: version "5.1.8" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" @@ -9267,10 +9262,10 @@ ts-jest@^27.1.3: semver "7.x" yargs-parser "20.x" -ts-loader@^9.2.7: - version "9.2.7" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.7.tgz#948654099ca96992b62ec47bd9cee5632006e101" - integrity sha512-Fxh44mKli9QezgbdCXkEJWxnedQ0ead7DXTH+lfXEPedu+Y9EtMJ2aQ9G3Dj1j7Q612E8931rww8NDZha4Tibg== +ts-loader@^9.2.8: + version "9.2.8" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.8.tgz#e89aa32fa829c5cad0a1d023d6b3adecd51d5a48" + integrity sha512-gxSak7IHUuRtwKf3FIPSW1VpZcqF9+MBrHOvBp9cjHh+525SjtCIJKVGjRKIAfxBwDGDGCFF00rTfzB1quxdSw== dependencies: chalk "^4.1.0" enhanced-resolve "^5.0.0" From a1c7ad7d7e16a8cb35f72411e598400cf8f4b616 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Mon, 14 Mar 2022 01:19:55 +0530 Subject: [PATCH 05/42] fix: file mimeType related issues (#922) --- .../AttachedFilesButton.tsx | 2 +- .../AttachedFilesPopover.tsx | 1 + .../AttachedFilesPopover/PopoverFileItem.tsx | 44 +++---------------- .../PopoverFileSubmenu.tsx | 2 +- .../ui_models/app_state/files_state.ts | 2 +- package.json | 2 +- yarn.lock | 8 ++-- 7 files changed, 15 insertions(+), 46 deletions(-) diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx index fdd399048..4ec4a7b36 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx @@ -15,7 +15,7 @@ import { useCloseOnClickOutside } from '../utils'; import { ChallengeReason, ContentType, SNFile } from '@standardnotes/snjs'; import { confirmDialog } from '@/services/alertService'; import { addToast, dismissToast, ToastType } from '@standardnotes/stylekit'; -import { parseFileName, StreamingFileReader } from '@standardnotes/filepicker'; +import { StreamingFileReader } from '@standardnotes/filepicker'; import { PopoverFileItemAction, PopoverFileItemActionType, diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx index a6c0134a4..1515e5307 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx @@ -169,6 +169,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( file={file} isAttachedToNote={attachedFiles.includes(file)} handleFileAction={handleFileAction} + getIconType={application.iconsController.getIconForFileType} /> ); }) diff --git a/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx b/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx index 96efc9923..eb86aae26 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/PopoverFileItem.tsx @@ -1,6 +1,6 @@ import { KeyboardKey } from '@/services/ioService'; import { formatSizeToReadableString } from '@standardnotes/filepicker'; -import { SNFile } from '@standardnotes/snjs'; +import { IconType, SNFile } from '@standardnotes/snjs'; import { FunctionComponent } from 'preact'; import { useEffect, useRef, useState } from 'preact/hooks'; import { ICONS } from '../Icon'; @@ -10,56 +10,24 @@ import { } from './PopoverFileItemAction'; import { PopoverFileSubmenu } from './PopoverFileSubmenu'; -const getIconForFileType = (fileType: string) => { - let iconType = 'file-other'; - - if (fileType === 'pdf') { - iconType = 'file-pdf'; - } - - if (/^(docx?|odt)/.test(fileType)) { - iconType = 'file-doc'; - } - - if (/^pptx?/.test(fileType)) { - iconType = 'file-ppt'; - } - - if (/^(xlsx?|ods)/.test(fileType)) { - iconType = 'file-xls'; - } - - if (/^(jpe?g|a?png|webp|gif)/.test(fileType)) { - iconType = 'file-image'; - } - - if (/^(mov|mp4|mkv)/.test(fileType)) { - iconType = 'file-mov'; - } - - if (/^(wav|mp3|flac|ogg)/.test(fileType)) { - iconType = 'file-music'; - } - - if (/^(zip|rar|7z)/.test(fileType)) { - iconType = 'file-zip'; - } - +const getFileIconComponent = (iconType: string) => { const IconComponent = ICONS[iconType as keyof typeof ICONS]; - return ; + return ; }; export type PopoverFileItemProps = { file: SNFile; isAttachedToNote: boolean; handleFileAction: (action: PopoverFileItemAction) => Promise; + getIconType(type: string): IconType; }; export const PopoverFileItem: FunctionComponent = ({ file, isAttachedToNote, handleFileAction, + getIconType, }) => { const [fileName, setFileName] = useState(file.name); const [isRenamingFile, setIsRenamingFile] = useState(false); @@ -99,7 +67,7 @@ export const PopoverFileItem: FunctionComponent = ({ return (
- {getIconForFileType(file.name ?? '')} + {getFileIconComponent(getIconType(file.mimeType))}
{isRenamingFile ? ( & { +type Props = Omit & { setIsRenamingFile: StateUpdater; }; diff --git a/app/assets/javascripts/ui_models/app_state/files_state.ts b/app/assets/javascripts/ui_models/app_state/files_state.ts index c2cb9bd43..e6f69c076 100644 --- a/app/assets/javascripts/ui_models/app_state/files_state.ts +++ b/app/assets/javascripts/ui_models/app_state/files_state.ts @@ -113,7 +113,7 @@ export class FilesState { const uploadedFile = await this.application.files.finishUpload( operation, - { name: fileResult.name, mimeType: '' } + { name: fileResult.name, mimeType: fileResult.mimeType } ); uploadedFiles.push(uploadedFile); diff --git a/package.json b/package.json index 2c8c815a7..78aba3447 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "@standardnotes/filepicker": "1.10.0", "@standardnotes/settings": "1.12.0", "@standardnotes/sncrypto-web": "1.7.3", - "@standardnotes/snjs": "2.81.1", + "@standardnotes/snjs": "2.82.0", "mobx": "^6.4.2", "mobx-react-lite": "^3.3.0", "preact": "^10.6.6", diff --git a/yarn.lock b/yarn.lock index e4b5937e0..68aba0102 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2401,10 +2401,10 @@ buffer "^6.0.3" libsodium-wrappers "^0.7.9" -"@standardnotes/snjs@2.81.1": - version "2.81.1" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.81.1.tgz#c6ac1970483743661d4d2227c6a8d1596d737bb7" - integrity sha512-Kc1FtkaUj1K8RuvZbwbsHdx0yrMzMYKVLf2aVKFJJXhMAKwVj9N4d2ZXOjr+1jlx4vc5Z5h76yeksOdKPO0NBA== +"@standardnotes/snjs@2.82.0": + version "2.82.0" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.82.0.tgz#7901526ea59cf8f3cbad846d5b17b6f75ff1d13b" + integrity sha512-jqw4BoVMtBNZ2bEVs4g3AX1UWGMUjCkORWLmR6W6qhv7fDpwl+wrdMPEQRoYdJqTfrNxYTnX4ZGZ+FEwHlzuUw== dependencies: "@standardnotes/applications" "^1.1.3" "@standardnotes/auth" "^3.17.5" From 7e6706109723d3524eb6a8f9b42553776b44fac6 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Mon, 14 Mar 2022 17:16:25 +0530 Subject: [PATCH 06/42] fix: file drag-n-drop issue (#923) --- .../AttachedFilesButton.tsx | 41 ++++++++++++++++++- .../components/NoteView/NoteView.tsx | 39 +++++------------- app/assets/stylesheets/_sn.scss | 4 ++ 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx index 4ec4a7b36..acaa042b8 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx @@ -12,7 +12,13 @@ import { FunctionComponent } from 'preact'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { Icon } from '../Icon'; import { useCloseOnClickOutside } from '../utils'; -import { ChallengeReason, ContentType, SNFile } from '@standardnotes/snjs'; +import { + ChallengeReason, + ContentType, + FeatureIdentifier, + FeatureStatus, + SNFile, +} from '@standardnotes/snjs'; import { confirmDialog } from '@/services/alertService'; import { addToast, dismissToast, ToastType } from '@standardnotes/stylekit'; import { StreamingFileReader } from '@standardnotes/filepicker'; @@ -21,6 +27,7 @@ import { PopoverFileItemActionType, } from './PopoverFileItemAction'; import { AttachedFilesPopover, PopoverTabs } from './AttachedFilesPopover'; +import { usePremiumModal } from '../Premium/usePremiumModal'; type Props = { application: WebApplication; @@ -28,8 +35,26 @@ type Props = { onClickPreprocessing?: () => Promise; }; +const createDragOverlay = () => { + if (document.getElementById('drag-overlay')) { + return; + } + + const overlayElementTemplate = + '
'; + const overlayFragment = document + .createRange() + .createContextualFragment(overlayElementTemplate); + document.body.appendChild(overlayFragment); +}; + +const removeDragOverlay = () => { + document.getElementById('drag-overlay')?.remove(); +}; + export const AttachedFilesButton: FunctionComponent = observer( ({ application, appState, onClickPreprocessing }) => { + const premiumModal = usePremiumModal(); const note = Object.values(appState.notes.selectedNotes)[0]; const [open, setOpen] = useState(false); @@ -69,6 +94,14 @@ export const AttachedFilesButton: FunctionComponent = observer( }, [application, reloadAttachedFilesCount]); const toggleAttachedFilesMenu = useCallback(async () => { + if ( + application.features.getFeatureStatus(FeatureIdentifier.Files) !== + FeatureStatus.Entitled + ) { + premiumModal.activate('Files'); + return; + } + const rect = buttonRef.current?.getBoundingClientRect(); if (rect) { const { clientHeight } = document.documentElement; @@ -98,7 +131,7 @@ export const AttachedFilesButton: FunctionComponent = observer( setOpen(newOpenState); } - }, [onClickPreprocessing, open]); + }, [application.features, onClickPreprocessing, open, premiumModal]); const deleteFile = async (file: SNFile) => { const shouldDelete = await confirmDialog({ @@ -230,6 +263,7 @@ export const AttachedFilesButton: FunctionComponent = observer( if (event.dataTransfer?.items.length) { setIsDraggingFiles(true); + createDragOverlay(); if (!open) { toggleAttachedFilesMenu(); } @@ -248,6 +282,8 @@ export const AttachedFilesButton: FunctionComponent = observer( return; } + removeDragOverlay(); + setIsDraggingFiles(false); }; @@ -257,6 +293,7 @@ export const AttachedFilesButton: FunctionComponent = observer( event.stopPropagation(); setIsDraggingFiles(false); + removeDragOverlay(); if (event.dataTransfer?.items.length) { Array.from(event.dataTransfer.items).forEach(async (item) => { diff --git a/app/assets/javascripts/components/NoteView/NoteView.tsx b/app/assets/javascripts/components/NoteView/NoteView.tsx index 33d8f21bb..01a8df836 100644 --- a/app/assets/javascripts/components/NoteView/NoteView.tsx +++ b/app/assets/javascripts/components/NoteView/NoteView.tsx @@ -12,13 +12,10 @@ import { ComponentMutator, PayloadSource, ComponentViewer, - ComponentManagerEvent, TransactionalMutation, ItemMutator, ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction, NoteViewController, - FeatureIdentifier, - FeatureStatus, } from '@standardnotes/snjs'; import { debounce, isDesktopApplication } from '@/utils'; import { KeyboardModifier, KeyboardKey } from '@/services/ioService'; @@ -103,7 +100,6 @@ type State = { editorTitle: string; editorText: string; isDesktop?: boolean; - isEntitledToFiles: boolean; lockText: string; marginResizersEnabled?: boolean; monospaceFont?: boolean; @@ -172,9 +168,6 @@ export class NoteView extends PureComponent { editorText: '', editorTitle: '', isDesktop: isDesktopApplication(), - isEntitledToFiles: - this.application.features.getFeatureStatus(FeatureIdentifier.Files) === - FeatureStatus.Entitled, lockText: 'Note Editing Disabled', noteStatus: undefined, noteLocked: this.controller.note.locked, @@ -328,15 +321,6 @@ export class NoteView extends PureComponent { /** @override */ async onAppEvent(eventName: ApplicationEvent) { switch (eventName) { - case ApplicationEvent.FeaturesUpdated: - case ApplicationEvent.UserRolesChanged: - this.setState({ - isEntitledToFiles: - this.application.features.getFeatureStatus( - FeatureIdentifier.Files - ) === FeatureStatus.Entitled, - }); - break; case ApplicationEvent.PreferencesChanged: this.reloadPreferences(); break; @@ -1043,18 +1027,17 @@ export class NoteView extends PureComponent { )}
- {this.state.isEntitledToFiles && - window.enabledUnfinishedFeatures && ( -
- -
- )} + {window.enabledUnfinishedFeatures && ( +
+ +
+ )}
Date: Mon, 14 Mar 2022 17:30:15 +0530 Subject: [PATCH 07/42] fix: file popover not closing when click inside editor (#924) --- .../AttachedFilesPopover/AttachedFilesButton.tsx | 15 +++++++++++---- .../AttachedFilesPopover.tsx | 16 +++++++++++++++- .../AttachedFilesPopover/PopoverFileItem.tsx | 3 +++ app/assets/javascripts/components/Button.tsx | 3 +++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx index acaa042b8..208e13949 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesButton.tsx @@ -11,7 +11,7 @@ import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { Icon } from '../Icon'; -import { useCloseOnClickOutside } from '../utils'; +import { useCloseOnBlur } from '../utils'; import { ChallengeReason, ContentType, @@ -66,9 +66,7 @@ export const AttachedFilesButton: FunctionComponent = observer( const buttonRef = useRef(null); const panelRef = useRef(null); const containerRef = useRef(null); - useCloseOnClickOutside(containerRef, () => { - setOpen(false); - }); + const [closeOnBlur, keepMenuOpen] = useCloseOnBlur(containerRef, setOpen); const [attachedFilesCount, setAttachedFilesCount] = useState( note ? application.items.getFilesForNote(note).length : 0 @@ -170,7 +168,10 @@ export const AttachedFilesButton: FunctionComponent = observer( const toggleFileProtection = async (file: SNFile) => { let result: SNFile | undefined; if (file.protected) { + keepMenuOpen(true); result = await application.protections.unprotectFile(file); + keepMenuOpen(false); + buttonRef.current?.focus(); } else { result = await application.protections.protectFile(file); } @@ -207,10 +208,13 @@ export const AttachedFilesButton: FunctionComponent = observer( file.protected && action.type !== PopoverFileItemActionType.ToggleFileProtection ) { + keepMenuOpen(true); isAuthorizedForAction = await authorizeProtectedActionForFile( file, ChallengeReason.AccessProtectedFile ); + keepMenuOpen(false); + buttonRef.current?.focus(); } if (!isAuthorizedForAction) { @@ -354,6 +358,7 @@ export const AttachedFilesButton: FunctionComponent = observer( className={`sn-icon-button border-contrast ${ attachedFilesCount > 0 ? 'py-1 px-3' : '' }`} + onBlur={closeOnBlur} > Attached files @@ -374,6 +379,7 @@ export const AttachedFilesButton: FunctionComponent = observer( maxHeight, }} className="sn-dropdown sn-dropdown--animated min-w-80 max-h-120 max-w-xs flex flex-col overflow-y-auto fixed" + onBlur={closeOnBlur} > {open && ( = observer( note={note} handleFileAction={handleFileAction} currentTab={currentTab} + closeOnBlur={closeOnBlur} setCurrentTab={setCurrentTab} isDraggingFiles={isDraggingFiles} /> diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx index 1515e5307..48b3f034b 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx @@ -1,3 +1,4 @@ +import { FOCUSABLE_BUT_NOT_TABBABLE } from '@/constants'; import { WebApplication } from '@/ui_models/application'; import { AppState } from '@/ui_models/app_state'; import { ContentType, SNFile, SNNote } from '@standardnotes/snjs'; @@ -22,6 +23,7 @@ type Props = { application: WebApplication; appState: AppState; currentTab: PopoverTabs; + closeOnBlur: (event: { relatedTarget: EventTarget | null }) => void; handleFileAction: (action: PopoverFileItemAction) => Promise; isDraggingFiles: boolean; note: SNNote; @@ -33,6 +35,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( application, appState, currentTab, + closeOnBlur, handleFileAction, isDraggingFiles, note, @@ -100,6 +103,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( return (
= observer( onClick={() => { setCurrentTab(PopoverTabs.AttachedFiles); }} + onBlur={closeOnBlur} > Attached @@ -128,6 +133,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( onClick={() => { setCurrentTab(PopoverTabs.AllFiles); }} + onBlur={closeOnBlur} > All files @@ -144,6 +150,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( onInput={(e) => { setSearchQuery((e.target as HTMLInputElement).value); }} + onBlur={closeOnBlur} /> {searchQuery.length > 0 && (
- @@ -204,6 +217,7 @@ export const AttachedFilesPopover: FunctionComponent = observer(
); diff --git a/app/assets/javascripts/components/Button.tsx b/app/assets/javascripts/components/Button.tsx index 516d416fe..8ac16a5be 100644 --- a/app/assets/javascripts/components/Button.tsx +++ b/app/assets/javascripts/components/Button.tsx @@ -25,6 +25,7 @@ type ButtonProps = { | TargetedEvent | TargetedMouseEvent ) => void; + onBlur?: (event: FocusEvent) => void; disabled?: boolean; }; @@ -34,6 +35,7 @@ export const Button: FunctionComponent = forwardRef( type, label, className = '', + onBlur, onClick, disabled = false, children, @@ -46,6 +48,7 @@ export const Button: FunctionComponent = forwardRef( return (