@parhelia/core 0.1.12881 → 0.1.12882
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/card.d.ts +1 -3
- package/dist/components/ui/card.js +2 -2
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/context-menu.js +2 -2
- package/dist/config/config.js +7 -8
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +7 -0
- package/dist/config/types.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +45 -1
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/FieldListField.d.ts +1 -1
- package/dist/editor/FieldListField.js +18 -20
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/ImageEditor.d.ts +1 -6
- package/dist/editor/ImageEditor.js +3 -19
- package/dist/editor/ImageEditor.js.map +1 -1
- package/dist/editor/PictureEditor.d.ts +1 -2
- package/dist/editor/PictureEditor.js +14 -5
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/ai/Agents.js +2 -2
- package/dist/editor/ai/Agents.js.map +1 -1
- package/dist/editor/ai/GuidanceOverlay.js +11 -1
- package/dist/editor/ai/GuidanceOverlay.js.map +1 -1
- package/dist/editor/ai/InlineAiDialog.js +11 -22
- package/dist/editor/ai/InlineAiDialog.js.map +1 -1
- package/dist/editor/ai/InlineAiTrigger.js +57 -17
- package/dist/editor/ai/InlineAiTrigger.js.map +1 -1
- package/dist/editor/ai/dialogs/capturePageDom.js +36 -66
- package/dist/editor/ai/dialogs/capturePageDom.js.map +1 -1
- package/dist/editor/ai/dialogs/capturePageScreenshot.js +162 -281
- package/dist/editor/ai/dialogs/capturePageScreenshot.js.map +1 -1
- package/dist/editor/ai/terminal/agentSessionState.d.ts +0 -3
- package/dist/editor/ai/terminal/agentSessionState.js +1 -3
- package/dist/editor/ai/terminal/agentSessionState.js.map +1 -1
- package/dist/editor/ai/terminal/agentStartRequest.d.ts +1 -2
- package/dist/editor/ai/terminal/agentStartRequest.js +1 -2
- package/dist/editor/ai/terminal/agentStartRequest.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentCostDisplay.js +1 -1
- package/dist/editor/ai/terminal/components/AgentCostDisplay.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentDocumentList.d.ts +0 -7
- package/dist/editor/ai/terminal/components/AgentDocumentList.js +13 -55
- package/dist/editor/ai/terminal/components/AgentDocumentList.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentFullPromptControls.d.ts +1 -3
- package/dist/editor/ai/terminal/components/AgentFullPromptControls.js +14 -22
- package/dist/editor/ai/terminal/components/AgentFullPromptControls.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentModeSelector.js +4 -4
- package/dist/editor/ai/terminal/components/AgentModeSelector.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentPromptActionButtons.js +4 -4
- package/dist/editor/ai/terminal/components/AgentPromptActionButtons.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentPromptComposer.js +1 -1
- package/dist/editor/ai/terminal/components/AgentPromptComposer.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentPromptInputArea.d.ts +1 -2
- package/dist/editor/ai/terminal/components/AgentPromptInputArea.js +11 -8
- package/dist/editor/ai/terminal/components/AgentPromptInputArea.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentPromptTrayPopovers.d.ts +4 -1
- package/dist/editor/ai/terminal/components/AgentPromptTrayPopovers.js +14 -31
- package/dist/editor/ai/terminal/components/AgentPromptTrayPopovers.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentSettingsPopover.js +1 -1
- package/dist/editor/ai/terminal/components/AgentSettingsPopover.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentTerminalFullLayout.d.ts +1 -2
- package/dist/editor/ai/terminal/components/AgentTerminalFullLayout.js +4 -2
- package/dist/editor/ai/terminal/components/AgentTerminalFullLayout.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentTerminalMessageGroups.js +1 -1
- package/dist/editor/ai/terminal/components/AgentTerminalMessageGroups.js.map +1 -1
- package/dist/editor/ai/terminal/components/AgentTerminalView.js +2 -13
- package/dist/editor/ai/terminal/components/AgentTerminalView.js.map +1 -1
- package/dist/editor/ai/terminal/components/AiResponseMessage.js +14 -16
- package/dist/editor/ai/terminal/components/AiResponseMessage.js.map +1 -1
- package/dist/editor/ai/terminal/components/ContextInfoBar.js +2 -22
- package/dist/editor/ai/terminal/components/ContextInfoBar.js.map +1 -1
- package/dist/editor/ai/terminal/components/QueuedPromptsPanel.js +26 -37
- package/dist/editor/ai/terminal/components/QueuedPromptsPanel.js.map +1 -1
- package/dist/editor/ai/terminal/components/UserMessage.d.ts +1 -2
- package/dist/editor/ai/terminal/components/UserMessage.js +8 -144
- package/dist/editor/ai/terminal/components/UserMessage.js.map +1 -1
- package/dist/editor/ai/terminal/useAgentPromptComposerHandlers.js +1 -1
- package/dist/editor/ai/terminal/useAgentPromptComposerHandlers.js.map +1 -1
- package/dist/editor/ai/terminal/useAgentSessionSync.d.ts +0 -1
- package/dist/editor/ai/terminal/useAgentSubmitHandlers.d.ts +1 -3
- package/dist/editor/ai/terminal/useAgentSubmitHandlers.js +3 -9
- package/dist/editor/ai/terminal/useAgentSubmitHandlers.js.map +1 -1
- package/dist/editor/ai/terminal/useAgentTerminalController.js +0 -7
- package/dist/editor/ai/terminal/useAgentTerminalController.js.map +1 -1
- package/dist/editor/ai/terminal/useAgentTerminalUiState.js +1 -1
- package/dist/editor/ai/terminal/useAgentTerminalUiState.js.map +1 -1
- package/dist/editor/ai/terminal/useAgentUserMessageSocketHandler.js +1 -3
- package/dist/editor/ai/terminal/useAgentUserMessageSocketHandler.js.map +1 -1
- package/dist/editor/ai/useInlineAiPosition.d.ts +1 -1
- package/dist/editor/ai/useInlineAiPosition.js +52 -22
- package/dist/editor/ai/useInlineAiPosition.js.map +1 -1
- package/dist/editor/ai-image-editor/AiImageResultOverlay.js +62 -30
- package/dist/editor/ai-image-editor/AiImageResultOverlay.js.map +1 -1
- package/dist/editor/client/EditorShell.d.ts +1 -5
- package/dist/editor/client/EditorShell.js +136 -285
- package/dist/editor/client/EditorShell.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +5 -33
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/hooks/useSocketMessageHandler.js +17 -14
- package/dist/editor/client/hooks/useSocketMessageHandler.js.map +1 -1
- package/dist/editor/client/itemsRepository.d.ts +0 -2
- package/dist/editor/client/itemsRepository.js +8 -15
- package/dist/editor/client/itemsRepository.js.map +1 -1
- package/dist/editor/client/operations.d.ts +1 -1
- package/dist/editor/client/operations.js +17 -41
- package/dist/editor/client/operations.js.map +1 -1
- package/dist/editor/client/pageModelBuilder.js +7 -24
- package/dist/editor/client/pageModelBuilder.js.map +1 -1
- package/dist/editor/commands/handlers/uiActionHandlers.js +5 -1
- package/dist/editor/commands/handlers/uiActionHandlers.js.map +1 -1
- package/dist/editor/editor-warnings/FinalWorkflowStateReadOnly.js +5 -0
- package/dist/editor/editor-warnings/FinalWorkflowStateReadOnly.js.map +1 -1
- package/dist/editor/editor-warnings/ItemLocked.js +6 -3
- package/dist/editor/editor-warnings/ItemLocked.js.map +1 -1
- package/dist/editor/field-types/MultiLineText.js +3 -10
- package/dist/editor/field-types/MultiLineText.js.map +1 -1
- package/dist/editor/field-types/RawEditor.js +1 -8
- package/dist/editor/field-types/RawEditor.js.map +1 -1
- package/dist/editor/field-types/RichTextEditorComponent.js +45 -156
- package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
- package/dist/editor/field-types/SingleLineText.js +3 -10
- package/dist/editor/field-types/SingleLineText.js.map +1 -1
- package/dist/editor/field-types/richtext/components/ReactSlate.js +2 -8
- package/dist/editor/field-types/richtext/components/ReactSlate.js.map +1 -1
- package/dist/editor/field-types/richtext/contextMenuFactory.d.ts +2 -1
- package/dist/editor/field-types/richtext/contextMenuFactory.js +303 -100
- package/dist/editor/field-types/richtext/contextMenuFactory.js.map +1 -1
- package/dist/editor/field-types/richtext/types.d.ts +0 -2
- package/dist/editor/field-types/richtext/types.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +2 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js +19 -9
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -1
- package/dist/editor/media-selector/TreeSelector.js +30 -24
- package/dist/editor/media-selector/TreeSelector.js.map +1 -1
- package/dist/editor/media-selector/UploadZone.d.ts +2 -1
- package/dist/editor/media-selector/UploadZone.js +21 -9
- package/dist/editor/media-selector/UploadZone.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +2 -8
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/menubar/VersionPreviewCard.js +249 -4
- package/dist/editor/menubar/VersionPreviewCard.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/EditControls.js +2 -2
- package/dist/editor/menubar/toolbar-sections/EditControls.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.d.ts +10 -0
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.js +462 -63
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/ViewportControls.js +1 -1
- package/dist/editor/page-editor-chrome/CommentHighlightings.d.ts +2 -5
- package/dist/editor/page-editor-chrome/CommentHighlightings.js +215 -340
- package/dist/editor/page-editor-chrome/CommentHighlightings.js.map +1 -1
- package/dist/editor/page-editor-chrome/FeedbackHighlightBadge.d.ts +1 -5
- package/dist/editor/page-editor-chrome/FeedbackHighlightBadge.js +4 -11
- package/dist/editor/page-editor-chrome/FeedbackHighlightBadge.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +13 -21
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldEditedIndicator.js +29 -23
- package/dist/editor/page-editor-chrome/FieldEditedIndicator.js.map +1 -1
- package/dist/editor/page-editor-chrome/FrameMenu.js +19 -110
- package/dist/editor/page-editor-chrome/FrameMenu.js.map +1 -1
- package/dist/editor/page-editor-chrome/InlineEditor.d.ts +7 -0
- package/dist/editor/page-editor-chrome/InlineEditor.js +1719 -0
- package/dist/editor/page-editor-chrome/InlineEditor.js.map +1 -0
- package/dist/editor/page-editor-chrome/LockedFieldIndicator.d.ts +2 -3
- package/dist/editor/page-editor-chrome/LockedFieldIndicator.js +45 -148
- package/dist/editor/page-editor-chrome/LockedFieldIndicator.js.map +1 -1
- package/dist/editor/page-editor-chrome/PageEditorChrome.d.ts +0 -2
- package/dist/editor/page-editor-chrome/PageEditorChrome.js +21 -25
- package/dist/editor/page-editor-chrome/PageEditorChrome.js.map +1 -1
- package/dist/editor/page-editor-chrome/PictureEditorOverlay.js +128 -163
- package/dist/editor/page-editor-chrome/PictureEditorOverlay.js.map +1 -1
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.d.ts +1 -1
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +3 -6
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.js.map +1 -1
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.d.ts +2 -1
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.js +146 -83
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.js.map +1 -1
- package/dist/editor/page-editor-chrome/SuggestionHighlightings.d.ts +2 -5
- package/dist/editor/page-editor-chrome/SuggestionHighlightings.js +63 -144
- package/dist/editor/page-editor-chrome/SuggestionHighlightings.js.map +1 -1
- package/dist/editor/page-editor-chrome/VersionDiffHighlightings.d.ts +2 -1
- package/dist/editor/page-editor-chrome/VersionDiffHighlightings.js +30 -101
- package/dist/editor/page-editor-chrome/VersionDiffHighlightings.js.map +1 -1
- package/dist/editor/page-editor-chrome/overlay/IframeOverlayProvider.d.ts +1 -10
- package/dist/editor/page-editor-chrome/overlay/IframeOverlayProvider.js +122 -105
- package/dist/editor/page-editor-chrome/overlay/IframeOverlayProvider.js.map +1 -1
- package/dist/editor/page-editor-chrome/overlay/geometry.d.ts +4 -11
- package/dist/editor/page-editor-chrome/overlay/geometry.js +36 -139
- package/dist/editor/page-editor-chrome/overlay/geometry.js.map +1 -1
- package/dist/editor/page-editor-chrome/overlay/iframeAccess.d.ts +2 -0
- package/dist/editor/page-editor-chrome/overlay/iframeAccess.js +21 -0
- package/dist/editor/page-editor-chrome/overlay/iframeAccess.js.map +1 -0
- package/dist/editor/page-editor-chrome/useInlineAICompletion.d.ts +7 -0
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +758 -0
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -0
- package/dist/editor/page-viewer/EditorForm.js +1 -17
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/page-viewer/MiniMap.d.ts +2 -2
- package/dist/editor/page-viewer/MiniMap.js +364 -176
- package/dist/editor/page-viewer/MiniMap.js.map +1 -1
- package/dist/editor/page-viewer/PageViewer.js +13 -40
- package/dist/editor/page-viewer/PageViewer.js.map +1 -1
- package/dist/editor/page-viewer/PageViewerFrame.d.ts +5 -0
- package/dist/editor/page-viewer/PageViewerFrame.js +1509 -1527
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.d.ts +3 -0
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.js +796 -0
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.js.map +1 -0
- package/dist/editor/page-viewer/pageViewContext.d.ts +0 -32
- package/dist/editor/page-viewer/pageViewContext.js +6 -37
- package/dist/editor/page-viewer/pageViewContext.js.map +1 -1
- package/dist/editor/reviews/Comment.d.ts +1 -2
- package/dist/editor/reviews/Comment.js +4 -9
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/reviews/CommentEditor.js +1 -1
- package/dist/editor/reviews/CommentEditor.js.map +1 -1
- package/dist/editor/reviews/CommentPopover.js +9 -68
- package/dist/editor/reviews/CommentPopover.js.map +1 -1
- package/dist/editor/reviews/CommentView.js +4 -24
- package/dist/editor/reviews/CommentView.js.map +1 -1
- package/dist/editor/reviews/Comments.d.ts +2 -0
- package/dist/editor/reviews/Comments.js +30 -29
- package/dist/editor/reviews/Comments.js.map +1 -1
- package/dist/editor/reviews/FeedbackCard.d.ts +2 -4
- package/dist/editor/reviews/FeedbackCard.js +5 -5
- package/dist/editor/reviews/FeedbackCard.js.map +1 -1
- package/dist/editor/reviews/SuggestedEdit.js +6 -4
- package/dist/editor/reviews/SuggestedEdit.js.map +1 -1
- package/dist/editor/reviews/SuggestionDisplayPopover.js +2 -3
- package/dist/editor/reviews/SuggestionDisplayPopover.js.map +1 -1
- package/dist/editor/reviews/commentAi.js +27 -96
- package/dist/editor/reviews/commentAi.js.map +1 -1
- package/dist/editor/reviews/feedbackSelection.js +4 -32
- package/dist/editor/reviews/feedbackSelection.js.map +1 -1
- package/dist/editor/services/agentService.d.ts +0 -15
- package/dist/editor/services/agentService.js +1 -11
- package/dist/editor/services/agentService.js.map +1 -1
- package/dist/editor/services/contentService.d.ts +1 -0
- package/dist/editor/services/contentService.js.map +1 -1
- package/dist/editor/services/reviewsService.d.ts +2 -2
- package/dist/editor/services/reviewsService.js.map +1 -1
- package/dist/editor/settings/SettingsView.js +2 -2
- package/dist/editor/settings/SettingsView.js.map +1 -1
- package/dist/editor/settings/panels/ProjectTemplatesPanel.js +1 -1
- package/dist/editor/settings/panels/ProjectTemplatesPanel.js.map +1 -1
- package/dist/editor/settings/panels/ProvidersPanel.js +3 -2
- package/dist/editor/settings/panels/ProvidersPanel.js.map +1 -1
- package/dist/editor/sidebar/MorePanelsButton.js +1 -1
- package/dist/editor/sidebar/MorePanelsButton.js.map +1 -1
- package/dist/editor/sidebar/Workbox.js +1 -1
- package/dist/editor/sidebar/Workbox.js.map +1 -1
- package/dist/editor/ui/IconSelectorDialog.js +1 -1
- package/dist/editor/ui/IconSelectorDialog.js.map +1 -1
- package/dist/editor/ui/SimpleIconButton.d.ts +2 -2
- package/dist/editor/ui/SimpleIconButton.js +1 -1
- package/dist/editor/ui/SimpleIconButton.js.map +1 -1
- package/dist/editor/utils.d.ts +17 -1
- package/dist/editor/utils.js +143 -0
- package/dist/editor/utils.js.map +1 -1
- package/dist/editor/version-diff/versionDiffTargets.d.ts +8 -3
- package/dist/editor/version-diff/versionDiffTargets.js +94 -37
- package/dist/editor/version-diff/versionDiffTargets.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.js +1 -1
- package/dist/editor/views/MediaFolderEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/splash-screen/DialogWrappers.js +2 -2
- package/dist/splash-screen/DialogWrappers.js.map +1 -1
- package/dist/splash-screen/ModernSplashScreen.js +3 -11
- package/dist/splash-screen/ModernSplashScreen.js.map +1 -1
- package/dist/splash-screen/NewPage.js +5 -7
- package/dist/splash-screen/NewPage.js.map +1 -1
- package/dist/splash-screen/OpenPage.js +3 -5
- package/dist/splash-screen/OpenPage.js.map +1 -1
- package/dist/splash-screen/RecentPages.js +3 -3
- package/dist/splash-screen/RecentPages.js.map +1 -1
- package/package.json +1 -2
- package/styles.css +0 -49
- package/dist/editor/ai/terminal/components/AgentEditHistoryButton.d.ts +0 -5
- package/dist/editor/ai/terminal/components/AgentEditHistoryButton.js +0 -12
- package/dist/editor/ai/terminal/components/AgentEditHistoryButton.js.map +0 -1
- package/dist/editor/bridge/BridgeClient.d.ts +0 -80
- package/dist/editor/bridge/BridgeClient.js +0 -417
- package/dist/editor/bridge/BridgeClient.js.map +0 -1
- package/dist/editor/field-types/useFormFieldCaretPresence.d.ts +0 -13
- package/dist/editor/field-types/useFormFieldCaretPresence.js +0 -92
- package/dist/editor/field-types/useFormFieldCaretPresence.js.map +0 -1
- package/dist/editor/page-editor-chrome/BridgeInlineFormatOverlay.d.ts +0 -6
- package/dist/editor/page-editor-chrome/BridgeInlineFormatOverlay.js +0 -123
- package/dist/editor/page-editor-chrome/BridgeInlineFormatOverlay.js.map +0 -1
- package/dist/editor/page-editor-chrome/useBridgeInlineEditing.d.ts +0 -26
- package/dist/editor/page-editor-chrome/useBridgeInlineEditing.js +0 -222
- package/dist/editor/page-editor-chrome/useBridgeInlineEditing.js.map +0 -1
- package/dist/editor/page-viewer/bridgeFieldPatch.d.ts +0 -20
- package/dist/editor/page-viewer/bridgeFieldPatch.js +0 -33
- package/dist/editor/page-viewer/bridgeFieldPatch.js.map +0 -1
- package/dist/editor/reviews/commentTransientSelection.d.ts +0 -23
- package/dist/editor/reviews/commentTransientSelection.js +0 -7
- package/dist/editor/reviews/commentTransientSelection.js.map +0 -1
- package/dist/editor/reviews/feedbackOrdering.d.ts +0 -5
- package/dist/editor/reviews/feedbackOrdering.js +0 -27
- package/dist/editor/reviews/feedbackOrdering.js.map +0 -1
- package/dist/editor/reviews/suggestedEditState.d.ts +0 -12
- package/dist/editor/reviews/suggestedEditState.js +0 -90
- package/dist/editor/reviews/suggestedEditState.js.map +0 -1
- package/dist/editor/reviews/suggestionDisplayValue.d.ts +0 -43
- package/dist/editor/reviews/suggestionDisplayValue.js +0 -93
- package/dist/editor/reviews/suggestionDisplayValue.js.map +0 -1
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef,
|
|
3
|
-
import { useEditContext, useFieldsEditContext
|
|
4
|
-
import {
|
|
2
|
+
import { forwardRef, useMemo, } from "react";
|
|
3
|
+
import { useEditContext, useFieldsEditContext } from "../client/editContext";
|
|
4
|
+
import { findElementByNormalizedDataAttribute, findFieldElement, getNextNonChromeMarkerElement, } from "../utils";
|
|
5
5
|
import { CommentDisplayPopover } from "../reviews/CommentDisplayPopover";
|
|
6
|
-
import {
|
|
6
|
+
import { measureElementRect, rectListEquals, toOverlayRect, } from "./overlay/geometry";
|
|
7
|
+
import { getAccessibleIframeDocument } from "./overlay/iframeAccess";
|
|
7
8
|
import { useOverlayMeasurement } from "./overlay/useOverlayMeasurement";
|
|
8
|
-
import { getComponentById } from "../componentTreeHelper";
|
|
9
9
|
import { dedupeFeedbackHighlightItems, FeedbackHighlightBadge, FeedbackHighlightBadgeTray, } from "./FeedbackHighlightBadge";
|
|
10
|
-
import { COMMENT_DRAFT_SELECTION_EVENT, COMMENT_TRANSIENT_ELEMENT_KEY, COMMENT_TRANSIENT_SELECTION_RECT, } from "../reviews/commentTransientSelection";
|
|
11
|
-
const COMMENT_DRAFT_TEXT_RANGE_KEY = "comment-draft-selection";
|
|
12
|
-
const COMMENT_BRIDGE_SOURCE = "comments";
|
|
13
10
|
function commentMeasurementsEqual(previous, next) {
|
|
14
11
|
const previousKeys = Object.keys(previous);
|
|
15
12
|
const nextKeys = Object.keys(next);
|
|
@@ -27,189 +24,56 @@ function commentMeasurementsEqual(previous, next) {
|
|
|
27
24
|
}
|
|
28
25
|
return true;
|
|
29
26
|
}
|
|
30
|
-
export function CommentHighlightings({
|
|
27
|
+
export function CommentHighlightings({ iframe, }) {
|
|
31
28
|
const editContext = useEditContext();
|
|
32
|
-
const modifiedFields = useFieldsEditContext();
|
|
33
|
-
const lastMeasurementsRef = useRef({});
|
|
34
|
-
const bridgeTextRangeRequestRef = useRef({
|
|
35
|
-
signature: "",
|
|
36
|
-
requestedSignature: "",
|
|
37
|
-
hasSeenAnyTarget: false,
|
|
38
|
-
});
|
|
39
|
-
const [commentDraftRange, setCommentDraftRange] = useState();
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const handleDraftSelection = (event) => {
|
|
42
|
-
const detail = event
|
|
43
|
-
.detail;
|
|
44
|
-
setCommentDraftRange(detail?.range);
|
|
45
|
-
};
|
|
46
|
-
window.addEventListener(COMMENT_DRAFT_SELECTION_EVENT, handleDraftSelection);
|
|
47
|
-
return () => {
|
|
48
|
-
window.removeEventListener(COMMENT_DRAFT_SELECTION_EVENT, handleDraftSelection);
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
29
|
const visibleComments = useMemo(() => (editContext?.comments || []).filter((comment) => !comment.suggestedEditId &&
|
|
52
30
|
(editContext?.showResolvedComments ? true : !comment.isResolved)), [editContext?.comments, editContext?.showResolvedComments]);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
if (!comment.fieldId || !range)
|
|
57
|
-
return [];
|
|
58
|
-
return getCommentFieldDescriptors(comment).map((descriptor) => ({
|
|
59
|
-
key: getCommentTextRangeKey(comment),
|
|
60
|
-
elementKey: getCommentTransientElementKey(comment),
|
|
61
|
-
fieldId: descriptor.fieldId,
|
|
62
|
-
item: descriptor.item,
|
|
63
|
-
start: range[0],
|
|
64
|
-
end: range[1],
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
const draftRange = getDraftBridgeTextRange(commentDraftRange);
|
|
68
|
-
return draftRange ? [...commentRanges, draftRange] : commentRanges;
|
|
69
|
-
}, [visibleComments, commentDraftRange]);
|
|
70
|
-
const bridgeTextRangeSignature = useMemo(() => bridgeTextRanges
|
|
71
|
-
.map((range) => [
|
|
72
|
-
range.key,
|
|
73
|
-
range.elementKey,
|
|
74
|
-
range.fieldId,
|
|
75
|
-
range.item.id,
|
|
76
|
-
range.item.language,
|
|
77
|
-
range.item.version,
|
|
78
|
-
range.start,
|
|
79
|
-
range.end,
|
|
80
|
-
].join(":"))
|
|
81
|
-
.join("|"), [bridgeTextRanges]);
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
const requestState = bridgeTextRangeRequestRef.current;
|
|
84
|
-
if (!pageViewContext.bridgeReady || bridgeTextRanges.length === 0) {
|
|
85
|
-
if (pageViewContext.bridgeReady && requestState.signature !== "") {
|
|
86
|
-
// Drop our contribution from the shared union so the highlights clear
|
|
87
|
-
// instead of lingering as phantom geometry targets.
|
|
88
|
-
pageViewContext.requestBridgeGeometry?.({
|
|
89
|
-
source: COMMENT_BRIDGE_SOURCE,
|
|
90
|
-
textRanges: [],
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
requestState.signature = "";
|
|
94
|
-
requestState.requestedSignature = "";
|
|
95
|
-
requestState.hasSeenAnyTarget = false;
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const signatureChanged = requestState.signature !== bridgeTextRangeSignature;
|
|
99
|
-
if (signatureChanged) {
|
|
100
|
-
requestState.signature = bridgeTextRangeSignature;
|
|
101
|
-
requestState.requestedSignature = "";
|
|
102
|
-
requestState.hasSeenAnyTarget = false;
|
|
103
|
-
}
|
|
104
|
-
const bridgeGeometry = pageViewContext.bridgeGeometry;
|
|
105
|
-
const hasAnyTarget = hasAnyExpectedBridgeTextRange(bridgeGeometry, bridgeTextRanges);
|
|
106
|
-
const hasAllTargets = hasAllExpectedBridgeTextRanges(bridgeGeometry, bridgeTextRanges);
|
|
107
|
-
if (hasAnyTarget) {
|
|
108
|
-
requestState.hasSeenAnyTarget = true;
|
|
109
|
-
}
|
|
110
|
-
if (hasAllTargets && !signatureChanged) {
|
|
111
|
-
requestState.requestedSignature = "";
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const shouldRequest = signatureChanged ||
|
|
115
|
-
requestState.requestedSignature !== bridgeTextRangeSignature ||
|
|
116
|
-
(requestState.hasSeenAnyTarget && !hasAnyTarget);
|
|
117
|
-
if (!shouldRequest)
|
|
118
|
-
return;
|
|
119
|
-
requestState.requestedSignature = bridgeTextRangeSignature;
|
|
120
|
-
pageViewContext.requestBridgeGeometry?.({
|
|
121
|
-
source: COMMENT_BRIDGE_SOURCE,
|
|
122
|
-
textRanges: bridgeTextRanges,
|
|
123
|
-
});
|
|
124
|
-
}, [
|
|
125
|
-
pageViewContext,
|
|
126
|
-
pageViewContext.bridgeReady,
|
|
127
|
-
pageViewContext.bridgeGeometry,
|
|
128
|
-
bridgeTextRanges,
|
|
129
|
-
bridgeTextRangeSignature,
|
|
130
|
-
commentDraftRange,
|
|
131
|
-
]);
|
|
132
|
-
const measurements = useOverlayMeasurement((metrics, reasons) => {
|
|
133
|
-
if (!editContext)
|
|
31
|
+
const measurements = useOverlayMeasurement((metrics) => {
|
|
32
|
+
const iframeDocument = getAccessibleIframeDocument(iframe);
|
|
33
|
+
if (!editContext || !iframeDocument?.body)
|
|
134
34
|
return {};
|
|
135
|
-
const bridgeGeometry = pageViewContext.bridgeGeometry;
|
|
136
|
-
const canReusePreviousMeasurement = !reasons.has("viewport") &&
|
|
137
|
-
!reasons.has("layout") &&
|
|
138
|
-
!reasons.has("text");
|
|
139
35
|
const nextMeasurements = {};
|
|
140
36
|
for (const comment of visibleComments) {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
:
|
|
37
|
+
const fieldElement = comment.fieldId
|
|
38
|
+
? findFieldElement(iframe, {
|
|
39
|
+
item: {
|
|
40
|
+
id: comment.itemId,
|
|
41
|
+
language: comment.language,
|
|
42
|
+
version: comment.version,
|
|
43
|
+
},
|
|
44
|
+
fieldId: comment.fieldId,
|
|
45
|
+
})
|
|
46
|
+
: undefined;
|
|
47
|
+
const range = fieldElement
|
|
48
|
+
? resolveCommentRange(comment, fieldElement, iframeDocument)
|
|
49
|
+
: null;
|
|
151
50
|
let rects = [];
|
|
152
51
|
let isTextRange = false;
|
|
153
|
-
if (
|
|
154
|
-
rects =
|
|
155
|
-
? textRangeRects
|
|
156
|
-
: previousTextRangeRects.length
|
|
157
|
-
? previousTextRangeRects
|
|
158
|
-
: getTransientSelectionRects(comment, metrics, pageViewContext.editorIframe);
|
|
52
|
+
if (fieldElement && range) {
|
|
53
|
+
rects = measureVisibleTextRangeRects(iframeDocument, fieldElement, range[0], range[1], metrics);
|
|
159
54
|
isTextRange = rects.length > 0;
|
|
160
55
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
isTextRange =
|
|
172
|
-
!fallbackRect &&
|
|
173
|
-
canReusePreviousMeasurement &&
|
|
174
|
-
previousMeasurement?.isTextRange === true;
|
|
56
|
+
if (rects.length === 0) {
|
|
57
|
+
let fallbackElement = fieldElement;
|
|
58
|
+
if (!fallbackElement && comment.itemId && editContext.page) {
|
|
59
|
+
const componentStart = findElementByNormalizedDataAttribute(iframeDocument.body, "data-component-start", comment.itemId);
|
|
60
|
+
fallbackElement =
|
|
61
|
+
getNextNonChromeMarkerElement(componentStart) ?? undefined;
|
|
62
|
+
}
|
|
63
|
+
const fallbackRect = measureElementRect(fallbackElement, metrics);
|
|
64
|
+
if (fallbackRect)
|
|
65
|
+
rects = [fallbackRect];
|
|
175
66
|
}
|
|
176
67
|
if (rects.length > 0) {
|
|
177
|
-
nextMeasurements[comment.id] = {
|
|
178
|
-
rects,
|
|
179
|
-
isTextRange,
|
|
180
|
-
};
|
|
68
|
+
nextMeasurements[comment.id] = { rects, isTextRange };
|
|
181
69
|
}
|
|
182
70
|
}
|
|
183
71
|
return nextMeasurements;
|
|
184
|
-
}, [
|
|
185
|
-
editContext,
|
|
186
|
-
pageViewContext.bridgeGeometry,
|
|
187
|
-
pageViewContext.bridgeStructure,
|
|
188
|
-
visibleComments,
|
|
189
|
-
], {
|
|
72
|
+
}, [iframe, editContext, visibleComments], {
|
|
190
73
|
initialValue: {},
|
|
191
74
|
equals: commentMeasurementsEqual,
|
|
192
75
|
interests: ["viewport", "layout", "text", "adornment-data"],
|
|
193
76
|
});
|
|
194
|
-
const draftRects = useOverlayMeasurement((metrics) => {
|
|
195
|
-
if (!commentDraftRange)
|
|
196
|
-
return [];
|
|
197
|
-
const bridgeRects = dedupeOverlayRects(measureBridgeTextRangeRects(pageViewContext.bridgeGeometry, COMMENT_DRAFT_TEXT_RANGE_KEY, metrics));
|
|
198
|
-
const fallbackRects = getSelectionRangeClientRects(commentDraftRange, metrics, pageViewContext.editorIframe);
|
|
199
|
-
const rects = bridgeRects.length ? bridgeRects : fallbackRects;
|
|
200
|
-
return rects;
|
|
201
|
-
}, [
|
|
202
|
-
commentDraftRange,
|
|
203
|
-
pageViewContext.bridgeGeometry,
|
|
204
|
-
pageViewContext.editorIframe,
|
|
205
|
-
], {
|
|
206
|
-
initialValue: [],
|
|
207
|
-
equals: rectListEquals,
|
|
208
|
-
interests: ["viewport", "layout", "text", "adornment-data"],
|
|
209
|
-
});
|
|
210
|
-
useEffect(() => {
|
|
211
|
-
lastMeasurementsRef.current = measurements;
|
|
212
|
-
}, [measurements]);
|
|
213
77
|
const overlayGroups = useMemo(() => {
|
|
214
78
|
const groups = new Map();
|
|
215
79
|
for (const comment of visibleComments) {
|
|
@@ -233,22 +97,11 @@ export function CommentHighlightings({ pageViewContext, variant = "default", })
|
|
|
233
97
|
isSelected: comment.id === editContext?.selectedComment?.id,
|
|
234
98
|
});
|
|
235
99
|
}
|
|
236
|
-
|
|
237
|
-
return nextGroups;
|
|
100
|
+
return Array.from(groups.values());
|
|
238
101
|
}, [visibleComments, measurements, editContext?.selectedComment?.id]);
|
|
239
102
|
if (!editContext)
|
|
240
103
|
return null;
|
|
241
|
-
return (_jsxs(_Fragment, { children: [_jsx("style", { children: commentHighlightingStyles }),
|
|
242
|
-
position: "absolute",
|
|
243
|
-
top: rect.y,
|
|
244
|
-
left: rect.x,
|
|
245
|
-
width: rect.width,
|
|
246
|
-
height: rect.height,
|
|
247
|
-
pointerEvents: "none",
|
|
248
|
-
}, children: _jsx("div", { "data-testid": "comment-draft-highlight", className: "absolute right-0 bottom-[0.08em] left-0 h-[0.82em] min-h-[10px]", style: {
|
|
249
|
-
...getDraftCommentRangeStyle(),
|
|
250
|
-
zIndex: 0,
|
|
251
|
-
} }) }, `comment-draft-${index}`))), overlayGroups.flatMap((group) => {
|
|
104
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: commentHighlightingStyles }), overlayGroups.flatMap((group) => {
|
|
252
105
|
const badgeComments = dedupeFeedbackHighlightItems(group.comments, (comment) => comment.id === editContext.selectedComment?.id);
|
|
253
106
|
return group.rects.map((rect, index) => (_jsxs("div", { style: {
|
|
254
107
|
position: "absolute",
|
|
@@ -257,38 +110,26 @@ export function CommentHighlightings({ pageViewContext, variant = "default", })
|
|
|
257
110
|
width: rect.width,
|
|
258
111
|
height: rect.height,
|
|
259
112
|
pointerEvents: "none",
|
|
260
|
-
}, children: [group.isTextRange ? (_jsx("div", {
|
|
113
|
+
}, children: [group.isTextRange ? (_jsx("div", { className: "absolute right-0 bottom-[0.08em] left-0 h-[0.82em] min-h-[10px]", style: {
|
|
261
114
|
...getCommentRangeStyle(group.comments, group.isSelected),
|
|
262
115
|
zIndex: 0,
|
|
263
|
-
} })) : (_jsx("div", {
|
|
116
|
+
} })) : (_jsx("div", { className: "absolute inset-0 rounded-[3px]", style: {
|
|
264
117
|
...getCommentFallbackStyle(group.comments, group.isSelected),
|
|
265
118
|
zIndex: 0,
|
|
266
|
-
} })), index === 0 && (_jsx(FeedbackHighlightBadgeTray, {
|
|
267
|
-
top:
|
|
268
|
-
|
|
269
|
-
? -11
|
|
270
|
-
: -8
|
|
271
|
-
: group.isTextRange
|
|
272
|
-
? -24
|
|
273
|
-
: -16,
|
|
274
|
-
left: variant === "minimap"
|
|
275
|
-
? group.isTextRange
|
|
276
|
-
? -4
|
|
277
|
-
: 4
|
|
278
|
-
: group.isTextRange
|
|
279
|
-
? -9
|
|
280
|
-
: 8,
|
|
119
|
+
} })), index === 0 && (_jsx(FeedbackHighlightBadgeTray, { style: {
|
|
120
|
+
top: group.isTextRange ? -24 : -16,
|
|
121
|
+
left: group.isTextRange ? -9 : 8,
|
|
281
122
|
}, children: badgeComments.map((comment, badgeIndex) => {
|
|
282
123
|
const isSelected = comment.id === editContext.selectedComment?.id;
|
|
283
124
|
return (_jsx(CommentDisplayPopover, { comment: comment, onCommentUpdated: () => {
|
|
284
125
|
editContext?.loadComments?.();
|
|
285
|
-
}, children: _jsx(CommentHighlightBadge, { comment: comment, isSelected: isSelected,
|
|
126
|
+
}, children: _jsx(CommentHighlightBadge, { comment: comment, isSelected: isSelected, zIndex: isSelected
|
|
286
127
|
? badgeComments.length + 101
|
|
287
128
|
: badgeComments.length - badgeIndex + 100 }) }, comment.id));
|
|
288
129
|
}) }))] }, `${group.key}-${index}`)));
|
|
289
130
|
})] }));
|
|
290
131
|
}
|
|
291
|
-
const CommentHighlightBadge = forwardRef(function CommentHighlightBadge({ comment, isSelected,
|
|
132
|
+
const CommentHighlightBadge = forwardRef(function CommentHighlightBadge({ comment, isSelected, zIndex, className, style, onClick, ...buttonProps }, ref) {
|
|
292
133
|
const editContext = useEditContext();
|
|
293
134
|
const modifiedFields = useFieldsEditContext();
|
|
294
135
|
const handleClick = (event) => {
|
|
@@ -309,7 +150,7 @@ const CommentHighlightBadge = forwardRef(function CommentHighlightBadge({ commen
|
|
|
309
150
|
}, false);
|
|
310
151
|
}
|
|
311
152
|
};
|
|
312
|
-
return (_jsx(FeedbackHighlightBadge, { ref: ref, item: comment, isSelected: isSelected,
|
|
153
|
+
return (_jsx(FeedbackHighlightBadge, { ref: ref, item: comment, isSelected: isSelected, zIndex: zIndex, testId: "comment-highlight-icon", ariaSubject: "comment", className: className, style: style, onClick: handleClick, ...buttonProps }));
|
|
313
154
|
});
|
|
314
155
|
function getCommentMeasurementKey(measurement) {
|
|
315
156
|
const rectKey = measurement.rects
|
|
@@ -320,140 +161,77 @@ function getCommentMeasurementKey(measurement) {
|
|
|
320
161
|
function roundMeasurement(value) {
|
|
321
162
|
return Math.round(value * 2) / 2;
|
|
322
163
|
}
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (!range?.fieldId || !range.itemId || !textRange)
|
|
329
|
-
return undefined;
|
|
330
|
-
return {
|
|
331
|
-
key: COMMENT_DRAFT_TEXT_RANGE_KEY,
|
|
332
|
-
elementKey: range.elementKey,
|
|
333
|
-
fieldId: range.fieldId,
|
|
334
|
-
item: {
|
|
335
|
-
id: range.itemId,
|
|
336
|
-
language: range.language || "",
|
|
337
|
-
version: typeof range.version === "number" ? range.version : undefined,
|
|
338
|
-
},
|
|
339
|
-
start: textRange[0],
|
|
340
|
-
end: textRange[1],
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function getSelectionTextRange(range) {
|
|
344
|
-
if (!range?.text?.trim() ||
|
|
345
|
-
typeof range.startOffset !== "number" ||
|
|
346
|
-
typeof range.endOffset !== "number") {
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
const start = Math.max(0, Math.min(range.startOffset, range.endOffset));
|
|
350
|
-
const end = Math.max(start, range.startOffset, range.endOffset);
|
|
351
|
-
return end > start ? [start, end] : null;
|
|
352
|
-
}
|
|
353
|
-
function getCommentTransientElementKey(comment) {
|
|
354
|
-
return comment[COMMENT_TRANSIENT_ELEMENT_KEY];
|
|
355
|
-
}
|
|
356
|
-
function hasAnyExpectedBridgeTextRange(geometry, textRanges) {
|
|
357
|
-
if (!geometry)
|
|
358
|
-
return false;
|
|
359
|
-
const expectedKeys = new Set(textRanges.map((range) => range.key));
|
|
360
|
-
return geometry.targets.some((target) => target.kind === "textRange" && expectedKeys.has(target.key));
|
|
361
|
-
}
|
|
362
|
-
function hasAllExpectedBridgeTextRanges(geometry, textRanges) {
|
|
363
|
-
if (!geometry)
|
|
364
|
-
return false;
|
|
365
|
-
const availableKeys = new Set(geometry.targets
|
|
366
|
-
.filter((target) => target.kind === "textRange")
|
|
367
|
-
.map((target) => target.key));
|
|
368
|
-
return textRanges.every((range) => availableKeys.has(range.key));
|
|
369
|
-
}
|
|
370
|
-
function getCommentTextRange(comment) {
|
|
371
|
-
if (typeof comment.rangeStart !== "number" ||
|
|
372
|
-
typeof comment.rangeEnd !== "number") {
|
|
373
|
-
return null;
|
|
374
|
-
}
|
|
375
|
-
const start = Math.max(0, Math.min(comment.rangeStart, comment.rangeEnd));
|
|
376
|
-
const end = Math.max(start, comment.rangeStart, comment.rangeEnd);
|
|
377
|
-
return end > start ? [start, end] : null;
|
|
378
|
-
}
|
|
379
|
-
function getCommentFieldDescriptors(comment) {
|
|
380
|
-
if (!comment.fieldId)
|
|
164
|
+
function measureVisibleTextRangeRects(iframeDocument, root, start, end, metrics) {
|
|
165
|
+
const text = root.textContent || "";
|
|
166
|
+
const boundedStart = Math.max(0, Math.min(start, text.length));
|
|
167
|
+
const boundedEnd = Math.max(boundedStart, Math.min(end, text.length));
|
|
168
|
+
if (boundedStart >= boundedEnd)
|
|
381
169
|
return [];
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (candidates.some((candidate) => normalizeMarkerId(candidate.id) === normalizedId)) {
|
|
395
|
-
return;
|
|
170
|
+
const rects = [];
|
|
171
|
+
const walker = iframeDocument.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
172
|
+
let absoluteOffset = 0;
|
|
173
|
+
let textNode;
|
|
174
|
+
while ((textNode = walker.nextNode())) {
|
|
175
|
+
const nodeText = textNode.textContent || "";
|
|
176
|
+
const nodeStart = absoluteOffset;
|
|
177
|
+
const nodeEnd = nodeStart + nodeText.length;
|
|
178
|
+
if (nodeEnd > boundedStart && nodeStart < boundedEnd) {
|
|
179
|
+
const localStart = Math.max(0, boundedStart - nodeStart);
|
|
180
|
+
const localEnd = Math.min(nodeText.length, boundedEnd - nodeStart);
|
|
181
|
+
rects.push(...measureVisibleTextNodeRects(iframeDocument, textNode, nodeText, localStart, localEnd, metrics));
|
|
396
182
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
version: comment.version,
|
|
401
|
-
});
|
|
402
|
-
};
|
|
403
|
-
addCandidate(comment.itemId);
|
|
404
|
-
addCandidate(comment.mainItemId);
|
|
405
|
-
comment.relatedItems?.forEach((item) => addCandidate(item.itemId));
|
|
406
|
-
return candidates;
|
|
407
|
-
}
|
|
408
|
-
function measureBridgeCommentComponentRect(comment, pageViewContext, bridgeGeometry, metrics) {
|
|
409
|
-
const page = pageViewContext?.page;
|
|
410
|
-
if (!page)
|
|
411
|
-
return null;
|
|
412
|
-
for (const item of getCommentCandidateItems(comment)) {
|
|
413
|
-
const component = getComponentById(item.id, page);
|
|
414
|
-
if (!component)
|
|
415
|
-
continue;
|
|
416
|
-
const measurement = measureBridgeComponentRect(bridgeGeometry, component, metrics);
|
|
417
|
-
if (measurement?.rect)
|
|
418
|
-
return measurement.rect;
|
|
183
|
+
absoluteOffset = nodeEnd;
|
|
184
|
+
if (absoluteOffset >= boundedEnd)
|
|
185
|
+
break;
|
|
419
186
|
}
|
|
420
|
-
return
|
|
187
|
+
return rects;
|
|
421
188
|
}
|
|
422
|
-
function
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
189
|
+
function measureVisibleTextNodeRects(iframeDocument, textNode, nodeText, start, end, metrics) {
|
|
190
|
+
const rects = [];
|
|
191
|
+
let cursor = start;
|
|
192
|
+
while (cursor < end) {
|
|
193
|
+
let lineEnd = cursor;
|
|
194
|
+
while (lineEnd < end && !isLineBreak(nodeText[lineEnd])) {
|
|
195
|
+
lineEnd++;
|
|
196
|
+
}
|
|
197
|
+
let visibleStart = cursor;
|
|
198
|
+
while (visibleStart < lineEnd &&
|
|
199
|
+
isHorizontalWhitespace(nodeText[visibleStart])) {
|
|
200
|
+
visibleStart++;
|
|
201
|
+
}
|
|
202
|
+
let visibleEnd = lineEnd;
|
|
203
|
+
while (visibleEnd > visibleStart &&
|
|
204
|
+
isHorizontalWhitespace(nodeText[visibleEnd - 1])) {
|
|
205
|
+
visibleEnd--;
|
|
206
|
+
}
|
|
207
|
+
if (visibleStart < visibleEnd) {
|
|
208
|
+
try {
|
|
209
|
+
const textRange = iframeDocument.createRange();
|
|
210
|
+
textRange.setStart(textNode, visibleStart);
|
|
211
|
+
textRange.setEnd(textNode, visibleEnd);
|
|
212
|
+
rects.push(...Array.from(textRange.getClientRects())
|
|
213
|
+
.filter((rect) => rect.width > 1 && rect.height > 1)
|
|
214
|
+
.map((rect) => toOverlayRect(rect, metrics)));
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// Ignore detached or otherwise invalid text nodes while the iframe mutates.
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
cursor = lineEnd;
|
|
221
|
+
if (nodeText[cursor] === "\r" && nodeText[cursor + 1] === "\n") {
|
|
222
|
+
cursor += 2;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
cursor++;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return rects;
|
|
429
229
|
}
|
|
430
|
-
function
|
|
431
|
-
|
|
432
|
-
return [];
|
|
433
|
-
const iframeRect = iframe?.getBoundingClientRect();
|
|
434
|
-
return [
|
|
435
|
-
toOverlayRect({
|
|
436
|
-
left: iframeRect ? rect.left - iframeRect.left : rect.left,
|
|
437
|
-
top: iframeRect ? rect.top - iframeRect.top : rect.top,
|
|
438
|
-
width: rect.width,
|
|
439
|
-
height: rect.height,
|
|
440
|
-
}, metrics),
|
|
441
|
-
];
|
|
230
|
+
function isLineBreak(value) {
|
|
231
|
+
return value === "\n" || value === "\r";
|
|
442
232
|
}
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
return rects.filter((rect) => {
|
|
446
|
-
const key = [
|
|
447
|
-
Math.round(rect.x * 100),
|
|
448
|
-
Math.round(rect.y * 100),
|
|
449
|
-
Math.round(rect.width * 100),
|
|
450
|
-
Math.round(rect.height * 100),
|
|
451
|
-
].join(":");
|
|
452
|
-
if (seen.has(key))
|
|
453
|
-
return false;
|
|
454
|
-
seen.add(key);
|
|
455
|
-
return true;
|
|
456
|
-
});
|
|
233
|
+
function isHorizontalWhitespace(value) {
|
|
234
|
+
return value === " " || value === "\t" || value === "\f" || value === "\v";
|
|
457
235
|
}
|
|
458
236
|
function getCommentRangeStyle(comments, isSelected) {
|
|
459
237
|
const allResolved = comments.every((comment) => comment.isResolved);
|
|
@@ -475,13 +253,6 @@ function getCommentRangeStyle(comments, isSelected) {
|
|
|
475
253
|
: {}),
|
|
476
254
|
};
|
|
477
255
|
}
|
|
478
|
-
function getDraftCommentRangeStyle() {
|
|
479
|
-
return {
|
|
480
|
-
background: "color-mix(in srgb, var(--color-highlight-100) 32%, transparent)",
|
|
481
|
-
borderRadius: "2px",
|
|
482
|
-
boxShadow: "0 1px 4px color-mix(in srgb, var(--color-highlight-100) 18%, transparent)",
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
256
|
function getCommentFallbackStyle(comments, isSelected) {
|
|
486
257
|
const allResolved = comments.every((comment) => comment.isResolved);
|
|
487
258
|
const color = allResolved
|
|
@@ -502,4 +273,108 @@ const commentHighlightingStyles = `
|
|
|
502
273
|
}
|
|
503
274
|
}
|
|
504
275
|
`;
|
|
276
|
+
function resolveCommentRange(comment, fieldElement, iframeDocument) {
|
|
277
|
+
if (comment.rangeStart === undefined || comment.rangeEnd === undefined) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
const originalRange = [
|
|
281
|
+
Math.max(0, comment.rangeStart),
|
|
282
|
+
Math.max(comment.rangeStart, comment.rangeEnd),
|
|
283
|
+
];
|
|
284
|
+
const storedText = getStoredFieldText(comment, fieldElement, iframeDocument);
|
|
285
|
+
const currentText = fieldElement.textContent || "";
|
|
286
|
+
if (!storedText || storedText === currentText) {
|
|
287
|
+
return originalRange;
|
|
288
|
+
}
|
|
289
|
+
const mapping = computeMapping(currentText, storedText);
|
|
290
|
+
const mappedStart = mapping[originalRange[0]];
|
|
291
|
+
const mappedEnd = mapping[originalRange[1]];
|
|
292
|
+
if (mappedStart === undefined || mappedEnd === undefined) {
|
|
293
|
+
return originalRange;
|
|
294
|
+
}
|
|
295
|
+
return [mappedStart, Math.max(mappedStart, mappedEnd)];
|
|
296
|
+
}
|
|
297
|
+
function getStoredFieldText(comment, fieldElement, iframeDocument) {
|
|
298
|
+
if (!comment.fieldValue)
|
|
299
|
+
return "";
|
|
300
|
+
const isRichText = fieldElement.getAttribute("data-is-richtext") === "true";
|
|
301
|
+
if (!isRichText)
|
|
302
|
+
return comment.fieldValue;
|
|
303
|
+
const template = iframeDocument.createElement("template");
|
|
304
|
+
template.innerHTML = comment.fieldValue;
|
|
305
|
+
return template.content.textContent || "";
|
|
306
|
+
}
|
|
307
|
+
function computeMapping(s1, s2) {
|
|
308
|
+
const n = s1.length;
|
|
309
|
+
const m = s2.length;
|
|
310
|
+
const dp = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
311
|
+
const back = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(""));
|
|
312
|
+
for (let i = 0; i <= n; i++) {
|
|
313
|
+
dp[i][0] = i;
|
|
314
|
+
if (i > 0)
|
|
315
|
+
back[i][0] = "D";
|
|
316
|
+
}
|
|
317
|
+
for (let j = 0; j <= m; j++) {
|
|
318
|
+
dp[0][j] = j;
|
|
319
|
+
if (j > 0)
|
|
320
|
+
back[0][j] = "I";
|
|
321
|
+
}
|
|
322
|
+
for (let i = 1; i <= n; i++) {
|
|
323
|
+
for (let j = 1; j <= m; j++) {
|
|
324
|
+
const cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
|
|
325
|
+
const deletion = dp[i - 1][j] + 1;
|
|
326
|
+
const insertion = dp[i][j - 1] + 1;
|
|
327
|
+
const substitution = dp[i - 1][j - 1] + cost;
|
|
328
|
+
let bestVal = deletion;
|
|
329
|
+
let op = "D";
|
|
330
|
+
if (insertion < bestVal) {
|
|
331
|
+
bestVal = insertion;
|
|
332
|
+
op = "I";
|
|
333
|
+
}
|
|
334
|
+
if (substitution < bestVal) {
|
|
335
|
+
bestVal = substitution;
|
|
336
|
+
op = cost === 0 ? "M" : "S";
|
|
337
|
+
}
|
|
338
|
+
dp[i][j] = bestVal;
|
|
339
|
+
back[i][j] = op;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const ops = [];
|
|
343
|
+
let i = n;
|
|
344
|
+
let j = m;
|
|
345
|
+
while (i > 0 || j > 0) {
|
|
346
|
+
const op = back[i][j];
|
|
347
|
+
ops.push(op);
|
|
348
|
+
if (op === "M" || op === "S") {
|
|
349
|
+
i--;
|
|
350
|
+
j--;
|
|
351
|
+
}
|
|
352
|
+
else if (op === "D") {
|
|
353
|
+
i--;
|
|
354
|
+
}
|
|
355
|
+
else if (op === "I") {
|
|
356
|
+
j--;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
ops.reverse();
|
|
360
|
+
const mapping = new Array(m + 1);
|
|
361
|
+
let iPos = 0;
|
|
362
|
+
let jPos = 0;
|
|
363
|
+
mapping[jPos] = iPos;
|
|
364
|
+
for (const op of ops) {
|
|
365
|
+
if (op === "M" || op === "S") {
|
|
366
|
+
iPos++;
|
|
367
|
+
jPos++;
|
|
368
|
+
mapping[jPos] = iPos;
|
|
369
|
+
}
|
|
370
|
+
else if (op === "I") {
|
|
371
|
+
jPos++;
|
|
372
|
+
mapping[jPos] = iPos;
|
|
373
|
+
}
|
|
374
|
+
else if (op === "D") {
|
|
375
|
+
iPos++;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return mapping;
|
|
379
|
+
}
|
|
505
380
|
//# sourceMappingURL=CommentHighlightings.js.map
|