camox 0.0.0 → 0.1.2-alpha.2

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 (255) hide show
  1. package/LICENSE.md +110 -0
  2. package/dist/components/AuthGate.d.ts +7 -0
  3. package/dist/components/AuthGate.d.ts.map +1 -0
  4. package/dist/core/components/AddBlockControlBar.d.ts +9 -0
  5. package/dist/core/components/AddBlockControlBar.d.ts.map +1 -0
  6. package/dist/core/components/AddBlockControlBar.js +65 -0
  7. package/dist/core/components/lexical/InlineContentEditable.d.ts +7 -0
  8. package/dist/core/components/lexical/InlineContentEditable.d.ts.map +1 -0
  9. package/dist/core/components/lexical/InlineContentEditable.js +40 -0
  10. package/dist/core/components/lexical/InlineLexicalEditor.d.ts +12 -0
  11. package/dist/core/components/lexical/InlineLexicalEditor.d.ts.map +1 -0
  12. package/dist/core/components/lexical/InlineLexicalEditor.js +133 -0
  13. package/dist/core/components/lexical/InlineParagraphNode.d.ts +10 -0
  14. package/dist/core/components/lexical/InlineParagraphNode.d.ts.map +1 -0
  15. package/dist/core/components/lexical/InlineParagraphNode.js +34 -0
  16. package/dist/core/components/lexical/SelectionBroadcaster.d.ts +6 -0
  17. package/dist/core/components/lexical/SelectionBroadcaster.d.ts.map +1 -0
  18. package/dist/core/components/lexical/SelectionBroadcaster.js +62 -0
  19. package/dist/core/components/lexical/SidebarLexicalEditor.d.ts +9 -0
  20. package/dist/core/components/lexical/SidebarLexicalEditor.d.ts.map +1 -0
  21. package/dist/core/components/lexical/editorConfig.d.ts +4 -0
  22. package/dist/core/components/lexical/editorConfig.d.ts.map +1 -0
  23. package/dist/core/components/lexical/editorConfig.js +24 -0
  24. package/dist/core/createApp.d.ts +373 -0
  25. package/dist/core/createApp.d.ts.map +1 -0
  26. package/dist/core/createApp.js +40 -0
  27. package/dist/core/createBlock.d.ts +947 -0
  28. package/dist/core/createBlock.d.ts.map +1 -0
  29. package/dist/core/createBlock.js +873 -0
  30. package/dist/core/createLayout.d.ts +78 -0
  31. package/dist/core/createLayout.d.ts.map +1 -0
  32. package/dist/core/createLayout.js +73 -0
  33. package/dist/core/hooks/useFieldSelection.d.ts +11 -0
  34. package/dist/core/hooks/useFieldSelection.d.ts.map +1 -0
  35. package/dist/core/hooks/useFieldSelection.js +25 -0
  36. package/dist/core/hooks/useIsEditable.d.ts +2 -0
  37. package/dist/core/hooks/useIsEditable.d.ts.map +1 -0
  38. package/dist/core/hooks/useIsEditable.js +12 -0
  39. package/dist/core/hooks/useOverlayMessage.d.ts +10 -0
  40. package/dist/core/hooks/useOverlayMessage.d.ts.map +1 -0
  41. package/dist/core/hooks/useOverlayMessage.js +37 -0
  42. package/dist/core/lib/contentType.d.ts +165 -0
  43. package/dist/core/lib/contentType.d.ts.map +1 -0
  44. package/dist/core/lib/contentType.js +148 -0
  45. package/dist/core/lib/fieldTypes.d.ts +85 -0
  46. package/dist/core/lib/fieldTypes.d.ts.map +1 -0
  47. package/dist/core/lib/lexicalReact.d.ts +3 -0
  48. package/dist/core/lib/lexicalReact.d.ts.map +1 -0
  49. package/dist/core/lib/lexicalReact.js +24 -0
  50. package/dist/core/lib/lexicalState.d.ts +10 -0
  51. package/dist/core/lib/lexicalState.d.ts.map +1 -0
  52. package/dist/core/lib/lexicalState.js +38 -0
  53. package/dist/core/lib/modifierFormats.d.ts +9 -0
  54. package/dist/core/lib/modifierFormats.d.ts.map +1 -0
  55. package/dist/core/lib/modifierFormats.js +8 -0
  56. package/dist/core/lib/modifiers.d.ts +12 -0
  57. package/dist/core/lib/modifiers.d.ts.map +1 -0
  58. package/dist/core/lib/modifiers.js +27 -0
  59. package/dist/features/content/CamoxContent.d.ts +2 -0
  60. package/dist/features/content/CamoxContent.d.ts.map +1 -0
  61. package/dist/features/content/CamoxContent.js +100 -0
  62. package/dist/features/content/components/AssetCard.d.ts +10 -0
  63. package/dist/features/content/components/AssetCard.d.ts.map +1 -0
  64. package/dist/features/content/components/AssetCard.js +41 -0
  65. package/dist/features/content/components/AssetCardSkeleton.d.ts +2 -0
  66. package/dist/features/content/components/AssetCardSkeleton.d.ts.map +1 -0
  67. package/dist/features/content/components/AssetCardSkeleton.js +11 -0
  68. package/dist/features/content/components/ContentSidebar.d.ts +2 -0
  69. package/dist/features/content/components/ContentSidebar.d.ts.map +1 -0
  70. package/dist/features/content/components/ContentSidebar.js +15 -0
  71. package/dist/features/content/components/UploadDropZone.d.ts +9 -0
  72. package/dist/features/content/components/UploadDropZone.d.ts.map +1 -0
  73. package/dist/features/content/components/UploadDropZone.js +51 -0
  74. package/dist/features/content/components/UploadProgressDrawer.d.ts +11 -0
  75. package/dist/features/content/components/UploadProgressDrawer.d.ts.map +1 -0
  76. package/dist/features/content/components/UploadProgressDrawer.js +72 -0
  77. package/dist/features/preview/CamoxPreview.d.ts +124 -0
  78. package/dist/features/preview/CamoxPreview.d.ts.map +1 -0
  79. package/dist/features/preview/CamoxPreview.js +253 -0
  80. package/dist/features/preview/components/AddBlockSheet.d.ts +3 -0
  81. package/dist/features/preview/components/AddBlockSheet.d.ts.map +1 -0
  82. package/dist/features/preview/components/AddBlockSheet.js +121 -0
  83. package/dist/features/preview/components/AgentChatSheet.d.ts +3 -0
  84. package/dist/features/preview/components/AgentChatSheet.d.ts.map +1 -0
  85. package/dist/features/preview/components/AgentChatSheet.js +24 -0
  86. package/dist/features/preview/components/AssetFieldEditor.d.ts +18 -0
  87. package/dist/features/preview/components/AssetFieldEditor.d.ts.map +1 -0
  88. package/dist/features/preview/components/AssetFieldEditor.js +139 -0
  89. package/dist/features/preview/components/AssetLightbox.d.ts +9 -0
  90. package/dist/features/preview/components/AssetLightbox.d.ts.map +1 -0
  91. package/dist/features/preview/components/AssetLightbox.js +421 -0
  92. package/dist/features/preview/components/AssetPickerGrid.d.ts +11 -0
  93. package/dist/features/preview/components/AssetPickerGrid.d.ts.map +1 -0
  94. package/dist/features/preview/components/AssetPickerGrid.js +92 -0
  95. package/dist/features/preview/components/BlockActionsPopover.d.ts +15 -0
  96. package/dist/features/preview/components/BlockActionsPopover.d.ts.map +1 -0
  97. package/dist/features/preview/components/BlockActionsPopover.js +506 -0
  98. package/dist/features/preview/components/CreatePageSheet.d.ts +3 -0
  99. package/dist/features/preview/components/CreatePageSheet.d.ts.map +1 -0
  100. package/dist/features/preview/components/CreatePageSheet.js +159 -0
  101. package/dist/features/preview/components/DebouncedFieldEditor.d.ts +10 -0
  102. package/dist/features/preview/components/DebouncedFieldEditor.d.ts.map +1 -0
  103. package/dist/features/preview/components/DebouncedFieldEditor.js +51 -0
  104. package/dist/features/preview/components/EditPageSheet.d.ts +3 -0
  105. package/dist/features/preview/components/EditPageSheet.d.ts.map +1 -0
  106. package/dist/features/preview/components/EditPageSheet.js +352 -0
  107. package/dist/features/preview/components/ItemFieldsEditor.d.ts +29 -0
  108. package/dist/features/preview/components/ItemFieldsEditor.d.ts.map +1 -0
  109. package/dist/features/preview/components/ItemFieldsEditor.js +308 -0
  110. package/dist/features/preview/components/LinkFieldEditor.d.ts +8 -0
  111. package/dist/features/preview/components/LinkFieldEditor.d.ts.map +1 -0
  112. package/dist/features/preview/components/LinkFieldEditor.js +190 -0
  113. package/dist/features/preview/components/MultipleAssetFieldEditor.d.ts +10 -0
  114. package/dist/features/preview/components/MultipleAssetFieldEditor.d.ts.map +1 -0
  115. package/dist/features/preview/components/MultipleAssetFieldEditor.js +232 -0
  116. package/dist/features/preview/components/OverlayTracker.d.ts +6 -0
  117. package/dist/features/preview/components/OverlayTracker.d.ts.map +1 -0
  118. package/dist/features/preview/components/OverlayTracker.js +41 -0
  119. package/dist/features/preview/components/Overlays.d.ts +6 -0
  120. package/dist/features/preview/components/Overlays.d.ts.map +1 -0
  121. package/dist/features/preview/components/Overlays.js +58 -0
  122. package/dist/features/preview/components/PageContentSheet.d.ts +3 -0
  123. package/dist/features/preview/components/PageContentSheet.d.ts.map +1 -0
  124. package/dist/features/preview/components/PageContentSheet.js +492 -0
  125. package/dist/features/preview/components/PageLocationFieldset.d.ts +14 -0
  126. package/dist/features/preview/components/PageLocationFieldset.d.ts.map +1 -0
  127. package/dist/features/preview/components/PageLocationFieldset.js +77 -0
  128. package/dist/features/preview/components/PagePicker.d.ts +3 -0
  129. package/dist/features/preview/components/PagePicker.d.ts.map +1 -0
  130. package/dist/features/preview/components/PagePicker.js +185 -0
  131. package/dist/features/preview/components/PageTree.d.ts +3 -0
  132. package/dist/features/preview/components/PageTree.d.ts.map +1 -0
  133. package/dist/features/preview/components/PageTree.js +410 -0
  134. package/dist/features/preview/components/PeekedBlock.d.ts +6 -0
  135. package/dist/features/preview/components/PeekedBlock.d.ts.map +1 -0
  136. package/dist/features/preview/components/PeekedBlock.js +95 -0
  137. package/dist/features/preview/components/PreviewPanel.d.ts +12 -0
  138. package/dist/features/preview/components/PreviewPanel.d.ts.map +1 -0
  139. package/dist/features/preview/components/PreviewPanel.js +192 -0
  140. package/dist/features/preview/components/PreviewSideSheet.d.ts +13 -0
  141. package/dist/features/preview/components/PreviewSideSheet.d.ts.map +1 -0
  142. package/dist/features/preview/components/PreviewSideSheet.js +28 -0
  143. package/dist/features/preview/components/PreviewToolbar.d.ts +2 -0
  144. package/dist/features/preview/components/PreviewToolbar.d.ts.map +1 -0
  145. package/dist/features/preview/components/PreviewToolbar.js +79 -0
  146. package/dist/features/preview/components/RepeatableItemsList.d.ts +14 -0
  147. package/dist/features/preview/components/RepeatableItemsList.d.ts.map +1 -0
  148. package/dist/features/preview/components/RepeatableItemsList.js +366 -0
  149. package/dist/features/preview/components/ShikiMarkdown.d.ts +4 -0
  150. package/dist/features/preview/components/ShikiMarkdown.d.ts.map +1 -0
  151. package/dist/features/preview/components/ShikiMarkdown.js +37 -0
  152. package/dist/features/preview/components/TextFormatToolbar.d.ts +2 -0
  153. package/dist/features/preview/components/TextFormatToolbar.d.ts.map +1 -0
  154. package/dist/features/preview/components/TextFormatToolbar.js +73 -0
  155. package/dist/features/preview/components/UnlinkAssetButton.d.ts +9 -0
  156. package/dist/features/preview/components/UnlinkAssetButton.d.ts.map +1 -0
  157. package/dist/features/preview/components/UnlinkAssetButton.js +55 -0
  158. package/dist/features/preview/overlayConstants.d.ts +19 -0
  159. package/dist/features/preview/overlayConstants.d.ts.map +1 -0
  160. package/dist/features/preview/overlayConstants.js +21 -0
  161. package/dist/features/preview/overlayMessages.d.ts +62 -0
  162. package/dist/features/preview/overlayMessages.d.ts.map +1 -0
  163. package/dist/features/preview/overlayMessages.js +9 -0
  164. package/dist/features/preview/previewConstants.d.ts +2 -0
  165. package/dist/features/preview/previewConstants.d.ts.map +1 -0
  166. package/dist/features/preview/previewStore.d.ts +116 -0
  167. package/dist/features/preview/previewStore.d.ts.map +1 -0
  168. package/dist/features/preview/previewStore.js +321 -0
  169. package/dist/features/provider/CamoxProvider.d.ts +11 -0
  170. package/dist/features/provider/CamoxProvider.d.ts.map +1 -0
  171. package/dist/features/provider/CamoxProvider.js +73 -0
  172. package/dist/features/provider/actionsStore.d.ts +39 -0
  173. package/dist/features/provider/actionsStore.d.ts.map +1 -0
  174. package/dist/features/provider/actionsStore.js +35 -0
  175. package/dist/features/provider/components/CamoxAppContext.d.ts +371 -0
  176. package/dist/features/provider/components/CamoxAppContext.d.ts.map +1 -0
  177. package/dist/features/provider/components/CamoxAppContext.js +17 -0
  178. package/dist/features/provider/components/CommandPalette.d.ts +3 -0
  179. package/dist/features/provider/components/CommandPalette.d.ts.map +1 -0
  180. package/dist/features/provider/components/CommandPalette.js +127 -0
  181. package/dist/features/provider/useAdminShortcuts.d.ts +5 -0
  182. package/dist/features/provider/useAdminShortcuts.d.ts.map +1 -0
  183. package/dist/features/provider/useAdminShortcuts.js +83 -0
  184. package/dist/features/routes/ogRoute.d.ts +7 -0
  185. package/dist/features/routes/ogRoute.d.ts.map +1 -0
  186. package/dist/features/routes/ogRoute.js +19 -0
  187. package/dist/features/routes/pageRoute.d.ts +135 -0
  188. package/dist/features/routes/pageRoute.d.ts.map +1 -0
  189. package/dist/features/routes/pageRoute.js +112 -0
  190. package/dist/features/studio/CamoxStudio.d.ts +7 -0
  191. package/dist/features/studio/CamoxStudio.d.ts.map +1 -0
  192. package/dist/features/studio/CamoxStudio.js +24 -0
  193. package/dist/features/studio/components/Navbar.d.ts +4 -0
  194. package/dist/features/studio/components/Navbar.d.ts.map +1 -0
  195. package/dist/features/studio/components/Navbar.js +95 -0
  196. package/dist/features/studio/components/ProjectMenu.d.ts +2 -0
  197. package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -0
  198. package/dist/features/studio/components/ProjectMenu.js +132 -0
  199. package/dist/features/studio/components/UserButton.d.ts +2 -0
  200. package/dist/features/studio/components/UserButton.d.ts.map +1 -0
  201. package/dist/features/studio/components/UserButton.js +96 -0
  202. package/dist/features/studio/studioStore.d.ts +17 -0
  203. package/dist/features/studio/studioStore.d.ts.map +1 -0
  204. package/dist/features/studio/studioStore.js +44 -0
  205. package/dist/features/studio/useTheme.d.ts +9 -0
  206. package/dist/features/studio/useTheme.d.ts.map +1 -0
  207. package/dist/features/studio/useTheme.js +98 -0
  208. package/dist/features/vite/appGeneration.d.ts +4 -0
  209. package/dist/features/vite/appGeneration.d.ts.map +1 -0
  210. package/dist/features/vite/appGeneration.js +67 -0
  211. package/dist/features/vite/blockBoilerplate.d.ts +3 -0
  212. package/dist/features/vite/blockBoilerplate.d.ts.map +1 -0
  213. package/dist/features/vite/blockBoilerplate.js +59 -0
  214. package/dist/features/vite/convexSync.d.ts +6 -0
  215. package/dist/features/vite/convexSync.d.ts.map +1 -0
  216. package/dist/features/vite/convexSync.js +98 -0
  217. package/dist/features/vite/definitionsSync.d.ts +11 -0
  218. package/dist/features/vite/definitionsSync.d.ts.map +1 -0
  219. package/dist/features/vite/definitionsSync.js +157 -0
  220. package/dist/features/vite/routeGeneration.d.ts +4 -0
  221. package/dist/features/vite/routeGeneration.d.ts.map +1 -0
  222. package/dist/features/vite/routeGeneration.js +194 -0
  223. package/dist/features/vite/skillGeneration.d.ts +4 -0
  224. package/dist/features/vite/skillGeneration.d.ts.map +1 -0
  225. package/dist/features/vite/skillGeneration.js +69 -0
  226. package/dist/features/vite/utils.d.ts +2 -0
  227. package/dist/features/vite/utils.d.ts.map +1 -0
  228. package/dist/features/vite/utils.js +10 -0
  229. package/dist/features/vite/vite.d.ts +18 -0
  230. package/dist/features/vite/vite.d.ts.map +1 -0
  231. package/dist/features/vite/vite.js +77 -0
  232. package/dist/hooks/use-file-upload.d.ts +22 -0
  233. package/dist/hooks/use-file-upload.d.ts.map +1 -0
  234. package/dist/hooks/use-marquee-selection.d.ts +17 -0
  235. package/dist/hooks/use-marquee-selection.d.ts.map +1 -0
  236. package/dist/lib/analytics-client.d.ts +3 -0
  237. package/dist/lib/analytics-client.d.ts.map +1 -0
  238. package/dist/lib/analytics.d.ts +3 -0
  239. package/dist/lib/analytics.d.ts.map +1 -0
  240. package/dist/lib/analytics.js +24 -0
  241. package/dist/lib/auth.d.ts +3683 -0
  242. package/dist/lib/auth.d.ts.map +1 -0
  243. package/dist/lib/convex-site.d.ts +3 -0
  244. package/dist/lib/convex-site.d.ts.map +1 -0
  245. package/dist/lib/utils.d.ts +40 -0
  246. package/dist/lib/utils.d.ts.map +1 -0
  247. package/dist/studio.css +2 -0
  248. package/package.json +123 -10
  249. package/server/api.d.ts +1 -0
  250. package/server/api.js +1 -0
  251. package/server/dataModel.d.ts +1 -0
  252. package/server/dataModel.js +1 -0
  253. package/skills/camox-block/SKILL.md +357 -0
  254. package/skills/camox-layout/SKILL.md +181 -0
  255. package/index.js +0 -3
@@ -0,0 +1,366 @@
1
+ import { previewStore } from "../previewStore.js";
2
+ import { useSelector } from "@xstate/store/react";
3
+ import { api } from "camox/server/api";
4
+ import { useMutation } from "convex/react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { useLocation } from "@tanstack/react-router";
7
+ import { cn } from "@/lib/utils";
8
+ import { Button } from "@camox/ui/button";
9
+ import { CircleMinus, CirclePlus, GripVertical } from "lucide-react";
10
+ import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
11
+ import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
12
+ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
13
+ import { SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
14
+ import { CSS } from "@dnd-kit/utilities";
15
+ import { generateKeyBetween } from "fractional-indexing";
16
+ //#region src/features/preview/components/RepeatableItemsList.tsx
17
+ var SortableRepeatableItem = ({ item, blockId, fieldName, canRemove, onRemove }) => {
18
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: item._id });
19
+ const style = {
20
+ transform: CSS.Transform.toString(transform),
21
+ transition,
22
+ opacity: isDragging ? .5 : 1
23
+ };
24
+ const selectionBreadcrumbs = useSelector(previewStore, (state) => state.context.selectionBreadcrumbs);
25
+ const iframeElement = useSelector(previewStore, (state) => state.context.iframeElement);
26
+ const isSelected = selectionBreadcrumbs.some((b) => b.type === "RepeatableObject" && b.id === item._id);
27
+ const shouldShowHover = !isDragging && !isSelected;
28
+ const handleMouseEnter = () => {
29
+ if (!iframeElement?.contentWindow) return;
30
+ const message = {
31
+ type: "CAMOX_HOVER_REPEATER_ITEM",
32
+ blockId,
33
+ itemId: item._id
34
+ };
35
+ iframeElement.contentWindow.postMessage(message, "*");
36
+ };
37
+ const handleMouseLeave = () => {
38
+ if (!iframeElement?.contentWindow) return;
39
+ const message = {
40
+ type: "CAMOX_HOVER_REPEATER_ITEM_END",
41
+ blockId,
42
+ itemId: item._id
43
+ };
44
+ iframeElement.contentWindow.postMessage(message, "*");
45
+ };
46
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", {
47
+ ref: setNodeRef,
48
+ style,
49
+ className: cn("flex flex-row justify-between items-center gap-2 px-1 py-1 max-w-full rounded-lg text-foreground transition-none group", shouldShowHover && "hover:bg-accent/75", isSelected && "bg-accent text-accent-foreground"),
50
+ onMouseEnter: handleMouseEnter,
51
+ onMouseLeave: handleMouseLeave,
52
+ children: [
53
+ /* @__PURE__ */ jsx(Button, {
54
+ type: "button",
55
+ variant: "ghost",
56
+ size: "icon-sm",
57
+ className: "text-muted-foreground hover:text-foreground flex cursor-grab active:cursor-grabbing",
58
+ ...attributes,
59
+ ...listeners,
60
+ children: /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" })
61
+ }),
62
+ /* @__PURE__ */ jsx("div", {
63
+ className: "flex flex-1 items-center gap-1 overflow-x-hidden",
64
+ children: /* @__PURE__ */ jsx("p", {
65
+ className: "flex-1 cursor-default truncate py-1 text-sm",
66
+ title: item.summary,
67
+ onClick: () => {
68
+ handleMouseLeave();
69
+ previewStore.send({
70
+ type: "drillIntoRepeatableItem",
71
+ itemId: item._id,
72
+ fieldName
73
+ });
74
+ },
75
+ children: item.summary
76
+ })
77
+ }),
78
+ canRemove && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
79
+ asChild: true,
80
+ children: /* @__PURE__ */ jsx(Button, {
81
+ type: "button",
82
+ variant: "ghost",
83
+ size: "icon-sm",
84
+ className: "text-muted-foreground hover:text-foreground hidden shrink-0 group-focus-within:flex group-hover:flex",
85
+ onClick: (e) => {
86
+ e.stopPropagation();
87
+ onRemove(item._id);
88
+ },
89
+ children: /* @__PURE__ */ jsx(CircleMinus, { className: "h-4 w-4" })
90
+ })
91
+ }), /* @__PURE__ */ jsx(TooltipContent, {
92
+ side: "right",
93
+ children: "Remove item"
94
+ })] })
95
+ ]
96
+ }) });
97
+ };
98
+ var getInlineItemLabel = (item, index) => {
99
+ for (const value of Object.values(item)) {
100
+ if (typeof value === "string" && value.trim()) return value;
101
+ if (value && typeof value === "object" && "text" in value) {
102
+ const text = value.text;
103
+ if (typeof text === "string" && text.trim()) return text;
104
+ }
105
+ }
106
+ return `Item ${index + 1}`;
107
+ };
108
+ var SortableInlineRepeatableItem = ({ item, index, blockId, parentItemId, fieldName, canRemove, onRemove }) => {
109
+ const sortableId = `idx:${index}`;
110
+ const label = getInlineItemLabel(item, index);
111
+ const nestedItemId = `nested:${parentItemId}:${fieldName}:${index}`;
112
+ const iframeElement = useSelector(previewStore, (state) => state.context.iframeElement);
113
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: sortableId });
114
+ const style = {
115
+ transform: CSS.Transform.toString(transform),
116
+ transition,
117
+ opacity: isDragging ? .5 : 1
118
+ };
119
+ const handleMouseEnter = () => {
120
+ if (!iframeElement?.contentWindow) return;
121
+ const message = {
122
+ type: "CAMOX_HOVER_REPEATER_ITEM",
123
+ blockId,
124
+ itemId: nestedItemId
125
+ };
126
+ iframeElement.contentWindow.postMessage(message, "*");
127
+ };
128
+ const handleMouseLeave = () => {
129
+ if (!iframeElement?.contentWindow) return;
130
+ const message = {
131
+ type: "CAMOX_HOVER_REPEATER_ITEM_END",
132
+ blockId,
133
+ itemId: nestedItemId
134
+ };
135
+ iframeElement.contentWindow.postMessage(message, "*");
136
+ };
137
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", {
138
+ ref: setNodeRef,
139
+ style,
140
+ className: cn("flex flex-row justify-between items-center gap-2 px-1 py-1 max-w-full rounded-lg text-foreground transition-none group", !isDragging && "hover:bg-accent/75"),
141
+ onMouseEnter: handleMouseEnter,
142
+ onMouseLeave: handleMouseLeave,
143
+ children: [
144
+ /* @__PURE__ */ jsx(Button, {
145
+ type: "button",
146
+ variant: "ghost",
147
+ size: "icon-sm",
148
+ className: "text-muted-foreground hover:text-foreground flex cursor-grab active:cursor-grabbing",
149
+ ...attributes,
150
+ ...listeners,
151
+ children: /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" })
152
+ }),
153
+ /* @__PURE__ */ jsx("div", {
154
+ className: "flex flex-1 items-center gap-1 overflow-x-hidden",
155
+ children: /* @__PURE__ */ jsx("p", {
156
+ className: "flex-1 cursor-default truncate py-1 text-sm",
157
+ title: label,
158
+ onClick: () => {
159
+ handleMouseLeave();
160
+ previewStore.send({
161
+ type: "drillIntoRepeatableItem",
162
+ itemId: sortableId,
163
+ fieldName
164
+ });
165
+ },
166
+ children: label
167
+ })
168
+ }),
169
+ canRemove && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
170
+ asChild: true,
171
+ children: /* @__PURE__ */ jsx(Button, {
172
+ type: "button",
173
+ variant: "ghost",
174
+ size: "icon-sm",
175
+ className: "text-muted-foreground hover:text-foreground hidden shrink-0 group-focus-within:flex group-hover:flex",
176
+ onClick: (e) => {
177
+ e.stopPropagation();
178
+ onRemove(index);
179
+ },
180
+ children: /* @__PURE__ */ jsx(CircleMinus, { className: "h-4 w-4" })
181
+ })
182
+ }), /* @__PURE__ */ jsx(TooltipContent, {
183
+ side: "right",
184
+ children: "Remove item"
185
+ })] })
186
+ ]
187
+ }) });
188
+ };
189
+ var RepeatableItemsList = ({ items, blockId, fieldName, minItems, maxItems, schema, parentItemId }) => {
190
+ const isInline = !!parentItemId;
191
+ const { pathname } = useLocation();
192
+ const updateRepeatableItemContent = useMutation(api.repeatableItems.updateRepeatableItemContent);
193
+ const updatePositionMutation = useMutation(api.repeatableItems.updateRepeatableItemPosition).withOptimisticUpdate((localStore, args) => {
194
+ const currentPage = localStore.getQuery(api.pages.getPage, { fullPath: pathname });
195
+ if (!currentPage) return;
196
+ const updatedBlocks = currentPage.blocks.map((block) => {
197
+ if (!Object.entries(block.content).some(([_, value]) => {
198
+ if (Array.isArray(value)) return value.some((item) => item._id === args.itemId);
199
+ return false;
200
+ })) return block;
201
+ const updatedContent = { ...block.content };
202
+ for (const [fieldName, fieldValue] of Object.entries(block.content)) {
203
+ if (!Array.isArray(fieldValue)) continue;
204
+ const items = fieldValue;
205
+ const itemIndex = items.findIndex((item) => item._id === args.itemId);
206
+ if (itemIndex === -1) continue;
207
+ const item = items[itemIndex];
208
+ const newPosition = generateKeyBetween(args.afterPosition ?? null, args.beforePosition ?? null);
209
+ const updatedItem = {
210
+ ...item,
211
+ position: newPosition
212
+ };
213
+ const newItems = [...items];
214
+ newItems[itemIndex] = updatedItem;
215
+ newItems.sort((a, b) => {
216
+ if (a.position < b.position) return -1;
217
+ if (a.position > b.position) return 1;
218
+ return 0;
219
+ });
220
+ updatedContent[fieldName] = newItems;
221
+ }
222
+ return {
223
+ ...block,
224
+ content: updatedContent
225
+ };
226
+ });
227
+ localStore.setQuery(api.pages.getPage, { fullPath: pathname }, {
228
+ ...currentPage,
229
+ blocks: updatedBlocks
230
+ });
231
+ });
232
+ const createItemMutation = useMutation(api.repeatableItems.createRepeatableItem);
233
+ const deleteItemMutation = useMutation(api.repeatableItems.deleteRepeatableItem);
234
+ const canAdd = maxItems === void 0 || items.length < maxItems;
235
+ const canRemove = minItems === void 0 || items.length > minItems;
236
+ const handleAddItem = () => {
237
+ const defaultContent = {};
238
+ const itemsSchema = schema?.items;
239
+ if (itemsSchema?.properties) for (const [key, prop] of Object.entries(itemsSchema.properties)) {
240
+ const ft = prop.fieldType;
241
+ if (ft === "Image" || ft === "File") continue;
242
+ if ("default" in prop) defaultContent[key] = prop.default;
243
+ }
244
+ createItemMutation({
245
+ blockId,
246
+ fieldName,
247
+ content: defaultContent
248
+ });
249
+ };
250
+ const handleRemoveItem = (itemId) => {
251
+ deleteItemMutation({ itemId });
252
+ };
253
+ const handleAddInlineItem = () => {
254
+ if (!parentItemId) return;
255
+ const defaultContent = {};
256
+ const itemsSchema = schema?.items;
257
+ if (itemsSchema?.properties) for (const [key, prop] of Object.entries(itemsSchema.properties)) {
258
+ const ft = prop.fieldType;
259
+ if (ft === "Image" || ft === "File") continue;
260
+ if ("default" in prop) defaultContent[key] = prop.default;
261
+ }
262
+ const currentItems = items;
263
+ updateRepeatableItemContent({
264
+ itemId: parentItemId,
265
+ content: { [fieldName]: [...currentItems, defaultContent] }
266
+ });
267
+ };
268
+ const handleRemoveInlineItem = (index) => {
269
+ if (!parentItemId) return;
270
+ const currentItems = items;
271
+ updateRepeatableItemContent({
272
+ itemId: parentItemId,
273
+ content: { [fieldName]: currentItems.filter((_, i) => i !== index) }
274
+ });
275
+ };
276
+ const handleInlineDragEnd = (event) => {
277
+ const { active, over } = event;
278
+ if (!over || active.id === over.id || !parentItemId) return;
279
+ const oldIndex = parseInt(active.id.slice(4), 10);
280
+ const newIndex = parseInt(over.id.slice(4), 10);
281
+ if (isNaN(oldIndex) || isNaN(newIndex)) return;
282
+ const currentItems = [...items];
283
+ const [moved] = currentItems.splice(oldIndex, 1);
284
+ currentItems.splice(newIndex, 0, moved);
285
+ updateRepeatableItemContent({
286
+ itemId: parentItemId,
287
+ content: { [fieldName]: currentItems }
288
+ });
289
+ };
290
+ const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
291
+ const handleDragEnd = async (event) => {
292
+ const { active, over } = event;
293
+ if (!over || active.id === over.id) return;
294
+ const dbItems = items;
295
+ const oldIndex = dbItems.findIndex((item) => item._id === active.id);
296
+ const newIndex = dbItems.findIndex((item) => item._id === over.id);
297
+ if (oldIndex === -1 || newIndex === -1) return;
298
+ let afterPosition;
299
+ let beforePosition;
300
+ if (oldIndex < newIndex) {
301
+ afterPosition = dbItems[newIndex].position;
302
+ beforePosition = newIndex < dbItems.length - 1 ? dbItems[newIndex + 1].position : void 0;
303
+ } else {
304
+ afterPosition = newIndex > 0 ? dbItems[newIndex - 1].position : void 0;
305
+ beforePosition = dbItems[newIndex].position;
306
+ }
307
+ await updatePositionMutation({
308
+ itemId: active.id,
309
+ afterPosition,
310
+ beforePosition
311
+ });
312
+ };
313
+ return /* @__PURE__ */ jsxs("div", {
314
+ className: "flex flex-col gap-1",
315
+ children: [isInline ? items.length > 0 && /* @__PURE__ */ jsx(DndContext, {
316
+ sensors,
317
+ collisionDetection: closestCenter,
318
+ onDragEnd: handleInlineDragEnd,
319
+ modifiers: [restrictToVerticalAxis],
320
+ children: /* @__PURE__ */ jsx(SortableContext, {
321
+ items: items.map((_, i) => `idx:${i}`),
322
+ strategy: verticalListSortingStrategy,
323
+ children: /* @__PURE__ */ jsx("ul", {
324
+ className: "flex flex-col gap-1",
325
+ children: items.map((item, index) => /* @__PURE__ */ jsx(SortableInlineRepeatableItem, {
326
+ item,
327
+ index,
328
+ blockId,
329
+ parentItemId,
330
+ fieldName,
331
+ canRemove,
332
+ onRemove: handleRemoveInlineItem
333
+ }, index))
334
+ })
335
+ })
336
+ }) : items.length > 0 && /* @__PURE__ */ jsx(DndContext, {
337
+ sensors,
338
+ collisionDetection: closestCenter,
339
+ onDragEnd: handleDragEnd,
340
+ modifiers: [restrictToVerticalAxis],
341
+ children: /* @__PURE__ */ jsx(SortableContext, {
342
+ items: items.map((item) => item._id),
343
+ strategy: verticalListSortingStrategy,
344
+ children: /* @__PURE__ */ jsx("ul", {
345
+ className: "flex flex-col gap-1",
346
+ children: items.map((item) => /* @__PURE__ */ jsx(SortableRepeatableItem, {
347
+ item,
348
+ blockId,
349
+ fieldName,
350
+ canRemove,
351
+ onRemove: handleRemoveItem
352
+ }, item._id))
353
+ })
354
+ })
355
+ }), canAdd && /* @__PURE__ */ jsxs(Button, {
356
+ type: "button",
357
+ variant: "ghost",
358
+ size: "sm",
359
+ className: "text-muted-foreground justify-start self-start",
360
+ onClick: isInline ? handleAddInlineItem : handleAddItem,
361
+ children: [/* @__PURE__ */ jsx(CirclePlus, { className: "h-4 w-4" }), "Add item"]
362
+ })]
363
+ });
364
+ };
365
+ //#endregion
366
+ export { RepeatableItemsList };
@@ -0,0 +1,4 @@
1
+ export declare const ShikiMarkdown: ({ code }: {
2
+ code: string;
3
+ }) => import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=ShikiMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShikiMarkdown.d.ts","sourceRoot":"","sources":["../../../../src/features/preview/components/ShikiMarkdown.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,GAAI,UAAU;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,mDA4BvD,CAAC"}
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { codeToHtml } from "shiki";
4
+ //#region src/features/preview/components/ShikiMarkdown.tsx
5
+ var css = `
6
+ .dark .shiki,
7
+ .dark .shiki span {
8
+ color: var(--shiki-dark) !important;
9
+ background-color: var(--shiki-dark-bg) !important;
10
+ }
11
+ `;
12
+ var ShikiMarkdown = ({ code }) => {
13
+ const [html, setHtml] = React.useState("");
14
+ React.useEffect(() => {
15
+ let cancelled = false;
16
+ codeToHtml(code, {
17
+ lang: "markdown",
18
+ themes: {
19
+ light: "github-light",
20
+ dark: "github-dark-high-contrast"
21
+ },
22
+ defaultColor: false
23
+ }).then((result) => {
24
+ if (!cancelled) setHtml(result);
25
+ });
26
+ return () => {
27
+ cancelled = true;
28
+ };
29
+ }, [code]);
30
+ if (!html) return null;
31
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("style", { children: css }), /* @__PURE__ */ jsx("div", {
32
+ className: "border-input w-full min-w-0 overflow-hidden rounded-md border text-sm [&_code]:font-mono [&_pre]:rounded-md [&_pre]:px-3 [&_pre]:py-2 [&_pre]:break-all [&_pre]:whitespace-pre-wrap",
33
+ dangerouslySetInnerHTML: { __html: html }
34
+ })] });
35
+ };
36
+ //#endregion
37
+ export { ShikiMarkdown };
@@ -0,0 +1,2 @@
1
+ export declare const TextFormatToolbar: () => import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=TextFormatToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextFormatToolbar.d.ts","sourceRoot":"","sources":["../../../../src/features/preview/components/TextFormatToolbar.tsx"],"names":[],"mappings":"AAsBA,eAAO,MAAM,iBAAiB,+CA6D7B,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { isOverlayMessage } from "../overlayMessages.js";
2
+ import { previewStore } from "../previewStore.js";
3
+ import { FORMAT_FLAGS } from "../../../core/lib/modifierFormats.js";
4
+ import { useIsPreviewSheetOpen } from "./PreviewSideSheet.js";
5
+ import { Kbd } from "@camox/ui/kbd";
6
+ import { useSelector } from "@xstate/store/react";
7
+ import * as React from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { cn } from "@/lib/utils";
10
+ import { Bold, Italic } from "lucide-react";
11
+ import * as Tooltip$1 from "@camox/ui/tooltip";
12
+ import { ButtonGroup } from "@camox/ui/button-group";
13
+ import { FloatingToolbar } from "@camox/ui/floating-toolbar";
14
+ import { Toggle } from "@camox/ui/toggle";
15
+ //#region src/features/preview/components/TextFormatToolbar.tsx
16
+ var FORMAT_BUTTONS = [{
17
+ key: "bold",
18
+ flag: FORMAT_FLAGS.bold,
19
+ icon: Bold,
20
+ label: "Bold",
21
+ shortcut: "⌘ B"
22
+ }, {
23
+ key: "italic",
24
+ flag: FORMAT_FLAGS.italic,
25
+ icon: Italic,
26
+ label: "Italic",
27
+ shortcut: "⌘ I"
28
+ }];
29
+ var TextFormatToolbar = () => {
30
+ const iframeElement = useSelector(previewStore, (state) => state.context.iframeElement);
31
+ const isAnySideSheetOpen = useIsPreviewSheetOpen();
32
+ const [hasSelection, setHasSelection] = React.useState(false);
33
+ const [activeFormats, setActiveFormats] = React.useState(0);
34
+ React.useEffect(() => {
35
+ const handleMessage = (event) => {
36
+ const data = event.data;
37
+ if (!isOverlayMessage(data) || data.type !== "CAMOX_TEXT_SELECTION_STATE") return;
38
+ setHasSelection(data.hasSelection);
39
+ setActiveFormats(data.activeFormats);
40
+ };
41
+ window.addEventListener("message", handleMessage);
42
+ return () => window.removeEventListener("message", handleMessage);
43
+ }, []);
44
+ const sendFormat = (formatKey) => {
45
+ iframeElement?.contentWindow?.postMessage({
46
+ type: "CAMOX_FORMAT_TEXT",
47
+ formatKey
48
+ }, "*");
49
+ };
50
+ return /* @__PURE__ */ jsx(FloatingToolbar, {
51
+ onMouseDown: (e) => e.preventDefault(),
52
+ className: cn("bottom-16 gap-1", hasSelection && !isAnySideSheetOpen ? "opacity-100 translate-y-0" : "opacity-0 pointer-events-none translate-y-2"),
53
+ children: /* @__PURE__ */ jsx(ButtonGroup, { children: FORMAT_BUTTONS.map(({ key, flag, icon: Icon, label, shortcut }) => {
54
+ const isActive = !!(activeFormats & flag);
55
+ return /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
56
+ asChild: true,
57
+ children: /* @__PURE__ */ jsx(Toggle, {
58
+ "data-state": isActive ? "on" : "off",
59
+ pressed: isActive,
60
+ variant: "outline",
61
+ onPressedChange: () => sendFormat(key),
62
+ children: /* @__PURE__ */ jsx(Icon, {})
63
+ })
64
+ }), /* @__PURE__ */ jsxs(Tooltip$1.TooltipContent, { children: [
65
+ label,
66
+ " ",
67
+ /* @__PURE__ */ jsx(Kbd, { children: shortcut })
68
+ ] })] }, key);
69
+ }) })
70
+ });
71
+ };
72
+ //#endregion
73
+ export { TextFormatToolbar };
@@ -0,0 +1,9 @@
1
+ import { Id } from 'camox/server/dataModel';
2
+ interface UnlinkAssetButtonProps {
3
+ fileId: Id<"files"> | undefined;
4
+ onUnlink: () => void;
5
+ className?: string;
6
+ }
7
+ declare const UnlinkAssetButton: ({ fileId, onUnlink, className }: UnlinkAssetButtonProps) => import("react/jsx-runtime").JSX.Element;
8
+ export { UnlinkAssetButton };
9
+ //# sourceMappingURL=UnlinkAssetButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnlinkAssetButton.d.ts","sourceRoot":"","sources":["../../../../src/features/preview/components/UnlinkAssetButton.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAOjD,UAAU,sBAAsB;IAC9B,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,iBAAiB,GAAI,iCAAiC,sBAAsB,4CA0DjF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { api } from "camox/server/api";
2
+ import { useMutation, useQuery } from "convex/react";
3
+ import { useState } from "react";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { cn } from "@/lib/utils";
6
+ import { Button } from "@camox/ui/button";
7
+ import { X } from "lucide-react";
8
+ import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
9
+ import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
10
+ //#region src/features/preview/components/UnlinkAssetButton.tsx
11
+ var UnlinkAssetButton = ({ fileId, onUnlink, className }) => {
12
+ const [dialogOpen, setDialogOpen] = useState(false);
13
+ const usageCount = useQuery(api.files.getFileUsageCount, fileId ? { fileId } : "skip");
14
+ const deleteFile = useMutation(api.files.deleteFile);
15
+ const handleClick = (e) => {
16
+ e.stopPropagation();
17
+ if (!fileId || usageCount === void 0 || usageCount > 1) {
18
+ onUnlink();
19
+ return;
20
+ }
21
+ setDialogOpen(true);
22
+ };
23
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
24
+ asChild: true,
25
+ children: /* @__PURE__ */ jsx(Button, {
26
+ type: "button",
27
+ variant: "ghost",
28
+ size: "icon-sm",
29
+ className: cn("text-muted-foreground hover:text-foreground shrink-0", className),
30
+ onClick: handleClick,
31
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
32
+ })
33
+ }), /* @__PURE__ */ jsx(TooltipContent, { children: "Unlink" })] }), /* @__PURE__ */ jsx(AlertDialog, {
34
+ open: dialogOpen,
35
+ onOpenChange: setDialogOpen,
36
+ children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Unlink file" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "This file is not used anywhere else. Would you like to also delete it?" })] }), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogAction, {
37
+ onClick: () => onUnlink(),
38
+ asChild: true,
39
+ children: /* @__PURE__ */ jsx(Button, {
40
+ variant: "outline",
41
+ className: "bg-background hover:bg-accent text-foreground",
42
+ children: "Unlink only"
43
+ })
44
+ }), /* @__PURE__ */ jsx(AlertDialogAction, {
45
+ onClick: () => {
46
+ onUnlink();
47
+ if (fileId) deleteFile({ fileId });
48
+ },
49
+ asChild: true,
50
+ children: /* @__PURE__ */ jsx(Button, { children: "Delete file" })
51
+ })] })] })
52
+ })] });
53
+ };
54
+ //#endregion
55
+ export { UnlinkAssetButton };
@@ -0,0 +1,19 @@
1
+ export declare const OVERLAY_COLORS: {
2
+ readonly hover: "#F472B6BF";
3
+ readonly selected: "#F472B6";
4
+ };
5
+ export declare const LAYOUT_OVERLAY_COLORS: {
6
+ readonly hover: "#c084fcBF";
7
+ readonly selected: "#c084fc";
8
+ };
9
+ export declare const OVERLAY_WIDTHS: {
10
+ readonly hover: "3px";
11
+ readonly selected: "1px";
12
+ };
13
+ export declare const OVERLAY_OFFSETS: {
14
+ readonly fieldHover: "1px";
15
+ readonly fieldSelected: "2px";
16
+ readonly blockHover: "-1px";
17
+ readonly blockSelected: "0px";
18
+ };
19
+ //# sourceMappingURL=overlayConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlayConstants.d.ts","sourceRoot":"","sources":["../../../src/features/preview/overlayConstants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX,eAAO,MAAM,qBAAqB;;;CAGxB,CAAC;AAEX,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC"}
@@ -0,0 +1,21 @@
1
+ //#region src/features/preview/overlayConstants.ts
2
+ var OVERLAY_COLORS = {
3
+ hover: "#F472B6BF",
4
+ selected: "#F472B6"
5
+ };
6
+ var LAYOUT_OVERLAY_COLORS = {
7
+ hover: "#c084fcBF",
8
+ selected: "#c084fc"
9
+ };
10
+ var OVERLAY_WIDTHS = {
11
+ hover: "3px",
12
+ selected: "1px"
13
+ };
14
+ var OVERLAY_OFFSETS = {
15
+ fieldHover: "1px",
16
+ fieldSelected: "2px",
17
+ blockHover: "-1px",
18
+ blockSelected: "0px"
19
+ };
20
+ //#endregion
21
+ export { LAYOUT_OVERLAY_COLORS, OVERLAY_COLORS, OVERLAY_OFFSETS, OVERLAY_WIDTHS };
@@ -0,0 +1,62 @@
1
+ export interface FieldRect {
2
+ top: number;
3
+ left: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export type OverlayMessage = {
8
+ type: "CAMOX_FOCUS_FIELD";
9
+ fieldId: string;
10
+ } | {
11
+ type: "CAMOX_FOCUS_FIELD_END";
12
+ fieldId: string;
13
+ } | {
14
+ type: "CAMOX_HOVER_FIELD";
15
+ fieldId: string;
16
+ } | {
17
+ type: "CAMOX_HOVER_FIELD_END";
18
+ fieldId: string;
19
+ } | {
20
+ type: "CAMOX_HOVER_BLOCK";
21
+ blockId: string;
22
+ } | {
23
+ type: "CAMOX_HOVER_BLOCK_END";
24
+ blockId: string;
25
+ } | {
26
+ type: "CAMOX_HOVER_REPEATER";
27
+ blockId: string;
28
+ fieldName: string;
29
+ } | {
30
+ type: "CAMOX_HOVER_REPEATER_END";
31
+ blockId: string;
32
+ fieldName: string;
33
+ } | {
34
+ type: "CAMOX_HOVER_REPEATER_ITEM";
35
+ blockId: string;
36
+ itemId: string;
37
+ } | {
38
+ type: "CAMOX_HOVER_REPEATER_ITEM_END";
39
+ blockId: string;
40
+ itemId: string;
41
+ } | {
42
+ type: "CAMOX_ADD_BLOCK_REQUEST";
43
+ blockPosition: string;
44
+ insertPosition: "before" | "after";
45
+ afterPosition?: string | null;
46
+ } | {
47
+ type: "CAMOX_TEXT_SELECTION_STATE";
48
+ hasSelection: boolean;
49
+ activeFormats: number;
50
+ } | {
51
+ type: "CAMOX_FORMAT_TEXT";
52
+ formatKey: string;
53
+ };
54
+ export declare function isOverlayMessage(data: unknown): data is OverlayMessage;
55
+ export declare function postOverlayMessage(message: OverlayMessage): void;
56
+ /**
57
+ * Returns the element's position relative to the document (not viewport).
58
+ * This allows overlays to be positioned correctly regardless of scroll position,
59
+ * by applying scroll offset at the container level instead of per-overlay.
60
+ */
61
+ export declare function getElementRect(element: HTMLElement): FieldRect;
62
+ //# sourceMappingURL=overlayMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlayMessages.d.ts","sourceRoot":"","sources":["../../../src/features/preview/overlayMessages.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAEtB;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAElD;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAElD;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAExE;IAAE,IAAI,EAAE,2BAA2B,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,+BAA+B,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAE1E;IACE,IAAI,EAAE,yBAAyB,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,QAAQ,GAAG,OAAO,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GAED;IAAE,IAAI,EAAE,4BAA4B,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAEpF;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,cAAc,CAQtE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,QAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAQ9D"}