@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,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ControlCenterMenu = ControlCenterMenu;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const navigation_1 = require("next/navigation");
6
+ const navigation_2 = require("next/navigation");
7
+ const editContext_1 = require("../client/editContext");
8
+ const SimpleMenu_1 = require("../ui/SimpleMenu");
9
+ const react_1 = require("react");
10
+ function ControlCenterMenu() {
11
+ const editContext = (0, editContext_1.useEditContext)();
12
+ const config = editContext?.configuration;
13
+ const searchParams = (0, navigation_2.useSearchParams)();
14
+ const urlActiveItemKey = searchParams.get("ccpanel");
15
+ const [activeItemKey, setActiveItemKey] = (0, react_1.useState)(urlActiveItemKey);
16
+ const router = (0, navigation_1.useRouter)();
17
+ const pathname = (0, navigation_2.usePathname)();
18
+ const updateUrl = (key) => {
19
+ if (urlActiveItemKey === key)
20
+ return;
21
+ const current = new URLSearchParams(Array.from(searchParams.entries()));
22
+ if (key) {
23
+ current.set("ccpanel", key);
24
+ }
25
+ else {
26
+ current.delete("ccpanel");
27
+ }
28
+ router.push(`${pathname}?${current.toString()}`, { scroll: false });
29
+ };
30
+ (0, react_1.useEffect)(() => {
31
+ updateUrl(activeItemKey);
32
+ }, [activeItemKey]);
33
+ const items = config?.controlCenter.groups.map((group) => {
34
+ return {
35
+ key: group.title,
36
+ label: group.title,
37
+ icon: group.icon,
38
+ items: group.panels.map((panel) => ({
39
+ key: panel.id,
40
+ label: panel.title,
41
+ })) || [],
42
+ };
43
+ });
44
+ (0, react_1.useEffect)(() => {
45
+ const groups = config?.controlCenter.groups;
46
+ const item = groups
47
+ ?.flatMap((x) => x.panels)
48
+ ?.find((item) => item.id === activeItemKey);
49
+ if (item) {
50
+ editContext?.setCenterPanelView(item.content);
51
+ }
52
+ }, [activeItemKey]);
53
+ if (!items) {
54
+ return null;
55
+ }
56
+ return ((0, jsx_runtime_1.jsx)(SimpleMenu_1.SimpleMenu, { items: items, activeItemKey: activeItemKey, onItemClick: (item) => {
57
+ setActiveItemKey(item.key);
58
+ } }));
59
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexOverview = IndexOverview;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_2 = require("react");
7
+ const indexService_1 = require("../services/indexService");
8
+ const IndexSettings_1 = require("./IndexSettings");
9
+ const utils_1 = require("primereact/utils");
10
+ function IndexOverview() {
11
+ const [indexes, setIndexes] = (0, react_2.useState)(undefined);
12
+ const [selectedIndex, setSelectedIndex] = (0, react_2.useState)(undefined);
13
+ (0, react_1.useEffect)(() => {
14
+ async function loadIndexes() {
15
+ const indexes = await (0, indexService_1.getIndexes)();
16
+ if (indexes.indexOf("master") === -1) {
17
+ indexes.push("master");
18
+ }
19
+ if (indexes.indexOf("media") === -1) {
20
+ indexes.push("media");
21
+ }
22
+ setIndexes(indexes);
23
+ }
24
+ loadIndexes();
25
+ }, []);
26
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-stretch h-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2 border-r border-gray-200", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center p-2 min-w-40 border-b border-gray-200", children: "Index" }), indexes?.map((index) => ((0, jsx_runtime_1.jsx)("div", { onClick: () => setSelectedIndex(index), className: (0, utils_1.classNames)("cursor-pointer p-2 px-6 hover:bg-gray-100 text-sm", selectedIndex === index && "bg-gray-100"), children: index }, index)))] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-2", children: selectedIndex && (0, jsx_runtime_1.jsx)(IndexSettings_1.IndexSettings, { index: { name: selectedIndex } }) })] }));
27
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexSettings = IndexSettings;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const indexService_1 = require("../services/indexService");
7
+ const button_1 = require("primereact/button");
8
+ const Spinner_1 = require("../ui/Spinner");
9
+ const editContext_1 = require("../client/editContext");
10
+ const progressspinner_1 = require("primereact/progressspinner");
11
+ function IndexSettings({ index }) {
12
+ const editContext = (0, editContext_1.useEditContext)();
13
+ const [indexStatus, setIndexStatus] = (0, react_1.useState)(undefined);
14
+ const [settingsItem, setSettingsItem] = (0, react_1.useState)(undefined);
15
+ const [rebuildJobItem, setRebuildJobItem] = (0, react_1.useState)(undefined);
16
+ const fetchStatus = (0, react_1.useCallback)(() => {
17
+ (0, indexService_1.getIndexStatus)(index.name).then(async (result) => {
18
+ setIndexStatus(result);
19
+ if (result?.settingsItemId) {
20
+ const settingsItem = await editContext?.itemsRepository.getItem({
21
+ id: result.settingsItemId,
22
+ language: "en",
23
+ version: 0,
24
+ });
25
+ setSettingsItem(settingsItem);
26
+ if (result.rebuildJobItemId) {
27
+ const rebuildJobItem = await editContext?.itemsRepository.getItem({
28
+ id: result.rebuildJobItemId,
29
+ language: "en",
30
+ version: 0,
31
+ });
32
+ setRebuildJobItem(rebuildJobItem);
33
+ }
34
+ else {
35
+ setRebuildJobItem(undefined);
36
+ }
37
+ }
38
+ else {
39
+ setSettingsItem(undefined);
40
+ setRebuildJobItem(undefined);
41
+ }
42
+ });
43
+ }, [index]);
44
+ (0, react_1.useEffect)(() => {
45
+ let interval;
46
+ if (indexStatus?.isRunning) {
47
+ interval = setInterval(() => {
48
+ fetchStatus();
49
+ }, 1000);
50
+ }
51
+ return () => {
52
+ if (interval) {
53
+ clearInterval(interval);
54
+ }
55
+ };
56
+ }, [indexStatus?.isRunning, fetchStatus]);
57
+ (0, react_1.useEffect)(() => {
58
+ fetchStatus();
59
+ }, [fetchStatus]);
60
+ (0, react_1.useEffect)(() => {
61
+ setIndexStatus(undefined);
62
+ }, [index]);
63
+ if (!indexStatus) {
64
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col h-full justify-center items-center gap-2 text-gray-500", children: [(0, jsx_runtime_1.jsx)(Spinner_1.Spinner, {}), "Loading..."] }));
65
+ }
66
+ async function setupIndexAndRefresh(index) {
67
+ await (0, indexService_1.setupIndex)(index);
68
+ setIndexStatus(undefined);
69
+ fetchStatus();
70
+ }
71
+ async function setupRebuildJobAndRefresh(index) {
72
+ await (0, indexService_1.setupRebuildJob)(index);
73
+ setIndexStatus(undefined);
74
+ fetchStatus();
75
+ }
76
+ async function rebuildIndexAndRefresh(index) {
77
+ await (0, indexService_1.rebuildIndex)(index);
78
+ setTimeout(() => {
79
+ fetchStatus();
80
+ }, 1000);
81
+ }
82
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col px-2 py-1 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-row items-center border-b p-1 mb-3", children: (0, jsx_runtime_1.jsx)("div", { className: "", children: index.name }) }), (0, jsx_runtime_1.jsxs)("div", { className: "ml-2", children: [settingsItem && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(IndexProp, { headline: "Settings", children: (0, jsx_runtime_1.jsx)("a", { className: "cursor-pointer underline", onClick: () => {
83
+ if (indexStatus.settingsItemId) {
84
+ editContext?.loadItem(indexStatus.settingsItemId);
85
+ editContext?.switchView("content-editor");
86
+ }
87
+ }, children: settingsItem.path }) }), (0, jsx_runtime_1.jsx)(IndexProp, { headline: "Service", children: indexStatus.serviceUrl }), (0, jsx_runtime_1.jsx)(IndexProp, { headline: "Name", children: indexStatus.name }), (0, jsx_runtime_1.jsxs)(IndexProp, { headline: "Rebuild Job", children: [rebuildJobItem && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("a", { className: "cursor-pointer underline", onClick: () => {
88
+ if (indexStatus.rebuildJobItemId) {
89
+ editContext?.loadItem(indexStatus.rebuildJobItemId);
90
+ editContext?.switchView("content-editor");
91
+ }
92
+ }, children: rebuildJobItem.path }), indexStatus.canRebuild && !indexStatus.isRunning && ((0, jsx_runtime_1.jsx)("div", { className: "my-2", children: (0, jsx_runtime_1.jsx)(button_1.Button, { label: "Rebuild Index", onClick: () => {
93
+ rebuildIndexAndRefresh(index.name);
94
+ } }) })), indexStatus.isRunning && ((0, jsx_runtime_1.jsxs)("div", { className: "my-2 flex flex-row items-center justify-start", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mr-2", style: { width: "20px" }, children: [(0, jsx_runtime_1.jsx)(progressspinner_1.ProgressSpinner, { style: { width: "20px", height: "20px" } }), " "] }), "Rebuilding... ", indexStatus.rebuildCount.toLocaleString(), " ", "items, ", indexStatus.rebuildTokensCount.toLocaleString(), " ", "tokens"] }))] })), !rebuildJobItem && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm text-gray-500 mb-2", children: "No rebuild job found for this index" }), (0, jsx_runtime_1.jsx)(button_1.Button, { label: "Setup Rebuild Job", onClick: () => {
95
+ setupRebuildJobAndRefresh(index.name);
96
+ } })] }))] }), (0, jsx_runtime_1.jsx)(IndexProp, { headline: "Last Rebuild", children: indexStatus.lastRebuildStartDateTime
97
+ ? new Date(indexStatus.lastRebuildStartDateTime).toLocaleString()
98
+ : "Never" }), indexStatus.exists && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(IndexProp, { headline: "Index Status", children: Object.entries(indexStatus.languages).map(([language, { numberOfItems, lastUpdated, status }]) => ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [(0, jsx_runtime_1.jsxs)("div", { className: "font-bold", children: [language, ":"] }), (0, jsx_runtime_1.jsx)("span", { className: `text-gray-500 ml-2 ${status === "Available"
99
+ ? "text-green-500"
100
+ : "text-yellow-500"}`, children: status }), (0, jsx_runtime_1.jsxs)("span", { className: "text-gray-500", children: ["Items: ", numberOfItems.toLocaleString(), " "] }), (0, jsx_runtime_1.jsxs)("span", { className: "text-gray-500", children: ["Last updated: ", new Date(lastUpdated).toLocaleString()] })] }, language))) }) })), indexStatus.errors?.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { children: "Errors:" }), indexStatus.errors.map((error, index) => ((0, jsx_runtime_1.jsxs)("div", { className: "mt-2 p-2 bg-red-100 rounded-md text-red-800 border border-red-300 ", children: [(0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: error.message }), (0, jsx_runtime_1.jsx)("div", { className: "text-sm", children: error.details })] }, index)))] }))] })), !indexStatus?.exists && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm text-gray-500 mb-2", children: "Index does not exist" }), (0, jsx_runtime_1.jsx)(button_1.Button, { label: "Setup index", onClick: () => {
101
+ setupIndexAndRefresh(index.name);
102
+ } })] })), " "] })] }));
103
+ }
104
+ function IndexProp({ headline, children, }) {
105
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "font-bold text-sm", children: headline }), (0, jsx_runtime_1.jsx)("div", { className: "text-sm", children: children })] }));
106
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Status = Status;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function Status() {
6
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col justify-center items-center h-full", children: "Status" }));
7
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemLocked = ItemLocked;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const EditorWarning_1 = require("../EditorWarning");
6
+ const editContext_1 = require("../client/editContext");
7
+ function ItemLocked({ item }) {
8
+ if (!item.canLock)
9
+ return;
10
+ var editContext = (0, editContext_1.useEditContext)();
11
+ if (!editContext)
12
+ return;
13
+ if (item.hasLock) {
14
+ return ((0, jsx_runtime_1.jsx)(EditorWarning_1.EditorWarning, { title: "Item locked", severity: "warning", children: (0, jsx_runtime_1.jsx)("button", { onClick: () => {
15
+ const items = [item];
16
+ editContext.operations.unlockItems(items);
17
+ }, children: "Release lock" }) }));
18
+ }
19
+ if (item.lockedBy == null) {
20
+ return ((0, jsx_runtime_1.jsx)(EditorWarning_1.EditorWarning, { title: "Item is locked", severity: "warning", children: (0, jsx_runtime_1.jsxs)("div", { children: ["Locked by ", item.lockedBy] }) }));
21
+ }
22
+ // else {
23
+ // return (
24
+ // <EditorWarning title="Item not locked" severity="warning">
25
+ // {item.canLock && (
26
+ // <button
27
+ // onClick={() => {
28
+ // const items: ItemDescriptor[] = [item];
29
+ // if ((item as ComponentData).linkedComponentItem)
30
+ // items.push((item as ComponentData).linkedComponentItem);
31
+ // editContext!.lockItems(items);
32
+ // }}
33
+ // >
34
+ // Lock item
35
+ // </button>
36
+ // )}
37
+ // </EditorWarning>
38
+ // );
39
+ // }
40
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoWriteLanguageAccess = NoWriteLanguageAccess;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const EditorWarning_1 = require("../EditorWarning");
6
+ const editContext_1 = require("../client/editContext");
7
+ function NoWriteLanguageAccess({ item }) {
8
+ var editContext = (0, editContext_1.useEditContext)();
9
+ if (!editContext)
10
+ return;
11
+ if (!item.canWriteItem)
12
+ return;
13
+ if (!item.canWriteLanguage) {
14
+ return ((0, jsx_runtime_1.jsx)(EditorWarning_1.EditorWarning, { title: "You dont have language write access.", severity: "warning", children: (0, jsx_runtime_1.jsxs)("p", { children: ["You can't edit this item because you don't have write access for language ", editContext.page?.item.language, "."] }) }));
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoWorkflowWriteAccess = NoWorkflowWriteAccess;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const EditorWarning_1 = require("../EditorWarning");
6
+ const editContext_1 = require("../client/editContext");
7
+ function NoWorkflowWriteAccess({ item }) {
8
+ var editContext = (0, editContext_1.useEditContext)();
9
+ if (!editContext)
10
+ return;
11
+ if (!item.canWriteItem || !item.canWriteLanguage)
12
+ return;
13
+ if (!item.canWriteWorkflow) {
14
+ return ((0, jsx_runtime_1.jsx)(EditorWarning_1.EditorWarning, { title: "You dont have write access in the current workflow state.", severity: "warning", children: (0, jsx_runtime_1.jsxs)("p", { children: ["The item is in the workflow state", " ", (0, jsx_runtime_1.jsx)("span", { className: "font-bold", children: item.workflowState }), " which prevents you from editing."] }) }));
15
+ }
16
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoWriteAccess = NoWriteAccess;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const EditorWarning_1 = require("../EditorWarning");
6
+ const editContext_1 = require("../client/editContext");
7
+ function NoWriteAccess({ item }) {
8
+ var editContext = (0, editContext_1.useEditContext)();
9
+ if (!editContext)
10
+ return;
11
+ if (!item.canWriteItem) {
12
+ return ((0, jsx_runtime_1.jsx)(EditorWarning_1.EditorWarning, { title: "You dont have write access.", severity: "warning", children: (0, jsx_runtime_1.jsx)("p", { children: "You can't edit this item because you don't have write access." }) }));
13
+ }
14
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationErrors = ValidationErrors;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const EditorWarning_1 = require("../EditorWarning");
6
+ function ValidationErrors({ item, editContext }) {
7
+ let validationResult = editContext.validationResult
8
+ ?.find((x) => x.item.id === item.id &&
9
+ x.item.language === item.language &&
10
+ x.item.version === item.version)
11
+ ?.results.filter((x) => x.itemId === item.id);
12
+ if (!validationResult) {
13
+ const pageResult = editContext.validationResult?.find((x) => x.item.id === editContext?.page?.item.id);
14
+ if (pageResult)
15
+ validationResult = pageResult.results.filter((x) => x.itemId === item.id);
16
+ }
17
+ if (!validationResult?.length)
18
+ return null;
19
+ const fields = validationResult?.filter((x) => x.fieldId);
20
+ return ((0, jsx_runtime_1.jsxs)(EditorWarning_1.EditorWarning, { title: "Validation", severity: "warning", children: [validationResult
21
+ ?.filter((x) => !x.fieldId)
22
+ .map((x) => ((0, jsx_runtime_1.jsx)("div", { children: x.message }, x.validator))), fields?.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { children: ["The following fields have validation messages:", " ", fields.map((x) => ((0, jsx_runtime_1.jsx)("span", { className: "cursor-pointer font-bold", onClick: () => {
23
+ const field = Object.values(item.fields).find((f) => f.id === x.fieldId);
24
+ if (field)
25
+ editContext.setFocusedField(field.descriptor, false);
26
+ }, children: x.fieldName }, x.validator + x.fieldId)))] }))] }));
27
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttachmentEditor = AttachmentEditor;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function AttachmentEditor({ field }) {
6
+ return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("img", { src: field.value.src }) }));
7
+ }
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CheckboxEditor = CheckboxEditor;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const editContext_1 = require("../client/editContext");
7
+ const checkbox_1 = require("primereact/checkbox");
8
+ const react_1 = require("react");
9
+ const progressspinner_1 = require("primereact/progressspinner");
10
+ function CheckboxEditor({ field, readOnly, }) {
11
+ const editContext = (0, editContext_1.useEditContext)();
12
+ const [isUpdating, setIsUpdating] = (0, react_1.useState)(false);
13
+ (0, react_1.useEffect)(() => {
14
+ setIsUpdating(false);
15
+ }, [field]);
16
+ if (!editContext)
17
+ return;
18
+ const fieldItem = field.descriptor.item;
19
+ if (!fieldItem)
20
+ return;
21
+ if (isUpdating) {
22
+ return (0, jsx_runtime_1.jsx)(progressspinner_1.ProgressSpinner, { style: { width: "18px", height: "18px" } });
23
+ }
24
+ return ((0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { checked: field.value, disabled: readOnly, onClick: () => {
25
+ setIsUpdating(true);
26
+ editContext.operations.editField({
27
+ field: field.descriptor,
28
+ rawValue: field.value ? "0" : "1",
29
+ refresh: "immediate",
30
+ });
31
+ } }, fieldItem.id + field.id + fieldItem.language + fieldItem.version));
32
+ }
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DropLinkEditor = DropLinkEditor;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const dropdown_1 = require("primereact/dropdown");
7
+ const editContext_1 = require("../client/editContext");
8
+ const react_1 = require("react");
9
+ const editService_1 = require("../services/editService");
10
+ const utils_1 = require("../utils");
11
+ function DropLinkEditor({ field, readOnly, }) {
12
+ const editContext = (0, editContext_1.useEditContext)();
13
+ const [lazyItems, setLazyItems] = (0, react_1.useState)([]);
14
+ const [lazyLoading, setLazyLoading] = (0, react_1.useState)(true);
15
+ if (!field)
16
+ return;
17
+ if (!editContext)
18
+ return;
19
+ (0, react_1.useEffect)(() => {
20
+ onLazyLoad();
21
+ }, [field.descriptor]);
22
+ const onLazyLoad = async () => {
23
+ setLazyLoading(true);
24
+ const options = await (0, editService_1.getLookupSources)(field, editContext.sessionId);
25
+ setLazyItems(options);
26
+ setLazyLoading(false);
27
+ };
28
+ return ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { value: field.value?.targetItemId, disabled: readOnly, onChange: (e) => {
29
+ editContext?.operations.editField({
30
+ field: field.descriptor,
31
+ rawValue: (0, utils_1.normalizeGuid)(e.value), // typeof e.value === "string" ? e.value : e.value.id, // This has changed in primereact
32
+ });
33
+ }, options: lazyItems, optionLabel: "name", optionValue: "id", placeholder: "Select", className: "w-full md:w-14rem", virtualScrollerOptions: {
34
+ lazy: true,
35
+ onLazyLoad: onLazyLoad,
36
+ itemSize: 38,
37
+ // showLoader: true,
38
+ loading: lazyLoading,
39
+ //delay: 250,
40
+ // loadingTemplate: (options) => {
41
+ // return (
42
+ // <div
43
+ // className="flex align-items-center p-2"
44
+ // style={{ height: "38px" }}
45
+ // >
46
+ // <Skeleton width={options.even ? "60%" : "50%"} height="1rem" />
47
+ // </div>
48
+ // );
49
+ // },
50
+ } }));
51
+ }
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DropListEditor = DropListEditor;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const dropdown_1 = require("primereact/dropdown");
7
+ const editContext_1 = require("../client/editContext");
8
+ const react_1 = require("react");
9
+ const editService_1 = require("../services/editService");
10
+ function DropListEditor({ field, readOnly, }) {
11
+ const editContext = (0, editContext_1.useEditContext)();
12
+ const [lazyItems, setLazyItems] = (0, react_1.useState)([]);
13
+ const [lazyLoading, setLazyLoading] = (0, react_1.useState)(true);
14
+ if (!field)
15
+ return;
16
+ if (!editContext)
17
+ return;
18
+ (0, react_1.useEffect)(() => {
19
+ onLazyLoad();
20
+ }, [field.descriptor]);
21
+ const onLazyLoad = async () => {
22
+ setLazyLoading(true);
23
+ const options = await (0, editService_1.getLookupSources)(field, editContext.sessionId);
24
+ if (field.value && !options.find((o) => o.name === field.value)) {
25
+ console.log("Adding unknown option", field.value);
26
+ options.unshift({
27
+ id: "unknown",
28
+ name: `[Unknown: ${field.value}]`,
29
+ });
30
+ }
31
+ setLazyItems(options);
32
+ setLazyLoading(false);
33
+ };
34
+ return ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { value: lazyItems.find((o) => o.name === field.value)?.name ||
35
+ "[Unknown: " + field.value + "]", disabled: readOnly, onChange: (e) => {
36
+ editContext?.operations.editField({
37
+ field: field.descriptor,
38
+ rawValue: e.value,
39
+ });
40
+ }, options: lazyItems, optionLabel: "name", optionValue: "name", placeholder: "Select", className: "w-full md:w-14rem", virtualScrollerOptions: {
41
+ lazy: true,
42
+ onLazyLoad: onLazyLoad,
43
+ itemSize: 38,
44
+ // showLoader: true,
45
+ loading: lazyLoading,
46
+ //delay: 250,
47
+ // loadingTemplate: (options) => {
48
+ // return (
49
+ // <div
50
+ // className="flex align-items-center p-2"
51
+ // style={{ height: "38px" }}
52
+ // >
53
+ // <Skeleton width={options.even ? "60%" : "50%"} height="1rem" />
54
+ // </div>
55
+ // );
56
+ // },
57
+ } }));
58
+ }
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ImageFieldEditor = ImageFieldEditor;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const editContext_1 = require("../client/editContext");
7
+ const inputtext_1 = require("primereact/inputtext");
8
+ const react_1 = require("react");
9
+ const ImageEditor_1 = require("../ImageEditor");
10
+ function ImageFieldEditor({ field, readOnly, }) {
11
+ const editContext = (0, editContext_1.useEditContext)();
12
+ const [altText, setAltText] = (0, react_1.useState)("");
13
+ if (!field || !editContext)
14
+ return null;
15
+ function updateAltText(rawValue, newAltText) {
16
+ const parser = new DOMParser();
17
+ const xmlDoc = parser.parseFromString(rawValue, 'text/xml');
18
+ const imageElement = xmlDoc.documentElement;
19
+ imageElement.setAttribute('alt', newAltText);
20
+ return new XMLSerializer().serializeToString(xmlDoc);
21
+ }
22
+ var item = field.descriptor.item;
23
+ (0, react_1.useEffect)(() => {
24
+ setAltText(field.value?.alt || "");
25
+ }, [field.value?.alt]);
26
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "flex gap-2 h-full focus-shadow flex-wrap", children: (0, jsx_runtime_1.jsx)("div", { className: "h-48 w-48 border border-gray-300 relative cursor-pointer flex justify-center items-center", children: !readOnly && (0, jsx_runtime_1.jsx)(ImageEditor_1.ImageEditor, { field: field }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-1", children: "Alt Text" }), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { value: altText, disabled: readOnly, className: "p-2 focus-shadow text-sm", style: { width: "100%" }, onChange: (e) => {
27
+ setAltText(e.target.value);
28
+ if (field.value)
29
+ field.value.alt = e.target.value;
30
+ editContext.operations.editField({
31
+ field: field.descriptor,
32
+ rawValue: updateAltText(field.rawValue || "", e.target.value),
33
+ refresh: "waitForQuietPeriod",
34
+ });
35
+ } }, item.id + field.id + item.language + item.version)] })] }));
36
+ }
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InternalLinkFieldEditor = InternalLinkFieldEditor;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const editContext_1 = require("../client/editContext");
11
+ const ContentTree_1 = __importDefault(require("../ContentTree"));
12
+ const overlaypanel_1 = require("primereact/overlaypanel");
13
+ const editService_1 = require("../services/editService");
14
+ const utils_1 = require("primereact/utils");
15
+ function InternalLinkFieldEditor({ field, readOnly, }) {
16
+ const editContext = (0, editContext_1.useEditContext)();
17
+ const [link, setLink] = (0, react_1.useState)();
18
+ const [showTree, setShowTree] = (0, react_1.useState)(false);
19
+ const [rootItemIds, setRootItemIds] = (0, react_1.useState)([]);
20
+ (0, react_1.useEffect)(() => {
21
+ setLink({
22
+ url: field.value.url,
23
+ target: field.value.target,
24
+ targetItemName: field.value.targetItemName,
25
+ targetItemLongId: field.value.targetItemLongId,
26
+ type: field.value.type,
27
+ itemId: field.value.targetItemLongId?.split("/").pop(),
28
+ queryString: field.value.queryString,
29
+ });
30
+ }, [field]);
31
+ const overlayPanelRef = (0, react_1.useRef)(null);
32
+ const dropdownRef = (0, react_1.useRef)(null);
33
+ const texboxRef = (0, react_1.useRef)(null);
34
+ if (!editContext)
35
+ return;
36
+ const selection = [];
37
+ if (link?.itemId)
38
+ selection.push(link.itemId);
39
+ (0, react_1.useEffect)(() => {
40
+ const loadLookupSources = async () => {
41
+ const datasources = await (0, editService_1.getLookupSources)(field, editContext.sessionId);
42
+ if (datasources.length > 0) {
43
+ setRootItemIds(datasources.map((x) => x.id));
44
+ }
45
+ else
46
+ setRootItemIds(["11111111-1111-1111-1111-111111111111"]);
47
+ };
48
+ loadLookupSources();
49
+ }, [field.descriptor]);
50
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { ref: texboxRef, className: (0, utils_1.classNames)("p-1.5 border flex justify-between text-sm cursor-pointer justiy-between focus-shadow", readOnly ? "bg-gray-50" : " bg-white"), onClick: (e) => {
51
+ if (readOnly)
52
+ return;
53
+ overlayPanelRef.current?.toggle(null, texboxRef.current);
54
+ setShowTree((show) => !show);
55
+ e.preventDefault();
56
+ }, children: [link?.targetItemName ? ((0, jsx_runtime_1.jsx)("span", { children: link.targetItemName })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u00A0" })), !readOnly && ((0, jsx_runtime_1.jsx)("i", { className: `pi ${showTree ? "pi-angle-up" : "pi-angle-down"} ` }))] }), (0, jsx_runtime_1.jsx)("div", { ref: dropdownRef, className: "w-0" })] }), (0, jsx_runtime_1.jsx)(overlaypanel_1.OverlayPanel, { ref: overlayPanelRef, children: (0, jsx_runtime_1.jsx)("div", { className: "h-64 overflow-auto resize border-b border-x p-2", style: { width: `${texboxRef.current?.offsetWidth || 100}px` }, children: (0, jsx_runtime_1.jsx)(ContentTree_1.default, { language: editContext.contentEditorItem.language, expandIdPath: link?.targetItemLongId, rootItemIds: rootItemIds, selectionMode: "single", selectedItemIds: selection, onNodeClick: (node) => {
57
+ setShowTree(false);
58
+ overlayPanelRef.current?.hide();
59
+ editContext?.operations.editField({
60
+ field: field.descriptor,
61
+ rawValue: node.id,
62
+ });
63
+ } }) }) })] }));
64
+ }
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.LinkFieldEditor = LinkFieldEditor;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const LinkEditorDialog_1 = require("../LinkEditorDialog");
8
+ const editContext_1 = require("../client/editContext");
9
+ const utils_1 = require("primereact/utils");
10
+ function LinkFieldEditor({ field, readOnly, }) {
11
+ const editContext = (0, editContext_1.useEditContext)();
12
+ const [showDialog, setShowDialog] = (0, react_1.useState)(false);
13
+ const [link, setLink] = (0, react_1.useState)();
14
+ (0, react_1.useEffect)(() => {
15
+ if (!field.value)
16
+ return;
17
+ setLink({
18
+ url: field.value.url,
19
+ target: field.value.target,
20
+ targetItemLongId: field.value.targetItemLongId,
21
+ type: field.value.type,
22
+ itemId: field.value.targetItemLongId?.split("/").pop(),
23
+ queryString: field.value.queryString,
24
+ });
25
+ }, [field]);
26
+ if (!field.value)
27
+ return;
28
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.classNames)("focus-shadow flex justify-between border border-gray-300 p-2", readOnly ? "bg-gray-100" : "cursor-pointer bg-white"), onClick: (e) => {
29
+ if (readOnly)
30
+ return;
31
+ setShowDialog(true);
32
+ e.preventDefault();
33
+ }, children: [(0, jsx_runtime_1.jsx)("div", { children: field.value.url }), (0, jsx_runtime_1.jsx)("i", { className: "pi pi-link" })] }), showDialog && ((0, jsx_runtime_1.jsx)(LinkEditorDialog_1.LinkEditorDialog, { linkValue: link || { type: "internal" }, onOk: (link) => {
34
+ const xml = link.type == "internal"
35
+ ? '<link linktype="internal" querystring="' +
36
+ (link.queryString ?? "") +
37
+ '" id="' +
38
+ link.itemId +
39
+ '" target="' +
40
+ link.target +
41
+ '" />'
42
+ : '<link linktype="external" querystring="' +
43
+ (link.queryString ?? "") +
44
+ '" url="' +
45
+ link.url +
46
+ '" target="' +
47
+ link.target +
48
+ '" />';
49
+ editContext?.operations.editField({
50
+ field: field.descriptor,
51
+ rawValue: xml,
52
+ refresh: "immediate",
53
+ });
54
+ setShowDialog(false);
55
+ }, onCancel: () => {
56
+ setShowDialog(false);
57
+ } }))] }));
58
+ }