@alpaca-editor/core 1.0.3942 → 1.0.3943
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/.prettierrc +3 -0
- package/build.css +3 -0
- package/components.json +21 -0
- package/dist/editor/ContentTree.d.ts +2 -1
- package/dist/editor/ContentTree.js +23 -21
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.js +0 -2
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/ScrollingContentTree.js +1 -1
- package/dist/editor/ScrollingContentTree.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +24 -3
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +7 -7
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/field-types/InternalLinkFieldEditor.js +60 -10
- package/dist/editor/field-types/InternalLinkFieldEditor.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js +48 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +116 -65
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +5 -2
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/ui/ItemSearch.js +14 -8
- package/dist/editor/ui/ItemSearch.js.map +1 -1
- package/dist/editor/ui/PerfectTree.d.ts +4 -2
- package/dist/editor/ui/PerfectTree.js +78 -4
- package/dist/editor/ui/PerfectTree.js.map +1 -1
- package/dist/editor/ui/Splitter.js +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +8 -2
- package/eslint.config.mjs +4 -0
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/package.json +2 -8
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +50 -0
- package/src/components/Error.tsx +57 -0
- package/src/components/ui/CardConnector.tsx +56 -0
- package/src/components/ui/button.tsx +62 -0
- package/src/components/ui/card.tsx +372 -0
- package/src/components/ui/context-menu.tsx +250 -0
- package/src/config/config.tsx +917 -0
- package/src/config/types.ts +286 -0
- package/src/editor/ComponentInfo.tsx +90 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +733 -0
- package/src/editor/ContextMenu.tsx +230 -0
- package/src/editor/Editor.tsx +90 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldActionsOverlay.tsx +296 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +75 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +391 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +217 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +128 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +196 -0
- package/src/editor/MainLayout.tsx +95 -0
- package/src/editor/MobileLayout.tsx +68 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +568 -0
- package/src/editor/PictureEditor.tsx +301 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +68 -0
- package/src/editor/Terminal.tsx +227 -0
- package/src/editor/Titlebar.tsx +104 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +106 -0
- package/src/editor/ai/AiTerminal.tsx +503 -0
- package/src/editor/ai/AiToolCall.tsx +61 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/GhostWriter.tsx +480 -0
- package/src/editor/ai/aiPageModel.ts +108 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/AboutDialog.tsx +44 -0
- package/src/editor/client/EditorClient.tsx +2241 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +416 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +574 -0
- package/src/editor/client/operations.ts +768 -0
- package/src/editor/client/pageModelBuilder.ts +219 -0
- package/src/editor/commands/commands.ts +22 -0
- package/src/editor/commands/componentCommands.tsx +431 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +351 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -0
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +27 -0
- package/src/editor/commands/undo.ts +39 -0
- package/src/editor/component-designer/ComponentDesigner.tsx +70 -0
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +11 -0
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +91 -0
- package/src/editor/component-designer/ComponentEditor.tsx +97 -0
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +31 -0
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +104 -0
- package/src/editor/component-designer/ComponentsDropdown.tsx +39 -0
- package/src/editor/component-designer/PlaceholdersEditor.tsx +179 -0
- package/src/editor/component-designer/RenderingsDropdown.tsx +36 -0
- package/src/editor/component-designer/TemplateEditor.tsx +236 -0
- package/src/editor/component-designer/aiContext.ts +23 -0
- package/src/editor/componentTreeHelper.tsx +116 -0
- package/src/editor/context-menu/CopyMoveMenu.tsx +103 -0
- package/src/editor/context-menu/InsertMenu.tsx +347 -0
- package/src/editor/control-center/About.tsx +342 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +76 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Info.tsx +104 -0
- package/src/editor/control-center/QuotaInfo.tsx +301 -0
- package/src/editor/control-center/Status.tsx +113 -0
- package/src/editor/control-center/WebSocketMessages.tsx +155 -0
- package/src/editor/editor-warnings/ItemLocked.tsx +63 -0
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +22 -0
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +23 -0
- package/src/editor/editor-warnings/NoWriteAccess.tsx +16 -0
- package/src/editor/editor-warnings/ValidationErrors.tsx +54 -0
- package/src/editor/field-types/AttachmentEditor.tsx +9 -0
- package/src/editor/field-types/CheckboxEditor.tsx +47 -0
- package/src/editor/field-types/DropLinkEditor.tsx +80 -0
- package/src/editor/field-types/DropListEditor.tsx +84 -0
- package/src/editor/field-types/ImageFieldEditor.tsx +65 -0
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +188 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +82 -0
- package/src/editor/field-types/PictureFieldEditor.tsx +121 -0
- package/src/editor/field-types/RawEditor.tsx +53 -0
- package/src/editor/field-types/ReactQuill.tsx +580 -0
- package/src/editor/field-types/RichTextEditor.tsx +22 -0
- package/src/editor/field-types/RichTextEditorComponent.tsx +127 -0
- package/src/editor/field-types/SingleLineText.tsx +174 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +185 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +94 -0
- package/src/editor/media-selector/MediaFolderBrowser.tsx +321 -0
- package/src/editor/media-selector/MediaSelector.tsx +42 -0
- package/src/editor/media-selector/Preview.tsx +14 -0
- package/src/editor/media-selector/Thumbnails.tsx +48 -0
- package/src/editor/media-selector/TreeSelector.tsx +292 -0
- package/src/editor/media-selector/UploadZone.tsx +137 -0
- package/src/editor/media-selector/index.ts +8 -0
- package/src/editor/menubar/ActionsMenu.tsx +94 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +28 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +76 -0
- package/src/editor/menubar/LanguageSelector.tsx +226 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +278 -0
- package/src/editor/menubar/PageViewerControls.tsx +120 -0
- package/src/editor/menubar/PreviewSecondaryControls.tsx +18 -0
- package/src/editor/menubar/SecondaryControls.tsx +45 -0
- package/src/editor/menubar/Separator.tsx +12 -0
- package/src/editor/menubar/SiteInfo.tsx +53 -0
- package/src/editor/menubar/User.tsx +27 -0
- package/src/editor/menubar/VersionSelector.tsx +142 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +307 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +59 -0
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +23 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +64 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +35 -0
- package/src/editor/page-editor-chrome/FrameMenu.tsx +338 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +765 -0
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +61 -0
- package/src/editor/page-editor-chrome/NoLayout.tsx +36 -0
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +122 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +161 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +169 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +315 -0
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +300 -0
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +40 -0
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +828 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +262 -0
- package/src/editor/page-viewer/MiniMap.tsx +362 -0
- package/src/editor/page-viewer/PageViewer.tsx +169 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1022 -0
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +412 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +220 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +308 -0
- package/src/editor/reviews/Comments.tsx +125 -0
- package/src/editor/reviews/DiffView.tsx +109 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/SuggestedEdit.tsx +316 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +173 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +180 -0
- package/src/editor/services/editService.ts +488 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +53 -0
- package/src/editor/services/serviceHelper.ts +95 -0
- package/src/editor/services/suggestedEditsService.ts +39 -0
- package/src/editor/services/systemService.ts +5 -0
- package/src/editor/services/translationService.ts +21 -0
- package/src/editor/services-server/api.ts +150 -0
- package/src/editor/services-server/graphQL.ts +106 -0
- package/src/editor/sidebar/ComponentPalette.tsx +161 -0
- package/src/editor/sidebar/ComponentTree.tsx +549 -0
- package/src/editor/sidebar/Debug.tsx +111 -0
- package/src/editor/sidebar/DictionaryEditor.tsx +261 -0
- package/src/editor/sidebar/EditHistory.tsx +134 -0
- package/src/editor/sidebar/GraphQL.tsx +164 -0
- package/src/editor/sidebar/Insert.tsx +35 -0
- package/src/editor/sidebar/MainContentTree.tsx +102 -0
- package/src/editor/sidebar/Performance.tsx +53 -0
- package/src/editor/sidebar/Sessions.tsx +35 -0
- package/src/editor/sidebar/Sidebar.tsx +20 -0
- package/src/editor/sidebar/SidebarView.tsx +152 -0
- package/src/editor/sidebar/Translations.tsx +295 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +60 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +81 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +24 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +709 -0
- package/src/editor/ui/ItemList.tsx +76 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +159 -0
- package/src/editor/ui/PerfectTree.tsx +676 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +54 -0
- package/src/editor/ui/SimpleMenu.tsx +40 -0
- package/src/editor/ui/SimpleTable.tsx +60 -0
- package/src/editor/ui/SimpleTabs.tsx +60 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +9 -0
- package/src/editor/ui/Splitter.tsx +420 -0
- package/src/editor/ui/StackedPanels.tsx +134 -0
- package/src/editor/ui/Toolbar.tsx +7 -0
- package/src/editor/utils/id-helper.ts +3 -0
- package/src/editor/utils/insertOptions.ts +69 -0
- package/src/editor/utils/itemutils.ts +29 -0
- package/src/editor/utils/useMemoDebug.ts +28 -0
- package/src/editor/utils.ts +486 -0
- package/src/editor/views/CompareView.tsx +245 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/MediaFolderEditView.tsx +66 -0
- package/src/editor/views/SingleEditView.tsx +57 -0
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/fonts/index.ts +10 -0
- package/src/index.ts +23 -0
- package/src/lib/safelist.tsx +16 -0
- package/src/lib/utils.ts +6 -0
- package/src/page-wizard/PageWizard.tsx +139 -0
- package/src/page-wizard/WizardBox.tsx +4 -0
- package/src/page-wizard/WizardBoxConnector.tsx +56 -0
- package/src/page-wizard/WizardSteps.tsx +458 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +26 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +259 -0
- package/src/page-wizard/steps/CollectStep.tsx +296 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +454 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/ContentStep.tsx +890 -0
- package/src/page-wizard/steps/EditButton.tsx +34 -0
- package/src/page-wizard/steps/FieldEditor.tsx +102 -0
- package/src/page-wizard/steps/Generate.tsx +60 -0
- package/src/page-wizard/steps/ImagesStep.tsx +382 -0
- package/src/page-wizard/steps/LayoutStep.tsx +227 -0
- package/src/page-wizard/steps/MetaDataStep.tsx +173 -0
- package/src/page-wizard/steps/SelectStep.tsx +281 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +325 -0
- package/src/page-wizard/usePageWizard.ts +79 -0
- package/src/revision.ts +2 -0
- package/src/splash-screen/NewPage.tsx +294 -0
- package/src/splash-screen/OpenPage.tsx +113 -0
- package/src/splash-screen/RecentPages.tsx +123 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +195 -0
- package/src/tour/Tour.tsx +566 -0
- package/src/tour/default-tour.tsx +301 -0
- package/src/tour/preview-tour.tsx +128 -0
- package/src/types.ts +335 -0
- package/styles.css +765 -0
- package/tsconfig.build.json +31 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Dialog } from "primereact/dialog";
|
|
2
|
+
|
|
3
|
+
import { Workbox as WorkboxWidget } from "./sidebar/Workbox";
|
|
4
|
+
|
|
5
|
+
import DialogButtons from "./DialogButtons";
|
|
6
|
+
import { Button } from "primereact/button";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function PublishDialog({
|
|
10
|
+
// lockItems,
|
|
11
|
+
// unlockItems,
|
|
12
|
+
|
|
13
|
+
visible,
|
|
14
|
+
onHide,
|
|
15
|
+
page,
|
|
16
|
+
}: {
|
|
17
|
+
// lockItems: (item: ItemDescriptor[]) => void;
|
|
18
|
+
// unlockItems: (item: ItemDescriptor[]) => void;
|
|
19
|
+
executeWorkflowCommand: (item: ItemDescriptor, commandId: string) => void;
|
|
20
|
+
visible: boolean;
|
|
21
|
+
onHide: () => void;
|
|
22
|
+
page: Page;
|
|
23
|
+
}) {
|
|
24
|
+
const allUnlocked =
|
|
25
|
+
page._editor!.workbox.items.filter((x) => x.hasLock).length > 0;
|
|
26
|
+
const allInFinalState =
|
|
27
|
+
page._editor!.workbox.items.filter((x) => !x.isFinalState).length > 0;
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Dialog
|
|
31
|
+
header={"Publish page " + page.name}
|
|
32
|
+
style={{ width: "70vw", height: "70vh" }}
|
|
33
|
+
onHide={onHide}
|
|
34
|
+
visible={visible}
|
|
35
|
+
>
|
|
36
|
+
<div className="a-w-full a-h-full a-flex a-flex-col">
|
|
37
|
+
<WorkboxWidget />
|
|
38
|
+
|
|
39
|
+
<DialogButtons>
|
|
40
|
+
{/* {allUnlocked && (
|
|
41
|
+
<Button
|
|
42
|
+
onClick={() => {
|
|
43
|
+
unlockItems(
|
|
44
|
+
page.workbox.items
|
|
45
|
+
.filter((x) => x.hasLock)
|
|
46
|
+
.map((x) => x.item)
|
|
47
|
+
);
|
|
48
|
+
}}
|
|
49
|
+
size="small"
|
|
50
|
+
>
|
|
51
|
+
Unlock all
|
|
52
|
+
</Button>
|
|
53
|
+
)} */}
|
|
54
|
+
{allInFinalState && (
|
|
55
|
+
<Button size="small" onClick={() => {}}>
|
|
56
|
+
Publish
|
|
57
|
+
</Button>
|
|
58
|
+
)}
|
|
59
|
+
{!(allInFinalState || !allUnlocked) && (
|
|
60
|
+
<Button
|
|
61
|
+
onClick={() => {
|
|
62
|
+
onHide();
|
|
63
|
+
}}
|
|
64
|
+
size="small"
|
|
65
|
+
>
|
|
66
|
+
Cancel
|
|
67
|
+
</Button>
|
|
68
|
+
)}
|
|
69
|
+
</DialogButtons>
|
|
70
|
+
</div>
|
|
71
|
+
</Dialog>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { ItemTreeNodeData } from "./services/contentService";
|
|
3
|
+
|
|
4
|
+
import ContentTree from "./ContentTree";
|
|
5
|
+
import { FullItem, ItemDescriptor } from "./pageModel";
|
|
6
|
+
import { contentItemId } from "../config/config";
|
|
7
|
+
import { useEditContext, EditContextType } from "./client/editContext";
|
|
8
|
+
|
|
9
|
+
export function ScrollingContentTree({
|
|
10
|
+
selectedItemId,
|
|
11
|
+
onSelectionChange,
|
|
12
|
+
rootItemId,
|
|
13
|
+
|
|
14
|
+
expandedItemId,
|
|
15
|
+
}: {
|
|
16
|
+
selectedItemId?: string;
|
|
17
|
+
onSelectionChange?: (itemIds: ItemTreeNodeData[]) => void;
|
|
18
|
+
rootItemId?: string;
|
|
19
|
+
expandedItemId?: string;
|
|
20
|
+
}) {
|
|
21
|
+
const [selectedItem, setSelectdItem] = useState<FullItem | null>(null);
|
|
22
|
+
const [expandedItem, setExpandedItem] = useState<FullItem | null>();
|
|
23
|
+
const editContext = useEditContext();
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const loadItem = async () => {
|
|
27
|
+
if (!selectedItemId) return;
|
|
28
|
+
const item = await editContext!.itemsRepository.getItem({
|
|
29
|
+
id: selectedItemId,
|
|
30
|
+
language: editContext!.currentItemDescriptor?.language ?? "en",
|
|
31
|
+
version: 0,
|
|
32
|
+
});
|
|
33
|
+
if (item) setSelectdItem(item);
|
|
34
|
+
};
|
|
35
|
+
loadItem();
|
|
36
|
+
}, [selectedItemId]);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const loadItem = async () => {
|
|
40
|
+
if (!expandedItemId && !selectedItemId) {
|
|
41
|
+
setExpandedItem(null);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const item = await editContext!.itemsRepository.getItem({
|
|
45
|
+
id: expandedItemId ?? selectedItemId ?? "",
|
|
46
|
+
language: editContext!.currentItemDescriptor?.language ?? "en",
|
|
47
|
+
version: 0,
|
|
48
|
+
});
|
|
49
|
+
if (item) setExpandedItem(item);
|
|
50
|
+
};
|
|
51
|
+
loadItem();
|
|
52
|
+
}, [expandedItemId, selectedItemId]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="absolute inset-0 overflow-auto">
|
|
56
|
+
<ContentTree
|
|
57
|
+
language={editContext!.currentItemDescriptor?.language ?? "en"}
|
|
58
|
+
rootItemId={rootItemId ?? contentItemId}
|
|
59
|
+
expandIdPath={expandedItem?.idPath}
|
|
60
|
+
selectedItemIds={selectedItemId ? [selectedItemId] : []}
|
|
61
|
+
selectionMode="single"
|
|
62
|
+
className="h-full p-1"
|
|
63
|
+
onSelectionChange={onSelectionChange}
|
|
64
|
+
scrollToSelected={true}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef,
|
|
5
|
+
useState,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
} from "react";
|
|
8
|
+
import { Button } from "primereact/button";
|
|
9
|
+
import { InputTextarea } from "primereact/inputtextarea";
|
|
10
|
+
import { classNames } from "primereact/utils";
|
|
11
|
+
|
|
12
|
+
type Message = {
|
|
13
|
+
text: React.ReactNode;
|
|
14
|
+
type: "command" | "response";
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Terminal = forwardRef<
|
|
18
|
+
{ submit: () => void },
|
|
19
|
+
{
|
|
20
|
+
commandHandler: (
|
|
21
|
+
text: string,
|
|
22
|
+
callback: (text: React.ReactNode, finished: boolean) => void,
|
|
23
|
+
) => void;
|
|
24
|
+
prompt: string;
|
|
25
|
+
setPrompt: (text: string) => void;
|
|
26
|
+
onReset: () => void;
|
|
27
|
+
toolbar?: React.ReactNode;
|
|
28
|
+
statusbar?: React.ReactNode;
|
|
29
|
+
infobar?: React.ReactNode;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
>((props, ref) => {
|
|
34
|
+
const {
|
|
35
|
+
commandHandler,
|
|
36
|
+
prompt,
|
|
37
|
+
setPrompt,
|
|
38
|
+
onReset,
|
|
39
|
+
toolbar,
|
|
40
|
+
statusbar,
|
|
41
|
+
infobar,
|
|
42
|
+
disabled,
|
|
43
|
+
className,
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
const [response, setResponse] = useState<React.ReactNode>();
|
|
47
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
48
|
+
const bottomRef = useRef<HTMLDivElement | null>(null);
|
|
49
|
+
const messageRef = useRef(messages);
|
|
50
|
+
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
51
|
+
const [promptHistory, setPromptHistory] = useState<string[]>(() => {
|
|
52
|
+
if (typeof window !== "undefined") {
|
|
53
|
+
return JSON.parse(
|
|
54
|
+
localStorage.getItem("editor.ai.promptHistory") || "[]",
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
});
|
|
59
|
+
const [currentHistoryIndex, setCurrentHistoryIndex] = useState<number>(-1);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
localStorage.setItem(
|
|
63
|
+
"editor.ai.promptHistory",
|
|
64
|
+
JSON.stringify(promptHistory),
|
|
65
|
+
);
|
|
66
|
+
}, [promptHistory]);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (inputRef.current) {
|
|
70
|
+
inputRef.current.focus();
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
messageRef.current = messages;
|
|
76
|
+
}, [messages]);
|
|
77
|
+
|
|
78
|
+
const callback = (text: React.ReactNode, finished: boolean) => {
|
|
79
|
+
if (!finished) setResponse(text);
|
|
80
|
+
else {
|
|
81
|
+
setResponse(undefined);
|
|
82
|
+
setMessages([...messageRef.current, { type: "response", text }]);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleKeyPress = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
87
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
submit();
|
|
90
|
+
}
|
|
91
|
+
if (e.key === "ArrowUp") {
|
|
92
|
+
// Only navigate history if we haven't started typing or if we're already navigating history
|
|
93
|
+
const hasStartedTyping =
|
|
94
|
+
prompt.trim().length > 0 && currentHistoryIndex === -1;
|
|
95
|
+
if (!hasStartedTyping) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
if (promptHistory.length > 0) {
|
|
98
|
+
const newIndex =
|
|
99
|
+
currentHistoryIndex < promptHistory.length - 1
|
|
100
|
+
? currentHistoryIndex + 1
|
|
101
|
+
: currentHistoryIndex;
|
|
102
|
+
setCurrentHistoryIndex(newIndex);
|
|
103
|
+
const historicalPrompt = promptHistory[newIndex];
|
|
104
|
+
if (inputRef.current && historicalPrompt) {
|
|
105
|
+
setPrompt(historicalPrompt);
|
|
106
|
+
setTimeout(() => {
|
|
107
|
+
inputRef.current!.selectionStart = historicalPrompt.length;
|
|
108
|
+
inputRef.current!.selectionEnd = historicalPrompt.length;
|
|
109
|
+
}, 0);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (e.key === "ArrowDown" && currentHistoryIndex >= 0) {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
const newIndex = currentHistoryIndex - 1;
|
|
117
|
+
setCurrentHistoryIndex(newIndex);
|
|
118
|
+
const historicalPrompt =
|
|
119
|
+
newIndex >= 0 ? promptHistory[newIndex] || "" : "";
|
|
120
|
+
setPrompt(historicalPrompt);
|
|
121
|
+
if (inputRef.current) {
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
inputRef.current!.selectionStart = historicalPrompt.length;
|
|
124
|
+
inputRef.current!.selectionEnd = historicalPrompt.length;
|
|
125
|
+
}, 0);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
// Scroll to bottom every time messages or response changes.
|
|
132
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
133
|
+
}, [messages, response]);
|
|
134
|
+
|
|
135
|
+
const responseBoxClasses =
|
|
136
|
+
"text-xs self-stretch text-gray-700 p-2 rounded shadow border border-gray-200";
|
|
137
|
+
const getClasses = (m: Message) => {
|
|
138
|
+
if (m.type === "response") return responseBoxClasses;
|
|
139
|
+
return "text-xs text-gray-700 bg-indigo-100 p-2 rounded prompt";
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Expose the submit function via the ref.
|
|
143
|
+
const submit = () => {
|
|
144
|
+
if (prompt.trim()) {
|
|
145
|
+
setPromptHistory((prev) => [
|
|
146
|
+
prompt,
|
|
147
|
+
...prev.filter((p) => p !== prompt).slice(0, 9),
|
|
148
|
+
]);
|
|
149
|
+
setCurrentHistoryIndex(-1);
|
|
150
|
+
}
|
|
151
|
+
setMessages([...messages, { type: "command", text: prompt }]);
|
|
152
|
+
setPrompt("");
|
|
153
|
+
setResponse("...");
|
|
154
|
+
commandHandler(prompt, callback);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
useImperativeHandle(ref, () => ({
|
|
158
|
+
submit,
|
|
159
|
+
}));
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div className={classNames("flex h-full flex-col", className)}>
|
|
163
|
+
<div className="flex items-center justify-between gap-2 border-b border-gray-200 p-1 text-xs">
|
|
164
|
+
<button
|
|
165
|
+
onClick={() => {
|
|
166
|
+
setMessages([]);
|
|
167
|
+
onReset();
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<i className="pi pi-trash m-1 text-sm" />
|
|
171
|
+
</button>
|
|
172
|
+
{toolbar}
|
|
173
|
+
</div>
|
|
174
|
+
<div className="h-full overflow-x-hidden overflow-y-auto p-2">
|
|
175
|
+
<div className="flex flex-col items-end gap-3 select-text">
|
|
176
|
+
{messages.map((m, i) => (
|
|
177
|
+
<div key={i} className={getClasses(m)}>
|
|
178
|
+
{m.text}
|
|
179
|
+
</div>
|
|
180
|
+
))}
|
|
181
|
+
|
|
182
|
+
{response != null && (
|
|
183
|
+
<div className={responseBoxClasses}>
|
|
184
|
+
<div className="flex text-xs">{response}</div>
|
|
185
|
+
<div className="mr-4 flex items-center justify-end space-x-1 text-xs text-gray-400">
|
|
186
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:-0.3s]"></div>
|
|
187
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:-0.15s]"></div>
|
|
188
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-400"></div>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
)}
|
|
192
|
+
<div ref={bottomRef} />
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
<div className="flex flex-col p-1 pb-0">
|
|
196
|
+
{infobar}
|
|
197
|
+
<InputTextarea
|
|
198
|
+
ref={inputRef}
|
|
199
|
+
value={prompt}
|
|
200
|
+
className="flex-1 resize-none self-stretch rounded border border-gray-300 text-xs"
|
|
201
|
+
onKeyDown={handleKeyPress}
|
|
202
|
+
onChange={(e) => {
|
|
203
|
+
setPrompt(e.target.value);
|
|
204
|
+
// Reset history index when user starts typing
|
|
205
|
+
if (currentHistoryIndex !== -1) {
|
|
206
|
+
setCurrentHistoryIndex(-1);
|
|
207
|
+
}
|
|
208
|
+
}}
|
|
209
|
+
rows={4}
|
|
210
|
+
cols={30}
|
|
211
|
+
disabled={disabled}
|
|
212
|
+
/>
|
|
213
|
+
<div className="flex items-center justify-between py-1">
|
|
214
|
+
{statusbar}
|
|
215
|
+
<Button
|
|
216
|
+
icon={"pi pi-send"}
|
|
217
|
+
text
|
|
218
|
+
size="small"
|
|
219
|
+
className="tour-send-button"
|
|
220
|
+
onClick={submit}
|
|
221
|
+
disabled={prompt.trim().length === 0}
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { MenuIcon } from "lucide-react";
|
|
2
|
+
import { useEditContext } from "./client/editContext";
|
|
3
|
+
import { useEffect, useState, useRef } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { Logo } from "./ui/Icons";
|
|
6
|
+
|
|
7
|
+
export function Titlebar() {
|
|
8
|
+
const editContext = useEditContext();
|
|
9
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
10
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
11
|
+
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
12
|
+
|
|
13
|
+
if (!editContext?.view) return null;
|
|
14
|
+
|
|
15
|
+
const isMobile = editContext.isMobile;
|
|
16
|
+
|
|
17
|
+
// Get custom title from view's headerTitle function, or fall back to "workbench"
|
|
18
|
+
const title = editContext.view.headerTitle
|
|
19
|
+
? editContext.view.headerTitle(editContext)
|
|
20
|
+
: "SiteMagician";
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setMenuOpen(false);
|
|
24
|
+
}, [editContext.currentItemDescriptor]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
28
|
+
if (!menuOpen) return;
|
|
29
|
+
|
|
30
|
+
const target = event.target as Element;
|
|
31
|
+
const menuElement = menuRef.current;
|
|
32
|
+
const buttonElement = buttonRef.current;
|
|
33
|
+
|
|
34
|
+
// Check if the click is inside the menu or button
|
|
35
|
+
const isInsideMenu = menuElement && menuElement.contains(target);
|
|
36
|
+
const isInsideButton = buttonElement && buttonElement.contains(target);
|
|
37
|
+
|
|
38
|
+
// Check if the click is inside a PrimeReact overlay (which renders in portals)
|
|
39
|
+
const isInsideOverlay = target.closest(".p-overlaypanel") !== null;
|
|
40
|
+
|
|
41
|
+
// Close menu only if click is outside menu, button, and overlays
|
|
42
|
+
if (!isInsideMenu && !isInsideButton && !isInsideOverlay) {
|
|
43
|
+
setMenuOpen(false);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (menuOpen) {
|
|
48
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
document.removeEventListener("click", handleClickOutside, true);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, [menuOpen]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className="z-1 flex min-h-11 items-center justify-between gap-1 bg-gradient-to-r from-gray-900 from-10% to-indigo-950">
|
|
58
|
+
<div className="relative flex items-center justify-center gap-2 pl-2 font-bold text-white">
|
|
59
|
+
<a
|
|
60
|
+
//href="/sitecore/shell/sitecore/client/Applications/Launchpad"
|
|
61
|
+
onClick={() => {
|
|
62
|
+
editContext.switchView("splash-screen");
|
|
63
|
+
}}
|
|
64
|
+
className="glow-text flex cursor-pointer items-center"
|
|
65
|
+
>
|
|
66
|
+
<Logo className="h-6 w-6" />
|
|
67
|
+
<span className="ml-2 font-mono">{title}</span>
|
|
68
|
+
</a>
|
|
69
|
+
</div>
|
|
70
|
+
<div>{editContext?.view.primaryControls}</div>
|
|
71
|
+
{/* Desktop View */}
|
|
72
|
+
{!isMobile && (
|
|
73
|
+
<>
|
|
74
|
+
<div>{editContext?.view.secondaryControls}</div>
|
|
75
|
+
</>
|
|
76
|
+
)}
|
|
77
|
+
|
|
78
|
+
{/* Mobile View - Burger Menu */}
|
|
79
|
+
{isMobile && editContext?.view.secondaryControls && (
|
|
80
|
+
<>
|
|
81
|
+
<button
|
|
82
|
+
ref={buttonRef}
|
|
83
|
+
className="px-4 text-white"
|
|
84
|
+
onClick={() => setMenuOpen(!menuOpen)}
|
|
85
|
+
aria-label="Menu"
|
|
86
|
+
>
|
|
87
|
+
<MenuIcon className="h-6 w-6" />
|
|
88
|
+
</button>
|
|
89
|
+
|
|
90
|
+
{menuOpen &&
|
|
91
|
+
createPortal(
|
|
92
|
+
<div
|
|
93
|
+
ref={menuRef}
|
|
94
|
+
className="absolute top-10.5 right-0 z-50 rounded bg-indigo-950 p-4 shadow-lg"
|
|
95
|
+
>
|
|
96
|
+
<div>{editContext?.view.secondaryControls}</div>
|
|
97
|
+
</div>,
|
|
98
|
+
document.body,
|
|
99
|
+
)}
|
|
100
|
+
</>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { OverlayPanel } from "primereact/overlaypanel";
|
|
4
|
+
import { Button } from "primereact/button";
|
|
5
|
+
import {
|
|
6
|
+
SyntheticEvent,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from "react";
|
|
12
|
+
import { EditorAiTerminal } from "./EditorAiTerminal";
|
|
13
|
+
import { AiTerminalOptions } from "./AiTerminal";
|
|
14
|
+
|
|
15
|
+
export interface AiPopupRef {
|
|
16
|
+
show: (event: SyntheticEvent, terminalOptions?: AiTerminalOptions) => void;
|
|
17
|
+
close: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface AiPopupProps {}
|
|
21
|
+
|
|
22
|
+
export const AiPopup = forwardRef<AiPopupRef, AiPopupProps>(
|
|
23
|
+
(_: unknown, ref) => {
|
|
24
|
+
const overlayRef = useRef<OverlayPanel>(null);
|
|
25
|
+
const [terminalOptions, setTerminalOptions] = useState<AiTerminalOptions>();
|
|
26
|
+
|
|
27
|
+
//const [components, setComponents] = useState<ComponentData[]>([]); // [componentId, componentId, ...]
|
|
28
|
+
|
|
29
|
+
useImperativeHandle(ref, () => ({
|
|
30
|
+
show: (ev: SyntheticEvent, terminalOptions?: AiTerminalOptions) => {
|
|
31
|
+
setTerminalOptions(terminalOptions);
|
|
32
|
+
//setComponents(components || []);
|
|
33
|
+
overlayRef.current?.toggle(ev);
|
|
34
|
+
},
|
|
35
|
+
close: () => {
|
|
36
|
+
overlayRef.current?.hide();
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<OverlayPanel ref={overlayRef}>
|
|
42
|
+
<div
|
|
43
|
+
className="w-96 h-96 flex flex-col gap-2"
|
|
44
|
+
onClick={(ev) => ev.stopPropagation()}
|
|
45
|
+
>
|
|
46
|
+
<EditorAiTerminal
|
|
47
|
+
options={terminalOptions}
|
|
48
|
+
closeButton=<Button
|
|
49
|
+
icon="pi pi-times"
|
|
50
|
+
onClick={() => overlayRef.current?.hide()}
|
|
51
|
+
size="small"
|
|
52
|
+
text
|
|
53
|
+
/>
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
</OverlayPanel>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { useEditContext } from "../client/editContext";
|
|
4
|
+
import { EditOperation } from "../../types";
|
|
5
|
+
import { Message } from "./AiTerminal";
|
|
6
|
+
import { AiToolCall } from "./AiToolCall";
|
|
7
|
+
|
|
8
|
+
export function AiResponseMessage({
|
|
9
|
+
messages,
|
|
10
|
+
finished,
|
|
11
|
+
editOperations,
|
|
12
|
+
}: {
|
|
13
|
+
messages: Message[];
|
|
14
|
+
finished: boolean;
|
|
15
|
+
editOperations: EditOperation[];
|
|
16
|
+
}) {
|
|
17
|
+
const editContext = useEditContext();
|
|
18
|
+
if (!editContext) return <></>;
|
|
19
|
+
|
|
20
|
+
// const [showFunctions, setShowFunctions] = useState(false);
|
|
21
|
+
const [changesRejected, setChangesRejected] = useState<boolean | undefined>(
|
|
22
|
+
undefined,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const reversedEditOperations = [...editOperations].reverse();
|
|
26
|
+
|
|
27
|
+
const canReject =
|
|
28
|
+
editContext.editHistory.length >= editOperations.length &&
|
|
29
|
+
reversedEditOperations.find(
|
|
30
|
+
(x, index) =>
|
|
31
|
+
editContext.editHistory[index]?.id !== x.id ||
|
|
32
|
+
!editContext.editHistory[index]?.canUndo,
|
|
33
|
+
) === undefined;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
{messages
|
|
38
|
+
.filter((x) => x.role !== "tool")
|
|
39
|
+
.map((message, index) => (
|
|
40
|
+
<div key={index}>
|
|
41
|
+
<div
|
|
42
|
+
dangerouslySetInnerHTML={{
|
|
43
|
+
__html: message.formattedContent || message.content || "",
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
{message.tool_calls && message.tool_calls.length > 0 && (
|
|
47
|
+
<div className="text-xs text-gray-400">
|
|
48
|
+
{message.tool_calls.map((x, index) => (
|
|
49
|
+
<AiToolCall
|
|
50
|
+
toolCall={x}
|
|
51
|
+
key={index}
|
|
52
|
+
result={messages.find(
|
|
53
|
+
(m) => m.role === "tool" && m.tool_call_id === x.id,
|
|
54
|
+
)}
|
|
55
|
+
/>
|
|
56
|
+
))}
|
|
57
|
+
</div>
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
))}
|
|
61
|
+
{/* <div
|
|
62
|
+
dangerouslySetInnerHTML={{
|
|
63
|
+
__html: responseText.replaceAll("\\n", "<br>"),
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
{toolcalls.length > 0 && (
|
|
67
|
+
<div
|
|
68
|
+
className="mt-1 flex cursor-pointer items-center gap-1 text-xs text-gray-400"
|
|
69
|
+
onClick={() => setShowFunctions(!showFunctions)}
|
|
70
|
+
>
|
|
71
|
+
<i className="pi pi-wrench text-xs" /> Tool calls
|
|
72
|
+
</div>
|
|
73
|
+
)} */}
|
|
74
|
+
|
|
75
|
+
{/* {showFunctions && (
|
|
76
|
+
<div className="text-xs text-gray-400">
|
|
77
|
+
{toolcalls.map((x, index) => (
|
|
78
|
+
<AiToolCall toolCall={x} key={index} />
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
)} */}
|
|
82
|
+
|
|
83
|
+
{finished && editOperations.length > 0 && (
|
|
84
|
+
<div className="my-2 flex items-center gap-2">
|
|
85
|
+
<div className="tour-ai-response-message-changes text-xs">
|
|
86
|
+
{editOperations.length} changes
|
|
87
|
+
</div>
|
|
88
|
+
{canReject && !changesRejected && (
|
|
89
|
+
<div
|
|
90
|
+
className="flex cursor-pointer items-center gap-1 text-xs text-red-500"
|
|
91
|
+
onClick={async () => {
|
|
92
|
+
await editContext?.operations.undo(editOperations.length);
|
|
93
|
+
setChangesRejected(true);
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<i className="pi pi-times" /> Reject
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
{changesRejected && (
|
|
100
|
+
<div className="text-xs text-red-500">rejected</div>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|