@ynput/ayon-frontend-shared 0.2.9 → 0.2.10
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/dist/_virtual/index.cjs5.js +3 -5
- package/dist/_virtual/index.cjs5.js.map +1 -1
- package/dist/_virtual/index.cjs6.js +5 -3
- package/dist/_virtual/index.cjs6.js.map +1 -1
- package/dist/_virtual/index.es5.js +2 -5
- package/dist/_virtual/index.es5.js.map +1 -1
- package/dist/_virtual/index.es6.js +5 -2
- package/dist/_virtual/index.es6.js.map +1 -1
- package/dist/node_modules/rehype-prism-plus/dist/index.es.cjs.js +1 -1
- package/dist/node_modules/rehype-prism-plus/dist/index.es.es.js +1 -1
- package/dist/node_modules/remove-accents/index.cjs.js +1 -1
- package/dist/node_modules/remove-accents/index.es.js +1 -1
- package/dist/shared/src/containers/Feed/Feed.cjs.js +21 -2
- package/dist/shared/src/containers/Feed/Feed.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/Feed.es.js +22 -3
- package/dist/shared/src/containers/Feed/Feed.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.cjs.js +18 -0
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.es.js +19 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.cjs.js +7 -4
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.es.js +7 -4
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/helpers.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/helpers.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.es.js +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.cjs.js +27 -15
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.es.js +27 -15
- package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.cjs.js +40 -12
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.es.js +41 -13
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.styled.cjs.js +33 -19
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.styled.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.styled.es.js +33 -19
- package/dist/shared/src/containers/Feed/components/FileUploadCard/FileUploadCard.styled.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/FilesGrid/FilesGrid.cjs.js +14 -12
- package/dist/shared/src/containers/Feed/components/FilesGrid/FilesGrid.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/FilesGrid/FilesGrid.es.js +14 -12
- package/dist/shared/src/containers/Feed/components/FilesGrid/FilesGrid.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/Tooltips/EntityTooltip/EntityTooltip.cjs.js +8 -8
- package/dist/shared/src/containers/Feed/components/Tooltips/EntityTooltip/EntityTooltip.es.js +8 -8
- package/dist/shared/src/containers/Feed/helpers/mergeAnnotationAttachments.cjs.js +18 -0
- package/dist/shared/src/containers/Feed/helpers/mergeAnnotationAttachments.cjs.js.map +1 -0
- package/dist/shared/src/containers/Feed/helpers/mergeAnnotationAttachments.es.js +19 -0
- package/dist/shared/src/containers/Feed/helpers/mergeAnnotationAttachments.es.js.map +1 -0
- package/dist/shared/src/containers/Feed/hooks/useCommentMutations.cjs.js +12 -3
- package/dist/shared/src/containers/Feed/hooks/useCommentMutations.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/hooks/useCommentMutations.es.js +12 -3
- package/dist/shared/src/containers/Feed/hooks/useCommentMutations.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/hooks/useTransformActivities.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/hooks/useTransformActivities.es.js.map +1 -1
- package/dist/shared/src/context/DetailsPanelContext.cjs.js +3 -0
- package/dist/shared/src/context/DetailsPanelContext.cjs.js.map +1 -1
- package/dist/shared/src/context/DetailsPanelContext.es.js +3 -0
- package/dist/shared/src/context/DetailsPanelContext.es.js.map +1 -1
- package/dist/types/containers/Feed/components/CommentInput/CommentInput.d.ts +1 -1
- package/dist/types/containers/Feed/components/CommentInput/helpers.d.ts +6 -1
- package/dist/types/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.d.ts +1 -1
- package/dist/types/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.d.ts +5 -1
- package/dist/types/containers/Feed/components/FileUploadCard/FileUploadCard.d.ts +5 -2
- package/dist/types/containers/Feed/components/FileUploadCard/FileUploadCard.styled.d.ts +4 -0
- package/dist/types/containers/Feed/components/FilesGrid/FilesGrid.d.ts +1 -1
- package/dist/types/containers/Feed/helpers/mergeAnnotationAttachments.d.ts +2 -0
- package/dist/types/containers/Feed/hooks/useCommentMutations.d.ts +1 -1
- package/dist/types/containers/Feed/index.d.ts +6 -0
- package/dist/types/context/DetailsPanelContext.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentInput.cjs.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/CommentInput.tsx"],"sourcesContent":["// React and related hooks\nimport React, { FC, useEffect, useMemo, useRef, useState } from 'react'\n\n// Third-party libraries\nimport clsx from 'clsx'\nimport { toast } from 'react-toastify'\nimport ReactQuill, { Quill } from 'react-quill-ayon'\n\n// Components\nimport { Button, Icon, SaveButton } from '@ynput/ayon-react-components'\nimport CommentMentionSelect from '../CommentMentionSelect/CommentMentionSelect'\nimport InputMarkdownConvert from './InputMarkdownConvert'\nimport FilesGrid from '../FilesGrid'\n\n// Styled components\nimport * as Styled from './CommentInput.styled'\n\n// Helpers and utilities\nimport getMentionOptions from '../../mentionHelpers/getMentionOptions'\nimport getMentionUsers from '../../mentionHelpers/getMentionUsers'\nimport getMentionTasks from '../../mentionHelpers/getMentionTasks'\nimport getMentionVersions from '../../mentionHelpers/getMentionVersions'\nimport { convertToMarkdown } from './quillToMarkdown'\nimport { handleFileDrop, parseImages, typeWithDelay } from './helpers'\nimport { getModules, quillFormats } from './modules'\n\n// Hooks\nimport useInitialValue from './hooks/useInitialValue'\nimport useSetCursorEnd from './hooks/useSetCursorEnd'\nimport useMentionLink from './hooks/useMentionLink'\nimport useAnnotationsSync from './hooks/useAnnotationsSync'\n\n// State management\nimport useAnnotationsUpload from './hooks/useAnnotationsUpload'\nimport { useFeedContext } from '../../context/FeedContext'\n\nvar Delta = Quill.import('delta')\n\nconst mentionTypes = ['@', '@@', '@@@']\nexport const mentionTypeOptions = {\n '@@@': {\n id: 'task',\n },\n '@@': {\n id: 'version',\n },\n '@': {\n id: 'user',\n isCircle: true,\n },\n}\n\ninterface CommentInputProps {\n initValue: string | null\n initFiles?: any[]\n onSubmit: (markdown: string, files: any[]) => Promise<void>\n isEditing?: boolean\n disabled?: boolean\n isLoading?: boolean\n isOpen: boolean\n onOpen?: () => void\n onClose?: () => void\n}\n\nconst CommentInput: FC<CommentInputProps> = ({\n initValue,\n initFiles = [],\n onSubmit,\n isEditing,\n disabled,\n isLoading,\n isOpen,\n onOpen,\n onClose,\n}) => {\n const { projectName, entities, projectInfo, scope, currentTab, mentionSuggestionsData } =\n useFeedContext()\n\n const {\n users: mentionUsers,\n versions: mentionVersions,\n tasks: mentionTasks,\n } = mentionSuggestionsData || {}\n\n const [initHeight, setInitHeight] = useState(88)\n const [editorValue, setEditorValue] = useState('')\n // file uploads\n const [files, setFiles] = useState(initFiles)\n const [filesUploading, setFilesUploading] = useState([])\n const [isDropping, setIsDropping] = useState(false)\n const [isSubmitting, setIsSubmitting] = useState(false)\n\n const { annotations, removeAnnotation, goToAnnotation } = useAnnotationsSync({\n entityId: entities[0]?.id,\n filesUploading,\n })\n\n // MENTION STATES\n const [mention, setMention] = useState<null | any>(null)\n const [mentionSelectedIndex, setMentionSelectedIndex] = useState(0)\n // REFS\n const editorRef = useRef<any>(null)\n const markdownRef = useRef<HTMLDivElement>(null)\n\n // if there is an initial value, set it so the editor is prefilled\n useInitialValue({\n markdownRef,\n initValue,\n setEditorValue,\n setInitHeight,\n isOpen: isOpen,\n filter: currentTab,\n })\n\n // When editing, set selection to the end of the editor\n useSetCursorEnd({ initHeight, editorRef, isEditing })\n // create a new quill format for mentions and registers it\n useMentionLink({ projectName })\n\n // focus on editor when opened\n useEffect(() => {\n if (isOpen) {\n editorRef.current?.getEditor()?.enable()\n // block autofocus if opened from an annotation\n if (annotations.length > 0 && files.length === 0) {\n return\n }\n\n editorRef.current?.focus()\n }\n // We don't set annotations or files as useEffect dependencies, because we don't want to focus\n // the input if it's already open but annotations change (e.g. are removed).\n }, [isOpen, editorRef])\n\n mentionTypes.sort((a, b) => b.length - a.length)\n\n const mentionOptions = useMemo(\n () =>\n getMentionOptions(\n mention?.type,\n {\n '@': () => getMentionUsers(mentionUsers),\n '@@': () => getMentionVersions(mentionVersions),\n '@@@': () => getMentionTasks(mentionTasks, projectInfo.taskTypes),\n },\n mention?.search,\n ),\n [mentionTasks, mentionVersions, mentionUsers, mention?.type, mention?.search],\n )\n\n // show first 5 and filter itself out\n const shownMentionOptions = mentionOptions.slice(0, 5)\n\n // triggered when a mention is selected\n const [newSelection, setNewSelection] = useState<null | number>()\n\n useEffect(() => {\n if (newSelection) {\n setNewSelection(null)\n // now we set selection to the end of the mention\n const quill = editorRef.current.getEditor()\n quill.setSelection(newSelection)\n }\n }, [newSelection])\n\n const handleSelectMention = (selectedOption: any) => {\n // get option text\n const quill = editorRef.current.getEditor()\n\n const typePrefix = mention.type // the type of mention: @, @@, @@@\n const search = typePrefix + (mention.search || '') // the full search string: @Tim\n const mentionLabel = typePrefix + selectedOption.label // the label of the mention: @Tim Bailey\n // @ts-expect-error\n const type = mentionTypeOptions[typePrefix] // the type of mention: user, version, task\n const href = `${type?.id}:${selectedOption.id}` // the href of the mention: user:user.123\n\n // get selection delta\n const selection = quill.getSelection(true)\n const selectionIndex = selection?.index || 0\n const startIndex = selectionIndex - search.length // the start index of the search\n\n // first delete the search string\n quill.deleteText(startIndex, search.length)\n\n // insert embed link\n quill.insertText(startIndex, mentionLabel, 'mention', href)\n\n const endIndex = startIndex + mentionLabel.length\n\n // insert a space after the mention\n quill.updateContents(new Delta().retain(endIndex).insert(' '))\n\n // remove single \\n after mention\n quill.updateContents(new Delta().retain(endIndex + 1).delete(1))\n\n // set selection to the end of the mention + 1\n setNewSelection(endIndex + 1)\n\n // reset mention state\n setMention(null)\n setMentionSelectedIndex(0)\n }\n\n const handleSelectChange = (option: any) => {\n handleSelectMention(option)\n }\n\n const handleChange = (content: string, delta: any, _: any, editor: any) => {\n let currentCharacter =\n (delta.ops[0] && delta.ops[0].insert) || (delta.ops[1] && delta.ops[1].insert)\n\n const tabOrEnter = currentCharacter === '\\n' || currentCharacter === '\\t'\n // find the first option\n const selectedOption = mentionOptions[mentionSelectedIndex]\n\n if (mention && tabOrEnter && selectedOption) {\n // get option text\n const retain = (delta.ops[0] && delta.ops[0].retain) || 0\n // prevent default\n\n // @ts-ignore\n handleSelectMention(selectedOption, retain)\n\n return\n }\n\n setEditorValue(content)\n\n const isDelete = delta.ops.length === 2 && !!delta.ops[1].delete\n\n if (!currentCharacter && isDelete) {\n currentCharacter = editor.getText(delta.ops[0].retain - 1, 1)\n }\n\n const isMention = mentionTypes.includes(currentCharacter)\n\n if (isMention) {\n const mentionIndex = delta.ops.findIndex((op: any) => 'insert' in op || 'delete' in op)\n const mention = currentCharacter\n let retain = mentionIndex === 0 ? 0 : delta.ops[mentionIndex - 1].retain\n if (isDelete) retain = retain - 1\n\n // for each mention denotation char, check if it is a mention\n // sort by length of mention denotation char\n let mentionMatch = null\n\n // loop through each mention denotation char, with longest first. First one to match is the one we want\n for (const chars of mentionTypes) {\n let isMatch = true\n // start with the last character\n if (chars.endsWith(mention)) {\n // loop through the chars backwards\n for (let i = chars.length - 1; i >= 0; i--) {\n // skip first character as that's already been checked\n if (i === 0) continue\n const char = chars[i - 1]\n const indexInDelta = retain - (chars.length - i)\n const valueCharAtIndex = editor.getText(indexInDelta, 1)\n if (valueCharAtIndex !== char) {\n isMatch = false\n break\n }\n }\n } else {\n isMatch = false\n }\n\n if (isMatch) {\n // console.log('match!!!', chars)\n mentionMatch = chars\n break\n }\n }\n\n if (mentionMatch) {\n setMention({\n type: mentionMatch,\n retain: retain,\n })\n } else {\n setMention(null)\n setMentionSelectedIndex(0)\n }\n } else {\n // get full string between mention and new delta\n // This is where SEARCH is handled\n if (mention) {\n const retain = delta.ops[0].retain\n // if space is pressed, remove mention\n if (currentCharacter === ' ' || !retain) {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n let distanceMentionToRetain = retain - mention.retain\n if (!isDelete) distanceMentionToRetain++\n const mentionFull = editor.getText(mention.retain, distanceMentionToRetain)\n const mentionSearch = mentionFull.replace(mention.type.slice(-1), '')\n // check for space in mentionFull\n if (mentionFull.includes(' ')) {\n setMention(null)\n setMentionSelectedIndex(0)\n } else {\n setMention({\n ...mention,\n search: mentionSearch?.toLowerCase(),\n })\n }\n } else {\n // just deleting any text\n const quill = editorRef.current.getEditor()\n const currentSelection = quill.getSelection(false)\n const currentFormat = quill.getFormat(currentSelection?.index, currentSelection?.length)\n if (currentFormat.mention) {\n // if format is mention, delete the whole mention\n const [lineBlock] = quill.getLine(currentSelection.index - 1) || []\n const ops = lineBlock?.cache?.delta?.ops || []\n // get last op with attributes mention: true\n const lastMentionOp = ops.reverse().find((op: any) => op.attributes?.mention)\n if (lastMentionOp) {\n const mentionLength = lastMentionOp.insert.length\n quill.deleteText(currentSelection.index - mentionLength, mentionLength)\n }\n }\n }\n }\n }\n\n const addTextToEditor = (type: string) => {\n // get editor retain\n const quill = editorRef.current.getEditor()\n\n let retain = quill.getSelection(true)?.index || 0\n\n // get character at retain\n const currentCharacter = quill.getText(retain - 1, 1)\n\n // if the current character is a character, increment retain\n const addSpace = currentCharacter !== ' ' && currentCharacter\n if (addSpace) {\n quill.insertText(retain, ' ')\n retain++\n }\n\n // This is hack AF, but it works\n typeWithDelay(quill, retain, type)\n }\n\n const handleMentionButton = (type: string) => {\n // first check if mention is already open\n if (mention) {\n const { type, retain, search = '' } = mention\n\n const quill = editorRef.current.getEditor()\n const length = type.length + search.length\n const start = retain - type.length + 1\n // delete the mention\n quill.deleteText(start, length)\n }\n\n addTextToEditor(type)\n }\n\n const handleOpenClick = () => {\n if (isOpen || disabled) return\n\n onOpen && onOpen()\n }\n\n const handleClose = () => {\n // get editor value\n const editor = editorRef.current.getEditor()\n const text = editor.getText()\n if (text.length < 2 || isEditing) {\n setEditorValue('')\n }\n\n // always close editor\n onClose && onClose()\n }\n\n const handleFileUploaded = ({ file, data }: any) => {\n const newFile = {\n id: data.id,\n name: file.name,\n mime: file.type,\n size: file.size,\n order: files.length,\n }\n\n setFiles((prev) => [...prev, newFile])\n // remove from uploading\n setFilesUploading((prev) => prev.filter((uploading: any) => uploading.name !== file.name))\n\n return newFile\n }\n\n const handleFileRemove = (id: string, name: string, isAnnotation: boolean) => {\n if (isAnnotation) {\n // remove from annotations (if it's an annotation)\n removeAnnotation?.(id)\n } else {\n // remove file from files\n setFiles((prev) => prev.filter((file) => file.id !== id))\n // remove from uploading\n setFilesUploading((prev) => {\n return prev.filter((file: any) => file.name !== name)\n })\n }\n }\n\n const handleFileProgress = (e: any, file: any) => {\n const progress = Math.round((e.loaded * 100) / e.total)\n if (progress !== 100) {\n const uploadProgress = {\n name: file.name,\n progress,\n type: file.type,\n order: files.length + filesUploading.length,\n }\n\n // @ts-ignore\n setFilesUploading((prev) => {\n // replace or add new progress\n const newProgress = prev.filter((name: any) => name.name !== file.name)\n return [...newProgress, uploadProgress]\n })\n }\n }\n\n // when a file is not dropped onto the comment input\n const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {\n setIsDropping(false)\n // upload file\n handleFileDrop(e, projectName, handleFileProgress, handleFileUploaded)\n }\n\n const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault()\n e.stopPropagation()\n setIsDropping(true)\n }\n\n const uploadAnnotations = useAnnotationsUpload({\n projectName,\n onSuccess: handleFileUploaded,\n })\n\n const handleSubmit = async () => {\n try {\n setIsSubmitting(true)\n // upload any annotations first\n let annotationFiles = []\n if (annotations.length) {\n annotationFiles = await uploadAnnotations(annotations)\n }\n\n // convert to markdown\n const [markdown] = convertToMarkdown(editorValue)\n\n // remove img query params\n const markdownParsed = parseImages(markdown)\n\n const uploadedFiles = [...files, ...annotationFiles]\n\n if ((markdownParsed || uploadedFiles.length) && onSubmit) {\n try {\n await onSubmit(markdownParsed, uploadedFiles)\n // only clear if onSubmit is successful\n setEditorValue('')\n setFiles([])\n } catch (error) {\n // error is handled in rtk query mutation\n return\n }\n }\n } catch (error) {\n console.error(error)\n toast.error('Something went wrong')\n } finally {\n setIsSubmitting(false)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (mention) {\n // close mention on escape\n if (e.key === 'Escape') {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n // add top search of mention\n if (mention && e.key === 'Tab') {\n // we handle this in the onChange\n }\n\n const arrowDirection = e.key === 'ArrowUp' ? -1 : e.key === 'ArrowDown' ? 1 : 0\n\n if (arrowDirection) {\n // navigate through mentions\n e.preventDefault()\n let newIndex = mentionSelectedIndex + arrowDirection\n if (newIndex < 0) newIndex = shownMentionOptions.length - 1\n if (newIndex >= shownMentionOptions.length) newIndex = 0\n setMentionSelectedIndex(newIndex)\n }\n\n if (e.key === 'Enter') {\n // we handle this in the onChange\n }\n }\n\n if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {\n handleSubmit()\n }\n\n if (e.key === 'Escape') {\n handleClose()\n }\n }\n\n let quillMinHeight: number | undefined = isOpen ? initHeight + 41 : 44\n if (isEditing) quillMinHeight = undefined\n\n // QUILL CONFIG\n const modules = useMemo(\n () =>\n getModules({\n imageUploader: {\n projectName,\n onUpload: handleFileUploaded,\n onUploadProgress: handleFileProgress,\n },\n }),\n [projectName, setFiles, setFilesUploading],\n )\n\n const allFiles = [...annotations, ...(files || []), ...filesUploading].sort(\n (a, b) => a.order - b.order,\n )\n const compactGrid = allFiles.length > 6\n\n // disable version mentions for folders\n let mentionsError = null\n if (entities.length && entities[0].entityType === 'folder') {\n if (mention?.type === '@@') {\n mentionsError = 'Version mentions are disabled for folders'\n }\n }\n\n return (\n <>\n <Styled.AutoHeight\n className={clsx('comment-container', { isOpen, isEditing })}\n onDragOver={handleDragOver}\n onDragLeave={() => setIsDropping(false)}\n onDrop={handleDrop}\n onClick={() => setIsDropping(false)}\n onKeyDown={(e) => e.stopPropagation()}\n >\n <Styled.Comment\n className={clsx('block-shortcuts', {\n isOpen,\n isClosed: !isOpen || disabled,\n isEditing,\n isDropping,\n disabled,\n isLoading,\n isSubmitting,\n })}\n onKeyDown={handleKeyDown}\n onClick={handleOpenClick}\n >\n <Styled.Markdown ref={markdownRef}>\n {/* this is purely used to translate the markdown into html for Editor */}\n <InputMarkdownConvert typeOptions={mentionTypeOptions} initValue={initValue} />\n </Styled.Markdown>\n\n {/* file uploads */}\n {isOpen && (\n <FilesGrid\n files={allFiles}\n isCompact={compactGrid}\n onRemove={handleFileRemove}\n style={{ borderBottom: '1px solid var(--md-sys-color-outline-variant)' }}\n projectName={projectName}\n onAnnotationClick={goToAnnotation}\n />\n )}\n {isOpen && !disabled ? (\n <ReactQuill\n theme=\"snow\"\n style={{ minHeight: quillMinHeight, maxHeight: 300 }}\n ref={editorRef}\n value={editorValue}\n onChange={handleChange}\n readOnly={!isOpen}\n placeholder={'Comment or mention with @user, @@version, @@@task...'}\n modules={modules}\n formats={quillFormats}\n />\n ) : (\n <Styled.Placeholder>\n {disabled ? 'Commenting is disabled across multiple projects.' : 'Add a comment...'}\n </Styled.Placeholder>\n )}\n\n <Styled.Footer>\n <Styled.Buttons>\n {/* mention a user */}\n <Button\n icon=\"person\"\n variant=\"text\"\n onClick={() => handleMentionButton('@')}\n data-tooltip={'Mention user'}\n data-shortcut={'@'}\n />\n {/* mention a version */}\n <Button\n icon=\"layers\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@')}\n data-tooltip={'Mention version'}\n data-shortcut={'@@'}\n />\n {/* mention a task */}\n <Button\n icon=\"check_circle\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@@')}\n data-tooltip={'Mention task'}\n data-shortcut={'@@@'}\n />\n </Styled.Buttons>\n <Styled.Buttons>\n {isEditing && (\n <Button variant=\"text\" onClick={handleClose}>\n Cancel\n </Button>\n )}\n <SaveButton\n label={isEditing ? 'Save' : 'Comment'}\n className=\"comment\"\n active={!!editorValue || !!files.length}\n onClick={handleSubmit}\n disabled={isLoading}\n />\n </Styled.Buttons>\n </Styled.Footer>\n\n <Styled.Dropzone className={clsx({ show: isDropping && isOpen })}>\n <Icon icon=\"cloud_upload\" />\n </Styled.Dropzone>\n </Styled.Comment>\n <CommentMentionSelect\n mention={mention}\n options={shownMentionOptions}\n onChange={handleSelectChange}\n types={mentionTypes}\n z\n // @ts-ignore\n config={mentionTypeOptions[mention?.type]}\n noneFound={!shownMentionOptions.length && mention?.search}\n noneFoundAtAll={!shownMentionOptions.length && !mention?.search}\n selectedIndex={mentionSelectedIndex}\n // @ts-ignore\n error={mentionsError}\n />\n </Styled.AutoHeight>\n </>\n )\n}\n\nexport default CommentInput\n"],"names":["Quill","useFeedContext","useState","useAnnotationsSync","useRef","useEffect","_a","useMemo","mention","typeWithDelay","type","handleFileDrop","convertToMarkdown","parseImages","toast","getModules","jsx","Fragment","jsxs","Styled.AutoHeight","Styled.Comment","Styled.Markdown","quillFormats","Styled.Placeholder","Styled.Footer","Styled.Buttons","Button","SaveButton","Styled.Dropzone","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAI,QAAQA,WAAAA,MAAM,OAAO,OAAO;AAEhC,MAAM,eAAe,CAAC,KAAK,MAAM,KAAK;AAC/B,MAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,IACL,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,KAAK;AAAA,IACH,IAAI;AAAA,IACJ,UAAU;AAAA,EAAA;AAEd;AAcA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA,YAAY,CAAC;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;;AACE,QAAA,EAAE,aAAa,UAAU,aAAa,OAAO,YAAY,2BAC7DC,2BAAe;AAEX,QAAA;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO;AAAA,EACT,IAAI,0BAA0B,CAAC;AAE/B,QAAM,CAAC,YAAY,aAAa,IAAIC,MAAAA,SAAS,EAAE;AAC/C,QAAM,CAAC,aAAa,cAAc,IAAIA,MAAAA,SAAS,EAAE;AAEjD,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAS,SAAS;AAC5C,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ACO,oBAAAA,SAAA,EACE,UAAA;AAAA,kBAAA,8DACEC,oBAAO,QAAA,EAAA,SAAQ,QAAO,SAAS,aAAa,UAE7C,UAAA;AAAA,kBAEFV,2BAAA,kBAAA;AAAA,oBAACW,oBAAA;AAAA,oBAAA;AAAA,sBACC,OAAO,YAAY,SAAS;AAAA,sBAC5B,WAAU;AAAA,sBACV,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,MAAM;AAAA,sBACjC,SAAS;AAAA,sBACT,UAAU;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACZ,EACF,CAAA;AAAA,cAAA,GACF;AAAA,+DAECC,oBAAO,UAAP,EAAgB,WAAW,KAAK,EAAE,MAAM,cAAc,OAAQ,CAAA,GAC7D,UAAAZ,2BAAAA,kBAAAA,IAACa,oBAAAA,MAAK,EAAA,MAAK,gBAAe,EAC5B,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACAb,2BAAA,kBAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,SAAS;AAAA,YACT,UAAU;AAAA,YACV,OAAO;AAAA,YACP,GAAC;AAAA,YAED,QAAQ,mBAAmB,mCAAS,IAAI;AAAA,YACxC,WAAW,CAAC,oBAAoB,WAAU,mCAAS;AAAA,YACnD,gBAAgB,CAAC,oBAAoB,UAAU,EAAC,mCAAS;AAAA,YACzD,eAAe;AAAA,YAEf,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"CommentInput.cjs.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/CommentInput.tsx"],"sourcesContent":["// React and related hooks\nimport React, { FC, useEffect, useMemo, useRef, useState } from 'react'\n\n// Third-party libraries\nimport clsx from 'clsx'\nimport { toast } from 'react-toastify'\nimport ReactQuill, { Quill } from 'react-quill-ayon'\n\n// Components\nimport { Button, Icon, SaveButton } from '@ynput/ayon-react-components'\nimport CommentMentionSelect from '../CommentMentionSelect/CommentMentionSelect'\nimport InputMarkdownConvert from './InputMarkdownConvert'\nimport FilesGrid from '../FilesGrid'\n\n// Styled components\nimport * as Styled from './CommentInput.styled'\n\n// Helpers and utilities\nimport getMentionOptions from '../../mentionHelpers/getMentionOptions'\nimport getMentionUsers from '../../mentionHelpers/getMentionUsers'\nimport getMentionTasks from '../../mentionHelpers/getMentionTasks'\nimport getMentionVersions from '../../mentionHelpers/getMentionVersions'\nimport { convertToMarkdown } from './quillToMarkdown'\nimport { handleFileDrop, parseImages, typeWithDelay } from './helpers'\nimport { getModules, quillFormats } from './modules'\n\n// Hooks\nimport useInitialValue from './hooks/useInitialValue'\nimport useSetCursorEnd from './hooks/useSetCursorEnd'\nimport useMentionLink from './hooks/useMentionLink'\nimport useAnnotationsSync from './hooks/useAnnotationsSync'\n\n// State management\nimport useAnnotationsUpload from './hooks/useAnnotationsUpload'\nimport { useFeedContext } from '../../context/FeedContext'\nimport { SavedAnnotationMetadata } from '../../index'\n\nvar Delta = Quill.import('delta')\n\nconst mentionTypes = ['@', '@@', '@@@']\nexport const mentionTypeOptions = {\n '@@@': {\n id: 'task',\n },\n '@@': {\n id: 'version',\n },\n '@': {\n id: 'user',\n isCircle: true,\n },\n}\n\ninterface CommentInputProps {\n initValue: string | null\n initFiles?: any[]\n onSubmit: (markdown: string, files: any[], data?: any) => Promise<void>\n isEditing?: boolean\n disabled?: boolean\n isLoading?: boolean\n isOpen: boolean\n onOpen?: () => void\n onClose?: () => void\n}\n\nconst CommentInput: FC<CommentInputProps> = ({\n initValue,\n initFiles = [],\n onSubmit,\n isEditing,\n disabled,\n isLoading,\n isOpen,\n onOpen,\n onClose,\n}) => {\n const { projectName, entities, projectInfo, scope, currentTab, mentionSuggestionsData } =\n useFeedContext()\n\n const {\n users: mentionUsers,\n versions: mentionVersions,\n tasks: mentionTasks,\n } = mentionSuggestionsData || {}\n\n const [initHeight, setInitHeight] = useState(88)\n const [editorValue, setEditorValue] = useState('')\n // file uploads\n const [files, setFiles] = useState(initFiles)\n const [filesUploading, setFilesUploading] = useState([])\n const [isDropping, setIsDropping] = useState(false)\n const [isSubmitting, setIsSubmitting] = useState(false)\n\n const { annotations, removeAnnotation, goToAnnotation } = useAnnotationsSync({\n entityId: entities[0]?.id,\n filesUploading,\n })\n\n // MENTION STATES\n const [mention, setMention] = useState<null | any>(null)\n const [mentionSelectedIndex, setMentionSelectedIndex] = useState(0)\n // REFS\n const editorRef = useRef<any>(null)\n const markdownRef = useRef<HTMLDivElement>(null)\n\n // if there is an initial value, set it so the editor is prefilled\n useInitialValue({\n markdownRef,\n initValue,\n setEditorValue,\n setInitHeight,\n isOpen: isOpen,\n filter: currentTab,\n })\n\n // When editing, set selection to the end of the editor\n useSetCursorEnd({ initHeight, editorRef, isEditing })\n // create a new quill format for mentions and registers it\n useMentionLink({ projectName })\n\n // focus on editor when opened\n useEffect(() => {\n if (isOpen) {\n editorRef.current?.getEditor()?.enable()\n // block autofocus if opened from an annotation\n if (annotations.length > 0 && files.length === 0) {\n return\n }\n\n editorRef.current?.focus()\n }\n // We don't set annotations or files as useEffect dependencies, because we don't want to focus\n // the input if it's already open but annotations change (e.g. are removed).\n }, [isOpen, editorRef])\n\n mentionTypes.sort((a, b) => b.length - a.length)\n\n const mentionOptions = useMemo(\n () =>\n getMentionOptions(\n mention?.type,\n {\n '@': () => getMentionUsers(mentionUsers),\n '@@': () => getMentionVersions(mentionVersions),\n '@@@': () => getMentionTasks(mentionTasks, projectInfo.taskTypes),\n },\n mention?.search,\n ),\n [mentionTasks, mentionVersions, mentionUsers, mention?.type, mention?.search],\n )\n\n // show first 5 and filter itself out\n const shownMentionOptions = mentionOptions.slice(0, 5)\n\n // triggered when a mention is selected\n const [newSelection, setNewSelection] = useState<null | number>()\n\n useEffect(() => {\n if (newSelection) {\n setNewSelection(null)\n // now we set selection to the end of the mention\n const quill = editorRef.current.getEditor()\n quill.setSelection(newSelection)\n }\n }, [newSelection])\n\n const handleSelectMention = (selectedOption: any) => {\n // get option text\n const quill = editorRef.current.getEditor()\n\n const typePrefix = mention.type // the type of mention: @, @@, @@@\n const search = typePrefix + (mention.search || '') // the full search string: @Tim\n const mentionLabel = typePrefix + selectedOption.label // the label of the mention: @Tim Bailey\n // @ts-expect-error\n const type = mentionTypeOptions[typePrefix] // the type of mention: user, version, task\n const href = `${type?.id}:${selectedOption.id}` // the href of the mention: user:user.123\n\n // get selection delta\n const selection = quill.getSelection(true)\n const selectionIndex = selection?.index || 0\n const startIndex = selectionIndex - search.length // the start index of the search\n\n // first delete the search string\n quill.deleteText(startIndex, search.length)\n\n // insert embed link\n quill.insertText(startIndex, mentionLabel, 'mention', href)\n\n const endIndex = startIndex + mentionLabel.length\n\n // insert a space after the mention\n quill.updateContents(new Delta().retain(endIndex).insert(' '))\n\n // remove single \\n after mention\n quill.updateContents(new Delta().retain(endIndex + 1).delete(1))\n\n // set selection to the end of the mention + 1\n setNewSelection(endIndex + 1)\n\n // reset mention state\n setMention(null)\n setMentionSelectedIndex(0)\n }\n\n const handleSelectChange = (option: any) => {\n handleSelectMention(option)\n }\n\n const handleChange = (content: string, delta: any, _: any, editor: any) => {\n let currentCharacter =\n (delta.ops[0] && delta.ops[0].insert) || (delta.ops[1] && delta.ops[1].insert)\n\n const tabOrEnter = currentCharacter === '\\n' || currentCharacter === '\\t'\n // find the first option\n const selectedOption = mentionOptions[mentionSelectedIndex]\n\n if (mention && tabOrEnter && selectedOption) {\n // get option text\n const retain = (delta.ops[0] && delta.ops[0].retain) || 0\n // prevent default\n\n // @ts-ignore\n handleSelectMention(selectedOption, retain)\n\n return\n }\n\n setEditorValue(content)\n\n const isDelete = delta.ops.length === 2 && !!delta.ops[1].delete\n\n if (!currentCharacter && isDelete) {\n currentCharacter = editor.getText(delta.ops[0].retain - 1, 1)\n }\n\n const isMention = mentionTypes.includes(currentCharacter)\n\n if (isMention) {\n const mentionIndex = delta.ops.findIndex((op: any) => 'insert' in op || 'delete' in op)\n const mention = currentCharacter\n let retain = mentionIndex === 0 ? 0 : delta.ops[mentionIndex - 1].retain\n if (isDelete) retain = retain - 1\n\n // for each mention denotation char, check if it is a mention\n // sort by length of mention denotation char\n let mentionMatch = null\n\n // loop through each mention denotation char, with longest first. First one to match is the one we want\n for (const chars of mentionTypes) {\n let isMatch = true\n // start with the last character\n if (chars.endsWith(mention)) {\n // loop through the chars backwards\n for (let i = chars.length - 1; i >= 0; i--) {\n // skip first character as that's already been checked\n if (i === 0) continue\n const char = chars[i - 1]\n const indexInDelta = retain - (chars.length - i)\n const valueCharAtIndex = editor.getText(indexInDelta, 1)\n if (valueCharAtIndex !== char) {\n isMatch = false\n break\n }\n }\n } else {\n isMatch = false\n }\n\n if (isMatch) {\n // console.log('match!!!', chars)\n mentionMatch = chars\n break\n }\n }\n\n if (mentionMatch) {\n setMention({\n type: mentionMatch,\n retain: retain,\n })\n } else {\n setMention(null)\n setMentionSelectedIndex(0)\n }\n } else {\n // get full string between mention and new delta\n // This is where SEARCH is handled\n if (mention) {\n const retain = delta.ops[0].retain\n // if space is pressed, remove mention\n if (currentCharacter === ' ' || !retain) {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n let distanceMentionToRetain = retain - mention.retain\n if (!isDelete) distanceMentionToRetain++\n const mentionFull = editor.getText(mention.retain, distanceMentionToRetain)\n const mentionSearch = mentionFull.replace(mention.type.slice(-1), '')\n // check for space in mentionFull\n if (mentionFull.includes(' ')) {\n setMention(null)\n setMentionSelectedIndex(0)\n } else {\n setMention({\n ...mention,\n search: mentionSearch?.toLowerCase(),\n })\n }\n } else {\n // just deleting any text\n const quill = editorRef.current.getEditor()\n const currentSelection = quill.getSelection(false)\n const currentFormat = quill.getFormat(currentSelection?.index, currentSelection?.length)\n if (currentFormat.mention) {\n // if format is mention, delete the whole mention\n const [lineBlock] = quill.getLine(currentSelection.index - 1) || []\n const ops = lineBlock?.cache?.delta?.ops || []\n // get last op with attributes mention: true\n const lastMentionOp = ops.reverse().find((op: any) => op.attributes?.mention)\n if (lastMentionOp) {\n const mentionLength = lastMentionOp.insert.length\n quill.deleteText(currentSelection.index - mentionLength, mentionLength)\n }\n }\n }\n }\n }\n\n const addTextToEditor = (type: string) => {\n // get editor retain\n const quill = editorRef.current.getEditor()\n\n let retain = quill.getSelection(true)?.index || 0\n\n // get character at retain\n const currentCharacter = quill.getText(retain - 1, 1)\n\n // if the current character is a character, increment retain\n const addSpace = currentCharacter !== ' ' && currentCharacter\n if (addSpace) {\n quill.insertText(retain, ' ')\n retain++\n }\n\n // This is hack AF, but it works\n typeWithDelay(quill, retain, type)\n }\n\n const handleMentionButton = (type: string) => {\n // first check if mention is already open\n if (mention) {\n const { type, retain, search = '' } = mention\n\n const quill = editorRef.current.getEditor()\n const length = type.length + search.length\n const start = retain - type.length + 1\n // delete the mention\n quill.deleteText(start, length)\n }\n\n addTextToEditor(type)\n }\n\n const handleOpenClick = () => {\n if (isOpen || disabled) return\n\n onOpen && onOpen()\n }\n\n const handleClose = () => {\n // get editor value\n const editor = editorRef.current.getEditor()\n const text = editor.getText()\n if (text.length < 2 || isEditing) {\n setEditorValue('')\n }\n\n // always close editor\n onClose && onClose()\n }\n\n const handleFileUploaded = ({ file, data }: any) => {\n const newFile = {\n id: data.id,\n name: file.name,\n mime: file.type,\n size: file.size,\n order: files.length,\n }\n\n setFiles((prev) => [...prev, newFile])\n // remove from uploading\n setFilesUploading((prev) => prev.filter((uploading: any) => uploading.name !== file.name))\n\n return newFile\n }\n\n const handleFileRemove = (id: string, name: string, isUnsavedAnnotation: boolean) => {\n if (isUnsavedAnnotation) {\n // remove from annotations (if it's an unsaved annotation)\n removeAnnotation?.(id)\n } else {\n // remove file from files\n setFiles((prev) => prev.filter((file) => file.id !== id))\n // remove from uploading\n setFilesUploading((prev) => {\n return prev.filter((file: any) => file.name !== name)\n })\n }\n }\n\n const handleFileProgress = (e: any, file: any) => {\n const progress = Math.round((e.loaded * 100) / e.total)\n if (progress !== 100) {\n const uploadProgress = {\n name: file.name,\n progress,\n type: file.type,\n order: files.length + filesUploading.length,\n }\n\n // @ts-ignore\n setFilesUploading((prev) => {\n // replace or add new progress\n const newProgress = prev.filter((name: any) => name.name !== file.name)\n return [...newProgress, uploadProgress]\n })\n }\n }\n\n // when a file is not dropped onto the comment input\n const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {\n setIsDropping(false)\n // upload file\n handleFileDrop(e, projectName, handleFileProgress, handleFileUploaded)\n }\n\n const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault()\n e.stopPropagation()\n setIsDropping(true)\n }\n\n const uploadAnnotations = useAnnotationsUpload({\n projectName,\n onSuccess: handleFileUploaded,\n })\n\n const handleSubmit = async () => {\n try {\n setIsSubmitting(true)\n // upload any annotations first\n let annotationFiles = []\n let annotationMetadata: SavedAnnotationMetadata[] = []\n\n if (annotations.length) {\n const { files, metadata } = await uploadAnnotations(annotations)\n annotationFiles = files\n annotationMetadata = metadata\n }\n\n // convert to markdown\n const [markdown] = convertToMarkdown(editorValue)\n\n // remove img query params\n const markdownParsed = parseImages(markdown)\n\n const uploadedFiles = [...files, ...annotationFiles]\n\n if ((markdownParsed || uploadedFiles.length) && onSubmit) {\n try {\n await onSubmit(markdownParsed, uploadedFiles, { annotations: annotationMetadata })\n // only clear if onSubmit is successful\n setEditorValue('')\n setFiles([])\n } catch (error) {\n // error is handled in rtk query mutation\n return\n }\n }\n } catch (error) {\n console.error(error)\n toast.error('Something went wrong')\n } finally {\n setIsSubmitting(false)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (mention) {\n // close mention on escape\n if (e.key === 'Escape') {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n // add top search of mention\n if (mention && e.key === 'Tab') {\n // we handle this in the onChange\n }\n\n const arrowDirection = e.key === 'ArrowUp' ? -1 : e.key === 'ArrowDown' ? 1 : 0\n\n if (arrowDirection) {\n // navigate through mentions\n e.preventDefault()\n let newIndex = mentionSelectedIndex + arrowDirection\n if (newIndex < 0) newIndex = shownMentionOptions.length - 1\n if (newIndex >= shownMentionOptions.length) newIndex = 0\n setMentionSelectedIndex(newIndex)\n }\n\n if (e.key === 'Enter') {\n // we handle this in the onChange\n }\n }\n\n if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {\n handleSubmit()\n }\n\n if (e.key === 'Escape') {\n handleClose()\n }\n }\n\n let quillMinHeight: number | undefined = isOpen ? initHeight + 41 : 44\n if (isEditing) quillMinHeight = undefined\n\n // QUILL CONFIG\n const modules = useMemo(\n () =>\n getModules({\n imageUploader: {\n projectName,\n onUpload: handleFileUploaded,\n onUploadProgress: handleFileProgress,\n },\n }),\n [projectName, setFiles, setFilesUploading],\n )\n\n const allFiles = [...annotations, ...(files || []), ...filesUploading].sort(\n (a, b) => a.order - b.order,\n )\n const compactGrid = allFiles.length > 6\n\n // disable version mentions for folders\n let mentionsError = null\n if (entities.length && entities[0].entityType === 'folder') {\n if (mention?.type === '@@') {\n mentionsError = 'Version mentions are disabled for folders'\n }\n }\n\n return (\n <>\n <Styled.AutoHeight\n className={clsx('comment-container', { isOpen, isEditing })}\n onDragOver={handleDragOver}\n onDragLeave={() => setIsDropping(false)}\n onDrop={handleDrop}\n onClick={() => setIsDropping(false)}\n onKeyDown={(e) => e.stopPropagation()}\n >\n <Styled.Comment\n className={clsx('block-shortcuts', {\n isOpen,\n isClosed: !isOpen || disabled,\n isEditing,\n isDropping,\n disabled,\n isLoading,\n isSubmitting,\n })}\n onKeyDown={handleKeyDown}\n onClick={handleOpenClick}\n >\n <Styled.Markdown ref={markdownRef}>\n {/* this is purely used to translate the markdown into html for Editor */}\n <InputMarkdownConvert typeOptions={mentionTypeOptions} initValue={initValue} />\n </Styled.Markdown>\n\n {/* file uploads */}\n {isOpen && (\n <FilesGrid\n files={allFiles}\n isCompact={compactGrid}\n onRemove={handleFileRemove}\n style={{ borderBottom: '1px solid var(--md-sys-color-outline-variant)' }}\n projectName={projectName}\n onAnnotationClick={goToAnnotation}\n />\n )}\n {isOpen && !disabled ? (\n <ReactQuill\n theme=\"snow\"\n style={{ minHeight: quillMinHeight, maxHeight: 300 }}\n ref={editorRef}\n value={editorValue}\n onChange={handleChange}\n readOnly={!isOpen}\n placeholder={'Comment or mention with @user, @@version, @@@task...'}\n modules={modules}\n formats={quillFormats}\n />\n ) : (\n <Styled.Placeholder>\n {disabled ? 'Commenting is disabled across multiple projects.' : 'Add a comment...'}\n </Styled.Placeholder>\n )}\n\n <Styled.Footer>\n <Styled.Buttons>\n {/* mention a user */}\n <Button\n icon=\"person\"\n variant=\"text\"\n onClick={() => handleMentionButton('@')}\n data-tooltip={'Mention user'}\n data-shortcut={'@'}\n />\n {/* mention a version */}\n <Button\n icon=\"layers\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@')}\n data-tooltip={'Mention version'}\n data-shortcut={'@@'}\n />\n {/* mention a task */}\n <Button\n icon=\"check_circle\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@@')}\n data-tooltip={'Mention task'}\n data-shortcut={'@@@'}\n />\n </Styled.Buttons>\n <Styled.Buttons>\n {isEditing && (\n <Button variant=\"text\" onClick={handleClose}>\n Cancel\n </Button>\n )}\n <SaveButton\n label={isEditing ? 'Save' : 'Comment'}\n className=\"comment\"\n active={!!editorValue || !!files.length}\n onClick={handleSubmit}\n disabled={isLoading}\n />\n </Styled.Buttons>\n </Styled.Footer>\n\n <Styled.Dropzone className={clsx({ show: isDropping && isOpen })}>\n <Icon icon=\"cloud_upload\" />\n </Styled.Dropzone>\n </Styled.Comment>\n <CommentMentionSelect\n mention={mention}\n options={shownMentionOptions}\n onChange={handleSelectChange}\n types={mentionTypes}\n z\n // @ts-ignore\n config={mentionTypeOptions[mention?.type]}\n noneFound={!shownMentionOptions.length && mention?.search}\n noneFoundAtAll={!shownMentionOptions.length && !mention?.search}\n selectedIndex={mentionSelectedIndex}\n // @ts-ignore\n error={mentionsError}\n />\n </Styled.AutoHeight>\n </>\n )\n}\n\nexport default CommentInput\n"],"names":["Quill","useFeedContext","useState","useAnnotationsSync","useRef","useEffect","_a","useMemo","mention","typeWithDelay","type","handleFileDrop","files","convertToMarkdown","parseImages","toast","getModules","jsx","Fragment","jsxs","Styled.AutoHeight","Styled.Comment","Styled.Markdown","quillFormats","Styled.Placeholder","Styled.Footer","Styled.Buttons","Button","SaveButton","Styled.Dropzone","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAI,QAAQA,WAAAA,MAAM,OAAO,OAAO;AAEhC,MAAM,eAAe,CAAC,KAAK,MAAM,KAAK;AAC/B,MAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,IACL,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,KAAK;AAAA,IACH,IAAI;AAAA,IACJ,UAAU;AAAA,EAAA;AAEd;AAcA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA,YAAY,CAAC;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;;AACE,QAAA,EAAE,aAAa,UAAU,aAAa,OAAO,YAAY,2BAC7DC,2BAAe;AAEX,QAAA;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO;AAAA,EACT,IAAI,0BAA0B,CAAC;AAE/B,QAAM,CAAC,YAAY,aAAa,IAAIC,MAAAA,SAAS,EAAE;AAC/C,QAAM,CAAC,aAAa,cAAc,IAAIA,MAAAA,SAAS,EAAE;AAEjD,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAS,SAAS;AAC5C,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,MAAAA,SAAS,CAAA,CAAE;AACvD,QAAM,CAAC,YAAY,aAAa,IAAIA,MAAAA,SAAS,KAAK;AAClD,QAAM,CAAC,cAAc,eAAe,IAAIA,MAAAA,SAAS,KAAK;AAEtD,QAAM,EAAE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UAE7C,UAAA;AAAA,kBAEFV,2BAAA,kBAAA;AAAA,oBAACW,oBAAA;AAAA,oBAAA;AAAA,sBACC,OAAO,YAAY,SAAS;AAAA,sBAC5B,WAAU;AAAA,sBACV,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,MAAM;AAAA,sBACjC,SAAS;AAAA,sBACT,UAAU;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACZ,EACF,CAAA;AAAA,cAAA,GACF;AAAA,+DAECC,oBAAO,UAAP,EAAgB,WAAW,KAAK,EAAE,MAAM,cAAc,OAAQ,CAAA,GAC7D,UAAAZ,2BAAAA,kBAAAA,IAACa,oBAAAA,MAAK,EAAA,MAAK,gBAAe,EAC5B,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACAb,2BAAA,kBAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,SAAS;AAAA,YACT,UAAU;AAAA,YACV,OAAO;AAAA,YACP,GAAC;AAAA,YAED,QAAQ,mBAAmB,mCAAS,IAAI;AAAA,YACxC,WAAW,CAAC,oBAAoB,WAAU,mCAAS;AAAA,YACnD,gBAAgB,CAAC,oBAAoB,UAAU,EAAC,mCAAS;AAAA,YACzD,eAAe;AAAA,YAEf,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;;;"}
|
|
@@ -269,8 +269,8 @@ const CommentInput = ({
|
|
|
269
269
|
setFilesUploading((prev) => prev.filter((uploading) => uploading.name !== file.name));
|
|
270
270
|
return newFile;
|
|
271
271
|
};
|
|
272
|
-
const handleFileRemove = (id, name,
|
|
273
|
-
if (
|
|
272
|
+
const handleFileRemove = (id, name, isUnsavedAnnotation) => {
|
|
273
|
+
if (isUnsavedAnnotation) {
|
|
274
274
|
removeAnnotation == null ? void 0 : removeAnnotation(id);
|
|
275
275
|
} else {
|
|
276
276
|
setFiles((prev) => prev.filter((file) => file.id !== id));
|
|
@@ -311,15 +311,18 @@ const CommentInput = ({
|
|
|
311
311
|
try {
|
|
312
312
|
setIsSubmitting(true);
|
|
313
313
|
let annotationFiles = [];
|
|
314
|
+
let annotationMetadata = [];
|
|
314
315
|
if (annotations.length) {
|
|
315
|
-
|
|
316
|
+
const { files: files2, metadata } = await uploadAnnotations(annotations);
|
|
317
|
+
annotationFiles = files2;
|
|
318
|
+
annotationMetadata = metadata;
|
|
316
319
|
}
|
|
317
320
|
const [markdown] = convertToMarkdown(editorValue);
|
|
318
321
|
const markdownParsed = parseImages(markdown);
|
|
319
322
|
const uploadedFiles = [...files, ...annotationFiles];
|
|
320
323
|
if ((markdownParsed || uploadedFiles.length) && onSubmit) {
|
|
321
324
|
try {
|
|
322
|
-
await onSubmit(markdownParsed, uploadedFiles);
|
|
325
|
+
await onSubmit(markdownParsed, uploadedFiles, { annotations: annotationMetadata });
|
|
323
326
|
setEditorValue("");
|
|
324
327
|
setFiles([]);
|
|
325
328
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentInput.es.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/CommentInput.tsx"],"sourcesContent":["// React and related hooks\nimport React, { FC, useEffect, useMemo, useRef, useState } from 'react'\n\n// Third-party libraries\nimport clsx from 'clsx'\nimport { toast } from 'react-toastify'\nimport ReactQuill, { Quill } from 'react-quill-ayon'\n\n// Components\nimport { Button, Icon, SaveButton } from '@ynput/ayon-react-components'\nimport CommentMentionSelect from '../CommentMentionSelect/CommentMentionSelect'\nimport InputMarkdownConvert from './InputMarkdownConvert'\nimport FilesGrid from '../FilesGrid'\n\n// Styled components\nimport * as Styled from './CommentInput.styled'\n\n// Helpers and utilities\nimport getMentionOptions from '../../mentionHelpers/getMentionOptions'\nimport getMentionUsers from '../../mentionHelpers/getMentionUsers'\nimport getMentionTasks from '../../mentionHelpers/getMentionTasks'\nimport getMentionVersions from '../../mentionHelpers/getMentionVersions'\nimport { convertToMarkdown } from './quillToMarkdown'\nimport { handleFileDrop, parseImages, typeWithDelay } from './helpers'\nimport { getModules, quillFormats } from './modules'\n\n// Hooks\nimport useInitialValue from './hooks/useInitialValue'\nimport useSetCursorEnd from './hooks/useSetCursorEnd'\nimport useMentionLink from './hooks/useMentionLink'\nimport useAnnotationsSync from './hooks/useAnnotationsSync'\n\n// State management\nimport useAnnotationsUpload from './hooks/useAnnotationsUpload'\nimport { useFeedContext } from '../../context/FeedContext'\n\nvar Delta = Quill.import('delta')\n\nconst mentionTypes = ['@', '@@', '@@@']\nexport const mentionTypeOptions = {\n '@@@': {\n id: 'task',\n },\n '@@': {\n id: 'version',\n },\n '@': {\n id: 'user',\n isCircle: true,\n },\n}\n\ninterface CommentInputProps {\n initValue: string | null\n initFiles?: any[]\n onSubmit: (markdown: string, files: any[]) => Promise<void>\n isEditing?: boolean\n disabled?: boolean\n isLoading?: boolean\n isOpen: boolean\n onOpen?: () => void\n onClose?: () => void\n}\n\nconst CommentInput: FC<CommentInputProps> = ({\n initValue,\n initFiles = [],\n onSubmit,\n isEditing,\n disabled,\n isLoading,\n isOpen,\n onOpen,\n onClose,\n}) => {\n const { projectName, entities, projectInfo, scope, currentTab, mentionSuggestionsData } =\n useFeedContext()\n\n const {\n users: mentionUsers,\n versions: mentionVersions,\n tasks: mentionTasks,\n } = mentionSuggestionsData || {}\n\n const [initHeight, setInitHeight] = useState(88)\n const [editorValue, setEditorValue] = useState('')\n // file uploads\n const [files, setFiles] = useState(initFiles)\n const [filesUploading, setFilesUploading] = useState([])\n const [isDropping, setIsDropping] = useState(false)\n const [isSubmitting, setIsSubmitting] = useState(false)\n\n const { annotations, removeAnnotation, goToAnnotation } = useAnnotationsSync({\n entityId: entities[0]?.id,\n filesUploading,\n })\n\n // MENTION STATES\n const [mention, setMention] = useState<null | any>(null)\n const [mentionSelectedIndex, setMentionSelectedIndex] = useState(0)\n // REFS\n const editorRef = useRef<any>(null)\n const markdownRef = useRef<HTMLDivElement>(null)\n\n // if there is an initial value, set it so the editor is prefilled\n useInitialValue({\n markdownRef,\n initValue,\n setEditorValue,\n setInitHeight,\n isOpen: isOpen,\n filter: currentTab,\n })\n\n // When editing, set selection to the end of the editor\n useSetCursorEnd({ initHeight, editorRef, isEditing })\n // create a new quill format for mentions and registers it\n useMentionLink({ projectName })\n\n // focus on editor when opened\n useEffect(() => {\n if (isOpen) {\n editorRef.current?.getEditor()?.enable()\n // block autofocus if opened from an annotation\n if (annotations.length > 0 && files.length === 0) {\n return\n }\n\n editorRef.current?.focus()\n }\n // We don't set annotations or files as useEffect dependencies, because we don't want to focus\n // the input if it's already open but annotations change (e.g. are removed).\n }, [isOpen, editorRef])\n\n mentionTypes.sort((a, b) => b.length - a.length)\n\n const mentionOptions = useMemo(\n () =>\n getMentionOptions(\n mention?.type,\n {\n '@': () => getMentionUsers(mentionUsers),\n '@@': () => getMentionVersions(mentionVersions),\n '@@@': () => getMentionTasks(mentionTasks, projectInfo.taskTypes),\n },\n mention?.search,\n ),\n [mentionTasks, mentionVersions, mentionUsers, mention?.type, mention?.search],\n )\n\n // show first 5 and filter itself out\n const shownMentionOptions = mentionOptions.slice(0, 5)\n\n // triggered when a mention is selected\n const [newSelection, setNewSelection] = useState<null | number>()\n\n useEffect(() => {\n if (newSelection) {\n setNewSelection(null)\n // now we set selection to the end of the mention\n const quill = editorRef.current.getEditor()\n quill.setSelection(newSelection)\n }\n }, [newSelection])\n\n const handleSelectMention = (selectedOption: any) => {\n // get option text\n const quill = editorRef.current.getEditor()\n\n const typePrefix = mention.type // the type of mention: @, @@, @@@\n const search = typePrefix + (mention.search || '') // the full search string: @Tim\n const mentionLabel = typePrefix + selectedOption.label // the label of the mention: @Tim Bailey\n // @ts-expect-error\n const type = mentionTypeOptions[typePrefix] // the type of mention: user, version, task\n const href = `${type?.id}:${selectedOption.id}` // the href of the mention: user:user.123\n\n // get selection delta\n const selection = quill.getSelection(true)\n const selectionIndex = selection?.index || 0\n const startIndex = selectionIndex - search.length // the start index of the search\n\n // first delete the search string\n quill.deleteText(startIndex, search.length)\n\n // insert embed link\n quill.insertText(startIndex, mentionLabel, 'mention', href)\n\n const endIndex = startIndex + mentionLabel.length\n\n // insert a space after the mention\n quill.updateContents(new Delta().retain(endIndex).insert(' '))\n\n // remove single \\n after mention\n quill.updateContents(new Delta().retain(endIndex + 1).delete(1))\n\n // set selection to the end of the mention + 1\n setNewSelection(endIndex + 1)\n\n // reset mention state\n setMention(null)\n setMentionSelectedIndex(0)\n }\n\n const handleSelectChange = (option: any) => {\n handleSelectMention(option)\n }\n\n const handleChange = (content: string, delta: any, _: any, editor: any) => {\n let currentCharacter =\n (delta.ops[0] && delta.ops[0].insert) || (delta.ops[1] && delta.ops[1].insert)\n\n const tabOrEnter = currentCharacter === '\\n' || currentCharacter === '\\t'\n // find the first option\n const selectedOption = mentionOptions[mentionSelectedIndex]\n\n if (mention && tabOrEnter && selectedOption) {\n // get option text\n const retain = (delta.ops[0] && delta.ops[0].retain) || 0\n // prevent default\n\n // @ts-ignore\n handleSelectMention(selectedOption, retain)\n\n return\n }\n\n setEditorValue(content)\n\n const isDelete = delta.ops.length === 2 && !!delta.ops[1].delete\n\n if (!currentCharacter && isDelete) {\n currentCharacter = editor.getText(delta.ops[0].retain - 1, 1)\n }\n\n const isMention = mentionTypes.includes(currentCharacter)\n\n if (isMention) {\n const mentionIndex = delta.ops.findIndex((op: any) => 'insert' in op || 'delete' in op)\n const mention = currentCharacter\n let retain = mentionIndex === 0 ? 0 : delta.ops[mentionIndex - 1].retain\n if (isDelete) retain = retain - 1\n\n // for each mention denotation char, check if it is a mention\n // sort by length of mention denotation char\n let mentionMatch = null\n\n // loop through each mention denotation char, with longest first. First one to match is the one we want\n for (const chars of mentionTypes) {\n let isMatch = true\n // start with the last character\n if (chars.endsWith(mention)) {\n // loop through the chars backwards\n for (let i = chars.length - 1; i >= 0; i--) {\n // skip first character as that's already been checked\n if (i === 0) continue\n const char = chars[i - 1]\n const indexInDelta = retain - (chars.length - i)\n const valueCharAtIndex = editor.getText(indexInDelta, 1)\n if (valueCharAtIndex !== char) {\n isMatch = false\n break\n }\n }\n } else {\n isMatch = false\n }\n\n if (isMatch) {\n // console.log('match!!!', chars)\n mentionMatch = chars\n break\n }\n }\n\n if (mentionMatch) {\n setMention({\n type: mentionMatch,\n retain: retain,\n })\n } else {\n setMention(null)\n setMentionSelectedIndex(0)\n }\n } else {\n // get full string between mention and new delta\n // This is where SEARCH is handled\n if (mention) {\n const retain = delta.ops[0].retain\n // if space is pressed, remove mention\n if (currentCharacter === ' ' || !retain) {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n let distanceMentionToRetain = retain - mention.retain\n if (!isDelete) distanceMentionToRetain++\n const mentionFull = editor.getText(mention.retain, distanceMentionToRetain)\n const mentionSearch = mentionFull.replace(mention.type.slice(-1), '')\n // check for space in mentionFull\n if (mentionFull.includes(' ')) {\n setMention(null)\n setMentionSelectedIndex(0)\n } else {\n setMention({\n ...mention,\n search: mentionSearch?.toLowerCase(),\n })\n }\n } else {\n // just deleting any text\n const quill = editorRef.current.getEditor()\n const currentSelection = quill.getSelection(false)\n const currentFormat = quill.getFormat(currentSelection?.index, currentSelection?.length)\n if (currentFormat.mention) {\n // if format is mention, delete the whole mention\n const [lineBlock] = quill.getLine(currentSelection.index - 1) || []\n const ops = lineBlock?.cache?.delta?.ops || []\n // get last op with attributes mention: true\n const lastMentionOp = ops.reverse().find((op: any) => op.attributes?.mention)\n if (lastMentionOp) {\n const mentionLength = lastMentionOp.insert.length\n quill.deleteText(currentSelection.index - mentionLength, mentionLength)\n }\n }\n }\n }\n }\n\n const addTextToEditor = (type: string) => {\n // get editor retain\n const quill = editorRef.current.getEditor()\n\n let retain = quill.getSelection(true)?.index || 0\n\n // get character at retain\n const currentCharacter = quill.getText(retain - 1, 1)\n\n // if the current character is a character, increment retain\n const addSpace = currentCharacter !== ' ' && currentCharacter\n if (addSpace) {\n quill.insertText(retain, ' ')\n retain++\n }\n\n // This is hack AF, but it works\n typeWithDelay(quill, retain, type)\n }\n\n const handleMentionButton = (type: string) => {\n // first check if mention is already open\n if (mention) {\n const { type, retain, search = '' } = mention\n\n const quill = editorRef.current.getEditor()\n const length = type.length + search.length\n const start = retain - type.length + 1\n // delete the mention\n quill.deleteText(start, length)\n }\n\n addTextToEditor(type)\n }\n\n const handleOpenClick = () => {\n if (isOpen || disabled) return\n\n onOpen && onOpen()\n }\n\n const handleClose = () => {\n // get editor value\n const editor = editorRef.current.getEditor()\n const text = editor.getText()\n if (text.length < 2 || isEditing) {\n setEditorValue('')\n }\n\n // always close editor\n onClose && onClose()\n }\n\n const handleFileUploaded = ({ file, data }: any) => {\n const newFile = {\n id: data.id,\n name: file.name,\n mime: file.type,\n size: file.size,\n order: files.length,\n }\n\n setFiles((prev) => [...prev, newFile])\n // remove from uploading\n setFilesUploading((prev) => prev.filter((uploading: any) => uploading.name !== file.name))\n\n return newFile\n }\n\n const handleFileRemove = (id: string, name: string, isAnnotation: boolean) => {\n if (isAnnotation) {\n // remove from annotations (if it's an annotation)\n removeAnnotation?.(id)\n } else {\n // remove file from files\n setFiles((prev) => prev.filter((file) => file.id !== id))\n // remove from uploading\n setFilesUploading((prev) => {\n return prev.filter((file: any) => file.name !== name)\n })\n }\n }\n\n const handleFileProgress = (e: any, file: any) => {\n const progress = Math.round((e.loaded * 100) / e.total)\n if (progress !== 100) {\n const uploadProgress = {\n name: file.name,\n progress,\n type: file.type,\n order: files.length + filesUploading.length,\n }\n\n // @ts-ignore\n setFilesUploading((prev) => {\n // replace or add new progress\n const newProgress = prev.filter((name: any) => name.name !== file.name)\n return [...newProgress, uploadProgress]\n })\n }\n }\n\n // when a file is not dropped onto the comment input\n const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {\n setIsDropping(false)\n // upload file\n handleFileDrop(e, projectName, handleFileProgress, handleFileUploaded)\n }\n\n const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault()\n e.stopPropagation()\n setIsDropping(true)\n }\n\n const uploadAnnotations = useAnnotationsUpload({\n projectName,\n onSuccess: handleFileUploaded,\n })\n\n const handleSubmit = async () => {\n try {\n setIsSubmitting(true)\n // upload any annotations first\n let annotationFiles = []\n if (annotations.length) {\n annotationFiles = await uploadAnnotations(annotations)\n }\n\n // convert to markdown\n const [markdown] = convertToMarkdown(editorValue)\n\n // remove img query params\n const markdownParsed = parseImages(markdown)\n\n const uploadedFiles = [...files, ...annotationFiles]\n\n if ((markdownParsed || uploadedFiles.length) && onSubmit) {\n try {\n await onSubmit(markdownParsed, uploadedFiles)\n // only clear if onSubmit is successful\n setEditorValue('')\n setFiles([])\n } catch (error) {\n // error is handled in rtk query mutation\n return\n }\n }\n } catch (error) {\n console.error(error)\n toast.error('Something went wrong')\n } finally {\n setIsSubmitting(false)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (mention) {\n // close mention on escape\n if (e.key === 'Escape') {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n // add top search of mention\n if (mention && e.key === 'Tab') {\n // we handle this in the onChange\n }\n\n const arrowDirection = e.key === 'ArrowUp' ? -1 : e.key === 'ArrowDown' ? 1 : 0\n\n if (arrowDirection) {\n // navigate through mentions\n e.preventDefault()\n let newIndex = mentionSelectedIndex + arrowDirection\n if (newIndex < 0) newIndex = shownMentionOptions.length - 1\n if (newIndex >= shownMentionOptions.length) newIndex = 0\n setMentionSelectedIndex(newIndex)\n }\n\n if (e.key === 'Enter') {\n // we handle this in the onChange\n }\n }\n\n if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {\n handleSubmit()\n }\n\n if (e.key === 'Escape') {\n handleClose()\n }\n }\n\n let quillMinHeight: number | undefined = isOpen ? initHeight + 41 : 44\n if (isEditing) quillMinHeight = undefined\n\n // QUILL CONFIG\n const modules = useMemo(\n () =>\n getModules({\n imageUploader: {\n projectName,\n onUpload: handleFileUploaded,\n onUploadProgress: handleFileProgress,\n },\n }),\n [projectName, setFiles, setFilesUploading],\n )\n\n const allFiles = [...annotations, ...(files || []), ...filesUploading].sort(\n (a, b) => a.order - b.order,\n )\n const compactGrid = allFiles.length > 6\n\n // disable version mentions for folders\n let mentionsError = null\n if (entities.length && entities[0].entityType === 'folder') {\n if (mention?.type === '@@') {\n mentionsError = 'Version mentions are disabled for folders'\n }\n }\n\n return (\n <>\n <Styled.AutoHeight\n className={clsx('comment-container', { isOpen, isEditing })}\n onDragOver={handleDragOver}\n onDragLeave={() => setIsDropping(false)}\n onDrop={handleDrop}\n onClick={() => setIsDropping(false)}\n onKeyDown={(e) => e.stopPropagation()}\n >\n <Styled.Comment\n className={clsx('block-shortcuts', {\n isOpen,\n isClosed: !isOpen || disabled,\n isEditing,\n isDropping,\n disabled,\n isLoading,\n isSubmitting,\n })}\n onKeyDown={handleKeyDown}\n onClick={handleOpenClick}\n >\n <Styled.Markdown ref={markdownRef}>\n {/* this is purely used to translate the markdown into html for Editor */}\n <InputMarkdownConvert typeOptions={mentionTypeOptions} initValue={initValue} />\n </Styled.Markdown>\n\n {/* file uploads */}\n {isOpen && (\n <FilesGrid\n files={allFiles}\n isCompact={compactGrid}\n onRemove={handleFileRemove}\n style={{ borderBottom: '1px solid var(--md-sys-color-outline-variant)' }}\n projectName={projectName}\n onAnnotationClick={goToAnnotation}\n />\n )}\n {isOpen && !disabled ? (\n <ReactQuill\n theme=\"snow\"\n style={{ minHeight: quillMinHeight, maxHeight: 300 }}\n ref={editorRef}\n value={editorValue}\n onChange={handleChange}\n readOnly={!isOpen}\n placeholder={'Comment or mention with @user, @@version, @@@task...'}\n modules={modules}\n formats={quillFormats}\n />\n ) : (\n <Styled.Placeholder>\n {disabled ? 'Commenting is disabled across multiple projects.' : 'Add a comment...'}\n </Styled.Placeholder>\n )}\n\n <Styled.Footer>\n <Styled.Buttons>\n {/* mention a user */}\n <Button\n icon=\"person\"\n variant=\"text\"\n onClick={() => handleMentionButton('@')}\n data-tooltip={'Mention user'}\n data-shortcut={'@'}\n />\n {/* mention a version */}\n <Button\n icon=\"layers\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@')}\n data-tooltip={'Mention version'}\n data-shortcut={'@@'}\n />\n {/* mention a task */}\n <Button\n icon=\"check_circle\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@@')}\n data-tooltip={'Mention task'}\n data-shortcut={'@@@'}\n />\n </Styled.Buttons>\n <Styled.Buttons>\n {isEditing && (\n <Button variant=\"text\" onClick={handleClose}>\n Cancel\n </Button>\n )}\n <SaveButton\n label={isEditing ? 'Save' : 'Comment'}\n className=\"comment\"\n active={!!editorValue || !!files.length}\n onClick={handleSubmit}\n disabled={isLoading}\n />\n </Styled.Buttons>\n </Styled.Footer>\n\n <Styled.Dropzone className={clsx({ show: isDropping && isOpen })}>\n <Icon icon=\"cloud_upload\" />\n </Styled.Dropzone>\n </Styled.Comment>\n <CommentMentionSelect\n mention={mention}\n options={shownMentionOptions}\n onChange={handleSelectChange}\n types={mentionTypes}\n z\n // @ts-ignore\n config={mentionTypeOptions[mention?.type]}\n noneFound={!shownMentionOptions.length && mention?.search}\n noneFoundAtAll={!shownMentionOptions.length && !mention?.search}\n selectedIndex={mentionSelectedIndex}\n // @ts-ignore\n error={mentionsError}\n />\n </Styled.AutoHeight>\n </>\n )\n}\n\nexport default CommentInput\n"],"names":["_a","mention","type","jsx","Fragment","jsxs","Styled.AutoHeight","Styled.Comment","Styled.Markdown","Styled.Placeholder","Styled.Footer","Styled.Buttons","Styled.Dropzone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAI,QAAQ,MAAM,OAAO,OAAO;AAEhC,MAAM,eAAe,CAAC,KAAK,MAAM,KAAK;AAC/B,MAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,IACL,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,KAAK;AAAA,IACH,IAAI;AAAA,IACJ,UAAU;AAAA,EAAA;AAEd;AAcA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAA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AA,sBACL,SAAQ;AAAA,sBACR,SAAS,MAAM,oBAAoB,KAAK;AAAA,sBACxC,gBAAc;AAAA,sBACd,iBAAe;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACjB,GACF;AAAA,gBACAE,uCAACM,SAAA,EACE,UAAA;AAAA,kBAAA,mDACE,QAAO,EAAA,SAAQ,QAAO,SAAS,aAAa,UAE7C,UAAA;AAAA,kBAEFR,kCAAA;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,OAAO,YAAY,SAAS;AAAA,sBAC5B,WAAU;AAAA,sBACV,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,MAAM;AAAA,sBACjC,SAAS;AAAA,sBACT,UAAU;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACZ,EACF,CAAA;AAAA,cAAA,GACF;AAAA,oDAECS,UAAA,EAAgB,WAAW,KAAK,EAAE,MAAM,cAAc,OAAQ,CAAA,GAC7D,UAAAT,kCAAAA,IAAC,MAAK,EAAA,MAAK,gBAAe,EAC5B,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACAA,kCAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,SAAS;AAAA,YACT,UAAU;AAAA,YACV,OAAO;AAAA,YACP,GAAC;AAAA,YAED,QAAQ,mBAAmB,mCAAS,IAAI;AAAA,YACxC,WAAW,CAAC,oBAAoB,WAAU,mCAAS;AAAA,YACnD,gBAAgB,CAAC,oBAAoB,UAAU,EAAC,mCAAS;AAAA,YACzD,eAAe;AAAA,YAEf,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"CommentInput.es.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/CommentInput.tsx"],"sourcesContent":["// React and related hooks\nimport React, { FC, useEffect, useMemo, useRef, useState } from 'react'\n\n// Third-party libraries\nimport clsx from 'clsx'\nimport { toast } from 'react-toastify'\nimport ReactQuill, { Quill } from 'react-quill-ayon'\n\n// Components\nimport { Button, Icon, SaveButton } from '@ynput/ayon-react-components'\nimport CommentMentionSelect from '../CommentMentionSelect/CommentMentionSelect'\nimport InputMarkdownConvert from './InputMarkdownConvert'\nimport FilesGrid from '../FilesGrid'\n\n// Styled components\nimport * as Styled from './CommentInput.styled'\n\n// Helpers and utilities\nimport getMentionOptions from '../../mentionHelpers/getMentionOptions'\nimport getMentionUsers from '../../mentionHelpers/getMentionUsers'\nimport getMentionTasks from '../../mentionHelpers/getMentionTasks'\nimport getMentionVersions from '../../mentionHelpers/getMentionVersions'\nimport { convertToMarkdown } from './quillToMarkdown'\nimport { handleFileDrop, parseImages, typeWithDelay } from './helpers'\nimport { getModules, quillFormats } from './modules'\n\n// Hooks\nimport useInitialValue from './hooks/useInitialValue'\nimport useSetCursorEnd from './hooks/useSetCursorEnd'\nimport useMentionLink from './hooks/useMentionLink'\nimport useAnnotationsSync from './hooks/useAnnotationsSync'\n\n// State management\nimport useAnnotationsUpload from './hooks/useAnnotationsUpload'\nimport { useFeedContext } from '../../context/FeedContext'\nimport { SavedAnnotationMetadata } from '../../index'\n\nvar Delta = Quill.import('delta')\n\nconst mentionTypes = ['@', '@@', '@@@']\nexport const mentionTypeOptions = {\n '@@@': {\n id: 'task',\n },\n '@@': {\n id: 'version',\n },\n '@': {\n id: 'user',\n isCircle: true,\n },\n}\n\ninterface CommentInputProps {\n initValue: string | null\n initFiles?: any[]\n onSubmit: (markdown: string, files: any[], data?: any) => Promise<void>\n isEditing?: boolean\n disabled?: boolean\n isLoading?: boolean\n isOpen: boolean\n onOpen?: () => void\n onClose?: () => void\n}\n\nconst CommentInput: FC<CommentInputProps> = ({\n initValue,\n initFiles = [],\n onSubmit,\n isEditing,\n disabled,\n isLoading,\n isOpen,\n onOpen,\n onClose,\n}) => {\n const { projectName, entities, projectInfo, scope, currentTab, mentionSuggestionsData } =\n useFeedContext()\n\n const {\n users: mentionUsers,\n versions: mentionVersions,\n tasks: mentionTasks,\n } = mentionSuggestionsData || {}\n\n const [initHeight, setInitHeight] = useState(88)\n const [editorValue, setEditorValue] = useState('')\n // file uploads\n const [files, setFiles] = useState(initFiles)\n const [filesUploading, setFilesUploading] = useState([])\n const [isDropping, setIsDropping] = useState(false)\n const [isSubmitting, setIsSubmitting] = useState(false)\n\n const { annotations, removeAnnotation, goToAnnotation } = useAnnotationsSync({\n entityId: entities[0]?.id,\n filesUploading,\n })\n\n // MENTION STATES\n const [mention, setMention] = useState<null | any>(null)\n const [mentionSelectedIndex, setMentionSelectedIndex] = useState(0)\n // REFS\n const editorRef = useRef<any>(null)\n const markdownRef = useRef<HTMLDivElement>(null)\n\n // if there is an initial value, set it so the editor is prefilled\n useInitialValue({\n markdownRef,\n initValue,\n setEditorValue,\n setInitHeight,\n isOpen: isOpen,\n filter: currentTab,\n })\n\n // When editing, set selection to the end of the editor\n useSetCursorEnd({ initHeight, editorRef, isEditing })\n // create a new quill format for mentions and registers it\n useMentionLink({ projectName })\n\n // focus on editor when opened\n useEffect(() => {\n if (isOpen) {\n editorRef.current?.getEditor()?.enable()\n // block autofocus if opened from an annotation\n if (annotations.length > 0 && files.length === 0) {\n return\n }\n\n editorRef.current?.focus()\n }\n // We don't set annotations or files as useEffect dependencies, because we don't want to focus\n // the input if it's already open but annotations change (e.g. are removed).\n }, [isOpen, editorRef])\n\n mentionTypes.sort((a, b) => b.length - a.length)\n\n const mentionOptions = useMemo(\n () =>\n getMentionOptions(\n mention?.type,\n {\n '@': () => getMentionUsers(mentionUsers),\n '@@': () => getMentionVersions(mentionVersions),\n '@@@': () => getMentionTasks(mentionTasks, projectInfo.taskTypes),\n },\n mention?.search,\n ),\n [mentionTasks, mentionVersions, mentionUsers, mention?.type, mention?.search],\n )\n\n // show first 5 and filter itself out\n const shownMentionOptions = mentionOptions.slice(0, 5)\n\n // triggered when a mention is selected\n const [newSelection, setNewSelection] = useState<null | number>()\n\n useEffect(() => {\n if (newSelection) {\n setNewSelection(null)\n // now we set selection to the end of the mention\n const quill = editorRef.current.getEditor()\n quill.setSelection(newSelection)\n }\n }, [newSelection])\n\n const handleSelectMention = (selectedOption: any) => {\n // get option text\n const quill = editorRef.current.getEditor()\n\n const typePrefix = mention.type // the type of mention: @, @@, @@@\n const search = typePrefix + (mention.search || '') // the full search string: @Tim\n const mentionLabel = typePrefix + selectedOption.label // the label of the mention: @Tim Bailey\n // @ts-expect-error\n const type = mentionTypeOptions[typePrefix] // the type of mention: user, version, task\n const href = `${type?.id}:${selectedOption.id}` // the href of the mention: user:user.123\n\n // get selection delta\n const selection = quill.getSelection(true)\n const selectionIndex = selection?.index || 0\n const startIndex = selectionIndex - search.length // the start index of the search\n\n // first delete the search string\n quill.deleteText(startIndex, search.length)\n\n // insert embed link\n quill.insertText(startIndex, mentionLabel, 'mention', href)\n\n const endIndex = startIndex + mentionLabel.length\n\n // insert a space after the mention\n quill.updateContents(new Delta().retain(endIndex).insert(' '))\n\n // remove single \\n after mention\n quill.updateContents(new Delta().retain(endIndex + 1).delete(1))\n\n // set selection to the end of the mention + 1\n setNewSelection(endIndex + 1)\n\n // reset mention state\n setMention(null)\n setMentionSelectedIndex(0)\n }\n\n const handleSelectChange = (option: any) => {\n handleSelectMention(option)\n }\n\n const handleChange = (content: string, delta: any, _: any, editor: any) => {\n let currentCharacter =\n (delta.ops[0] && delta.ops[0].insert) || (delta.ops[1] && delta.ops[1].insert)\n\n const tabOrEnter = currentCharacter === '\\n' || currentCharacter === '\\t'\n // find the first option\n const selectedOption = mentionOptions[mentionSelectedIndex]\n\n if (mention && tabOrEnter && selectedOption) {\n // get option text\n const retain = (delta.ops[0] && delta.ops[0].retain) || 0\n // prevent default\n\n // @ts-ignore\n handleSelectMention(selectedOption, retain)\n\n return\n }\n\n setEditorValue(content)\n\n const isDelete = delta.ops.length === 2 && !!delta.ops[1].delete\n\n if (!currentCharacter && isDelete) {\n currentCharacter = editor.getText(delta.ops[0].retain - 1, 1)\n }\n\n const isMention = mentionTypes.includes(currentCharacter)\n\n if (isMention) {\n const mentionIndex = delta.ops.findIndex((op: any) => 'insert' in op || 'delete' in op)\n const mention = currentCharacter\n let retain = mentionIndex === 0 ? 0 : delta.ops[mentionIndex - 1].retain\n if (isDelete) retain = retain - 1\n\n // for each mention denotation char, check if it is a mention\n // sort by length of mention denotation char\n let mentionMatch = null\n\n // loop through each mention denotation char, with longest first. First one to match is the one we want\n for (const chars of mentionTypes) {\n let isMatch = true\n // start with the last character\n if (chars.endsWith(mention)) {\n // loop through the chars backwards\n for (let i = chars.length - 1; i >= 0; i--) {\n // skip first character as that's already been checked\n if (i === 0) continue\n const char = chars[i - 1]\n const indexInDelta = retain - (chars.length - i)\n const valueCharAtIndex = editor.getText(indexInDelta, 1)\n if (valueCharAtIndex !== char) {\n isMatch = false\n break\n }\n }\n } else {\n isMatch = false\n }\n\n if (isMatch) {\n // console.log('match!!!', chars)\n mentionMatch = chars\n break\n }\n }\n\n if (mentionMatch) {\n setMention({\n type: mentionMatch,\n retain: retain,\n })\n } else {\n setMention(null)\n setMentionSelectedIndex(0)\n }\n } else {\n // get full string between mention and new delta\n // This is where SEARCH is handled\n if (mention) {\n const retain = delta.ops[0].retain\n // if space is pressed, remove mention\n if (currentCharacter === ' ' || !retain) {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n let distanceMentionToRetain = retain - mention.retain\n if (!isDelete) distanceMentionToRetain++\n const mentionFull = editor.getText(mention.retain, distanceMentionToRetain)\n const mentionSearch = mentionFull.replace(mention.type.slice(-1), '')\n // check for space in mentionFull\n if (mentionFull.includes(' ')) {\n setMention(null)\n setMentionSelectedIndex(0)\n } else {\n setMention({\n ...mention,\n search: mentionSearch?.toLowerCase(),\n })\n }\n } else {\n // just deleting any text\n const quill = editorRef.current.getEditor()\n const currentSelection = quill.getSelection(false)\n const currentFormat = quill.getFormat(currentSelection?.index, currentSelection?.length)\n if (currentFormat.mention) {\n // if format is mention, delete the whole mention\n const [lineBlock] = quill.getLine(currentSelection.index - 1) || []\n const ops = lineBlock?.cache?.delta?.ops || []\n // get last op with attributes mention: true\n const lastMentionOp = ops.reverse().find((op: any) => op.attributes?.mention)\n if (lastMentionOp) {\n const mentionLength = lastMentionOp.insert.length\n quill.deleteText(currentSelection.index - mentionLength, mentionLength)\n }\n }\n }\n }\n }\n\n const addTextToEditor = (type: string) => {\n // get editor retain\n const quill = editorRef.current.getEditor()\n\n let retain = quill.getSelection(true)?.index || 0\n\n // get character at retain\n const currentCharacter = quill.getText(retain - 1, 1)\n\n // if the current character is a character, increment retain\n const addSpace = currentCharacter !== ' ' && currentCharacter\n if (addSpace) {\n quill.insertText(retain, ' ')\n retain++\n }\n\n // This is hack AF, but it works\n typeWithDelay(quill, retain, type)\n }\n\n const handleMentionButton = (type: string) => {\n // first check if mention is already open\n if (mention) {\n const { type, retain, search = '' } = mention\n\n const quill = editorRef.current.getEditor()\n const length = type.length + search.length\n const start = retain - type.length + 1\n // delete the mention\n quill.deleteText(start, length)\n }\n\n addTextToEditor(type)\n }\n\n const handleOpenClick = () => {\n if (isOpen || disabled) return\n\n onOpen && onOpen()\n }\n\n const handleClose = () => {\n // get editor value\n const editor = editorRef.current.getEditor()\n const text = editor.getText()\n if (text.length < 2 || isEditing) {\n setEditorValue('')\n }\n\n // always close editor\n onClose && onClose()\n }\n\n const handleFileUploaded = ({ file, data }: any) => {\n const newFile = {\n id: data.id,\n name: file.name,\n mime: file.type,\n size: file.size,\n order: files.length,\n }\n\n setFiles((prev) => [...prev, newFile])\n // remove from uploading\n setFilesUploading((prev) => prev.filter((uploading: any) => uploading.name !== file.name))\n\n return newFile\n }\n\n const handleFileRemove = (id: string, name: string, isUnsavedAnnotation: boolean) => {\n if (isUnsavedAnnotation) {\n // remove from annotations (if it's an unsaved annotation)\n removeAnnotation?.(id)\n } else {\n // remove file from files\n setFiles((prev) => prev.filter((file) => file.id !== id))\n // remove from uploading\n setFilesUploading((prev) => {\n return prev.filter((file: any) => file.name !== name)\n })\n }\n }\n\n const handleFileProgress = (e: any, file: any) => {\n const progress = Math.round((e.loaded * 100) / e.total)\n if (progress !== 100) {\n const uploadProgress = {\n name: file.name,\n progress,\n type: file.type,\n order: files.length + filesUploading.length,\n }\n\n // @ts-ignore\n setFilesUploading((prev) => {\n // replace or add new progress\n const newProgress = prev.filter((name: any) => name.name !== file.name)\n return [...newProgress, uploadProgress]\n })\n }\n }\n\n // when a file is not dropped onto the comment input\n const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {\n setIsDropping(false)\n // upload file\n handleFileDrop(e, projectName, handleFileProgress, handleFileUploaded)\n }\n\n const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault()\n e.stopPropagation()\n setIsDropping(true)\n }\n\n const uploadAnnotations = useAnnotationsUpload({\n projectName,\n onSuccess: handleFileUploaded,\n })\n\n const handleSubmit = async () => {\n try {\n setIsSubmitting(true)\n // upload any annotations first\n let annotationFiles = []\n let annotationMetadata: SavedAnnotationMetadata[] = []\n\n if (annotations.length) {\n const { files, metadata } = await uploadAnnotations(annotations)\n annotationFiles = files\n annotationMetadata = metadata\n }\n\n // convert to markdown\n const [markdown] = convertToMarkdown(editorValue)\n\n // remove img query params\n const markdownParsed = parseImages(markdown)\n\n const uploadedFiles = [...files, ...annotationFiles]\n\n if ((markdownParsed || uploadedFiles.length) && onSubmit) {\n try {\n await onSubmit(markdownParsed, uploadedFiles, { annotations: annotationMetadata })\n // only clear if onSubmit is successful\n setEditorValue('')\n setFiles([])\n } catch (error) {\n // error is handled in rtk query mutation\n return\n }\n }\n } catch (error) {\n console.error(error)\n toast.error('Something went wrong')\n } finally {\n setIsSubmitting(false)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (mention) {\n // close mention on escape\n if (e.key === 'Escape') {\n setMention(null)\n setMentionSelectedIndex(0)\n return\n }\n\n // add top search of mention\n if (mention && e.key === 'Tab') {\n // we handle this in the onChange\n }\n\n const arrowDirection = e.key === 'ArrowUp' ? -1 : e.key === 'ArrowDown' ? 1 : 0\n\n if (arrowDirection) {\n // navigate through mentions\n e.preventDefault()\n let newIndex = mentionSelectedIndex + arrowDirection\n if (newIndex < 0) newIndex = shownMentionOptions.length - 1\n if (newIndex >= shownMentionOptions.length) newIndex = 0\n setMentionSelectedIndex(newIndex)\n }\n\n if (e.key === 'Enter') {\n // we handle this in the onChange\n }\n }\n\n if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {\n handleSubmit()\n }\n\n if (e.key === 'Escape') {\n handleClose()\n }\n }\n\n let quillMinHeight: number | undefined = isOpen ? initHeight + 41 : 44\n if (isEditing) quillMinHeight = undefined\n\n // QUILL CONFIG\n const modules = useMemo(\n () =>\n getModules({\n imageUploader: {\n projectName,\n onUpload: handleFileUploaded,\n onUploadProgress: handleFileProgress,\n },\n }),\n [projectName, setFiles, setFilesUploading],\n )\n\n const allFiles = [...annotations, ...(files || []), ...filesUploading].sort(\n (a, b) => a.order - b.order,\n )\n const compactGrid = allFiles.length > 6\n\n // disable version mentions for folders\n let mentionsError = null\n if (entities.length && entities[0].entityType === 'folder') {\n if (mention?.type === '@@') {\n mentionsError = 'Version mentions are disabled for folders'\n }\n }\n\n return (\n <>\n <Styled.AutoHeight\n className={clsx('comment-container', { isOpen, isEditing })}\n onDragOver={handleDragOver}\n onDragLeave={() => setIsDropping(false)}\n onDrop={handleDrop}\n onClick={() => setIsDropping(false)}\n onKeyDown={(e) => e.stopPropagation()}\n >\n <Styled.Comment\n className={clsx('block-shortcuts', {\n isOpen,\n isClosed: !isOpen || disabled,\n isEditing,\n isDropping,\n disabled,\n isLoading,\n isSubmitting,\n })}\n onKeyDown={handleKeyDown}\n onClick={handleOpenClick}\n >\n <Styled.Markdown ref={markdownRef}>\n {/* this is purely used to translate the markdown into html for Editor */}\n <InputMarkdownConvert typeOptions={mentionTypeOptions} initValue={initValue} />\n </Styled.Markdown>\n\n {/* file uploads */}\n {isOpen && (\n <FilesGrid\n files={allFiles}\n isCompact={compactGrid}\n onRemove={handleFileRemove}\n style={{ borderBottom: '1px solid var(--md-sys-color-outline-variant)' }}\n projectName={projectName}\n onAnnotationClick={goToAnnotation}\n />\n )}\n {isOpen && !disabled ? (\n <ReactQuill\n theme=\"snow\"\n style={{ minHeight: quillMinHeight, maxHeight: 300 }}\n ref={editorRef}\n value={editorValue}\n onChange={handleChange}\n readOnly={!isOpen}\n placeholder={'Comment or mention with @user, @@version, @@@task...'}\n modules={modules}\n formats={quillFormats}\n />\n ) : (\n <Styled.Placeholder>\n {disabled ? 'Commenting is disabled across multiple projects.' : 'Add a comment...'}\n </Styled.Placeholder>\n )}\n\n <Styled.Footer>\n <Styled.Buttons>\n {/* mention a user */}\n <Button\n icon=\"person\"\n variant=\"text\"\n onClick={() => handleMentionButton('@')}\n data-tooltip={'Mention user'}\n data-shortcut={'@'}\n />\n {/* mention a version */}\n <Button\n icon=\"layers\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@')}\n data-tooltip={'Mention version'}\n data-shortcut={'@@'}\n />\n {/* mention a task */}\n <Button\n icon=\"check_circle\"\n variant=\"text\"\n onClick={() => handleMentionButton('@@@')}\n data-tooltip={'Mention task'}\n data-shortcut={'@@@'}\n />\n </Styled.Buttons>\n <Styled.Buttons>\n {isEditing && (\n <Button variant=\"text\" onClick={handleClose}>\n Cancel\n </Button>\n )}\n <SaveButton\n label={isEditing ? 'Save' : 'Comment'}\n className=\"comment\"\n active={!!editorValue || !!files.length}\n onClick={handleSubmit}\n disabled={isLoading}\n />\n </Styled.Buttons>\n </Styled.Footer>\n\n <Styled.Dropzone className={clsx({ show: isDropping && isOpen })}>\n <Icon icon=\"cloud_upload\" />\n </Styled.Dropzone>\n </Styled.Comment>\n <CommentMentionSelect\n mention={mention}\n options={shownMentionOptions}\n onChange={handleSelectChange}\n types={mentionTypes}\n z\n // @ts-ignore\n config={mentionTypeOptions[mention?.type]}\n noneFound={!shownMentionOptions.length && mention?.search}\n noneFoundAtAll={!shownMentionOptions.length && !mention?.search}\n selectedIndex={mentionSelectedIndex}\n // @ts-ignore\n error={mentionsError}\n />\n </Styled.AutoHeight>\n </>\n )\n}\n\nexport default CommentInput\n"],"names":["_a","mention","type","files","jsx","Fragment","jsxs","Styled.AutoHeight","Styled.Comment","Styled.Markdown","Styled.Placeholder","Styled.Footer","Styled.Buttons","Styled.Dropzone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAI,QAAQ,MAAM,OAAO,OAAO;AAEhC,MAAM,eAAe,CAAC,KAAK,MAAM,KAAK;AAC/B,MAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,IACL,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,KAAK;AAAA,IACH,IAAI;AAAA,IACJ,UAAU;AAAA,EAAA;AAEd;AAcA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA,YAAY,CAAC;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;;AACE,QAAA,EAAE,aAAa,UAAU,aAAa,OAAO,YAAY,2BAC7D,eAAe;AAEX,QAAA;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO;AAAA,EACT,IAAI,0BAA0B,CAAC;AAE/B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAC/C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,EAAE;AAEjD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,SAAS;AAC5C,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,CAAA,CAAE;AACvD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AAEtD,QAAM,EAAE,aAAa,kBAAkB,eAAA,IAAmB,mBAAmB;AAAA,IAC3E,WAAU,cAAS,CAAC,MAAV,mBAAa;AAAA,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,GAC7D,UAAAT,kCAAAA,IAAC,MAAK,EAAA,MAAK,gBAAe,EAC5B,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACAA,kCAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,SAAS;AAAA,YACT,UAAU;AAAA,YACV,OAAO;AAAA,YACP,GAAC;AAAA,YAED,QAAQ,mBAAmB,mCAAS,IAAI;AAAA,YACxC,WAAW,CAAC,oBAAoB,WAAU,mCAAS;AAAA,YACnD,gBAAgB,CAAC,oBAAoB,UAAU,EAAC,mCAAS;AAAA,YACzD,eAAe;AAAA,YAEf,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/helpers.tsx"],"sourcesContent":["// @ts-nocheck\n\n// remove any query parameters from the url\nexport const parseImages = (body) => {\n // find images in the markdown with format \n const regex = /!\\[.*?\\]\\((.*?)\\)/g\n const matches = body.match(regex)\n\n let newBody = body\n\n if (matches) {\n matches.forEach((match) => {\n if (!match.includes('http')) return\n const url = match.match(/\\(([^)]+)\\)/)[1]\n const newUrl = url.split('?')[0]\n newBody = body.replace(url, newUrl)\n })\n }\n\n return newBody\n}\n\nexport async function typeWithDelay(quill, retain, type, delay = 1) {\n for (let i = 0; i < type.length; i++) {\n quill.insertText(retain + i, type[i])\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n}\n\nimport axios from 'axios'\nconst abortController = new AbortController()\nconst cancelToken = axios.CancelToken\nconst cancelTokenSource = cancelToken.source()\nimport { toast } from 'react-toastify'\n\n// used to upload files (quill ImageUploader module)\nexport const uploadFile = (file, projectName, onUploadProgress) => {\n return new Promise((resolve, reject) => {\n const formData = new FormData()\n formData.append('image', file)\n const opts = {\n signal: abortController.signal,\n cancelToken: cancelTokenSource.token,\n onUploadProgress: (e) => onUploadProgress && onUploadProgress(e, file),\n headers: {\n 'Content-Type': file.type,\n 'x-file-name': file.name,\n },\n }\n\n axios\n .post(`/api/projects/${projectName}/files`, file, opts)\n .then((result) => {\n resolve({ file: file, data: result.data })\n })\n .catch((error) => {\n console.error(error)\n reject({ message: 'Upload failed: ' + error.response.data.detail })\n })\n })\n}\n\nexport const handleFileDrop = (e, projectName, onProgress, onSuccess) => {\n e.preventDefault()\n e.stopPropagation()\n\n let files = e.dataTransfer.files\n if (files?.length) {\n if (files.length === 0) return\n\n for (const file of files) {\n uploadFile(file, projectName, onProgress).then(\n (data) => onSuccess(data),\n (error) => {\n toast.error('Upload failed: ' + error.response.data.detail)\n console.warn(error)\n },\n )\n }\n }\n}\n"],"names":["toast"],"mappings":";;;;AAGa,MAAA,cAAc,CAAC,SAAS;AAEnC,QAAM,QAAQ;AACR,QAAA,UAAU,KAAK,MAAM,KAAK;AAEhC,MAAI,UAAU;AAEd,MAAI,SAAS;AACH,YAAA,QAAQ,CAAC,UAAU;AACzB,UAAI,CAAC,MAAM,SAAS,MAAM,EAAG;AAC7B,YAAM,MAAM,MAAM,MAAM,aAAa,EAAE,CAAC;AACxC,YAAM,SAAS,IAAI,MAAM,GAAG,EAAE,CAAC;AACrB,gBAAA,KAAK,QAAQ,KAAK,MAAM;AAAA,IAAA,CACnC;AAAA,EAAA;AAGI,SAAA;AACT;AAEA,eAAsB,cAAc,OAAO,QAAQ,MAAM,QAAQ,GAAG;AAClE,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,WAAW,SAAS,GAAG,KAAK,CAAC,CAAC;AACpC,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,CAAC;AAAA,EAAA;AAE7D;AAGA,MAAM,kBAAkB,IAAI,gBAAgB;AAC5C,MAAM,cAAc,MAAM;AAC1B,MAAM,oBAAoB,YAAY,OAAO;
|
|
1
|
+
{"version":3,"file":"helpers.cjs.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/helpers.tsx"],"sourcesContent":["// @ts-nocheck\n\n// remove any query parameters from the url\nexport const parseImages = (body) => {\n // find images in the markdown with format \n const regex = /!\\[.*?\\]\\((.*?)\\)/g\n const matches = body.match(regex)\n\n let newBody = body\n\n if (matches) {\n matches.forEach((match) => {\n if (!match.includes('http')) return\n const url = match.match(/\\(([^)]+)\\)/)[1]\n const newUrl = url.split('?')[0]\n newBody = body.replace(url, newUrl)\n })\n }\n\n return newBody\n}\n\nexport async function typeWithDelay(quill, retain, type, delay = 1) {\n for (let i = 0; i < type.length; i++) {\n quill.insertText(retain + i, type[i])\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n}\n\nimport axios from 'axios'\nconst abortController = new AbortController()\nconst cancelToken = axios.CancelToken\nconst cancelTokenSource = cancelToken.source()\nimport { toast } from 'react-toastify'\n\ntype UploadedFile = {\n file: any\n data: any\n}\n\n// used to upload files (quill ImageUploader module)\nexport const uploadFile = (file, projectName, onUploadProgress): Promise<UploadedFile> => {\n return new Promise((resolve, reject) => {\n const formData = new FormData()\n formData.append('image', file)\n const opts = {\n signal: abortController.signal,\n cancelToken: cancelTokenSource.token,\n onUploadProgress: (e) => onUploadProgress && onUploadProgress(e, file),\n headers: {\n 'Content-Type': file.type,\n 'x-file-name': file.name,\n },\n }\n\n axios\n .post(`/api/projects/${projectName}/files`, file, opts)\n .then((result) => {\n resolve({ file: file, data: result.data })\n })\n .catch((error) => {\n console.error(error)\n reject({ message: 'Upload failed: ' + error.response.data.detail })\n })\n })\n}\n\nexport const handleFileDrop = (e, projectName, onProgress, onSuccess) => {\n e.preventDefault()\n e.stopPropagation()\n\n let files = e.dataTransfer.files\n if (files?.length) {\n if (files.length === 0) return\n\n for (const file of files) {\n uploadFile(file, projectName, onProgress).then(\n (data) => onSuccess(data),\n (error) => {\n toast.error('Upload failed: ' + error.response.data.detail)\n console.warn(error)\n },\n )\n }\n }\n}\n"],"names":["toast"],"mappings":";;;;AAGa,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ChB,cAAQ,MAAM,KAAK;AACnB,aAAO,EAAE,SAAS,oBAAoB,MAAM,SAAS,KAAK,QAAQ;AAAA,IAAA,CACnE;AAAA,EAAA,CACJ;AACH;AAEO,MAAM,iBAAiB,CAAC,GAAG,aAAa,YAAY,cAAc;AACvE,IAAE,eAAe;AACjB,IAAE,gBAAgB;AAEd,MAAA,QAAQ,EAAE,aAAa;AAC3B,MAAI,+BAAO,QAAQ;AACb,QAAA,MAAM,WAAW,EAAG;AAExB,eAAW,QAAQ,OAAO;AACb,iBAAA,MAAM,aAAa,UAAU,EAAE;AAAA,QACxC,CAAC,SAAS,UAAU,IAAI;AAAA,QACxB,CAAC,UAAU;AACTA,wBAAA,MAAM,MAAM,oBAAoB,MAAM,SAAS,KAAK,MAAM;AAC1D,kBAAQ,KAAK,KAAK;AAAA,QAAA;AAAA,MAEtB;AAAA,IAAA;AAAA,EACF;AAEJ;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.es.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/helpers.tsx"],"sourcesContent":["// @ts-nocheck\n\n// remove any query parameters from the url\nexport const parseImages = (body) => {\n // find images in the markdown with format \n const regex = /!\\[.*?\\]\\((.*?)\\)/g\n const matches = body.match(regex)\n\n let newBody = body\n\n if (matches) {\n matches.forEach((match) => {\n if (!match.includes('http')) return\n const url = match.match(/\\(([^)]+)\\)/)[1]\n const newUrl = url.split('?')[0]\n newBody = body.replace(url, newUrl)\n })\n }\n\n return newBody\n}\n\nexport async function typeWithDelay(quill, retain, type, delay = 1) {\n for (let i = 0; i < type.length; i++) {\n quill.insertText(retain + i, type[i])\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n}\n\nimport axios from 'axios'\nconst abortController = new AbortController()\nconst cancelToken = axios.CancelToken\nconst cancelTokenSource = cancelToken.source()\nimport { toast } from 'react-toastify'\n\n// used to upload files (quill ImageUploader module)\nexport const uploadFile = (file, projectName, onUploadProgress) => {\n return new Promise((resolve, reject) => {\n const formData = new FormData()\n formData.append('image', file)\n const opts = {\n signal: abortController.signal,\n cancelToken: cancelTokenSource.token,\n onUploadProgress: (e) => onUploadProgress && onUploadProgress(e, file),\n headers: {\n 'Content-Type': file.type,\n 'x-file-name': file.name,\n },\n }\n\n axios\n .post(`/api/projects/${projectName}/files`, file, opts)\n .then((result) => {\n resolve({ file: file, data: result.data })\n })\n .catch((error) => {\n console.error(error)\n reject({ message: 'Upload failed: ' + error.response.data.detail })\n })\n })\n}\n\nexport const handleFileDrop = (e, projectName, onProgress, onSuccess) => {\n e.preventDefault()\n e.stopPropagation()\n\n let files = e.dataTransfer.files\n if (files?.length) {\n if (files.length === 0) return\n\n for (const file of files) {\n uploadFile(file, projectName, onProgress).then(\n (data) => onSuccess(data),\n (error) => {\n toast.error('Upload failed: ' + error.response.data.detail)\n console.warn(error)\n },\n )\n }\n }\n}\n"],"names":[],"mappings":";;AAGa,MAAA,cAAc,CAAC,SAAS;AAEnC,QAAM,QAAQ;AACR,QAAA,UAAU,KAAK,MAAM,KAAK;AAEhC,MAAI,UAAU;AAEd,MAAI,SAAS;AACH,YAAA,QAAQ,CAAC,UAAU;AACzB,UAAI,CAAC,MAAM,SAAS,MAAM,EAAG;AAC7B,YAAM,MAAM,MAAM,MAAM,aAAa,EAAE,CAAC;AACxC,YAAM,SAAS,IAAI,MAAM,GAAG,EAAE,CAAC;AACrB,gBAAA,KAAK,QAAQ,KAAK,MAAM;AAAA,IAAA,CACnC;AAAA,EAAA;AAGI,SAAA;AACT;AAEA,eAAsB,cAAc,OAAO,QAAQ,MAAM,QAAQ,GAAG;AAClE,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,WAAW,SAAS,GAAG,KAAK,CAAC,CAAC;AACpC,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,CAAC;AAAA,EAAA;AAE7D;AAGA,MAAM,kBAAkB,IAAI,gBAAgB;AAC5C,MAAM,cAAc,MAAM;AAC1B,MAAM,oBAAoB,YAAY,OAAO;
|
|
1
|
+
{"version":3,"file":"helpers.es.js","sources":["../../../../../../../src/containers/Feed/components/CommentInput/helpers.tsx"],"sourcesContent":["// @ts-nocheck\n\n// remove any query parameters from the url\nexport const parseImages = (body) => {\n // find images in the markdown with format \n const regex = /!\\[.*?\\]\\((.*?)\\)/g\n const matches = body.match(regex)\n\n let newBody = body\n\n if (matches) {\n matches.forEach((match) => {\n if (!match.includes('http')) return\n const url = match.match(/\\(([^)]+)\\)/)[1]\n const newUrl = url.split('?')[0]\n newBody = body.replace(url, newUrl)\n })\n }\n\n return newBody\n}\n\nexport async function typeWithDelay(quill, retain, type, delay = 1) {\n for (let i = 0; i < type.length; i++) {\n quill.insertText(retain + i, type[i])\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n}\n\nimport axios from 'axios'\nconst abortController = new AbortController()\nconst cancelToken = axios.CancelToken\nconst cancelTokenSource = cancelToken.source()\nimport { toast } from 'react-toastify'\n\ntype UploadedFile = {\n file: any\n data: any\n}\n\n// used to upload files (quill ImageUploader module)\nexport const uploadFile = (file, projectName, onUploadProgress): Promise<UploadedFile> => {\n return new Promise((resolve, reject) => {\n const formData = new FormData()\n formData.append('image', file)\n const opts = {\n signal: abortController.signal,\n cancelToken: cancelTokenSource.token,\n onUploadProgress: (e) => onUploadProgress && onUploadProgress(e, file),\n headers: {\n 'Content-Type': file.type,\n 'x-file-name': file.name,\n },\n }\n\n axios\n .post(`/api/projects/${projectName}/files`, file, opts)\n .then((result) => {\n resolve({ file: file, data: result.data })\n })\n .catch((error) => {\n console.error(error)\n reject({ message: 'Upload failed: ' + error.response.data.detail })\n })\n })\n}\n\nexport const handleFileDrop = (e, projectName, onProgress, onSuccess) => {\n e.preventDefault()\n e.stopPropagation()\n\n let files = e.dataTransfer.files\n if (files?.length) {\n if (files.length === 0) return\n\n for (const file of files) {\n uploadFile(file, projectName, onProgress).then(\n (data) => onSuccess(data),\n (error) => {\n toast.error('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EAAE,MAAY,MAAM,OAAO,MAAM;AAAA,IAAA,CAC1C,EACA,MAAM,CAAC,UAAU;AAChB,cAAQ,MAAM,KAAK;AACnB,aAAO,EAAE,SAAS,oBAAoB,MAAM,SAAS,KAAK,QAAQ;AAAA,IAAA,CACnE;AAAA,EAAA,CACJ;AACH;AAEO,MAAM,iBAAiB,CAAC,GAAG,aAAa,YAAY,cAAc;AACvE,IAAE,eAAe;AACjB,IAAE,gBAAgB;AAEd,MAAA,QAAQ,EAAE,aAAa;AAC3B,MAAI,+BAAO,QAAQ;AACb,QAAA,MAAM,WAAW,EAAG;AAExB,eAAW,QAAQ,OAAO;AACb,iBAAA,MAAM,aAAa,UAAU,EAAE;AAAA,QACxC,CAAC,SAAS,UAAU,IAAI;AAAA,QACxB,CAAC,UAAU;AACT,gBAAM,MAAM,oBAAoB,MAAM,SAAS,KAAK,MAAM;AAC1D,kBAAQ,KAAK,KAAK;AAAA,QAAA;AAAA,MAEtB;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ require("../../../../../context/AddonContext.cjs.js");
|
|
|
14
14
|
const filterEntityAnnotations = (annotations, entityId, filesUploading) => {
|
|
15
15
|
return Object.values(annotations).filter(
|
|
16
16
|
(annotation) => annotation.versionId === entityId && !filesUploading.some((file) => file.name === annotation.name)
|
|
17
|
-
).map((annotation) => ({ ...annotation,
|
|
17
|
+
).map((annotation) => ({ ...annotation, isUnsavedAnnotation: true }));
|
|
18
18
|
};
|
|
19
19
|
const useAnnotationsSync = ({ entityId, filesUploading }) => {
|
|
20
20
|
const { editingId, setEditingId, annotations, removeAnnotation } = FeedContext.useFeedContext();
|
package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnnotationsSync.cjs.js","sources":["../../../../../../../../src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { FEED_NEW_COMMENT, useFeedContext } from '../../../context/FeedContext'\nimport { useDetailsPanelContext } from '@shared/context'\n\ntype Props = {\n entityId: string\n filesUploading: File[]\n}\n\nexport type AnnotationPreview = any & {\n
|
|
1
|
+
{"version":3,"file":"useAnnotationsSync.cjs.js","sources":["../../../../../../../../src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { FEED_NEW_COMMENT, useFeedContext } from '../../../context/FeedContext'\nimport { useDetailsPanelContext } from '@shared/context'\n\ntype Props = {\n entityId: string\n filesUploading: File[]\n}\n\nexport type AnnotationPreview = any & {\n isUnsavedAnnotation: true\n}\n\n// annotations are temporary store\nexport const filterEntityAnnotations = (\n annotations: Record<string, any>,\n entityId: string,\n filesUploading: File[],\n): AnnotationPreview[] => {\n return Object.values(annotations)\n .filter(\n (annotation) =>\n annotation.versionId === entityId &&\n !filesUploading.some((file) => file.name === annotation.name),\n )\n .map((annotation) => ({ ...annotation, isUnsavedAnnotation: true })) as AnnotationPreview[]\n}\n\nconst useAnnotationsSync = ({ entityId, filesUploading }: Props) => {\n const { editingId, setEditingId, annotations, removeAnnotation } = useFeedContext()\n const { onGoToFrame } = useDetailsPanelContext()\n\n // filter out annotations that are for this entity and are NOT uploading\n const filteredAnnotations = filterEntityAnnotations(annotations || [], entityId, filesUploading)\n\n // when annotations change, update the state\n useEffect(() => {\n // open the comment input if there are annotations and something is not being edited already\n if (filteredAnnotations.length > 0 && !editingId) {\n setEditingId(FEED_NEW_COMMENT)\n }\n }, [filteredAnnotations])\n\n const handleGoToAnnotation = (annotation: AnnotationPreview) => {\n const firstFrame = annotation.range[0]\n onGoToFrame?.(firstFrame)\n }\n\n return {\n annotations: filteredAnnotations,\n goToAnnotation: handleGoToAnnotation,\n removeAnnotation,\n }\n}\n\nexport default useAnnotationsSync\n"],"names":["useFeedContext","useDetailsPanelContext","useEffect","FEED_NEW_COMMENT"],"mappings":";;;;;;;;;;;;;AAcO,MAAM,0BAA0B,CACrC,aACA,UACA,mBACwB;AACjB,SAAA,OAAO,OAAO,WAAW,EAC7B;AAAA,IACC,CAAC,eACC,WAAW,cAAc,YACzB,CAAC,eAAe,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW,IAAI;AAAA,EAAA,EAE/D,IAAI,CAAC,gBAAgB,EAAE,GAAG,YAAY,qBAAqB,KAAA,EAAO;AACvE;AAEA,MAAM,qBAAqB,CAAC,EAAE,UAAU,qBAA4B;AAClE,QAAM,EAAE,WAAW,cAAc,aAAa,iBAAA,IAAqBA,YAAAA,eAAe;AAC5E,QAAA,EAAE,YAAY,IAAIC,2CAAuB;AAG/C,QAAM,sBAAsB,wBAAwB,eAAe,CAAA,GAAI,UAAU,cAAc;AAG/FC,QAAAA,UAAU,MAAM;AAEd,QAAI,oBAAoB,SAAS,KAAK,CAAC,WAAW;AAChD,mBAAaC,YAAAA,gBAAgB;AAAA,IAAA;AAAA,EAC/B,GACC,CAAC,mBAAmB,CAAC;AAElB,QAAA,uBAAuB,CAAC,eAAkC;AACxD,UAAA,aAAa,WAAW,MAAM,CAAC;AACrC,+CAAc;AAAA,EAChB;AAEO,SAAA;AAAA,IACL,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB;AAAA,EACF;AACF;;;"}
|
package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import "../../../../../context/AddonContext.es.js";
|
|
|
12
12
|
const filterEntityAnnotations = (annotations, entityId, filesUploading) => {
|
|
13
13
|
return Object.values(annotations).filter(
|
|
14
14
|
(annotation) => annotation.versionId === entityId && !filesUploading.some((file) => file.name === annotation.name)
|
|
15
|
-
).map((annotation) => ({ ...annotation,
|
|
15
|
+
).map((annotation) => ({ ...annotation, isUnsavedAnnotation: true }));
|
|
16
16
|
};
|
|
17
17
|
const useAnnotationsSync = ({ entityId, filesUploading }) => {
|
|
18
18
|
const { editingId, setEditingId, annotations, removeAnnotation } = useFeedContext();
|
package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnnotationsSync.es.js","sources":["../../../../../../../../src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { FEED_NEW_COMMENT, useFeedContext } from '../../../context/FeedContext'\nimport { useDetailsPanelContext } from '@shared/context'\n\ntype Props = {\n entityId: string\n filesUploading: File[]\n}\n\nexport type AnnotationPreview = any & {\n
|
|
1
|
+
{"version":3,"file":"useAnnotationsSync.es.js","sources":["../../../../../../../../src/containers/Feed/components/CommentInput/hooks/useAnnotationsSync.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { FEED_NEW_COMMENT, useFeedContext } from '../../../context/FeedContext'\nimport { useDetailsPanelContext } from '@shared/context'\n\ntype Props = {\n entityId: string\n filesUploading: File[]\n}\n\nexport type AnnotationPreview = any & {\n isUnsavedAnnotation: true\n}\n\n// annotations are temporary store\nexport const filterEntityAnnotations = (\n annotations: Record<string, any>,\n entityId: string,\n filesUploading: File[],\n): AnnotationPreview[] => {\n return Object.values(annotations)\n .filter(\n (annotation) =>\n annotation.versionId === entityId &&\n !filesUploading.some((file) => file.name === annotation.name),\n )\n .map((annotation) => ({ ...annotation, isUnsavedAnnotation: true })) as AnnotationPreview[]\n}\n\nconst useAnnotationsSync = ({ entityId, filesUploading }: Props) => {\n const { editingId, setEditingId, annotations, removeAnnotation } = useFeedContext()\n const { onGoToFrame } = useDetailsPanelContext()\n\n // filter out annotations that are for this entity and are NOT uploading\n const filteredAnnotations = filterEntityAnnotations(annotations || [], entityId, filesUploading)\n\n // when annotations change, update the state\n useEffect(() => {\n // open the comment input if there are annotations and something is not being edited already\n if (filteredAnnotations.length > 0 && !editingId) {\n setEditingId(FEED_NEW_COMMENT)\n }\n }, [filteredAnnotations])\n\n const handleGoToAnnotation = (annotation: AnnotationPreview) => {\n const firstFrame = annotation.range[0]\n onGoToFrame?.(firstFrame)\n }\n\n return {\n annotations: filteredAnnotations,\n goToAnnotation: handleGoToAnnotation,\n removeAnnotation,\n }\n}\n\nexport default useAnnotationsSync\n"],"names":[],"mappings":";;;;;;;;;;;AAcO,MAAM,0BAA0B,CACrC,aACA,UACA,mBACwB;AACjB,SAAA,OAAO,OAAO,WAAW,EAC7B;AAAA,IACC,CAAC,eACC,WAAW,cAAc,YACzB,CAAC,eAAe,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW,IAAI;AAAA,EAAA,EAE/D,IAAI,CAAC,gBAAgB,EAAE,GAAG,YAAY,qBAAqB,KAAA,EAAO;AACvE;AAEA,MAAM,qBAAqB,CAAC,EAAE,UAAU,qBAA4B;AAClE,QAAM,EAAE,WAAW,cAAc,aAAa,iBAAA,IAAqB,eAAe;AAC5E,QAAA,EAAE,YAAY,IAAI,uBAAuB;AAG/C,QAAM,sBAAsB,wBAAwB,eAAe,CAAA,GAAI,UAAU,cAAc;AAG/F,YAAU,MAAM;AAEd,QAAI,oBAAoB,SAAS,KAAK,CAAC,WAAW;AAChD,mBAAa,gBAAgB;AAAA,IAAA;AAAA,EAC/B,GACC,CAAC,mBAAmB,CAAC;AAElB,QAAA,uBAAuB,CAAC,eAAkC;AACxD,UAAA,aAAa,WAAW,MAAM,CAAC;AACrC,+CAAc;AAAA,EAChB;AAEO,SAAA;AAAA,IACL,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB;AAAA,EACF;AACF;"}
|
package/dist/shared/src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.cjs.js
CHANGED
|
@@ -7,37 +7,49 @@ const useAnnotationsUpload = ({ projectName, onSuccess }) => {
|
|
|
7
7
|
const uploadAnnotations = async (annotations) => {
|
|
8
8
|
try {
|
|
9
9
|
const uploadPromises = annotations.map(async (annotation) => {
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
10
|
+
const composite = await (exportAnnotationComposite == null ? void 0 : exportAnnotationComposite(annotation.id));
|
|
11
|
+
if (!composite) {
|
|
12
12
|
throw new Error(`Exporting composite image for annotation ${annotation.id} failed`);
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const compositeFile = new File([composite], annotation.name, {
|
|
15
15
|
type: "image/png"
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
const transparent = await fetch(annotation.annotationData).then((r) => r.blob());
|
|
18
|
+
const transparentFile = new File([transparent], `annotation-${annotation.name}`, {
|
|
19
|
+
type: "image/png"
|
|
18
20
|
});
|
|
21
|
+
const uploads = await Promise.all([
|
|
22
|
+
helpers.uploadFile(compositeFile, projectName, () => {
|
|
23
|
+
}),
|
|
24
|
+
helpers.uploadFile(transparentFile, projectName, () => {
|
|
25
|
+
})
|
|
26
|
+
]);
|
|
27
|
+
return { annotation, uploads };
|
|
19
28
|
});
|
|
20
29
|
const res = await Promise.allSettled(uploadPromises);
|
|
21
30
|
const successfulFiles = [];
|
|
31
|
+
const metadata = [];
|
|
22
32
|
res.forEach((result) => {
|
|
23
|
-
var _a;
|
|
24
33
|
if (result.status === "fulfilled") {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
const { uploads, annotation } = result.value;
|
|
35
|
+
uploads.forEach((upload) => {
|
|
36
|
+
successfulFiles.push(onSuccess(upload));
|
|
37
|
+
});
|
|
38
|
+
metadata.push({
|
|
39
|
+
range: annotation.range,
|
|
40
|
+
id: annotation.id,
|
|
41
|
+
composite: uploads[0].data.id,
|
|
42
|
+
transparent: uploads[1].data.id
|
|
43
|
+
});
|
|
44
|
+
removeAnnotation == null ? void 0 : removeAnnotation(annotation.id);
|
|
33
45
|
} else {
|
|
34
46
|
reactToastify.toast.error("Upload failed: " + result.reason.message);
|
|
35
47
|
}
|
|
36
48
|
});
|
|
37
|
-
return successfulFiles;
|
|
49
|
+
return { files: successfulFiles, metadata };
|
|
38
50
|
} catch (error) {
|
|
39
51
|
reactToastify.toast.error("Upload failed: " + error.message);
|
|
40
|
-
return [];
|
|
52
|
+
return { files: [], metadata: [] };
|
|
41
53
|
}
|
|
42
54
|
};
|
|
43
55
|
return uploadAnnotations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnnotationsUpload.cjs.js","sources":["../../../../../../../../src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.ts"],"sourcesContent":["import { uploadFile } from '../helpers'\nimport { toast } from 'react-toastify'\nimport { useFeedContext } from '../../../context/FeedContext'\n\ntype Props = {\n projectName: string\n onSuccess: (data: any) => void\n}\n\nconst useAnnotationsUpload = ({ projectName, onSuccess }: Props) => {\n const { removeAnnotation, exportAnnotationComposite } = useFeedContext()\n\n const uploadAnnotations = async (annotations: any[]) => {\n try {\n const uploadPromises = annotations.map(async (annotation) => {\n const
|
|
1
|
+
{"version":3,"file":"useAnnotationsUpload.cjs.js","sources":["../../../../../../../../src/containers/Feed/components/CommentInput/hooks/useAnnotationsUpload.ts"],"sourcesContent":["import { uploadFile } from '../helpers'\nimport { toast } from 'react-toastify'\nimport { useFeedContext } from '../../../context/FeedContext'\nimport { SavedAnnotationMetadata } from '../../../index'\n\ntype Props = {\n projectName: string\n onSuccess: (data: any) => void\n}\n\nconst useAnnotationsUpload = ({ projectName, onSuccess }: Props) => {\n const { removeAnnotation, exportAnnotationComposite } = useFeedContext()\n\n const uploadAnnotations = async (annotations: any[]) => {\n try {\n const uploadPromises = annotations.map(async (annotation) => {\n const composite = await exportAnnotationComposite?.(annotation.id)\n if (!composite) {\n throw new Error(`Exporting composite image for annotation ${annotation.id} failed`)\n }\n\n const compositeFile = new File([composite], annotation.name, {\n type: 'image/png',\n })\n\n const transparent = await fetch(annotation.annotationData).then(r => r.blob())\n const transparentFile = new File([transparent], `annotation-${annotation.name}`, {\n type: 'image/png',\n })\n\n const uploads = await Promise.all([\n uploadFile(compositeFile, projectName, () => {}),\n uploadFile(transparentFile, projectName, () => {}),\n ])\n\n return { annotation, uploads }\n })\n\n const res = await Promise.allSettled(uploadPromises)\n\n const successfulFiles: any[] = []\n const metadata: SavedAnnotationMetadata[] = []\n\n res.forEach((result) => {\n if (result.status === 'fulfilled') {\n const { uploads, annotation } = result.value\n\n uploads.forEach((upload: any) => {\n successfulFiles.push(onSuccess(upload))\n })\n\n metadata.push({\n range: annotation.range,\n id: annotation.id,\n composite: uploads[0].data.id,\n transparent: uploads[1].data.id,\n })\n\n removeAnnotation?.(annotation.id)\n } else {\n toast.error('Upload failed: ' + result.reason.message)\n }\n })\n\n return { files: successfulFiles, metadata }\n } catch (error: any) {\n toast.error('Upload failed: ' + error.message)\n return { files: [], metadata: [] }\n }\n }\n\n return uploadAnnotations\n}\n\nexport default useAnnotationsUpload\n\nconst base64ToBlob = (base64: string) => {\n const byteString = atob(base64.split(',')[1])\n const mimeString = base64.split(',')[0].split(':')[1].split(';')[0]\n const ab = new ArrayBuffer(byteString.length)\n const ia = new Uint8Array(ab)\n for (let i = 0; i < byteString.length; i++) {\n ia[i] = byteString.charCodeAt(i)\n }\n return new Blob([ab], { type: mimeString })\n}\n"],"names":["useFeedContext","uploadFile","toast"],"mappings":";;;;AAUA,MAAM,uBAAuB,CAAC,EAAE,aAAa,gBAAuB;AAClE,QAAM,EAAE,kBAAkB,0BAA0B,IAAIA,2BAAe;AAEjE,QAAA,oBAAoB,OAAO,gBAAuB;AAClD,QAAA;AACF,YAAM,iBAAiB,YAAY,IAAI,OAAO,eAAe;AAC3D,cAAM,YAAY,OAAM,uEAA4B,WAAW;AAC/D,YAAI,CAAC,WAAW;AACd,gBAAM,IAAI,MAAM,4CAA4C,WAAW,EAAE,SAAS;AAAA,QAAA;AAGpF,cAAM,gBAAgB,IAAI,KAAK,CAAC,SAAS,GAAG,WAAW,MAAM;AAAA,UAC3D,MAAM;AAAA,QAAA,CACP;AA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