@parhelia/core 0.1.12534 → 0.1.12555
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 +97 -186
- 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 -2
- package/dist/config/config.js +70 -215
- package/dist/config/config.js.map +1 -1
- package/dist/config/types/workspace.d.ts +0 -6
- package/dist/config/types.d.ts +12 -58
- 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 +18 -72
- 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/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 +5 -4
- 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 +13 -12
- 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 +482 -2350
- 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 +101 -91
- 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 +0 -1
- package/dist/editor/ai/useAgentStatus.js +96 -79
- 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.js +212 -581
- package/dist/editor/client/EditorShell.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +19 -28
- 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/navigation.d.ts +21 -0
- package/dist/editor/client/navigation.js +98 -0
- package/dist/editor/client/navigation.js.map +1 -0
- 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/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/handlers/uiActionHandlers.js +3 -4
- package/dist/editor/commands/handlers/uiActionHandlers.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 +2 -4
- 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 +22 -177
- 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/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 +36 -7
- 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 +219 -500
- package/dist/editor/menubar/toolbar-sections/ManualBrowser.js.map +1 -1
- package/dist/editor/menubar/toolbar-sections/UtilityControls.js +1 -10
- 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 +298 -283
- package/dist/editor/page-editor-chrome/useInlineAICompletion.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 +109 -292
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/page-viewer/RenderingParametersSection.js +3 -2
- package/dist/editor/page-viewer/RenderingParametersSection.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 +11 -23
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/reviews/CommentDisplayPopover.js +4 -4
- 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 -21
- 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 -50
- package/dist/editor/services/editService.js +2 -91
- 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/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 +21 -23
- 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 +4 -5
- 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/ProjectTemplatesPanel.js +1 -1
- package/dist/editor/settings/panels/ProjectTemplatesPanel.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 -7
- 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/NavigationPanelItem.js +1 -1
- package/dist/editor/sidebar/NavigationPanelItem.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 +6 -20
- package/dist/editor/sidebar/OperationItem.js.map +1 -1
- package/dist/editor/sidebar/SidebarPanel.js +7 -30
- package/dist/editor/sidebar/SidebarPanel.js.map +1 -1
- package/dist/editor/sidebar/SidebarStack.js +0 -1
- 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/template-wizard/TemplateStructureInlineEditor.js +10 -3
- package/dist/editor/template-wizard/TemplateStructureInlineEditor.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 +139 -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 +4 -6
- 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 -14
- package/dist/index.js +0 -10
- package/dist/index.js.map +1 -1
- package/dist/licensing/LicenseContext.d.ts +3 -1
- package/dist/licensing/LicenseContext.js +55 -38
- package/dist/licensing/LicenseContext.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 -110
- 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/task-board/TaskBoardWorkspace.js +34 -6
- package/dist/task-board/TaskBoardWorkspace.js.map +1 -1
- package/dist/task-board/components/AssignAgentDialog.js +13 -1
- package/dist/task-board/components/AssignAgentDialog.js.map +1 -1
- package/dist/task-board/components/TaskAgentPanel.js +11 -1
- package/dist/task-board/components/TaskAgentPanel.js.map +1 -1
- package/dist/task-board/components/TaskAssigneePicker.js +14 -4
- package/dist/task-board/components/TaskAssigneePicker.js.map +1 -1
- package/dist/task-board/components/WizardCommunicationCenter.js +18 -9
- package/dist/task-board/components/WizardCommunicationCenter.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 +13 -17
- package/styles.css +10 -14
|
@@ -1,27 +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
|
-
function InlineCompletionHint({ hintText, isMobile, onAccept, positionStyle, }) {
|
|
9
|
-
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 })] }));
|
|
10
|
-
}
|
|
11
5
|
export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatingRef, }) {
|
|
12
6
|
const editContext = useEditContext();
|
|
13
7
|
const fieldsContext = useFieldsEditContext();
|
|
14
8
|
const [currentCompletion, setCurrentCompletion] = useState(null);
|
|
15
|
-
const [, setIsLoading] = useState(false);
|
|
9
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
16
10
|
const abortControllerRef = useRef(null);
|
|
17
11
|
const loadingAnimationRef = useRef(null);
|
|
18
|
-
const applyCompletionRef = useRef(null);
|
|
19
|
-
const hintReactRootRef = useRef(null);
|
|
20
12
|
// Clean up hint element on unmount
|
|
21
13
|
useEffect(() => {
|
|
22
14
|
return () => {
|
|
23
|
-
hintReactRootRef.current?.unmount();
|
|
24
|
-
hintReactRootRef.current = null;
|
|
25
15
|
const hintElement = document.getElementById(`${cursorSpanId}-hint`);
|
|
26
16
|
if (hintElement) {
|
|
27
17
|
hintElement.remove();
|
|
@@ -33,7 +23,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
33
23
|
}, [cursorSpanId]);
|
|
34
24
|
const lastCaretPosRef = useRef(null);
|
|
35
25
|
// Simple function to track caret position without inserting spans
|
|
36
|
-
const positionCursorSpan =
|
|
26
|
+
const positionCursorSpan = () => {
|
|
37
27
|
if (isUpdatingRef.current)
|
|
38
28
|
return;
|
|
39
29
|
isUpdatingRef.current = true;
|
|
@@ -107,14 +97,55 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
107
97
|
isUpdatingRef.current = false;
|
|
108
98
|
}, 10);
|
|
109
99
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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]);
|
|
116
147
|
// Extracts the text up to the cursor position in the editable element
|
|
117
|
-
const getContentUpToCursor =
|
|
148
|
+
const getContentUpToCursor = (element) => {
|
|
118
149
|
const iframeWindow = pageViewContext.editorIframe?.contentWindow;
|
|
119
150
|
const selection = iframeWindow?.getSelection();
|
|
120
151
|
if (!element || !selection || selection.rangeCount === 0)
|
|
@@ -137,17 +168,19 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
137
168
|
contentUpToCursor = tempRange.toString();
|
|
138
169
|
}
|
|
139
170
|
return contentUpToCursor;
|
|
140
|
-
}
|
|
171
|
+
};
|
|
141
172
|
// Loading animation with three dots changing color
|
|
142
|
-
const startLoadingAnimation =
|
|
173
|
+
const startLoadingAnimation = () => {
|
|
143
174
|
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
144
175
|
const span = doc?.getElementById(cursorSpanId);
|
|
145
176
|
if (!doc || !span)
|
|
146
177
|
return;
|
|
178
|
+
// Create dots container
|
|
147
179
|
span.innerHTML = "";
|
|
148
180
|
span.style.display = "inline-flex";
|
|
149
181
|
span.style.gap = "4px";
|
|
150
182
|
span.style.alignItems = "center";
|
|
183
|
+
// Create three dots
|
|
151
184
|
for (let i = 0; i < 3; i++) {
|
|
152
185
|
const dot = doc.createElement("span");
|
|
153
186
|
dot.textContent = "•";
|
|
@@ -156,6 +189,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
156
189
|
dot.style.fontSize = "16px";
|
|
157
190
|
span.appendChild(dot);
|
|
158
191
|
}
|
|
192
|
+
// Animate dots
|
|
159
193
|
let step = 0;
|
|
160
194
|
const animate = () => {
|
|
161
195
|
const dots = span.querySelectorAll("span");
|
|
@@ -169,6 +203,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
169
203
|
});
|
|
170
204
|
step++;
|
|
171
205
|
loadingAnimationRef.current = requestAnimationFrame(() => {
|
|
206
|
+
// Slow down animation by only updating every 15 frames (~250ms at 60fps)
|
|
172
207
|
if (step % 15 === 0) {
|
|
173
208
|
animate();
|
|
174
209
|
}
|
|
@@ -178,27 +213,34 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
178
213
|
});
|
|
179
214
|
};
|
|
180
215
|
animate();
|
|
181
|
-
}
|
|
182
|
-
const stopLoadingAnimation =
|
|
216
|
+
};
|
|
217
|
+
const stopLoadingAnimation = () => {
|
|
183
218
|
if (loadingAnimationRef.current) {
|
|
184
219
|
cancelAnimationFrame(loadingAnimationRef.current);
|
|
185
220
|
loadingAnimationRef.current = null;
|
|
186
221
|
}
|
|
187
|
-
}
|
|
188
|
-
const getCompletion =
|
|
222
|
+
};
|
|
223
|
+
const getCompletion = async (element, isManualTrigger = false) => {
|
|
189
224
|
const contentUpToCursor = getContentUpToCursor(element);
|
|
190
225
|
if (!contentUpToCursor?.trim())
|
|
191
226
|
return null;
|
|
227
|
+
// Abort any in-flight request
|
|
192
228
|
if (abortControllerRef.current) {
|
|
193
229
|
abortControllerRef.current.abort();
|
|
194
230
|
}
|
|
231
|
+
// Create a new abort controller for this request
|
|
195
232
|
abortControllerRef.current = new AbortController();
|
|
233
|
+
const signal = abortControllerRef.current.signal;
|
|
234
|
+
// Get field attributes
|
|
196
235
|
const fieldId = element.getAttribute("data-fieldid");
|
|
236
|
+
const fieldName = element.getAttribute("data-fieldname");
|
|
197
237
|
const itemId = element.getAttribute("data-itemid");
|
|
198
238
|
const language = element.getAttribute("data-language");
|
|
199
239
|
const version = element.getAttribute("data-version");
|
|
200
240
|
if (!fieldId || !itemId || !language || !version)
|
|
201
241
|
return null;
|
|
242
|
+
// Only trigger completion after a space for automatic completions
|
|
243
|
+
// Manual triggers (Ctrl+Space) can work anywhere
|
|
202
244
|
if (!isManualTrigger) {
|
|
203
245
|
const lastChar = contentUpToCursor.slice(-1);
|
|
204
246
|
if (lastChar !== " " && lastChar !== "\u00A0") {
|
|
@@ -207,6 +249,7 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
207
249
|
}
|
|
208
250
|
if (!editContext)
|
|
209
251
|
return null;
|
|
252
|
+
// Get page context for better completions
|
|
210
253
|
let pageContext = getCachedContext(editContext);
|
|
211
254
|
if (!pageContext) {
|
|
212
255
|
try {
|
|
@@ -214,20 +257,22 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
214
257
|
}
|
|
215
258
|
catch (error) {
|
|
216
259
|
console.warn("Failed to generate page context:", error);
|
|
260
|
+
// Continue without context
|
|
217
261
|
}
|
|
218
262
|
}
|
|
219
263
|
let contextString = "";
|
|
220
264
|
if (pageContext) {
|
|
221
265
|
contextString = `Page Name: ${pageContext.pageTitle} (${pageContext.pageType})\n PageSummary: ${pageContext.abstract}`;
|
|
222
266
|
}
|
|
267
|
+
// Show loading indicator
|
|
223
268
|
setIsLoading(true);
|
|
224
269
|
startLoadingAnimation();
|
|
225
270
|
try {
|
|
226
271
|
const endpoint = `/parhelia/agent/GetTextCompletion`;
|
|
227
272
|
const response = await fetch(endpoint, {
|
|
228
|
-
method:
|
|
273
|
+
method: 'POST',
|
|
229
274
|
headers: {
|
|
230
|
-
|
|
275
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
231
276
|
},
|
|
232
277
|
body: new URLSearchParams({
|
|
233
278
|
textToComplete: contentUpToCursor,
|
|
@@ -238,22 +283,18 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
238
283
|
return data.completion || null;
|
|
239
284
|
}
|
|
240
285
|
catch (error) {
|
|
286
|
+
// Ignore AbortError as it's expected when cancelling
|
|
241
287
|
if (error instanceof Error && error.name !== "AbortError") {
|
|
242
288
|
console.error("Error getting completion:", error);
|
|
243
289
|
}
|
|
244
290
|
return null;
|
|
245
291
|
}
|
|
246
292
|
finally {
|
|
293
|
+
// Hide loading indicator
|
|
247
294
|
setIsLoading(false);
|
|
248
295
|
stopLoadingAnimation();
|
|
249
296
|
}
|
|
250
|
-
}
|
|
251
|
-
getContentUpToCursor,
|
|
252
|
-
editContext,
|
|
253
|
-
pageViewContext,
|
|
254
|
-
startLoadingAnimation,
|
|
255
|
-
stopLoadingAnimation,
|
|
256
|
-
]);
|
|
297
|
+
};
|
|
257
298
|
// Debounced AI call: recompute the sentence, call getCompletion, and extract only the "tail" for the ghost text
|
|
258
299
|
const getCompletionDebounced = useDebouncedCallback(async (isManualTrigger = false) => {
|
|
259
300
|
const el = fieldsContext?.inlineEditingFieldElement;
|
|
@@ -276,17 +317,50 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
276
317
|
setCurrentCompletion(suggestion);
|
|
277
318
|
updateCursorSpan(suggestion.substring(sentence.length));
|
|
278
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
|
+
};
|
|
279
342
|
// Inserts or clears the ghost text inside the cursor span
|
|
280
|
-
const updateCursorSpan =
|
|
343
|
+
const updateCursorSpan = (text) => {
|
|
281
344
|
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
282
345
|
const span = doc?.getElementById(cursorSpanId);
|
|
283
346
|
if (!doc || !span)
|
|
284
347
|
return;
|
|
285
348
|
// Update the completion text
|
|
286
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();
|
|
287
360
|
span.textContent = text;
|
|
288
361
|
span.style.color = "#888";
|
|
289
362
|
span.style.fontStyle = "italic";
|
|
363
|
+
//span.innerHTML = "hello";
|
|
290
364
|
// Create or update hint element in the main document
|
|
291
365
|
let hintElement = document.getElementById(`${cursorSpanId}-hint`);
|
|
292
366
|
if (!hintElement) {
|
|
@@ -294,264 +368,68 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
294
368
|
hintElement.id = `${cursorSpanId}-hint`;
|
|
295
369
|
document.body.appendChild(hintElement);
|
|
296
370
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
: "
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const spanRect = span.getBoundingClientRect();
|
|
307
|
-
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",
|
|
308
380
|
marginLeft: "0.25rem",
|
|
309
381
|
marginRight: "0.25rem",
|
|
310
|
-
|
|
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();
|
|
311
394
|
if (iframeRect) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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`;
|
|
321
407
|
}
|
|
322
408
|
else {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
range.setStart(span.firstChild, Math.max(0, textLength - 1));
|
|
329
|
-
range.setEnd(span.firstChild, textLength);
|
|
330
|
-
const rangeRect = range.getBoundingClientRect();
|
|
331
|
-
left = iframeRect.left + rangeRect.right;
|
|
332
|
-
top = iframeRect.top + rangeRect.top;
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
left = iframeRect.left + spanRect.right;
|
|
336
|
-
top = iframeRect.top + spanRect.top;
|
|
337
|
-
}
|
|
338
|
-
positionStyle = {
|
|
339
|
-
...positionStyle,
|
|
340
|
-
left,
|
|
341
|
-
top,
|
|
342
|
-
transform: undefined,
|
|
343
|
-
};
|
|
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`;
|
|
344
414
|
}
|
|
345
415
|
}
|
|
346
|
-
hintReactRootRef.current.render(_jsx(InlineCompletionHint, { hintText: hintLabel, isMobile: isMobile, onAccept: () => applyCompletionRef.current?.(), positionStyle: positionStyle }));
|
|
347
416
|
}
|
|
348
417
|
else {
|
|
349
418
|
span.textContent = "";
|
|
350
419
|
// Remove hint element if it exists
|
|
351
420
|
const hintElement = document.getElementById(`${cursorSpanId}-hint`);
|
|
352
421
|
if (hintElement) {
|
|
353
|
-
hintReactRootRef.current?.unmount();
|
|
354
|
-
hintReactRootRef.current = null;
|
|
355
422
|
hintElement.remove();
|
|
356
423
|
}
|
|
357
424
|
}
|
|
358
|
-
}
|
|
359
|
-
const clearCursorSpan =
|
|
425
|
+
};
|
|
426
|
+
const clearCursorSpan = () => {
|
|
360
427
|
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
361
428
|
if (!doc)
|
|
362
429
|
return;
|
|
363
430
|
// Clear the completion text
|
|
364
431
|
updateCursorSpan("");
|
|
365
|
-
}
|
|
366
|
-
// Handle keydown events for cursor movement (arrow keys, etc.)
|
|
367
|
-
useEffect(() => {
|
|
368
|
-
const keyHandler = (e) => {
|
|
369
|
-
if (e.key === "ArrowLeft" ||
|
|
370
|
-
e.key === "ArrowRight" ||
|
|
371
|
-
e.key === "ArrowUp" ||
|
|
372
|
-
e.key === "ArrowDown" ||
|
|
373
|
-
e.key === " " ||
|
|
374
|
-
e.key === "Tab" ||
|
|
375
|
-
e.key === "End" ||
|
|
376
|
-
e.key === "Backspace" ||
|
|
377
|
-
e.key === "Delete") {
|
|
378
|
-
setCurrentCompletion(null);
|
|
379
|
-
clearCursorSpan();
|
|
380
|
-
setTimeout(() => {
|
|
381
|
-
if (!isUpdatingRef.current) {
|
|
382
|
-
positionCursorSpan();
|
|
383
|
-
}
|
|
384
|
-
}, 10);
|
|
385
|
-
if (e.key === "ArrowRight" || e.key === "Delete") {
|
|
386
|
-
const cursorSpan = pageViewContext.editorIframe?.contentWindow?.document.getElementById(cursorSpanId);
|
|
387
|
-
if (cursorSpan) {
|
|
388
|
-
const originalDisplay = cursorSpan.style.display;
|
|
389
|
-
cursorSpan.style.display = "none";
|
|
390
|
-
setTimeout(() => {
|
|
391
|
-
if (cursorSpan.parentNode) {
|
|
392
|
-
cursorSpan.style.display = originalDisplay;
|
|
393
|
-
}
|
|
394
|
-
}, 0);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
const doc = pageViewContext.editorIframe?.contentWindow?.document;
|
|
400
|
-
if (!doc)
|
|
401
|
-
return;
|
|
402
|
-
doc.addEventListener("keydown", keyHandler);
|
|
403
|
-
return () => doc.removeEventListener("keydown", keyHandler);
|
|
404
|
-
}, [
|
|
405
|
-
clearCursorSpan,
|
|
406
|
-
cursorSpanId,
|
|
407
|
-
isUpdatingRef,
|
|
408
|
-
pageViewContext.editorIframe?.contentWindow?.document,
|
|
409
|
-
pageViewContext.page,
|
|
410
|
-
positionCursorSpan,
|
|
411
|
-
]);
|
|
412
|
-
// Function to apply the completion (must be before handleInput)
|
|
413
|
-
const applyCompletion = useCallback(() => {
|
|
414
|
-
const iframeWindow = pageViewContext.editorIframe?.contentWindow;
|
|
415
|
-
const iframeDocument = iframeWindow?.document;
|
|
416
|
-
if (!iframeWindow ||
|
|
417
|
-
!iframeDocument ||
|
|
418
|
-
!fieldsContext?.inlineEditingFieldElement)
|
|
419
|
-
return;
|
|
420
|
-
const cursorSpan = iframeDocument.getElementById(cursorSpanId);
|
|
421
|
-
if (!cursorSpan)
|
|
422
|
-
return;
|
|
423
|
-
const completionToApply = cursorSpan.textContent || "";
|
|
424
|
-
if (!completionToApply)
|
|
425
|
-
return;
|
|
426
|
-
const element = fieldsContext.inlineEditingFieldElement;
|
|
427
|
-
const fieldId = element.getAttribute("data-fieldid");
|
|
428
|
-
const fieldName = element.getAttribute("data-fieldname");
|
|
429
|
-
const itemId = element.getAttribute("data-itemid");
|
|
430
|
-
const language = element.getAttribute("data-language");
|
|
431
|
-
const versionStr = element.getAttribute("data-version");
|
|
432
|
-
const isRichText = element.getAttribute("data-is-richtext") === "true";
|
|
433
|
-
const version = versionStr ? parseInt(versionStr, 10) : undefined;
|
|
434
|
-
if (!fieldId || !itemId || !language || !version)
|
|
435
|
-
return;
|
|
436
|
-
const selection = iframeWindow.getSelection();
|
|
437
|
-
if (!selection || selection.rangeCount === 0)
|
|
438
|
-
return;
|
|
439
|
-
const range = selection.getRangeAt(0);
|
|
440
|
-
const tempRange = document.createRange();
|
|
441
|
-
tempRange.selectNodeContents(element);
|
|
442
|
-
tempRange.setEnd(range.startContainer, range.startOffset);
|
|
443
|
-
const textUpToCursor = tempRange.toString();
|
|
444
|
-
const wordBoundaryRegex = /[\s.,;:!?"'()[\]{}<>/|=+\-*&^%$#@~`](?=[^\s.,;:!?"'()[\]{}<>/|=+\-*&^%$#@~`]*$)/;
|
|
445
|
-
const match = textUpToCursor.match(wordBoundaryRegex);
|
|
446
|
-
const lastWordBoundaryIndex = match && match.index !== undefined ? match.index + 1 : 0;
|
|
447
|
-
const currentPartialWord = textUpToCursor
|
|
448
|
-
.substring(lastWordBoundaryIndex)
|
|
449
|
-
.trim();
|
|
450
|
-
const isOverlapping = currentPartialWord.length > 0 &&
|
|
451
|
-
completionToApply
|
|
452
|
-
.toLowerCase()
|
|
453
|
-
.startsWith(currentPartialWord.toLowerCase());
|
|
454
|
-
if (isOverlapping) {
|
|
455
|
-
const wordRange = document.createRange();
|
|
456
|
-
const startContainer = range.startContainer;
|
|
457
|
-
const startOffset = range.startOffset - currentPartialWord.length;
|
|
458
|
-
if (startOffset >= 0 && startContainer.nodeType === Node.TEXT_NODE) {
|
|
459
|
-
wordRange.setStart(startContainer, startOffset);
|
|
460
|
-
wordRange.setEnd(range.startContainer, range.startOffset);
|
|
461
|
-
wordRange.deleteContents();
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
if (textUpToCursor.length > 0 && !textUpToCursor.endsWith(" ")) {
|
|
465
|
-
const spaceNode = document.createTextNode(" ");
|
|
466
|
-
range.insertNode(spaceNode);
|
|
467
|
-
range.setStartAfter(spaceNode);
|
|
468
|
-
range.setEndAfter(spaceNode);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
if (textUpToCursor.length > 0 &&
|
|
474
|
-
!textUpToCursor.endsWith(" ") &&
|
|
475
|
-
!textUpToCursor.endsWith("\n") &&
|
|
476
|
-
!/[.!?\-—:;({[\s]$/.test(textUpToCursor)) {
|
|
477
|
-
const spaceNode = document.createTextNode(" ");
|
|
478
|
-
range.insertNode(spaceNode);
|
|
479
|
-
range.setStartAfter(spaceNode);
|
|
480
|
-
range.setEndAfter(spaceNode);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
const textNode = document.createTextNode(completionToApply);
|
|
484
|
-
range.insertNode(textNode);
|
|
485
|
-
range.setStartAfter(textNode);
|
|
486
|
-
range.setEndAfter(textNode);
|
|
487
|
-
selection.removeAllRanges();
|
|
488
|
-
selection.addRange(range);
|
|
489
|
-
setCurrentCompletion(null);
|
|
490
|
-
clearCursorSpan();
|
|
491
|
-
setTimeout(() => {
|
|
492
|
-
let valueToSave;
|
|
493
|
-
if (isRichText) {
|
|
494
|
-
const clone = element.cloneNode(true);
|
|
495
|
-
const cursorElem = clone.querySelector(`#${cursorSpanId}`);
|
|
496
|
-
if (cursorElem)
|
|
497
|
-
cursorElem.parentNode?.removeChild(cursorElem);
|
|
498
|
-
const ownerDoc = clone.ownerDocument || document;
|
|
499
|
-
const walker = ownerDoc.createTreeWalker(clone, NodeFilter.SHOW_TEXT);
|
|
500
|
-
const toClean = [];
|
|
501
|
-
while (walker.nextNode()) {
|
|
502
|
-
const tn = walker.currentNode;
|
|
503
|
-
if (tn.nodeValue && tn.nodeValue.includes("\u200B"))
|
|
504
|
-
toClean.push(tn);
|
|
505
|
-
}
|
|
506
|
-
toClean.forEach((tn) => (tn.nodeValue = tn.nodeValue?.replaceAll("\u200B", "") || ""));
|
|
507
|
-
valueToSave = clone.innerHTML;
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
valueToSave = (element.innerText || "").replaceAll("\u200B", "");
|
|
511
|
-
}
|
|
512
|
-
editContext?.operations.editField({
|
|
513
|
-
field: {
|
|
514
|
-
fieldId,
|
|
515
|
-
fieldName: fieldName ?? undefined,
|
|
516
|
-
item: { id: itemId, language, version },
|
|
517
|
-
},
|
|
518
|
-
refresh: "none",
|
|
519
|
-
value: valueToSave,
|
|
520
|
-
});
|
|
521
|
-
}, 0);
|
|
522
|
-
}, [
|
|
523
|
-
pageViewContext.editorIframe?.contentWindow,
|
|
524
|
-
fieldsContext?.inlineEditingFieldElement,
|
|
525
|
-
cursorSpanId,
|
|
526
|
-
clearCursorSpan,
|
|
527
|
-
editContext?.operations,
|
|
528
|
-
]);
|
|
529
|
-
applyCompletionRef.current = applyCompletion;
|
|
530
|
-
// Manual completion trigger (non-debounced)
|
|
531
|
-
const getCompletionManual = useCallback(async () => {
|
|
532
|
-
const el = fieldsContext?.inlineEditingFieldElement;
|
|
533
|
-
if (!el)
|
|
534
|
-
return;
|
|
535
|
-
const full = getContentUpToCursor(el) || "";
|
|
536
|
-
const sentence = full.split(/[.?!]\s*/).pop() || "";
|
|
537
|
-
const rawSuggestion = await getCompletion(el, true);
|
|
538
|
-
if (!rawSuggestion) {
|
|
539
|
-
setCurrentCompletion(null);
|
|
540
|
-
clearCursorSpan();
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
const suggestion = rawSuggestion.startsWith(sentence)
|
|
544
|
-
? rawSuggestion
|
|
545
|
-
: sentence + rawSuggestion;
|
|
546
|
-
setCurrentCompletion(suggestion);
|
|
547
|
-
updateCursorSpan(suggestion.substring(sentence.length));
|
|
548
|
-
}, [
|
|
549
|
-
fieldsContext?.inlineEditingFieldElement,
|
|
550
|
-
getContentUpToCursor,
|
|
551
|
-
getCompletion,
|
|
552
|
-
clearCursorSpan,
|
|
553
|
-
updateCursorSpan,
|
|
554
|
-
]);
|
|
432
|
+
};
|
|
555
433
|
// On every input: either reuse the existing suggestion or fire a new one
|
|
556
434
|
const handleInput = useCallback((e) => {
|
|
557
435
|
const el = fieldsContext?.inlineEditingFieldElement;
|
|
@@ -640,15 +518,9 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
640
518
|
}
|
|
641
519
|
}, [
|
|
642
520
|
fieldsContext?.inlineEditingFieldElement,
|
|
643
|
-
getContentUpToCursor,
|
|
644
521
|
currentCompletion,
|
|
645
|
-
clearCursorSpan,
|
|
646
|
-
getCompletionManual,
|
|
647
|
-
pageViewContext.editorIframe?.contentWindow,
|
|
648
|
-
cursorSpanId,
|
|
649
|
-
applyCompletion,
|
|
650
|
-
updateCursorSpan,
|
|
651
522
|
getCompletionDebounced,
|
|
523
|
+
getCompletionManual,
|
|
652
524
|
]);
|
|
653
525
|
// Wire up the input listener
|
|
654
526
|
useEffect(() => {
|
|
@@ -686,9 +558,6 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
686
558
|
}, [
|
|
687
559
|
fieldsContext?.inlineEditingFieldElement,
|
|
688
560
|
editContext?.enableCompletions,
|
|
689
|
-
isUpdatingRef,
|
|
690
|
-
positionCursorSpan,
|
|
691
|
-
clearCursorSpan,
|
|
692
561
|
]);
|
|
693
562
|
// Clean up abort controller on unmount
|
|
694
563
|
useEffect(() => {
|
|
@@ -703,11 +572,157 @@ export function useInlineAiCompletion({ pageViewContext, cursorSpanId, isUpdatin
|
|
|
703
572
|
}
|
|
704
573
|
};
|
|
705
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
|
+
};
|
|
706
721
|
// Exposed manual trigger (if needed)
|
|
707
722
|
return useMemo(() => () => {
|
|
708
723
|
setCurrentCompletion(null);
|
|
709
724
|
clearCursorSpan();
|
|
710
725
|
getCompletionManual();
|
|
711
|
-
}, [
|
|
726
|
+
}, [getCompletionManual]);
|
|
712
727
|
}
|
|
713
728
|
//# sourceMappingURL=useInlineAICompletion.js.map
|