@alpaca-editor/core 1.0.0 → 1.0.3764-editor-mono

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.
Files changed (223) hide show
  1. package/dist/client-components/api.js +6 -0
  2. package/dist/client-components/index.js +36 -0
  3. package/dist/components/ActionButton.js +9 -0
  4. package/dist/components/Error.js +28 -0
  5. package/dist/config/config.js +654 -0
  6. package/dist/config/types.js +2 -0
  7. package/dist/editor/ComponentInfo.js +31 -0
  8. package/dist/editor/ConfirmationDialog.js +32 -0
  9. package/dist/editor/ContentTree.js +406 -0
  10. package/dist/editor/ContextMenu.js +117 -0
  11. package/dist/editor/Editor.js +55 -0
  12. package/dist/editor/EditorWarning.js +13 -0
  13. package/dist/editor/EditorWarnings.js +24 -0
  14. package/dist/editor/FieldEditorPopup.js +24 -0
  15. package/dist/editor/FieldHistory.js +40 -0
  16. package/dist/editor/FieldList.js +63 -0
  17. package/dist/editor/FieldListField.js +164 -0
  18. package/dist/editor/FieldListFieldWithFallbacks.js +114 -0
  19. package/dist/editor/FloatingToolbar.js +92 -0
  20. package/dist/editor/ImageEditor.js +55 -0
  21. package/dist/editor/InsertMenu.js +164 -0
  22. package/dist/editor/ItemInfo.js +30 -0
  23. package/dist/editor/LinkEditorDialog.js +89 -0
  24. package/dist/editor/MainLayout.js +46 -0
  25. package/dist/editor/NewEditorClient.js +9 -0
  26. package/dist/editor/PictureCropper.js +332 -0
  27. package/dist/editor/PictureEditor.js +104 -0
  28. package/dist/editor/PictureEditorDialog.js +194 -0
  29. package/dist/editor/ScrollingContentTree.js +30 -0
  30. package/dist/editor/Terminal.js +109 -0
  31. package/dist/editor/Titlebar.js +11 -0
  32. package/dist/editor/ai/AiPopup.js +25 -0
  33. package/dist/editor/ai/AiResponseMessage.js +24 -0
  34. package/dist/editor/ai/AiTerminal.js +241 -0
  35. package/dist/editor/ai/AiToolCall.js +18 -0
  36. package/dist/editor/ai/EditorAiTerminal.js +9 -0
  37. package/dist/editor/ai/editorAiContext.js +14 -0
  38. package/dist/editor/client/DialogContext.js +29 -0
  39. package/dist/editor/client/EditorClient.js +1336 -0
  40. package/dist/editor/client/GenericDialog.js +27 -0
  41. package/dist/editor/client/editContext.js +59 -0
  42. package/dist/editor/client/helpers.js +31 -0
  43. package/dist/editor/client/itemsRepository.js +255 -0
  44. package/dist/editor/client/operations.js +398 -0
  45. package/dist/editor/client/pageModelBuilder.js +129 -0
  46. package/dist/editor/commands/commands.js +2 -0
  47. package/dist/editor/commands/componentCommands.js +277 -0
  48. package/dist/editor/commands/createVersionCommand.js +26 -0
  49. package/dist/editor/commands/deleteVersionCommand.js +55 -0
  50. package/dist/editor/commands/itemCommands.js +134 -0
  51. package/dist/editor/commands/localizeItem/LocalizeItemDialog.js +94 -0
  52. package/dist/editor/commands/undo.js +32 -0
  53. package/dist/editor/component-designer/ComponentDesigner.js +58 -0
  54. package/dist/editor/component-designer/ComponentDesignerAiTerminal.js +9 -0
  55. package/dist/editor/component-designer/ComponentDesignerMenu.js +67 -0
  56. package/dist/editor/component-designer/ComponentEditor.js +59 -0
  57. package/dist/editor/component-designer/ComponentRenderingCodeEditor.js +16 -0
  58. package/dist/editor/component-designer/ComponentRenderingEditor.js +71 -0
  59. package/dist/editor/component-designer/ComponentsDropdown.js +22 -0
  60. package/dist/editor/component-designer/PlaceholdersEditor.js +70 -0
  61. package/dist/editor/component-designer/RenderingsDropdown.js +25 -0
  62. package/dist/editor/component-designer/TemplateEditor.js +144 -0
  63. package/dist/editor/component-designer/aiContext.js +18 -0
  64. package/dist/editor/componentTreeHelper.js +97 -0
  65. package/dist/editor/control-center/ControlCenterMenu.js +59 -0
  66. package/dist/editor/control-center/IndexOverview.js +27 -0
  67. package/dist/editor/control-center/IndexSettings.js +106 -0
  68. package/dist/editor/control-center/Status.js +7 -0
  69. package/dist/editor/editor-warnings/ItemLocked.js +40 -0
  70. package/dist/editor/editor-warnings/NoLanguageWriteAccess.js +16 -0
  71. package/dist/editor/editor-warnings/NoWorkflowWriteAccess.js +16 -0
  72. package/dist/editor/editor-warnings/NoWriteAccess.js +14 -0
  73. package/dist/editor/editor-warnings/ValidationErrors.js +27 -0
  74. package/dist/editor/field-types/AttachmentEditor.js +7 -0
  75. package/dist/editor/field-types/CheckboxEditor.js +32 -0
  76. package/dist/editor/field-types/DropLinkEditor.js +51 -0
  77. package/dist/editor/field-types/DropListEditor.js +58 -0
  78. package/dist/editor/field-types/ImageFieldEditor.js +36 -0
  79. package/dist/editor/field-types/InternalLinkFieldEditor.js +64 -0
  80. package/dist/editor/field-types/LinkFieldEditor.js +58 -0
  81. package/dist/editor/field-types/MultiLineText.js +35 -0
  82. package/dist/editor/field-types/PictureFieldEditor.js +59 -0
  83. package/dist/editor/field-types/RawEditor.js +33 -0
  84. package/dist/editor/field-types/ReactQuill.js +366 -0
  85. package/dist/editor/field-types/RichTextEditor.js +46 -0
  86. package/dist/editor/field-types/RichTextEditorComponent.js +72 -0
  87. package/dist/editor/field-types/SingleLineText.js +92 -0
  88. package/dist/editor/field-types/TreeListEditor.js +137 -0
  89. package/dist/editor/fieldTypes.js +2 -0
  90. package/dist/editor/media-selector/AiImageSearch.js +110 -0
  91. package/dist/editor/media-selector/AiImageSearchPrompt.js +58 -0
  92. package/dist/editor/media-selector/MediaSelector.js +11 -0
  93. package/dist/editor/media-selector/Preview.js +9 -0
  94. package/dist/editor/media-selector/Thumbnails.js +11 -0
  95. package/dist/editor/media-selector/TreeSelector.js +171 -0
  96. package/dist/editor/media-selector/UploadZone.js +80 -0
  97. package/dist/editor/menubar/ActionsMenu.js +33 -0
  98. package/dist/editor/menubar/ActiveUsers.js +13 -0
  99. package/dist/editor/menubar/ApproveAndPublish.js +13 -0
  100. package/dist/editor/menubar/BrowseHistory.js +14 -0
  101. package/dist/editor/menubar/ItemLanguageVersion.js +36 -0
  102. package/dist/editor/menubar/LanguageSelector.js +33 -0
  103. package/dist/editor/menubar/Menu.js +65 -0
  104. package/dist/editor/menubar/NavButtons.js +43 -0
  105. package/dist/editor/menubar/PageSelector.js +50 -0
  106. package/dist/editor/menubar/PageViewerControls.js +37 -0
  107. package/dist/editor/menubar/Separator.js +8 -0
  108. package/dist/editor/menubar/SiteInfo.js +26 -0
  109. package/dist/editor/menubar/User.js +18 -0
  110. package/dist/editor/menubar/VersionSelector.js +49 -0
  111. package/dist/editor/page-editor-chrome/CommentHighlighting.js +214 -0
  112. package/dist/editor/page-editor-chrome/CommentHighlightings.js +17 -0
  113. package/dist/editor/page-editor-chrome/FieldActionIndicator.js +27 -0
  114. package/dist/editor/page-editor-chrome/FieldActionIndicators.js +15 -0
  115. package/dist/editor/page-editor-chrome/FieldEditedIndicator.js +27 -0
  116. package/dist/editor/page-editor-chrome/FieldEditedIndicators.js +15 -0
  117. package/dist/editor/page-editor-chrome/FrameMenu.js +178 -0
  118. package/dist/editor/page-editor-chrome/FrameMenus.js +24 -0
  119. package/dist/editor/page-editor-chrome/InlineEditor.js +101 -0
  120. package/dist/editor/page-editor-chrome/LockedFieldIndicator.js +35 -0
  121. package/dist/editor/page-editor-chrome/NoLayout.js +21 -0
  122. package/dist/editor/page-editor-chrome/PageEditorChrome.js +65 -0
  123. package/dist/editor/page-editor-chrome/PictureEditorOverlay.js +109 -0
  124. package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +82 -0
  125. package/dist/editor/page-editor-chrome/PlaceholderDropZones.js +147 -0
  126. package/dist/editor/page-viewer/DeviceToolbar.js +21 -0
  127. package/dist/editor/page-viewer/EditorForm.js +130 -0
  128. package/dist/editor/page-viewer/MiniMap.js +257 -0
  129. package/dist/editor/page-viewer/PageViewer.js +64 -0
  130. package/dist/editor/page-viewer/PageViewerFrame.js +696 -0
  131. package/dist/editor/page-viewer/pageViewContext.js +117 -0
  132. package/dist/editor/pageModel.js +2 -0
  133. package/dist/editor/picture-shared.js +28 -0
  134. package/dist/editor/reviews/Comment.js +112 -0
  135. package/dist/editor/reviews/Comments.js +24 -0
  136. package/dist/editor/reviews/PreviewInfo.js +13 -0
  137. package/dist/editor/reviews/Reviews.js +165 -0
  138. package/dist/editor/reviews/reviewCommands.js +44 -0
  139. package/dist/editor/reviews/useReviews.js +48 -0
  140. package/dist/editor/services/aiService.js +99 -0
  141. package/dist/editor/services/componentDesignerService.js +79 -0
  142. package/dist/editor/services/contentService.js +104 -0
  143. package/dist/editor/services/editService.js +322 -0
  144. package/dist/editor/services/indexService.js +25 -0
  145. package/dist/editor/services/reviewsService.js +43 -0
  146. package/dist/editor/services/serviceHelper.js +67 -0
  147. package/dist/editor/services/systemService.js +7 -0
  148. package/dist/editor/services/translationService.js +15 -0
  149. package/dist/editor/services-server/api.js +119 -0
  150. package/dist/editor/services-server/graphQL.js +56 -0
  151. package/dist/editor/sidebar/ComponentPalette.js +55 -0
  152. package/dist/editor/sidebar/ComponentTree.js +362 -0
  153. package/dist/editor/sidebar/Debug.js +60 -0
  154. package/dist/editor/sidebar/DictionaryEditor.js +160 -0
  155. package/dist/editor/sidebar/EditHistory.js +74 -0
  156. package/dist/editor/sidebar/GraphQL.js +115 -0
  157. package/dist/editor/sidebar/Insert.js +24 -0
  158. package/dist/editor/sidebar/MainContentTree.js +52 -0
  159. package/dist/editor/sidebar/Performance.js +34 -0
  160. package/dist/editor/sidebar/Sessions.js +31 -0
  161. package/dist/editor/sidebar/Sidebar.js +15 -0
  162. package/dist/editor/sidebar/SidebarView.js +76 -0
  163. package/dist/editor/sidebar/Translations.js +160 -0
  164. package/dist/editor/sidebar/Validation.js +52 -0
  165. package/dist/editor/sidebar/ViewSelector.js +15 -0
  166. package/dist/editor/sidebar/Workbox.js +80 -0
  167. package/dist/editor/ui/CenteredMessage.js +7 -0
  168. package/dist/editor/ui/CopyToClipboardButton.js +17 -0
  169. package/dist/editor/ui/DialogButtons.js +7 -0
  170. package/dist/editor/ui/Icons.js +75 -0
  171. package/dist/editor/ui/ItemNameDialog.js +45 -0
  172. package/dist/editor/ui/ItemNameDialogNew.js +61 -0
  173. package/dist/editor/ui/ItemSearch.js +93 -0
  174. package/dist/editor/ui/PerfectTree.js +223 -0
  175. package/dist/editor/ui/Section.js +12 -0
  176. package/dist/editor/ui/SimpleIconButton.js +11 -0
  177. package/dist/editor/ui/SimpleMenu.js +9 -0
  178. package/dist/editor/ui/SimpleTable.js +11 -0
  179. package/dist/editor/ui/SimpleTabs.js +21 -0
  180. package/dist/editor/ui/SimpleToolbar.js +7 -0
  181. package/dist/editor/ui/Spinner.js +7 -0
  182. package/dist/editor/ui/Splitter.js +187 -0
  183. package/dist/editor/ui/StackedPanels.js +69 -0
  184. package/dist/editor/ui/Toolbar.js +7 -0
  185. package/dist/editor/utils/id-helper.js +7 -0
  186. package/dist/editor/utils/insertOptions.js +45 -0
  187. package/dist/editor/utils/itemutils.js +25 -0
  188. package/dist/editor/utils/useMemoDebug.js +20 -0
  189. package/dist/editor/utils.js +328 -0
  190. package/dist/editor/views/CompareView.js +147 -0
  191. package/dist/editor/views/EditView.js +17 -0
  192. package/dist/editor/views/ItemEditor.js +24 -0
  193. package/dist/editor/views/SingleEditView.js +25 -0
  194. package/dist/index.js +22 -0
  195. package/dist/page-wizard/PageWizard.js +62 -0
  196. package/dist/page-wizard/SelectWizard.js +43 -0
  197. package/dist/page-wizard/WizardSteps.js +71 -0
  198. package/dist/page-wizard/service.js +26 -0
  199. package/dist/page-wizard/startPageWizardCommand.js +23 -0
  200. package/dist/page-wizard/steps/BuildPageStep.js +138 -0
  201. package/dist/page-wizard/steps/CollectStep.js +124 -0
  202. package/dist/page-wizard/steps/ComponentTypesSelector.js +211 -0
  203. package/dist/page-wizard/steps/Components.js +94 -0
  204. package/dist/page-wizard/steps/CreatePage.js +142 -0
  205. package/dist/page-wizard/steps/CreatePageAndLayoutStep.js +230 -0
  206. package/dist/page-wizard/steps/EditButton.js +7 -0
  207. package/dist/page-wizard/steps/FieldEditor.js +30 -0
  208. package/dist/page-wizard/steps/Generate.js +11 -0
  209. package/dist/page-wizard/steps/ImagesStep.js +159 -0
  210. package/dist/page-wizard/steps/LayoutStep.js +120 -0
  211. package/dist/page-wizard/steps/SelectStep.js +150 -0
  212. package/dist/page-wizard/steps/schema.js +140 -0
  213. package/dist/page-wizard/steps/usePageCreator.js +194 -0
  214. package/dist/splash-screen/NewPage.js +131 -0
  215. package/dist/splash-screen/SectionHeadline.js +9 -0
  216. package/dist/splash-screen/SplashScreen.js +81 -0
  217. package/dist/tour/Tour.js +321 -0
  218. package/dist/tour/default-tour.js +231 -0
  219. package/dist/tour/preview-tour.js +93 -0
  220. package/dist/tsconfig.build.tsbuildinfo +1 -0
  221. package/dist/types.js +2 -0
  222. package/package.json +1 -1
  223. package/src/editor/sidebar/ComponentTree.tsx +512 -512
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SplashScreen = SplashScreen;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const editContext_1 = require("../editor/client/editContext");
8
+ const SimpleTabs_1 = require("../editor/ui/SimpleTabs");
9
+ const ScrollingContentTree_1 = require("../editor/ScrollingContentTree");
10
+ const NewPage_1 = require("./NewPage");
11
+ const navigation_1 = require("next/navigation");
12
+ const SimpleIconButton_1 = require("../editor/ui/SimpleIconButton");
13
+ function SplashScreen() {
14
+ const savedHistory = typeof window !== "undefined"
15
+ ? localStorage.getItem("editor.browseHistory")
16
+ : null;
17
+ const [selectedPage, setSelectedPage] = (0, react_1.useState)(null);
18
+ const [activeTab, setActiveTab] = (0, react_1.useState)(0);
19
+ const editContext = (0, editContext_1.useEditContext)();
20
+ const recentPages = savedHistory
21
+ ? JSON.parse(savedHistory)
22
+ : [];
23
+ const searchParams = new URLSearchParams(window.location.search);
24
+ const [history, setHistory] = (0, react_1.useState)();
25
+ const router = (0, navigation_1.useRouter)();
26
+ const pathname = (0, navigation_1.usePathname)();
27
+ (0, react_1.useEffect)(() => {
28
+ const fetchItems = async () => {
29
+ const pages = await editContext?.itemsRepository.getItems(recentPages);
30
+ setHistory(pages);
31
+ };
32
+ fetchItems();
33
+ }, [editContext?.itemsRepository]);
34
+ (0, react_1.useEffect)(() => {
35
+ if (recentPages.length > 0 && recentPages[0])
36
+ setSelectedPage(recentPages[0]);
37
+ if (searchParams.get("create") === "1")
38
+ setActiveTab(1);
39
+ }, []);
40
+ (0, react_1.useEffect)(() => {
41
+ if (activeTab === 0) {
42
+ router.replace(pathname);
43
+ }
44
+ else {
45
+ router.replace(`${pathname}?create=1`);
46
+ }
47
+ }, [activeTab]);
48
+ if (searchParams.has("itemid"))
49
+ return;
50
+ const tabs = [
51
+ {
52
+ content: ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 gap-4 p-2 text-sm", children: [(0, jsx_runtime_1.jsx)("div", { className: "relative w-2/3", children: (0, jsx_runtime_1.jsx)(ScrollingContentTree_1.ScrollingContentTree, { selectedItemId: selectedPage?.id, onSelectionChange: (selection) => {
53
+ const selectedItem = selection[0];
54
+ if (selectedItem)
55
+ editContext?.loadItem({
56
+ id: selectedItem.id,
57
+ language: selectedItem.language ?? "en",
58
+ version: selectedItem.version,
59
+ });
60
+ } }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-1/3 flex-col border-l pl-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-3 font-bold", children: "Recent Pages" }), (0, jsx_runtime_1.jsx)("div", { className: "relative flex-1", children: (0, jsx_runtime_1.jsx)("ul", { className: "absolute inset-0 overflow-auto", children: history?.map((page, index) => ((0, jsx_runtime_1.jsxs)("li", { onMouseOver: () => setSelectedPage(page), onClick: () => {
61
+ editContext?.switchView("page-editor");
62
+ editContext?.loadItem({
63
+ id: page.id,
64
+ language: page.language ?? "en",
65
+ version: 0,
66
+ });
67
+ }, className: "flex cursor-pointer items-center gap-2 p-2 text-xs hover:bg-gray-100", children: [page.icon && ((0, jsx_runtime_1.jsx)("img", { src: page.icon, width: "16", height: "16" })), " ", page.name, " ", (0, jsx_runtime_1.jsxs)("span", { className: "text-gray-500", children: ["(", page.language, ")"] })] }, index))) }) })] })] })),
68
+ label: "Open Page",
69
+ id: "open-page-tab",
70
+ },
71
+ {
72
+ content: ((0, jsx_runtime_1.jsx)("div", { className: "relative flex flex-1 flex-col", children: (0, jsx_runtime_1.jsx)(NewPage_1.NewPage, { selectedItemId: selectedPage?.id }) })),
73
+ label: "New Page",
74
+ id: "new-page-tab",
75
+ testId: "new-page-tab",
76
+ },
77
+ ];
78
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex h-full items-center justify-center bg-gray-100", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative h-3/4 w-2/3 space-y-8 rounded-lg bg-white p-6 p-8 shadow-lg", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col", children: (0, jsx_runtime_1.jsx)(SimpleTabs_1.SimpleTabs, { tabs: tabs, activeTab: activeTab, setActiveTab: setActiveTab }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end", children: (0, jsx_runtime_1.jsxs)("a", { className: "flex cursor-pointer items-center text-xs text-blue-600", onClick: () => editContext?.startTour(), children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-arrow-right mr-2" }), " Take Tour"] }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "absolute top-0 right-0 p-2", children: (0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: "pi pi-times", onClick: () => editContext?.switchView(editContext.contentEditorItem?.hasLayout
79
+ ? "page-editor"
80
+ : "content-editor"), label: "Close" }) })] }) }));
81
+ }
@@ -0,0 +1,321 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tour = Tour;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const client_components_1 = require("../client-components");
7
+ const utils_1 = require("primereact/utils");
8
+ function Tour({ tourStopCallback }) {
9
+ const [currentStep, setCurrentStep] = (0, react_1.useState)("start-tour");
10
+ const [show, setShow] = (0, react_1.useState)(true);
11
+ const editContext = (0, client_components_1.useEditContext)();
12
+ const [focusRect, setFocusRect] = (0, react_1.useState)(null);
13
+ const [pointToRect, setPointToRect] = (0, react_1.useState)(null);
14
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
15
+ const waitForElement = (selector, timeout = 0) => {
16
+ if (selector.startsWith("iframe:")) {
17
+ return waitForElementInIframe(selector.substring(7), timeout);
18
+ }
19
+ return new Promise((resolve) => {
20
+ const startTime = Date.now();
21
+ const checkForElement = () => {
22
+ const element = document.querySelector(selector);
23
+ if (element) {
24
+ let rect = element.getBoundingClientRect();
25
+ const extendFocus = step?.extendFocus || 10;
26
+ rect = new DOMRect(rect.left - extendFocus / 2, rect.top - extendFocus / 2, rect.width + extendFocus, rect.height + extendFocus);
27
+ resolve(rect);
28
+ }
29
+ else if (timeout > 0 && Date.now() - startTime >= timeout) {
30
+ resolve(undefined);
31
+ }
32
+ else {
33
+ requestAnimationFrame(checkForElement);
34
+ }
35
+ };
36
+ checkForElement();
37
+ });
38
+ };
39
+ const waitForElementInIframe = (selector, timeout = 0) => {
40
+ return new Promise((resolve, reject) => {
41
+ const startTime = Date.now();
42
+ const checkForElement = () => {
43
+ const iframe = document.querySelector("iframe.page-iframe");
44
+ if (iframe && iframe.contentDocument) {
45
+ const element = iframe.contentDocument.querySelector(selector);
46
+ if (element) {
47
+ const elementRect = element.getBoundingClientRect();
48
+ const iframeRect = iframe.getBoundingClientRect();
49
+ let rect = new DOMRect(elementRect.left + iframeRect.left, elementRect.top + iframeRect.top, elementRect.width, elementRect.height);
50
+ const extendFocus = step?.extendFocus || 10;
51
+ rect = new DOMRect(rect.left - extendFocus / 2, rect.top - extendFocus / 2, rect.width + extendFocus, rect.height + extendFocus);
52
+ resolve(rect);
53
+ }
54
+ else if (timeout > 0 && Date.now() - startTime >= timeout) {
55
+ resolve(undefined);
56
+ }
57
+ else {
58
+ requestAnimationFrame(checkForElement);
59
+ }
60
+ }
61
+ else if (Date.now() - startTime >= timeout) {
62
+ reject(new Error(`Timeout waiting for iframe: ${selector}`));
63
+ }
64
+ else {
65
+ requestAnimationFrame(checkForElement);
66
+ }
67
+ };
68
+ checkForElement();
69
+ });
70
+ };
71
+ const waitForElementToDisappear = (selector) => {
72
+ return new Promise((resolve) => {
73
+ const checkForElement = () => {
74
+ const element = document.querySelector(selector);
75
+ if (!element) {
76
+ resolve();
77
+ }
78
+ else {
79
+ requestAnimationFrame(checkForElement);
80
+ }
81
+ };
82
+ checkForElement();
83
+ });
84
+ };
85
+ const waitForInput = (selector, minNumberOfCharacters = 1) => {
86
+ return new Promise((resolve) => {
87
+ const checkForInput = () => {
88
+ const input = document.querySelector(selector);
89
+ let inputValue = "";
90
+ if (input?.getAttribute("contenteditable")) {
91
+ console.log("contenteditable", input.innerText);
92
+ inputValue = input.innerText;
93
+ }
94
+ else if (input &&
95
+ input.value.length >= minNumberOfCharacters) {
96
+ inputValue = input.value;
97
+ }
98
+ if (inputValue.length >= minNumberOfCharacters) {
99
+ console.log("input found", inputValue);
100
+ resolve();
101
+ }
102
+ else {
103
+ requestAnimationFrame(checkForInput);
104
+ }
105
+ };
106
+ checkForInput();
107
+ });
108
+ };
109
+ function setNativeValue(element, value) {
110
+ const valueSetter = Object.getOwnPropertyDescriptor(element.constructor.prototype, "value")?.set;
111
+ const prototype = Object.getPrototypeOf(element);
112
+ const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, "value")?.set;
113
+ if (valueSetter && valueSetter !== prototypeValueSetter) {
114
+ prototypeValueSetter?.call(element, value);
115
+ }
116
+ else {
117
+ valueSetter?.call(element, value);
118
+ }
119
+ const event = new Event("input", { bubbles: true });
120
+ element.dispatchEvent(event);
121
+ }
122
+ async function simulateTyping(element, text, interval = 35) {
123
+ let i = 0;
124
+ while (i <= text.length) {
125
+ const currentText = text.substring(0, i);
126
+ setNativeValue(element, currentText);
127
+ i++;
128
+ const randomDelay = interval * (0.5 + Math.random());
129
+ await delay(randomDelay);
130
+ }
131
+ }
132
+ /**
133
+ * Stops the tour and resets the state.
134
+ */
135
+ const stopTour = () => {
136
+ setCurrentStep("start-tour");
137
+ setFocusRect(null);
138
+ tourStopCallback();
139
+ };
140
+ const tours = editContext.configuration.tours;
141
+ const tour = tours[editContext.configuration.activeTour];
142
+ const tourSteps = tour.getSteps({
143
+ editContext: editContext,
144
+ nextStep: (stepId) => setCurrentStep(stepId),
145
+ stopTour: () => tourStopCallback(),
146
+ waitForElement,
147
+ waitForElementToDisappear,
148
+ setFocusRect,
149
+ delay,
150
+ waitForInput: waitForInput,
151
+ simulateTyping,
152
+ });
153
+ const step = tourSteps[currentStep];
154
+ if (!step)
155
+ return null;
156
+ (0, react_1.useEffect)(() => {
157
+ const runStep = async () => {
158
+ setShow(false);
159
+ setFocusRect(null);
160
+ await delay(500);
161
+ const step = tourSteps[currentStep];
162
+ if (!step)
163
+ return;
164
+ console.log("step", currentStep, step);
165
+ if (step.prepareAction) {
166
+ await step.prepareAction();
167
+ }
168
+ if (step.focusElement) {
169
+ const rect = await waitForElement(step.focusElement, 5000);
170
+ if (!rect)
171
+ setCurrentStep("error");
172
+ else
173
+ setFocusRect(rect);
174
+ }
175
+ setShow(true);
176
+ if (step.waitForUserInput) {
177
+ const nextStep = (await step.waitForUserInput()) || step.nextStep;
178
+ if (nextStep) {
179
+ setCurrentStep(nextStep);
180
+ }
181
+ else
182
+ console.log("no next step defined for step", currentStep);
183
+ }
184
+ else {
185
+ if (step.waitForElement) {
186
+ await waitForElement(step.waitForElement);
187
+ if (step.nextStep) {
188
+ setCurrentStep(step.nextStep);
189
+ }
190
+ }
191
+ }
192
+ };
193
+ runStep();
194
+ }, [currentStep]);
195
+ (0, react_1.useEffect)(() => {
196
+ const getPointTo = async () => {
197
+ let pointToRect = focusRect;
198
+ if (step.getPointTo) {
199
+ const pointTo = step.getPointTo();
200
+ if (pointTo) {
201
+ pointToRect = pointTo;
202
+ }
203
+ }
204
+ if (step.pointToElement) {
205
+ const rect = await waitForElement(step.pointToElement, 5000);
206
+ if (rect) {
207
+ pointToRect = rect;
208
+ }
209
+ }
210
+ setPointToRect(pointToRect);
211
+ };
212
+ getPointTo();
213
+ }, [focusRect, currentStep]);
214
+ if (!step) {
215
+ throw new Error(`Tour step ${currentStep} not found`);
216
+ }
217
+ const bubblePosition = step.bubblePosition || "right";
218
+ const bubbleStyle = {};
219
+ let boxStyle = {
220
+ position: "fixed",
221
+ left: "50%",
222
+ top: "50%",
223
+ transform: "translate(-50%, -50%)",
224
+ };
225
+ let arrowStyle = {};
226
+ if (pointToRect) {
227
+ if (bubblePosition === "right") {
228
+ boxStyle = {
229
+ position: "absolute",
230
+ left: pointToRect.left + pointToRect.width,
231
+ top: pointToRect.top - 10,
232
+ alignItems: "flex-start",
233
+ };
234
+ arrowStyle = {
235
+ marginLeft: "-20px",
236
+ };
237
+ bubbleStyle.marginLeft = "80px";
238
+ bubbleStyle.marginTop = "-20px";
239
+ }
240
+ if (bubblePosition === "left") {
241
+ boxStyle = {
242
+ position: "absolute",
243
+ right: window.innerWidth - pointToRect.left,
244
+ top: pointToRect.top + pointToRect.height / 2,
245
+ alignItems: "flex-end",
246
+ };
247
+ arrowStyle = {
248
+ marginRight: "-20px",
249
+ };
250
+ }
251
+ if (bubblePosition === "bottom") {
252
+ boxStyle = {
253
+ position: "absolute",
254
+ left: pointToRect.left + pointToRect.width / 2,
255
+ top: pointToRect.top + pointToRect.height,
256
+ transform: "translate(-50%, 0)",
257
+ };
258
+ if (step.flipArrow) {
259
+ arrowStyle = {
260
+ transform: "scaleX(-1)",
261
+ };
262
+ }
263
+ }
264
+ if (bubblePosition === "top-right") {
265
+ boxStyle = {
266
+ position: "absolute",
267
+ left: pointToRect.left + pointToRect.width,
268
+ bottom: window.innerHeight - pointToRect.top,
269
+ transform: "translate(-50%, 0)",
270
+ flexDirection: "column-reverse",
271
+ };
272
+ arrowStyle = {
273
+ transform: "rotate(180deg)",
274
+ };
275
+ if (step.flipArrow) {
276
+ arrowStyle = {
277
+ transform: "scaleX(-1)",
278
+ };
279
+ }
280
+ }
281
+ }
282
+ const arrowRotation = bubblePosition === "right" ? "-a-rotate-90" : "";
283
+ const overlayStyle = {
284
+ position: "fixed",
285
+ top: 0,
286
+ left: 0,
287
+ width: "100%",
288
+ height: "100%",
289
+ backgroundColor: "rgba(0, 0, 0, 0.3)",
290
+ pointerEvents: "auto",
291
+ clipPath: focusRect
292
+ ? `polygon(0% 0%, 0% 100%, ${focusRect.left}px 100%, ${focusRect.left}px ${focusRect.top}px, ${focusRect.left + focusRect.width}px ${focusRect.top}px, ${focusRect.left + focusRect.width}px ${focusRect.top + focusRect.height}px, ${focusRect.left}px ${focusRect.top + focusRect.height}px, ${focusRect.left}px 100%, 100% 100%, 100% 0%)`
293
+ : "none",
294
+ // clipPath: focusPosition
295
+ // ? `path('M 0 0 H 100% V 100% H 0 Z M ${focusPosition.left}px ${focusPosition.top}px H ${focusPosition.left + focusPosition.width}px V ${focusPosition.top + focusPosition.height}px H ${focusPosition.left}px Z')`
296
+ // : 'none',
297
+ };
298
+ if (!show) {
299
+ return (0, jsx_runtime_1.jsx)("div", { className: "overlay", style: overlayStyle });
300
+ }
301
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "overlay", style: overlayStyle }), (0, jsx_runtime_1.jsxs)("div", { style: boxStyle, className: "text-gray-800 flex flex-col items-center fade-in", children: [focusRect && ((0, jsx_runtime_1.jsx)("svg", { width: "100px", height: "100px", viewBox: "0 -7.89 113.08 113.08", xmlns: "http://www.w3.org/2000/svg", className: (0, utils_1.classNames)("pointer-events-none", arrowRotation), style: arrowStyle, children: (0, jsx_runtime_1.jsx)("path", { style: { stroke: "#0000ff", fill: "#0000ff" }, d: "M20.1871 175C15.7485 172.891 13.0008 172.469 12.1553 170.992C8.98489 165.508 5.39173 160.024 3.70083 153.908C-1.37187 137.666 -0.737781 121.214 2.64402 104.762C8.35081 76.7092 21.0325 51.8201 36.8847 28.1966C38.5756 25.6655 40.0552 23.1344 41.7461 20.3924C41.7461 20.1814 41.5347 19.7596 41.112 19.1268C36.462 20.3923 31.6007 21.6579 26.9507 22.7125C24.4144 23.1344 21.4552 23.1344 18.9189 22.2907C17.4394 21.8688 15.3258 19.5486 15.3258 18.0722C15.3258 16.1739 16.8053 13.8537 18.0735 12.1663C19.1303 11.1117 21.0326 10.9008 22.7235 10.4789C35.4052 7.31508 48.087 3.72935 60.9801 0.776411C71.9709 -1.75468 75.564 1.83105 74.9299 12.5882C74.2959 23.7672 74.0845 34.9462 73.6618 45.9142C73.4505 49.289 72.8164 52.8747 72.3936 56.6714C63.5164 52.6638 63.5164 52.6638 60.346 18.494C47.0301 33.2588 38.1529 49.289 29.9098 65.7411C21.6666 82.1932 16.1712 99.489 13.2121 117.839C10.2531 136.823 13.8462 154.751 20.1871 175Z", fill: "#0D1927" }) })), (0, jsx_runtime_1.jsx)("style", { children: `
302
+ @import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&display=swap');
303
+ .handwritten {
304
+ font-family: 'Caveat', cursive;
305
+ }
306
+ .fade-background {
307
+ background: radial-gradient(circle, rgba(255,255,255,0.8) 60%, rgba(255,255,255,0) 90%);
308
+ }
309
+ .fade-in {
310
+ animation: fadeIn 0.5s ease-in-out;
311
+ }
312
+ @keyframes fadeIn {
313
+ from { opacity: 0; }
314
+ to { opacity: 1; }
315
+ }
316
+ ` }), (0, jsx_runtime_1.jsxs)("div", { className: `relative flex items-stretch justify-center bg-gray-50 rounded-lg border border-gray-800 gap-6 shadow-2xl`, style: bubbleStyle, children: [(0, jsx_runtime_1.jsx)("div", { className: "text-xs font-bold cursor-pointer flex items-center gap-2 absolute top-0 right-0 mr-2 mt-2", onClick: stopTour, children: (0, jsx_runtime_1.jsx)("i", { className: "pi pi-times" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-center justify-center gap-2 bg-gray-200 p-6 rounded-l-lg", children: (0, jsx_runtime_1.jsx)(AlpacaIcon, {}) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end justify-center gap-3 p-4 ", children: [(0, jsx_runtime_1.jsxs)("div", { className: "opacity-100 text-2xl font-bold handwritten text-center flex flex-col items-center max-w-[450px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-4xl mb-4", children: step.title }), (0, jsx_runtime_1.jsx)("div", { children: step.description })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex gap-2", children: step.buttons &&
317
+ step.buttons.map((button, index) => ((0, jsx_runtime_1.jsx)("button", { onClick: button.onClick, className: button.className, children: button.label }, index))) })] })] })] })] }));
318
+ }
319
+ function AlpacaIcon() {
320
+ return ((0, jsx_runtime_1.jsxs)("svg", { height: "80px", width: "80px", version: "1.1", id: "Layer_1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", children: [(0, jsx_runtime_1.jsx)("path", { style: { fill: "#EBE4DD" }, d: "M102.989,153.011v153.011C119.613,428.825,184.332,506.115,256,506.115\r\n\ts136.387-77.29,153.012-200.092V153.011H102.989z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#D8CCBC" }, d: "M255.999,153.011v353.103H256c71.668,0,136.387-77.29,153.012-200.092V153.011H255.999z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#A58868" }, d: "M273.655,435.494h-35.31c0,41.195-17.007,41.195-29.425,41.195V512\r\n\tc16.246,0,34.206-4.021,47.08-18.162C268.873,507.979,286.834,512,303.08,512v-35.31C290.662,476.69,273.655,476.69,273.655,435.494\r\n\tz" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#947859" }, d: "M273.655,435.494H256v58.343C268.873,507.979,286.834,512,303.08,512v-35.31\r\n\tC290.662,476.69,273.655,476.69,273.655,435.494z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#EBE4DD" }, d: "M126.529,0C81.025,0,44.138,36.888,44.138,82.391s36.888,82.391,82.391,82.391V0z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#D8CCBC" }, d: "M385.471,164.782c45.503,0,82.391-36.888,82.391-82.391S430.975,0,385.471,0V164.782z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#BFA993" }, d: "M490.407,247.172c0.643-3.83,0.996-7.758,0.996-11.77c0-39.003-31.618-70.621-70.621-70.621\r\n\ts-70.621,31.618-70.621,70.621c0,4.012,0.352,7.94,0.995,11.77H490.407z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#EDEDED" }, d: "M420.782,306.023c39.003,0,70.621-31.618,70.621-70.621H350.161\r\n\tC350.161,274.405,381.779,306.023,420.782,306.023z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#454449" }, d: "M397.241,235.401c0,12.981,10.559,23.54,23.538,23.54h0.002c12.981,0.001,23.54-10.559,23.54-23.54\r\n\tH397.241z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#BFA993" }, d: "M160.844,247.172c0.643-3.83,0.995-7.758,0.995-11.77c0-39.003-31.618-70.621-70.621-70.621\r\n\tS20.598,196.4,20.598,235.402c0,4.012,0.352,7.94,0.995,11.77H160.844z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#EDEDED" }, d: "M91.218,306.023c39.003,0,70.621-31.618,70.621-70.621H20.598\r\n\tC20.598,274.405,52.216,306.023,91.218,306.023z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#454449" }, d: "M67.678,235.401c0,12.981,10.559,23.54,23.538,23.54h0.002c12.981,0.001,23.54-10.559,23.54-23.54\r\n\tH67.678z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#D8CCBC" }, d: "M391.356,107.187c0-15.527,4.902-33.778-5.082-46.69c-8.818-11.403-28.519-12.694-43.229-20.793\r\n\tc-12.822-7.059-23.38-23.527-39.415-27.235c-14.505-3.356-31.411,6.442-47.63,6.442c-16.218,0-33.125-9.796-47.631-6.442\r\n\tc-16.036,3.708-26.595,20.178-39.415,27.237c-14.71,8.099-34.41,9.391-43.227,20.792c-9.985,12.912-5.082,31.161-5.082,46.689\r\n\ts-4.902,33.778,5.082,46.69c8.818,11.403,28.519,12.693,43.229,20.793c12.821,7.059,23.379,23.527,39.413,27.235\r\n\tc14.505,3.356,31.412-6.442,47.63-6.442s33.125,9.796,47.632,6.442c16.034-3.708,26.592-20.176,39.413-27.237\r\n\tc14.709-8.099,34.411-9.391,43.228-20.792C396.259,140.965,391.356,122.715,391.356,107.187z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#BFA993" }, d: "M386.274,60.497c-8.818-11.403-28.519-12.694-43.229-20.793\r\n\tc-12.822-7.059-23.38-23.527-39.415-27.235c-14.505-3.356-31.411,6.442-47.63,6.442v176.552c16.218,0,33.125,9.796,47.632,6.442\r\n\tc16.034-3.708,26.592-20.176,39.413-27.237c14.709-8.099,34.411-9.391,43.228-20.792c9.985-12.912,5.082-31.161,5.082-46.689\r\n\tS396.259,73.409,386.274,60.497z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#58575D" }, d: "M293.664,406.069c-6.186,18.772-22.763,39.469-37.664,39.784\r\n\tc-14.901-0.315-31.478-21.012-37.664-39.784c-2.858-9.591,4.529-17.529,16.478-17.655c14.124,0,28.248,0,42.372,0\r\n\tC289.136,388.54,296.522,396.476,293.664,406.069z" }), (0, jsx_runtime_1.jsx)("path", { style: { fill: "#454449" }, d: "M277.186,388.414c-7.062,0-14.124,0-21.186,0v57.439c14.901-0.315,31.478-21.012,37.664-39.784\r\n\tC296.522,396.476,289.136,388.54,277.186,388.414z" })] }));
321
+ }
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultTourSteps = getDefaultTourSteps;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function getDefaultTourSteps({ editContext, nextStep, stopTour, waitForElement, waitForElementToDisappear, setFocusRect, delay, waitForInput, simulateTyping, }, config) {
6
+ const tourSteps = {
7
+ "start-tour": {
8
+ title: "Welcome to the AI Editor Tour!",
9
+ description: "I will show you around the editor and how to use the most important features.",
10
+ prepareAction: async () => {
11
+ editContext?.openSplashScreen();
12
+ },
13
+ buttons: [
14
+ {
15
+ label: ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-play" }), " Start Tour"] })),
16
+ onClick: () => {
17
+ nextStep("new-page");
18
+ },
19
+ className: "button button-primary mt-2",
20
+ },
21
+ {
22
+ label: ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-times" }), " No thanks"] })),
23
+ onClick: () => {
24
+ stopTour();
25
+ },
26
+ className: "button button-secondary mt-2",
27
+ },
28
+ ],
29
+ },
30
+ "new-page": {
31
+ description: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Click on the ", (0, jsx_runtime_1.jsx)("b", { children: "New Page" }), " tab to create a new page"] })),
32
+ focusElement: "#new-page-tab",
33
+ waitForUserInput: async () => {
34
+ await waitForElement("#new-page-tab.active-tab");
35
+ },
36
+ nextStep: "pick-location",
37
+ },
38
+ "pick-location": {
39
+ description: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select the ", (0, jsx_runtime_1.jsx)("b", { children: "Playground" }), " folder as the parent for your new page"] })),
40
+ focusElement: ".tour-pick-location",
41
+ waitForUserInput: async () => {
42
+ await new Promise((resolve) => {
43
+ const checkForElement = () => {
44
+ const elements = document.querySelectorAll(".p-highlight");
45
+ for (const element of elements) {
46
+ if (element.textContent?.trim() === "Playground") {
47
+ setFocusRect(element.getBoundingClientRect());
48
+ resolve();
49
+ return;
50
+ }
51
+ }
52
+ requestAnimationFrame(checkForElement);
53
+ };
54
+ checkForElement();
55
+ });
56
+ },
57
+ getPointTo: () => {
58
+ const elements = document.querySelectorAll(".p-treenode-label");
59
+ for (const element of elements) {
60
+ if (element.textContent?.trim() === "Playground") {
61
+ return element.getBoundingClientRect();
62
+ }
63
+ }
64
+ return undefined;
65
+ },
66
+ nextStep: "choose-template",
67
+ },
68
+ "choose-template": {
69
+ description: "Select a template for your page",
70
+ focusElement: ".tour-choose-template",
71
+ waitForUserInput: async () => {
72
+ await waitForElement(".tour-selected-template");
73
+ },
74
+ bubblePosition: "left",
75
+ nextStep: "enter-name",
76
+ },
77
+ "enter-name": {
78
+ description: "Enter a name for your page",
79
+ focusElement: "#new-page-name",
80
+ bubblePosition: "left",
81
+ waitForUserInput: async () => {
82
+ await waitForElement("#create-new-page-button:not(.p-disabled)");
83
+ },
84
+ nextStep: "create-page",
85
+ },
86
+ "create-page": {
87
+ description: "Click the Create button",
88
+ focusElement: "#create-new-page-button",
89
+ waitForUserInput: async () => {
90
+ await waitForElement("#insert-component-button");
91
+ },
92
+ nextStep: "ready-to-add-component",
93
+ },
94
+ "ready-to-add-component": {
95
+ description: "Wanna add a component to your beautiful empty page?",
96
+ buttons: [
97
+ {
98
+ label: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-arrow-right" }), " I'm ready, lets go!"] })),
99
+ onClick: () => nextStep("insert-component"),
100
+ },
101
+ ],
102
+ },
103
+ "insert-component": {
104
+ description: "Excellent, click on the plus button to insert a component.",
105
+ focusElement: "#insert-component-button",
106
+ waitForUserInput: async () => {
107
+ await waitForElement(".tour-component-palette");
108
+ },
109
+ nextStep: "drag-component",
110
+ },
111
+ "drag-component": {
112
+ description: `Drag and drop a ${config.firstComponentTemplateName} component to your page.`,
113
+ focusElement: `#insert-component-${config.firstComponentTemplateId}`,
114
+ waitForUserInput: async () => {
115
+ await waitForElement(".tour-placeholder-dropzone");
116
+ },
117
+ nextStep: "drop-component-on-placeholder",
118
+ },
119
+ "drop-component-on-placeholder": {
120
+ description: "Drop the component onto this placeholder!",
121
+ focusElement: ".tour-placeholder-dropzone",
122
+ bubblePosition: "left",
123
+ extendFocus: 70,
124
+ waitForUserInput: async () => {
125
+ await waitForElementToDisappear(".tour-placeholder-dropzone");
126
+ await delay(400);
127
+ if (!document.querySelector(".tour-component-palette")) {
128
+ return "enter-title";
129
+ }
130
+ return "drag-component";
131
+ },
132
+ nextStep: "enter-title",
133
+ },
134
+ "enter-title": {
135
+ description: `Excellent! Now lets fill in the fields. First enter a ${config.firstComponentTextFieldName}`,
136
+ focusElement: `[data-field-id='${config.firstComponentTextFieldId}']`,
137
+ waitForUserInput: async () => {
138
+ await delay(5000);
139
+ await waitForInput(`[data-field-id='${config.firstComponentTextFieldId}'] input`, 5);
140
+ },
141
+ nextStep: "see-content-update",
142
+ },
143
+ "see-content-update": {
144
+ description: "See how the content is automatically updating on your page?",
145
+ focusElement: `[data-field-id='${config.firstComponentTextFieldId}']`,
146
+ pointToElement: `iframe:[data-fieldid='${config.firstComponentTextFieldId}']`,
147
+ bubblePosition: "bottom",
148
+ flipArrow: true,
149
+ waitForUserInput: async () => {
150
+ await delay(5000);
151
+ await waitForInput(`[data-field-id='${config.firstComponentTextFieldId}'] input`, 5);
152
+ },
153
+ nextStep: "edit-content-inline",
154
+ },
155
+ "edit-content-inline": {
156
+ description: "You can also directly edit the content on the page. Click on the [Introduction] placeholder here and start typing!",
157
+ focusElement: `iframe:[data-fieldid='${config.firstComponentRichTextFieldId}']`,
158
+ bubblePosition: "bottom",
159
+ flipArrow: true,
160
+ waitForUserInput: async () => {
161
+ await delay(5000);
162
+ await waitForInput(`[data-field-id='${config.firstComponentRichTextFieldId}'] [contenteditable]`, 5);
163
+ },
164
+ nextStep: "ai-intro",
165
+ },
166
+ "ai-intro": {
167
+ description: "But hey, this is an AI editor, so why not let the AI do some of the work for you?",
168
+ buttons: [
169
+ {
170
+ label: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-arrow-right" }), " Great, show me!"] })),
171
+ onClick: () => nextStep("ai-sidebar"),
172
+ },
173
+ ],
174
+ },
175
+ "ai-sidebar": {
176
+ description: "Click on the AI sidebar to open the AI chat.",
177
+ focusElement: `[data-sidebarview-name='ai']`,
178
+ nextStep: "ai-terminal",
179
+ waitForElement: "[data-sidebarview-name='ai'].a-active",
180
+ },
181
+ "ai-terminal": {
182
+ description: "Let me take control and add tell the AI to add some more components.",
183
+ focusElement: `.tour-ai-terminal textarea`,
184
+ waitForUserInput: async () => {
185
+ await delay(1000);
186
+ const aiTerminal = document.querySelector(".tour-ai-terminal textarea");
187
+ if (aiTerminal) {
188
+ aiTerminal.focus();
189
+ await simulateTyping(aiTerminal, `Plase add three components of type ${config.firstComponentTemplateName} with some funny dummy content to the page.`);
190
+ }
191
+ },
192
+ bubblePosition: "top-right",
193
+ nextStep: "ai-submit",
194
+ },
195
+ "ai-submit": {
196
+ description: "Click on the Send button to submit the prompt to the AI.",
197
+ focusElement: ".tour-ai-terminal .tour-send-button",
198
+ bubblePosition: "top-right",
199
+ nextStep: "ai-watch-components-added",
200
+ waitForElement: ".tour-ai-terminal .a-prompt",
201
+ },
202
+ "ai-watch-components-added": {
203
+ description: "Watch how the AI adds the components to the page. This can take a few seconds.",
204
+ focusElement: ".tour-ai-terminal",
205
+ pointToElement: ".tour-ai-terminal .a-prompt",
206
+ waitForElement: ".tour-ai-response-message-changes",
207
+ nextStep: "congratulations",
208
+ },
209
+ congratulations: {
210
+ title: "Congratulations!",
211
+ description: "You have completed the tour and are now an AI Editor Pro!",
212
+ buttons: [
213
+ {
214
+ label: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-check" }), " Finish Tour"] })),
215
+ onClick: () => stopTour(),
216
+ className: "button button-primary mt-2",
217
+ },
218
+ ],
219
+ },
220
+ error: {
221
+ description: "Oops, something went wrong.",
222
+ buttons: [
223
+ {
224
+ label: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-check" }), " Close"] })),
225
+ onClick: () => stopTour(),
226
+ },
227
+ ],
228
+ },
229
+ };
230
+ return tourSteps;
231
+ }