@weavy/uikit-react 14.0.4 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +2 -0
- package/changelog.md +10 -0
- package/dist/cjs/client/WeavyClient.d.ts +1 -0
- package/dist/cjs/components/Attachment.d.ts +5 -5
- package/dist/cjs/components/Blob.d.ts +9 -0
- package/dist/cjs/components/Comment.d.ts +18 -0
- package/dist/cjs/components/CommentCount.d.ts +7 -0
- package/dist/cjs/components/CommentEdit.d.ts +16 -0
- package/dist/cjs/components/CommentPlaceholder.d.ts +8 -0
- package/dist/cjs/components/CommentTrashed.d.ts +15 -0
- package/dist/cjs/components/CommentView.d.ts +18 -0
- package/dist/cjs/components/Comments.d.ts +8 -0
- package/dist/cjs/components/ConversationListItem.d.ts +1 -1
- package/dist/cjs/components/Dropzone.d.ts +10 -0
- package/dist/cjs/components/Editor.d.ts +25 -0
- package/dist/cjs/components/Embed.d.ts +8 -0
- package/dist/cjs/components/FileItem.d.ts +41 -0
- package/dist/cjs/components/FileList.d.ts +11 -0
- package/dist/cjs/components/FileVersions.d.ts +9 -0
- package/dist/cjs/components/Files.d.ts +4 -0
- package/dist/cjs/components/Image.d.ts +3 -3
- package/dist/cjs/components/MeetingCard.d.ts +1 -1
- package/dist/cjs/components/Meetings.d.ts +2 -1
- package/dist/cjs/components/Poll.d.ts +8 -0
- package/dist/cjs/components/PollOption.d.ts +10 -0
- package/dist/cjs/components/Post.d.ts +21 -0
- package/dist/cjs/components/PostEdit.d.ts +17 -0
- package/dist/cjs/components/PostList.d.ts +6 -0
- package/dist/cjs/components/PostPlaceholder.d.ts +8 -0
- package/dist/cjs/components/PostTrashed.d.ts +14 -0
- package/dist/cjs/components/PostView.d.ts +21 -0
- package/dist/cjs/components/Posts.d.ts +4 -0
- package/dist/cjs/components/Preview.d.ts +1 -3
- package/dist/cjs/components/PreviewFiles.d.ts +10 -0
- package/dist/cjs/components/Reactions.d.ts +6 -2
- package/dist/cjs/components/SearchUsers.d.ts +2 -1
- package/dist/cjs/contexts/CloudFilesContext.d.ts +9 -0
- package/dist/cjs/hooks/useApps.d.ts +1 -0
- package/dist/cjs/hooks/useCloudFiles.d.ts +3 -0
- package/dist/cjs/hooks/useCommentList.d.ts +1 -0
- package/dist/cjs/hooks/useEmbeds.d.ts +5 -0
- package/dist/cjs/hooks/useFileList.d.ts +1 -0
- package/dist/cjs/hooks/useFileUploader.d.ts +8 -0
- package/dist/cjs/hooks/useFileVersions.d.ts +2 -0
- package/dist/cjs/hooks/useInfiniteScroll.d.ts +4 -0
- package/dist/cjs/hooks/useIsFirstRender.d.ts +2 -0
- package/dist/cjs/hooks/useMutateApps.d.ts +5 -0
- package/dist/cjs/hooks/useMutateComment.d.ts +10 -0
- package/dist/cjs/hooks/useMutateConversationName.d.ts +1 -1
- package/dist/cjs/hooks/useMutateDeleteReaction.d.ts +3 -1
- package/dist/cjs/hooks/useMutateEditComment.d.ts +10 -0
- package/dist/cjs/hooks/useMutateEditPost.d.ts +10 -0
- package/dist/cjs/hooks/useMutateExternalBlobs.d.ts +2 -2
- package/dist/cjs/hooks/useMutateFile.d.ts +26 -0
- package/dist/cjs/hooks/useMutateFileRename.d.ts +5 -0
- package/dist/cjs/hooks/useMutateFileSubscribe.d.ts +7 -0
- package/dist/cjs/hooks/useMutateFileTrash.d.ts +10 -0
- package/dist/cjs/hooks/useMutateFileVersion.d.ts +7 -0
- package/dist/cjs/hooks/useMutateFiles.d.ts +2 -0
- package/dist/cjs/hooks/useMutateLeaveConversation.d.ts +4 -0
- package/dist/cjs/hooks/useMutateMessage.d.ts +2 -2
- package/dist/cjs/hooks/useMutatePost.d.ts +10 -0
- package/dist/cjs/hooks/useMutateReaction.d.ts +3 -1
- package/dist/cjs/hooks/useMutateRead.d.ts +1 -1
- package/dist/cjs/hooks/useMutateReplaceReaction.d.ts +6 -0
- package/dist/cjs/hooks/useMutateRestoreComment.d.ts +5 -0
- package/dist/cjs/hooks/useMutateRestorePost.d.ts +4 -0
- package/dist/cjs/hooks/useMutateStarred.d.ts +4 -0
- package/dist/cjs/hooks/useMutateSubscribe.d.ts +4 -0
- package/dist/cjs/hooks/useMutateTrashComment.d.ts +5 -0
- package/dist/cjs/hooks/useMutateTrashPost.d.ts +4 -0
- package/dist/cjs/hooks/useMutateTyping.d.ts +2 -0
- package/dist/cjs/hooks/useMutateUnsubscribe.d.ts +4 -0
- package/dist/cjs/hooks/useMutateVote.d.ts +5 -0
- package/dist/cjs/hooks/usePost.d.ts +1 -0
- package/dist/cjs/hooks/usePosts.d.ts +1 -0
- package/dist/cjs/hooks/usePostsList.d.ts +1 -0
- package/dist/cjs/hooks/useReactionList.d.ts +1 -0
- package/dist/cjs/hooks/useSessionState.d.ts +2 -0
- package/dist/cjs/hooks/useUnload.d.ts +2 -0
- package/dist/cjs/hooks/useUpdateEffect.d.ts +3 -0
- package/dist/cjs/hooks/useVotes.d.ts +1 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +28 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/ConversationListItem.d.ts +1 -0
- package/dist/cjs/types/Files.d.ts +7 -0
- package/dist/cjs/types/Message.d.ts +2 -2
- package/dist/cjs/types/Posts.d.ts +4 -0
- package/dist/cjs/types/interfaces.d.ts +9 -0
- package/dist/cjs/types/types.d.ts +138 -22
- package/dist/cjs/ui/Dropdown.d.ts +18 -2
- package/dist/cjs/ui/Icon.d.ts +10 -2
- package/dist/cjs/ui/Overlay.d.ts +3 -1
- package/dist/cjs/ui/Sheet.d.ts +14 -0
- package/dist/cjs/ui/Spinner.d.ts +2 -1
- package/dist/cjs/utils/cacheUtils.d.ts +14 -0
- package/dist/cjs/utils/fileUtilities.d.ts +10 -1
- package/dist/cjs/utils/mentions.d.ts +6 -0
- package/dist/cjs/utils/openUrl.d.ts +1 -0
- package/dist/css/weavy-chat.css +637 -218
- package/dist/css/weavy-files.css +3046 -0
- package/dist/css/weavy-messenger.css +643 -213
- package/dist/css/weavy-posts.css +2773 -0
- package/dist/css/weavy.css +1749 -308
- package/dist/esm/client/WeavyClient.d.ts +1 -0
- package/dist/esm/components/Attachment.d.ts +5 -5
- package/dist/esm/components/Blob.d.ts +9 -0
- package/dist/esm/components/Comment.d.ts +18 -0
- package/dist/esm/components/CommentCount.d.ts +7 -0
- package/dist/esm/components/CommentEdit.d.ts +16 -0
- package/dist/esm/components/CommentPlaceholder.d.ts +8 -0
- package/dist/esm/components/CommentTrashed.d.ts +15 -0
- package/dist/esm/components/CommentView.d.ts +18 -0
- package/dist/esm/components/Comments.d.ts +8 -0
- package/dist/esm/components/ConversationListItem.d.ts +1 -1
- package/dist/esm/components/Dropzone.d.ts +10 -0
- package/dist/esm/components/Editor.d.ts +25 -0
- package/dist/esm/components/Embed.d.ts +8 -0
- package/dist/esm/components/FileItem.d.ts +41 -0
- package/dist/esm/components/FileList.d.ts +11 -0
- package/dist/esm/components/FileVersions.d.ts +9 -0
- package/dist/esm/components/Files.d.ts +4 -0
- package/dist/esm/components/Image.d.ts +3 -3
- package/dist/esm/components/MeetingCard.d.ts +1 -1
- package/dist/esm/components/Meetings.d.ts +2 -1
- package/dist/esm/components/Poll.d.ts +8 -0
- package/dist/esm/components/PollOption.d.ts +10 -0
- package/dist/esm/components/Post.d.ts +21 -0
- package/dist/esm/components/PostEdit.d.ts +17 -0
- package/dist/esm/components/PostList.d.ts +6 -0
- package/dist/esm/components/PostPlaceholder.d.ts +8 -0
- package/dist/esm/components/PostTrashed.d.ts +14 -0
- package/dist/esm/components/PostView.d.ts +21 -0
- package/dist/esm/components/Posts.d.ts +4 -0
- package/dist/esm/components/Preview.d.ts +1 -3
- package/dist/esm/components/PreviewFiles.d.ts +10 -0
- package/dist/esm/components/Reactions.d.ts +6 -2
- package/dist/esm/components/SearchUsers.d.ts +2 -1
- package/dist/esm/contexts/CloudFilesContext.d.ts +9 -0
- package/dist/esm/hooks/useApps.d.ts +1 -0
- package/dist/esm/hooks/useCloudFiles.d.ts +3 -0
- package/dist/esm/hooks/useCommentList.d.ts +1 -0
- package/dist/esm/hooks/useEmbeds.d.ts +5 -0
- package/dist/esm/hooks/useFileList.d.ts +1 -0
- package/dist/esm/hooks/useFileUploader.d.ts +8 -0
- package/dist/esm/hooks/useFileVersions.d.ts +2 -0
- package/dist/esm/hooks/useInfiniteScroll.d.ts +4 -0
- package/dist/esm/hooks/useIsFirstRender.d.ts +2 -0
- package/dist/esm/hooks/useMutateApps.d.ts +5 -0
- package/dist/esm/hooks/useMutateComment.d.ts +10 -0
- package/dist/esm/hooks/useMutateConversationName.d.ts +1 -1
- package/dist/esm/hooks/useMutateDeleteReaction.d.ts +3 -1
- package/dist/esm/hooks/useMutateEditComment.d.ts +10 -0
- package/dist/esm/hooks/useMutateEditPost.d.ts +10 -0
- package/dist/esm/hooks/useMutateExternalBlobs.d.ts +2 -2
- package/dist/esm/hooks/useMutateFile.d.ts +26 -0
- package/dist/esm/hooks/useMutateFileRename.d.ts +5 -0
- package/dist/esm/hooks/useMutateFileSubscribe.d.ts +7 -0
- package/dist/esm/hooks/useMutateFileTrash.d.ts +10 -0
- package/dist/esm/hooks/useMutateFileVersion.d.ts +7 -0
- package/dist/esm/hooks/useMutateFiles.d.ts +2 -0
- package/dist/esm/hooks/useMutateLeaveConversation.d.ts +4 -0
- package/dist/esm/hooks/useMutateMessage.d.ts +2 -2
- package/dist/esm/hooks/useMutatePost.d.ts +10 -0
- package/dist/esm/hooks/useMutateReaction.d.ts +3 -1
- package/dist/esm/hooks/useMutateRead.d.ts +1 -1
- package/dist/esm/hooks/useMutateReplaceReaction.d.ts +6 -0
- package/dist/esm/hooks/useMutateRestoreComment.d.ts +5 -0
- package/dist/esm/hooks/useMutateRestorePost.d.ts +4 -0
- package/dist/esm/hooks/useMutateStarred.d.ts +4 -0
- package/dist/esm/hooks/useMutateSubscribe.d.ts +4 -0
- package/dist/esm/hooks/useMutateTrashComment.d.ts +5 -0
- package/dist/esm/hooks/useMutateTrashPost.d.ts +4 -0
- package/dist/esm/hooks/useMutateTyping.d.ts +2 -0
- package/dist/esm/hooks/useMutateUnsubscribe.d.ts +4 -0
- package/dist/esm/hooks/useMutateVote.d.ts +5 -0
- package/dist/esm/hooks/usePost.d.ts +1 -0
- package/dist/esm/hooks/usePosts.d.ts +1 -0
- package/dist/esm/hooks/usePostsList.d.ts +1 -0
- package/dist/esm/hooks/useReactionList.d.ts +1 -0
- package/dist/esm/hooks/useSessionState.d.ts +2 -0
- package/dist/esm/hooks/useUnload.d.ts +2 -0
- package/dist/esm/hooks/useUpdateEffect.d.ts +3 -0
- package/dist/esm/hooks/useVotes.d.ts +1 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +28 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/ConversationListItem.d.ts +1 -0
- package/dist/esm/types/Files.d.ts +7 -0
- package/dist/esm/types/Message.d.ts +2 -2
- package/dist/esm/types/Posts.d.ts +4 -0
- package/dist/esm/types/interfaces.d.ts +9 -0
- package/dist/esm/types/types.d.ts +138 -22
- package/dist/esm/ui/Dropdown.d.ts +18 -2
- package/dist/esm/ui/Icon.d.ts +10 -2
- package/dist/esm/ui/Overlay.d.ts +3 -1
- package/dist/esm/ui/Sheet.d.ts +14 -0
- package/dist/esm/ui/Spinner.d.ts +2 -1
- package/dist/esm/utils/cacheUtils.d.ts +14 -0
- package/dist/esm/utils/fileUtilities.d.ts +10 -1
- package/dist/esm/utils/mentions.d.ts +6 -0
- package/dist/esm/utils/openUrl.d.ts +1 -0
- package/dist/index.d.ts +50 -6
- package/package.json +8 -2
- package/src/client/WeavyClient.ts +35 -1
- package/src/components/Attachment.tsx +20 -13
- package/src/components/Blob.tsx +28 -0
- package/src/components/Comment.tsx +43 -0
- package/src/components/CommentCount.tsx +15 -0
- package/src/components/CommentEdit.tsx +48 -0
- package/src/components/CommentPlaceholder.tsx +34 -0
- package/src/components/CommentTrashed.tsx +45 -0
- package/src/components/CommentView.tsx +142 -0
- package/src/components/Comments.tsx +78 -0
- package/src/components/Conversation.tsx +85 -31
- package/src/components/ConversationList.tsx +12 -41
- package/src/components/ConversationListItem.tsx +125 -74
- package/src/components/Dropzone.tsx +26 -0
- package/src/components/Editor.tsx +700 -0
- package/src/components/Embed.tsx +80 -0
- package/src/components/FileItem.tsx +391 -0
- package/src/components/FileList.tsx +166 -0
- package/src/components/FileVersions.tsx +100 -0
- package/src/components/Files.tsx +294 -0
- package/src/components/Image.tsx +11 -10
- package/src/components/Meeting.tsx +1 -2
- package/src/components/MeetingCard.tsx +1 -1
- package/src/components/Meetings.tsx +13 -5
- package/src/components/Message.tsx +14 -19
- package/src/components/Messages.tsx +38 -64
- package/src/components/NewConversation.tsx +8 -6
- package/src/components/PdfViewer.tsx +2 -2
- package/src/components/Poll.tsx +45 -0
- package/src/components/PollOption.tsx +65 -0
- package/src/components/Post.tsx +45 -0
- package/src/components/PostEdit.tsx +49 -0
- package/src/components/PostList.tsx +95 -0
- package/src/components/PostPlaceholder.tsx +32 -0
- package/src/components/PostTrashed.tsx +35 -0
- package/src/components/PostView.tsx +194 -0
- package/src/components/Posts.tsx +59 -0
- package/src/components/Preview.tsx +16 -23
- package/src/components/PreviewFiles.tsx +336 -0
- package/src/components/Reactions.tsx +142 -38
- package/src/components/SearchUsers.tsx +77 -37
- package/src/components/Typing.tsx +1 -1
- package/src/{components/FileBrowser.tsx → contexts/CloudFilesContext.tsx} +46 -30
- package/src/contexts/PreviewContext.tsx +102 -85
- package/src/contexts/WeavyContext.tsx +10 -6
- package/src/hooks/useApps.ts +23 -0
- package/src/hooks/useCloudFiles.ts +12 -0
- package/src/hooks/useCommentList.ts +30 -0
- package/src/hooks/useEmbeds.ts +126 -0
- package/src/hooks/useEvents.ts +3 -1
- package/src/hooks/useFileList.ts +84 -0
- package/src/hooks/useFileUploader.ts +38 -1
- package/src/hooks/useFileVersions.ts +20 -0
- package/src/hooks/useInfiniteScroll.ts +45 -0
- package/src/hooks/useIsFirstRender.ts +15 -0
- package/src/hooks/useMembers.ts +3 -3
- package/src/hooks/useMutateApps.ts +48 -0
- package/src/hooks/useMutateComment.ts +60 -0
- package/src/hooks/useMutateConversationName.ts +1 -1
- package/src/hooks/useMutateDeleteReaction.ts +17 -4
- package/src/hooks/useMutateEditComment.ts +63 -0
- package/src/hooks/useMutateEditPost.ts +64 -0
- package/src/hooks/useMutateExternalBlobs.ts +5 -9
- package/src/hooks/useMutateFile.ts +311 -0
- package/src/hooks/useMutateFileRename.ts +51 -0
- package/src/hooks/useMutateFileSubscribe.ts +80 -0
- package/src/hooks/useMutateFileTrash.ts +115 -0
- package/src/hooks/useMutateFileVersion.ts +85 -0
- package/src/hooks/useMutateFiles.ts +23 -0
- package/src/hooks/useMutateLeaveConversation.ts +38 -0
- package/src/hooks/useMutateMessage.ts +23 -62
- package/src/hooks/useMutatePost.ts +60 -0
- package/src/hooks/useMutateReaction.ts +21 -6
- package/src/hooks/useMutateRead.ts +8 -2
- package/src/hooks/useMutateRemoveMembers.ts +2 -9
- package/src/hooks/useMutateReplaceReaction.ts +59 -0
- package/src/hooks/useMutateRestoreComment.ts +37 -0
- package/src/hooks/useMutateRestorePost.ts +36 -0
- package/src/hooks/useMutateStarred.ts +35 -0
- package/src/hooks/useMutateSubscribe.ts +36 -0
- package/src/hooks/useMutateTrashComment.ts +37 -0
- package/src/hooks/useMutateTrashPost.ts +36 -0
- package/src/hooks/useMutateTyping.ts +5 -3
- package/src/hooks/useMutateUnsubscribe.ts +36 -0
- package/src/hooks/useMutateVote.ts +59 -0
- package/src/hooks/usePost.ts +20 -0
- package/src/hooks/usePosts.ts +21 -0
- package/src/hooks/usePostsList.ts +31 -0
- package/src/hooks/useReactionList.ts +21 -0
- package/src/hooks/useSearchUsers.ts +2 -2
- package/src/hooks/useSessionState.ts +23 -0
- package/src/hooks/useUnload.ts +19 -0
- package/src/hooks/useUpdateEffect.ts +16 -0
- package/src/hooks/useVotes.ts +21 -0
- package/src/index.ts +5 -1
- package/src/scss/theme/_appbar.scss +8 -4
- package/src/scss/theme/_card.scss +2 -0
- package/src/scss/theme/_comment-editor-cm.scss +5 -1
- package/src/scss/theme/_comments.scss +9 -8
- package/src/scss/theme/_conversations.scss +4 -0
- package/src/scss/theme/_files.scss +2 -81
- package/src/scss/theme/_icons.scss +21 -3
- package/src/scss/theme/_input.scss +13 -7
- package/src/scss/theme/_item.scss +23 -1
- package/src/scss/theme/_message-editor-cm.scss +5 -1
- package/src/scss/theme/_pager.scss +1 -1
- package/src/scss/theme/_post-editor-cm.scss +2 -2
- package/src/scss/theme/_post.scss +3 -10
- package/src/scss/theme/_preview-pdf-viewer.scss +996 -0
- package/src/scss/theme/_preview-pdf.scss +57 -783
- package/src/scss/theme/_sheet.scss +4 -1
- package/src/scss/theme/_spinner.scss +10 -1
- package/src/scss/theme/_tables.scss +2 -0
- package/src/scss/theme/base/_scroll.scss +3 -0
- package/src/scss/weavy-chat.scss +3 -1
- package/src/scss/weavy-files.scss +31 -0
- package/src/scss/weavy-messenger.scss +3 -1
- package/src/scss/weavy-posts.scss +35 -0
- package/src/scss/weavy.scss +2 -0
- package/src/types/ConversationListItem.ts +1 -0
- package/src/types/Files.ts +7 -0
- package/src/types/Message.ts +2 -2
- package/src/types/Posts.ts +4 -0
- package/src/types/interfaces.ts +13 -0
- package/src/types/types.ts +157 -28
- package/src/ui/Button.tsx +6 -5
- package/src/ui/Dropdown.tsx +67 -16
- package/src/ui/Icon.tsx +112 -15
- package/src/ui/Overlay.tsx +6 -2
- package/src/ui/Sheet.tsx +87 -0
- package/src/ui/Spinner.tsx +7 -4
- package/src/utils/cacheUtils.ts +246 -0
- package/src/utils/fileUtilities.ts +208 -24
- package/src/utils/infinite-scroll.js +103 -0
- package/src/utils/mentions.ts +50 -0
- package/src/utils/openUrl.ts +41 -0
- package/src/utils/{scrollToBottom.js → scroll-position.js} +50 -9
- package/src/utils/{scrollbarDetection.js → scrollbar-detection.js} +0 -0
- package/src/utils/utils.js +15 -1
- package/tsconfig.json +1 -1
- package/dist/cjs/components/ConversationForm.d.ts +0 -7
- package/dist/cjs/components/File.d.ts +0 -9
- package/dist/cjs/components/FileBrowser.d.ts +0 -6
- package/dist/cjs/hooks/usePreview.d.ts +0 -4
- package/dist/cjs/hooks/useReactions.d.ts +0 -3
- package/dist/esm/components/ConversationForm.d.ts +0 -7
- package/dist/esm/components/File.d.ts +0 -9
- package/dist/esm/components/FileBrowser.d.ts +0 -6
- package/dist/esm/hooks/usePreview.d.ts +0 -4
- package/dist/esm/hooks/useReactions.d.ts +0 -3
- package/src/components/ConversationForm.tsx +0 -210
- package/src/components/File.tsx +0 -21
- package/src/hooks/usePreview.ts +0 -21
- package/src/hooks/useReactions.ts +0 -51
- package/src/utils/infiniteScroll.js +0 -184
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isConstructorDeclaration } from "typescript";
|
|
1
|
+
import { getAllJSDocTagsOfKind, isConstructorDeclaration } from "typescript";
|
|
2
2
|
|
|
3
|
-
export const fileSizeAsString = (size: number) => {
|
|
3
|
+
export const fileSizeAsString = (size: number, significantDigits: number = 3) => {
|
|
4
4
|
var s = size;
|
|
5
5
|
var format = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"];
|
|
6
6
|
var i = 0;
|
|
@@ -8,14 +8,15 @@ export const fileSizeAsString = (size: number) => {
|
|
|
8
8
|
s = (100 * s / 1024) / 100.0;
|
|
9
9
|
i++;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
return s.toLocaleString(undefined, { maximumSignificantDigits: significantDigits }) + format[i];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export function getExtension
|
|
15
|
-
return name.substring(name.lastIndexOf('.')
|
|
15
|
+
export function getExtension(name: string) {
|
|
16
|
+
return (name.substring(name.lastIndexOf('.'), name.length) || name).toLowerCase();
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export function isAudio
|
|
19
|
+
export function isAudio(ext: string) {
|
|
19
20
|
switch (ext) {
|
|
20
21
|
case ".aac":
|
|
21
22
|
case ".aif":
|
|
@@ -41,7 +42,7 @@ export function isAudio (ext: string) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export function isImage
|
|
45
|
+
export function isImage(ext: string) {
|
|
45
46
|
switch (ext) {
|
|
46
47
|
case ".ai":
|
|
47
48
|
case ".apng":
|
|
@@ -66,7 +67,7 @@ export function isImage (ext: string) {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
export function isWebImage
|
|
70
|
+
export function isWebImage(path: string) {
|
|
70
71
|
// see https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
|
71
72
|
var ext = getExtension(path);
|
|
72
73
|
switch (ext) {
|
|
@@ -113,7 +114,7 @@ export function isMetaFile(path: string) {
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export function isVideo
|
|
117
|
+
export function isVideo(ext: string) {
|
|
117
118
|
switch (ext) {
|
|
118
119
|
case ".3g2":
|
|
119
120
|
case ".asx":
|
|
@@ -144,7 +145,7 @@ export function isVideo (ext: string) {
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
export function isMarkdown
|
|
148
|
+
export function isMarkdown(ext: string) {
|
|
148
149
|
switch (ext) {
|
|
149
150
|
case ".markdown":
|
|
150
151
|
case ".md":
|
|
@@ -154,7 +155,7 @@ export function isMarkdown (ext: string) {
|
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
export function isMarkup
|
|
158
|
+
export function isMarkup(ext: string) {
|
|
158
159
|
switch (ext) {
|
|
159
160
|
case ".htm":
|
|
160
161
|
case ".html":
|
|
@@ -166,7 +167,7 @@ export function isMarkup (ext: string) {
|
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
export function isCode
|
|
170
|
+
export function isCode(ext: string) {
|
|
170
171
|
if (isMarkup(ext)) {
|
|
171
172
|
return true;
|
|
172
173
|
}
|
|
@@ -233,7 +234,7 @@ export function isCode (ext: string) {
|
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
export function isText
|
|
237
|
+
export function isText(ext: string) {
|
|
237
238
|
if (isCode(ext) || isMarkdown(ext)) {
|
|
238
239
|
return true;
|
|
239
240
|
}
|
|
@@ -267,7 +268,7 @@ export function isOfficeDocument(path: string) {
|
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
270
|
|
|
270
|
-
export function getIcon
|
|
271
|
+
export function getIcon(name: string, mediaType?: string): { icon: string, color?: string } {
|
|
271
272
|
var ext = getExtension(name);
|
|
272
273
|
|
|
273
274
|
if (ext === "") return { icon: "file" };
|
|
@@ -284,41 +285,224 @@ export function getIcon (name: string, mediaType?: string): { icon: string, colo
|
|
|
284
285
|
return { icon: "file-code", color: "purple" };
|
|
285
286
|
} else if (isText(ext)) {
|
|
286
287
|
return { icon: "file-document" };
|
|
287
|
-
} else{
|
|
288
|
+
} else {
|
|
288
289
|
switch (ext) {
|
|
289
290
|
case ".7z":
|
|
290
291
|
case ".zip":
|
|
291
|
-
return { icon: "file-compressed", color: "orange"};
|
|
292
|
+
return { icon: "file-compressed", color: "orange" };
|
|
292
293
|
case ".doc":
|
|
293
294
|
case ".docm":
|
|
294
295
|
case ".docx":
|
|
295
296
|
case ".dotm":
|
|
296
297
|
case ".dotx":
|
|
297
|
-
return { icon: "file-word", color: "native"};
|
|
298
|
+
return { icon: "file-word", color: "native" };
|
|
298
299
|
case ".eml":
|
|
299
300
|
case ".msg":
|
|
300
|
-
return { icon: "email", color: ""};
|
|
301
|
+
return { icon: "email", color: "" };
|
|
301
302
|
case ".xls":
|
|
302
303
|
case ".xlsm":
|
|
303
304
|
case ".xlsx":
|
|
304
305
|
case ".xltx":
|
|
305
|
-
return { icon: "file-excel", color: "native"};
|
|
306
|
+
return { icon: "file-excel", color: "native" };
|
|
306
307
|
case ".pdf":
|
|
307
|
-
return { icon: "file-pdf", color: "native"};
|
|
308
|
+
return { icon: "file-pdf", color: "native" };
|
|
308
309
|
case ".ppt":
|
|
309
310
|
case ".pptm":
|
|
310
311
|
case ".pptx":
|
|
311
312
|
case ".potx":
|
|
312
|
-
return { icon: "file-powerpoint", color: "native"};
|
|
313
|
+
return { icon: "file-powerpoint", color: "native" };
|
|
313
314
|
case ".pages":
|
|
314
|
-
return { icon: "file", color: "orange"};
|
|
315
|
+
return { icon: "file", color: "orange" };
|
|
315
316
|
case ".numbers":
|
|
316
|
-
return { icon: "file", color: "green"};
|
|
317
|
+
return { icon: "file", color: "green" };
|
|
317
318
|
case ".keynote":
|
|
318
|
-
return { icon: "file", color: "blue"};
|
|
319
|
+
return { icon: "file", color: "blue" };
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
// fallback
|
|
323
324
|
return { icon: "file" };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Returns preview formats that can be rendered directly in the browser
|
|
329
|
+
*
|
|
330
|
+
* @param {string} name - Name of the file
|
|
331
|
+
* @returns PreviewFormatType
|
|
332
|
+
*/
|
|
333
|
+
export function getWebPreviewFormat(name: string): PreviewFormatType {
|
|
334
|
+
var ext = getExtension(name);
|
|
335
|
+
|
|
336
|
+
if (ext === "") return "none";
|
|
337
|
+
|
|
338
|
+
// TODO: Handle embed?
|
|
339
|
+
|
|
340
|
+
if (isWebImage(ext)) {
|
|
341
|
+
return "image";
|
|
342
|
+
} else if (isCode(ext)) {
|
|
343
|
+
return "code";
|
|
344
|
+
} else if (isText(ext)) {
|
|
345
|
+
return "text";
|
|
346
|
+
} else if (isAudio(ext)) {
|
|
347
|
+
return "audio";
|
|
348
|
+
} else if (isVideo(ext)) {
|
|
349
|
+
return "video";
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return "none";
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function getProvider(provider: string | undefined): ProviderType | "" {
|
|
356
|
+
switch (provider) {
|
|
357
|
+
case "Google Drive":
|
|
358
|
+
return "google-drive";
|
|
359
|
+
case "Dropbox":
|
|
360
|
+
return "dropbox";
|
|
361
|
+
case "OneDrive":
|
|
362
|
+
return "onedrive";
|
|
363
|
+
case "Box":
|
|
364
|
+
return "box";
|
|
365
|
+
default:
|
|
366
|
+
return "";
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export function getKind(name: string): FileKindType {
|
|
371
|
+
var kind: FileKindType = "file";
|
|
372
|
+
var ext = getExtension(name);
|
|
373
|
+
|
|
374
|
+
switch (ext) {
|
|
375
|
+
case ".7z":
|
|
376
|
+
case ".zip":
|
|
377
|
+
kind = "archive";
|
|
378
|
+
break;
|
|
379
|
+
case ".aac":
|
|
380
|
+
case ".aif":
|
|
381
|
+
case ".aiff":
|
|
382
|
+
case ".au":
|
|
383
|
+
case ".gsm":
|
|
384
|
+
case ".m4a":
|
|
385
|
+
case ".mid":
|
|
386
|
+
case ".midi":
|
|
387
|
+
case ".mka":
|
|
388
|
+
case ".mp3":
|
|
389
|
+
case ".oga":
|
|
390
|
+
case ".ogg":
|
|
391
|
+
case ".ra":
|
|
392
|
+
case ".ram":
|
|
393
|
+
case ".snd":
|
|
394
|
+
case ".spx":
|
|
395
|
+
case ".wav":
|
|
396
|
+
case ".wma":
|
|
397
|
+
kind = "audio";
|
|
398
|
+
break;
|
|
399
|
+
case ".c":
|
|
400
|
+
case ".cgi":
|
|
401
|
+
case ".cpp":
|
|
402
|
+
case ".cs":
|
|
403
|
+
case ".cshtml":
|
|
404
|
+
case ".css":
|
|
405
|
+
case ".html":
|
|
406
|
+
case ".java":
|
|
407
|
+
case ".js":
|
|
408
|
+
case ".json":
|
|
409
|
+
case ".less":
|
|
410
|
+
case ".php":
|
|
411
|
+
case ".pl":
|
|
412
|
+
case ".ps1":
|
|
413
|
+
case ".py":
|
|
414
|
+
case ".rb":
|
|
415
|
+
case ".rs":
|
|
416
|
+
case ".scss":
|
|
417
|
+
case ".sh":
|
|
418
|
+
case ".swift":
|
|
419
|
+
case ".sql":
|
|
420
|
+
case ".ts":
|
|
421
|
+
case ".xml":
|
|
422
|
+
case ".yaml":
|
|
423
|
+
case ".yml":
|
|
424
|
+
kind = "code";
|
|
425
|
+
break;
|
|
426
|
+
case ".doc":
|
|
427
|
+
case ".docm":
|
|
428
|
+
case ".docx":
|
|
429
|
+
case ".dotm":
|
|
430
|
+
case ".dotx":
|
|
431
|
+
case ".gdoc":
|
|
432
|
+
case ".pages":
|
|
433
|
+
case ".pdf":
|
|
434
|
+
kind = "document";
|
|
435
|
+
break;
|
|
436
|
+
case ".eml":
|
|
437
|
+
case ".msg":
|
|
438
|
+
kind = "email";
|
|
439
|
+
break;
|
|
440
|
+
case ".gslides":
|
|
441
|
+
case ".keynote":
|
|
442
|
+
case ".ppt":
|
|
443
|
+
case ".pptm":
|
|
444
|
+
case ".pptx":
|
|
445
|
+
case ".potx":
|
|
446
|
+
kind = "presentation";
|
|
447
|
+
break;
|
|
448
|
+
case ".gsheet":
|
|
449
|
+
case ".numbers":
|
|
450
|
+
case ".xls":
|
|
451
|
+
case ".xlsm":
|
|
452
|
+
case ".xlsx":
|
|
453
|
+
case ".xltx":
|
|
454
|
+
kind = "spreadsheet";
|
|
455
|
+
break;
|
|
456
|
+
case ".ai":
|
|
457
|
+
case ".apng":
|
|
458
|
+
case ".bmp":
|
|
459
|
+
case ".emf":
|
|
460
|
+
case ".eps":
|
|
461
|
+
case ".gif":
|
|
462
|
+
case ".heic":
|
|
463
|
+
case ".ico":
|
|
464
|
+
case ".jpg":
|
|
465
|
+
case ".jpeg":
|
|
466
|
+
case ".png":
|
|
467
|
+
case ".psd":
|
|
468
|
+
case ".svg":
|
|
469
|
+
case ".tif":
|
|
470
|
+
case ".tiff":
|
|
471
|
+
case ".webp":
|
|
472
|
+
case ".wmf":
|
|
473
|
+
kind = "image";
|
|
474
|
+
break;
|
|
475
|
+
case ".md":
|
|
476
|
+
case ".markdown":
|
|
477
|
+
case ".txt":
|
|
478
|
+
kind = "text";
|
|
479
|
+
break;
|
|
480
|
+
case ".3g2":
|
|
481
|
+
case ".asx":
|
|
482
|
+
case ".asf":
|
|
483
|
+
case ".avi":
|
|
484
|
+
case ".flv":
|
|
485
|
+
case ".mk3d":
|
|
486
|
+
case ".mkv":
|
|
487
|
+
case ".mov":
|
|
488
|
+
case ".mp4":
|
|
489
|
+
case ".mpeg":
|
|
490
|
+
case ".mpg":
|
|
491
|
+
case ".ogm":
|
|
492
|
+
case ".ogv":
|
|
493
|
+
case ".ogx":
|
|
494
|
+
case ".qt":
|
|
495
|
+
case ".rm":
|
|
496
|
+
case ".rv":
|
|
497
|
+
case ".smi":
|
|
498
|
+
case ".smil":
|
|
499
|
+
case ".swf":
|
|
500
|
+
case ".webm":
|
|
501
|
+
case ".wmv":
|
|
502
|
+
case ".xaml":
|
|
503
|
+
kind = "video";
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return kind;
|
|
324
508
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { getNextPositionedChild, getScrollParent } from "./scroll-position"
|
|
2
|
+
|
|
3
|
+
const THRESHOLD = 0; // as soon as even one pixel is visible, the callback will be run
|
|
4
|
+
const ROOT_MARGIN = "24px"; // margin around the root, used to grow or shrink the root element's bounding box before computing intersections
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new regular scroll listener
|
|
8
|
+
*
|
|
9
|
+
* @param {Element} observeElement
|
|
10
|
+
* @param {Function} whenNext
|
|
11
|
+
* @returns IntersectionObserver
|
|
12
|
+
*/
|
|
13
|
+
export function createScroller(observeElement, whenNext, reverse = false) {
|
|
14
|
+
// inverted infinite scroll (e.g. for messages)
|
|
15
|
+
let prevSleep = false;
|
|
16
|
+
|
|
17
|
+
//console.log("creating reverse scroller");
|
|
18
|
+
var parent = getScrollParent(observeElement);
|
|
19
|
+
|
|
20
|
+
// Disable scroll anchoring https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor/Guide_to_scroll_anchoring
|
|
21
|
+
parent.style.overflowAnchor = "none";
|
|
22
|
+
|
|
23
|
+
// Bug using scrollingElement in frames. See https://github.com/w3c/IntersectionObserver/issues/372
|
|
24
|
+
var intersectionParent = (parent === document.documentElement ? document : parent);
|
|
25
|
+
|
|
26
|
+
whenNext ??= () => Promise.reject(new Error("No reverse scroller handler function defined")); // default
|
|
27
|
+
|
|
28
|
+
const scrollObserver = new IntersectionObserver((entries, observer) => {
|
|
29
|
+
entries.forEach(function (entry) {
|
|
30
|
+
if (entry.isIntersecting && !prevSleep) {
|
|
31
|
+
prevSleep = true;
|
|
32
|
+
|
|
33
|
+
// find first child (that is regularly positioned)
|
|
34
|
+
if (reverse) {
|
|
35
|
+
var nextPositionedChild = getNextPositionedChild(entry.target);
|
|
36
|
+
var prevScrollHeight = parent.scrollHeight;
|
|
37
|
+
var childOffsetBefore = nextPositionedChild.offsetTop;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let afterNext = () => {
|
|
41
|
+
queueMicrotask(() => { // Place last in microtask queue
|
|
42
|
+
// scroll parent so that first child remains in the same position as before
|
|
43
|
+
// NOTE: when this is called via observer we need to requestAnimationFrame, otherwise scrolling happens to fast (before the DOM has been updated)
|
|
44
|
+
if (prevScrollHeight !== parent.scrollHeight) {
|
|
45
|
+
// layout already rendered
|
|
46
|
+
//console.log("infinite scroll updated instantly");
|
|
47
|
+
if (reverse) {
|
|
48
|
+
let diff = nextPositionedChild.offsetTop - childOffsetBefore;
|
|
49
|
+
parent.scrollTop += diff;
|
|
50
|
+
}
|
|
51
|
+
requestAnimationFrame(() => prevSleep = false);
|
|
52
|
+
} else {
|
|
53
|
+
queueMicrotask(() => {
|
|
54
|
+
if (prevScrollHeight !== parent.scrollHeight) {
|
|
55
|
+
// layout rendered after
|
|
56
|
+
//console.log("infinite scroll updated by microtask");
|
|
57
|
+
if (reverse) {
|
|
58
|
+
let diff = nextPositionedChild.offsetTop - childOffsetBefore;
|
|
59
|
+
parent.scrollTop += diff;
|
|
60
|
+
}
|
|
61
|
+
requestAnimationFrame(() => prevSleep = false);
|
|
62
|
+
} else {
|
|
63
|
+
// layout not rendered yet
|
|
64
|
+
requestAnimationFrame(() => {
|
|
65
|
+
//console.log("infinite scroll updated by animationframe", diff);
|
|
66
|
+
if (reverse) {
|
|
67
|
+
let diff = nextPositionedChild.offsetTop - childOffsetBefore;
|
|
68
|
+
parent.scrollTop += diff;
|
|
69
|
+
}
|
|
70
|
+
requestAnimationFrame(() => prevSleep = false);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
let whenNextResult = whenNext();
|
|
79
|
+
|
|
80
|
+
if (whenNextResult) {
|
|
81
|
+
whenNextResult.then(afterNext);
|
|
82
|
+
} else {
|
|
83
|
+
afterNext();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}, { root: intersectionParent, threshold: THRESHOLD, rootMargin: ROOT_MARGIN });
|
|
88
|
+
|
|
89
|
+
scrollObserver.observe(observeElement);
|
|
90
|
+
|
|
91
|
+
return scrollObserver;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new reverse scroll listener
|
|
96
|
+
*
|
|
97
|
+
* @param {Element} observeElement
|
|
98
|
+
* @param {Function} whenNext
|
|
99
|
+
* @returns IntersectionObserver
|
|
100
|
+
*/
|
|
101
|
+
export function createReverseScroller(observeElement, whenNext) {
|
|
102
|
+
return createScroller(observeElement, whenNext, true);
|
|
103
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EditorView, MatchDecorator, Decoration, ViewPlugin, WidgetType, ViewUpdate } from "@codemirror/view"
|
|
2
|
+
import { RangeSet } from "@codemirror/state"
|
|
3
|
+
|
|
4
|
+
const mentionMatcher = new MatchDecorator({
|
|
5
|
+
regexp: /(\[(.+?)\])(\(@u(\d+)\))/g,
|
|
6
|
+
decoration: match => Decoration.replace({
|
|
7
|
+
// NOTE: can't use backspace to go "up one row" when inclusive is false
|
|
8
|
+
inclusive: true,
|
|
9
|
+
widget: new MentionWidget(match)
|
|
10
|
+
})
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
class MentionWidget extends WidgetType {
|
|
14
|
+
|
|
15
|
+
match: RegExpExecArray;
|
|
16
|
+
|
|
17
|
+
constructor(match: RegExpExecArray) {
|
|
18
|
+
super();
|
|
19
|
+
this.match = match;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
eq(other: MentionWidget) {
|
|
23
|
+
return other.match[1] === this.match[1];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toDOM() {
|
|
27
|
+
let wrap = document.createElement("span");
|
|
28
|
+
wrap.className = "wy-mention";
|
|
29
|
+
wrap.innerHTML = typeof (this.match[5]) !== "undefined" ? this.match[5] : this.match[2];
|
|
30
|
+
return wrap
|
|
31
|
+
}
|
|
32
|
+
ignoreEvent() { return false }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const mentions = ViewPlugin.fromClass(class {
|
|
36
|
+
|
|
37
|
+
mentions: RangeSet<Decoration>;
|
|
38
|
+
|
|
39
|
+
constructor(view: EditorView) {
|
|
40
|
+
this.mentions = mentionMatcher.createDeco(view)
|
|
41
|
+
}
|
|
42
|
+
update(update: ViewUpdate) {
|
|
43
|
+
this.mentions = mentionMatcher.updateDeco(update, this.mentions)
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
decorations: instance => instance.mentions,
|
|
47
|
+
provide: plugin => EditorView.atomicRanges.of(view => {
|
|
48
|
+
return view.plugin(plugin)?.mentions || Decoration.none
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export default function openUrl(url: string = "", target: string = "", name: string = "", download: boolean = false) {
|
|
2
|
+
if (url) {
|
|
3
|
+
// a is needed for downloading object urls
|
|
4
|
+
const a = document.createElement('a');
|
|
5
|
+
|
|
6
|
+
if (download) {
|
|
7
|
+
if(/^(data:|blob:)/.test(url)) {
|
|
8
|
+
// Only set download param for files not from server
|
|
9
|
+
a.download = name || 'download'
|
|
10
|
+
} else {
|
|
11
|
+
// add download parameter, needed for CORS downloads
|
|
12
|
+
url = url.includes("?d=1") || url.includes("&d=1") ? url : url.includes("?") ? url + "&d=1" : url + "?d=1";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (target) {
|
|
17
|
+
a.target = target;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
a.href = url;
|
|
21
|
+
|
|
22
|
+
document.body.appendChild(a);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
a.click();
|
|
26
|
+
} catch(e) {
|
|
27
|
+
console.warn("Could not open link normally, trying fallback");
|
|
28
|
+
if (!/^(?:blob:|data:)/.test(url)) {
|
|
29
|
+
try {
|
|
30
|
+
window.open(url, target);
|
|
31
|
+
} catch(e) {
|
|
32
|
+
console.error(`Could not ${download ? "download" : "open" } ${name}`)
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
console.error(`Could not ${download ? "download" : "open" } ${name}`)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
document.body.removeChild(a);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Gets the next positioned child relative to the element.
|
|
4
|
+
*
|
|
5
|
+
* @param {Element} el - Reference element in the scrollable area
|
|
6
|
+
* @returns Element
|
|
7
|
+
*/
|
|
8
|
+
export function getNextPositionedChild(el) {
|
|
9
|
+
while (el) {
|
|
10
|
+
el = el.nextElementSibling;
|
|
11
|
+
if (/absolute|sticky|fixed/.test(getComputedStyle(el).position) === false) {
|
|
12
|
+
return el;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/**
|
|
2
18
|
* Finds the nearest scrollable area. Defaults to document.scrollingElement.
|
|
3
19
|
*
|
|
@@ -41,9 +57,9 @@ export function isParentAtBottom(element, bottomThreshold) {
|
|
|
41
57
|
bottomThreshold ??= 32; // Minimum 1 to catch float errors
|
|
42
58
|
|
|
43
59
|
let area = getScrollParent(element);
|
|
44
|
-
|
|
60
|
+
|
|
45
61
|
// We need to account for scrollTop being a float
|
|
46
|
-
return Math.abs((area.scrollTop + area.clientHeight) - area.scrollHeight)
|
|
62
|
+
return Math.abs((area.scrollTop + area.clientHeight) - area.scrollHeight) < bottomThreshold;
|
|
47
63
|
}
|
|
48
64
|
return false;
|
|
49
65
|
}
|
|
@@ -54,22 +70,47 @@ export function isParentAtBottom(element, bottomThreshold) {
|
|
|
54
70
|
* @param {Element?} element - Element in the scroll area
|
|
55
71
|
* @param {boolean} [smooth] - Use smooth scrolling instead of instant scrolling
|
|
56
72
|
*/
|
|
57
|
-
export function scrollParentToBottom(element, smooth) {
|
|
73
|
+
export async function scrollParentToBottom(element, smooth) {
|
|
58
74
|
if (element) {
|
|
59
75
|
let area = getScrollParent(element);
|
|
60
|
-
//console.log("scrolling to bottom", area.scrollHeight);
|
|
76
|
+
//console.log("scrolling to bottom", {scrollTop: area.scrollTop, clientHeight: area.clientHeight, scrollHeight: area.scrollHeight}, (area.scrollTop + area.clientHeight) - area.scrollHeight);
|
|
61
77
|
|
|
62
78
|
// Don't bother if the scroll already is correct
|
|
63
|
-
|
|
79
|
+
// We need to account for scrollTop being a float by using 1px diff
|
|
80
|
+
if (Math.abs((area.scrollTop + area.clientHeight) - area.scrollHeight) > 1) {
|
|
64
81
|
if (smooth) {
|
|
65
82
|
area.scrollTo({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
top: area.scrollHeight,
|
|
84
|
+
left: 0,
|
|
85
|
+
behavior: 'smooth'
|
|
69
86
|
});
|
|
70
87
|
} else {
|
|
71
88
|
area.scrollTop = area.scrollHeight;
|
|
72
89
|
}
|
|
73
90
|
}
|
|
91
|
+
|
|
92
|
+
// Check when the scroll is done
|
|
93
|
+
await new Promise((resolve) => {
|
|
94
|
+
let lastScrollTop = area.scrollTop;
|
|
95
|
+
let scrollCheck = () => {
|
|
96
|
+
if (smooth && area.scrollTop === lastScrollTop) {
|
|
97
|
+
//console.log("smooth scroll interrupted, performing unsmooth scroll instead");
|
|
98
|
+
area.scrollTop = area.scrollHeight;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
lastScrollTop = area.scrollTop;
|
|
102
|
+
|
|
103
|
+
// We need to account for scrollTop being a float by using 1px diff
|
|
104
|
+
if (Math.abs((area.scrollTop + area.clientHeight) - area.scrollHeight) > 1) {
|
|
105
|
+
requestAnimationFrame(scrollCheck);
|
|
106
|
+
} else {
|
|
107
|
+
resolve();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
requestAnimationFrame(scrollCheck);
|
|
112
|
+
})
|
|
113
|
+
//console.log("scrolltoBottom done")
|
|
74
114
|
}
|
|
75
|
-
}
|
|
115
|
+
}
|
|
116
|
+
|
|
File without changes
|
package/src/utils/utils.js
CHANGED
|
@@ -237,7 +237,7 @@ export function sanitizeJSON(key, value) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
|
-
* Changes a string to snake_case from camelCase, PascalCase and spinal-case.
|
|
240
|
+
* Changes a string to snake_case from camelCase, PascalCase and spinal-case/kebab-case.
|
|
241
241
|
*
|
|
242
242
|
* @param {string} str - The string to change to snake case
|
|
243
243
|
* @returns {string} The processed string as snake_case
|
|
@@ -250,6 +250,20 @@ export function toSnakeCase(str) {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Changes a string to kebab-case/spinal-case from camelCase, PascalCase and snake_case.
|
|
255
|
+
*
|
|
256
|
+
* @param {string} str - The string to change to kebab case
|
|
257
|
+
* @returns {string} The processed string as kebab-case
|
|
258
|
+
*/
|
|
259
|
+
export function toKebabCase(str) {
|
|
260
|
+
if (str.length > 0) {
|
|
261
|
+
return str.replace(/([a-z\d])([A-Z]+)/g, '$1-$2').replace(/_|\s+/g, '-').toLowerCase();
|
|
262
|
+
} else {
|
|
263
|
+
return str;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
253
267
|
/**
|
|
254
268
|
* Changes a string to camelCase from PascalCase, spinal-case and snake_case.
|
|
255
269
|
*
|
package/tsconfig.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
14
|
+
"target": "es2019", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
15
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
16
|
"jsx": "react", /* Specify what JSX code is generated. */
|
|
17
17
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|