sanity 6.2.1-next.21 → 6.2.1-next.22
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/lib/_chunks-es/CommentsInspector.js +1 -0
- package/lib/_chunks-es/CommentsInspector.js.map +1 -1
- package/lib/_chunks-es/ReleasesStudioLayout.js +1 -0
- package/lib/_chunks-es/ReleasesStudioLayout.js.map +1 -1
- package/lib/_chunks-es/ReleasesTool.js +1 -0
- package/lib/_chunks-es/ReleasesTool.js.map +1 -1
- package/lib/_chunks-es/TasksDocumentInputLayout.js +1 -0
- package/lib/_chunks-es/TasksDocumentInputLayout.js.map +1 -1
- package/lib/_chunks-es/TasksFooterOpenTasks.js +1 -0
- package/lib/_chunks-es/TasksFooterOpenTasks.js.map +1 -1
- package/lib/_chunks-es/TasksStudioActiveToolLayout.js +1 -0
- package/lib/_chunks-es/TasksStudioActiveToolLayout.js.map +1 -1
- package/lib/_chunks-es/TasksStudioLayout.js +1 -0
- package/lib/_chunks-es/TasksStudioLayout.js.map +1 -1
- package/lib/_chunks-es/TasksStudioNavbar.js +1 -0
- package/lib/_chunks-es/TasksStudioNavbar.js.map +1 -1
- package/lib/_chunks-es/VariantsStudioNavbar.js +1 -0
- package/lib/_chunks-es/VariantsStudioNavbar.js.map +1 -1
- package/lib/_chunks-es/VariantsTool.js +1 -0
- package/lib/_chunks-es/VariantsTool.js.map +1 -1
- package/lib/_chunks-es/index2.js +93 -613
- package/lib/_chunks-es/index2.js.map +1 -1
- package/lib/_chunks-es/index3.js +1 -0
- package/lib/_chunks-es/index3.js.map +1 -1
- package/lib/_chunks-es/index6.js +1 -0
- package/lib/_chunks-es/index6.js.map +1 -1
- package/lib/_chunks-es/index7.js +1 -0
- package/lib/_chunks-es/index7.js.map +1 -1
- package/lib/_chunks-es/index8.js +1 -0
- package/lib/_chunks-es/index8.js.map +1 -1
- package/lib/_chunks-es/resources2.js +1 -0
- package/lib/_chunks-es/resources2.js.map +1 -1
- package/lib/_chunks-es/resources3.js +1 -0
- package/lib/_chunks-es/resources3.js.map +1 -1
- package/lib/_chunks-es/resources4.js +1 -0
- package/lib/_chunks-es/resources4.js.map +1 -1
- package/lib/_chunks-es/resources5.js +1 -0
- package/lib/_chunks-es/resources5.js.map +1 -1
- package/lib/_chunks-es/resources6.js +1 -0
- package/lib/_chunks-es/resources6.js.map +1 -1
- package/lib/_chunks-es/resources7.js +1 -0
- package/lib/_chunks-es/resources7.js.map +1 -1
- package/lib/_chunks-es/version.js +2 -2
- package/package.json +11 -11
package/lib/_chunks-es/index3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":["../../src/core/comments/plugin/document-layout/CommentsDocumentLayout.tsx"],"sourcesContent":["import {type DocumentLayoutProps} from '../../../config'\nimport {\n CommentsAuthoringPathProvider,\n CommentsEnabledProvider,\n CommentsSelectedPathProvider,\n} from '../../context'\nimport {useCommentsEnabled} from '../../hooks'\n\nexport function CommentsDocumentLayout(props: DocumentLayoutProps) {\n const {documentId, documentType} = props\n const parentContext = useCommentsEnabled()\n\n // If there is a parent context and the mode is not null, a parent provider is\n // already checking if comments are enabled. In such cases, additional wrapping\n // of the document layout in the `CommentsEnabledProvider` is unnecessary.\n // The `DocumentPane` component within the `structureTool` handles this wrapping.\n // However, as this plugin may be used in contexts outside of the `structureTool`,\n // we must check for a parent context that checks if comments are enabled and\n // conditionally apply the `CommentsEnabledProvider` wrapping if it is not present.\n if (parentContext.mode !== null) {\n return <CommentsDocumentLayoutInner {...props} />\n }\n\n return (\n <CommentsEnabledProvider documentId={documentId} documentType={documentType}>\n <CommentsDocumentLayoutInner {...props} />\n </CommentsEnabledProvider>\n )\n}\n\nfunction CommentsDocumentLayoutInner(props: DocumentLayoutProps) {\n const commentsEnabled = useCommentsEnabled()\n\n // If comments are not enabled, render the default document layout\n if (!commentsEnabled.enabled) {\n return props.renderDefault(props)\n }\n\n return (\n <CommentsSelectedPathProvider>\n <CommentsAuthoringPathProvider>{props.renderDefault(props)}</CommentsAuthoringPathProvider>\n </CommentsSelectedPathProvider>\n )\n}\n"],"names":["CommentsDocumentLayout","props","$","_c","documentId","documentType","useCommentsEnabled","mode","t0","t1","CommentsDocumentLayoutInner","enabled","renderDefault"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index3.js","sources":["../../src/core/comments/plugin/document-layout/CommentsDocumentLayout.tsx"],"sourcesContent":["import {type DocumentLayoutProps} from '../../../config'\nimport {\n CommentsAuthoringPathProvider,\n CommentsEnabledProvider,\n CommentsSelectedPathProvider,\n} from '../../context'\nimport {useCommentsEnabled} from '../../hooks'\n\nexport function CommentsDocumentLayout(props: DocumentLayoutProps) {\n const {documentId, documentType} = props\n const parentContext = useCommentsEnabled()\n\n // If there is a parent context and the mode is not null, a parent provider is\n // already checking if comments are enabled. In such cases, additional wrapping\n // of the document layout in the `CommentsEnabledProvider` is unnecessary.\n // The `DocumentPane` component within the `structureTool` handles this wrapping.\n // However, as this plugin may be used in contexts outside of the `structureTool`,\n // we must check for a parent context that checks if comments are enabled and\n // conditionally apply the `CommentsEnabledProvider` wrapping if it is not present.\n if (parentContext.mode !== null) {\n return <CommentsDocumentLayoutInner {...props} />\n }\n\n return (\n <CommentsEnabledProvider documentId={documentId} documentType={documentType}>\n <CommentsDocumentLayoutInner {...props} />\n </CommentsEnabledProvider>\n )\n}\n\nfunction CommentsDocumentLayoutInner(props: DocumentLayoutProps) {\n const commentsEnabled = useCommentsEnabled()\n\n // If comments are not enabled, render the default document layout\n if (!commentsEnabled.enabled) {\n return props.renderDefault(props)\n }\n\n return (\n <CommentsSelectedPathProvider>\n <CommentsAuthoringPathProvider>{props.renderDefault(props)}</CommentsAuthoringPathProvider>\n </CommentsSelectedPathProvider>\n )\n}\n"],"names":["CommentsDocumentLayout","props","$","_c","documentId","documentType","useCommentsEnabled","mode","t0","t1","CommentsDocumentLayoutInner","enabled","renderDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,KAAA,oBAAC,8BAAA,EACC,UAAA,oBAAC,+BAAA,EAA+BD,UAAAA,IAA2B,EAAA,CAC7D,GAA+BN,OAAAM,IAAAN,OAAAO,MAAAA,KAAAP,EAAA,CAAA,GAF/BO;AAE+B;"}
|
package/lib/_chunks-es/index6.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index6.js","sources":["../../src/core/comments/hooks/useCommentsAuthoringPath.ts","../../src/core/comments/plugin/field/CommentsFieldButton.tsx","../../src/core/comments/plugin/field/CommentsField.tsx"],"sourcesContent":["import {useContext} from 'react'\nimport {CommentsAuthoringPathContext} from 'sanity/_singletons'\n\nimport {type CommentsAuthoringPathContextValue} from '../context'\n\n/**\n * @beta\n * @hidden\n */\nexport function useCommentsAuthoringPath(): CommentsAuthoringPathContextValue {\n const value = useContext(CommentsAuthoringPathContext)\n\n if (!value) {\n throw new Error('useCommentsAuthoringPath: missing context value')\n }\n\n return value\n}\n","import {AddCommentIcon, CommentIcon} from '@sanity/icons'\nimport {type CurrentUser, type PortableTextBlock} from '@sanity/types'\nimport {\n // oxlint-disable-next-line no-restricted-imports\n Button as SanityUIButton,\n Flex,\n Stack,\n Text,\n useClickOutsideEvent,\n} from '@sanity/ui'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button, Popover, Tooltip} from '../../../../ui-components'\nimport {type UserListWithPermissionsHookValue} from '../../../hooks'\nimport {Translate, useTranslation} from '../../../i18n'\nimport {useAddonDataset} from '../../../studio/addonDataset/useAddonDataset'\nimport {CommentInput, type CommentInputHandle} from '../../components'\nimport {hasCommentMessageValue} from '../../helpers'\nimport {commentsLocaleNamespace} from '../../i18n'\nimport {type CommentMessage} from '../../types'\n\nconst ContentStack = styled(Stack)`\n width: 320px;\n`\n\ninterface CommentsFieldButtonProps {\n count: number\n currentUser: CurrentUser\n fieldTitle: string\n isCreatingDataset: boolean\n mentionOptions: UserListWithPermissionsHookValue\n onChange: (value: PortableTextBlock[]) => void\n onClick?: () => void\n onClose: () => void\n onCommentAdd: (value: PortableTextBlock[]) => void\n onDiscard: () => void\n onInputKeyDown?: (event: React.KeyboardEvent) => void\n open: boolean\n value: CommentMessage\n}\n\nexport function CommentsFieldButton(props: CommentsFieldButtonProps) {\n const {\n count,\n currentUser,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n onChange,\n onClick,\n onClose,\n onCommentAdd,\n onDiscard,\n onInputKeyDown,\n open,\n value,\n } = props\n const {t} = useTranslation(commentsLocaleNamespace)\n const {error: addonDatasetError} = useAddonDataset()\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [addCommentButtonElement, setAddCommentButtonElement] = useState<HTMLButtonElement | null>(\n null,\n )\n const commentInputHandle = useRef<CommentInputHandle | null>(null)\n const hasComments = Boolean(count > 0)\n\n const closePopover = useCallback(() => {\n if (!open) return\n onClose()\n addCommentButtonElement?.focus()\n }, [addCommentButtonElement, open, onClose])\n\n const handleSubmit = useCallback(\n (nextValue: PortableTextBlock[]) => {\n onCommentAdd(nextValue)\n closePopover()\n },\n [closePopover, onCommentAdd],\n )\n\n const hasValue = useMemo(() => hasCommentMessageValue(value), [value])\n\n const startDiscard = useCallback(() => {\n if (!hasValue) {\n closePopover()\n return\n }\n\n commentInputHandle.current?.discardDialogController.open()\n }, [closePopover, hasValue])\n\n const handleInputKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Don't act if the input already prevented this event\n if (event.isDefaultPrevented()) {\n return\n }\n\n // Call parent handler\n if (onInputKeyDown) onInputKeyDown(event)\n },\n [onInputKeyDown],\n )\n\n const handleDiscardCancel = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n }, [])\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n closePopover()\n onDiscard()\n }, [closePopover, onDiscard])\n\n const handlePopoverKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n startDiscard()\n }\n },\n [startDiscard],\n )\n\n useClickOutsideEvent(!open && startDiscard, () => [popoverRef.current])\n\n if (!hasComments) {\n const placeholder = (\n <Translate\n t={t}\n i18nKey=\"compose.add-comment-input-placeholder\"\n values={{field: fieldTitle}}\n />\n )\n\n const content = (\n <ContentStack padding={2} space={4}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onKeyDown={handleInputKeyDown}\n onSubmit={handleSubmit}\n placeholder={placeholder}\n readOnly={isCreatingDataset}\n ref={commentInputHandle}\n value={value}\n />\n </ContentStack>\n )\n\n return (\n <Popover\n constrainSize\n content={content}\n fallbackPlacements={['bottom-end']}\n open={open}\n placement=\"right-start\"\n portal\n ref={popoverRef}\n onKeyDown={handlePopoverKeyDown}\n >\n <div>\n <Button\n aria-label={t('field-button.aria-label-add')}\n disabled={isCreatingDataset || Boolean(addonDatasetError)}\n icon={AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={setAddCommentButtonElement}\n selected={open}\n tooltipProps={{\n content: t('field-button.title'),\n placement: 'top',\n }}\n />\n </div>\n </Popover>\n )\n }\n\n return (\n <Tooltip portal placement=\"top\" content={t('field-button.content', {count})}>\n <SanityUIButton\n aria-label={t('field-button.aria-label-open')}\n mode=\"bleed\"\n onClick={onClick}\n padding={2}\n space={2}\n >\n <Flex align=\"center\" gap={2}>\n <Text size={1}>\n <CommentIcon />\n </Text>\n <Text size={0}>{count > 9 ? '9+' : count}</Text>\n </Flex>\n </SanityUIButton>\n </Tooltip>\n )\n}\n","import {hues} from '@sanity/color'\nimport {type PortableTextBlock} from '@sanity/types'\nimport {Stack, useBoundaryElement} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport {AnimatePresence, motion, type Variants} from 'motion/react'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {type FieldProps} from '../../../form'\nimport {getSchemaTypeTitle} from '../../../schema'\nimport {useCurrentUser} from '../../../store'\nimport {COMMENTS_HIGHLIGHT_HUE_KEY} from '../../constants'\nimport {isTextSelectionComment} from '../../helpers'\nimport {\n applyCommentsFieldAttr,\n useComments,\n useCommentsAuthoringPath,\n useCommentsEnabled,\n useCommentsScroll,\n useCommentsSelectedPath,\n useCommentsUpsell,\n} from '../../hooks'\nimport {type CommentCreatePayload, type CommentMessage, type CommentsUIMode} from '../../types'\nimport {CommentsFieldButton} from './CommentsFieldButton'\n\n// When the form is temporarily set to `readOnly` while reconnecting, the form\n// will be re-rendered and any comment that is being authored will be lost.\n// To avoid this, we cache the comment message in a map and restore it when the\n// field is re-rendered.\nconst messageCache = new Map<string, CommentMessage>()\n\nconst EMPTY_ARRAY: [] = []\n\nconst HIGHLIGHT_BLOCK_VARIANTS: Variants = {\n initial: {\n opacity: 0,\n },\n animate: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n}\n\nexport function CommentsField(props: FieldProps) {\n const {enabled, mode} = useCommentsEnabled()\n\n if (!enabled) {\n return props.renderDefault(props)\n }\n\n return <CommentFieldInner {...props} mode={mode} />\n}\n\nconst HighlightDiv = styled(motion.div)(({theme}) => {\n const {radius, space, color} = theme.sanity\n const bg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][color.dark ? 900 : 50].hex\n\n return css`\n mix-blend-mode: ${color.dark ? 'screen' : 'multiply'};\n border-radius: ${radius[3]}px;\n top: -${space[2]}px;\n left: -${space[2]}px;\n bottom: -${space[2]}px;\n right: -${space[2]}px;\n pointer-events: none;\n position: absolute;\n z-index: 1;\n width: calc(100% + ${space[2] * 2}px);\n height: calc(100% + ${space[2] * 2}px);\n background-color: ${bg};\n `\n})\n\nconst FieldStack = styled(Stack)`\n position: relative;\n\n // Hide when the field component renders nothing (e.g. a custom\n // field component that returns null) to avoid an empty wrapper\n // taking up space in the form.\n &:empty:not([hidden]) {\n display: none;\n }\n`\n\nfunction CommentFieldInner(\n props: FieldProps & {\n mode: CommentsUIMode\n },\n) {\n const {mode} = props\n\n const currentUser = useCurrentUser()\n const {element: boundaryElement} = useBoundaryElement()\n\n const rootRef = useRef<HTMLDivElement | null>(null)\n\n const {\n comments,\n isCommentsOpen,\n isCreatingDataset,\n mentionOptions,\n onCommentsOpen,\n operation,\n setStatus,\n status,\n } = useComments()\n const {upsellData, handleOpenDialog} = useCommentsUpsell()\n const {selectedPath, setSelectedPath} = useCommentsSelectedPath()\n const {authoringPath, setAuthoringPath} = useCommentsAuthoringPath()\n const {scrollToGroup} = useCommentsScroll({\n boundaryElement,\n })\n\n const fieldTitle = useMemo(() => getSchemaTypeTitle(props.schemaType), [props.schemaType])\n const stringPath = useMemo(() => PathUtils.toString(props.path), [props.path])\n\n // Use the cached value if it exists as the initial value\n const cachedValue = messageCache.get(stringPath) || null\n\n const [value, setValue] = useState<PortableTextBlock[] | null>(cachedValue)\n\n // If the path of the field matches the authoring path, the comment input should be open.\n const isOpen = useMemo(() => authoringPath === stringPath, [authoringPath, stringPath])\n\n // Determine if the current field is selected\n const isSelected = useMemo(() => {\n if (!isCommentsOpen) return false\n if (selectedPath?.origin === 'form' || selectedPath?.origin === 'url') return false\n return selectedPath?.fieldPath === stringPath\n }, [isCommentsOpen, selectedPath?.fieldPath, selectedPath?.origin, stringPath])\n\n const isInlineCommentThread = useMemo(() => {\n return comments.data.open\n .filter((c) => c.threadId === selectedPath?.threadId)\n .some((x) => isTextSelectionComment(x.parentComment))\n }, [comments.data.open, selectedPath?.threadId])\n\n // Total number of comments for the current field\n const count = useMemo(() => {\n const commentsCount = comments.data.open\n .map((c) => (c.fieldPath === stringPath ? c.commentsCount : 0))\n .reduce((acc, val) => acc + val, 0)\n\n return commentsCount || 0\n }, [comments.data.open, stringPath])\n\n const hasComments = Boolean(count > 0)\n\n const resetMessageValue = useCallback(() => {\n // Reset the value and remove the message from the cache\n setValue(null)\n messageCache.delete(stringPath)\n }, [stringPath])\n\n const handleClick = useCallback(() => {\n // When clicking a comment button when the field has comments, we want to:\n if (hasComments) {\n // 1. Change the status to 'open' if it's 'resolved'\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // 2. Ensure that the authoring path is reset when clicking\n // the comment button when the field has comments.\n setAuthoringPath(null)\n\n // 3. Open the comments inspector\n onCommentsOpen?.()\n\n // 4. Find the latest comment thread ID for the current field\n const scrollToThreadId = comments.data.open.find(\n (c) => c.fieldPath === PathUtils.toString(props.path),\n )?.threadId\n\n // 5. Set the latest thread ID as the selected thread ID\n // and scroll to the it.\n if (scrollToThreadId) {\n // handleSetThreadToScrollTo(scrollToThreadId)\n setSelectedPath({\n threadId: scrollToThreadId,\n origin: 'form',\n fieldPath: PathUtils.toString(props.path),\n })\n\n scrollToGroup(scrollToThreadId)\n }\n\n return\n }\n\n if (mode === 'upsell') {\n if (upsellData) {\n handleOpenDialog('field_action')\n } else {\n // Open the comments inspector\n onCommentsOpen?.()\n }\n return\n }\n\n // If the field is open (i.e. the authoring path is set to the current field)\n // we close the field by resetting the authoring path. If the field is not open,\n // we set the authoring path to the current field so that the comment form is opened.\n setAuthoringPath(isOpen ? null : stringPath)\n }, [\n comments.data.open,\n handleOpenDialog,\n hasComments,\n isOpen,\n mode,\n onCommentsOpen,\n props.path,\n scrollToGroup,\n setAuthoringPath,\n setSelectedPath,\n setStatus,\n status,\n stringPath,\n upsellData,\n ])\n\n const handleCommentAdd = useCallback(\n (nextValue: PortableTextBlock[]) => {\n if (nextValue) {\n // Since this is a new comment, we generate a new thread ID\n const newThreadId = uuid()\n\n // Construct the comment payload\n const nextComment: CommentCreatePayload = {\n type: 'field',\n fieldPath: PathUtils.toString(props.path),\n message: nextValue,\n parentCommentId: undefined,\n status: 'open',\n threadId: newThreadId,\n // New comments have no reactions\n reactions: EMPTY_ARRAY,\n }\n\n // Execute the create mutation\n void operation.create(nextComment)\n\n // If a comment is added to a field when viewing resolved comments, we switch\n // to open comments and scroll to the comment that was just added\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n if (status === 'resolved') {\n // Set the status to 'open' so that the comment is visible\n setStatus('open')\n }\n\n resetMessageValue()\n\n // Scroll to the thread\n setSelectedPath({\n threadId: newThreadId,\n origin: 'form',\n fieldPath: PathUtils.toString(props.path),\n })\n\n scrollToGroup(newThreadId)\n }\n },\n [\n onCommentsOpen,\n operation,\n props.path,\n resetMessageValue,\n scrollToGroup,\n setSelectedPath,\n setStatus,\n status,\n ],\n )\n\n const handleClose = useCallback(() => setAuthoringPath(null), [setAuthoringPath])\n\n const handleOnChange = useCallback(\n (nextValue: CommentMessage) => {\n setValue(nextValue)\n messageCache.set(stringPath, nextValue)\n },\n [stringPath],\n )\n\n const internalComments: FieldProps['__internal_comments'] = useMemo(\n () => ({\n button: currentUser && (\n <CommentsFieldButton\n count={Number(count)}\n currentUser={currentUser}\n fieldTitle={fieldTitle}\n isCreatingDataset={isCreatingDataset}\n mentionOptions={mentionOptions}\n onChange={handleOnChange}\n onClick={handleClick}\n onClose={handleClose}\n onCommentAdd={handleCommentAdd}\n onDiscard={resetMessageValue}\n open={isOpen}\n value={value}\n />\n ),\n hasComments,\n isAddingComment: isOpen,\n }),\n [\n currentUser,\n count,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n handleOnChange,\n handleClick,\n handleClose,\n handleCommentAdd,\n resetMessageValue,\n isOpen,\n value,\n hasComments,\n ],\n )\n\n return (\n <FieldStack {...applyCommentsFieldAttr(PathUtils.toString(props.path))} ref={rootRef}>\n {props.renderDefault({\n ...props,\n __internal_comments: internalComments,\n })}\n\n <AnimatePresence>\n {isSelected && !isInlineCommentThread && (\n <HighlightDiv\n animate=\"animate\"\n exit=\"exit\"\n initial=\"initial\"\n variants={HIGHLIGHT_BLOCK_VARIANTS}\n />\n )}\n </AnimatePresence>\n </FieldStack>\n )\n}\n"],"names":["useCommentsAuthoringPath","value","useContext","CommentsAuthoringPathContext","Error","ContentStack","styled","Stack","withConfig","displayName","componentId","CommentsFieldButton","props","$","_c","count","currentUser","fieldTitle","isCreatingDataset","mentionOptions","onChange","onClick","onClose","onCommentAdd","onDiscard","onInputKeyDown","open","t","useTranslation","commentsLocaleNamespace","error","addonDatasetError","useAddonDataset","popoverRef","useRef","addCommentButtonElement","setAddCommentButtonElement","useState","commentInputHandle","hasComments","t0","focus","closePopover","t1","nextValue","handleSubmit","t2","hasCommentMessageValue","hasValue","t3","current","discardDialogController","startDiscard","t4","event","isDefaultPrevented","handleInputKeyDown","t5","Symbol","for","close","handleDiscardCancel","t6","handleDiscardConfirm","t7","event_0","key","preventDefault","stopPropagation","handlePopoverKeyDown","t8","useClickOutsideEvent","t9","field","t10","placeholder","t11","content","t12","t13","t14","Boolean","t15","t16","placement","t17","AddCommentIcon","t18","SanityUIButton","messageCache","Map","EMPTY_ARRAY","HIGHLIGHT_BLOCK_VARIANTS","initial","opacity","animate","exit","CommentsField","enabled","mode","useCommentsEnabled","renderDefault","HighlightDiv","motion","div","theme","radius","space","color","sanity","bg","hues","COMMENTS_HIGHLIGHT_HUE_KEY","dark","hex","css","FieldStack","CommentFieldInner","useCurrentUser","element","boundaryElement","useBoundaryElement","rootRef","comments","isCommentsOpen","onCommentsOpen","operation","setStatus","status","useComments","upsellData","handleOpenDialog","useCommentsUpsell","selectedPath","setSelectedPath","useCommentsSelectedPath","authoringPath","setAuthoringPath","scrollToGroup","useCommentsScroll","schemaType","getSchemaTypeTitle","path","PathUtils","toString","stringPath","get","cachedValue","setValue","isOpen","fieldPath","origin","isSelected","data","threadId","c","filter","some","_temp","isInlineCommentThread","c_0","commentsCount","map","reduce","_temp2","delete","resetMessageValue","scrollToThreadId","find","c_1","handleClick","newThreadId","uuid","nextComment","type","message","parentCommentId","undefined","reactions","create","handleCommentAdd","handleClose","nextValue_0","set","handleOnChange","Number","button","isAddingComment","internalComments","applyCommentsFieldAttr","__internal_comments","acc","val","x","isTextSelectionComment","parentComment"],"mappings":";;;;;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AnE,UAAAqE,OAAArE,EAAA,EAAA,MAAAwE,OAfpBE,2BAAC,cAAU,GAAKP,KAA6D0C,KAAAA,SAC1ExC,UAAAA;AAAAA,IAAAA;AAAAA,IAKDG;AAAAA,EAAAA,GAUF,GAAaxE,QAAAmE,KAAAnE,QAAAqE,KAAArE,QAAAwE,KAAAxE,QAAA0E,OAAAA,MAAA1E,EAAA,EAAA,GAhBb0E;AAgBa;AAjQjB,SAAA6E,OAAA2B,KAAAC,KAAA;AAAA,SAyD4BD,MAAMC;AAAG;AAzDrC,SAAAlC,MAAAmC,GAAA;AAAA,SAkDmBC,uBAAuBD,EAACE,aAAc;AAAC;"}
|
|
1
|
+
{"version":3,"file":"index6.js","sources":["../../src/core/comments/hooks/useCommentsAuthoringPath.ts","../../src/core/comments/plugin/field/CommentsFieldButton.tsx","../../src/core/comments/plugin/field/CommentsField.tsx"],"sourcesContent":["import {useContext} from 'react'\nimport {CommentsAuthoringPathContext} from 'sanity/_singletons'\n\nimport {type CommentsAuthoringPathContextValue} from '../context'\n\n/**\n * @beta\n * @hidden\n */\nexport function useCommentsAuthoringPath(): CommentsAuthoringPathContextValue {\n const value = useContext(CommentsAuthoringPathContext)\n\n if (!value) {\n throw new Error('useCommentsAuthoringPath: missing context value')\n }\n\n return value\n}\n","import {AddCommentIcon, CommentIcon} from '@sanity/icons'\nimport {type CurrentUser, type PortableTextBlock} from '@sanity/types'\nimport {\n // oxlint-disable-next-line no-restricted-imports\n Button as SanityUIButton,\n Flex,\n Stack,\n Text,\n useClickOutsideEvent,\n} from '@sanity/ui'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button, Popover, Tooltip} from '../../../../ui-components'\nimport {type UserListWithPermissionsHookValue} from '../../../hooks'\nimport {Translate, useTranslation} from '../../../i18n'\nimport {useAddonDataset} from '../../../studio/addonDataset/useAddonDataset'\nimport {CommentInput, type CommentInputHandle} from '../../components'\nimport {hasCommentMessageValue} from '../../helpers'\nimport {commentsLocaleNamespace} from '../../i18n'\nimport {type CommentMessage} from '../../types'\n\nconst ContentStack = styled(Stack)`\n width: 320px;\n`\n\ninterface CommentsFieldButtonProps {\n count: number\n currentUser: CurrentUser\n fieldTitle: string\n isCreatingDataset: boolean\n mentionOptions: UserListWithPermissionsHookValue\n onChange: (value: PortableTextBlock[]) => void\n onClick?: () => void\n onClose: () => void\n onCommentAdd: (value: PortableTextBlock[]) => void\n onDiscard: () => void\n onInputKeyDown?: (event: React.KeyboardEvent) => void\n open: boolean\n value: CommentMessage\n}\n\nexport function CommentsFieldButton(props: CommentsFieldButtonProps) {\n const {\n count,\n currentUser,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n onChange,\n onClick,\n onClose,\n onCommentAdd,\n onDiscard,\n onInputKeyDown,\n open,\n value,\n } = props\n const {t} = useTranslation(commentsLocaleNamespace)\n const {error: addonDatasetError} = useAddonDataset()\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [addCommentButtonElement, setAddCommentButtonElement] = useState<HTMLButtonElement | null>(\n null,\n )\n const commentInputHandle = useRef<CommentInputHandle | null>(null)\n const hasComments = Boolean(count > 0)\n\n const closePopover = useCallback(() => {\n if (!open) return\n onClose()\n addCommentButtonElement?.focus()\n }, [addCommentButtonElement, open, onClose])\n\n const handleSubmit = useCallback(\n (nextValue: PortableTextBlock[]) => {\n onCommentAdd(nextValue)\n closePopover()\n },\n [closePopover, onCommentAdd],\n )\n\n const hasValue = useMemo(() => hasCommentMessageValue(value), [value])\n\n const startDiscard = useCallback(() => {\n if (!hasValue) {\n closePopover()\n return\n }\n\n commentInputHandle.current?.discardDialogController.open()\n }, [closePopover, hasValue])\n\n const handleInputKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Don't act if the input already prevented this event\n if (event.isDefaultPrevented()) {\n return\n }\n\n // Call parent handler\n if (onInputKeyDown) onInputKeyDown(event)\n },\n [onInputKeyDown],\n )\n\n const handleDiscardCancel = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n }, [])\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n closePopover()\n onDiscard()\n }, [closePopover, onDiscard])\n\n const handlePopoverKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n startDiscard()\n }\n },\n [startDiscard],\n )\n\n useClickOutsideEvent(!open && startDiscard, () => [popoverRef.current])\n\n if (!hasComments) {\n const placeholder = (\n <Translate\n t={t}\n i18nKey=\"compose.add-comment-input-placeholder\"\n values={{field: fieldTitle}}\n />\n )\n\n const content = (\n <ContentStack padding={2} space={4}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onKeyDown={handleInputKeyDown}\n onSubmit={handleSubmit}\n placeholder={placeholder}\n readOnly={isCreatingDataset}\n ref={commentInputHandle}\n value={value}\n />\n </ContentStack>\n )\n\n return (\n <Popover\n constrainSize\n content={content}\n fallbackPlacements={['bottom-end']}\n open={open}\n placement=\"right-start\"\n portal\n ref={popoverRef}\n onKeyDown={handlePopoverKeyDown}\n >\n <div>\n <Button\n aria-label={t('field-button.aria-label-add')}\n disabled={isCreatingDataset || Boolean(addonDatasetError)}\n icon={AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={setAddCommentButtonElement}\n selected={open}\n tooltipProps={{\n content: t('field-button.title'),\n placement: 'top',\n }}\n />\n </div>\n </Popover>\n )\n }\n\n return (\n <Tooltip portal placement=\"top\" content={t('field-button.content', {count})}>\n <SanityUIButton\n aria-label={t('field-button.aria-label-open')}\n mode=\"bleed\"\n onClick={onClick}\n padding={2}\n space={2}\n >\n <Flex align=\"center\" gap={2}>\n <Text size={1}>\n <CommentIcon />\n </Text>\n <Text size={0}>{count > 9 ? '9+' : count}</Text>\n </Flex>\n </SanityUIButton>\n </Tooltip>\n )\n}\n","import {hues} from '@sanity/color'\nimport {type PortableTextBlock} from '@sanity/types'\nimport {Stack, useBoundaryElement} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport {AnimatePresence, motion, type Variants} from 'motion/react'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {type FieldProps} from '../../../form'\nimport {getSchemaTypeTitle} from '../../../schema'\nimport {useCurrentUser} from '../../../store'\nimport {COMMENTS_HIGHLIGHT_HUE_KEY} from '../../constants'\nimport {isTextSelectionComment} from '../../helpers'\nimport {\n applyCommentsFieldAttr,\n useComments,\n useCommentsAuthoringPath,\n useCommentsEnabled,\n useCommentsScroll,\n useCommentsSelectedPath,\n useCommentsUpsell,\n} from '../../hooks'\nimport {type CommentCreatePayload, type CommentMessage, type CommentsUIMode} from '../../types'\nimport {CommentsFieldButton} from './CommentsFieldButton'\n\n// When the form is temporarily set to `readOnly` while reconnecting, the form\n// will be re-rendered and any comment that is being authored will be lost.\n// To avoid this, we cache the comment message in a map and restore it when the\n// field is re-rendered.\nconst messageCache = new Map<string, CommentMessage>()\n\nconst EMPTY_ARRAY: [] = []\n\nconst HIGHLIGHT_BLOCK_VARIANTS: Variants = {\n initial: {\n opacity: 0,\n },\n animate: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n}\n\nexport function CommentsField(props: FieldProps) {\n const {enabled, mode} = useCommentsEnabled()\n\n if (!enabled) {\n return props.renderDefault(props)\n }\n\n return <CommentFieldInner {...props} mode={mode} />\n}\n\nconst HighlightDiv = styled(motion.div)(({theme}) => {\n const {radius, space, color} = theme.sanity\n const bg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][color.dark ? 900 : 50].hex\n\n return css`\n mix-blend-mode: ${color.dark ? 'screen' : 'multiply'};\n border-radius: ${radius[3]}px;\n top: -${space[2]}px;\n left: -${space[2]}px;\n bottom: -${space[2]}px;\n right: -${space[2]}px;\n pointer-events: none;\n position: absolute;\n z-index: 1;\n width: calc(100% + ${space[2] * 2}px);\n height: calc(100% + ${space[2] * 2}px);\n background-color: ${bg};\n `\n})\n\nconst FieldStack = styled(Stack)`\n position: relative;\n\n // Hide when the field component renders nothing (e.g. a custom\n // field component that returns null) to avoid an empty wrapper\n // taking up space in the form.\n &:empty:not([hidden]) {\n display: none;\n }\n`\n\nfunction CommentFieldInner(\n props: FieldProps & {\n mode: CommentsUIMode\n },\n) {\n const {mode} = props\n\n const currentUser = useCurrentUser()\n const {element: boundaryElement} = useBoundaryElement()\n\n const rootRef = useRef<HTMLDivElement | null>(null)\n\n const {\n comments,\n isCommentsOpen,\n isCreatingDataset,\n mentionOptions,\n onCommentsOpen,\n operation,\n setStatus,\n status,\n } = useComments()\n const {upsellData, handleOpenDialog} = useCommentsUpsell()\n const {selectedPath, setSelectedPath} = useCommentsSelectedPath()\n const {authoringPath, setAuthoringPath} = useCommentsAuthoringPath()\n const {scrollToGroup} = useCommentsScroll({\n boundaryElement,\n })\n\n const fieldTitle = useMemo(() => getSchemaTypeTitle(props.schemaType), [props.schemaType])\n const stringPath = useMemo(() => PathUtils.toString(props.path), [props.path])\n\n // Use the cached value if it exists as the initial value\n const cachedValue = messageCache.get(stringPath) || null\n\n const [value, setValue] = useState<PortableTextBlock[] | null>(cachedValue)\n\n // If the path of the field matches the authoring path, the comment input should be open.\n const isOpen = useMemo(() => authoringPath === stringPath, [authoringPath, stringPath])\n\n // Determine if the current field is selected\n const isSelected = useMemo(() => {\n if (!isCommentsOpen) return false\n if (selectedPath?.origin === 'form' || selectedPath?.origin === 'url') return false\n return selectedPath?.fieldPath === stringPath\n }, [isCommentsOpen, selectedPath?.fieldPath, selectedPath?.origin, stringPath])\n\n const isInlineCommentThread = useMemo(() => {\n return comments.data.open\n .filter((c) => c.threadId === selectedPath?.threadId)\n .some((x) => isTextSelectionComment(x.parentComment))\n }, [comments.data.open, selectedPath?.threadId])\n\n // Total number of comments for the current field\n const count = useMemo(() => {\n const commentsCount = comments.data.open\n .map((c) => (c.fieldPath === stringPath ? c.commentsCount : 0))\n .reduce((acc, val) => acc + val, 0)\n\n return commentsCount || 0\n }, [comments.data.open, stringPath])\n\n const hasComments = Boolean(count > 0)\n\n const resetMessageValue = useCallback(() => {\n // Reset the value and remove the message from the cache\n setValue(null)\n messageCache.delete(stringPath)\n }, [stringPath])\n\n const handleClick = useCallback(() => {\n // When clicking a comment button when the field has comments, we want to:\n if (hasComments) {\n // 1. Change the status to 'open' if it's 'resolved'\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // 2. Ensure that the authoring path is reset when clicking\n // the comment button when the field has comments.\n setAuthoringPath(null)\n\n // 3. Open the comments inspector\n onCommentsOpen?.()\n\n // 4. Find the latest comment thread ID for the current field\n const scrollToThreadId = comments.data.open.find(\n (c) => c.fieldPath === PathUtils.toString(props.path),\n )?.threadId\n\n // 5. Set the latest thread ID as the selected thread ID\n // and scroll to the it.\n if (scrollToThreadId) {\n // handleSetThreadToScrollTo(scrollToThreadId)\n setSelectedPath({\n threadId: scrollToThreadId,\n origin: 'form',\n fieldPath: PathUtils.toString(props.path),\n })\n\n scrollToGroup(scrollToThreadId)\n }\n\n return\n }\n\n if (mode === 'upsell') {\n if (upsellData) {\n handleOpenDialog('field_action')\n } else {\n // Open the comments inspector\n onCommentsOpen?.()\n }\n return\n }\n\n // If the field is open (i.e. the authoring path is set to the current field)\n // we close the field by resetting the authoring path. If the field is not open,\n // we set the authoring path to the current field so that the comment form is opened.\n setAuthoringPath(isOpen ? null : stringPath)\n }, [\n comments.data.open,\n handleOpenDialog,\n hasComments,\n isOpen,\n mode,\n onCommentsOpen,\n props.path,\n scrollToGroup,\n setAuthoringPath,\n setSelectedPath,\n setStatus,\n status,\n stringPath,\n upsellData,\n ])\n\n const handleCommentAdd = useCallback(\n (nextValue: PortableTextBlock[]) => {\n if (nextValue) {\n // Since this is a new comment, we generate a new thread ID\n const newThreadId = uuid()\n\n // Construct the comment payload\n const nextComment: CommentCreatePayload = {\n type: 'field',\n fieldPath: PathUtils.toString(props.path),\n message: nextValue,\n parentCommentId: undefined,\n status: 'open',\n threadId: newThreadId,\n // New comments have no reactions\n reactions: EMPTY_ARRAY,\n }\n\n // Execute the create mutation\n void operation.create(nextComment)\n\n // If a comment is added to a field when viewing resolved comments, we switch\n // to open comments and scroll to the comment that was just added\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n if (status === 'resolved') {\n // Set the status to 'open' so that the comment is visible\n setStatus('open')\n }\n\n resetMessageValue()\n\n // Scroll to the thread\n setSelectedPath({\n threadId: newThreadId,\n origin: 'form',\n fieldPath: PathUtils.toString(props.path),\n })\n\n scrollToGroup(newThreadId)\n }\n },\n [\n onCommentsOpen,\n operation,\n props.path,\n resetMessageValue,\n scrollToGroup,\n setSelectedPath,\n setStatus,\n status,\n ],\n )\n\n const handleClose = useCallback(() => setAuthoringPath(null), [setAuthoringPath])\n\n const handleOnChange = useCallback(\n (nextValue: CommentMessage) => {\n setValue(nextValue)\n messageCache.set(stringPath, nextValue)\n },\n [stringPath],\n )\n\n const internalComments: FieldProps['__internal_comments'] = useMemo(\n () => ({\n button: currentUser && (\n <CommentsFieldButton\n count={Number(count)}\n currentUser={currentUser}\n fieldTitle={fieldTitle}\n isCreatingDataset={isCreatingDataset}\n mentionOptions={mentionOptions}\n onChange={handleOnChange}\n onClick={handleClick}\n onClose={handleClose}\n onCommentAdd={handleCommentAdd}\n onDiscard={resetMessageValue}\n open={isOpen}\n value={value}\n />\n ),\n hasComments,\n isAddingComment: isOpen,\n }),\n [\n currentUser,\n count,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n handleOnChange,\n handleClick,\n handleClose,\n handleCommentAdd,\n resetMessageValue,\n isOpen,\n value,\n hasComments,\n ],\n )\n\n return (\n <FieldStack {...applyCommentsFieldAttr(PathUtils.toString(props.path))} ref={rootRef}>\n {props.renderDefault({\n ...props,\n __internal_comments: internalComments,\n })}\n\n <AnimatePresence>\n {isSelected && !isInlineCommentThread && (\n <HighlightDiv\n animate=\"animate\"\n exit=\"exit\"\n initial=\"initial\"\n variants={HIGHLIGHT_BLOCK_VARIANTS}\n />\n )}\n </AnimatePresence>\n </FieldStack>\n )\n}\n"],"names":["useCommentsAuthoringPath","value","useContext","CommentsAuthoringPathContext","Error","ContentStack","styled","Stack","withConfig","displayName","componentId","CommentsFieldButton","props","$","_c","count","currentUser","fieldTitle","isCreatingDataset","mentionOptions","onChange","onClick","onClose","onCommentAdd","onDiscard","onInputKeyDown","open","t","useTranslation","commentsLocaleNamespace","error","addonDatasetError","useAddonDataset","popoverRef","useRef","addCommentButtonElement","setAddCommentButtonElement","useState","commentInputHandle","hasComments","t0","focus","closePopover","t1","nextValue","handleSubmit","t2","hasCommentMessageValue","hasValue","t3","current","discardDialogController","startDiscard","t4","event","isDefaultPrevented","handleInputKeyDown","t5","Symbol","for","close","handleDiscardCancel","t6","handleDiscardConfirm","t7","event_0","key","preventDefault","stopPropagation","handlePopoverKeyDown","t8","useClickOutsideEvent","t9","field","t10","placeholder","t11","content","t12","t13","t14","Boolean","t15","t16","placement","t17","AddCommentIcon","t18","SanityUIButton","messageCache","Map","EMPTY_ARRAY","HIGHLIGHT_BLOCK_VARIANTS","initial","opacity","animate","exit","CommentsField","enabled","mode","useCommentsEnabled","renderDefault","HighlightDiv","motion","div","theme","radius","space","color","sanity","bg","hues","COMMENTS_HIGHLIGHT_HUE_KEY","dark","hex","css","FieldStack","CommentFieldInner","useCurrentUser","element","boundaryElement","useBoundaryElement","rootRef","comments","isCommentsOpen","onCommentsOpen","operation","setStatus","status","useComments","upsellData","handleOpenDialog","useCommentsUpsell","selectedPath","setSelectedPath","useCommentsSelectedPath","authoringPath","setAuthoringPath","scrollToGroup","useCommentsScroll","schemaType","getSchemaTypeTitle","path","PathUtils","toString","stringPath","get","cachedValue","setValue","isOpen","fieldPath","origin","isSelected","data","threadId","c","filter","some","_temp","isInlineCommentThread","c_0","commentsCount","map","reduce","_temp2","delete","resetMessageValue","scrollToThreadId","find","c_1","handleClick","newThreadId","uuid","nextComment","type","message","parentCommentId","undefined","reactions","create","handleCommentAdd","handleClose","nextValue_0","set","handleOnChange","Number","button","isAddingComment","internalComments","applyCommentsFieldAttr","__internal_comments","acc","val","x","isTextSelectionComment","parentComment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,SAAAA,2BAAA;AACL,QAAAC,QAAcC,WAAWC,4BAA4B;AAErD,MAAI,CAACF;AACH,UAAM,IAAIG,MAAM,iDAAiD;AAClE,SAEMH;AAAK;ACMd,MAAMI,eAAeC,OAAOC,KAAK,EAACC,WAAA;AAAA,EAAAC,aAAA;AAAA,EAAAC,aAAA;AAAA,CAAA;AAoB3B,SAAAC,oBAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GACL;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAzB;AAAAA,EAAAA,IAcIW,OACJ;AAAA,IAAAe;AAAAA,EAAAA,IAAYC,eAAeC,uBAAuB,GAClD;AAAA,IAAAC,OAAAC;AAAAA,EAAAA,IAAmCC,gBAAAA,GACnCC,aAAmBC,OAA8B,IAAI,GACrD,CAAAC,yBAAAC,0BAAA,IAA8DC,SAC5D,IACF,GACAC,qBAA2BJ,OAAkC,IAAI,GACjEK,cAA4BxB,QAAQ;AAAE,MAAAyB;AAAA3B,IAAA,CAAA,MAAAsB,2BAAAtB,SAAAS,WAAAT,EAAA,CAAA,MAAAa,QAELc,KAAAA,MAAA;AAC1Bd,aACLJ,QAAAA,GACAa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A,EAAA;AAAA,MAAAwE;AAAAxE,YAAAsE,OARHE,MAAA,oBAAC,mBACEF,UAAAA,IAAAA,CAQH,GAAkBtE,QAAAsE,KAAAtE,QAAAwE,OAAAA,MAAAxE,EAAA,EAAA;AAAA,MAAA0E;AAAA,SAAA1E,EAAA,EAAA,MAAAmE,OAAAnE,UAAAqE,OAAArE,EAAA,EAAA,MAAAwE,OAfpBE,2BAAC,cAAU,GAAKP,KAA6D0C,KAAAA,SAC1ExC,UAAAA;AAAAA,IAAAA;AAAAA,IAKDG;AAAAA,EAAAA,GAUF,GAAaxE,QAAAmE,KAAAnE,QAAAqE,KAAArE,QAAAwE,KAAAxE,QAAA0E,OAAAA,MAAA1E,EAAA,EAAA,GAhBb0E;AAgBa;AAjQjB,SAAA6E,OAAA2B,KAAAC,KAAA;AAAA,SAyD4BD,MAAMC;AAAG;AAzDrC,SAAAlC,MAAAmC,GAAA;AAAA,SAkDmBC,uBAAuBD,EAACE,aAAc;AAAC;"}
|
package/lib/_chunks-es/index7.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index7.js","sources":["../../src/core/comments/context/onboarding/CommentsOnboardingProvider.tsx","../../src/core/comments/context/upsell/CommentsUpsellProvider.tsx","../../src/core/comments/plugin/studio-layout/CommentsStudioLayout.tsx"],"sourcesContent":["import {type ReactNode, useCallback, useMemo, useState} from 'react'\nimport {CommentsOnboardingContext} from 'sanity/_singletons'\n\nimport {type CommentsOnboardingContextValue} from './types'\n\nconst VERSION = 1\nconst LOCAL_STORAGE_KEY = `sanityStudio:comments:inspector:onboarding:dismissed:v${VERSION}`\n\nconst setLocalStorage = (value: boolean) => {\n try {\n window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(value))\n } catch {\n // Fail silently\n }\n}\n\nconst getLocalStorage = (): boolean => {\n try {\n const value = window.localStorage.getItem(LOCAL_STORAGE_KEY)\n return value ? JSON.parse(value) : false\n } catch {\n return false\n }\n}\n\ninterface CommentsOnboardingProviderProps {\n children: ReactNode\n}\n\nexport function CommentsOnboardingProvider(props: CommentsOnboardingProviderProps) {\n const {children} = props\n const [dismissed, setDismissed] = useState<boolean>(getLocalStorage())\n\n const handleDismiss = useCallback(() => {\n setDismissed(true)\n setLocalStorage(true)\n }, [setDismissed])\n\n const ctxValue = useMemo(\n (): CommentsOnboardingContextValue => ({\n setDismissed: handleDismiss,\n isDismissed: dismissed,\n }),\n [handleDismiss, dismissed],\n )\n\n return (\n <CommentsOnboardingContext.Provider value={ctxValue}>\n {children}\n </CommentsOnboardingContext.Provider>\n )\n}\n","import {CommentsUpsellContext} from 'sanity/_singletons'\n\nimport {getDialogPropsFromContext, useUpsellContext} from '../../../hooks/useUpsellContext'\nimport {UpsellDialog} from '../../../studio/upsell/UpsellDialog'\n\n/**\n * @beta\n * @hidden\n */\nexport function CommentsUpsellProvider(props: {children: React.ReactNode}) {\n const contextValue = useUpsellContext({\n dataUri: '/journey/comments',\n feature: 'comments',\n })\n\n return (\n <CommentsUpsellContext.Provider value={contextValue}>\n {props.children}\n <UpsellDialog {...getDialogPropsFromContext(contextValue)} />\n </CommentsUpsellContext.Provider>\n )\n}\n","import {type LayoutProps} from '../../../config'\nimport {useFeatureEnabled} from '../../../hooks'\nimport {FEATURES} from '../../../hooks/useFeatureEnabled'\nimport {AddonDatasetProvider} from '../../../studio'\nimport {CommentsOnboardingProvider, CommentsUpsellProvider} from '../../context'\n\nexport function CommentsStudioLayout(props: LayoutProps) {\n const {enabled, isLoading} = useFeatureEnabled(FEATURES.studioComments)\n const children = props.renderDefault(props)\n\n return (\n <AddonDatasetProvider>\n <CommentsOnboardingProvider>\n {!enabled && !isLoading ? (\n <CommentsUpsellProvider>{children}</CommentsUpsellProvider>\n ) : (\n children\n )}\n </CommentsOnboardingProvider>\n </AddonDatasetProvider>\n )\n}\n"],"names":["VERSION","LOCAL_STORAGE_KEY","setLocalStorage","value","window","localStorage","setItem","JSON","stringify","getLocalStorage","getItem","parse","CommentsOnboardingProvider","props","$","_c","children","t0","Symbol","for","dismissed","setDismissed","useState","t1","handleDismiss","t2","isDismissed","ctxValue","t3","CommentsUpsellProvider","dataUri","feature","contextValue","useUpsellContext","getDialogPropsFromContext","t4","CommentsStudioLayout","enabled","isLoading","useFeatureEnabled","FEATURES","studioComments","renderDefault"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index7.js","sources":["../../src/core/comments/context/onboarding/CommentsOnboardingProvider.tsx","../../src/core/comments/context/upsell/CommentsUpsellProvider.tsx","../../src/core/comments/plugin/studio-layout/CommentsStudioLayout.tsx"],"sourcesContent":["import {type ReactNode, useCallback, useMemo, useState} from 'react'\nimport {CommentsOnboardingContext} from 'sanity/_singletons'\n\nimport {type CommentsOnboardingContextValue} from './types'\n\nconst VERSION = 1\nconst LOCAL_STORAGE_KEY = `sanityStudio:comments:inspector:onboarding:dismissed:v${VERSION}`\n\nconst setLocalStorage = (value: boolean) => {\n try {\n window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(value))\n } catch {\n // Fail silently\n }\n}\n\nconst getLocalStorage = (): boolean => {\n try {\n const value = window.localStorage.getItem(LOCAL_STORAGE_KEY)\n return value ? JSON.parse(value) : false\n } catch {\n return false\n }\n}\n\ninterface CommentsOnboardingProviderProps {\n children: ReactNode\n}\n\nexport function CommentsOnboardingProvider(props: CommentsOnboardingProviderProps) {\n const {children} = props\n const [dismissed, setDismissed] = useState<boolean>(getLocalStorage())\n\n const handleDismiss = useCallback(() => {\n setDismissed(true)\n setLocalStorage(true)\n }, [setDismissed])\n\n const ctxValue = useMemo(\n (): CommentsOnboardingContextValue => ({\n setDismissed: handleDismiss,\n isDismissed: dismissed,\n }),\n [handleDismiss, dismissed],\n )\n\n return (\n <CommentsOnboardingContext.Provider value={ctxValue}>\n {children}\n </CommentsOnboardingContext.Provider>\n )\n}\n","import {CommentsUpsellContext} from 'sanity/_singletons'\n\nimport {getDialogPropsFromContext, useUpsellContext} from '../../../hooks/useUpsellContext'\nimport {UpsellDialog} from '../../../studio/upsell/UpsellDialog'\n\n/**\n * @beta\n * @hidden\n */\nexport function CommentsUpsellProvider(props: {children: React.ReactNode}) {\n const contextValue = useUpsellContext({\n dataUri: '/journey/comments',\n feature: 'comments',\n })\n\n return (\n <CommentsUpsellContext.Provider value={contextValue}>\n {props.children}\n <UpsellDialog {...getDialogPropsFromContext(contextValue)} />\n </CommentsUpsellContext.Provider>\n )\n}\n","import {type LayoutProps} from '../../../config'\nimport {useFeatureEnabled} from '../../../hooks'\nimport {FEATURES} from '../../../hooks/useFeatureEnabled'\nimport {AddonDatasetProvider} from '../../../studio'\nimport {CommentsOnboardingProvider, CommentsUpsellProvider} from '../../context'\n\nexport function CommentsStudioLayout(props: LayoutProps) {\n const {enabled, isLoading} = useFeatureEnabled(FEATURES.studioComments)\n const children = props.renderDefault(props)\n\n return (\n <AddonDatasetProvider>\n <CommentsOnboardingProvider>\n {!enabled && !isLoading ? (\n <CommentsUpsellProvider>{children}</CommentsUpsellProvider>\n ) : (\n children\n )}\n </CommentsOnboardingProvider>\n </AddonDatasetProvider>\n )\n}\n"],"names":["VERSION","LOCAL_STORAGE_KEY","setLocalStorage","value","window","localStorage","setItem","JSON","stringify","getLocalStorage","getItem","parse","CommentsOnboardingProvider","props","$","_c","children","t0","Symbol","for","dismissed","setDismissed","useState","t1","handleDismiss","t2","isDismissed","ctxValue","t3","CommentsUpsellProvider","dataUri","feature","contextValue","useUpsellContext","getDialogPropsFromContext","t4","CommentsStudioLayout","enabled","isLoading","useFeatureEnabled","FEATURES","studioComments","renderDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,UAAU,GACVC,oBAAoB,yDAAyDD,OAAO,IAEpFE,kBAAmBC,CAAAA,UAAmB;AAC1C,MAAI;AACFC,WAAO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AIAF,OAAAE,UAAAF,OAAAuB,SAAAvB,OAAAwB,WAAAxB,OAAAS,MAAAA,KAAAT,EAAA,CAAA;AAAA,MAAAW;AAAA,SAAAX,SAAAS,MANLE,KAAA,oBAAC,sBAAA,EACC,UAAA,oBAAC,4BAAA,EACEF,UAAAA,IAKH,EAAA,CACF,GAAuBT,OAAAS,IAAAT,OAAAW,MAAAA,KAAAX,EAAA,CAAA,GARvBW;AAQuB;"}
|
package/lib/_chunks-es/index8.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index8.js","sources":["../../src/core/comments/plugin/input/helpers.ts","../../src/core/comments/plugin/input/components/FloatingButtonPopover.tsx","../../src/core/comments/plugin/input/components/InlineCommentInputPopover.tsx","../../src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx","../../src/core/comments/plugin/input/CommentsInput.tsx"],"sourcesContent":["import {useEffect, useMemo, useState} from 'react'\n\n/**\n * A function that creates a DOMRect from an array of elements.\n */\nfunction createDomRectFromElements(elements: Element[]): DOMRect | null {\n if (!elements || !elements.length) return null\n\n const rects = elements.map((el) => el.getBoundingClientRect())\n\n const minX = Math.min(...rects.map((r) => r.x)) || 0\n const minY = Math.min(...rects.map((r) => r.y)) || 0\n const maxRight = Math.max(...rects.map((r) => r.right)) || 0\n const maxBottom = Math.max(...rects.map((r) => r.bottom)) || 0\n\n return {\n x: minX,\n y: minY,\n width: maxRight - minX,\n height: maxBottom - minY,\n top: minY,\n right: maxRight,\n bottom: maxBottom,\n left: minX,\n } as DOMRect\n}\n\ninterface RectFromElementsHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a DOMRect from an array of elements.\n * This is needed because the Range Decoration API might render se\n */\nfunction useRectFromElements(props: RectFromElementsHookOptions): DOMRect | null {\n const {scrollElement, disabled, selector} = props\n const [rect, setRect] = useState<DOMRect | null>(null)\n\n useEffect(() => {\n if (disabled) return undefined\n\n const handleSetRect = () => {\n const elements = document?.querySelectorAll(selector)\n if (!elements) return\n\n const nextRect = createDomRectFromElements(Array.from(elements))\n\n setRect(nextRect)\n }\n\n handleSetRect()\n\n if (!scrollElement) return undefined\n\n scrollElement.addEventListener('wheel', handleSetRect)\n\n return () => {\n scrollElement.removeEventListener('wheel', handleSetRect)\n }\n }, [scrollElement, disabled, selector])\n\n return rect\n}\n\nexport interface ReferenceElementHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a reference element that can be used to position a popover.\n */\nexport function useAuthoringReferenceElement(\n props: ReferenceElementHookOptions,\n): HTMLElement | null {\n const {scrollElement, disabled, selector} = props\n\n const rect = useRectFromElements({\n scrollElement,\n disabled,\n selector,\n })\n\n const element = useMemo((): HTMLElement | null => {\n if (!rect) return null\n\n return {\n getBoundingClientRect: () => rect,\n } as HTMLElement\n }, [rect])\n\n return element\n}\n\nexport function getSelectionBoundingRect(): DOMRect | null {\n const selection = window.getSelection()\n let range = null\n\n if (selection && selection.rangeCount > 0) {\n range = selection.getRangeAt(0)\n }\n const rect = range?.getBoundingClientRect()\n\n return rect || null\n}\n","import {AddCommentIcon} from '@sanity/icons'\nimport {useClickOutsideEvent} from '@sanity/ui'\nimport {motion, type Variants} from 'motion/react'\nimport {useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button, Popover, type PopoverProps} from '../../../../../ui-components'\nimport {useTranslation} from '../../../../i18n'\nimport {CommentDisabledIcon} from '../../../components'\nimport {commentsLocaleNamespace} from '../../../i18n'\n\nconst MotionPopover = styled(motion.create(Popover))`\n user-select: none;\n`\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst VARIANTS: Variants = {\n hidden: {opacity: 0, y: -4},\n visible: {opacity: 1, y: 0},\n}\n\ninterface FloatingButtonPopoverProps {\n disabled: boolean\n onClick: () => void\n onClickOutside: (e: MouseEvent) => void\n referenceElement: PopoverProps['referenceElement']\n}\n\nexport function FloatingButtonPopover(props: FloatingButtonPopoverProps) {\n const {disabled, onClick, onClickOutside, referenceElement} = props\n const buttonRef = useRef<HTMLButtonElement | null>(null)\n const {t} = useTranslation(commentsLocaleNamespace)\n\n useClickOutsideEvent(onClickOutside, () => [buttonRef.current])\n\n const disabledText = t('inline-add-comment-button.disabled-overlap-title')\n const enabledText = t('inline-add-comment-button.title')\n const text = disabled ? disabledText : enabledText\n\n const content = (\n <Button\n data-testid=\"inline-comment-button\"\n disabled={disabled}\n icon={disabled ? CommentDisabledIcon : AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={buttonRef}\n text={text}\n />\n )\n\n return (\n <MotionPopover\n animate=\"visible\"\n content={content}\n contentEditable={false}\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n initial=\"hidden\"\n open\n padding={1}\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n variants={VARIANTS}\n />\n )\n}\n","import {type CurrentUser} from '@sanity/types'\nimport {Stack, useClickOutsideEvent} from '@sanity/ui'\nimport {useCallback, useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Popover, type PopoverProps} from '../../../../../ui-components'\nimport {CommentInput, type CommentInputHandle, type CommentInputProps} from '../../../components'\nimport {hasCommentMessageValue} from '../../../helpers'\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst RootStack = styled(Stack)`\n width: 250px;\n`\n\ninterface InlineCommentInputPopoverProps {\n currentUser: CurrentUser\n mentionOptions: CommentInputProps['mentionOptions']\n onChange: CommentInputProps['onChange']\n onClickOutside: () => void\n onDiscardConfirm: CommentInputProps['onDiscardConfirm']\n onSubmit: CommentInputProps['onSubmit']\n referenceElement?: HTMLElement | null\n value: CommentInputProps['value']\n}\n\nexport function InlineCommentInputPopover(props: InlineCommentInputPopoverProps) {\n const {\n currentUser,\n mentionOptions,\n onChange,\n onClickOutside,\n onDiscardConfirm,\n onSubmit,\n referenceElement,\n value,\n } = props\n\n const commentInputRef = useRef<CommentInputHandle | null>(null)\n const contentElementRef = useRef<HTMLDivElement | null>(null)\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n onDiscardConfirm()\n }, [onDiscardConfirm])\n\n const handleDiscardCancel = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n }, [])\n\n useClickOutsideEvent(\n () => {\n const hasValue = hasCommentMessageValue(value)\n\n if (hasValue) {\n commentInputRef.current?.discardDialogController.open()\n return\n }\n\n onClickOutside()\n },\n () => [contentElementRef.current],\n )\n\n const content = (\n <RootStack padding={2} ref={contentElementRef}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onSubmit={onSubmit}\n ref={commentInputRef}\n value={value}\n />\n </RootStack>\n )\n\n return (\n <Popover\n content={content}\n data-ui=\"InlineCommentInputPopover\"\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n open\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n />\n )\n}\n","import {\n type EditorSelection,\n type PortableTextBlock,\n PortableTextEditor,\n type RangeDecoration,\n type RangeDecorationOnMovedDetails,\n} from '@portabletext/editor'\nimport {isPortableTextTextBlock} from '@sanity/types'\nimport {BoundaryElementProvider, Stack, usePortal} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport debounce from 'lodash-es/debounce.js'\nimport isEqual from 'lodash-es/isEqual.js'\nimport {AnimatePresence} from 'motion/react'\nimport {memo, startTransition, useCallback, useEffect, useMemo, useRef, useState} from 'react'\n\nimport {type EditorChange, type PortableTextInputProps, useFieldActions} from '../../../../form'\nimport {useCurrentUser} from '../../../../store'\nimport {useAddonDataset} from '../../../../studio/addonDataset/useAddonDataset'\nimport {CommentInlineHighlightSpan} from '../../../components'\nimport {isTextSelectionComment} from '../../../helpers'\nimport {\n useComments,\n useCommentsEnabled,\n useCommentsScroll,\n useCommentsSelectedPath,\n useCommentsUpsell,\n} from '../../../hooks'\nimport {\n type CommentDocument,\n type CommentMessage,\n type CommentsTextSelectionItem,\n type CommentsUIMode,\n type CommentUpdatePayload,\n} from '../../../types'\nimport {\n buildCommentRangeDecorations,\n buildRangeDecorationSelectionsFromComments,\n buildTextSelectionFromFragment,\n} from '../../../utils'\nimport {getSelectionBoundingRect, useAuthoringReferenceElement} from '../helpers'\nimport {FloatingButtonPopover} from './FloatingButtonPopover'\nimport {InlineCommentInputPopover} from './InlineCommentInputPopover'\n\nconst EMPTY_ARRAY: [] = []\n\nconst AI_ASSIST_TYPE = 'sanity.assist.instruction.prompt'\n\nexport function CommentsPortableTextInput(props: PortableTextInputProps) {\n const {enabled, mode} = useCommentsEnabled()\n const fieldActions = useFieldActions()\n\n // This is a workaround solution to disable comments for the AI assist type.\n // The AI assist uses the official PTE input which is composed from the\n // Form Components API for the authoring of the prompt. Consequently, the input\n // will get the comments functionality as well, which we don't want.\n // Therefore we disable the comments for the AI assist type.\n const isAiAssist = props.schemaType.name === AI_ASSIST_TYPE\n /**\n * Comments can be disabled at field level by passing the `__internal_comments: undefined` prop to the field.\n * Even though is not recommended and tagged as internal, it works for all type of fields.\n * This adds the same ability to disable inline comments in the Portable Text editor.\n */\n const isCommentsEnabledInField = Boolean(fieldActions.__internal_comments)\n if (!enabled || isAiAssist || !isCommentsEnabledInField) {\n return props.renderDefault(props)\n }\n\n return <CommentsPortableTextInputInner {...props} mode={mode} />\n}\n\nconst CommentsPortableTextInputInner = memo(function CommentsPortableTextInputInner(\n props: PortableTextInputProps & {mode: CommentsUIMode},\n) {\n const {mode} = props\n const currentUser = useCurrentUser()\n const portal = usePortal()\n\n const {comments, getComment, mentionOptions, onCommentsOpen, operation, setStatus, status} =\n useComments()\n const {error: addonDatasetError} = useAddonDataset()\n const {setSelectedPath, selectedPath} = useCommentsSelectedPath()\n const {scrollToComment, scrollToGroup} = useCommentsScroll()\n const {handleOpenDialog} = useCommentsUpsell()\n const [mousePressed, setMousePressed] = useState<boolean>(false)\n\n const editorRef = useRef<PortableTextEditor | null>(null)\n\n // A reference to the authoring decoration element that highlights the selected text\n // when starting to author a comment.\n const [authoringDecorationElement, setAuthoringDecorationElement] =\n useState<HTMLSpanElement | null>(null)\n\n const [nextCommentValue, setNextCommentValue] = useState<CommentMessage | null>(null)\n const [nextCommentSelection, setNextCommentSelection] = useState<EditorSelection | null>(null)\n\n const [currentSelection, setCurrentSelection] = useState<EditorSelection | null>(null)\n const [currentSelectionRect, setCurrenSelectionRect] = useState<DOMRect | null>(null)\n\n const [currentHoveredCommentId, setCurrentHoveredCommentId] = useState<string | null>(null)\n\n const [canSubmit, setCanSubmit] = useState<boolean>(false)\n\n const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)\n const [isFullScreen, setIsFullScreen] = useState<boolean>(false)\n const [addedCommentsDecorations, setAddedCommentsDecorations] =\n useState<RangeDecoration[]>(EMPTY_ARRAY)\n\n const stringFieldPath = useMemo(() => PathUtils.toString(props.path), [props.path])\n const [fragment, setFragment] = useState<PortableTextBlock[] | null>(null)\n\n const getFragment = useCallback(() => {\n if (!editorRef.current) return EMPTY_ARRAY\n return PortableTextEditor.getFragment(editorRef.current)\n }, [])\n\n const handleSetCurrentSelectionRect = useCallback(() => {\n const rect = getSelectionBoundingRect()\n setCurrenSelectionRect(rect)\n }, [])\n\n const resetStates = useCallback(() => {\n setCurrentSelection(null)\n setCurrenSelectionRect(null)\n setNextCommentSelection(null)\n setNextCommentValue(null)\n setCanSubmit(false)\n setAuthoringDecorationElement(null)\n setFragment(null)\n }, [])\n\n // Set the next comment selection to the current selection so that we can\n // render the comment input popover on the current selection using a range decoration.\n const handleSelectCurrentSelection = useCallback(() => {\n // When trying to add a comment in \"upsell\" mode, we want to\n // display the upsell dialog instead of the comment input popover.\n if (mode === 'upsell') {\n handleOpenDialog('pte')\n return\n }\n const currentFragment = getFragment() || null\n setFragment(currentFragment)\n setNextCommentSelection(currentSelection)\n }, [currentSelection, getFragment, handleOpenDialog, mode])\n\n // Clear the selection and close the popover when discarding the comment\n const handleCommentDiscardConfirm = useCallback(() => {\n resetStates()\n }, [resetStates])\n\n const textComments = useMemo(() => {\n return comments.data.open\n .filter((comment) => comment.fieldPath === stringFieldPath)\n .filter((c) => isTextSelectionComment(c.parentComment))\n .map((c) => c.parentComment)\n }, [comments.data.open, stringFieldPath])\n\n const handleSubmit = useCallback(\n (nextValue: CommentMessage) => {\n if (!nextCommentSelection || !editorRef.current) return\n\n const editorValue = PortableTextEditor.getValue(editorRef.current)\n\n if (!editorValue) return\n\n const textSelection = buildTextSelectionFromFragment({\n fragment: fragment || EMPTY_ARRAY,\n selection: nextCommentSelection,\n value: editorValue,\n })\n\n const threadId = uuid()\n\n void operation.create({\n type: 'field',\n contentSnapshot: fragment,\n fieldPath: stringFieldPath,\n message: nextValue,\n parentCommentId: undefined,\n reactions: EMPTY_ARRAY,\n selection: textSelection,\n status: 'open',\n threadId,\n })\n\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n // Set the status to 'open' so that the comment is visible\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // Set the selected path to the new comment\n setSelectedPath({\n fieldPath: stringFieldPath,\n threadId,\n origin: 'form',\n })\n\n // Scroll to the comment\n scrollToGroup(threadId)\n\n resetStates()\n },\n [\n nextCommentSelection,\n operation,\n stringFieldPath,\n onCommentsOpen,\n status,\n setSelectedPath,\n scrollToGroup,\n resetStates,\n setStatus,\n fragment,\n ],\n )\n\n const handleDecoratorClick = useCallback(\n (commentId: string) => {\n const comment = getComment(commentId)\n if (!comment) return\n\n setSelectedPath({\n fieldPath: comment.target.path?.field || '',\n threadId: comment.threadId,\n origin: 'form',\n })\n\n onCommentsOpen?.()\n\n scrollToComment(comment._id)\n },\n [getComment, onCommentsOpen, scrollToComment, setSelectedPath],\n )\n\n const blurred = useRef<boolean>(false)\n\n const handleSelectionChange = useCallback(\n (selection: EditorSelection | null) => {\n const isRangeSelected = selection?.anchor.offset !== selection?.focus.offset\n\n const selectedFragment = getFragment()\n const isValidSelection = selectedFragment?.every(isPortableTextTextBlock)\n\n if (!isValidSelection || !isRangeSelected) {\n setCanSubmit(false)\n return\n }\n /**\n * When the portable text editor loses focus we will save the blurred.current to true.\n * Later, when it restores focus the editor will emit a selection change event, but we don't want to immediately show the comment input\n * instead, we want to wait until the user selects a new range.\n */\n if (blurred.current) {\n blurred.current = false\n return\n }\n // If the mouse is not down, we want to set the current selection rect\n // when the selection changes. Otherwise, we want to wait until the mouse\n // is up to set the current selection rect (see `handleMouseUp`).\n if (!mousePressed) {\n handleSetCurrentSelectionRect()\n }\n\n setCurrentSelection(selection)\n setCanSubmit(true)\n },\n [getFragment, handleSetCurrentSelectionRect, mousePressed],\n )\n\n const debounceSelectionChange = useDebounceSelectionChange(handleSelectionChange)\n\n const handleMouseDown = useCallback(() => {\n startTransition(() => setMousePressed(true))\n }, [])\n\n const handleMouseUp = useCallback(() => {\n startTransition(() => setMousePressed(false))\n\n // When the mouse is up, we want to set the current selection rect.\n handleSetCurrentSelectionRect()\n }, [handleSetCurrentSelectionRect])\n\n const handleRangeDecorationMoved = useCallback((details: RangeDecorationOnMovedDetails) => {\n const {rangeDecoration, newSelection} = details\n\n const commentId = rangeDecoration.payload?.commentId as undefined | string\n\n // Update the range decoration with the new selection.\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n if (p.payload?.commentId === commentId) {\n const nextDecoration: RangeDecoration = {\n ...rangeDecoration,\n selection: newSelection,\n payload: {...rangeDecoration.payload, dirty: true},\n }\n return nextDecoration\n }\n return p\n })\n return next\n })\n }, [])\n\n const updateCommentRange = useCallback(() => {\n const decoratorsToUpdate = addedCommentsDecorations.filter(\n (decorator) => decorator.payload?.dirty,\n )\n if (decoratorsToUpdate.length === 0) return\n\n decoratorsToUpdate.forEach((decorator) => {\n const commentId = decorator.payload?.commentId as undefined | string\n const comment = getComment(commentId || '')\n\n // If the comment no longer exists, remove the range decoration.\n if (!comment) {\n return\n }\n\n // The below code will update the comment object to reflect the new selection\n if (!editorRef.current) return\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n const [updatedDecoration] = buildRangeDecorationSelectionsFromComments({\n comments: [comment],\n value: editorValue,\n })\n\n const nextRange = updatedDecoration?.range ? [updatedDecoration.range] : EMPTY_ARRAY\n\n const nextValue: CommentsTextSelectionItem[] = updatedDecoration\n ? [\n ...(comment.target.path?.selection?.value\n .filter((r) => r._key !== nextRange[0]?._key)\n .concat(nextRange)\n .flat()\n .sort((a, b) => a._key.localeCompare(b._key)) || EMPTY_ARRAY),\n ]\n : EMPTY_ARRAY\n\n const nextComment: CommentUpdatePayload = {\n target: {\n ...comment.target,\n path: {\n ...comment.target?.path,\n field: comment.target.path?.field || '',\n selection: {\n type: 'text',\n value: nextValue,\n },\n },\n },\n }\n\n const hasChanged = !isEqual(comment.target, nextComment.target)\n\n if (hasChanged) {\n void operation.update(comment._id, nextComment)\n }\n })\n\n // Mark the range decorations as not dirty\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n const isDirty = decoratorsToUpdate.find(\n (d) => d.payload?.commentId === p.payload?.commentId,\n )?.payload?.dirty\n\n if (isDirty) {\n const nextDecoration: RangeDecoration = {\n ...p,\n payload: {...p.payload, dirty: false},\n }\n return nextDecoration\n }\n return p\n })\n return next.filter((p) => p.selection !== null)\n })\n }, [addedCommentsDecorations, getComment, operation])\n\n const handleBuildRangeDecorations = useCallback(\n (commentsToDecorate: CommentDocument[]) => {\n if (!editorRef.current) return EMPTY_ARRAY\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n return buildCommentRangeDecorations({\n comments: commentsToDecorate,\n currentHoveredCommentId,\n onDecorationClick: handleDecoratorClick,\n onDecorationHoverEnd: setCurrentHoveredCommentId,\n onDecorationHoverStart: setCurrentHoveredCommentId,\n onDecorationMoved: handleRangeDecorationMoved,\n selectedThreadId: selectedPath?.threadId || null,\n value: editorValue,\n })\n },\n [\n currentHoveredCommentId,\n handleDecoratorClick,\n handleRangeDecorationMoved,\n selectedPath?.threadId,\n ],\n )\n\n const onEditorChange = useCallback(\n (change: EditorChange) => {\n if (change.type === 'mutation') {\n updateCommentRange()\n }\n if (change.type === 'blur') {\n blurred.current = true\n }\n if (change.type === 'selection') {\n debounceSelectionChange(change.selection)\n }\n },\n [debounceSelectionChange, updateCommentRange],\n )\n\n // The range decoration for the comment input. This is used to position the\n // comment input popover on the current selection and to highlight the\n // selected text.\n const authoringDecoration = useMemo((): RangeDecoration | null => {\n if (!nextCommentSelection) return null\n\n return {\n component: ({children}) => (\n <CommentInlineHighlightSpan isAuthoring ref={setAuthoringDecorationElement}>\n {children}\n </CommentInlineHighlightSpan>\n ),\n selection: nextCommentSelection,\n }\n }, [nextCommentSelection])\n\n // All the range decorations\n const rangeDecorations: RangeDecoration[] = [\n // Existing range decorations\n ...(props?.rangeDecorations || EMPTY_ARRAY),\n // The range decoration when adding a comment\n ...(authoringDecoration ? [authoringDecoration] : EMPTY_ARRAY),\n // The range decorations for existing comments\n ...addedCommentsDecorations,\n ]\n\n const [currentSelectionIsOverlapping, setCurrentSelectionIsOverlapping] = useState<boolean>(false)\n useEffect(() => {\n startTransition(() =>\n setCurrentSelectionIsOverlapping(() => {\n if (!currentSelection || addedCommentsDecorations.length === 0) return false\n\n return addedCommentsDecorations.some((d) => {\n if (!editorRef.current) return false\n\n const testA = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n currentSelection,\n d.selection,\n )\n\n const testB = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n d.selection,\n currentSelection,\n )\n\n return testA || testB\n })\n }),\n )\n }, [addedCommentsDecorations, currentSelection])\n\n // The scroll element used to update the reference element for the\n // popover on scroll.\n const scrollElement = isFullScreen\n ? document.body\n : portal.elements?.documentScrollElement || document.body\n\n // The boundary element used to position the popover properly\n // inside the editor.\n const boundaryElement = isFullScreen\n ? portal.elements?.documentScrollElement || document.body\n : rootElement\n\n const popoverAuthoringReferenceElement = useAuthoringReferenceElement({\n scrollElement,\n disabled: !nextCommentSelection || !authoringDecorationElement,\n selector: '[data-inline-comment-state=\"authoring\"]',\n })\n\n const selectionReferenceElement = useMemo(() => {\n if (!currentSelectionRect) return null\n\n return {\n getBoundingClientRect: () => currentSelectionRect,\n } as HTMLElement\n }, [currentSelectionRect])\n\n // This effect is needed to update the reference element for the popover\n // when the current selection changes so that it is always positioned\n // on the current selection.\n useEffect(() => {\n if (!currentSelection) return undefined\n scrollElement?.addEventListener('wheel', handleSetCurrentSelectionRect)\n\n return () => {\n scrollElement?.removeEventListener('wheel', handleSetCurrentSelectionRect)\n }\n }, [currentSelection, scrollElement, handleSetCurrentSelectionRect])\n\n // This is effect is needed to handle remote changes to the comments.\n // That is, when another user adds, updates or deletes a comment, we need\n // to update the range decorations to reflect these changes in the UI.\n useEffect(() => {\n const nextDecorations = handleBuildRangeDecorations(textComments)\n\n // The `dirty` flag is used to keep track of range decorations that\n // have been moved. When a range decoration is moved, we need to update\n // the comment document. However, when receiving updates from the server,\n // the `dirty` flag will be removed. Therefore, we need to make sure\n // that the `dirty` flag is preserved so that we can update the comment.\n startTransition(() =>\n setAddedCommentsDecorations((current) => {\n return nextDecorations.map((nextDecoration) => {\n const prevDecoration = current.find(\n (p) => p.payload?.commentId === nextDecoration.payload?.commentId,\n )\n\n if (prevDecoration?.payload?.dirty) {\n return {\n ...nextDecoration,\n payload: {...nextDecoration.payload, dirty: prevDecoration.payload.dirty},\n }\n }\n\n return nextDecoration\n })\n }),\n )\n }, [handleBuildRangeDecorations, textComments])\n\n const showFloatingButton = Boolean(\n currentSelection && canSubmit && selectionReferenceElement && !mousePressed,\n )\n const showFloatingInput = Boolean(nextCommentSelection && popoverAuthoringReferenceElement)\n\n return (\n <>\n <BoundaryElementProvider element={boundaryElement}>\n {showFloatingInput && currentUser && (\n <InlineCommentInputPopover\n currentUser={currentUser}\n mentionOptions={mentionOptions}\n onChange={setNextCommentValue}\n onClickOutside={resetStates}\n onDiscardConfirm={handleCommentDiscardConfirm}\n onSubmit={handleSubmit}\n referenceElement={popoverAuthoringReferenceElement}\n value={nextCommentValue}\n />\n )}\n <AnimatePresence>\n {showFloatingButton && !showFloatingInput && (\n <FloatingButtonPopover\n disabled={currentSelectionIsOverlapping || Boolean(addonDatasetError)}\n onClick={handleSelectCurrentSelection}\n onClickOutside={resetStates}\n referenceElement={selectionReferenceElement}\n />\n )}\n </AnimatePresence>\n </BoundaryElementProvider>\n\n <Stack ref={setRootElement} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp}>\n <RenderDefaultCommentsPortableTextInputInner\n {...props}\n onEditorChange={onEditorChange}\n editorRef={editorRef}\n rangeDecorations={rangeDecorations}\n onFullScreenChange={setIsFullScreen}\n />\n </Stack>\n </>\n )\n})\n\n// Workaround for react compiler restrictions on refs triggered by the debounce wrapper\nfunction useDebounceSelectionChange(\n handleSelectionChange: (selection: EditorSelection | null) => void,\n) {\n return useMemo(() => debounce(handleSelectionChange, 200), [handleSelectionChange])\n}\n// Used to workaround restrictions on passing refs to functions in react compiler\nfunction RenderDefaultCommentsPortableTextInputInner(\n props: React.ComponentProps<typeof CommentsPortableTextInputInner>,\n) {\n return props.renderDefault(props)\n}\n","import {isArrayOfBlocksSchemaType} from '@sanity/types'\n\nimport {type InputProps, type PortableTextInputProps} from '../../../form'\nimport {CommentsPortableTextInput} from './components'\n\nfunction isPortableTextInputProps(\n inputProps: InputProps | Omit<InputProps, 'renderDefault'>,\n): inputProps is PortableTextInputProps {\n return isArrayOfBlocksSchemaType(inputProps.schemaType)\n}\n\nexport function CommentsInput(props: InputProps) {\n if (isPortableTextInputProps(props)) {\n return <CommentsPortableTextInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n"],"names":["createDomRectFromElements","elements","length","rects","map","el","getBoundingClientRect","minX","Math","min","r","x","minY","y","maxRight","max","right","maxBottom","bottom","width","height","top","left","useRectFromElements","props","$","_c","scrollElement","disabled","selector","rect","setRect","useState","t0","t1","handleSetRect","document","querySelectorAll","nextRect","Array","from","addEventListener","removeEventListener","useEffect","useAuthoringReferenceElement","bb0","t2","getSelectionBoundingRect","selection","window","getSelection","range","rangeCount","getRangeAt","MotionPopover","styled","motion","create","Popover","withConfig","displayName","componentId","POPOVER_FALLBACK_PLACEMENTS","VARIANTS","hidden","opacity","visible","FloatingButtonPopover","onClick","onClickOutside","referenceElement","buttonRef","useRef","t","useTranslation","commentsLocaleNamespace","Symbol","for","current","useClickOutsideEvent","disabledText","text","t3","CommentDisabledIcon","AddCommentIcon","t4","content","t5","RootStack","Stack","InlineCommentInputPopover","currentUser","mentionOptions","onChange","onDiscardConfirm","onSubmit","value","commentInputRef","contentElementRef","discardDialogController","close","handleDiscardConfirm","handleDiscardCancel","hasCommentMessageValue","open","EMPTY_ARRAY","AI_ASSIST_TYPE","CommentsPortableTextInput","enabled","mode","useCommentsEnabled","fieldActions","useFieldActions","isAiAssist","schemaType","name","isCommentsEnabledInField","Boolean","__internal_comments","renderDefault","CommentsPortableTextInputInner","memo","useCurrentUser","portal","usePortal","comments","getComment","onCommentsOpen","operation","setStatus","status","useComments","error","addonDatasetError","useAddonDataset","setSelectedPath","selectedPath","useCommentsSelectedPath","scrollToComment","scrollToGroup","useCommentsScroll","handleOpenDialog","useCommentsUpsell","mousePressed","setMousePressed","editorRef","authoringDecorationElement","setAuthoringDecorationElement","nextCommentValue","setNextCommentValue","nextCommentSelection","setNextCommentSelection","currentSelection","setCurrentSelection","currentSelectionRect","setCurrenSelectionRect","currentHoveredCommentId","setCurrentHoveredCommentId","canSubmit","setCanSubmit","rootElement","setRootElement","isFullScreen","setIsFullScreen","addedCommentsDecorations","setAddedCommentsDecorations","path","PathUtils","toString","stringFieldPath","fragment","setFragment","PortableTextEditor","getFragment","handleSetCurrentSelectionRect","resetStates","currentFragment","handleSelectCurrentSelection","handleCommentDiscardConfirm","t6","data","t7","comment","fieldPath","filter","_temp","_temp2","textComments","nextValue","editorValue","getValue","textSelection","buildTextSelectionFromFragment","threadId","uuid","type","contentSnapshot","message","parentCommentId","undefined","reactions","origin","handleSubmit","t8","commentId","comment_0","target","field","_id","handleDecoratorClick","blurred","t9","isRangeSelected","anchor","offset","focus","every","isPortableTextTextBlock","debounceSelectionChange","useDebounceSelectionChange","t10","startTransition","handleMouseDown","t11","handleMouseUp","t12","details","rangeDecoration","newSelection","commentId_0","payload","prev","p","dirty","handleRangeDecorationMoved","t13","decoratorsToUpdate","_temp3","forEach","decorator_0","commentId_1","decorator","comment_1","editorValue_0","updatedDecoration","buildRangeDecorationSelectionsFromComments","nextRange","nextValue_0","_key","concat","flat","sort","_temp4","nextComment","isEqual","update","prev_0","p_0","find","d","_temp5","updateCommentRange","t14","commentsToDecorate","editorValue_1","buildCommentRangeDecorations","onDecorationClick","onDecorationHoverEnd","onDecorationHoverStart","onDecorationMoved","selectedThreadId","handleBuildRangeDecorations","t15","change","onEditorChange","t16","t17","t18","children","component","authoringDecoration","rangeDecorations","currentSelectionIsOverlapping","setCurrentSelectionIsOverlapping","t19","t20","some","d_0","testA","isSelectionsOverlapping","testB","body","documentScrollElement","boundaryElement","t21","t22","popoverAuthoringReferenceElement","t23","bb1","t24","selectionReferenceElement","t25","t26","t27","nextDecorations","nextDecoration_1","prevDecoration","p_2","nextDecoration","showFloatingButton","showFloatingInput","t28","t29","t30","t31","t32","t33","handleSelectionChange","debounce","RenderDefaultCommentsPortableTextInputInner","c","isTextSelectionComment","parentComment","c_0","a","b","localeCompare","p_1","isPortableTextInputProps","inputProps","isArrayOfBlocksSchemaType","CommentsInput"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAASA,0BAA0BC,UAAqC;AACtE,MAAI,CAACA,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OAAAI,WAAA;AAAA,SA8OvBA,UAASX,SAAeG;AAAA;AA9OD,SAAAmB,OAAAwE,GAAAC,GAAA;AAAA,SA4QdD,EAAC5E,KAAK8E,cAAeD,EAAC7E,IAAK;AAAC;AA5Qd,SAAAY,OAAAmE,KAAA;AAAA,SAqTZ/F,IAACxL,cAAe;AAAI;ACvXpD,SAASwR,yBACPC,YACsC;AACtC,SAAOC,0BAA0BD,WAAWvN,UAAU;AACxD;AAEO,SAAAyN,cAAAnT,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AACL,MAAI8S,yBAAyBhT,KAAK,GAAC;AAAA,QAAAS;AAAA,WAAAR,SAAAD,SAC1BS,MAAA,oBAAC,2BAAA,EAAyB,GAAKT,OAAK,GAAIC,OAAAD,OAAAC,OAAAQ,OAAAA,MAAAR,EAAA,CAAA,GAAxCQ;AAAAA,EAAwC;AAChD,MAAAA;AAAA,SAAAR,SAAAD,SAEMS,KAAAT,MAAK+F,cAAe/F,KAAK,GAACC,OAAAD,OAAAC,OAAAQ,MAAAA,KAAAR,EAAA,CAAA,GAA1BQ;AAA0B;"}
|
|
1
|
+
{"version":3,"file":"index8.js","sources":["../../src/core/comments/plugin/input/helpers.ts","../../src/core/comments/plugin/input/components/FloatingButtonPopover.tsx","../../src/core/comments/plugin/input/components/InlineCommentInputPopover.tsx","../../src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx","../../src/core/comments/plugin/input/CommentsInput.tsx"],"sourcesContent":["import {useEffect, useMemo, useState} from 'react'\n\n/**\n * A function that creates a DOMRect from an array of elements.\n */\nfunction createDomRectFromElements(elements: Element[]): DOMRect | null {\n if (!elements || !elements.length) return null\n\n const rects = elements.map((el) => el.getBoundingClientRect())\n\n const minX = Math.min(...rects.map((r) => r.x)) || 0\n const minY = Math.min(...rects.map((r) => r.y)) || 0\n const maxRight = Math.max(...rects.map((r) => r.right)) || 0\n const maxBottom = Math.max(...rects.map((r) => r.bottom)) || 0\n\n return {\n x: minX,\n y: minY,\n width: maxRight - minX,\n height: maxBottom - minY,\n top: minY,\n right: maxRight,\n bottom: maxBottom,\n left: minX,\n } as DOMRect\n}\n\ninterface RectFromElementsHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a DOMRect from an array of elements.\n * This is needed because the Range Decoration API might render se\n */\nfunction useRectFromElements(props: RectFromElementsHookOptions): DOMRect | null {\n const {scrollElement, disabled, selector} = props\n const [rect, setRect] = useState<DOMRect | null>(null)\n\n useEffect(() => {\n if (disabled) return undefined\n\n const handleSetRect = () => {\n const elements = document?.querySelectorAll(selector)\n if (!elements) return\n\n const nextRect = createDomRectFromElements(Array.from(elements))\n\n setRect(nextRect)\n }\n\n handleSetRect()\n\n if (!scrollElement) return undefined\n\n scrollElement.addEventListener('wheel', handleSetRect)\n\n return () => {\n scrollElement.removeEventListener('wheel', handleSetRect)\n }\n }, [scrollElement, disabled, selector])\n\n return rect\n}\n\nexport interface ReferenceElementHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a reference element that can be used to position a popover.\n */\nexport function useAuthoringReferenceElement(\n props: ReferenceElementHookOptions,\n): HTMLElement | null {\n const {scrollElement, disabled, selector} = props\n\n const rect = useRectFromElements({\n scrollElement,\n disabled,\n selector,\n })\n\n const element = useMemo((): HTMLElement | null => {\n if (!rect) return null\n\n return {\n getBoundingClientRect: () => rect,\n } as HTMLElement\n }, [rect])\n\n return element\n}\n\nexport function getSelectionBoundingRect(): DOMRect | null {\n const selection = window.getSelection()\n let range = null\n\n if (selection && selection.rangeCount > 0) {\n range = selection.getRangeAt(0)\n }\n const rect = range?.getBoundingClientRect()\n\n return rect || null\n}\n","import {AddCommentIcon} from '@sanity/icons'\nimport {useClickOutsideEvent} from '@sanity/ui'\nimport {motion, type Variants} from 'motion/react'\nimport {useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button, Popover, type PopoverProps} from '../../../../../ui-components'\nimport {useTranslation} from '../../../../i18n'\nimport {CommentDisabledIcon} from '../../../components'\nimport {commentsLocaleNamespace} from '../../../i18n'\n\nconst MotionPopover = styled(motion.create(Popover))`\n user-select: none;\n`\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst VARIANTS: Variants = {\n hidden: {opacity: 0, y: -4},\n visible: {opacity: 1, y: 0},\n}\n\ninterface FloatingButtonPopoverProps {\n disabled: boolean\n onClick: () => void\n onClickOutside: (e: MouseEvent) => void\n referenceElement: PopoverProps['referenceElement']\n}\n\nexport function FloatingButtonPopover(props: FloatingButtonPopoverProps) {\n const {disabled, onClick, onClickOutside, referenceElement} = props\n const buttonRef = useRef<HTMLButtonElement | null>(null)\n const {t} = useTranslation(commentsLocaleNamespace)\n\n useClickOutsideEvent(onClickOutside, () => [buttonRef.current])\n\n const disabledText = t('inline-add-comment-button.disabled-overlap-title')\n const enabledText = t('inline-add-comment-button.title')\n const text = disabled ? disabledText : enabledText\n\n const content = (\n <Button\n data-testid=\"inline-comment-button\"\n disabled={disabled}\n icon={disabled ? CommentDisabledIcon : AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={buttonRef}\n text={text}\n />\n )\n\n return (\n <MotionPopover\n animate=\"visible\"\n content={content}\n contentEditable={false}\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n initial=\"hidden\"\n open\n padding={1}\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n variants={VARIANTS}\n />\n )\n}\n","import {type CurrentUser} from '@sanity/types'\nimport {Stack, useClickOutsideEvent} from '@sanity/ui'\nimport {useCallback, useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Popover, type PopoverProps} from '../../../../../ui-components'\nimport {CommentInput, type CommentInputHandle, type CommentInputProps} from '../../../components'\nimport {hasCommentMessageValue} from '../../../helpers'\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst RootStack = styled(Stack)`\n width: 250px;\n`\n\ninterface InlineCommentInputPopoverProps {\n currentUser: CurrentUser\n mentionOptions: CommentInputProps['mentionOptions']\n onChange: CommentInputProps['onChange']\n onClickOutside: () => void\n onDiscardConfirm: CommentInputProps['onDiscardConfirm']\n onSubmit: CommentInputProps['onSubmit']\n referenceElement?: HTMLElement | null\n value: CommentInputProps['value']\n}\n\nexport function InlineCommentInputPopover(props: InlineCommentInputPopoverProps) {\n const {\n currentUser,\n mentionOptions,\n onChange,\n onClickOutside,\n onDiscardConfirm,\n onSubmit,\n referenceElement,\n value,\n } = props\n\n const commentInputRef = useRef<CommentInputHandle | null>(null)\n const contentElementRef = useRef<HTMLDivElement | null>(null)\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n onDiscardConfirm()\n }, [onDiscardConfirm])\n\n const handleDiscardCancel = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n }, [])\n\n useClickOutsideEvent(\n () => {\n const hasValue = hasCommentMessageValue(value)\n\n if (hasValue) {\n commentInputRef.current?.discardDialogController.open()\n return\n }\n\n onClickOutside()\n },\n () => [contentElementRef.current],\n )\n\n const content = (\n <RootStack padding={2} ref={contentElementRef}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onSubmit={onSubmit}\n ref={commentInputRef}\n value={value}\n />\n </RootStack>\n )\n\n return (\n <Popover\n content={content}\n data-ui=\"InlineCommentInputPopover\"\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n open\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n />\n )\n}\n","import {\n type EditorSelection,\n type PortableTextBlock,\n PortableTextEditor,\n type RangeDecoration,\n type RangeDecorationOnMovedDetails,\n} from '@portabletext/editor'\nimport {isPortableTextTextBlock} from '@sanity/types'\nimport {BoundaryElementProvider, Stack, usePortal} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport debounce from 'lodash-es/debounce.js'\nimport isEqual from 'lodash-es/isEqual.js'\nimport {AnimatePresence} from 'motion/react'\nimport {memo, startTransition, useCallback, useEffect, useMemo, useRef, useState} from 'react'\n\nimport {type EditorChange, type PortableTextInputProps, useFieldActions} from '../../../../form'\nimport {useCurrentUser} from '../../../../store'\nimport {useAddonDataset} from '../../../../studio/addonDataset/useAddonDataset'\nimport {CommentInlineHighlightSpan} from '../../../components'\nimport {isTextSelectionComment} from '../../../helpers'\nimport {\n useComments,\n useCommentsEnabled,\n useCommentsScroll,\n useCommentsSelectedPath,\n useCommentsUpsell,\n} from '../../../hooks'\nimport {\n type CommentDocument,\n type CommentMessage,\n type CommentsTextSelectionItem,\n type CommentsUIMode,\n type CommentUpdatePayload,\n} from '../../../types'\nimport {\n buildCommentRangeDecorations,\n buildRangeDecorationSelectionsFromComments,\n buildTextSelectionFromFragment,\n} from '../../../utils'\nimport {getSelectionBoundingRect, useAuthoringReferenceElement} from '../helpers'\nimport {FloatingButtonPopover} from './FloatingButtonPopover'\nimport {InlineCommentInputPopover} from './InlineCommentInputPopover'\n\nconst EMPTY_ARRAY: [] = []\n\nconst AI_ASSIST_TYPE = 'sanity.assist.instruction.prompt'\n\nexport function CommentsPortableTextInput(props: PortableTextInputProps) {\n const {enabled, mode} = useCommentsEnabled()\n const fieldActions = useFieldActions()\n\n // This is a workaround solution to disable comments for the AI assist type.\n // The AI assist uses the official PTE input which is composed from the\n // Form Components API for the authoring of the prompt. Consequently, the input\n // will get the comments functionality as well, which we don't want.\n // Therefore we disable the comments for the AI assist type.\n const isAiAssist = props.schemaType.name === AI_ASSIST_TYPE\n /**\n * Comments can be disabled at field level by passing the `__internal_comments: undefined` prop to the field.\n * Even though is not recommended and tagged as internal, it works for all type of fields.\n * This adds the same ability to disable inline comments in the Portable Text editor.\n */\n const isCommentsEnabledInField = Boolean(fieldActions.__internal_comments)\n if (!enabled || isAiAssist || !isCommentsEnabledInField) {\n return props.renderDefault(props)\n }\n\n return <CommentsPortableTextInputInner {...props} mode={mode} />\n}\n\nconst CommentsPortableTextInputInner = memo(function CommentsPortableTextInputInner(\n props: PortableTextInputProps & {mode: CommentsUIMode},\n) {\n const {mode} = props\n const currentUser = useCurrentUser()\n const portal = usePortal()\n\n const {comments, getComment, mentionOptions, onCommentsOpen, operation, setStatus, status} =\n useComments()\n const {error: addonDatasetError} = useAddonDataset()\n const {setSelectedPath, selectedPath} = useCommentsSelectedPath()\n const {scrollToComment, scrollToGroup} = useCommentsScroll()\n const {handleOpenDialog} = useCommentsUpsell()\n const [mousePressed, setMousePressed] = useState<boolean>(false)\n\n const editorRef = useRef<PortableTextEditor | null>(null)\n\n // A reference to the authoring decoration element that highlights the selected text\n // when starting to author a comment.\n const [authoringDecorationElement, setAuthoringDecorationElement] =\n useState<HTMLSpanElement | null>(null)\n\n const [nextCommentValue, setNextCommentValue] = useState<CommentMessage | null>(null)\n const [nextCommentSelection, setNextCommentSelection] = useState<EditorSelection | null>(null)\n\n const [currentSelection, setCurrentSelection] = useState<EditorSelection | null>(null)\n const [currentSelectionRect, setCurrenSelectionRect] = useState<DOMRect | null>(null)\n\n const [currentHoveredCommentId, setCurrentHoveredCommentId] = useState<string | null>(null)\n\n const [canSubmit, setCanSubmit] = useState<boolean>(false)\n\n const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)\n const [isFullScreen, setIsFullScreen] = useState<boolean>(false)\n const [addedCommentsDecorations, setAddedCommentsDecorations] =\n useState<RangeDecoration[]>(EMPTY_ARRAY)\n\n const stringFieldPath = useMemo(() => PathUtils.toString(props.path), [props.path])\n const [fragment, setFragment] = useState<PortableTextBlock[] | null>(null)\n\n const getFragment = useCallback(() => {\n if (!editorRef.current) return EMPTY_ARRAY\n return PortableTextEditor.getFragment(editorRef.current)\n }, [])\n\n const handleSetCurrentSelectionRect = useCallback(() => {\n const rect = getSelectionBoundingRect()\n setCurrenSelectionRect(rect)\n }, [])\n\n const resetStates = useCallback(() => {\n setCurrentSelection(null)\n setCurrenSelectionRect(null)\n setNextCommentSelection(null)\n setNextCommentValue(null)\n setCanSubmit(false)\n setAuthoringDecorationElement(null)\n setFragment(null)\n }, [])\n\n // Set the next comment selection to the current selection so that we can\n // render the comment input popover on the current selection using a range decoration.\n const handleSelectCurrentSelection = useCallback(() => {\n // When trying to add a comment in \"upsell\" mode, we want to\n // display the upsell dialog instead of the comment input popover.\n if (mode === 'upsell') {\n handleOpenDialog('pte')\n return\n }\n const currentFragment = getFragment() || null\n setFragment(currentFragment)\n setNextCommentSelection(currentSelection)\n }, [currentSelection, getFragment, handleOpenDialog, mode])\n\n // Clear the selection and close the popover when discarding the comment\n const handleCommentDiscardConfirm = useCallback(() => {\n resetStates()\n }, [resetStates])\n\n const textComments = useMemo(() => {\n return comments.data.open\n .filter((comment) => comment.fieldPath === stringFieldPath)\n .filter((c) => isTextSelectionComment(c.parentComment))\n .map((c) => c.parentComment)\n }, [comments.data.open, stringFieldPath])\n\n const handleSubmit = useCallback(\n (nextValue: CommentMessage) => {\n if (!nextCommentSelection || !editorRef.current) return\n\n const editorValue = PortableTextEditor.getValue(editorRef.current)\n\n if (!editorValue) return\n\n const textSelection = buildTextSelectionFromFragment({\n fragment: fragment || EMPTY_ARRAY,\n selection: nextCommentSelection,\n value: editorValue,\n })\n\n const threadId = uuid()\n\n void operation.create({\n type: 'field',\n contentSnapshot: fragment,\n fieldPath: stringFieldPath,\n message: nextValue,\n parentCommentId: undefined,\n reactions: EMPTY_ARRAY,\n selection: textSelection,\n status: 'open',\n threadId,\n })\n\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n // Set the status to 'open' so that the comment is visible\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // Set the selected path to the new comment\n setSelectedPath({\n fieldPath: stringFieldPath,\n threadId,\n origin: 'form',\n })\n\n // Scroll to the comment\n scrollToGroup(threadId)\n\n resetStates()\n },\n [\n nextCommentSelection,\n operation,\n stringFieldPath,\n onCommentsOpen,\n status,\n setSelectedPath,\n scrollToGroup,\n resetStates,\n setStatus,\n fragment,\n ],\n )\n\n const handleDecoratorClick = useCallback(\n (commentId: string) => {\n const comment = getComment(commentId)\n if (!comment) return\n\n setSelectedPath({\n fieldPath: comment.target.path?.field || '',\n threadId: comment.threadId,\n origin: 'form',\n })\n\n onCommentsOpen?.()\n\n scrollToComment(comment._id)\n },\n [getComment, onCommentsOpen, scrollToComment, setSelectedPath],\n )\n\n const blurred = useRef<boolean>(false)\n\n const handleSelectionChange = useCallback(\n (selection: EditorSelection | null) => {\n const isRangeSelected = selection?.anchor.offset !== selection?.focus.offset\n\n const selectedFragment = getFragment()\n const isValidSelection = selectedFragment?.every(isPortableTextTextBlock)\n\n if (!isValidSelection || !isRangeSelected) {\n setCanSubmit(false)\n return\n }\n /**\n * When the portable text editor loses focus we will save the blurred.current to true.\n * Later, when it restores focus the editor will emit a selection change event, but we don't want to immediately show the comment input\n * instead, we want to wait until the user selects a new range.\n */\n if (blurred.current) {\n blurred.current = false\n return\n }\n // If the mouse is not down, we want to set the current selection rect\n // when the selection changes. Otherwise, we want to wait until the mouse\n // is up to set the current selection rect (see `handleMouseUp`).\n if (!mousePressed) {\n handleSetCurrentSelectionRect()\n }\n\n setCurrentSelection(selection)\n setCanSubmit(true)\n },\n [getFragment, handleSetCurrentSelectionRect, mousePressed],\n )\n\n const debounceSelectionChange = useDebounceSelectionChange(handleSelectionChange)\n\n const handleMouseDown = useCallback(() => {\n startTransition(() => setMousePressed(true))\n }, [])\n\n const handleMouseUp = useCallback(() => {\n startTransition(() => setMousePressed(false))\n\n // When the mouse is up, we want to set the current selection rect.\n handleSetCurrentSelectionRect()\n }, [handleSetCurrentSelectionRect])\n\n const handleRangeDecorationMoved = useCallback((details: RangeDecorationOnMovedDetails) => {\n const {rangeDecoration, newSelection} = details\n\n const commentId = rangeDecoration.payload?.commentId as undefined | string\n\n // Update the range decoration with the new selection.\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n if (p.payload?.commentId === commentId) {\n const nextDecoration: RangeDecoration = {\n ...rangeDecoration,\n selection: newSelection,\n payload: {...rangeDecoration.payload, dirty: true},\n }\n return nextDecoration\n }\n return p\n })\n return next\n })\n }, [])\n\n const updateCommentRange = useCallback(() => {\n const decoratorsToUpdate = addedCommentsDecorations.filter(\n (decorator) => decorator.payload?.dirty,\n )\n if (decoratorsToUpdate.length === 0) return\n\n decoratorsToUpdate.forEach((decorator) => {\n const commentId = decorator.payload?.commentId as undefined | string\n const comment = getComment(commentId || '')\n\n // If the comment no longer exists, remove the range decoration.\n if (!comment) {\n return\n }\n\n // The below code will update the comment object to reflect the new selection\n if (!editorRef.current) return\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n const [updatedDecoration] = buildRangeDecorationSelectionsFromComments({\n comments: [comment],\n value: editorValue,\n })\n\n const nextRange = updatedDecoration?.range ? [updatedDecoration.range] : EMPTY_ARRAY\n\n const nextValue: CommentsTextSelectionItem[] = updatedDecoration\n ? [\n ...(comment.target.path?.selection?.value\n .filter((r) => r._key !== nextRange[0]?._key)\n .concat(nextRange)\n .flat()\n .sort((a, b) => a._key.localeCompare(b._key)) || EMPTY_ARRAY),\n ]\n : EMPTY_ARRAY\n\n const nextComment: CommentUpdatePayload = {\n target: {\n ...comment.target,\n path: {\n ...comment.target?.path,\n field: comment.target.path?.field || '',\n selection: {\n type: 'text',\n value: nextValue,\n },\n },\n },\n }\n\n const hasChanged = !isEqual(comment.target, nextComment.target)\n\n if (hasChanged) {\n void operation.update(comment._id, nextComment)\n }\n })\n\n // Mark the range decorations as not dirty\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n const isDirty = decoratorsToUpdate.find(\n (d) => d.payload?.commentId === p.payload?.commentId,\n )?.payload?.dirty\n\n if (isDirty) {\n const nextDecoration: RangeDecoration = {\n ...p,\n payload: {...p.payload, dirty: false},\n }\n return nextDecoration\n }\n return p\n })\n return next.filter((p) => p.selection !== null)\n })\n }, [addedCommentsDecorations, getComment, operation])\n\n const handleBuildRangeDecorations = useCallback(\n (commentsToDecorate: CommentDocument[]) => {\n if (!editorRef.current) return EMPTY_ARRAY\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n return buildCommentRangeDecorations({\n comments: commentsToDecorate,\n currentHoveredCommentId,\n onDecorationClick: handleDecoratorClick,\n onDecorationHoverEnd: setCurrentHoveredCommentId,\n onDecorationHoverStart: setCurrentHoveredCommentId,\n onDecorationMoved: handleRangeDecorationMoved,\n selectedThreadId: selectedPath?.threadId || null,\n value: editorValue,\n })\n },\n [\n currentHoveredCommentId,\n handleDecoratorClick,\n handleRangeDecorationMoved,\n selectedPath?.threadId,\n ],\n )\n\n const onEditorChange = useCallback(\n (change: EditorChange) => {\n if (change.type === 'mutation') {\n updateCommentRange()\n }\n if (change.type === 'blur') {\n blurred.current = true\n }\n if (change.type === 'selection') {\n debounceSelectionChange(change.selection)\n }\n },\n [debounceSelectionChange, updateCommentRange],\n )\n\n // The range decoration for the comment input. This is used to position the\n // comment input popover on the current selection and to highlight the\n // selected text.\n const authoringDecoration = useMemo((): RangeDecoration | null => {\n if (!nextCommentSelection) return null\n\n return {\n component: ({children}) => (\n <CommentInlineHighlightSpan isAuthoring ref={setAuthoringDecorationElement}>\n {children}\n </CommentInlineHighlightSpan>\n ),\n selection: nextCommentSelection,\n }\n }, [nextCommentSelection])\n\n // All the range decorations\n const rangeDecorations: RangeDecoration[] = [\n // Existing range decorations\n ...(props?.rangeDecorations || EMPTY_ARRAY),\n // The range decoration when adding a comment\n ...(authoringDecoration ? [authoringDecoration] : EMPTY_ARRAY),\n // The range decorations for existing comments\n ...addedCommentsDecorations,\n ]\n\n const [currentSelectionIsOverlapping, setCurrentSelectionIsOverlapping] = useState<boolean>(false)\n useEffect(() => {\n startTransition(() =>\n setCurrentSelectionIsOverlapping(() => {\n if (!currentSelection || addedCommentsDecorations.length === 0) return false\n\n return addedCommentsDecorations.some((d) => {\n if (!editorRef.current) return false\n\n const testA = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n currentSelection,\n d.selection,\n )\n\n const testB = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n d.selection,\n currentSelection,\n )\n\n return testA || testB\n })\n }),\n )\n }, [addedCommentsDecorations, currentSelection])\n\n // The scroll element used to update the reference element for the\n // popover on scroll.\n const scrollElement = isFullScreen\n ? document.body\n : portal.elements?.documentScrollElement || document.body\n\n // The boundary element used to position the popover properly\n // inside the editor.\n const boundaryElement = isFullScreen\n ? portal.elements?.documentScrollElement || document.body\n : rootElement\n\n const popoverAuthoringReferenceElement = useAuthoringReferenceElement({\n scrollElement,\n disabled: !nextCommentSelection || !authoringDecorationElement,\n selector: '[data-inline-comment-state=\"authoring\"]',\n })\n\n const selectionReferenceElement = useMemo(() => {\n if (!currentSelectionRect) return null\n\n return {\n getBoundingClientRect: () => currentSelectionRect,\n } as HTMLElement\n }, [currentSelectionRect])\n\n // This effect is needed to update the reference element for the popover\n // when the current selection changes so that it is always positioned\n // on the current selection.\n useEffect(() => {\n if (!currentSelection) return undefined\n scrollElement?.addEventListener('wheel', handleSetCurrentSelectionRect)\n\n return () => {\n scrollElement?.removeEventListener('wheel', handleSetCurrentSelectionRect)\n }\n }, [currentSelection, scrollElement, handleSetCurrentSelectionRect])\n\n // This is effect is needed to handle remote changes to the comments.\n // That is, when another user adds, updates or deletes a comment, we need\n // to update the range decorations to reflect these changes in the UI.\n useEffect(() => {\n const nextDecorations = handleBuildRangeDecorations(textComments)\n\n // The `dirty` flag is used to keep track of range decorations that\n // have been moved. When a range decoration is moved, we need to update\n // the comment document. However, when receiving updates from the server,\n // the `dirty` flag will be removed. Therefore, we need to make sure\n // that the `dirty` flag is preserved so that we can update the comment.\n startTransition(() =>\n setAddedCommentsDecorations((current) => {\n return nextDecorations.map((nextDecoration) => {\n const prevDecoration = current.find(\n (p) => p.payload?.commentId === nextDecoration.payload?.commentId,\n )\n\n if (prevDecoration?.payload?.dirty) {\n return {\n ...nextDecoration,\n payload: {...nextDecoration.payload, dirty: prevDecoration.payload.dirty},\n }\n }\n\n return nextDecoration\n })\n }),\n )\n }, [handleBuildRangeDecorations, textComments])\n\n const showFloatingButton = Boolean(\n currentSelection && canSubmit && selectionReferenceElement && !mousePressed,\n )\n const showFloatingInput = Boolean(nextCommentSelection && popoverAuthoringReferenceElement)\n\n return (\n <>\n <BoundaryElementProvider element={boundaryElement}>\n {showFloatingInput && currentUser && (\n <InlineCommentInputPopover\n currentUser={currentUser}\n mentionOptions={mentionOptions}\n onChange={setNextCommentValue}\n onClickOutside={resetStates}\n onDiscardConfirm={handleCommentDiscardConfirm}\n onSubmit={handleSubmit}\n referenceElement={popoverAuthoringReferenceElement}\n value={nextCommentValue}\n />\n )}\n <AnimatePresence>\n {showFloatingButton && !showFloatingInput && (\n <FloatingButtonPopover\n disabled={currentSelectionIsOverlapping || Boolean(addonDatasetError)}\n onClick={handleSelectCurrentSelection}\n onClickOutside={resetStates}\n referenceElement={selectionReferenceElement}\n />\n )}\n </AnimatePresence>\n </BoundaryElementProvider>\n\n <Stack ref={setRootElement} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp}>\n <RenderDefaultCommentsPortableTextInputInner\n {...props}\n onEditorChange={onEditorChange}\n editorRef={editorRef}\n rangeDecorations={rangeDecorations}\n onFullScreenChange={setIsFullScreen}\n />\n </Stack>\n </>\n )\n})\n\n// Workaround for react compiler restrictions on refs triggered by the debounce wrapper\nfunction useDebounceSelectionChange(\n handleSelectionChange: (selection: EditorSelection | null) => void,\n) {\n return useMemo(() => debounce(handleSelectionChange, 200), [handleSelectionChange])\n}\n// Used to workaround restrictions on passing refs to functions in react compiler\nfunction RenderDefaultCommentsPortableTextInputInner(\n props: React.ComponentProps<typeof CommentsPortableTextInputInner>,\n) {\n return props.renderDefault(props)\n}\n","import {isArrayOfBlocksSchemaType} from '@sanity/types'\n\nimport {type InputProps, type PortableTextInputProps} from '../../../form'\nimport {CommentsPortableTextInput} from './components'\n\nfunction isPortableTextInputProps(\n inputProps: InputProps | Omit<InputProps, 'renderDefault'>,\n): inputProps is PortableTextInputProps {\n return isArrayOfBlocksSchemaType(inputProps.schemaType)\n}\n\nexport function CommentsInput(props: InputProps) {\n if (isPortableTextInputProps(props)) {\n return <CommentsPortableTextInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n"],"names":["createDomRectFromElements","elements","length","rects","map","el","getBoundingClientRect","minX","Math","min","r","x","minY","y","maxRight","max","right","maxBottom","bottom","width","height","top","left","useRectFromElements","props","$","_c","scrollElement","disabled","selector","rect","setRect","useState","t0","t1","handleSetRect","document","querySelectorAll","nextRect","Array","from","addEventListener","removeEventListener","useEffect","useAuthoringReferenceElement","bb0","t2","getSelectionBoundingRect","selection","window","getSelection","range","rangeCount","getRangeAt","MotionPopover","styled","motion","create","Popover","withConfig","displayName","componentId","POPOVER_FALLBACK_PLACEMENTS","VARIANTS","hidden","opacity","visible","FloatingButtonPopover","onClick","onClickOutside","referenceElement","buttonRef","useRef","t","useTranslation","commentsLocaleNamespace","Symbol","for","current","useClickOutsideEvent","disabledText","text","t3","CommentDisabledIcon","AddCommentIcon","t4","content","t5","RootStack","Stack","InlineCommentInputPopover","currentUser","mentionOptions","onChange","onDiscardConfirm","onSubmit","value","commentInputRef","contentElementRef","discardDialogController","close","handleDiscardConfirm","handleDiscardCancel","hasCommentMessageValue","open","EMPTY_ARRAY","AI_ASSIST_TYPE","CommentsPortableTextInput","enabled","mode","useCommentsEnabled","fieldActions","useFieldActions","isAiAssist","schemaType","name","isCommentsEnabledInField","Boolean","__internal_comments","renderDefault","CommentsPortableTextInputInner","memo","useCurrentUser","portal","usePortal","comments","getComment","onCommentsOpen","operation","setStatus","status","useComments","error","addonDatasetError","useAddonDataset","setSelectedPath","selectedPath","useCommentsSelectedPath","scrollToComment","scrollToGroup","useCommentsScroll","handleOpenDialog","useCommentsUpsell","mousePressed","setMousePressed","editorRef","authoringDecorationElement","setAuthoringDecorationElement","nextCommentValue","setNextCommentValue","nextCommentSelection","setNextCommentSelection","currentSelection","setCurrentSelection","currentSelectionRect","setCurrenSelectionRect","currentHoveredCommentId","setCurrentHoveredCommentId","canSubmit","setCanSubmit","rootElement","setRootElement","isFullScreen","setIsFullScreen","addedCommentsDecorations","setAddedCommentsDecorations","path","PathUtils","toString","stringFieldPath","fragment","setFragment","PortableTextEditor","getFragment","handleSetCurrentSelectionRect","resetStates","currentFragment","handleSelectCurrentSelection","handleCommentDiscardConfirm","t6","data","t7","comment","fieldPath","filter","_temp","_temp2","textComments","nextValue","editorValue","getValue","textSelection","buildTextSelectionFromFragment","threadId","uuid","type","contentSnapshot","message","parentCommentId","undefined","reactions","origin","handleSubmit","t8","commentId","comment_0","target","field","_id","handleDecoratorClick","blurred","t9","isRangeSelected","anchor","offset","focus","every","isPortableTextTextBlock","debounceSelectionChange","useDebounceSelectionChange","t10","startTransition","handleMouseDown","t11","handleMouseUp","t12","details","rangeDecoration","newSelection","commentId_0","payload","prev","p","dirty","handleRangeDecorationMoved","t13","decoratorsToUpdate","_temp3","forEach","decorator_0","commentId_1","decorator","comment_1","editorValue_0","updatedDecoration","buildRangeDecorationSelectionsFromComments","nextRange","nextValue_0","_key","concat","flat","sort","_temp4","nextComment","isEqual","update","prev_0","p_0","find","d","_temp5","updateCommentRange","t14","commentsToDecorate","editorValue_1","buildCommentRangeDecorations","onDecorationClick","onDecorationHoverEnd","onDecorationHoverStart","onDecorationMoved","selectedThreadId","handleBuildRangeDecorations","t15","change","onEditorChange","t16","t17","t18","children","component","authoringDecoration","rangeDecorations","currentSelectionIsOverlapping","setCurrentSelectionIsOverlapping","t19","t20","some","d_0","testA","isSelectionsOverlapping","testB","body","documentScrollElement","boundaryElement","t21","t22","popoverAuthoringReferenceElement","t23","bb1","t24","selectionReferenceElement","t25","t26","t27","nextDecorations","nextDecoration_1","prevDecoration","p_2","nextDecoration","showFloatingButton","showFloatingInput","t28","t29","t30","t31","t32","t33","handleSelectionChange","debounce","RenderDefaultCommentsPortableTextInputInner","c","isTextSelectionComment","parentComment","c_0","a","b","localeCompare","p_1","isPortableTextInputProps","inputProps","isArrayOfBlocksSchemaType","CommentsInput"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAASA,0BAA0BC,UAAqC;AACtE,MAAI,CAACA,YAAY,CAACA,SAASC,OAAQ,QAAO;AAE1C,QAAMC,QAAQF,SAASG,IAAKC,CAAAA,OAAOA,GAAGC,uBAAuB,GAEvDC,OAAOC,KAAKC,IAAI,GAAGN,MAAMC,IAAKM,CAAAA,MAAMA,EAAEC,CAAC,CAAC,KAAK,GAC7CC,OAAOJ,KAAKC,IAAI,GAAGN,MAAMC,IAAKM,CAAAA,MAAMA,EAAEG,CAAC,CAAC,KAAK,GAC7CC,WAAWN,KAAKO,IAAI,GAAGZ,MAAMC,IAAKM,CAAAA,MAAMA,EAAEM,KAAK,CAAC,KAAK,GACrDC,YAAYT,KAAKO,IAAI,GAAGZ,MAAMC,IAAKM,CAAAA,MAAMA,EAAEQ,MAAM,CAAC,KAAK;AAE7D,SAAO;AAAA,IACLP,GAAGJ;AAAAA,IACHM,GAAGD;AAAAA,IACHO,OAAOL,WAAWP;AAAAA,IAClBa,QAAQH,YAAYL;AAAAA,IACpBS,KAAKT;AAAAA,IACLI,OAAOF;AAAAA,IACPI,QAAQD;AAAAA,IACRK,MAAMf;AAAAA,EAAAA;AAEV;AAYA,SAAAgB,oBAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GACE;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAA4CL,OAC5C,CAAAM,MAAAC,OAAA,IAAwBC,SAAyB,IAAI;AAAC,MAAAC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