@alpaca-editor/core 1.0.3939 → 1.0.3941

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 (325) hide show
  1. package/dist/components/ActionButton.d.ts +1 -0
  2. package/dist/components/ActionButton.js +2 -2
  3. package/dist/components/ActionButton.js.map +1 -1
  4. package/dist/editor/FieldActionsOverlay.d.ts +1 -0
  5. package/dist/editor/FieldActionsOverlay.js +2 -11
  6. package/dist/editor/FieldActionsOverlay.js.map +1 -1
  7. package/dist/editor/PictureCropper.js +65 -23
  8. package/dist/editor/PictureCropper.js.map +1 -1
  9. package/dist/editor/PictureEditor.js +16 -2
  10. package/dist/editor/PictureEditor.js.map +1 -1
  11. package/dist/editor/Titlebar.js +1 -1
  12. package/dist/editor/Titlebar.js.map +1 -1
  13. package/dist/editor/ai/GhostWriter.js +21 -2
  14. package/dist/editor/ai/GhostWriter.js.map +1 -1
  15. package/dist/editor/commands/componentCommands.js +7 -3
  16. package/dist/editor/commands/componentCommands.js.map +1 -1
  17. package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
  18. package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
  19. package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
  20. package/dist/editor/media-selector/MediaSelector.js +1 -1
  21. package/dist/editor/media-selector/MediaSelector.js.map +1 -1
  22. package/dist/editor/media-selector/Thumbnails.js +2 -2
  23. package/dist/editor/media-selector/index.d.ts +8 -0
  24. package/dist/editor/media-selector/index.js +9 -0
  25. package/dist/editor/media-selector/index.js.map +1 -0
  26. package/dist/editor/menubar/BrowseHistory.js +1 -1
  27. package/dist/editor/menubar/PageSelector.js +39 -15
  28. package/dist/editor/menubar/PageSelector.js.map +1 -1
  29. package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
  30. package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
  31. package/dist/editor/reviews/Comment.js +1 -1
  32. package/dist/editor/reviews/Comment.js.map +1 -1
  33. package/dist/editor/services/aiService.js +0 -1
  34. package/dist/editor/services/aiService.js.map +1 -1
  35. package/dist/editor/sidebar/ComponentTree.js +3 -4
  36. package/dist/editor/sidebar/ComponentTree.js.map +1 -1
  37. package/dist/editor/ui/SimpleTabs.d.ts +1 -0
  38. package/dist/editor/ui/SimpleTabs.js +3 -3
  39. package/dist/editor/ui/SimpleTabs.js.map +1 -1
  40. package/dist/editor/ui/Splitter.js +61 -6
  41. package/dist/editor/ui/Splitter.js.map +1 -1
  42. package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
  43. package/dist/editor/views/MediaFolderEditView.js +40 -0
  44. package/dist/editor/views/MediaFolderEditView.js.map +1 -0
  45. package/dist/editor/views/SingleEditView.js +9 -1
  46. package/dist/editor/views/SingleEditView.js.map +1 -1
  47. package/dist/revision.d.ts +2 -2
  48. package/dist/revision.js +2 -2
  49. package/dist/styles.css +61 -5
  50. package/package.json +8 -2
  51. package/.prettierrc +0 -3
  52. package/build.css +0 -3
  53. package/components.json +0 -21
  54. package/eslint.config.mjs +0 -4
  55. package/images/bg-shape-black.webp +0 -0
  56. package/images/wizard-bg.png +0 -0
  57. package/images/wizard-tour.png +0 -0
  58. package/images/wizard.png +0 -0
  59. package/src/client-components/api.ts +0 -6
  60. package/src/client-components/index.ts +0 -19
  61. package/src/components/ActionButton.tsx +0 -41
  62. package/src/components/Error.tsx +0 -57
  63. package/src/components/ui/CardConnector.tsx +0 -56
  64. package/src/components/ui/button.tsx +0 -62
  65. package/src/components/ui/card.tsx +0 -372
  66. package/src/components/ui/context-menu.tsx +0 -250
  67. package/src/config/config.tsx +0 -917
  68. package/src/config/types.ts +0 -286
  69. package/src/editor/ComponentInfo.tsx +0 -90
  70. package/src/editor/ConfirmationDialog.tsx +0 -103
  71. package/src/editor/ContentTree.tsx +0 -730
  72. package/src/editor/ContextMenu.tsx +0 -230
  73. package/src/editor/Editor.tsx +0 -90
  74. package/src/editor/EditorWarning.tsx +0 -34
  75. package/src/editor/EditorWarnings.tsx +0 -33
  76. package/src/editor/FieldActionsOverlay.tsx +0 -307
  77. package/src/editor/FieldEditorPopup.tsx +0 -65
  78. package/src/editor/FieldHistory.tsx +0 -75
  79. package/src/editor/FieldList.tsx +0 -190
  80. package/src/editor/FieldListField.tsx +0 -391
  81. package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
  82. package/src/editor/FloatingToolbar.tsx +0 -163
  83. package/src/editor/ImageEditor.tsx +0 -128
  84. package/src/editor/ItemInfo.tsx +0 -90
  85. package/src/editor/LinkEditorDialog.tsx +0 -196
  86. package/src/editor/MainLayout.tsx +0 -95
  87. package/src/editor/MobileLayout.tsx +0 -68
  88. package/src/editor/NewEditorClient.tsx +0 -11
  89. package/src/editor/PictureCropper.tsx +0 -503
  90. package/src/editor/PictureEditor.tsx +0 -277
  91. package/src/editor/PictureEditorDialog.tsx +0 -381
  92. package/src/editor/PublishDialog.ignore +0 -74
  93. package/src/editor/ScrollingContentTree.tsx +0 -67
  94. package/src/editor/Terminal.tsx +0 -227
  95. package/src/editor/Titlebar.tsx +0 -104
  96. package/src/editor/ai/AiPopup.tsx +0 -59
  97. package/src/editor/ai/AiResponseMessage.tsx +0 -106
  98. package/src/editor/ai/AiTerminal.tsx +0 -503
  99. package/src/editor/ai/AiToolCall.tsx +0 -61
  100. package/src/editor/ai/EditorAiTerminal.tsx +0 -20
  101. package/src/editor/ai/GhostWriter.tsx +0 -432
  102. package/src/editor/ai/aiPageModel.ts +0 -108
  103. package/src/editor/ai/editorAiContext.ts +0 -18
  104. package/src/editor/client/AboutDialog.tsx +0 -44
  105. package/src/editor/client/EditorClient.tsx +0 -2241
  106. package/src/editor/client/GenericDialog.tsx +0 -50
  107. package/src/editor/client/editContext.ts +0 -416
  108. package/src/editor/client/helpers.ts +0 -44
  109. package/src/editor/client/itemsRepository.ts +0 -574
  110. package/src/editor/client/operations.ts +0 -768
  111. package/src/editor/client/pageModelBuilder.ts +0 -219
  112. package/src/editor/commands/commands.ts +0 -22
  113. package/src/editor/commands/componentCommands.tsx +0 -424
  114. package/src/editor/commands/createVersionCommand.ts +0 -33
  115. package/src/editor/commands/deleteVersionCommand.ts +0 -71
  116. package/src/editor/commands/itemCommands.tsx +0 -351
  117. package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
  118. package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
  119. package/src/editor/commands/undo.ts +0 -39
  120. package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
  121. package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
  122. package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
  123. package/src/editor/component-designer/ComponentEditor.tsx +0 -97
  124. package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
  125. package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
  126. package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
  127. package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
  128. package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
  129. package/src/editor/component-designer/TemplateEditor.tsx +0 -236
  130. package/src/editor/component-designer/aiContext.ts +0 -23
  131. package/src/editor/componentTreeHelper.tsx +0 -116
  132. package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
  133. package/src/editor/context-menu/InsertMenu.tsx +0 -347
  134. package/src/editor/control-center/About.tsx +0 -342
  135. package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
  136. package/src/editor/control-center/IndexOverview.tsx +0 -50
  137. package/src/editor/control-center/IndexSettings.tsx +0 -266
  138. package/src/editor/control-center/Info.tsx +0 -104
  139. package/src/editor/control-center/QuotaInfo.tsx +0 -301
  140. package/src/editor/control-center/Status.tsx +0 -113
  141. package/src/editor/control-center/WebSocketMessages.tsx +0 -155
  142. package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
  143. package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
  144. package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
  145. package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
  146. package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
  147. package/src/editor/field-types/AttachmentEditor.tsx +0 -9
  148. package/src/editor/field-types/CheckboxEditor.tsx +0 -47
  149. package/src/editor/field-types/DropLinkEditor.tsx +0 -80
  150. package/src/editor/field-types/DropListEditor.tsx +0 -84
  151. package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
  152. package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
  153. package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
  154. package/src/editor/field-types/MultiLineText.tsx +0 -82
  155. package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
  156. package/src/editor/field-types/RawEditor.tsx +0 -53
  157. package/src/editor/field-types/ReactQuill.tsx +0 -580
  158. package/src/editor/field-types/RichTextEditor.tsx +0 -22
  159. package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
  160. package/src/editor/field-types/SingleLineText.tsx +0 -174
  161. package/src/editor/field-types/TreeListEditor.tsx +0 -261
  162. package/src/editor/fieldTypes.ts +0 -140
  163. package/src/editor/media-selector/AiImageSearch.tsx +0 -185
  164. package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
  165. package/src/editor/media-selector/MediaSelector.tsx +0 -42
  166. package/src/editor/media-selector/Preview.tsx +0 -14
  167. package/src/editor/media-selector/Thumbnails.tsx +0 -48
  168. package/src/editor/media-selector/TreeSelector.tsx +0 -292
  169. package/src/editor/media-selector/UploadZone.tsx +0 -137
  170. package/src/editor/menubar/ActionsMenu.tsx +0 -94
  171. package/src/editor/menubar/ActiveUsers.tsx +0 -17
  172. package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
  173. package/src/editor/menubar/BrowseHistory.tsx +0 -28
  174. package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
  175. package/src/editor/menubar/LanguageSelector.tsx +0 -226
  176. package/src/editor/menubar/Menu.tsx +0 -83
  177. package/src/editor/menubar/NavButtons.tsx +0 -74
  178. package/src/editor/menubar/PageSelector.tsx +0 -166
  179. package/src/editor/menubar/PageViewerControls.tsx +0 -120
  180. package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
  181. package/src/editor/menubar/SecondaryControls.tsx +0 -45
  182. package/src/editor/menubar/Separator.tsx +0 -12
  183. package/src/editor/menubar/SiteInfo.tsx +0 -53
  184. package/src/editor/menubar/User.tsx +0 -27
  185. package/src/editor/menubar/VersionSelector.tsx +0 -142
  186. package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
  187. package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
  188. package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
  189. package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
  190. package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
  191. package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
  192. package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
  193. package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
  194. package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
  195. package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
  196. package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
  197. package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
  198. package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
  199. package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
  200. package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
  201. package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
  202. package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
  203. package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
  204. package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
  205. package/src/editor/page-viewer/EditorForm.tsx +0 -258
  206. package/src/editor/page-viewer/MiniMap.tsx +0 -362
  207. package/src/editor/page-viewer/PageViewer.tsx +0 -169
  208. package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
  209. package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
  210. package/src/editor/page-viewer/pageViewContext.ts +0 -186
  211. package/src/editor/pageModel.ts +0 -220
  212. package/src/editor/picture-shared.tsx +0 -53
  213. package/src/editor/reviews/Comment.tsx +0 -307
  214. package/src/editor/reviews/Comments.tsx +0 -125
  215. package/src/editor/reviews/DiffView.tsx +0 -109
  216. package/src/editor/reviews/PreviewInfo.tsx +0 -35
  217. package/src/editor/reviews/Reviews.tsx +0 -280
  218. package/src/editor/reviews/SuggestedEdit.tsx +0 -316
  219. package/src/editor/reviews/reviewCommands.tsx +0 -47
  220. package/src/editor/reviews/useReviews.tsx +0 -70
  221. package/src/editor/services/aiService.ts +0 -174
  222. package/src/editor/services/componentDesignerService.ts +0 -151
  223. package/src/editor/services/contentService.ts +0 -180
  224. package/src/editor/services/editService.ts +0 -488
  225. package/src/editor/services/indexService.ts +0 -24
  226. package/src/editor/services/reviewsService.ts +0 -53
  227. package/src/editor/services/serviceHelper.ts +0 -95
  228. package/src/editor/services/suggestedEditsService.ts +0 -39
  229. package/src/editor/services/systemService.ts +0 -5
  230. package/src/editor/services/translationService.ts +0 -21
  231. package/src/editor/services-server/api.ts +0 -150
  232. package/src/editor/services-server/graphQL.ts +0 -106
  233. package/src/editor/sidebar/ComponentPalette.tsx +0 -161
  234. package/src/editor/sidebar/ComponentTree.tsx +0 -548
  235. package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
  236. package/src/editor/sidebar/Debug.tsx +0 -111
  237. package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
  238. package/src/editor/sidebar/EditHistory.tsx +0 -134
  239. package/src/editor/sidebar/GraphQL.tsx +0 -164
  240. package/src/editor/sidebar/Insert.tsx +0 -35
  241. package/src/editor/sidebar/MainContentTree.tsx +0 -102
  242. package/src/editor/sidebar/Performance.tsx +0 -53
  243. package/src/editor/sidebar/Sessions.tsx +0 -35
  244. package/src/editor/sidebar/Sidebar.tsx +0 -20
  245. package/src/editor/sidebar/SidebarView.tsx +0 -152
  246. package/src/editor/sidebar/Translations.tsx +0 -295
  247. package/src/editor/sidebar/Validation.tsx +0 -102
  248. package/src/editor/sidebar/ViewSelector.tsx +0 -60
  249. package/src/editor/sidebar/Workbox.tsx +0 -209
  250. package/src/editor/ui/CenteredMessage.tsx +0 -7
  251. package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
  252. package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
  253. package/src/editor/ui/DialogButtons.tsx +0 -11
  254. package/src/editor/ui/Icons.tsx +0 -709
  255. package/src/editor/ui/ItemList.tsx +0 -76
  256. package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
  257. package/src/editor/ui/ItemSearch.tsx +0 -153
  258. package/src/editor/ui/PerfectTree.tsx +0 -571
  259. package/src/editor/ui/Section.tsx +0 -35
  260. package/src/editor/ui/SimpleIconButton.tsx +0 -54
  261. package/src/editor/ui/SimpleMenu.tsx +0 -40
  262. package/src/editor/ui/SimpleTable.tsx +0 -60
  263. package/src/editor/ui/SimpleTabs.tsx +0 -55
  264. package/src/editor/ui/SimpleToolbar.tsx +0 -7
  265. package/src/editor/ui/Spinner.tsx +0 -9
  266. package/src/editor/ui/Splitter.tsx +0 -314
  267. package/src/editor/ui/StackedPanels.tsx +0 -134
  268. package/src/editor/ui/Toolbar.tsx +0 -7
  269. package/src/editor/utils/id-helper.ts +0 -3
  270. package/src/editor/utils/insertOptions.ts +0 -69
  271. package/src/editor/utils/itemutils.ts +0 -29
  272. package/src/editor/utils/useMemoDebug.ts +0 -28
  273. package/src/editor/utils.ts +0 -486
  274. package/src/editor/views/CompareView.tsx +0 -245
  275. package/src/editor/views/EditView.tsx +0 -27
  276. package/src/editor/views/ItemEditor.tsx +0 -58
  277. package/src/editor/views/SingleEditView.tsx +0 -46
  278. package/src/fonts/Geist-Black.woff2 +0 -0
  279. package/src/fonts/Geist-Bold.woff2 +0 -0
  280. package/src/fonts/Geist-ExtraBold.woff2 +0 -0
  281. package/src/fonts/Geist-ExtraLight.woff2 +0 -0
  282. package/src/fonts/Geist-Light.woff2 +0 -0
  283. package/src/fonts/Geist-Medium.woff2 +0 -0
  284. package/src/fonts/Geist-Regular.woff2 +0 -0
  285. package/src/fonts/Geist-SemiBold.woff2 +0 -0
  286. package/src/fonts/Geist-Thin.woff2 +0 -0
  287. package/src/fonts/Geist[wght].woff2 +0 -0
  288. package/src/fonts/index.ts +0 -10
  289. package/src/index.ts +0 -23
  290. package/src/lib/safelist.tsx +0 -16
  291. package/src/lib/utils.ts +0 -6
  292. package/src/page-wizard/PageWizard.tsx +0 -139
  293. package/src/page-wizard/WizardBox.tsx +0 -4
  294. package/src/page-wizard/WizardBoxConnector.tsx +0 -56
  295. package/src/page-wizard/WizardSteps.tsx +0 -458
  296. package/src/page-wizard/service.ts +0 -35
  297. package/src/page-wizard/startPageWizardCommand.ts +0 -26
  298. package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
  299. package/src/page-wizard/steps/CollectStep.tsx +0 -296
  300. package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
  301. package/src/page-wizard/steps/Components.tsx +0 -193
  302. package/src/page-wizard/steps/ContentStep.tsx +0 -890
  303. package/src/page-wizard/steps/EditButton.tsx +0 -34
  304. package/src/page-wizard/steps/FieldEditor.tsx +0 -102
  305. package/src/page-wizard/steps/Generate.tsx +0 -60
  306. package/src/page-wizard/steps/ImagesStep.tsx +0 -382
  307. package/src/page-wizard/steps/LayoutStep.tsx +0 -227
  308. package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
  309. package/src/page-wizard/steps/SelectStep.tsx +0 -281
  310. package/src/page-wizard/steps/schema.ts +0 -180
  311. package/src/page-wizard/steps/usePageCreator.ts +0 -325
  312. package/src/page-wizard/usePageWizard.ts +0 -79
  313. package/src/revision.ts +0 -2
  314. package/src/splash-screen/NewPage.tsx +0 -294
  315. package/src/splash-screen/OpenPage.tsx +0 -113
  316. package/src/splash-screen/RecentPages.tsx +0 -123
  317. package/src/splash-screen/SectionHeadline.tsx +0 -21
  318. package/src/splash-screen/SplashScreen.tsx +0 -195
  319. package/src/tour/Tour.tsx +0 -566
  320. package/src/tour/default-tour.tsx +0 -301
  321. package/src/tour/preview-tour.tsx +0 -128
  322. package/src/types.ts +0 -335
  323. package/styles.css +0 -765
  324. package/tsconfig.build.json +0 -31
  325. package/tsconfig.json +0 -14
@@ -1,68 +0,0 @@
1
- import { cn } from "../lib/utils";
2
- import { MainLayoutProps } from "./MainLayout";
3
- import { ViewSelector } from "./sidebar/ViewSelector";
4
- import { useEditContext } from "./client/editContext";
5
- import { Splitter, SplitterPanel } from "./ui/Splitter";
6
- import { SidebarView } from "./sidebar/SidebarView";
7
-
8
- export function MobileLayout(props: MainLayoutProps) {
9
- const editContext = useEditContext();
10
-
11
- if (!editContext) return null;
12
-
13
- let className = props.className;
14
-
15
- if (!editContext?.configuration.editor.embedded) {
16
- className = cn("fixed inset-0", props.className);
17
- }
18
-
19
- const panels: SplitterPanel[] = [
20
- {
21
- name: "center",
22
- defaultSize: "auto",
23
- content: props.centerPanelView,
24
- },
25
- ];
26
-
27
- const viewsWithLeftSidebar = editContext.configuration.editor.views.filter(
28
- (v) => v.leftSidebar,
29
- );
30
-
31
- if (viewsWithLeftSidebar.length > 0) {
32
- panels.push({
33
- name: "sidebar",
34
- hidden: !props.view.leftSidebar,
35
- defaultSize: 250,
36
- content: (
37
- <div className="relative h-full w-full">
38
- {viewsWithLeftSidebar.map((v) => (
39
- <SidebarView
40
- key={v.name}
41
- sidebar={v.leftSidebar!}
42
- editContext={editContext}
43
- active={props.view.name === v.name && !!v.leftSidebar}
44
- />
45
- ))}
46
- </div>
47
- ),
48
- });
49
- }
50
-
51
- return (
52
- <div className={cn("flex flex-col select-none", className)}>
53
- {editContext?.configuration.editor.titlebar}
54
-
55
- <Splitter
56
- panels={panels}
57
- direction="vertical"
58
- localStorageKey="mobile-layout-splitter"
59
- />
60
-
61
- {!props.view.hideViewSelector && <ViewSelector />}
62
- {/* <div className="text-2xs fixed right-0 bottom-0 z-50 flex flex-col rounded-tl-2xl bg-gray-50/70 px-1 pt-1 text-center font-mono text-gray-400">
63
- <div title={buildDate}>{version}</div>
64
- </div> */}
65
- {/* Sidebars rendered above */}
66
- </div>
67
- );
68
- }
@@ -1,11 +0,0 @@
1
- "use client";
2
-
3
- import { EditorConfiguration } from "../config/types";
4
-
5
- export function NewEditorClient(props: {
6
- className?: string;
7
- configuration: EditorConfiguration;
8
- }) {
9
- console.log(props);
10
- return <div>Hello</div>;
11
- }
@@ -1,503 +0,0 @@
1
- import { Dialog } from "primereact/dialog";
2
- import { useEditContext } from "./client/editContext";
3
- import { ReactNode, useEffect, useRef, useState } from "react";
4
- import { Button } from "primereact/button";
5
- import DialogButtons from "./ui/DialogButtons";
6
- import { Rect } from "./utils";
7
- import { classNames } from "primereact/utils";
8
- import {
9
- PictureField,
10
- PictureRawValue,
11
- PictureValue,
12
- PictureVariant,
13
- } from "./fieldTypes";
14
-
15
- export function PictureCropper({
16
- field,
17
- onClose,
18
- variantName: selectedVariantName,
19
- }: {
20
- field: PictureField;
21
- variantName: string;
22
- onClose: () => void;
23
- }) {
24
- const [pictureValue, setPictureValue] = useState<PictureValue>();
25
- const [isValid, setIsValid] = useState<boolean>(true);
26
- const [rawValue, setRawValue] = useState<PictureRawValue>();
27
-
28
- const imageRef = useRef<HTMLDivElement>(null);
29
- const [rect, setRect] = useState<Rect>();
30
- const rectRef = useRef(rect);
31
- const movingRef = useRef(false);
32
- const [startPos, setStartPos] = useState<{ x: number; y: number }>({
33
- x: 0,
34
- y: 0,
35
- });
36
- const offset = useRef<{ x: number; y: number }>({ x: 0, y: 0 });
37
-
38
- const editContext = useEditContext();
39
-
40
- const EDGE_THRESHOLD = 10; // pixels from edge to detect resize
41
-
42
- const [resizeEdge, setResizeEdge] = useState<string | null>(null);
43
- const resizeEdgeRef = useRef<string | null>(null);
44
-
45
- const getResizeEdge = (
46
- pos: { x: number; y: number },
47
- rect?: Rect,
48
- bounds?: DOMRect,
49
- ) => {
50
- if (!rect || !bounds) return null;
51
-
52
- const x = pos.x * bounds.width;
53
- const y = pos.y * bounds.height;
54
- const rectX = rect.x * bounds.width;
55
- const rectY = rect.y * bounds.height;
56
- const rectWidth = rect.width * bounds.width;
57
- const rectHeight = rect.height * bounds.height;
58
-
59
- const isNearLeft = Math.abs(x - rectX) < EDGE_THRESHOLD;
60
- const isNearRight = Math.abs(x - (rectX + rectWidth)) < EDGE_THRESHOLD;
61
- const isNearTop = Math.abs(y - rectY) < EDGE_THRESHOLD;
62
- const isNearBottom = Math.abs(y - (rectY + rectHeight)) < EDGE_THRESHOLD;
63
-
64
- if (isNearLeft && isNearTop) return "nw";
65
- if (isNearRight && isNearTop) return "ne";
66
- if (isNearLeft && isNearBottom) return "sw";
67
- if (isNearRight && isNearBottom) return "se";
68
- if (isNearLeft) return "w";
69
- if (isNearRight) return "e";
70
- if (isNearTop) return "n";
71
- if (isNearBottom) return "s";
72
-
73
- return null;
74
- };
75
-
76
- useEffect(() => {
77
- const deepCopy = JSON.parse(JSON.stringify(field.value));
78
- setPictureValue(deepCopy);
79
- const raw = field?.rawValue
80
- ? (JSON.parse(field?.rawValue) as PictureRawValue)
81
- : ({ Variants: [] } as PictureRawValue);
82
- setRawValue(raw);
83
- }, [field]);
84
-
85
- const selectedVariant =
86
- pictureValue && pictureValue.variants
87
- ? pictureValue.variants?.find(
88
- (x: PictureVariant) => x.name == selectedVariantName,
89
- )
90
- : null;
91
-
92
- useEffect(() => {
93
- if (
94
- selectedVariant?.region &&
95
- (!selectedVariant.aspectRatioLock ||
96
- Math.abs(
97
- selectedVariant.aspectRatioLock -
98
- (selectedVariant.region.width * selectedVariant.width) /
99
- (selectedVariant.region.height * selectedVariant.height),
100
- ) < 0.1) &&
101
- selectedVariant.region.width > 0 &&
102
- selectedVariant.region.height > 0
103
- ) {
104
- setRect({
105
- width: selectedVariant.region.width,
106
- height: selectedVariant.region.height,
107
- y: selectedVariant.region.y,
108
- x: selectedVariant.region.x,
109
- });
110
- } else {
111
- setRect(undefined);
112
- }
113
- }, [selectedVariant]);
114
-
115
- useEffect(() => {
116
- if (!rect) return;
117
- if (
118
- (selectedVariant?.minWidth && selectedVariant.minWidth > widthPx) ||
119
- (selectedVariant?.minHeight && selectedVariant?.minHeight > heightPx)
120
- ) {
121
- setIsValid(false);
122
- } else setIsValid(true);
123
- rectRef.current = rect;
124
- }, [rect]);
125
-
126
- useEffect(() => {
127
- if (!rawValue) return;
128
- if (!selectedVariantName) return;
129
- if (selectedVariant) {
130
- let selected = rawValue.Variants?.find(
131
- (x) => x.Name == selectedVariantName,
132
- );
133
- if (!selected) {
134
- selected = {
135
- Name: selectedVariantName,
136
- MediaId: selectedVariant.mediaId!,
137
- };
138
- rawValue.Variants?.push(selected);
139
- }
140
- if (selected) {
141
- if (rect)
142
- selected.Region = {
143
- X: rect.x,
144
- Y: rect.y,
145
- Width: rect.width,
146
- Height: rect.height,
147
- };
148
- else selected.Region = undefined;
149
- setRawValue(rawValue);
150
- }
151
- }
152
- }, [rect]);
153
-
154
- const handleMouseMove = (ev: React.MouseEvent) => {
155
- if (!selectedVariant) return null;
156
-
157
- const bounds = imageRef.current?.getBoundingClientRect();
158
- if (!bounds) return;
159
-
160
- const pos = {
161
- x: (ev.clientX - bounds.left) / bounds.width,
162
- y: (ev.clientY - bounds.top) / bounds.height,
163
- };
164
-
165
- // Update cursor on hover (when not dragging)
166
- if (ev.buttons !== 1) {
167
- const edge = getResizeEdge(pos, rect, bounds);
168
- setResizeEdge(edge);
169
- return;
170
- }
171
-
172
- if (ev.buttons === 1) {
173
- if (!rectRef.current || !imageRef.current) return;
174
- const rect = rectRef.current;
175
-
176
- const bounds = imageRef.current.getBoundingClientRect();
177
- const deltaX = ev.clientX - startPos.x;
178
- const deltaY = ev.clientY - startPos.y;
179
- if (resizeEdgeRef.current) {
180
- const pos = {
181
- x: (ev.clientX - bounds.left) / bounds.width,
182
- y: (ev.clientY - bounds.top) / bounds.height,
183
- };
184
-
185
- let newRect = { ...rect };
186
- const aspectRatio = selectedVariant.aspectRatioLock;
187
- const originalAspectRatio =
188
- selectedVariant.width / selectedVariant.height;
189
-
190
- if (resizeEdgeRef.current.includes("w")) {
191
- const newWidth = rect.width + rect.x - pos.x;
192
- if (newWidth > 0) {
193
- newRect.width = newWidth;
194
- newRect.x = pos.x;
195
- if (aspectRatio) {
196
- newRect.height =
197
- (newRect.width / aspectRatio) * originalAspectRatio;
198
- }
199
- }
200
- }
201
- if (resizeEdgeRef.current.includes("e")) {
202
- newRect.width = pos.x - rect.x;
203
- if (aspectRatio) {
204
- newRect.height =
205
- (newRect.width / aspectRatio) * originalAspectRatio;
206
- }
207
- }
208
- if (resizeEdgeRef.current.includes("n")) {
209
- const newHeight = rect.height + rect.y - pos.y;
210
- if (newHeight > 0) {
211
- newRect.height = newHeight;
212
- newRect.y = pos.y;
213
- if (aspectRatio) {
214
- newRect.width =
215
- (newRect.height * aspectRatio) / originalAspectRatio;
216
- }
217
- }
218
- }
219
- if (resizeEdgeRef.current.includes("s")) {
220
- newRect.height = pos.y - rect.y;
221
- if (aspectRatio) {
222
- newRect.width =
223
- (newRect.height * aspectRatio) / originalAspectRatio;
224
- }
225
- }
226
-
227
- // Constrain to bounds
228
- if (newRect.x < 0) newRect.x = 0;
229
- if (newRect.y < 0) newRect.y = 0;
230
- if (newRect.x + newRect.width > 1) newRect.width = 1 - newRect.x;
231
- if (newRect.y + newRect.height > 1) newRect.height = 1 - newRect.y;
232
-
233
- setRect(newRect);
234
- } else if (movingRef.current) {
235
- setRect({
236
- ...rect,
237
- x: Math.max(
238
- 0,
239
- Math.min(
240
- 1 - rectRef.current.width,
241
- (ev.clientX - bounds.left) / bounds.width - offset.current.x,
242
- ),
243
- ),
244
- y: Math.max(
245
- 0,
246
- Math.min(
247
- 1 - rectRef.current.height,
248
- (ev.clientY - bounds.top) / bounds.height - offset.current.y,
249
- ),
250
- ),
251
- });
252
- } else {
253
- const originalAspectRatio =
254
- selectedVariant.width / selectedVariant.height;
255
-
256
- const aspectRatio = selectedVariant.aspectRatioLock;
257
-
258
- let width = (ev.clientX - bounds.left) / bounds.width - rect.x;
259
- let height = (ev.clientY - bounds.top) / bounds.height - rect.y;
260
-
261
- if (aspectRatio) {
262
- if (Math.abs(deltaX) > Math.abs(deltaY)) {
263
- height = (width / aspectRatio) * originalAspectRatio;
264
- } else {
265
- width = (height * aspectRatio) / originalAspectRatio;
266
- }
267
- }
268
-
269
- if (width + rect.x > 1) {
270
- width = 1 - rect.x;
271
- if (aspectRatio) height = (width / aspectRatio) * originalAspectRatio;
272
- }
273
-
274
- if (height + rect.y > 1) {
275
- height = 1 - rect.y;
276
- if (aspectRatio) width = (height * aspectRatio) / originalAspectRatio;
277
- }
278
-
279
- const newRect = { ...rect, width, height };
280
- setRect(newRect);
281
- }
282
- ev.preventDefault();
283
- ev.stopPropagation();
284
- }
285
- };
286
-
287
- const handleMouseUp = () => {
288
- if (!rectRef.current || !rectRef.current.width || !rectRef.current.height) {
289
- setRect(undefined);
290
- }
291
- movingRef.current = false;
292
- resizeEdgeRef.current = null;
293
- setResizeEdge(null);
294
- // window.removeEventListener("mousemove", handleMouseMove);
295
- window.removeEventListener("mouseup", handleMouseUp);
296
- };
297
-
298
- const isInRect = (pos: { x: number; y: number }, rect?: Rect) => {
299
- if (!rect || !selectedVariant) return false;
300
-
301
- return (
302
- pos.x >= rect.x &&
303
- pos.x <= rect.x + rect.width &&
304
- pos.y >= rect.y &&
305
- pos.y <= rect.y + rect.height
306
- );
307
- };
308
-
309
- const handleMouseDown = (ev: React.MouseEvent) => {
310
- ev.preventDefault();
311
- ev.stopPropagation();
312
- const bounds = ev.currentTarget.getBoundingClientRect();
313
- const pos = {
314
- x: (ev.clientX - bounds.left) / bounds.width,
315
- y: (ev.clientY - bounds.top) / bounds.height,
316
- };
317
-
318
- const edge = getResizeEdge(pos, rect, bounds);
319
- if (edge) {
320
- resizeEdgeRef.current = edge;
321
- setResizeEdge(edge);
322
- } else if (isInRect(pos, rect)) {
323
- movingRef.current = true;
324
- offset.current = {
325
- x: pos.x - rect!.x,
326
- y: pos.y - rect!.y,
327
- };
328
- } else {
329
- setRect({
330
- x: (ev.clientX - bounds.left) / bounds.width,
331
- y: (ev.clientY - bounds.top) / bounds.height,
332
- width: 0,
333
- height: 0,
334
- });
335
- }
336
-
337
- setStartPos({ x: ev.clientX, y: ev.clientY });
338
-
339
- window.addEventListener("mouseup", handleMouseUp);
340
- };
341
-
342
- if (!selectedVariant) return null;
343
-
344
- const imageBounds = imageRef.current?.getBoundingClientRect();
345
- const scale = imageBounds ? selectedVariant.width / imageBounds.width : 0;
346
- const widthPx = rect ? Math.round(rect.width * selectedVariant.width) : 0;
347
- const heightPx = rect ? Math.round(rect.height * selectedVariant.height) : 0;
348
-
349
- return (
350
- <>
351
- <Dialog
352
- header={"Crop " + field.name + " - " + selectedVariantName}
353
- pt={{ content: { style: { paddingLeft: "0" } } }}
354
- visible={true}
355
- style={{ width: "75vw", height: "75vh" }}
356
- onHide={onClose}
357
- >
358
- <div className="justify flex h-full flex-col gap-1">
359
- <div className="flex flex-1 gap-2">
360
- <div className="flex w-56 flex-col gap-3 bg-gray-100 p-4 text-sm">
361
- <LabelAndValue label="Variant:" value={selectedVariantName} />
362
- <LabelAndValue
363
- label="Image Dimensions:"
364
- value={
365
- <>
366
- {selectedVariant.width} x {selectedVariant.height}
367
- </>
368
- }
369
- />
370
- {selectedVariant.aspectRatioLock && (
371
- <LabelAndValue
372
- label="Required Aspect Ratio:"
373
- value={selectedVariant.aspectRatioLockText}
374
- />
375
- )}
376
- {selectedVariant.minWidth && (
377
- <LabelAndValue
378
- label="Minimum Width:"
379
- value={selectedVariant.minWidth}
380
- />
381
- )}
382
- {selectedVariant.minHeight && (
383
- <LabelAndValue
384
- label="Minimum Height:"
385
- value={selectedVariant.minHeight}
386
- />
387
- )}
388
- {rect && (
389
- <>
390
- <LabelAndValue
391
- label="Selection:"
392
- value={
393
- <>
394
- {widthPx} x {heightPx}
395
- </>
396
- }
397
- />
398
- {selectedVariant.minWidth &&
399
- widthPx < selectedVariant.minWidth && (
400
- <div className="text-red-500">Minimum width not met!</div>
401
- )}
402
- {selectedVariant.minHeight &&
403
- heightPx < selectedVariant.minHeight && (
404
- <div className="text-red-500">
405
- Minimum height not met!
406
- </div>
407
- )}
408
- </>
409
- )}
410
- </div>
411
- <div className="relative flex-1 p-3">
412
- <div className="absolute inset-0 top-3 flex items-center justify-center select-none">
413
- <div
414
- ref={imageRef}
415
- className="relative max-h-full cursor-crosshair"
416
- style={{
417
- aspectRatio: `${selectedVariant.width}/${selectedVariant.height}`,
418
- }}
419
- onMouseDown={handleMouseDown}
420
- onMouseMove={handleMouseMove}
421
- >
422
- <img
423
- className="object-scale-down"
424
- src={selectedVariant.originalSrc ?? selectedVariant.src}
425
- />
426
- {rect && (
427
- <div
428
- className={classNames(
429
- "absolute cursor-move border text-xs opacity-70",
430
- isValid
431
- ? "border-blue-400 bg-blue-200 text-blue-500"
432
- : "border-red-400 bg-red-200 text-red-500",
433
- )}
434
- style={{
435
- left: rect.x * 100 + "%",
436
- top: rect.y * 100 + "%",
437
- width: widthPx / scale + "px",
438
- height: heightPx / scale + "px",
439
- cursor: resizeEdge
440
- ? resizeEdge.length === 1
441
- ? `${resizeEdge}-resize`
442
- : `${resizeEdge}-resize`
443
- : "move",
444
- }}
445
- >
446
- {widthPx / scale > 50 && (
447
- <div
448
- className="absolute right-2 bottom-1 text-nowrap"
449
- style={{ textShadow: "white 1px 1px" }}
450
- >
451
- {widthPx} x {heightPx}
452
- </div>
453
- )}
454
- </div>
455
- )}
456
- </div>
457
- </div>
458
- </div>
459
- </div>
460
- <DialogButtons>
461
- <Button onClick={() => setRect(undefined)}>Reset</Button>
462
- <Button
463
- size="small"
464
- disabled={!isValid}
465
- onClick={() => {
466
- if (pictureValue) {
467
- if (field) {
468
- editContext?.operations.editField({
469
- field: field.descriptor,
470
- rawValue: JSON.stringify(rawValue),
471
- refresh: "immediate",
472
- });
473
- }
474
- }
475
- onClose();
476
- }}
477
- >
478
- Ok
479
- </Button>
480
- <Button onClick={onClose} size="small">
481
- Cancel
482
- </Button>
483
- </DialogButtons>
484
- </div>
485
- </Dialog>
486
- </>
487
- );
488
- }
489
-
490
- function LabelAndValue({
491
- label,
492
- value,
493
- }: {
494
- label: ReactNode;
495
- value: ReactNode;
496
- }) {
497
- return (
498
- <div>
499
- <div className="font-bold">{label}</div>
500
- <div>{value}</div>
501
- </div>
502
- );
503
- }