@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.
- package/dist/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +2 -11
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +16 -2
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +1 -1
- package/dist/editor/menubar/PageSelector.js +39 -15
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/reviews/Comment.js +1 -1
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +61 -5
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -730
- package/src/editor/ContextMenu.tsx +0 -230
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldActionsOverlay.tsx +0 -307
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -75
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -277
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -104
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -503
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2241
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -416
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -574
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -28
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -166
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -220
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -307
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -488
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -709
- package/src/editor/ui/ItemList.tsx +0 -76
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -153
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/fonts/index.ts +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { EditorWarning } from "../EditorWarning";
|
|
2
|
-
import { EditorWarningProps } from "../EditorWarnings";
|
|
3
|
-
import { useEditContext } from "../client/editContext";
|
|
4
|
-
|
|
5
|
-
export function NoWriteAccess({ item }: EditorWarningProps) {
|
|
6
|
-
var editContext = useEditContext();
|
|
7
|
-
if (!editContext) return;
|
|
8
|
-
if (editContext.mode !== "edit") return;
|
|
9
|
-
if (!item.canWriteItem) {
|
|
10
|
-
return (
|
|
11
|
-
<EditorWarning title="You dont have write access." severity="warning">
|
|
12
|
-
<p>You can't edit this item because you don't have write access.</p>
|
|
13
|
-
</EditorWarning>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { EditorWarning } from "../EditorWarning";
|
|
2
|
-
import { EditorWarningProps } from "../EditorWarnings";
|
|
3
|
-
|
|
4
|
-
export function ValidationErrors({ item, editContext }: EditorWarningProps) {
|
|
5
|
-
let validationResult = editContext.validationResult
|
|
6
|
-
?.find(
|
|
7
|
-
(x) =>
|
|
8
|
-
x.item.id === item.id &&
|
|
9
|
-
x.item.language === item.language &&
|
|
10
|
-
x.item.version === item.version
|
|
11
|
-
)
|
|
12
|
-
?.results.filter((x) => x.itemId === item.id);
|
|
13
|
-
|
|
14
|
-
if (!validationResult) {
|
|
15
|
-
const pageResult = editContext.validationResult?.find(
|
|
16
|
-
(x) => x.item.id === editContext?.page?.item.id
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
if (pageResult)
|
|
20
|
-
validationResult = pageResult.results.filter((x) => x.itemId === item.id);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!validationResult?.length) return null;
|
|
24
|
-
const fields = validationResult?.filter((x) => x.fieldId);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<EditorWarning title="Validation" severity="warning">
|
|
28
|
-
{validationResult
|
|
29
|
-
?.filter((x) => !x.fieldId)
|
|
30
|
-
.map((x) => (
|
|
31
|
-
<div key={x.validator}>{x.message}</div>
|
|
32
|
-
))}
|
|
33
|
-
{fields?.length > 0 && (
|
|
34
|
-
<div>
|
|
35
|
-
The following fields have validation messages:{" "}
|
|
36
|
-
{fields.map((x) => (
|
|
37
|
-
<span
|
|
38
|
-
className="cursor-pointer font-bold"
|
|
39
|
-
key={x.validator + x.fieldId}
|
|
40
|
-
onClick={() => {
|
|
41
|
-
const field = Object.values(item.fields).find(
|
|
42
|
-
(f) => f.id === x.fieldId
|
|
43
|
-
);
|
|
44
|
-
if (field) editContext.setFocusedField(field.descriptor, false);
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
{x.fieldName}
|
|
48
|
-
</span>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
|
-
)}
|
|
52
|
-
</EditorWarning>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEditContext } from "../client/editContext";
|
|
4
|
-
|
|
5
|
-
import { Checkbox } from "primereact/checkbox";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { ProgressSpinner } from "primereact/progressspinner";
|
|
8
|
-
import { CheckboxField } from "../fieldTypes";
|
|
9
|
-
|
|
10
|
-
export function CheckboxEditor({
|
|
11
|
-
field,
|
|
12
|
-
readOnly,
|
|
13
|
-
}: {
|
|
14
|
-
field: CheckboxField;
|
|
15
|
-
readOnly?: boolean;
|
|
16
|
-
}) {
|
|
17
|
-
const editContext = useEditContext();
|
|
18
|
-
const [isUpdating, setIsUpdating] = useState(false);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
setIsUpdating(false);
|
|
22
|
-
}, [field]);
|
|
23
|
-
|
|
24
|
-
if (!editContext) return;
|
|
25
|
-
const fieldItem = field.descriptor.item;
|
|
26
|
-
if (!fieldItem) return;
|
|
27
|
-
|
|
28
|
-
if (isUpdating) {
|
|
29
|
-
return <ProgressSpinner style={{ width: "18px", height: "18px" }} />;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Checkbox
|
|
34
|
-
key={fieldItem.id + field.id + fieldItem.language + fieldItem.version}
|
|
35
|
-
checked={field.value}
|
|
36
|
-
disabled={readOnly}
|
|
37
|
-
onClick={() => {
|
|
38
|
-
setIsUpdating(true);
|
|
39
|
-
editContext.operations.editField({
|
|
40
|
-
field: field.descriptor,
|
|
41
|
-
rawValue: field.value ? "0" : "1",
|
|
42
|
-
refresh: "immediate",
|
|
43
|
-
});
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Dropdown, DropdownChangeEvent } from "primereact/dropdown";
|
|
4
|
-
|
|
5
|
-
import { useEditContext } from "../client/editContext";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
|
|
8
|
-
import { getLookupSources } from "../services/editService";
|
|
9
|
-
import { InternalLinkField } from "../fieldTypes";
|
|
10
|
-
import { ItemIdAndName } from "../pageModel";
|
|
11
|
-
import { normalizeGuid } from "../utils";
|
|
12
|
-
|
|
13
|
-
export function DropLinkEditor({
|
|
14
|
-
field,
|
|
15
|
-
readOnly,
|
|
16
|
-
}: {
|
|
17
|
-
field: InternalLinkField;
|
|
18
|
-
readOnly?: boolean;
|
|
19
|
-
}) {
|
|
20
|
-
const editContext = useEditContext();
|
|
21
|
-
|
|
22
|
-
const [lazyItems, setLazyItems] = useState<ItemIdAndName[]>([]);
|
|
23
|
-
const [lazyLoading, setLazyLoading] = useState<boolean>(true);
|
|
24
|
-
|
|
25
|
-
if (!field) return;
|
|
26
|
-
|
|
27
|
-
if (!editContext) return;
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
onLazyLoad();
|
|
31
|
-
}, [
|
|
32
|
-
field.descriptor.fieldId +
|
|
33
|
-
field.descriptor.item.id +
|
|
34
|
-
field.descriptor.item.language +
|
|
35
|
-
field.descriptor.item.version,
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
const onLazyLoad = async () => {
|
|
39
|
-
setLazyLoading(true);
|
|
40
|
-
const options = await getLookupSources(field, editContext.sessionId);
|
|
41
|
-
setLazyItems(options);
|
|
42
|
-
setLazyLoading(false);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<Dropdown
|
|
47
|
-
value={field.value?.targetItemId}
|
|
48
|
-
disabled={readOnly}
|
|
49
|
-
onChange={(e: DropdownChangeEvent) => {
|
|
50
|
-
editContext?.operations.editField({
|
|
51
|
-
field: field.descriptor,
|
|
52
|
-
rawValue: normalizeGuid(e.value), // typeof e.value === "string" ? e.value : e.value.id, // This has changed in primereact
|
|
53
|
-
});
|
|
54
|
-
}}
|
|
55
|
-
options={lazyItems}
|
|
56
|
-
optionLabel="name"
|
|
57
|
-
optionValue="id"
|
|
58
|
-
placeholder="Select"
|
|
59
|
-
className="md:w-14rem w-full"
|
|
60
|
-
virtualScrollerOptions={{
|
|
61
|
-
lazy: true,
|
|
62
|
-
onLazyLoad: onLazyLoad,
|
|
63
|
-
itemSize: 38,
|
|
64
|
-
// showLoader: true,
|
|
65
|
-
loading: lazyLoading,
|
|
66
|
-
//delay: 250,
|
|
67
|
-
// loadingTemplate: (options) => {
|
|
68
|
-
// return (
|
|
69
|
-
// <div
|
|
70
|
-
// className="flex align-items-center p-2"
|
|
71
|
-
// style={{ height: "38px" }}
|
|
72
|
-
// >
|
|
73
|
-
// <Skeleton width={options.even ? "60%" : "50%"} height="1rem" />
|
|
74
|
-
// </div>
|
|
75
|
-
// );
|
|
76
|
-
// },
|
|
77
|
-
}}
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Dropdown, DropdownChangeEvent } from "primereact/dropdown";
|
|
4
|
-
|
|
5
|
-
import { useEditContext } from "../client/editContext";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
|
|
8
|
-
import { getLookupSources } from "../services/editService";
|
|
9
|
-
import { TextField } from "../fieldTypes";
|
|
10
|
-
import { ItemIdAndName } from "../pageModel";
|
|
11
|
-
|
|
12
|
-
export function DropListEditor({
|
|
13
|
-
field,
|
|
14
|
-
readOnly,
|
|
15
|
-
}: {
|
|
16
|
-
field: TextField;
|
|
17
|
-
readOnly?: boolean;
|
|
18
|
-
}) {
|
|
19
|
-
const editContext = useEditContext();
|
|
20
|
-
|
|
21
|
-
const [lazyItems, setLazyItems] = useState<ItemIdAndName[]>([]);
|
|
22
|
-
const [lazyLoading, setLazyLoading] = useState<boolean>(true);
|
|
23
|
-
|
|
24
|
-
if (!field) return;
|
|
25
|
-
|
|
26
|
-
if (!editContext) return;
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
onLazyLoad();
|
|
30
|
-
}, [field.descriptor]);
|
|
31
|
-
|
|
32
|
-
const onLazyLoad = async () => {
|
|
33
|
-
setLazyLoading(true);
|
|
34
|
-
const options = await getLookupSources(field, editContext.sessionId);
|
|
35
|
-
if (field.value && !options.find((o) => o.name === field.value)) {
|
|
36
|
-
console.log("Adding unknown option", field.value);
|
|
37
|
-
options.unshift({
|
|
38
|
-
id: "unknown",
|
|
39
|
-
name: `[Unknown: ${field.value}]`,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
setLazyItems(options);
|
|
43
|
-
setLazyLoading(false);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Dropdown
|
|
48
|
-
value={
|
|
49
|
-
lazyItems.find((o) => o.name === field.value)?.name ||
|
|
50
|
-
"[Unknown: " + field.value + "]"
|
|
51
|
-
}
|
|
52
|
-
disabled={readOnly}
|
|
53
|
-
onChange={(e: DropdownChangeEvent) => {
|
|
54
|
-
editContext?.operations.editField({
|
|
55
|
-
field: field.descriptor,
|
|
56
|
-
rawValue: e.value,
|
|
57
|
-
});
|
|
58
|
-
}}
|
|
59
|
-
options={lazyItems}
|
|
60
|
-
optionLabel="name"
|
|
61
|
-
optionValue="name"
|
|
62
|
-
placeholder="Select"
|
|
63
|
-
className="w-full md:w-14rem"
|
|
64
|
-
virtualScrollerOptions={{
|
|
65
|
-
lazy: true,
|
|
66
|
-
onLazyLoad: onLazyLoad,
|
|
67
|
-
itemSize: 38,
|
|
68
|
-
// showLoader: true,
|
|
69
|
-
loading: lazyLoading,
|
|
70
|
-
//delay: 250,
|
|
71
|
-
// loadingTemplate: (options) => {
|
|
72
|
-
// return (
|
|
73
|
-
// <div
|
|
74
|
-
// className="flex align-items-center p-2"
|
|
75
|
-
// style={{ height: "38px" }}
|
|
76
|
-
// >
|
|
77
|
-
// <Skeleton width={options.even ? "60%" : "50%"} height="1rem" />
|
|
78
|
-
// </div>
|
|
79
|
-
// );
|
|
80
|
-
// },
|
|
81
|
-
}}
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEditContext } from "../client/editContext";
|
|
4
|
-
import { InputText } from "primereact/inputtext";
|
|
5
|
-
import { ImageField } from "../fieldTypes";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { ImageEditor } from "../ImageEditor";
|
|
8
|
-
|
|
9
|
-
export function ImageFieldEditor({
|
|
10
|
-
field,
|
|
11
|
-
readOnly,
|
|
12
|
-
}: {
|
|
13
|
-
field: ImageField;
|
|
14
|
-
readOnly?: boolean;
|
|
15
|
-
}) {
|
|
16
|
-
const editContext = useEditContext();
|
|
17
|
-
const [altText, setAltText] = useState<string>("");
|
|
18
|
-
|
|
19
|
-
if (!field || !editContext) return null;
|
|
20
|
-
|
|
21
|
-
function updateAltText(rawValue: string, newAltText: string): string {
|
|
22
|
-
const parser = new DOMParser();
|
|
23
|
-
const xmlDoc = parser.parseFromString(rawValue, 'text/xml');
|
|
24
|
-
const imageElement = xmlDoc.documentElement;
|
|
25
|
-
|
|
26
|
-
imageElement.setAttribute('alt', newAltText);
|
|
27
|
-
|
|
28
|
-
return new XMLSerializer().serializeToString(xmlDoc);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var item = field.descriptor.item;
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
setAltText(field.value?.alt || "");
|
|
35
|
-
}, [field.value?.alt]);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div>
|
|
39
|
-
<div className="flex gap-2 h-full focus-shadow flex-wrap">
|
|
40
|
-
<div className="h-48 w-48 border border-gray-300 relative cursor-pointer flex justify-center items-center">
|
|
41
|
-
{!readOnly && <ImageEditor field={field} />}
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
<div className="mt-2">
|
|
45
|
-
<div className="mb-1">Alt Text</div>
|
|
46
|
-
<InputText
|
|
47
|
-
key={item!.id + field.id + item!.language + item!.version}
|
|
48
|
-
value={altText}
|
|
49
|
-
disabled={readOnly}
|
|
50
|
-
className="p-2 focus-shadow text-sm"
|
|
51
|
-
style={{ width: "100%" }}
|
|
52
|
-
onChange={(e) => {
|
|
53
|
-
setAltText(e.target.value);
|
|
54
|
-
if (field.value) field.value.alt = e.target.value;
|
|
55
|
-
editContext.operations.editField({
|
|
56
|
-
field: field.descriptor,
|
|
57
|
-
rawValue: updateAltText(field.rawValue || "", e.target.value),
|
|
58
|
-
refresh: "waitForQuietPeriod",
|
|
59
|
-
});
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
4
|
-
|
|
5
|
-
import { Link } from "../LinkEditorDialog";
|
|
6
|
-
import { useEditContext } from "../client/editContext";
|
|
7
|
-
import ContentTree from "../ContentTree";
|
|
8
|
-
|
|
9
|
-
import { OverlayPanel } from "primereact/overlaypanel";
|
|
10
|
-
import { InternalLinkField } from "../fieldTypes";
|
|
11
|
-
import { getLookupSources } from "../services/editService";
|
|
12
|
-
import { classNames } from "primereact/utils";
|
|
13
|
-
|
|
14
|
-
export function InternalLinkFieldEditor({
|
|
15
|
-
field,
|
|
16
|
-
readOnly,
|
|
17
|
-
}: {
|
|
18
|
-
field: InternalLinkField;
|
|
19
|
-
readOnly?: boolean;
|
|
20
|
-
}) {
|
|
21
|
-
const editContext = useEditContext();
|
|
22
|
-
|
|
23
|
-
const [link, setLink] = useState<Link>();
|
|
24
|
-
const [showTree, setShowTree] = useState(false);
|
|
25
|
-
const [rootItemIds, setRootItemIds] = useState<string[]>([]);
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
setLink({
|
|
29
|
-
url: field.value.url,
|
|
30
|
-
target: field.value.target,
|
|
31
|
-
targetItemName: field.value.targetItemName,
|
|
32
|
-
targetItemLongId: field.value.targetItemLongId,
|
|
33
|
-
type: field.value.type,
|
|
34
|
-
itemId: field.value.targetItemLongId?.split("/").pop(),
|
|
35
|
-
queryString: field.value.queryString,
|
|
36
|
-
});
|
|
37
|
-
}, [field]);
|
|
38
|
-
|
|
39
|
-
const overlayPanelRef = useRef<OverlayPanel>(null);
|
|
40
|
-
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
41
|
-
const texboxRef = useRef<HTMLDivElement>(null);
|
|
42
|
-
|
|
43
|
-
if (!editContext) return;
|
|
44
|
-
|
|
45
|
-
const selection = [];
|
|
46
|
-
if (link?.itemId) selection.push(link.itemId);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
const loadLookupSources = async () => {
|
|
50
|
-
const datasources = await getLookupSources(field, editContext.sessionId);
|
|
51
|
-
|
|
52
|
-
if (datasources.length > 0) {
|
|
53
|
-
setRootItemIds(datasources.map((x) => x.id));
|
|
54
|
-
} else setRootItemIds(["11111111-1111-1111-1111-111111111111"]);
|
|
55
|
-
};
|
|
56
|
-
loadLookupSources();
|
|
57
|
-
}, [
|
|
58
|
-
field.descriptor.fieldId +
|
|
59
|
-
field.descriptor.item.id +
|
|
60
|
-
field.descriptor.item.language +
|
|
61
|
-
field.descriptor.item.version,
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<>
|
|
66
|
-
<div>
|
|
67
|
-
<div
|
|
68
|
-
ref={texboxRef}
|
|
69
|
-
className={classNames(
|
|
70
|
-
"justiy-between focus-shadow flex cursor-pointer justify-between border p-1.5 text-sm",
|
|
71
|
-
readOnly ? "bg-gray-50" : "bg-white",
|
|
72
|
-
)}
|
|
73
|
-
onClick={(e) => {
|
|
74
|
-
if (readOnly) return;
|
|
75
|
-
overlayPanelRef.current?.toggle(null, texboxRef.current);
|
|
76
|
-
setShowTree((show) => !show);
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
{link?.targetItemName ? (
|
|
81
|
-
<span>{link.targetItemName}</span>
|
|
82
|
-
) : (
|
|
83
|
-
<span> </span>
|
|
84
|
-
)}
|
|
85
|
-
{!readOnly && (
|
|
86
|
-
<i
|
|
87
|
-
className={`pi ${showTree ? "pi-angle-up" : "pi-angle-down"} `}
|
|
88
|
-
></i>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
<div ref={dropdownRef} className="w-0"></div>
|
|
92
|
-
</div>
|
|
93
|
-
<OverlayPanel ref={overlayPanelRef}>
|
|
94
|
-
<div
|
|
95
|
-
className="h-64 resize overflow-auto border-x border-b p-2"
|
|
96
|
-
style={{ width: `${texboxRef.current?.offsetWidth || 100}px` }}
|
|
97
|
-
>
|
|
98
|
-
<ContentTree
|
|
99
|
-
language={editContext.contentEditorItem!.language}
|
|
100
|
-
expandIdPath={link?.targetItemLongId}
|
|
101
|
-
rootItemIds={rootItemIds}
|
|
102
|
-
selectionMode="single"
|
|
103
|
-
selectedItemIds={selection}
|
|
104
|
-
onSelectionChange={(nodes) => {
|
|
105
|
-
setShowTree(false);
|
|
106
|
-
overlayPanelRef.current?.hide();
|
|
107
|
-
editContext?.operations.editField({
|
|
108
|
-
field: field.descriptor,
|
|
109
|
-
rawValue: nodes[0]?.id,
|
|
110
|
-
});
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
</div>
|
|
114
|
-
</OverlayPanel>
|
|
115
|
-
</>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
|
|
5
|
-
import { Link, LinkEditorDialog } from "../LinkEditorDialog";
|
|
6
|
-
import { useEditContext } from "../client/editContext";
|
|
7
|
-
import { LinkField } from "../fieldTypes";
|
|
8
|
-
import { classNames } from "primereact/utils";
|
|
9
|
-
|
|
10
|
-
export function LinkFieldEditor({
|
|
11
|
-
field,
|
|
12
|
-
readOnly,
|
|
13
|
-
}: {
|
|
14
|
-
field: LinkField;
|
|
15
|
-
readOnly?: boolean;
|
|
16
|
-
}) {
|
|
17
|
-
const editContext = useEditContext();
|
|
18
|
-
const [showDialog, setShowDialog] = useState(false);
|
|
19
|
-
const [link, setLink] = useState<Link>();
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!field.value) return;
|
|
22
|
-
setLink({
|
|
23
|
-
url: field.value.url,
|
|
24
|
-
target: field.value.target,
|
|
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
|
-
if (!field.value) return;
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
<div
|
|
36
|
-
className={classNames(
|
|
37
|
-
"focus-shadow flex justify-between border border-gray-300 p-2",
|
|
38
|
-
readOnly ? "bg-gray-100" : "cursor-pointer bg-white",
|
|
39
|
-
)}
|
|
40
|
-
onClick={(e) => {
|
|
41
|
-
if (readOnly) return;
|
|
42
|
-
setShowDialog(true);
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
46
|
-
<div>{field.value.url}</div>
|
|
47
|
-
<i className="pi pi-link"></i>
|
|
48
|
-
</div>
|
|
49
|
-
{showDialog && (
|
|
50
|
-
<LinkEditorDialog
|
|
51
|
-
linkValue={link || { type: "internal" }}
|
|
52
|
-
onOk={(link) => {
|
|
53
|
-
const xml =
|
|
54
|
-
link.type == "internal"
|
|
55
|
-
? '<link linktype="internal" querystring="' +
|
|
56
|
-
(link.queryString ?? "") +
|
|
57
|
-
'" id="' +
|
|
58
|
-
link.itemId +
|
|
59
|
-
'" target="' +
|
|
60
|
-
link.target +
|
|
61
|
-
'" />'
|
|
62
|
-
: '<link linktype="external" querystring="' +
|
|
63
|
-
(link.queryString ?? "") +
|
|
64
|
-
'" url="' +
|
|
65
|
-
link.url +
|
|
66
|
-
'" target="' +
|
|
67
|
-
link.target +
|
|
68
|
-
'" />';
|
|
69
|
-
|
|
70
|
-
editContext?.operations.editField({
|
|
71
|
-
field: field.descriptor,
|
|
72
|
-
rawValue: xml,
|
|
73
|
-
refresh: "immediate",
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
setShowDialog(false);
|
|
77
|
-
}}
|
|
78
|
-
onCancel={() => {
|
|
79
|
-
setShowDialog(false);
|
|
80
|
-
}}
|
|
81
|
-
/>
|
|
82
|
-
)}
|
|
83
|
-
</>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { InputTextarea } from "primereact/inputtextarea";
|
|
4
|
-
import {
|
|
5
|
-
useEditContext,
|
|
6
|
-
useEditContextRef,
|
|
7
|
-
useModifiedFieldsContext,
|
|
8
|
-
} from "../client/editContext";
|
|
9
|
-
|
|
10
|
-
import { useEffect, useRef, useState } from "react";
|
|
11
|
-
|
|
12
|
-
import { Field } from "../pageModel";
|
|
13
|
-
|
|
14
|
-
export function MultiLineText({
|
|
15
|
-
field,
|
|
16
|
-
readOnly,
|
|
17
|
-
updateFieldValue,
|
|
18
|
-
}: {
|
|
19
|
-
field: Field;
|
|
20
|
-
readOnly?: boolean;
|
|
21
|
-
updateFieldValue: (value: string) => void;
|
|
22
|
-
}) {
|
|
23
|
-
const editContextRef = useEditContextRef();
|
|
24
|
-
const editContext = useEditContext();
|
|
25
|
-
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
26
|
-
|
|
27
|
-
const fieldItem = field.descriptor.item;
|
|
28
|
-
const [value, setValue] = useState(field.value as string);
|
|
29
|
-
|
|
30
|
-
const modifiedFieldsContext = useModifiedFieldsContext();
|
|
31
|
-
const modifiedField = modifiedFieldsContext?.modifiedFields.find(
|
|
32
|
-
(x) =>
|
|
33
|
-
x.fieldId === field.id &&
|
|
34
|
-
x.item.id === fieldItem.id &&
|
|
35
|
-
x.item.language === fieldItem.language &&
|
|
36
|
-
x.item.version === fieldItem.version,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (inputRef.current !== document.activeElement) {
|
|
41
|
-
if (field.isHistoric) setValue(field.value as string);
|
|
42
|
-
else setValue(modifiedField?.value ?? (field.value as string));
|
|
43
|
-
}
|
|
44
|
-
}, [field.value, modifiedFieldsContext?.modifiedFields]);
|
|
45
|
-
|
|
46
|
-
if (!editContextRef.current) return;
|
|
47
|
-
|
|
48
|
-
if (!fieldItem) return;
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
if (
|
|
53
|
-
!editContextRef.current?.inlineEditingFieldElement &&
|
|
54
|
-
editContextRef.current?.focusedField?.fieldId === field.id &&
|
|
55
|
-
editContextRef.current?.focusedField?.item.id === fieldItem.id &&
|
|
56
|
-
editContextRef.current?.focusedField?.item.language ===
|
|
57
|
-
fieldItem.language &&
|
|
58
|
-
editContextRef.current?.focusedField?.item.version === fieldItem.version
|
|
59
|
-
) {
|
|
60
|
-
if (inputRef.current) {
|
|
61
|
-
inputRef.current.focus();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}, 500);
|
|
65
|
-
}, [editContext?.focusedField]);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<InputTextarea
|
|
69
|
-
ref={inputRef}
|
|
70
|
-
key={fieldItem.id + field.id + fieldItem.language + fieldItem.version}
|
|
71
|
-
value={value}
|
|
72
|
-
disabled={readOnly}
|
|
73
|
-
className="focus-shadow p-2 text-sm"
|
|
74
|
-
style={{ width: "100%" }}
|
|
75
|
-
rows={12}
|
|
76
|
-
onChange={(e) => {
|
|
77
|
-
setValue(e.target.value);
|
|
78
|
-
updateFieldValue(e.target.value as string);
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
81
|
-
);
|
|
82
|
-
}
|