@parhelia/core 0.1.12554 → 0.1.12556
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/agents-view/AgentCard.d.ts +4 -6
- package/dist/agents-view/AgentCard.js +24 -143
- package/dist/agents-view/AgentCard.js.map +1 -1
- package/dist/agents-view/AgentsInbox.d.ts +1 -1
- package/dist/agents-view/AgentsInbox.js +92 -7
- package/dist/agents-view/AgentsInbox.js.map +1 -1
- package/dist/agents-view/AgentsTitlebar.js +2 -3
- package/dist/agents-view/AgentsTitlebar.js.map +1 -1
- package/dist/agents-view/AgentsView.d.ts +7 -6
- package/dist/agents-view/AgentsView.js +98 -187
- package/dist/agents-view/AgentsView.js.map +1 -1
- package/dist/agents-view/AgentsWorkspaceView.d.ts +6 -2
- package/dist/agents-view/AgentsWorkspaceView.js +113 -266
- package/dist/agents-view/AgentsWorkspaceView.js.map +1 -1
- package/dist/agents-view/ProfileAgentsGroup.d.ts +1 -2
- package/dist/agents-view/ProfileAgentsGroup.js +3 -4
- package/dist/agents-view/ProfileAgentsGroup.js.map +1 -1
- package/dist/components/ActionButton.d.ts +1 -1
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/components/FilterInput.d.ts +1 -1
- package/dist/components/FilterInput.js +1 -1
- package/dist/components/FilterInput.js.map +1 -1
- package/dist/components/ui/LanguageSelector.js +4 -2
- package/dist/components/ui/LanguageSelector.js.map +1 -1
- package/dist/components/ui/PlaceholderInput.js +3 -3
- package/dist/components/ui/PlaceholderInput.js.map +1 -1
- package/dist/components/ui/PlaceholderInputTypes.js +1 -1
- package/dist/components/ui/PlaceholderInputTypes.js.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts +1 -1
- package/dist/components/ui/alert-dialog.js +10 -6
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/button.d.ts +4 -4
- package/dist/components/ui/button.js +1 -4
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts +1 -1
- package/dist/components/ui/context-menu.js +4 -12
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/copy-button.d.ts +1 -2
- package/dist/components/ui/copy-button.js +2 -2
- package/dist/components/ui/copy-button.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +1 -1
- package/dist/components/ui/dialog.js +126 -21
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/input.d.ts +1 -1
- package/dist/components/ui/input.js +3 -5
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/paste-button.d.ts +1 -2
- package/dist/components/ui/paste-button.js +2 -2
- package/dist/components/ui/paste-button.js.map +1 -1
- package/dist/components/ui/popover.js +9 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/styled-dialog-title.js +1 -1
- package/dist/components/ui/styled-dialog-title.js.map +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/tabs.js +11 -4
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/config/config.d.ts +2 -4
- package/dist/config/config.js +70 -250
- package/dist/config/config.js.map +1 -1
- package/dist/config/types/workspace.d.ts +0 -6
- package/dist/config/types.d.ts +12 -63
- package/dist/config/types.js.map +1 -1
- package/dist/editor/ComponentInfo.d.ts +4 -0
- package/dist/editor/ComponentInfo.js +41 -0
- package/dist/editor/ComponentInfo.js.map +1 -0
- package/dist/editor/ConfirmationDialog.js +4 -20
- package/dist/editor/ConfirmationDialog.js.map +1 -1
- package/dist/editor/ContentTree.d.ts +1 -2
- package/dist/editor/ContentTree.js +32 -93
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/Editor.js +22 -87
- package/dist/editor/Editor.js.map +1 -1
- package/dist/editor/FieldHistory.js +36 -84
- package/dist/editor/FieldHistory.js.map +1 -1
- package/dist/editor/FieldListField.js +9 -21
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/FieldListFieldWithFallbacks.js +2 -23
- package/dist/editor/FieldListFieldWithFallbacks.js.map +1 -1
- package/dist/editor/GlobalMenuBar.js +2 -29
- package/dist/editor/GlobalMenuBar.js.map +1 -1
- package/dist/editor/ImageEditor.js +2 -5
- package/dist/editor/ImageEditor.js.map +1 -1
- package/dist/editor/ItemInfo.js +1 -36
- package/dist/editor/ItemInfo.js.map +1 -1
- package/dist/editor/LinkEditorDialog.js +0 -3
- package/dist/editor/LinkEditorDialog.js.map +1 -1
- package/dist/editor/MainLayout.d.ts +2 -0
- package/dist/editor/MainLayout.js +8 -65
- package/dist/editor/MainLayout.js.map +1 -1
- package/dist/editor/MigrationsView.js +5 -29
- package/dist/editor/MigrationsView.js.map +1 -1
- package/dist/editor/MobileLayout.js +12 -37
- package/dist/editor/MobileLayout.js.map +1 -1
- package/dist/editor/PictureCropper.js +45 -54
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +15 -17
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/QuickItemSwitcher.js +21 -21
- package/dist/editor/QuickItemSwitcher.js.map +1 -1
- package/dist/editor/SetupWizard.js +12 -52
- package/dist/editor/SetupWizard.js.map +1 -1
- package/dist/editor/Titlebar.js +2 -7
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/AgentCostDisplay.d.ts +0 -1
- package/dist/editor/ai/AgentCostDisplay.js +1 -1
- package/dist/editor/ai/AgentCostDisplay.js.map +1 -1
- package/dist/editor/ai/AgentDocumentList.js +14 -32
- package/dist/editor/ai/AgentDocumentList.js.map +1 -1
- package/dist/editor/ai/AgentGreeting.js +2 -3
- package/dist/editor/ai/AgentGreeting.js.map +1 -1
- package/dist/editor/ai/AgentProfileSelector.js +1 -2
- package/dist/editor/ai/AgentProfileSelector.js.map +1 -1
- package/dist/editor/ai/AgentStatusBadge.d.ts +5 -0
- package/dist/editor/ai/AgentStatusBadge.js +65 -67
- package/dist/editor/ai/AgentStatusBadge.js.map +1 -1
- package/dist/editor/ai/AgentTerminal.d.ts +2 -14
- package/dist/editor/ai/AgentTerminal.js +483 -2377
- package/dist/editor/ai/AgentTerminal.js.map +1 -1
- package/dist/editor/ai/AgentTerminalStatusBar.d.ts +3 -8
- package/dist/editor/ai/AgentTerminalStatusBar.js +56 -460
- package/dist/editor/ai/AgentTerminalStatusBar.js.map +1 -1
- package/dist/editor/ai/Agents.js +113 -150
- package/dist/editor/ai/Agents.js.map +1 -1
- package/dist/editor/ai/AiResponseMessage.d.ts +1 -10
- package/dist/editor/ai/AiResponseMessage.js +23 -238
- package/dist/editor/ai/AiResponseMessage.js.map +1 -1
- package/dist/editor/ai/ContextInfoBar.d.ts +3 -2
- package/dist/editor/ai/ContextInfoBar.js +7 -64
- package/dist/editor/ai/ContextInfoBar.js.map +1 -1
- package/dist/editor/ai/GuidanceOverlay.js +11 -17
- package/dist/editor/ai/GuidanceOverlay.js.map +1 -1
- package/dist/editor/ai/HelpTerminal.d.ts +5 -0
- package/dist/editor/ai/HelpTerminal.js +166 -0
- package/dist/editor/ai/HelpTerminal.js.map +1 -0
- package/dist/editor/ai/InlineAiDialog.d.ts +1 -1
- package/dist/editor/ai/InlineAiDialog.js +192 -514
- package/dist/editor/ai/InlineAiDialog.js.map +1 -1
- package/dist/editor/ai/InlineAiTrigger.js +12 -115
- package/dist/editor/ai/InlineAiTrigger.js.map +1 -1
- package/dist/editor/ai/MediaImage.js +8 -40
- package/dist/editor/ai/MediaImage.js.map +1 -1
- package/dist/editor/ai/SpawnedAgentsPanel.js +12 -10
- package/dist/editor/ai/SpawnedAgentsPanel.js.map +1 -1
- package/dist/editor/ai/ToolCallDisplay.d.ts +2 -22
- package/dist/editor/ai/ToolCallDisplay.js +147 -518
- package/dist/editor/ai/ToolCallDisplay.js.map +1 -1
- package/dist/editor/ai/dialogs/AgentDialogHandler.d.ts +8 -1
- package/dist/editor/ai/dialogs/AgentDialogHandler.js +42 -379
- package/dist/editor/ai/dialogs/AgentDialogHandler.js.map +1 -1
- package/dist/editor/ai/dialogs/QuestionnaireInline.d.ts +1 -5
- package/dist/editor/ai/dialogs/QuestionnaireInline.js +60 -628
- package/dist/editor/ai/dialogs/QuestionnaireInline.js.map +1 -1
- package/dist/editor/ai/dialogs/agentDialogTypes.d.ts +0 -115
- package/dist/editor/ai/dialogs/agentDialogTypes.js +0 -2
- package/dist/editor/ai/dialogs/agentDialogTypes.js.map +1 -1
- package/dist/editor/ai/types.d.ts +1 -3
- package/dist/editor/ai/useAgentStatus.d.ts +1 -2
- package/dist/editor/ai/useAgentStatus.js +99 -86
- package/dist/editor/ai/useAgentStatus.js.map +1 -1
- package/dist/editor/ai/useInlineAiPosition.js +5 -45
- package/dist/editor/ai/useInlineAiPosition.js.map +1 -1
- package/dist/editor/client/AboutDialog.js +2 -4
- package/dist/editor/client/AboutDialog.js.map +1 -1
- package/dist/editor/client/EditorShell.d.ts +1 -4
- package/dist/editor/client/EditorShell.js +230 -730
- package/dist/editor/client/EditorShell.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +19 -33
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/helpers.js +0 -6
- package/dist/editor/client/helpers.js.map +1 -1
- package/dist/editor/client/hooks/useEditorUrlSync.js +2 -1
- package/dist/editor/client/hooks/useEditorUrlSync.js.map +1 -1
- package/dist/editor/client/hooks/useEditorWebSocket.d.ts +0 -10
- package/dist/editor/client/hooks/useEditorWebSocket.js +14 -209
- package/dist/editor/client/hooks/useEditorWebSocket.js.map +1 -1
- package/dist/editor/client/hooks/useQuota.d.ts +0 -8
- package/dist/editor/client/hooks/useQuota.js.map +1 -1
- package/dist/editor/client/hooks/useSocketMessageHandler.js +7 -68
- package/dist/editor/client/hooks/useSocketMessageHandler.js.map +1 -1
- package/dist/editor/client/itemsRepository.js +6 -10
- package/dist/editor/client/itemsRepository.js.map +1 -1
- package/dist/editor/client/operations.d.ts +3 -6
- package/dist/editor/client/operations.js +30 -208
- package/dist/editor/client/operations.js.map +1 -1
- package/dist/editor/client/pageModelBuilder.js +31 -4
- package/dist/editor/client/pageModelBuilder.js.map +1 -1
- package/dist/editor/client/ui/DevModeIndicator.js +2 -2
- package/dist/editor/client/ui/DevModeIndicator.js.map +1 -1
- package/dist/editor/client/ui/EditorChrome.d.ts +6 -0
- package/dist/editor/client/ui/EditorChrome.js +72 -55
- package/dist/editor/client/ui/EditorChrome.js.map +1 -1
- package/dist/editor/client/ui/FullscreenControls.js +3 -5
- package/dist/editor/client/ui/FullscreenControls.js.map +1 -1
- package/dist/editor/commands/commands.d.ts +1 -11
- package/dist/editor/commands/commands.js +1 -12
- package/dist/editor/commands/commands.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +55 -109
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/commands/customCommandConverter.d.ts +1 -8
- package/dist/editor/commands/customCommandConverter.js +5 -35
- package/dist/editor/commands/customCommandConverter.js.map +1 -1
- package/dist/editor/commands/handlers/agentHandler.js +1 -2
- package/dist/editor/commands/handlers/agentHandler.js.map +1 -1
- package/dist/editor/commands/itemCommands.d.ts +0 -3
- package/dist/editor/commands/itemCommands.js +10 -93
- package/dist/editor/commands/itemCommands.js.map +1 -1
- package/dist/editor/commands/undo.d.ts +15 -9
- package/dist/editor/commands/undo.js +0 -24
- package/dist/editor/commands/undo.js.map +1 -1
- package/dist/editor/context-menu/InsertMenu.js +39 -83
- package/dist/editor/context-menu/InsertMenu.js.map +1 -1
- package/dist/editor/field-types/MultiLineText.js +1 -1
- package/dist/editor/field-types/MultiLineText.js.map +1 -1
- package/dist/editor/field-types/RawEditor.js +1 -1
- package/dist/editor/field-types/ReactQuill.d.ts +125 -0
- package/dist/editor/field-types/ReactQuill.js +385 -0
- package/dist/editor/field-types/ReactQuill.js.map +1 -0
- package/dist/editor/field-types/RichTextEditor.js +5 -13
- package/dist/editor/field-types/RichTextEditor.js.map +1 -1
- package/dist/editor/field-types/RichTextEditorComponent.js +3 -37
- package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
- package/dist/editor/field-types/SingleLineText.js +1 -1
- package/dist/editor/field-types/TreeListEditor.js +2 -3
- package/dist/editor/field-types/TreeListEditor.js.map +1 -1
- package/dist/editor/field-types/richtext/components/ReactSlate.css +5 -23
- package/dist/editor/field-types/richtext/components/ReactSlate.d.ts +0 -2
- package/dist/editor/field-types/richtext/components/ReactSlate.js +4 -28
- package/dist/editor/field-types/richtext/components/ReactSlate.js.map +1 -1
- package/dist/editor/field-types/richtext/components/ToolbarButton.js +2 -4
- package/dist/editor/field-types/richtext/components/ToolbarButton.js.map +1 -1
- package/dist/editor/field-types/richtext/contextMenuFactory.d.ts +0 -13
- package/dist/editor/field-types/richtext/contextMenuFactory.js +24 -181
- 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/field-types/richtext/utils/plugins.js +0 -4
- package/dist/editor/field-types/richtext/utils/plugins.js.map +1 -1
- package/dist/editor/field-types/textContextMenuFactory.js +2 -3
- package/dist/editor/field-types/textContextMenuFactory.js.map +1 -1
- package/dist/editor/media-selector/AiImageSearchPrompt.js +2 -4
- package/dist/editor/media-selector/AiImageSearchPrompt.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -1
- package/dist/editor/media-selector/MediaSelector.js +1 -7
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/TreeSelector.js +35 -40
- package/dist/editor/media-selector/TreeSelector.js.map +1 -1
- package/dist/editor/menubar/ActiveUsers.js +1 -1
- package/dist/editor/menubar/ActiveUsers.js.map +1 -1
- package/dist/editor/menubar/GenericToolbar.js +2 -4
- package/dist/editor/menubar/GenericToolbar.js.map +1 -1
- package/dist/editor/menubar/ItemLanguageVersion.js +2 -2
- package/dist/editor/menubar/ItemLanguageVersion.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +147 -26
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/menubar/Separator.js +1 -1
- package/dist/editor/menubar/VersionSelector.js +4 -2
- package/dist/editor/menubar/VersionSelector.js.map +1 -1
- package/dist/editor/menubar/WorkflowButton.js +12 -39
- package/dist/editor/menubar/WorkflowButton.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/CustomCommandsToolbar.js +38 -16
- package/dist/editor/menubar/toolbar-sections/CustomCommandsToolbar.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/EditControls.js +3 -3
- package/dist/editor/menubar/toolbar-sections/EditControls.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/HelpButton.js +0 -1
- package/dist/editor/menubar/toolbar-sections/HelpButton.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.d.ts +10 -6
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.js +220 -597
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js +2 -13
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js.map +1 -1
- package/dist/editor/page-editor-chrome/CommentHighlighting.js +1 -42
- package/dist/editor/page-editor-chrome/CommentHighlighting.js.map +1 -1
- package/dist/editor/page-editor-chrome/FrameMenu.js +1 -1
- package/dist/editor/page-editor-chrome/FrameMenu.js.map +1 -1
- package/dist/editor/page-editor-chrome/InlineEditor.js +48 -97
- package/dist/editor/page-editor-chrome/InlineEditor.js.map +1 -1
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +17 -38
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.js.map +1 -1
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.js +11 -17
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +301 -301
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/page-viewer/DeviceToolbar.js +1 -1
- package/dist/editor/page-viewer/DeviceToolbar.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +11 -69
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/page-viewer/MiniMap.d.ts +4 -2
- package/dist/editor/page-viewer/MiniMap.js +28 -91
- package/dist/editor/page-viewer/MiniMap.js.map +1 -1
- package/dist/editor/page-viewer/PageViewer.d.ts +1 -3
- package/dist/editor/page-viewer/PageViewer.js +19 -92
- package/dist/editor/page-viewer/PageViewer.js.map +1 -1
- package/dist/editor/page-viewer/PageViewerFrame.d.ts +1 -2
- package/dist/editor/page-viewer/PageViewerFrame.js +115 -348
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.js +49 -114
- package/dist/editor/page-viewer/pageModelSkeletonBuilder.js.map +1 -1
- package/dist/editor/page-viewer/pageViewContext.d.ts +0 -1
- package/dist/editor/page-viewer/pageViewContext.js +14 -51
- package/dist/editor/page-viewer/pageViewContext.js.map +1 -1
- package/dist/editor/pageModel.d.ts +1 -14
- package/dist/editor/reviews/Comment.js +12 -26
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/reviews/CommentDisplayPopover.js +5 -7
- package/dist/editor/reviews/CommentDisplayPopover.js.map +1 -1
- package/dist/editor/reviews/CommentView.js +4 -19
- package/dist/editor/reviews/CommentView.js.map +1 -1
- package/dist/editor/reviews/Comments.js +72 -89
- package/dist/editor/reviews/Comments.js.map +1 -1
- package/dist/editor/reviews/CreateReviewDialog.js +177 -281
- package/dist/editor/reviews/CreateReviewDialog.js.map +1 -1
- package/dist/editor/reviews/DecisionsMatrix.js +25 -96
- package/dist/editor/reviews/DecisionsMatrix.js.map +1 -1
- package/dist/editor/reviews/DiffView.js +14 -7
- package/dist/editor/reviews/DiffView.js.map +1 -1
- package/dist/editor/reviews/EditReviewSettingsDialog.js +4 -6
- package/dist/editor/reviews/EditReviewSettingsDialog.js.map +1 -1
- package/dist/editor/reviews/MultiReviewManager.js +3 -25
- package/dist/editor/reviews/MultiReviewManager.js.map +1 -1
- package/dist/editor/reviews/PagesPanel.js +15 -31
- package/dist/editor/reviews/PagesPanel.js.map +1 -1
- package/dist/editor/reviews/PreviewInfo.js +4 -1
- package/dist/editor/reviews/PreviewInfo.js.map +1 -1
- package/dist/editor/reviews/ReviewCard.js +7 -13
- package/dist/editor/reviews/ReviewCard.js.map +1 -1
- package/dist/editor/reviews/ReviewDetail.js +2 -3
- package/dist/editor/reviews/ReviewDetail.js.map +1 -1
- package/dist/editor/reviews/ReviewsList.js +3 -7
- package/dist/editor/reviews/ReviewsList.js.map +1 -1
- package/dist/editor/reviews/SuggestedEdit.js +3 -34
- package/dist/editor/reviews/SuggestedEdit.js.map +1 -1
- package/dist/editor/reviews/SuggestionDisplayPopover.js +5 -31
- package/dist/editor/reviews/SuggestionDisplayPopover.js.map +1 -1
- package/dist/editor/reviews/commentAi.js +6 -25
- package/dist/editor/reviews/commentAi.js.map +1 -1
- package/dist/editor/reviews/reviewCommands.js +1 -4
- package/dist/editor/reviews/reviewCommands.js.map +1 -1
- package/dist/editor/reviews/useMultiReview.js +2 -2
- package/dist/editor/reviews/useMultiReview.js.map +1 -1
- package/dist/editor/reviews/useReviews.d.ts +2 -2
- package/dist/editor/reviews/useReviews.js +30 -12
- package/dist/editor/reviews/useReviews.js.map +1 -1
- package/dist/editor/services/agentService.d.ts +5 -229
- package/dist/editor/services/agentService.js +39 -292
- package/dist/editor/services/agentService.js.map +1 -1
- package/dist/editor/services/aiService.d.ts +1 -57
- package/dist/editor/services/aiService.js +6 -79
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/services/contentService.d.ts +3 -6
- package/dist/editor/services/contentService.js +12 -13
- package/dist/editor/services/contentService.js.map +1 -1
- package/dist/editor/services/editService.d.ts +1 -52
- package/dist/editor/services/editService.js +2 -94
- package/dist/editor/services/editService.js.map +1 -1
- package/dist/editor/services/indexService.js +1 -1
- package/dist/editor/services/indexService.js.map +1 -1
- package/dist/editor/services/reviewsService.d.ts +6 -3
- package/dist/editor/services/reviewsService.js +11 -2
- package/dist/editor/services/reviewsService.js.map +1 -1
- package/dist/editor/services/serviceHelper.d.ts +1 -2
- package/dist/editor/services/serviceHelper.js +20 -112
- package/dist/editor/services/serviceHelper.js.map +1 -1
- package/dist/editor/services/systemService.d.ts +1 -2
- package/dist/editor/services/systemService.js +0 -3
- package/dist/editor/services/systemService.js.map +1 -1
- package/dist/editor/services-server/api.d.ts +2 -1
- package/dist/editor/services-server/api.js +6 -11
- package/dist/editor/services-server/api.js.map +1 -1
- package/dist/editor/services-server/graphQL.d.ts +29 -0
- package/dist/editor/services-server/graphQL.js +53 -0
- package/dist/editor/services-server/graphQL.js.map +1 -0
- package/dist/editor/settings/About.js +3 -317
- package/dist/editor/settings/About.js.map +1 -1
- package/dist/editor/settings/AllAgentsPanel.d.ts +5 -0
- package/dist/editor/settings/AllAgentsPanel.js +139 -0
- package/dist/editor/settings/AllAgentsPanel.js.map +1 -0
- package/dist/editor/settings/LatestFeedback.d.ts +1 -0
- package/dist/editor/settings/LatestFeedback.js +136 -0
- package/dist/editor/settings/LatestFeedback.js.map +1 -0
- package/dist/editor/settings/QuotaInfo.js +4 -210
- package/dist/editor/settings/QuotaInfo.js.map +1 -1
- package/dist/editor/settings/SettingsView.js +23 -25
- package/dist/editor/settings/SettingsView.js.map +1 -1
- package/dist/editor/settings/Setup.d.ts +1 -0
- package/dist/editor/settings/Setup.js +211 -0
- package/dist/editor/settings/Setup.js.map +1 -0
- package/dist/editor/settings/Status.js +6 -7
- package/dist/editor/settings/Status.js.map +1 -1
- package/dist/editor/settings/index/useIndexStatus.js +22 -20
- package/dist/editor/settings/index/useIndexStatus.js.map +1 -1
- package/dist/editor/settings/panels/AgentsPanel.d.ts +4 -0
- package/dist/editor/settings/panels/AgentsPanel.js +121 -95
- package/dist/editor/settings/panels/AgentsPanel.js.map +1 -1
- package/dist/editor/settings/panels/DatabasePanel.d.ts +6 -0
- package/dist/editor/settings/panels/DatabasePanel.js +50 -0
- package/dist/editor/settings/panels/DatabasePanel.js.map +1 -0
- package/dist/editor/settings/panels/ModelsPanel.js +108 -329
- package/dist/editor/settings/panels/ModelsPanel.js.map +1 -1
- package/dist/editor/settings/panels/ProvidersPanel.d.ts +1 -1
- package/dist/editor/settings/panels/ProvidersPanel.js +59 -86
- package/dist/editor/settings/panels/ProvidersPanel.js.map +1 -1
- package/dist/editor/settings/panels/SearchConfigPanel.js +4 -4
- package/dist/editor/settings/panels/SearchConfigPanel.js.map +1 -1
- package/dist/editor/settings/panels/index.d.ts +2 -3
- package/dist/editor/settings/panels/index.js +2 -3
- package/dist/editor/settings/panels/index.js.map +1 -1
- package/dist/editor/settings/setup-steps/AiSetupStep/EmbeddingsModelSection.d.ts +2 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/EmbeddingsModelSection.js +195 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/EmbeddingsModelSection.js.map +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/index.d.ts +2 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/index.js +21 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/index.js.map +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/provider/ProviderSection.d.ts +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/provider/ProviderSection.js +233 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/provider/ProviderSection.js.map +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/required-containers/RequiredContainersList.d.ts +15 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/required-containers/RequiredContainersList.js +14 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/required-containers/RequiredContainersList.js.map +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/required-containers/RequiredContainersSection.d.ts +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/required-containers/RequiredContainersSection.js +94 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/required-containers/RequiredContainersSection.js.map +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/types.d.ts +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/types.js +2 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/types.js.map +1 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/utils.d.ts +5 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/utils.js +44 -0
- package/dist/editor/settings/setup-steps/AiSetupStep/utils.js.map +1 -0
- package/dist/editor/settings/setup-steps/IndexSetupStep.d.ts +2 -0
- package/dist/editor/settings/setup-steps/IndexSetupStep.js +36 -0
- package/dist/editor/settings/setup-steps/IndexSetupStep.js.map +1 -0
- package/dist/editor/settings/setup-steps/SettingsSetupStep.d.ts +2 -0
- package/dist/editor/settings/setup-steps/SettingsSetupStep.js +111 -0
- package/dist/editor/settings/setup-steps/SettingsSetupStep.js.map +1 -0
- package/dist/editor/settings/setup-steps/SetupOverview.d.ts +14 -0
- package/dist/editor/settings/setup-steps/SetupOverview.js +38 -0
- package/dist/editor/settings/setup-steps/SetupOverview.js.map +1 -0
- package/dist/editor/settings/status/coreStatusChecks.js +19 -124
- package/dist/editor/settings/status/coreStatusChecks.js.map +1 -1
- package/dist/editor/settings/status/useStartupChecks.d.ts +1 -3
- package/dist/editor/settings/status/useStartupChecks.js +5 -9
- package/dist/editor/settings/status/useStartupChecks.js.map +1 -1
- package/dist/editor/setup-wizard/steps/CompleteStep.d.ts +1 -2
- package/dist/editor/setup-wizard/steps/CompleteStep.js +1 -2
- package/dist/editor/setup-wizard/steps/CompleteStep.js.map +1 -1
- package/dist/editor/sidebar/ComponentPalette.js +1 -2
- package/dist/editor/sidebar/ComponentPalette.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.d.ts +1 -8
- package/dist/editor/sidebar/ComponentTree.js +69 -216
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/sidebar/Debug.d.ts +1 -0
- package/dist/editor/sidebar/Debug.js +70 -0
- package/dist/editor/sidebar/Debug.js.map +1 -0
- package/dist/editor/sidebar/EditHistory.js +46 -22
- package/dist/editor/sidebar/EditHistory.js.map +1 -1
- package/dist/editor/sidebar/Favorites.js +8 -4
- package/dist/editor/sidebar/Favorites.js.map +1 -1
- package/dist/editor/sidebar/GraphQL.d.ts +2 -0
- package/dist/editor/sidebar/GraphQL.js +234 -0
- package/dist/editor/sidebar/GraphQL.js.map +1 -0
- package/dist/editor/sidebar/LeftToolbar.d.ts +1 -0
- package/dist/editor/sidebar/LeftToolbar.js +12 -0
- package/dist/editor/sidebar/LeftToolbar.js.map +1 -0
- package/dist/editor/sidebar/MainContentTree.js +3 -4
- package/dist/editor/sidebar/MainContentTree.js.map +1 -1
- package/dist/editor/sidebar/NavigationSidebar.d.ts +4 -0
- package/dist/editor/sidebar/NavigationSidebar.js +254 -0
- package/dist/editor/sidebar/NavigationSidebar.js.map +1 -0
- package/dist/editor/sidebar/OperationItem.js +7 -21
- package/dist/editor/sidebar/OperationItem.js.map +1 -1
- package/dist/editor/sidebar/SidebarPanel.d.ts +1 -3
- package/dist/editor/sidebar/SidebarPanel.js +12 -44
- package/dist/editor/sidebar/SidebarPanel.js.map +1 -1
- package/dist/editor/sidebar/SidebarStack.d.ts +1 -2
- package/dist/editor/sidebar/SidebarStack.js +3 -4
- package/dist/editor/sidebar/SidebarStack.js.map +1 -1
- package/dist/editor/sidebar/Validation.js +12 -22
- package/dist/editor/sidebar/Validation.js.map +1 -1
- package/dist/editor/sidebar/Workbox.js +3 -53
- package/dist/editor/sidebar/Workbox.js.map +1 -1
- package/dist/editor/sidebar/WorkspaceRail.d.ts +1 -0
- package/dist/editor/sidebar/WorkspaceRail.js +167 -56
- package/dist/editor/sidebar/WorkspaceRail.js.map +1 -1
- package/dist/editor/tree-indicators/GutterColumns.d.ts +1 -3
- package/dist/editor/tree-indicators/GutterColumns.js +5 -26
- package/dist/editor/tree-indicators/GutterColumns.js.map +1 -1
- package/dist/editor/tree-indicators/GutterContext.d.ts +0 -4
- package/dist/editor/tree-indicators/GutterContext.js +0 -23
- package/dist/editor/tree-indicators/GutterContext.js.map +1 -1
- package/dist/editor/tree-indicators/GutterSelector.d.ts +5 -0
- package/dist/editor/tree-indicators/GutterSelector.js +91 -0
- package/dist/editor/tree-indicators/GutterSelector.js.map +1 -0
- package/dist/editor/tree-indicators/index.d.ts +1 -0
- package/dist/editor/tree-indicators/index.js +1 -0
- package/dist/editor/tree-indicators/index.js.map +1 -1
- package/dist/editor/tree-indicators/types.d.ts +1 -12
- package/dist/editor/ui/CopyMoveTargetSelectorDialog.js +1 -1
- package/dist/editor/ui/CopyMoveTargetSelectorDialog.js.map +1 -1
- package/dist/editor/ui/Icons.js +1 -1
- package/dist/editor/ui/Icons.js.map +1 -1
- package/dist/editor/ui/ItemNameDialogNew.d.ts +0 -2
- package/dist/editor/ui/ItemNameDialogNew.js +17 -33
- package/dist/editor/ui/ItemNameDialogNew.js.map +1 -1
- package/dist/editor/ui/ItemSearch.js +11 -7
- package/dist/editor/ui/ItemSearch.js.map +1 -1
- package/dist/editor/ui/SimpleIconButton.js +1 -1
- package/dist/editor/ui/SimpleIconButton.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +0 -1
- package/dist/editor/ui/SimpleTabs.js +25 -45
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.d.ts +0 -1
- package/dist/editor/ui/Splitter.js +86 -102
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/ui/TemplateSelectorDialog.js +4 -4
- package/dist/editor/ui/TemplateSelectorDialog.js.map +1 -1
- package/dist/editor/ui/TreeListSelector.d.ts +1 -6
- package/dist/editor/ui/TreeListSelector.js +2 -2
- package/dist/editor/ui/TreeListSelector.js.map +1 -1
- package/dist/editor/utils/keyboardNavigation.d.ts +20 -6
- package/dist/editor/utils/keyboardNavigation.js +140 -48
- package/dist/editor/utils/keyboardNavigation.js.map +1 -1
- package/dist/editor/utils.js +9 -19
- package/dist/editor/utils.js.map +1 -1
- package/dist/editor/views/CompareView.d.ts +1 -3
- package/dist/editor/views/CompareView.js +5 -7
- package/dist/editor/views/CompareView.js.map +1 -1
- package/dist/editor/views/EditView.js +1 -1
- package/dist/editor/views/EditView.js.map +1 -1
- package/dist/editor/views/EditorSlot.js +34 -27
- package/dist/editor/views/EditorSlot.js.map +1 -1
- package/dist/editor/views/ItemEditor.js +3 -7
- package/dist/editor/views/ItemEditor.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.js +1 -1
- package/dist/editor/views/MediaFolderEditView.js.map +1 -1
- package/dist/editor/views/ParheliaView.js +6 -5
- package/dist/editor/views/ParheliaView.js.map +1 -1
- package/dist/editor/views/SingleEditView.d.ts +1 -2
- package/dist/editor/views/SingleEditView.js +8 -10
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/editor/views/editorSlotContext.js +6 -35
- package/dist/editor/views/editorSlotContext.js.map +1 -1
- package/dist/index.d.ts +2 -16
- package/dist/index.js +0 -11
- package/dist/index.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/setup/services/setupWizardService.d.ts +13 -40
- package/dist/setup/services/setupWizardService.js +17 -32
- package/dist/setup/services/setupWizardService.js.map +1 -1
- package/dist/setup/wizard/steps/AddModelDialog.js +3 -12
- package/dist/setup/wizard/steps/AddModelDialog.js.map +1 -1
- package/dist/setup/wizard/steps/ImportModelDialog.js +22 -39
- package/dist/setup/wizard/steps/ImportModelDialog.js.map +1 -1
- package/dist/splash-screen/ModernSplashScreen.js +32 -112
- package/dist/splash-screen/ModernSplashScreen.js.map +1 -1
- package/dist/splash-screen/NewPage.js +50 -33
- package/dist/splash-screen/NewPage.js.map +1 -1
- package/dist/splash-screen/OpenPage.js +6 -2
- package/dist/splash-screen/OpenPage.js.map +1 -1
- package/dist/splash-screen/ParheliaAssistantChat.js +29 -12
- package/dist/splash-screen/ParheliaAssistantChat.js.map +1 -1
- package/dist/splash-screen/ParheliaLogo.js +37 -87
- package/dist/splash-screen/ParheliaLogo.js.map +1 -1
- package/dist/splash-screen/RecentPages.js +3 -3
- package/dist/splash-screen/RecentPages.js.map +1 -1
- package/dist/tour/Tour.d.ts +1 -2
- package/dist/tour/Tour.js +75 -256
- package/dist/tour/Tour.js.map +1 -1
- package/dist/tour/default-tour.js +96 -222
- package/dist/tour/default-tour.js.map +1 -1
- package/dist/types.d.ts +29 -63
- package/package.json +15 -19
- package/styles.css +10 -14
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { useEffect, useCallback, useState, useMemo, useRef, } from "react";
|
|
3
2
|
import { useDebouncedCallback } from "use-debounce";
|
|
4
3
|
import { useEditContext, useFieldsEditContext } from "../client/editContext";
|
|
5
4
|
import { generatePageContext, getCachedContext, } from "../services/contextService";
|
|
6
|
-
import { WandSparkles } from "lucide-react";
|
|
7
|
-
import { createRoot } from "react-dom/client";
|
|
8
|
-
import { LicenseFeatures, useFeature } from "../../licensing";
|
|
9
|
-
function InlineCompletionHint({ hintText, isMobile, onAccept, positionStyle, }) {
|
|
10
|
-
return (_jsxs("div", { className: "shadow-[0_4px_14px_rgba(15,23,42,0.14),0_0_0_1px_rgba(15,23,42,0.06)]pointer-events-auto fixed z-95 inline-flex max-w-none cursor-pointer items-center gap-2 rounded-md border border-slate-400 bg-slate-100 px-2.5 py-2 text-xs leading-snug font-medium whitespace-nowrap text-slate-900", style: positionStyle, onClick: isMobile ? onAccept : undefined, role: isMobile ? "button" : undefined, children: [_jsx(WandSparkles, { className: "size-3.5 shrink-0 text-violet-600", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { children: hintText })] }));
|
|
11
|
-
}
|
|
12
5
|
export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatingRef, }) {
|
|
13
6
|
const editContext = useEditContext();
|
|
14
7
|
const fieldsContext = useFieldsEditContext();
|
|
15
|
-
const canUseAi = useFeature(LicenseFeatures.AI);
|
|
16
8
|
const [currentCompletion, setCurrentCompletion] = useState(null);
|
|
17
|
-
const [, setIsLoading] = useState(false);
|
|
9
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
18
10
|
const abortControllerRef = useRef(null);
|
|
19
11
|
const loadingAnimationRef = useRef(null);
|
|
20
|
-
const applyCompletionRef = useRef(null);
|
|
21
|
-
const hintReactRootRef = useRef(null);
|
|
22
12
|
// Clean up hint element on unmount
|
|
23
13
|
useEffect(() => {
|
|
24
14
|
return () => {
|
|
25
|
-
hintReactRootRef.current?.unmount();
|
|
26
|
-
hintReactRootRef.current = null;
|
|
27
15
|
const hintElement = document.getElementById(`${cursorSpanId}-hint`);
|
|
28
16
|
if (hintElement) {
|
|
29
17
|
hintElement.remove();
|
|
@@ -35,7 +23,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
35
23
|
}, [cursorSpanId]);
|
|
36
24
|
const lastCaretPosRef = useRef(null);
|
|
37
25
|
// Simple function to track caret position without inserting spans
|
|
38
|
-
const positionCursorSpan =
|
|
26
|
+
const positionCursorSpan = () => {
|
|
39
27
|
if (isUpdatingRef.current)
|
|
40
28
|
return;
|
|
41
29
|
isUpdatingRef.current = true;
|
|
@@ -109,14 +97,55 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
109
97
|
isUpdatingRef.current = false;
|
|
110
98
|
}, 10);
|
|
111
99
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
};
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
// Handle keydown events - especially for cursor movement
|
|
103
|
+
const keyHandler = (e) => {
|
|
104
|
+
if (e.key === "ArrowLeft" ||
|
|
105
|
+
e.key === "ArrowRight" ||
|
|
106
|
+
e.key === "ArrowUp" ||
|
|
107
|
+
e.key === "ArrowDown" ||
|
|
108
|
+
e.key === " " ||
|
|
109
|
+
e.key === "Tab" ||
|
|
110
|
+
e.key === "End" ||
|
|
111
|
+
e.key === "Backspace" ||
|
|
112
|
+
e.key === "Delete" // Add Delete key handling
|
|
113
|
+
) {
|
|
114
|
+
// Clear the completion when arrow keys are used
|
|
115
|
+
setCurrentCompletion(null);
|
|
116
|
+
clearCursorSpan();
|
|
117
|
+
// Let the browser handle the cursor movement/deletion
|
|
118
|
+
// Then update our cursor span after a small delay
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
if (!isUpdatingRef.current) {
|
|
121
|
+
positionCursorSpan();
|
|
122
|
+
}
|
|
123
|
+
}, 10);
|
|
124
|
+
// Special handling for right arrow and delete which seems to have issues
|
|
125
|
+
if (e.key === "ArrowRight" || e.key === "Delete") {
|
|
126
|
+
// Make sure the cursor span doesn't block the movement/deletion
|
|
127
|
+
const cursorSpan = pageViewContext.editorIframe?.contentWindow?.document.getElementById(cursorSpanId);
|
|
128
|
+
if (cursorSpan) {
|
|
129
|
+
// Temporarily make it display none so it doesn't interfere with selection
|
|
130
|
+
const originalDisplay = cursorSpan.style.display;
|
|
131
|
+
cursorSpan.style.display = "none";
|
|
132
|
+
// Restore after the browser has processed the movement/deletion
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
if (cursorSpan.parentNode) {
|
|
135
|
+
cursorSpan.style.display = originalDisplay;
|
|
136
|
+
}
|
|
137
|
+
}, 0);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
pageViewContext.editorIframe?.contentWindow?.document.addEventListener("keydown", keyHandler);
|
|
143
|
+
return () => {
|
|
144
|
+
pageViewContext.editorIframe?.contentWindow?.document.removeEventListener("keydown", keyHandler);
|
|
145
|
+
};
|
|
146
|
+
}, [currentCompletion, pageViewContext.page]);
|
|
118
147
|
// Extracts the text up to the cursor position in the editable element
|
|
119
|
-
const getContentUpToCursor =
|
|
148
|
+
const getContentUpToCursor = (element) => {
|
|
120
149
|
const iframeWindow = pageViewContext.editorIframe?.contentWindow;
|
|
121
150
|
const selection = iframeWindow?.getSelection();
|
|
122
151
|
if (!element || !selection || selection.rangeCount === 0)
|
|
@@ -139,17 +168,19 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
139
168
|
contentUpToCursor = tempRange.toString();
|
|
140
169
|
}
|
|
141
170
|
return contentUpToCursor;
|
|
142
|
-
}
|
|
171
|
+
};
|
|
143
172
|
// Loading animation with three dots changing color
|
|
144
|
-
const startLoadingAnimation =
|
|
173
|
+
const startLoadingAnimation = () => {
|
|
145
174
|
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
146
175
|
const span = doc?.getElementById(cursorSpanId);
|
|
147
176
|
if (!doc || !span)
|
|
148
177
|
return;
|
|
178
|
+
// Create dots container
|
|
149
179
|
span.innerHTML = "";
|
|
150
180
|
span.style.display = "inline-flex";
|
|
151
181
|
span.style.gap = "4px";
|
|
152
182
|
span.style.alignItems = "center";
|
|
183
|
+
// Create three dots
|
|
153
184
|
for (let i = 0; i < 3; i++) {
|
|
154
185
|
const dot = doc.createElement("span");
|
|
155
186
|
dot.textContent = "•";
|
|
@@ -158,6 +189,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
158
189
|
dot.style.fontSize = "16px";
|
|
159
190
|
span.appendChild(dot);
|
|
160
191
|
}
|
|
192
|
+
// Animate dots
|
|
161
193
|
let step = 0;
|
|
162
194
|
const animate = () => {
|
|
163
195
|
const dots = span.querySelectorAll("span");
|
|
@@ -171,6 +203,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
171
203
|
});
|
|
172
204
|
step++;
|
|
173
205
|
loadingAnimationRef.current = requestAnimationFrame(() => {
|
|
206
|
+
// Slow down animation by only updating every 15 frames (~250ms at 60fps)
|
|
174
207
|
if (step % 15 === 0) {
|
|
175
208
|
animate();
|
|
176
209
|
}
|
|
@@ -180,27 +213,34 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
180
213
|
});
|
|
181
214
|
};
|
|
182
215
|
animate();
|
|
183
|
-
}
|
|
184
|
-
const stopLoadingAnimation =
|
|
216
|
+
};
|
|
217
|
+
const stopLoadingAnimation = () => {
|
|
185
218
|
if (loadingAnimationRef.current) {
|
|
186
219
|
cancelAnimationFrame(loadingAnimationRef.current);
|
|
187
220
|
loadingAnimationRef.current = null;
|
|
188
221
|
}
|
|
189
|
-
}
|
|
190
|
-
const getCompletion =
|
|
222
|
+
};
|
|
223
|
+
const getCompletion = async (element, isManualTrigger = false) => {
|
|
191
224
|
const contentUpToCursor = getContentUpToCursor(element);
|
|
192
225
|
if (!contentUpToCursor?.trim())
|
|
193
226
|
return null;
|
|
227
|
+
// Abort any in-flight request
|
|
194
228
|
if (abortControllerRef.current) {
|
|
195
229
|
abortControllerRef.current.abort();
|
|
196
230
|
}
|
|
231
|
+
// Create a new abort controller for this request
|
|
197
232
|
abortControllerRef.current = new AbortController();
|
|
233
|
+
const signal = abortControllerRef.current.signal;
|
|
234
|
+
// Get field attributes
|
|
198
235
|
const fieldId = element.getAttribute("data-fieldid");
|
|
236
|
+
const fieldName = element.getAttribute("data-fieldname");
|
|
199
237
|
const itemId = element.getAttribute("data-itemid");
|
|
200
238
|
const language = element.getAttribute("data-language");
|
|
201
239
|
const version = element.getAttribute("data-version");
|
|
202
240
|
if (!fieldId || !itemId || !language || !version)
|
|
203
241
|
return null;
|
|
242
|
+
// Only trigger completion after a space for automatic completions
|
|
243
|
+
// Manual triggers (Ctrl+Space) can work anywhere
|
|
204
244
|
if (!isManualTrigger) {
|
|
205
245
|
const lastChar = contentUpToCursor.slice(-1);
|
|
206
246
|
if (lastChar !== " " && lastChar !== "\u00A0") {
|
|
@@ -209,6 +249,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
209
249
|
}
|
|
210
250
|
if (!editContext)
|
|
211
251
|
return null;
|
|
252
|
+
// Get page context for better completions
|
|
212
253
|
let pageContext = getCachedContext(editContext);
|
|
213
254
|
if (!pageContext) {
|
|
214
255
|
try {
|
|
@@ -216,20 +257,22 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
216
257
|
}
|
|
217
258
|
catch (error) {
|
|
218
259
|
console.warn("Failed to generate page context:", error);
|
|
260
|
+
// Continue without context
|
|
219
261
|
}
|
|
220
262
|
}
|
|
221
263
|
let contextString = "";
|
|
222
264
|
if (pageContext) {
|
|
223
265
|
contextString = `Page Name: ${pageContext.pageTitle} (${pageContext.pageType})\n PageSummary: ${pageContext.abstract}`;
|
|
224
266
|
}
|
|
267
|
+
// Show loading indicator
|
|
225
268
|
setIsLoading(true);
|
|
226
269
|
startLoadingAnimation();
|
|
227
270
|
try {
|
|
228
271
|
const endpoint = `/parhelia/agent/GetTextCompletion`;
|
|
229
272
|
const response = await fetch(endpoint, {
|
|
230
|
-
method:
|
|
273
|
+
method: 'POST',
|
|
231
274
|
headers: {
|
|
232
|
-
|
|
275
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
233
276
|
},
|
|
234
277
|
body: new URLSearchParams({
|
|
235
278
|
textToComplete: contentUpToCursor,
|
|
@@ -240,22 +283,18 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
240
283
|
return data.completion || null;
|
|
241
284
|
}
|
|
242
285
|
catch (error) {
|
|
286
|
+
// Ignore AbortError as it's expected when cancelling
|
|
243
287
|
if (error instanceof Error && error.name !== "AbortError") {
|
|
244
288
|
console.error("Error getting completion:", error);
|
|
245
289
|
}
|
|
246
290
|
return null;
|
|
247
291
|
}
|
|
248
292
|
finally {
|
|
293
|
+
// Hide loading indicator
|
|
249
294
|
setIsLoading(false);
|
|
250
295
|
stopLoadingAnimation();
|
|
251
296
|
}
|
|
252
|
-
}
|
|
253
|
-
getContentUpToCursor,
|
|
254
|
-
editContext,
|
|
255
|
-
pageViewContext,
|
|
256
|
-
startLoadingAnimation,
|
|
257
|
-
stopLoadingAnimation,
|
|
258
|
-
]);
|
|
297
|
+
};
|
|
259
298
|
// Debounced AI call: recompute the sentence, call getCompletion, and extract only the "tail" for the ghost text
|
|
260
299
|
const getCompletionDebounced = useDebouncedCallback(async (isManualTrigger = false) => {
|
|
261
300
|
const el = fieldsContext?.inlineEditingFieldElement;
|
|
@@ -278,17 +317,50 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
278
317
|
setCurrentCompletion(suggestion);
|
|
279
318
|
updateCursorSpan(suggestion.substring(sentence.length));
|
|
280
319
|
}, 250);
|
|
320
|
+
// Manual completion trigger (non-debounced for immediate response)
|
|
321
|
+
const getCompletionManual = async () => {
|
|
322
|
+
const el = fieldsContext?.inlineEditingFieldElement;
|
|
323
|
+
if (!el)
|
|
324
|
+
return;
|
|
325
|
+
// 1) Recompute the exact sentence at this moment
|
|
326
|
+
const full = getContentUpToCursor(el) || "";
|
|
327
|
+
const sentence = full.split(/[.?!]\s*/).pop() || "";
|
|
328
|
+
// 2) Ask AI for a completion
|
|
329
|
+
const rawSuggestion = await getCompletion(el, true);
|
|
330
|
+
if (!rawSuggestion) {
|
|
331
|
+
setCurrentCompletion(null);
|
|
332
|
+
clearCursorSpan();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
// 3) Strip off the already-typed sentence to leave just the "completion tail"
|
|
336
|
+
const suggestion = rawSuggestion.startsWith(sentence)
|
|
337
|
+
? rawSuggestion
|
|
338
|
+
: sentence + rawSuggestion;
|
|
339
|
+
setCurrentCompletion(suggestion);
|
|
340
|
+
updateCursorSpan(suggestion.substring(sentence.length));
|
|
341
|
+
};
|
|
281
342
|
// Inserts or clears the ghost text inside the cursor span
|
|
282
|
-
const updateCursorSpan =
|
|
343
|
+
const updateCursorSpan = (text) => {
|
|
283
344
|
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
284
345
|
const span = doc?.getElementById(cursorSpanId);
|
|
285
346
|
if (!doc || !span)
|
|
286
347
|
return;
|
|
287
348
|
// Update the completion text
|
|
288
349
|
if (text) {
|
|
350
|
+
// // Create a temporary span to measure the text width
|
|
351
|
+
// const measureSpan = doc.createElement("span");
|
|
352
|
+
// measureSpan.style.visibility = "hidden";
|
|
353
|
+
// measureSpan.style.position = "absolute";
|
|
354
|
+
// measureSpan.style.whiteSpace = "pre"; // Preserve whitespace
|
|
355
|
+
// measureSpan.style.font = window.getComputedStyle(span).font; // Match the font
|
|
356
|
+
// measureSpan.textContent = text;
|
|
357
|
+
// doc.body.appendChild(measureSpan);
|
|
358
|
+
// const textWidth = measureSpan.getBoundingClientRect().width;
|
|
359
|
+
// measureSpan.remove();
|
|
289
360
|
span.textContent = text;
|
|
290
361
|
span.style.color = "#888";
|
|
291
362
|
span.style.fontStyle = "italic";
|
|
363
|
+
//span.innerHTML = "hello";
|
|
292
364
|
// Create or update hint element in the main document
|
|
293
365
|
let hintElement = document.getElementById(`${cursorSpanId}-hint`);
|
|
294
366
|
if (!hintElement) {
|
|
@@ -296,274 +368,70 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
296
368
|
hintElement.id = `${cursorSpanId}-hint`;
|
|
297
369
|
document.body.appendChild(hintElement);
|
|
298
370
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
: "
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const spanRect = span.getBoundingClientRect();
|
|
309
|
-
let positionStyle = {
|
|
371
|
+
hintElement.textContent = "Press Tab to accept ⇥";
|
|
372
|
+
// Apply styles that match Tailwind's utility classes
|
|
373
|
+
Object.assign(hintElement.style, {
|
|
374
|
+
position: "fixed",
|
|
375
|
+
fontSize: "12px",
|
|
376
|
+
fontWeight: "normal",
|
|
377
|
+
color: "rgb(75, 85, 99)",
|
|
378
|
+
backgroundColor: "white",
|
|
379
|
+
padding: "0.5rem",
|
|
310
380
|
marginLeft: "0.25rem",
|
|
311
381
|
marginRight: "0.25rem",
|
|
312
|
-
|
|
382
|
+
borderRadius: "0.25rem",
|
|
383
|
+
border: "1px solid rgb(229, 231, 235)",
|
|
384
|
+
fontStyle: "normal",
|
|
385
|
+
display: "block",
|
|
386
|
+
lineHeight: "1.4",
|
|
387
|
+
zIndex: "95",
|
|
388
|
+
pointerEvents: "none",
|
|
389
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
390
|
+
});
|
|
391
|
+
// Position the hint element relative to the iframe and cursor span
|
|
392
|
+
const iframeRect = pageViewContext.editorIframe?.getBoundingClientRect();
|
|
393
|
+
const spanRect = span.getBoundingClientRect();
|
|
313
394
|
if (iframeRect) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
395
|
+
// Create a range for the last character to get proper position
|
|
396
|
+
const textLength = span.textContent?.length || 0;
|
|
397
|
+
if (textLength > 0 && span.firstChild) {
|
|
398
|
+
const range = doc.createRange();
|
|
399
|
+
range.setStart(span.firstChild, Math.max(0, textLength - 1));
|
|
400
|
+
range.setEnd(span.firstChild, textLength);
|
|
401
|
+
const rangeRect = range.getBoundingClientRect();
|
|
402
|
+
// Position at the end of the actual text
|
|
403
|
+
const absoluteLeft = iframeRect.left + rangeRect.right;
|
|
404
|
+
const absoluteTop = iframeRect.top + rangeRect.top;
|
|
405
|
+
hintElement.style.left = `${absoluteLeft}px`;
|
|
406
|
+
hintElement.style.top = `${absoluteTop}px`;
|
|
323
407
|
}
|
|
324
408
|
else {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
range.setStart(span.firstChild, Math.max(0, textLength - 1));
|
|
331
|
-
range.setEnd(span.firstChild, textLength);
|
|
332
|
-
const rangeRect = range.getBoundingClientRect();
|
|
333
|
-
left = iframeRect.left + rangeRect.right;
|
|
334
|
-
top = iframeRect.top + rangeRect.top;
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
left = iframeRect.left + spanRect.right;
|
|
338
|
-
top = iframeRect.top + spanRect.top;
|
|
339
|
-
}
|
|
340
|
-
positionStyle = {
|
|
341
|
-
...positionStyle,
|
|
342
|
-
left,
|
|
343
|
-
top,
|
|
344
|
-
transform: undefined,
|
|
345
|
-
};
|
|
409
|
+
// Fallback to the old positioning if there's no text
|
|
410
|
+
const absoluteLeft = iframeRect.left + spanRect.right;
|
|
411
|
+
const absoluteTop = iframeRect.top + spanRect.top;
|
|
412
|
+
hintElement.style.left = `${absoluteLeft}px`;
|
|
413
|
+
hintElement.style.top = `${absoluteTop}px`;
|
|
346
414
|
}
|
|
347
415
|
}
|
|
348
|
-
hintReactRootRef.current.render(_jsx(InlineCompletionHint, { hintText: hintLabel, isMobile: isMobile, onAccept: () => applyCompletionRef.current?.(), positionStyle: positionStyle }));
|
|
349
416
|
}
|
|
350
417
|
else {
|
|
351
418
|
span.textContent = "";
|
|
352
419
|
// Remove hint element if it exists
|
|
353
420
|
const hintElement = document.getElementById(`${cursorSpanId}-hint`);
|
|
354
421
|
if (hintElement) {
|
|
355
|
-
hintReactRootRef.current?.unmount();
|
|
356
|
-
hintReactRootRef.current = null;
|
|
357
422
|
hintElement.remove();
|
|
358
423
|
}
|
|
359
424
|
}
|
|
360
|
-
}
|
|
361
|
-
const clearCursorSpan =
|
|
425
|
+
};
|
|
426
|
+
const clearCursorSpan = () => {
|
|
362
427
|
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
363
428
|
if (!doc)
|
|
364
429
|
return;
|
|
365
430
|
// Clear the completion text
|
|
366
431
|
updateCursorSpan("");
|
|
367
|
-
}
|
|
368
|
-
// Handle keydown events for cursor movement (arrow keys, etc.)
|
|
369
|
-
useEffect(() => {
|
|
370
|
-
const keyHandler = (e) => {
|
|
371
|
-
if (e.key === "ArrowLeft" ||
|
|
372
|
-
e.key === "ArrowRight" ||
|
|
373
|
-
e.key === "ArrowUp" ||
|
|
374
|
-
e.key === "ArrowDown" ||
|
|
375
|
-
e.key === " " ||
|
|
376
|
-
e.key === "Tab" ||
|
|
377
|
-
e.key === "End" ||
|
|
378
|
-
e.key === "Backspace" ||
|
|
379
|
-
e.key === "Delete") {
|
|
380
|
-
setCurrentCompletion(null);
|
|
381
|
-
clearCursorSpan();
|
|
382
|
-
setTimeout(() => {
|
|
383
|
-
if (!isUpdatingRef.current) {
|
|
384
|
-
positionCursorSpan();
|
|
385
|
-
}
|
|
386
|
-
}, 10);
|
|
387
|
-
if (e.key === "ArrowRight" || e.key === "Delete") {
|
|
388
|
-
const cursorSpan = pageViewContext.editorIframe?.contentWindow?.document.getElementById(cursorSpanId);
|
|
389
|
-
if (cursorSpan) {
|
|
390
|
-
const originalDisplay = cursorSpan.style.display;
|
|
391
|
-
cursorSpan.style.display = "none";
|
|
392
|
-
setTimeout(() => {
|
|
393
|
-
if (cursorSpan.parentNode) {
|
|
394
|
-
cursorSpan.style.display = originalDisplay;
|
|
395
|
-
}
|
|
396
|
-
}, 0);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
402
|
-
if (!doc)
|
|
403
|
-
return;
|
|
404
|
-
doc.addEventListener("keydown", keyHandler);
|
|
405
|
-
return () => doc.removeEventListener("keydown", keyHandler);
|
|
406
|
-
}, [
|
|
407
|
-
clearCursorSpan,
|
|
408
|
-
cursorSpanId,
|
|
409
|
-
isUpdatingRef,
|
|
410
|
-
pageViewContext.editorIframe?.contentWindow?.document,
|
|
411
|
-
pageViewContext.page,
|
|
412
|
-
positionCursorSpan,
|
|
413
|
-
]);
|
|
414
|
-
// Function to apply the completion (must be before handleInput)
|
|
415
|
-
const applyCompletion = useCallback(() => {
|
|
416
|
-
const iframeWindow = pageViewContext.editorIframe?.contentWindow;
|
|
417
|
-
const iframeDocument = iframeWindow?.document;
|
|
418
|
-
if (!iframeWindow ||
|
|
419
|
-
!iframeDocument ||
|
|
420
|
-
!fieldsContext?.inlineEditingFieldElement)
|
|
421
|
-
return;
|
|
422
|
-
const cursorSpan = iframeDocument.getElementById(cursorSpanId);
|
|
423
|
-
if (!cursorSpan)
|
|
424
|
-
return;
|
|
425
|
-
const completionToApply = cursorSpan.textContent || "";
|
|
426
|
-
if (!completionToApply)
|
|
427
|
-
return;
|
|
428
|
-
const element = fieldsContext.inlineEditingFieldElement;
|
|
429
|
-
const fieldId = element.getAttribute("data-fieldid");
|
|
430
|
-
const fieldName = element.getAttribute("data-fieldname");
|
|
431
|
-
const itemId = element.getAttribute("data-itemid");
|
|
432
|
-
const language = element.getAttribute("data-language");
|
|
433
|
-
const versionStr = element.getAttribute("data-version");
|
|
434
|
-
const isRichText = element.getAttribute("data-is-richtext") === "true";
|
|
435
|
-
const version = versionStr ? parseInt(versionStr, 10) : undefined;
|
|
436
|
-
if (!fieldId || !itemId || !language || !version)
|
|
437
|
-
return;
|
|
438
|
-
const selection = iframeWindow.getSelection();
|
|
439
|
-
if (!selection || selection.rangeCount === 0)
|
|
440
|
-
return;
|
|
441
|
-
const range = selection.getRangeAt(0);
|
|
442
|
-
const tempRange = document.createRange();
|
|
443
|
-
tempRange.selectNodeContents(element);
|
|
444
|
-
tempRange.setEnd(range.startContainer, range.startOffset);
|
|
445
|
-
const textUpToCursor = tempRange.toString();
|
|
446
|
-
const wordBoundaryRegex = /[\s.,;:!?"'()[\]{}<>/|=+\-*&^%$#@~`](?=[^\s.,;:!?"'()[\]{}<>/|=+\-*&^%$#@~`]*$)/;
|
|
447
|
-
const match = textUpToCursor.match(wordBoundaryRegex);
|
|
448
|
-
const lastWordBoundaryIndex = match && match.index !== undefined ? match.index + 1 : 0;
|
|
449
|
-
const currentPartialWord = textUpToCursor
|
|
450
|
-
.substring(lastWordBoundaryIndex)
|
|
451
|
-
.trim();
|
|
452
|
-
const isOverlapping = currentPartialWord.length > 0 &&
|
|
453
|
-
completionToApply
|
|
454
|
-
.toLowerCase()
|
|
455
|
-
.startsWith(currentPartialWord.toLowerCase());
|
|
456
|
-
if (isOverlapping) {
|
|
457
|
-
const wordRange = document.createRange();
|
|
458
|
-
const startContainer = range.startContainer;
|
|
459
|
-
const startOffset = range.startOffset - currentPartialWord.length;
|
|
460
|
-
if (startOffset >= 0 && startContainer.nodeType === Node.TEXT_NODE) {
|
|
461
|
-
wordRange.setStart(startContainer, startOffset);
|
|
462
|
-
wordRange.setEnd(range.startContainer, range.startOffset);
|
|
463
|
-
wordRange.deleteContents();
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
if (textUpToCursor.length > 0 && !textUpToCursor.endsWith(" ")) {
|
|
467
|
-
const spaceNode = document.createTextNode(" ");
|
|
468
|
-
range.insertNode(spaceNode);
|
|
469
|
-
range.setStartAfter(spaceNode);
|
|
470
|
-
range.setEndAfter(spaceNode);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
if (textUpToCursor.length > 0 &&
|
|
476
|
-
!textUpToCursor.endsWith(" ") &&
|
|
477
|
-
!textUpToCursor.endsWith("\n") &&
|
|
478
|
-
!/[.!?\-—:;({[\s]$/.test(textUpToCursor)) {
|
|
479
|
-
const spaceNode = document.createTextNode(" ");
|
|
480
|
-
range.insertNode(spaceNode);
|
|
481
|
-
range.setStartAfter(spaceNode);
|
|
482
|
-
range.setEndAfter(spaceNode);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
const textNode = document.createTextNode(completionToApply);
|
|
486
|
-
range.insertNode(textNode);
|
|
487
|
-
range.setStartAfter(textNode);
|
|
488
|
-
range.setEndAfter(textNode);
|
|
489
|
-
selection.removeAllRanges();
|
|
490
|
-
selection.addRange(range);
|
|
491
|
-
setCurrentCompletion(null);
|
|
492
|
-
clearCursorSpan();
|
|
493
|
-
setTimeout(() => {
|
|
494
|
-
let valueToSave;
|
|
495
|
-
if (isRichText) {
|
|
496
|
-
const clone = element.cloneNode(true);
|
|
497
|
-
const cursorElem = clone.querySelector(`#${cursorSpanId}`);
|
|
498
|
-
if (cursorElem)
|
|
499
|
-
cursorElem.parentNode?.removeChild(cursorElem);
|
|
500
|
-
const ownerDoc = clone.ownerDocument || document;
|
|
501
|
-
const walker = ownerDoc.createTreeWalker(clone, NodeFilter.SHOW_TEXT);
|
|
502
|
-
const toClean = [];
|
|
503
|
-
while (walker.nextNode()) {
|
|
504
|
-
const tn = walker.currentNode;
|
|
505
|
-
if (tn.nodeValue && tn.nodeValue.includes("\u200B"))
|
|
506
|
-
toClean.push(tn);
|
|
507
|
-
}
|
|
508
|
-
toClean.forEach((tn) => (tn.nodeValue = tn.nodeValue?.replaceAll("\u200B", "") || ""));
|
|
509
|
-
valueToSave = clone.innerHTML;
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
valueToSave = (element.innerText || "").replaceAll("\u200B", "");
|
|
513
|
-
}
|
|
514
|
-
editContext?.operations.editField({
|
|
515
|
-
field: {
|
|
516
|
-
fieldId,
|
|
517
|
-
fieldName: fieldName ?? undefined,
|
|
518
|
-
item: { id: itemId, language, version },
|
|
519
|
-
},
|
|
520
|
-
refresh: "none",
|
|
521
|
-
value: valueToSave,
|
|
522
|
-
});
|
|
523
|
-
}, 0);
|
|
524
|
-
}, [
|
|
525
|
-
pageViewContext.editorIframe?.contentWindow,
|
|
526
|
-
fieldsContext?.inlineEditingFieldElement,
|
|
527
|
-
cursorSpanId,
|
|
528
|
-
clearCursorSpan,
|
|
529
|
-
editContext?.operations,
|
|
530
|
-
]);
|
|
531
|
-
applyCompletionRef.current = applyCompletion;
|
|
532
|
-
// Manual completion trigger (non-debounced)
|
|
533
|
-
const getCompletionManual = useCallback(async () => {
|
|
534
|
-
if (!canUseAi)
|
|
535
|
-
return;
|
|
536
|
-
const el = fieldsContext?.inlineEditingFieldElement;
|
|
537
|
-
if (!el)
|
|
538
|
-
return;
|
|
539
|
-
const full = getContentUpToCursor(el) || "";
|
|
540
|
-
const sentence = full.split(/[.?!]\s*/).pop() || "";
|
|
541
|
-
const rawSuggestion = await getCompletion(el, true);
|
|
542
|
-
if (!rawSuggestion) {
|
|
543
|
-
setCurrentCompletion(null);
|
|
544
|
-
clearCursorSpan();
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
const suggestion = rawSuggestion.startsWith(sentence)
|
|
548
|
-
? rawSuggestion
|
|
549
|
-
: sentence + rawSuggestion;
|
|
550
|
-
setCurrentCompletion(suggestion);
|
|
551
|
-
updateCursorSpan(suggestion.substring(sentence.length));
|
|
552
|
-
}, [
|
|
553
|
-
fieldsContext?.inlineEditingFieldElement,
|
|
554
|
-
canUseAi,
|
|
555
|
-
getContentUpToCursor,
|
|
556
|
-
getCompletion,
|
|
557
|
-
clearCursorSpan,
|
|
558
|
-
updateCursorSpan,
|
|
559
|
-
]);
|
|
432
|
+
};
|
|
560
433
|
// On every input: either reuse the existing suggestion or fire a new one
|
|
561
434
|
const handleInput = useCallback((e) => {
|
|
562
|
-
if (!canUseAi) {
|
|
563
|
-
setCurrentCompletion(null);
|
|
564
|
-
clearCursorSpan();
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
435
|
const el = fieldsContext?.inlineEditingFieldElement;
|
|
568
436
|
if (!el)
|
|
569
437
|
return;
|
|
@@ -650,20 +518,13 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
650
518
|
}
|
|
651
519
|
}, [
|
|
652
520
|
fieldsContext?.inlineEditingFieldElement,
|
|
653
|
-
getContentUpToCursor,
|
|
654
521
|
currentCompletion,
|
|
655
|
-
canUseAi,
|
|
656
|
-
clearCursorSpan,
|
|
657
|
-
getCompletionManual,
|
|
658
|
-
pageViewContext.editorIframe?.contentWindow,
|
|
659
|
-
cursorSpanId,
|
|
660
|
-
applyCompletion,
|
|
661
|
-
updateCursorSpan,
|
|
662
522
|
getCompletionDebounced,
|
|
523
|
+
getCompletionManual,
|
|
663
524
|
]);
|
|
664
525
|
// Wire up the input listener
|
|
665
526
|
useEffect(() => {
|
|
666
|
-
if (!
|
|
527
|
+
if (!editContext?.enableCompletions)
|
|
667
528
|
return;
|
|
668
529
|
const el = fieldsContext?.inlineEditingFieldElement;
|
|
669
530
|
if (!el)
|
|
@@ -673,12 +534,11 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
673
534
|
}, [
|
|
674
535
|
fieldsContext?.inlineEditingFieldElement,
|
|
675
536
|
handleInput,
|
|
676
|
-
canUseAi,
|
|
677
537
|
editContext?.enableCompletions,
|
|
678
538
|
]);
|
|
679
539
|
// Add mouse click handler to update cursor span position
|
|
680
540
|
useEffect(() => {
|
|
681
|
-
if (!
|
|
541
|
+
if (!editContext?.enableCompletions)
|
|
682
542
|
return;
|
|
683
543
|
const el = fieldsContext?.inlineEditingFieldElement;
|
|
684
544
|
if (!el)
|
|
@@ -697,11 +557,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
697
557
|
return () => el.removeEventListener("mouseup", handleMouseUp);
|
|
698
558
|
}, [
|
|
699
559
|
fieldsContext?.inlineEditingFieldElement,
|
|
700
|
-
canUseAi,
|
|
701
560
|
editContext?.enableCompletions,
|
|
702
|
-
isUpdatingRef,
|
|
703
|
-
positionCursorSpan,
|
|
704
|
-
clearCursorSpan,
|
|
705
561
|
]);
|
|
706
562
|
// Clean up abort controller on unmount
|
|
707
563
|
useEffect(() => {
|
|
@@ -716,13 +572,157 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
716
572
|
}
|
|
717
573
|
};
|
|
718
574
|
}, []);
|
|
575
|
+
// Function to apply the completion
|
|
576
|
+
const applyCompletion = () => {
|
|
577
|
+
// Get the cursor span to read the most up-to-date completion
|
|
578
|
+
const iframeWindow = pageViewContext.editorIframe?.contentWindow;
|
|
579
|
+
const iframeDocument = iframeWindow?.document;
|
|
580
|
+
if (!iframeWindow ||
|
|
581
|
+
!iframeDocument ||
|
|
582
|
+
!fieldsContext?.inlineEditingFieldElement)
|
|
583
|
+
return;
|
|
584
|
+
const cursorSpan = iframeDocument.getElementById(cursorSpanId);
|
|
585
|
+
if (!cursorSpan)
|
|
586
|
+
return;
|
|
587
|
+
// Get the completion text directly from the cursor span, which should be the most current
|
|
588
|
+
const completionToApply = cursorSpan.textContent || "";
|
|
589
|
+
if (!completionToApply)
|
|
590
|
+
return;
|
|
591
|
+
const element = fieldsContext?.inlineEditingFieldElement;
|
|
592
|
+
// Get field attributes for saving
|
|
593
|
+
const fieldId = element.getAttribute("data-fieldid");
|
|
594
|
+
const fieldName = element.getAttribute("data-fieldname");
|
|
595
|
+
const itemId = element.getAttribute("data-itemid");
|
|
596
|
+
const language = element.getAttribute("data-language");
|
|
597
|
+
const versionStr = element.getAttribute("data-version");
|
|
598
|
+
const isRichText = element.getAttribute("data-is-richtext") === "true";
|
|
599
|
+
const version = versionStr ? parseInt(versionStr, 10) : undefined;
|
|
600
|
+
if (!fieldId || !itemId || !language || !version)
|
|
601
|
+
return;
|
|
602
|
+
// Get the current selection position
|
|
603
|
+
const selection = iframeWindow.getSelection();
|
|
604
|
+
if (!selection || selection.rangeCount === 0)
|
|
605
|
+
return;
|
|
606
|
+
// Get the text up to the cursor to analyze current word
|
|
607
|
+
const range = selection.getRangeAt(0);
|
|
608
|
+
const tempRange = document.createRange();
|
|
609
|
+
tempRange.selectNodeContents(element);
|
|
610
|
+
tempRange.setEnd(range.startContainer, range.startOffset);
|
|
611
|
+
const textUpToCursor = tempRange.toString();
|
|
612
|
+
// Get the current partial word by finding text from the last word boundary to cursor
|
|
613
|
+
// Look for last word boundary (space, punctuation, etc.)
|
|
614
|
+
const wordBoundaryRegex = /[\s.,;:!?"'()[\]{}<>\/\\|=+\-*&^%$#@~`](?=[^\s.,;:!?"'()[\]{}<>\/\\|=+\-*&^%$#@~`]*$)/;
|
|
615
|
+
const match = textUpToCursor.match(wordBoundaryRegex);
|
|
616
|
+
const lastWordBoundaryIndex = match && match.index !== undefined ? match.index + 1 : 0;
|
|
617
|
+
const currentPartialWord = textUpToCursor
|
|
618
|
+
.substring(lastWordBoundaryIndex)
|
|
619
|
+
.trim();
|
|
620
|
+
// Check if completion overlaps with current partial word
|
|
621
|
+
// (e.g., if user typed "int" and completion is "integer")
|
|
622
|
+
const isOverlapping = currentPartialWord.length > 0 &&
|
|
623
|
+
completionToApply
|
|
624
|
+
.toLowerCase()
|
|
625
|
+
.startsWith(currentPartialWord.toLowerCase());
|
|
626
|
+
console.log("Is overlapping:", isOverlapping);
|
|
627
|
+
// If there's overlap, we need to delete the current partial word
|
|
628
|
+
if (isOverlapping) {
|
|
629
|
+
// Create a range to select the current partial word
|
|
630
|
+
const wordRange = document.createRange();
|
|
631
|
+
// Position where the current word starts
|
|
632
|
+
let startContainer = range.startContainer;
|
|
633
|
+
let startOffset = range.startOffset - currentPartialWord.length;
|
|
634
|
+
// We need to handle the case where the word spans multiple text nodes
|
|
635
|
+
// For simplicity, we'll try to handle the common case first
|
|
636
|
+
if (startOffset >= 0 && startContainer.nodeType === Node.TEXT_NODE) {
|
|
637
|
+
// Simple case: word is in the same text node as cursor
|
|
638
|
+
wordRange.setStart(startContainer, startOffset);
|
|
639
|
+
wordRange.setEnd(range.startContainer, range.startOffset);
|
|
640
|
+
wordRange.deleteContents(); // Delete the partial word
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
// Complex case: use a simpler approach - just insert, user can delete manually if needed
|
|
644
|
+
// This is a fallback for complex DOM structures
|
|
645
|
+
// Add a space if we're in the middle of a sentence
|
|
646
|
+
if (textUpToCursor.length > 0 && !textUpToCursor.endsWith(" ")) {
|
|
647
|
+
const spaceNode = document.createTextNode(" ");
|
|
648
|
+
range.insertNode(spaceNode);
|
|
649
|
+
range.setStartAfter(spaceNode);
|
|
650
|
+
range.setEndAfter(spaceNode);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
// Not overlapping, add a space if we're in the middle of text
|
|
656
|
+
// and not already at the beginning of text or after a space
|
|
657
|
+
if (textUpToCursor.length > 0 &&
|
|
658
|
+
!textUpToCursor.endsWith(" ") &&
|
|
659
|
+
// Don't add space at the start of a line or after punctuation that shouldn't have a space
|
|
660
|
+
!textUpToCursor.endsWith("\n") &&
|
|
661
|
+
!/[.!?\-—:;({[\s]$/.test(textUpToCursor)) {
|
|
662
|
+
const spaceNode = document.createTextNode(" ");
|
|
663
|
+
range.insertNode(spaceNode);
|
|
664
|
+
range.setStartAfter(spaceNode);
|
|
665
|
+
range.setEndAfter(spaceNode);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
// Now insert the completion text
|
|
669
|
+
const textNode = document.createTextNode(isOverlapping
|
|
670
|
+
? completionToApply // If overlapping, use the full completion
|
|
671
|
+
: completionToApply);
|
|
672
|
+
range.insertNode(textNode);
|
|
673
|
+
// Move the cursor after the inserted text
|
|
674
|
+
range.setStartAfter(textNode);
|
|
675
|
+
range.setEndAfter(textNode);
|
|
676
|
+
selection.removeAllRanges();
|
|
677
|
+
selection.addRange(range);
|
|
678
|
+
setCurrentCompletion(null);
|
|
679
|
+
clearCursorSpan();
|
|
680
|
+
// Explicitly save the field value since the MutationObserver may miss this change
|
|
681
|
+
// when isUpdatingRef is true during cursor positioning
|
|
682
|
+
setTimeout(() => {
|
|
683
|
+
// Get the final value from the element (excluding cursor span content)
|
|
684
|
+
let valueToSave;
|
|
685
|
+
if (isRichText) {
|
|
686
|
+
const clone = element.cloneNode(true);
|
|
687
|
+
const cursorElem = clone.querySelector(`#${cursorSpanId}`);
|
|
688
|
+
if (cursorElem)
|
|
689
|
+
cursorElem.parentNode?.removeChild(cursorElem);
|
|
690
|
+
// Clean up zero-width spaces
|
|
691
|
+
const ownerDoc = clone.ownerDocument || document;
|
|
692
|
+
const walker = ownerDoc.createTreeWalker(clone, NodeFilter.SHOW_TEXT);
|
|
693
|
+
const toClean = [];
|
|
694
|
+
while (walker.nextNode()) {
|
|
695
|
+
const tn = walker.currentNode;
|
|
696
|
+
if (tn.nodeValue && tn.nodeValue.includes("\u200B"))
|
|
697
|
+
toClean.push(tn);
|
|
698
|
+
}
|
|
699
|
+
toClean.forEach((tn) => (tn.nodeValue = tn.nodeValue?.replaceAll("\u200B", "") || ""));
|
|
700
|
+
valueToSave = clone.innerHTML;
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
valueToSave = (element.innerText || "").replaceAll("\u200B", "");
|
|
704
|
+
}
|
|
705
|
+
// Call editField to save the value
|
|
706
|
+
editContext?.operations.editField({
|
|
707
|
+
field: {
|
|
708
|
+
fieldId,
|
|
709
|
+
fieldName: fieldName ?? undefined,
|
|
710
|
+
item: {
|
|
711
|
+
id: itemId,
|
|
712
|
+
language,
|
|
713
|
+
version,
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
refresh: "none",
|
|
717
|
+
value: valueToSave,
|
|
718
|
+
});
|
|
719
|
+
}, 0);
|
|
720
|
+
};
|
|
719
721
|
// Exposed manual trigger (if needed)
|
|
720
722
|
return useMemo(() => () => {
|
|
721
723
|
setCurrentCompletion(null);
|
|
722
724
|
clearCursorSpan();
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
}, [canUseAi, clearCursorSpan, getCompletionManual]);
|
|
725
|
+
getCompletionManual();
|
|
726
|
+
}, [getCompletionManual]);
|
|
727
727
|
}
|
|
728
728
|
//# sourceMappingURL=useInlineAICompletion.js.map
|