@alpaca-editor/core 1.0.3938 → 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/ContentTree.js +12 -8
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/ContextMenu.d.ts +1 -1
- package/dist/editor/ContextMenu.js +17 -3
- package/dist/editor/ContextMenu.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +18 -0
- package/dist/editor/FieldActionsOverlay.js +139 -0
- package/dist/editor/FieldActionsOverlay.js.map +1 -0
- package/dist/editor/FieldHistory.d.ts +2 -1
- package/dist/editor/FieldHistory.js +11 -8
- package/dist/editor/FieldHistory.js.map +1 -1
- package/dist/editor/FieldListField.js +14 -17
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +43 -3
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +19 -10
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/AiTerminal.js +27 -41
- package/dist/editor/ai/AiTerminal.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +48 -18
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +1 -1
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/itemsRepository.js +126 -90
- package/dist/editor/client/itemsRepository.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 +3 -4
- package/dist/editor/menubar/BrowseHistory.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +62 -10
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.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/page-viewer/PageViewerFrame.js +98 -2
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/pageModel.d.ts +14 -0
- package/dist/editor/reviews/Comment.js +3 -2
- 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/services/editService.d.ts +1 -1
- package/dist/editor/services/editService.js +2 -1
- package/dist/editor/services/editService.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/Icons.js +1 -1
- package/dist/editor/ui/Icons.js.map +1 -1
- package/dist/editor/ui/ItemList.d.ts +16 -0
- package/dist/editor/ui/ItemList.js +19 -0
- package/dist/editor/ui/ItemList.js.map +1 -0
- package/dist/editor/ui/ItemSearch.js +2 -12
- package/dist/editor/ui/ItemSearch.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 +64 -13
- 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 -727
- package/src/editor/ContextMenu.tsx +0 -212
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -74
- 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 -212
- 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 -93
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -514
- 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 -2197
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -412
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -538
- 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 -37
- 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 -141
- 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 -879
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -208
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -308
- 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 -486
- 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 -708
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -190
- 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,412 +0,0 @@
|
|
|
1
|
-
import { EditContextType } from "../client/editContext";
|
|
2
|
-
import { PageViewContext } from "./pageViewContext";
|
|
3
|
-
import {
|
|
4
|
-
ComponentSkeleton,
|
|
5
|
-
PageSkeleton,
|
|
6
|
-
PlaceholderSkeleton,
|
|
7
|
-
RenderedItemSkeleton,
|
|
8
|
-
} from "../pageModel";
|
|
9
|
-
|
|
10
|
-
export function buildPageModelSkeleton(
|
|
11
|
-
iframeDocument: Document | undefined,
|
|
12
|
-
editContextRef: React.MutableRefObject<EditContextType | undefined>,
|
|
13
|
-
pageViewContextRef: React.MutableRefObject<PageViewContext | undefined>,
|
|
14
|
-
) {
|
|
15
|
-
if (!iframeDocument || !editContextRef.current || !pageViewContextRef.current)
|
|
16
|
-
return;
|
|
17
|
-
|
|
18
|
-
const extractItemId = (uri: string): string => {
|
|
19
|
-
const match = uri.match(/\{[A-F0-9-]+\}/i);
|
|
20
|
-
return match
|
|
21
|
-
? match[0].replace(/[{}]/g, "").toLowerCase()
|
|
22
|
-
: uri.toLowerCase();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Function to ensure IDs are in UUID format
|
|
26
|
-
const ensureUUIDFormat = (id: string): string => {
|
|
27
|
-
// If it's already in UUID format (with or without curly braces), return it
|
|
28
|
-
if (
|
|
29
|
-
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)
|
|
30
|
-
) {
|
|
31
|
-
return id;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// If it's in curly braces format, remove them
|
|
35
|
-
if (
|
|
36
|
-
/^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/i.test(
|
|
37
|
-
id,
|
|
38
|
-
)
|
|
39
|
-
) {
|
|
40
|
-
return id.replace(/[{}]/g, "");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// If it's a GUID without hyphens, add them
|
|
44
|
-
if (/^[0-9a-f]{32}$/i.test(id)) {
|
|
45
|
-
return `${id.substring(0, 8)}-${id.substring(8, 12)}-${id.substring(12, 16)}-${id.substring(16, 20)}-${id.substring(20, 32)}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// If it's a shorter ID, pad it to make it a valid UUID
|
|
49
|
-
if (id.length < 32) {
|
|
50
|
-
const paddedId = id.padEnd(32, "0");
|
|
51
|
-
return `${paddedId.substring(0, 8)}-${paddedId.substring(8, 12)}-${paddedId.substring(12, 16)}-${paddedId.substring(16, 20)}-${paddedId.substring(20, 32)}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// For any other format, return as is
|
|
55
|
-
return id;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const pageItemDescriptor = pageViewContextRef.current?.pageItemDescriptor;
|
|
59
|
-
|
|
60
|
-
if (!pageItemDescriptor) return;
|
|
61
|
-
|
|
62
|
-
const pageItem: RenderedItemSkeleton = {
|
|
63
|
-
...pageItemDescriptor,
|
|
64
|
-
renderedFieldIds: [],
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const start = performance.now();
|
|
68
|
-
|
|
69
|
-
const treeWalker = iframeDocument.createTreeWalker(
|
|
70
|
-
iframeDocument.documentElement, // Root node to start traversal
|
|
71
|
-
NodeFilter.SHOW_ELEMENT, // Only show element nodes
|
|
72
|
-
null, // Optional filter function, can be `null`
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const root: ComponentSkeleton = {
|
|
76
|
-
placeholders: [],
|
|
77
|
-
id: "page",
|
|
78
|
-
type: "Page",
|
|
79
|
-
typeId: "",
|
|
80
|
-
name: "Page",
|
|
81
|
-
items: [pageItem],
|
|
82
|
-
datasourceItem: pageItem,
|
|
83
|
-
renderedDictionaryKeys: [],
|
|
84
|
-
editorFields: {},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
let currentComponent: ComponentSkeleton | undefined = root;
|
|
88
|
-
let currentPlaceholder: undefined | PlaceholderSkeleton;
|
|
89
|
-
|
|
90
|
-
const startComponent = (
|
|
91
|
-
componentStartId: string,
|
|
92
|
-
element: Element,
|
|
93
|
-
dataSourceItemId?: string,
|
|
94
|
-
) => {
|
|
95
|
-
if (!currentPlaceholder) {
|
|
96
|
-
if (!currentComponent) {
|
|
97
|
-
console.error(
|
|
98
|
-
"Component start without parent component:",
|
|
99
|
-
componentStartId,
|
|
100
|
-
);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
currentPlaceholder = currentComponent.placeholders.find(
|
|
105
|
-
(x) => x.key === "implicit_" + currentComponent?.datasourceItem?.id,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
if (!currentPlaceholder) {
|
|
109
|
-
currentPlaceholder = {
|
|
110
|
-
key: "implicit_" + currentComponent?.datasourceItem?.id,
|
|
111
|
-
name: "Implicit placeholder: " + currentComponent?.datasourceItem?.id,
|
|
112
|
-
description: "",
|
|
113
|
-
components: [],
|
|
114
|
-
parentComponent: currentComponent,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
if (!currentComponent) {
|
|
118
|
-
console.error(
|
|
119
|
-
"Component start without placeholder or parent component",
|
|
120
|
-
);
|
|
121
|
-
} else {
|
|
122
|
-
currentComponent.placeholders.push(currentPlaceholder);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (currentPlaceholder) {
|
|
127
|
-
const language =
|
|
128
|
-
element.getAttribute("data-language") || pageItem.language;
|
|
129
|
-
const version = element.hasAttribute("data-version")
|
|
130
|
-
? parseInt(element.getAttribute("data-version")!)
|
|
131
|
-
: pageItem.version;
|
|
132
|
-
|
|
133
|
-
const itemId = dataSourceItemId || element.getAttribute("data-itemid");
|
|
134
|
-
|
|
135
|
-
const datasourceItem = itemId
|
|
136
|
-
? {
|
|
137
|
-
id: itemId,
|
|
138
|
-
language,
|
|
139
|
-
version,
|
|
140
|
-
renderedFieldIds: [],
|
|
141
|
-
}
|
|
142
|
-
: undefined;
|
|
143
|
-
|
|
144
|
-
const layoutId = element.getAttribute("data-layoutid");
|
|
145
|
-
|
|
146
|
-
currentComponent = currentPlaceholder.components.find(
|
|
147
|
-
(x) => x.id === componentStartId,
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
if (!currentComponent) {
|
|
151
|
-
currentComponent = {
|
|
152
|
-
id: componentStartId,
|
|
153
|
-
name: "",
|
|
154
|
-
type: element.getAttribute("data-type") || "",
|
|
155
|
-
typeId: element.getAttribute("data-typeid") || "",
|
|
156
|
-
items: datasourceItem ? [datasourceItem] : [],
|
|
157
|
-
placeholders: [],
|
|
158
|
-
parentPlaceholder: currentPlaceholder,
|
|
159
|
-
renderedDictionaryKeys: [],
|
|
160
|
-
datasourceItem,
|
|
161
|
-
layoutId: layoutId || undefined,
|
|
162
|
-
editorFields: {},
|
|
163
|
-
firstDOMElement:
|
|
164
|
-
element.tagName === "SCRIPT"
|
|
165
|
-
? (element.nextElementSibling ?? element)
|
|
166
|
-
: element,
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
currentPlaceholder.components.push(currentComponent);
|
|
170
|
-
}
|
|
171
|
-
currentPlaceholder = undefined;
|
|
172
|
-
return currentComponent;
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const endComponent = (componentEndId: string) => {
|
|
177
|
-
if (!currentComponent || currentComponent.id !== componentEndId) {
|
|
178
|
-
console.error(
|
|
179
|
-
"Component end does not match start",
|
|
180
|
-
currentComponent,
|
|
181
|
-
componentEndId,
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
// Placeholder closed implicitly
|
|
185
|
-
if (currentPlaceholder?.parentComponent.id === componentEndId) {
|
|
186
|
-
currentComponent = currentPlaceholder.parentComponent;
|
|
187
|
-
currentPlaceholder = undefined;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
currentPlaceholder = currentComponent?.parentPlaceholder;
|
|
191
|
-
|
|
192
|
-
if (currentPlaceholder?.key.startsWith("implicit_")) {
|
|
193
|
-
currentComponent = currentPlaceholder.parentComponent;
|
|
194
|
-
} else currentComponent = undefined;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const componentStack: { component: ComponentSkeleton; element: Element }[] =
|
|
198
|
-
[];
|
|
199
|
-
|
|
200
|
-
while (treeWalker.nextNode()) {
|
|
201
|
-
const node = treeWalker.currentNode;
|
|
202
|
-
|
|
203
|
-
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
204
|
-
|
|
205
|
-
const element = node as Element;
|
|
206
|
-
|
|
207
|
-
if (componentStack.length > 0) {
|
|
208
|
-
const component = componentStack[componentStack.length - 1];
|
|
209
|
-
//if element is not a descendant of the component's firstDOMElement, the component from the stack
|
|
210
|
-
if (component && !component.element.contains(element)) {
|
|
211
|
-
componentStack.pop();
|
|
212
|
-
endComponent(component.component.id);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (currentComponent && element.getAttribute("chrometype") === "field") {
|
|
217
|
-
const id = element.getAttribute("id");
|
|
218
|
-
|
|
219
|
-
if (id) {
|
|
220
|
-
//fld_C866BEE59CE340F18529EF72E1EC34A7_427EC0BD3BF245B9880FBDB0054E7925_en_1_f3327de03c4c4fb39dae57c139e6202d_913_edit
|
|
221
|
-
const idComponents = id.split("_");
|
|
222
|
-
if (idComponents.length > 2) {
|
|
223
|
-
let fieldId = idComponents[2]?.toLocaleLowerCase();
|
|
224
|
-
if (!fieldId) continue;
|
|
225
|
-
fieldId = ensureUUIDFormat(fieldId);
|
|
226
|
-
|
|
227
|
-
let itemId = idComponents[1]?.toLocaleLowerCase();
|
|
228
|
-
if (!itemId) continue;
|
|
229
|
-
itemId = ensureUUIDFormat(itemId);
|
|
230
|
-
|
|
231
|
-
let renderedItem =
|
|
232
|
-
itemId == currentComponent.datasourceItem?.id
|
|
233
|
-
? currentComponent.datasourceItem
|
|
234
|
-
: currentComponent.items.find((x) => x.id === itemId);
|
|
235
|
-
|
|
236
|
-
if (!renderedItem) {
|
|
237
|
-
renderedItem = {
|
|
238
|
-
id: itemId,
|
|
239
|
-
language: currentComponent.datasourceItem?.language || "",
|
|
240
|
-
version: currentComponent.datasourceItem?.version || 0,
|
|
241
|
-
renderedFieldIds: [],
|
|
242
|
-
};
|
|
243
|
-
currentComponent.items.push(renderedItem);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (
|
|
247
|
-
renderedItem &&
|
|
248
|
-
renderedItem.renderedFieldIds.indexOf(fieldId) === -1
|
|
249
|
-
) {
|
|
250
|
-
renderedItem.renderedFieldIds.push(fieldId);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
currentComponent.editorFields;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (currentComponent && element.hasAttribute("data-fieldid")) {
|
|
259
|
-
const fieldId = element.getAttribute("data-fieldid")!;
|
|
260
|
-
const formattedFieldId = ensureUUIDFormat(fieldId);
|
|
261
|
-
|
|
262
|
-
const language =
|
|
263
|
-
element.getAttribute("data-language") ||
|
|
264
|
-
currentComponent.datasourceItem?.language ||
|
|
265
|
-
pageItem.language;
|
|
266
|
-
const version = element.hasAttribute("data-version")
|
|
267
|
-
? parseInt(element.getAttribute("data-version")!)
|
|
268
|
-
: currentComponent.datasourceItem?.version || pageItem.version;
|
|
269
|
-
const itemId =
|
|
270
|
-
element.getAttribute("data-itemid") ||
|
|
271
|
-
currentComponent.datasourceItem?.id;
|
|
272
|
-
|
|
273
|
-
if (!itemId) continue;
|
|
274
|
-
|
|
275
|
-
let renderedItem = currentComponent.items.find(
|
|
276
|
-
(x) =>
|
|
277
|
-
x.id === itemId && x.language === language && x.version === version,
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
if (!renderedItem) {
|
|
281
|
-
renderedItem = {
|
|
282
|
-
id: itemId,
|
|
283
|
-
language,
|
|
284
|
-
version,
|
|
285
|
-
renderedFieldIds: [],
|
|
286
|
-
};
|
|
287
|
-
currentComponent.items.push(renderedItem);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (renderedItem.renderedFieldIds.indexOf(formattedFieldId) === -1) {
|
|
291
|
-
renderedItem.renderedFieldIds.push(formattedFieldId);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (element.tagName == "DIV" && element.hasAttribute("sc_item")) {
|
|
296
|
-
const componentId = extractItemId(element.getAttribute("sc_item")!);
|
|
297
|
-
if (componentId) {
|
|
298
|
-
const component = startComponent(componentId, element, componentId);
|
|
299
|
-
|
|
300
|
-
if (component) {
|
|
301
|
-
component.lastDOMElement = component.firstDOMElement;
|
|
302
|
-
componentStack.push({ component, element });
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (element.tagName === "SCRIPT") {
|
|
308
|
-
const placeholderStartId = element.getAttribute("data-placeholder-start");
|
|
309
|
-
const placeholderEndId = element.getAttribute("data-placeholder-end");
|
|
310
|
-
const componentStartId = element.getAttribute("data-component-start");
|
|
311
|
-
const componentEndId = element.getAttribute("data-component-end");
|
|
312
|
-
const dictionaryKeyStart = element.getAttribute(
|
|
313
|
-
"data-dictionary-key-start",
|
|
314
|
-
);
|
|
315
|
-
const editorGroup = element.getAttribute("data-editor-group");
|
|
316
|
-
|
|
317
|
-
if (currentComponent && editorGroup) {
|
|
318
|
-
let group = currentComponent.editorFields[editorGroup];
|
|
319
|
-
if (!group) {
|
|
320
|
-
group = {
|
|
321
|
-
addFields: [],
|
|
322
|
-
removeFields: [],
|
|
323
|
-
};
|
|
324
|
-
currentComponent.editorFields[editorGroup] = group;
|
|
325
|
-
}
|
|
326
|
-
const addFields = element.getAttribute("data-add-fields")?.split(",");
|
|
327
|
-
const removeFields = element
|
|
328
|
-
.getAttribute("data-remove-fields")
|
|
329
|
-
?.split(",");
|
|
330
|
-
|
|
331
|
-
group.addFields = [...group.addFields, ...(addFields || [])];
|
|
332
|
-
group.removeFields = [...group.removeFields, ...(removeFields || [])];
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (dictionaryKeyStart) {
|
|
336
|
-
if (!currentComponent) {
|
|
337
|
-
console.error(
|
|
338
|
-
"Dictionary key without component:",
|
|
339
|
-
dictionaryKeyStart,
|
|
340
|
-
);
|
|
341
|
-
} else {
|
|
342
|
-
currentComponent.renderedDictionaryKeys.push(dictionaryKeyStart);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (placeholderStartId) {
|
|
346
|
-
if (!currentComponent) {
|
|
347
|
-
console.error(
|
|
348
|
-
"Placeholder start without component:",
|
|
349
|
-
placeholderStartId,
|
|
350
|
-
"Current placeholder",
|
|
351
|
-
currentPlaceholder,
|
|
352
|
-
);
|
|
353
|
-
} else {
|
|
354
|
-
currentPlaceholder = currentComponent.placeholders.find(
|
|
355
|
-
(x) => x.key === placeholderStartId,
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
if (!currentPlaceholder) {
|
|
359
|
-
currentPlaceholder = {
|
|
360
|
-
key: placeholderStartId,
|
|
361
|
-
name:
|
|
362
|
-
placeholderStartId.indexOf(currentComponent.id + "_") === 0
|
|
363
|
-
? placeholderStartId.substring(currentComponent.id.length + 1)
|
|
364
|
-
: placeholderStartId,
|
|
365
|
-
description: element.getAttribute("data-description") || "",
|
|
366
|
-
components: [],
|
|
367
|
-
parentComponent: currentComponent,
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
currentComponent.placeholders.push(currentPlaceholder);
|
|
371
|
-
}
|
|
372
|
-
currentComponent = undefined;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (placeholderEndId) {
|
|
377
|
-
currentComponent = currentPlaceholder?.parentComponent;
|
|
378
|
-
if (currentPlaceholder?.key !== placeholderEndId) {
|
|
379
|
-
console.error(
|
|
380
|
-
"Placeholder end does not match start",
|
|
381
|
-
currentPlaceholder,
|
|
382
|
-
placeholderEndId,
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
currentPlaceholder = undefined;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (componentStartId) {
|
|
389
|
-
startComponent(componentStartId, element);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (componentEndId) {
|
|
393
|
-
if (currentComponent) {
|
|
394
|
-
currentComponent.lastDOMElement =
|
|
395
|
-
element.previousElementSibling || element;
|
|
396
|
-
endComponent(componentEndId);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
const page: PageSkeleton = {
|
|
403
|
-
rootComponent: root,
|
|
404
|
-
item: pageItem,
|
|
405
|
-
editRevision: editContextRef.current?.revision ?? "",
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
const time = performance.now() - start;
|
|
409
|
-
|
|
410
|
-
console.log("PAGE MODEL SKELETON", page, time);
|
|
411
|
-
pageViewContextRef.current?.setPageSkeleton(page);
|
|
412
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { ItemDescriptor, Page, PageSkeleton } from "../pageModel";
|
|
4
|
-
import { usePageModel } from "../client/pageModelBuilder";
|
|
5
|
-
import { ItemsRepository } from "../client/itemsRepository";
|
|
6
|
-
import { EditorConfiguration } from "../../config/types";
|
|
7
|
-
import { useDebouncedCallback } from "use-debounce";
|
|
8
|
-
import { resolvePageAndSite } from "../services/contentService";
|
|
9
|
-
import { Site } from "../../types";
|
|
10
|
-
|
|
11
|
-
export type PageViewContext = {
|
|
12
|
-
device: string;
|
|
13
|
-
setDevice: React.Dispatch<React.SetStateAction<string>>;
|
|
14
|
-
zoom: number;
|
|
15
|
-
setZoom: React.Dispatch<React.SetStateAction<number>>;
|
|
16
|
-
scroll: number;
|
|
17
|
-
setScroll: React.Dispatch<React.SetStateAction<number>>;
|
|
18
|
-
fullscreen: boolean;
|
|
19
|
-
setFullscreen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
20
|
-
editorIframeRef: React.RefObject<HTMLIFrameElement | null>;
|
|
21
|
-
deviceWidth?: number;
|
|
22
|
-
deviceHeight?: number;
|
|
23
|
-
setDeviceWidth: React.Dispatch<React.SetStateAction<number | undefined>>;
|
|
24
|
-
setDeviceHeight: React.Dispatch<React.SetStateAction<number | undefined>>;
|
|
25
|
-
lockHeight: boolean;
|
|
26
|
-
setLockHeight: React.Dispatch<React.SetStateAction<boolean>>;
|
|
27
|
-
rotate: boolean;
|
|
28
|
-
setRotate: React.Dispatch<React.SetStateAction<boolean>>;
|
|
29
|
-
page?: Page;
|
|
30
|
-
pageItemDescriptor?: ItemDescriptor;
|
|
31
|
-
setPageSkeleton: React.Dispatch<
|
|
32
|
-
React.SetStateAction<PageSkeleton | undefined>
|
|
33
|
-
>;
|
|
34
|
-
viewport: { width: number; height: number };
|
|
35
|
-
setWorkaround: React.Dispatch<React.SetStateAction<boolean>>;
|
|
36
|
-
isHeadless: boolean;
|
|
37
|
-
site?: Site;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export function usePageViewContext({
|
|
41
|
-
pageItemDescriptor,
|
|
42
|
-
itemsRepository,
|
|
43
|
-
configuration,
|
|
44
|
-
}: {
|
|
45
|
-
pageItemDescriptor?: ItemDescriptor;
|
|
46
|
-
itemsRepository?: ItemsRepository;
|
|
47
|
-
configuration?: EditorConfiguration;
|
|
48
|
-
}) {
|
|
49
|
-
const [device, setDevice] = useState<string>("desktop");
|
|
50
|
-
const [zoom, setZoom] = useState<number>(1);
|
|
51
|
-
const [scroll, setScroll] = useState<number>(0);
|
|
52
|
-
const [fullscreen, setFullscreen] = useState<boolean>(false);
|
|
53
|
-
const editorIframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
54
|
-
const [deviceWidth, setDeviceWidth] = useState<number>();
|
|
55
|
-
const [deviceHeight, setDeviceHeight] = useState<number>();
|
|
56
|
-
const [lockHeight, setLockHeight] = useState(true);
|
|
57
|
-
const [rotate, setRotate] = useState(false);
|
|
58
|
-
const [viewportRect, setViewportRect] = useState({ width: 0, height: 0 });
|
|
59
|
-
const [workaround, setWorkaround] = useState(false);
|
|
60
|
-
const [site, setSite] = useState<Site>();
|
|
61
|
-
const [resolvedPageItemDescriptor, setResolvedPageItemDescriptor] =
|
|
62
|
-
useState<ItemDescriptor>();
|
|
63
|
-
const [isHeadless, setIsHeadless] = useState(false);
|
|
64
|
-
|
|
65
|
-
const { page, setPageSkeleton } = usePageModel(
|
|
66
|
-
itemsRepository,
|
|
67
|
-
pageItemDescriptor
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
var deviceConfig = configuration?.devices.find((x) => x.name === device);
|
|
72
|
-
|
|
73
|
-
let width = deviceConfig?.width;
|
|
74
|
-
let height = deviceConfig?.height;
|
|
75
|
-
|
|
76
|
-
if (rotate) {
|
|
77
|
-
[width, height] = [height, width];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (device) {
|
|
81
|
-
setDeviceWidth(width);
|
|
82
|
-
setDeviceHeight(lockHeight ? height : undefined);
|
|
83
|
-
}
|
|
84
|
-
}, [rotate, device, lockHeight, configuration]);
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
updateViewportRect();
|
|
88
|
-
}, [fullscreen, device, deviceHeight, deviceWidth]);
|
|
89
|
-
|
|
90
|
-
const updateViewportRectDebounced = useDebouncedCallback(() => {
|
|
91
|
-
updateViewportRect();
|
|
92
|
-
}, 100);
|
|
93
|
-
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
96
|
-
updateViewportRectDebounced();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (editorIframeRef.current) {
|
|
100
|
-
resizeObserver.observe(editorIframeRef.current);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Cleanup function
|
|
104
|
-
return () => {
|
|
105
|
-
if (editorIframeRef.current) {
|
|
106
|
-
resizeObserver.disconnect();
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}, [editorIframeRef.current, workaround]);
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (!pageItemDescriptor) return;
|
|
113
|
-
|
|
114
|
-
async function resolvePage() {
|
|
115
|
-
if (!pageItemDescriptor) {
|
|
116
|
-
setSite(undefined);
|
|
117
|
-
setResolvedPageItemDescriptor(undefined);
|
|
118
|
-
setPageSkeleton(undefined);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (!itemsRepository) return;
|
|
122
|
-
|
|
123
|
-
const item = await itemsRepository.getItem(pageItemDescriptor);
|
|
124
|
-
if (!item?.hasLayout) {
|
|
125
|
-
setSite(undefined);
|
|
126
|
-
setResolvedPageItemDescriptor(undefined);
|
|
127
|
-
setPageSkeleton(undefined);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
console.log(
|
|
132
|
-
"resolve page",
|
|
133
|
-
pageItemDescriptor.id,
|
|
134
|
-
pageItemDescriptor.language,
|
|
135
|
-
pageItemDescriptor.version
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const result = await resolvePageAndSite(
|
|
139
|
-
pageItemDescriptor.id,
|
|
140
|
-
pageItemDescriptor.language,
|
|
141
|
-
pageItemDescriptor.version
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
if (result) {
|
|
145
|
-
setIsHeadless(result.isHeadless);
|
|
146
|
-
setSite(result.site);
|
|
147
|
-
setResolvedPageItemDescriptor(result.pageItem);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
resolvePage();
|
|
151
|
-
}, [pageItemDescriptor]);
|
|
152
|
-
|
|
153
|
-
function updateViewportRect() {
|
|
154
|
-
const rect = editorIframeRef.current?.getBoundingClientRect();
|
|
155
|
-
if (rect) setViewportRect({ width: rect.width, height: rect.height });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const pageViewContext: PageViewContext = {
|
|
159
|
-
device,
|
|
160
|
-
setDevice,
|
|
161
|
-
deviceWidth,
|
|
162
|
-
setDeviceWidth,
|
|
163
|
-
deviceHeight,
|
|
164
|
-
setDeviceHeight,
|
|
165
|
-
lockHeight,
|
|
166
|
-
setLockHeight,
|
|
167
|
-
scroll,
|
|
168
|
-
setScroll,
|
|
169
|
-
zoom,
|
|
170
|
-
setZoom,
|
|
171
|
-
fullscreen,
|
|
172
|
-
setFullscreen,
|
|
173
|
-
editorIframeRef,
|
|
174
|
-
rotate,
|
|
175
|
-
setRotate,
|
|
176
|
-
page,
|
|
177
|
-
setPageSkeleton,
|
|
178
|
-
viewport: viewportRect,
|
|
179
|
-
pageItemDescriptor: resolvedPageItemDescriptor,
|
|
180
|
-
setWorkaround,
|
|
181
|
-
isHeadless,
|
|
182
|
-
site,
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
return pageViewContext;
|
|
186
|
-
}
|