@alpaca-editor/core 1.0.3942 → 1.0.3944
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/.prettierrc +3 -0
- package/build.css +3 -0
- package/components.json +21 -0
- package/dist/editor/ContentTree.d.ts +2 -1
- package/dist/editor/ContentTree.js +23 -21
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.js +0 -2
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/ScrollingContentTree.js +1 -1
- package/dist/editor/ScrollingContentTree.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 +24 -3
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +7 -7
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/field-types/InternalLinkFieldEditor.js +60 -10
- package/dist/editor/field-types/InternalLinkFieldEditor.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js +48 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +116 -65
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +5 -2
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/ui/ItemSearch.js +14 -8
- package/dist/editor/ui/ItemSearch.js.map +1 -1
- package/dist/editor/ui/PerfectTree.d.ts +4 -2
- package/dist/editor/ui/PerfectTree.js +78 -4
- package/dist/editor/ui/PerfectTree.js.map +1 -1
- package/dist/editor/ui/Splitter.js +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +8 -2
- package/eslint.config.mjs +4 -0
- 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/package.json +2 -8
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +50 -0
- package/src/components/Error.tsx +57 -0
- package/src/components/ui/CardConnector.tsx +56 -0
- package/src/components/ui/button.tsx +62 -0
- package/src/components/ui/card.tsx +372 -0
- package/src/components/ui/context-menu.tsx +250 -0
- package/src/config/config.tsx +917 -0
- package/src/config/types.ts +286 -0
- package/src/editor/ComponentInfo.tsx +90 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +733 -0
- package/src/editor/ContextMenu.tsx +230 -0
- package/src/editor/Editor.tsx +90 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldActionsOverlay.tsx +296 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +75 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +391 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +217 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +128 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +196 -0
- package/src/editor/MainLayout.tsx +95 -0
- package/src/editor/MobileLayout.tsx +68 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +568 -0
- package/src/editor/PictureEditor.tsx +301 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +68 -0
- package/src/editor/Terminal.tsx +227 -0
- package/src/editor/Titlebar.tsx +104 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +106 -0
- package/src/editor/ai/AiTerminal.tsx +503 -0
- package/src/editor/ai/AiToolCall.tsx +61 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/GhostWriter.tsx +480 -0
- package/src/editor/ai/aiPageModel.ts +108 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/AboutDialog.tsx +44 -0
- package/src/editor/client/EditorClient.tsx +2241 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +416 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +574 -0
- package/src/editor/client/operations.ts +768 -0
- package/src/editor/client/pageModelBuilder.ts +219 -0
- package/src/editor/commands/commands.ts +22 -0
- package/src/editor/commands/componentCommands.tsx +431 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +351 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -0
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +27 -0
- package/src/editor/commands/undo.ts +39 -0
- package/src/editor/component-designer/ComponentDesigner.tsx +70 -0
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +11 -0
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +91 -0
- package/src/editor/component-designer/ComponentEditor.tsx +97 -0
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +31 -0
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +104 -0
- package/src/editor/component-designer/ComponentsDropdown.tsx +39 -0
- package/src/editor/component-designer/PlaceholdersEditor.tsx +179 -0
- package/src/editor/component-designer/RenderingsDropdown.tsx +36 -0
- package/src/editor/component-designer/TemplateEditor.tsx +236 -0
- package/src/editor/component-designer/aiContext.ts +23 -0
- package/src/editor/componentTreeHelper.tsx +116 -0
- package/src/editor/context-menu/CopyMoveMenu.tsx +103 -0
- package/src/editor/context-menu/InsertMenu.tsx +347 -0
- package/src/editor/control-center/About.tsx +342 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +76 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Info.tsx +104 -0
- package/src/editor/control-center/QuotaInfo.tsx +301 -0
- package/src/editor/control-center/Status.tsx +113 -0
- package/src/editor/control-center/WebSocketMessages.tsx +155 -0
- package/src/editor/editor-warnings/ItemLocked.tsx +63 -0
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +22 -0
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +23 -0
- package/src/editor/editor-warnings/NoWriteAccess.tsx +16 -0
- package/src/editor/editor-warnings/ValidationErrors.tsx +54 -0
- package/src/editor/field-types/AttachmentEditor.tsx +9 -0
- package/src/editor/field-types/CheckboxEditor.tsx +47 -0
- package/src/editor/field-types/DropLinkEditor.tsx +80 -0
- package/src/editor/field-types/DropListEditor.tsx +84 -0
- package/src/editor/field-types/ImageFieldEditor.tsx +65 -0
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +188 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +82 -0
- package/src/editor/field-types/PictureFieldEditor.tsx +121 -0
- package/src/editor/field-types/RawEditor.tsx +53 -0
- package/src/editor/field-types/ReactQuill.tsx +580 -0
- package/src/editor/field-types/RichTextEditor.tsx +22 -0
- package/src/editor/field-types/RichTextEditorComponent.tsx +127 -0
- package/src/editor/field-types/SingleLineText.tsx +174 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +185 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +94 -0
- package/src/editor/media-selector/MediaFolderBrowser.tsx +321 -0
- package/src/editor/media-selector/MediaSelector.tsx +42 -0
- package/src/editor/media-selector/Preview.tsx +14 -0
- package/src/editor/media-selector/Thumbnails.tsx +48 -0
- package/src/editor/media-selector/TreeSelector.tsx +292 -0
- package/src/editor/media-selector/UploadZone.tsx +137 -0
- package/src/editor/media-selector/index.ts +8 -0
- package/src/editor/menubar/ActionsMenu.tsx +94 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +28 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +76 -0
- package/src/editor/menubar/LanguageSelector.tsx +226 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +278 -0
- package/src/editor/menubar/PageViewerControls.tsx +120 -0
- package/src/editor/menubar/PreviewSecondaryControls.tsx +18 -0
- package/src/editor/menubar/SecondaryControls.tsx +45 -0
- package/src/editor/menubar/Separator.tsx +12 -0
- package/src/editor/menubar/SiteInfo.tsx +53 -0
- package/src/editor/menubar/User.tsx +27 -0
- package/src/editor/menubar/VersionSelector.tsx +142 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +307 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +59 -0
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +23 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +64 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +35 -0
- package/src/editor/page-editor-chrome/FrameMenu.tsx +338 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +765 -0
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +61 -0
- package/src/editor/page-editor-chrome/NoLayout.tsx +36 -0
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +122 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +161 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +169 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +315 -0
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +300 -0
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +40 -0
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +828 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +262 -0
- package/src/editor/page-viewer/MiniMap.tsx +362 -0
- package/src/editor/page-viewer/PageViewer.tsx +169 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1022 -0
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +412 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +220 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +308 -0
- package/src/editor/reviews/Comments.tsx +125 -0
- package/src/editor/reviews/DiffView.tsx +109 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/SuggestedEdit.tsx +316 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +173 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +180 -0
- package/src/editor/services/editService.ts +488 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +53 -0
- package/src/editor/services/serviceHelper.ts +95 -0
- package/src/editor/services/suggestedEditsService.ts +39 -0
- package/src/editor/services/systemService.ts +5 -0
- package/src/editor/services/translationService.ts +21 -0
- package/src/editor/services-server/api.ts +150 -0
- package/src/editor/services-server/graphQL.ts +106 -0
- package/src/editor/sidebar/ComponentPalette.tsx +161 -0
- package/src/editor/sidebar/ComponentTree.tsx +549 -0
- package/src/editor/sidebar/Debug.tsx +111 -0
- package/src/editor/sidebar/DictionaryEditor.tsx +261 -0
- package/src/editor/sidebar/EditHistory.tsx +134 -0
- package/src/editor/sidebar/GraphQL.tsx +164 -0
- package/src/editor/sidebar/Insert.tsx +35 -0
- package/src/editor/sidebar/MainContentTree.tsx +102 -0
- package/src/editor/sidebar/Performance.tsx +53 -0
- package/src/editor/sidebar/Sessions.tsx +35 -0
- package/src/editor/sidebar/Sidebar.tsx +20 -0
- package/src/editor/sidebar/SidebarView.tsx +152 -0
- package/src/editor/sidebar/Translations.tsx +295 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +60 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +81 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +24 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +709 -0
- package/src/editor/ui/ItemList.tsx +76 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +159 -0
- package/src/editor/ui/PerfectTree.tsx +676 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +54 -0
- package/src/editor/ui/SimpleMenu.tsx +40 -0
- package/src/editor/ui/SimpleTable.tsx +60 -0
- package/src/editor/ui/SimpleTabs.tsx +60 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +9 -0
- package/src/editor/ui/Splitter.tsx +420 -0
- package/src/editor/ui/StackedPanels.tsx +134 -0
- package/src/editor/ui/Toolbar.tsx +7 -0
- package/src/editor/utils/id-helper.ts +3 -0
- package/src/editor/utils/insertOptions.ts +69 -0
- package/src/editor/utils/itemutils.ts +29 -0
- package/src/editor/utils/useMemoDebug.ts +28 -0
- package/src/editor/utils.ts +486 -0
- package/src/editor/views/CompareView.tsx +245 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/MediaFolderEditView.tsx +66 -0
- package/src/editor/views/SingleEditView.tsx +57 -0
- 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 +10 -0
- package/src/index.ts +23 -0
- package/src/lib/safelist.tsx +16 -0
- package/src/lib/utils.ts +6 -0
- package/src/page-wizard/PageWizard.tsx +139 -0
- package/src/page-wizard/WizardBox.tsx +4 -0
- package/src/page-wizard/WizardBoxConnector.tsx +56 -0
- package/src/page-wizard/WizardSteps.tsx +458 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +26 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +259 -0
- package/src/page-wizard/steps/CollectStep.tsx +296 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +454 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/ContentStep.tsx +890 -0
- package/src/page-wizard/steps/EditButton.tsx +34 -0
- package/src/page-wizard/steps/FieldEditor.tsx +102 -0
- package/src/page-wizard/steps/Generate.tsx +60 -0
- package/src/page-wizard/steps/ImagesStep.tsx +382 -0
- package/src/page-wizard/steps/LayoutStep.tsx +227 -0
- package/src/page-wizard/steps/MetaDataStep.tsx +173 -0
- package/src/page-wizard/steps/SelectStep.tsx +281 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +325 -0
- package/src/page-wizard/usePageWizard.ts +79 -0
- package/src/revision.ts +2 -0
- package/src/splash-screen/NewPage.tsx +294 -0
- package/src/splash-screen/OpenPage.tsx +113 -0
- package/src/splash-screen/RecentPages.tsx +123 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +195 -0
- package/src/tour/Tour.tsx +566 -0
- package/src/tour/default-tour.tsx +301 -0
- package/src/tour/preview-tour.tsx +128 -0
- package/src/types.ts +335 -0
- package/styles.css +765 -0
- package/tsconfig.build.json +31 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,412 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
}
|