@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,70 +0,0 @@
|
|
|
1
|
-
import { Dropdown } from "primereact/dropdown";
|
|
2
|
-
import { InputNumber } from "primereact/inputnumber";
|
|
3
|
-
import { SimpleIconButton } from "../ui/SimpleIconButton";
|
|
4
|
-
import { RotateDeviceIcon } from "../ui/Icons";
|
|
5
|
-
import { useDebouncedCallback } from "use-debounce";
|
|
6
|
-
import { PageViewContext } from "./pageViewContext";
|
|
7
|
-
import { EditorConfiguration } from "../../config/types";
|
|
8
|
-
|
|
9
|
-
export function DeviceToolbar({
|
|
10
|
-
pageViewContext,
|
|
11
|
-
configuration,
|
|
12
|
-
}: {
|
|
13
|
-
pageViewContext: PageViewContext;
|
|
14
|
-
configuration: EditorConfiguration;
|
|
15
|
-
}) {
|
|
16
|
-
const debouncedSetDeviceWidth = useDebouncedCallback(
|
|
17
|
-
(width: number | undefined) => {
|
|
18
|
-
pageViewContext.setDeviceWidth(width);
|
|
19
|
-
},
|
|
20
|
-
400
|
|
21
|
-
);
|
|
22
|
-
const debouncedSetDeviceHeight = useDebouncedCallback(
|
|
23
|
-
(height: number | undefined) => {
|
|
24
|
-
pageViewContext.setDeviceHeight(height);
|
|
25
|
-
},
|
|
26
|
-
400
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="flex justify-center w-full items-center bg-gray-100 p-1 z-1000 text-sm gap-2 border-b">
|
|
31
|
-
<Dropdown
|
|
32
|
-
options={configuration.devices.map((x) => ({
|
|
33
|
-
label: x.name,
|
|
34
|
-
value: x.name,
|
|
35
|
-
}))}
|
|
36
|
-
value={pageViewContext.device}
|
|
37
|
-
onChange={(e) => pageViewContext.setDevice(e.value)}
|
|
38
|
-
/>
|
|
39
|
-
<InputNumber
|
|
40
|
-
size={4}
|
|
41
|
-
max={10000}
|
|
42
|
-
className="text-sm"
|
|
43
|
-
value={pageViewContext.deviceWidth}
|
|
44
|
-
onChange={(e) => debouncedSetDeviceWidth(e.value || undefined)}
|
|
45
|
-
/>
|
|
46
|
-
x
|
|
47
|
-
<InputNumber
|
|
48
|
-
size={4}
|
|
49
|
-
max={10000}
|
|
50
|
-
className="text-sm"
|
|
51
|
-
value={pageViewContext.deviceHeight}
|
|
52
|
-
onChange={(e) => debouncedSetDeviceHeight(e.value || undefined)}
|
|
53
|
-
/>
|
|
54
|
-
<SimpleIconButton
|
|
55
|
-
icon="pi pi-lock"
|
|
56
|
-
selected={pageViewContext.lockHeight || false}
|
|
57
|
-
onClick={() =>
|
|
58
|
-
pageViewContext.setLockHeight(!pageViewContext.lockHeight)
|
|
59
|
-
}
|
|
60
|
-
label="Lock Height"
|
|
61
|
-
/>
|
|
62
|
-
<SimpleIconButton
|
|
63
|
-
icon={<RotateDeviceIcon className="w-4 h-4" />}
|
|
64
|
-
selected={pageViewContext.rotate || false}
|
|
65
|
-
onClick={() => pageViewContext.setRotate(!pageViewContext.rotate)}
|
|
66
|
-
label="Rotate"
|
|
67
|
-
/>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { useEditContext } from "../client/editContext";
|
|
2
|
-
import { getComponentById } from "../componentTreeHelper";
|
|
3
|
-
|
|
4
|
-
import { FieldList, ItemFields } from "../FieldList";
|
|
5
|
-
import { ItemInfo } from "../ItemInfo";
|
|
6
|
-
import { Insert } from "../sidebar/Insert";
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
8
|
-
|
|
9
|
-
import { SimpleIconButton } from "../ui/SimpleIconButton";
|
|
10
|
-
import { Component, Field, FullItem, RenderedItem } from "../pageModel";
|
|
11
|
-
import { Spinner } from "../ui/Spinner";
|
|
12
|
-
import { PageViewContext } from "./pageViewContext";
|
|
13
|
-
import { SimpleTabs, Tab } from "../ui/SimpleTabs";
|
|
14
|
-
|
|
15
|
-
export function EditorForm({
|
|
16
|
-
pageViewContext,
|
|
17
|
-
readonly,
|
|
18
|
-
compareView,
|
|
19
|
-
}: {
|
|
20
|
-
pageViewContext?: PageViewContext;
|
|
21
|
-
readonly?: boolean;
|
|
22
|
-
compareView: boolean;
|
|
23
|
-
}) {
|
|
24
|
-
const editContext = useEditContext()!;
|
|
25
|
-
if (!pageViewContext) pageViewContext = editContext.pageView;
|
|
26
|
-
|
|
27
|
-
const setInsertMode = editContext.setInsertMode;
|
|
28
|
-
const insertMode =
|
|
29
|
-
editContext.insertMode && editContext.mode === "edit" && !compareView;
|
|
30
|
-
const [activeTabKey, setActiveTabKey] = useState("content");
|
|
31
|
-
const [item, setItem] = useState<RenderedItem>();
|
|
32
|
-
const [component, setComponent] = useState<Component>();
|
|
33
|
-
const [fullItem, setFullItem] = useState<FullItem>();
|
|
34
|
-
|
|
35
|
-
const toggleInsertMode = () => {
|
|
36
|
-
if (insertMode) {
|
|
37
|
-
setInsertMode(false);
|
|
38
|
-
} else {
|
|
39
|
-
setInsertMode(true);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
async function loadFullItem() {
|
|
45
|
-
if (!item) return;
|
|
46
|
-
const fullItem = await editContext!.itemsRepository.getItem(item);
|
|
47
|
-
setFullItem(fullItem);
|
|
48
|
-
}
|
|
49
|
-
loadFullItem();
|
|
50
|
-
}, [item]);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (editContext.selectedForInsertion) setInsertMode(true);
|
|
54
|
-
}, [editContext.selectedForInsertion]);
|
|
55
|
-
|
|
56
|
-
let isShared = false;
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!pageViewContext.page) return;
|
|
60
|
-
let newSelectedItem;
|
|
61
|
-
|
|
62
|
-
if (editContext.selection.length === 1) {
|
|
63
|
-
const component = getComponentById(
|
|
64
|
-
editContext.selection[0]!,
|
|
65
|
-
pageViewContext.page,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
setComponent(component);
|
|
69
|
-
newSelectedItem = component?.datasourceItem;
|
|
70
|
-
if (
|
|
71
|
-
component?.datasourceItem &&
|
|
72
|
-
component?.datasourceItem?.id !== component?.id
|
|
73
|
-
)
|
|
74
|
-
isShared = true;
|
|
75
|
-
} else {
|
|
76
|
-
newSelectedItem = pageViewContext.page.rootComponent.datasourceItem;
|
|
77
|
-
setComponent(pageViewContext.page.rootComponent);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
setItem(
|
|
81
|
-
newSelectedItem || pageViewContext.page.rootComponent.datasourceItem,
|
|
82
|
-
);
|
|
83
|
-
}, [
|
|
84
|
-
editContext.selection,
|
|
85
|
-
pageViewContext.page,
|
|
86
|
-
pageViewContext.pageItemDescriptor,
|
|
87
|
-
]);
|
|
88
|
-
|
|
89
|
-
if (!fullItem || !item)
|
|
90
|
-
return (
|
|
91
|
-
<div className="grid h-full w-full items-center justify-center">
|
|
92
|
-
<Spinner />
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const validators =
|
|
97
|
-
editContext.validationResult?.find(
|
|
98
|
-
(x) =>
|
|
99
|
-
x.item.id === item?.id &&
|
|
100
|
-
x.item.language === item?.language &&
|
|
101
|
-
x.item.version === item?.version,
|
|
102
|
-
)?.results || [];
|
|
103
|
-
|
|
104
|
-
let designFields = Object.values(fullItem?.fields || []).filter(
|
|
105
|
-
(x) => x.section === "Design" || x.section === "Rendering",
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const editorFields = component?.editorFields;
|
|
109
|
-
|
|
110
|
-
if (editorFields && editorFields["Design"]) {
|
|
111
|
-
editorFields["Design"]?.addFields.forEach((fieldName) => {
|
|
112
|
-
const field = fullItem?.fields.find((x) => x.name === fieldName);
|
|
113
|
-
if (field) designFields.push(field);
|
|
114
|
-
});
|
|
115
|
-
editorFields["Design"]?.removeFields.forEach((fieldName) => {
|
|
116
|
-
designFields = designFields.filter((x) => x.name !== fieldName);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const itemFields: ItemFields[] = [];
|
|
121
|
-
|
|
122
|
-
const contentFields = Object.values(fullItem?.fields || []).filter(
|
|
123
|
-
(x) =>
|
|
124
|
-
((editorFields && editorFields["Content"]?.addFields.includes(x.name!)) ||
|
|
125
|
-
item.renderedFieldIds.indexOf(x.id) >= 0) &&
|
|
126
|
-
!(
|
|
127
|
-
editorFields && editorFields["Content"]?.removeFields.includes(x.name!)
|
|
128
|
-
),
|
|
129
|
-
);
|
|
130
|
-
if (contentFields.length > 0) itemFields.push({ fields: contentFields });
|
|
131
|
-
|
|
132
|
-
component?.items
|
|
133
|
-
.filter((x) => x.id !== item.id)
|
|
134
|
-
.forEach((i) => {
|
|
135
|
-
const fields: Field[] = [];
|
|
136
|
-
i.renderedFieldIds.forEach((id) => {
|
|
137
|
-
const field = Object.values(fullItem?.fields || []).find(
|
|
138
|
-
(x) => x.id === id,
|
|
139
|
-
);
|
|
140
|
-
if (field) fields.push(field);
|
|
141
|
-
});
|
|
142
|
-
if (fields.length > 0) itemFields.push({ headline: i.name, fields });
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const getFieldsTab = (fields: ItemFields[], headline: string, id: string) => {
|
|
146
|
-
return {
|
|
147
|
-
label: headline,
|
|
148
|
-
content: (
|
|
149
|
-
<div className="relative h-full">
|
|
150
|
-
<div className="absolute inset-0 overflow-auto">
|
|
151
|
-
<FieldList
|
|
152
|
-
fields={fields}
|
|
153
|
-
validators={validators}
|
|
154
|
-
simplified={true}
|
|
155
|
-
readonly={readonly}
|
|
156
|
-
/>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
),
|
|
160
|
-
id,
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const tabPanels: Tab[] = [];
|
|
165
|
-
if (itemFields.length > 0)
|
|
166
|
-
tabPanels.push(getFieldsTab(itemFields, "Content", "content"));
|
|
167
|
-
|
|
168
|
-
//TODO: generalize thisdata-field-id
|
|
169
|
-
if (editorFields) {
|
|
170
|
-
Object.keys(editorFields).forEach((key) => {
|
|
171
|
-
if (key !== "Content" && key !== "Design") {
|
|
172
|
-
const fields = fullItem?.fields.filter((x) =>
|
|
173
|
-
editorFields[key]?.addFields.includes(x.name!),
|
|
174
|
-
);
|
|
175
|
-
if (fields?.length)
|
|
176
|
-
tabPanels.push(getFieldsTab([{ fields }], key, key));
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (designFields?.length)
|
|
182
|
-
tabPanels.push(
|
|
183
|
-
getFieldsTab([{ fields: designFields }], "Design", "design"),
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
tabPanels.push({
|
|
187
|
-
label: "Advanced",
|
|
188
|
-
content: (
|
|
189
|
-
<div className="relative h-full">
|
|
190
|
-
<div className="absolute inset-0 overflow-auto">
|
|
191
|
-
<ItemInfo item={fullItem} />
|
|
192
|
-
<FieldList
|
|
193
|
-
fields={[{ fields: fullItem?.fields || [] }]}
|
|
194
|
-
validators={validators}
|
|
195
|
-
showStandardFieldsEnabled={true}
|
|
196
|
-
readonly={readonly}
|
|
197
|
-
/>
|
|
198
|
-
</div>
|
|
199
|
-
</div>
|
|
200
|
-
),
|
|
201
|
-
id: "advanced",
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<div
|
|
206
|
-
className="flex h-full flex-col bg-gray-50"
|
|
207
|
-
data-testid="editor-sidepanel"
|
|
208
|
-
>
|
|
209
|
-
<h1 className="flex h-12 items-center justify-center border-b border-gray-200 p-2">
|
|
210
|
-
{component !== pageViewContext.page?.rootComponent && (
|
|
211
|
-
<SimpleIconButton
|
|
212
|
-
icon="pi pi-angle-left"
|
|
213
|
-
onClick={() => editContext.select([])}
|
|
214
|
-
label="Back to page"
|
|
215
|
-
size="large"
|
|
216
|
-
/>
|
|
217
|
-
)}
|
|
218
|
-
{editContext.selection.length === 0 && <div className="w-12" />}
|
|
219
|
-
<div
|
|
220
|
-
className="flex-1 text-center text-gray-800"
|
|
221
|
-
id="item-name"
|
|
222
|
-
data-testid="component-name"
|
|
223
|
-
>
|
|
224
|
-
{item?.name}
|
|
225
|
-
{isShared && (
|
|
226
|
-
<span className="ml-2 rounded-md bg-orange-400 p-2 text-sm text-black">
|
|
227
|
-
Shared
|
|
228
|
-
</span>
|
|
229
|
-
)}
|
|
230
|
-
</div>
|
|
231
|
-
<SimpleIconButton
|
|
232
|
-
id="insert-component-button"
|
|
233
|
-
icon={insertMode ? "pi pi-pencil" : "pi pi-plus"}
|
|
234
|
-
onClick={() => toggleInsertMode()}
|
|
235
|
-
label={insertMode ? "Continue editing" : "Insert component"}
|
|
236
|
-
size="large"
|
|
237
|
-
disabled={
|
|
238
|
-
!editContext.page?.item.canWriteItem ||
|
|
239
|
-
!fullItem?.canWriteItem ||
|
|
240
|
-
editContext.mode !== "edit" ||
|
|
241
|
-
compareView
|
|
242
|
-
}
|
|
243
|
-
/>
|
|
244
|
-
</h1>
|
|
245
|
-
|
|
246
|
-
{insertMode && <Insert />}
|
|
247
|
-
{!insertMode && (
|
|
248
|
-
<SimpleTabs
|
|
249
|
-
key="editor-tabs"
|
|
250
|
-
tabs={tabPanels}
|
|
251
|
-
className="flex flex-1 items-center justify-center border-b border-gray-200 bg-gray-50 py-2.5 text-sm"
|
|
252
|
-
activeTab={tabPanels.findIndex((x) => x.id === activeTabKey) || 0}
|
|
253
|
-
setActiveTab={(index) => setActiveTabKey(tabPanels[index]?.id!)}
|
|
254
|
-
></SimpleTabs>
|
|
255
|
-
)}
|
|
256
|
-
</div>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import { useEditContext, EditorMode } from "../client/editContext";
|
|
3
|
-
import { PlaceholderDropZones } from "../page-editor-chrome/PlaceholderDropZones";
|
|
4
|
-
import { FieldEditedIndicators } from "../page-editor-chrome/FieldEditedIndicators";
|
|
5
|
-
import { PageViewContext } from "./pageViewContext";
|
|
6
|
-
import { CommentHighlightings } from "../page-editor-chrome/CommentHighlightings";
|
|
7
|
-
import { SuggestionHighlightings } from "../page-editor-chrome/SuggestionHighlightings";
|
|
8
|
-
|
|
9
|
-
export function MiniMap({
|
|
10
|
-
deviceHeight,
|
|
11
|
-
scroll,
|
|
12
|
-
mainViewIframeRef,
|
|
13
|
-
compareView,
|
|
14
|
-
pageViewContext,
|
|
15
|
-
}: {
|
|
16
|
-
deviceHeight?: number;
|
|
17
|
-
scroll: number;
|
|
18
|
-
mainViewIframeRef: React.RefObject<HTMLIFrameElement | null>;
|
|
19
|
-
compareView: boolean;
|
|
20
|
-
pageViewContext: PageViewContext;
|
|
21
|
-
}) {
|
|
22
|
-
const editContext = useEditContext();
|
|
23
|
-
|
|
24
|
-
const [scale, setScale] = React.useState(1);
|
|
25
|
-
const minimapRef = useRef<HTMLDivElement>(null);
|
|
26
|
-
const scaleContainerRef = useRef<HTMLDivElement>(null);
|
|
27
|
-
|
|
28
|
-
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
29
|
-
const [minimapReady, setMinimapReady] = React.useState(false);
|
|
30
|
-
const [refreshScale, setRefreshScale] = React.useState(0);
|
|
31
|
-
|
|
32
|
-
const observerRef = useRef<MutationObserver | null>(null);
|
|
33
|
-
|
|
34
|
-
const editorIframeRef = mainViewIframeRef;
|
|
35
|
-
const minimapContainerRef = useRef<HTMLDivElement>(null);
|
|
36
|
-
|
|
37
|
-
if (!mainViewIframeRef.current) return;
|
|
38
|
-
|
|
39
|
-
const scrollContainer =
|
|
40
|
-
editorIframeRef.current?.contentWindow?.document.scrollingElement ||
|
|
41
|
-
editorIframeRef.current?.contentWindow?.document.body;
|
|
42
|
-
|
|
43
|
-
const calcAndUpdateScale = () => {
|
|
44
|
-
const viewport = pageViewContext.viewport;
|
|
45
|
-
const minimapHeight = minimapContainerRef.current?.clientHeight;
|
|
46
|
-
if (!viewport || !scrollContainer) return;
|
|
47
|
-
const width = viewport.width;
|
|
48
|
-
const scaleX = (editContext?.configuration.outline.width || 100) / width;
|
|
49
|
-
const scaleY =
|
|
50
|
-
Math.max(deviceHeight || 0, minimapHeight || viewport.height) /
|
|
51
|
-
scrollContainer.scrollHeight!;
|
|
52
|
-
|
|
53
|
-
const newScale = Math.min(scaleX, scaleY, 1);
|
|
54
|
-
updateScale(newScale);
|
|
55
|
-
setScale(newScale);
|
|
56
|
-
return newScale;
|
|
57
|
-
};
|
|
58
|
-
// Prevent scale/width feedback loop by tracking previous values
|
|
59
|
-
const prevScaleRef = useRef(scale);
|
|
60
|
-
const prevWidthRef = useRef(0);
|
|
61
|
-
|
|
62
|
-
const miniMapWidth = useMemo(() => {
|
|
63
|
-
const currentWidth = Math.max(
|
|
64
|
-
30,
|
|
65
|
-
scale * (pageViewContext.viewport.width || 0),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// Only update if change is significant (>1px) to avoid minor oscillations
|
|
69
|
-
if (
|
|
70
|
-
prevWidthRef.current < currentWidth ||
|
|
71
|
-
(Math.abs(currentWidth - prevWidthRef.current) > 1 &&
|
|
72
|
-
Math.abs(scale - prevScaleRef.current) > 0.01)
|
|
73
|
-
) {
|
|
74
|
-
prevWidthRef.current = currentWidth;
|
|
75
|
-
prevScaleRef.current = scale;
|
|
76
|
-
return currentWidth;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return prevWidthRef.current;
|
|
80
|
-
}, [scale, scrollContainer?.clientWidth, pageViewContext.viewport]);
|
|
81
|
-
|
|
82
|
-
function updateCorrespondingNode(node: HTMLElement) {
|
|
83
|
-
const path = [];
|
|
84
|
-
let current: Node | null = node;
|
|
85
|
-
|
|
86
|
-
if (node?.tagName === "HTML") return;
|
|
87
|
-
|
|
88
|
-
while (
|
|
89
|
-
current &&
|
|
90
|
-
current !== current.ownerDocument?.documentElement &&
|
|
91
|
-
current.parentNode
|
|
92
|
-
) {
|
|
93
|
-
const index = Array.prototype.indexOf.call(
|
|
94
|
-
current.parentNode.childNodes,
|
|
95
|
-
current,
|
|
96
|
-
);
|
|
97
|
-
path.unshift(index);
|
|
98
|
-
current = current.parentNode;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const minimapDoc = iframeRef.current?.contentDocument;
|
|
102
|
-
|
|
103
|
-
if (!minimapDoc) return;
|
|
104
|
-
let correspondingNode: HTMLElement | null = minimapDoc.documentElement;
|
|
105
|
-
let originalNode: HTMLElement | null | undefined =
|
|
106
|
-
mainViewIframeRef.current?.contentWindow?.document.documentElement;
|
|
107
|
-
for (const index of path) {
|
|
108
|
-
if (originalNode && correspondingNode) {
|
|
109
|
-
if (
|
|
110
|
-
originalNode.childNodes.length !== correspondingNode.childNodes.length
|
|
111
|
-
) {
|
|
112
|
-
correspondingNode.innerHTML = originalNode.innerHTML;
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (originalNode) {
|
|
118
|
-
originalNode = originalNode.childNodes[index] as HTMLElement;
|
|
119
|
-
}
|
|
120
|
-
if (correspondingNode) {
|
|
121
|
-
correspondingNode = correspondingNode.childNodes[index] as HTMLElement;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (correspondingNode && originalNode) {
|
|
126
|
-
if (originalNode.tagName === "HEAD")
|
|
127
|
-
correspondingNode.innerHTML = originalNode.innerHTML;
|
|
128
|
-
else {
|
|
129
|
-
correspondingNode.outerHTML = originalNode.outerHTML;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const handleLoad = () => {
|
|
135
|
-
if (!mainViewIframeRef?.current?.contentWindow?.document) return;
|
|
136
|
-
|
|
137
|
-
mirrorIframeContent(editorIframeRef.current!, iframeRef.current!);
|
|
138
|
-
|
|
139
|
-
const observer = new MutationObserver((mutationsList) => {
|
|
140
|
-
const minimapDoc = iframeRef.current?.contentDocument;
|
|
141
|
-
if (!minimapDoc) return;
|
|
142
|
-
|
|
143
|
-
// get distinct list of target nodes
|
|
144
|
-
const targetNodes = mutationsList
|
|
145
|
-
.filter((x) => x.type === "childList" && x.target.parentElement)
|
|
146
|
-
.map((m) => m.target)
|
|
147
|
-
.concat(
|
|
148
|
-
mutationsList
|
|
149
|
-
.filter(
|
|
150
|
-
(x) =>
|
|
151
|
-
x.type === "characterData" ||
|
|
152
|
-
(x.type === "attributes" && x.target.parentElement),
|
|
153
|
-
)
|
|
154
|
-
.map((m) => m.target.parentElement!),
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const distinctTargetNodes = Array.from(new Set(targetNodes));
|
|
158
|
-
|
|
159
|
-
const nodesToRemove = new Set<Node>();
|
|
160
|
-
|
|
161
|
-
for (let i = 0; i < distinctTargetNodes.length; i++) {
|
|
162
|
-
for (let j = 0; j < distinctTargetNodes.length; j++) {
|
|
163
|
-
if (i !== j) {
|
|
164
|
-
if (
|
|
165
|
-
distinctTargetNodes[i]?.contains(distinctTargetNodes[j] as Node)
|
|
166
|
-
) {
|
|
167
|
-
nodesToRemove.add(distinctTargetNodes[j] as Node);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const filteredNodes = distinctTargetNodes.filter(
|
|
174
|
-
(node) => !nodesToRemove.has(node),
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
filteredNodes.forEach((targetNode) => {
|
|
178
|
-
updateCorrespondingNode(targetNode as HTMLElement);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
setRefreshScale((x) => x + 1);
|
|
182
|
-
});
|
|
183
|
-
observer.observe(mainViewIframeRef.current.contentWindow!.document!, {
|
|
184
|
-
childList: true, // observe direct children changes
|
|
185
|
-
subtree: true, // observe all descendants changes
|
|
186
|
-
characterData: true, // observe text changes
|
|
187
|
-
attributes: true, // observe attribute changes (like style or class)
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
setMinimapReady(true);
|
|
191
|
-
observerRef.current = observer;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
if (editorIframeRef?.current) {
|
|
196
|
-
editorIframeRef?.current.addEventListener("load", handleLoad);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
handleLoad();
|
|
200
|
-
|
|
201
|
-
// Cleanup function
|
|
202
|
-
return () => {
|
|
203
|
-
editorIframeRef?.current?.removeEventListener("load", handleLoad);
|
|
204
|
-
};
|
|
205
|
-
}, [mainViewIframeRef.current, iframeRef.current]);
|
|
206
|
-
|
|
207
|
-
useEffect(() => {
|
|
208
|
-
calcAndUpdateScale();
|
|
209
|
-
}, [
|
|
210
|
-
refreshScale,
|
|
211
|
-
editorIframeRef,
|
|
212
|
-
//pageViewContext?.windowSize,
|
|
213
|
-
pageViewContext?.zoom,
|
|
214
|
-
pageViewContext.viewport,
|
|
215
|
-
pageViewContext.deviceHeight,
|
|
216
|
-
pageViewContext.deviceWidth,
|
|
217
|
-
]);
|
|
218
|
-
|
|
219
|
-
if (!editContext) {
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const scrollDocumentTo = (y: number) => {
|
|
224
|
-
if (!editorIframeRef?.current) return;
|
|
225
|
-
|
|
226
|
-
if (!scrollContainer) return;
|
|
227
|
-
|
|
228
|
-
scrollContainer.scrollTo({
|
|
229
|
-
top: y,
|
|
230
|
-
behavior: "smooth",
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const scrollHeight = scrollContainer?.scrollHeight;
|
|
235
|
-
const scrollTop = scroll;
|
|
236
|
-
|
|
237
|
-
const viewport = pageViewContext.viewport;
|
|
238
|
-
|
|
239
|
-
function mirrorIframeContent(
|
|
240
|
-
sourceIframe: HTMLIFrameElement,
|
|
241
|
-
targetIframe: HTMLIFrameElement,
|
|
242
|
-
) {
|
|
243
|
-
if (sourceIframe.contentDocument && targetIframe.contentDocument) {
|
|
244
|
-
const sourceHtml = sourceIframe.contentDocument.documentElement.innerHTML;
|
|
245
|
-
targetIframe.contentDocument.documentElement.innerHTML = sourceHtml;
|
|
246
|
-
targetIframe.contentDocument.documentElement.style.overflow = "hidden";
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
setRefreshScale((x) => x + 1);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const updateScale = (scale: number) => {
|
|
253
|
-
if (!iframeRef.current || !scaleContainerRef.current) return;
|
|
254
|
-
|
|
255
|
-
// console.log(
|
|
256
|
-
// "Update Scale: ScrollHeight: ",
|
|
257
|
-
// scrollContainer?.scrollHeight,
|
|
258
|
-
// " scrollcontainer: ",
|
|
259
|
-
// scrollContainer,
|
|
260
|
-
// );
|
|
261
|
-
|
|
262
|
-
scaleContainerRef.current.style.transform = `scale(${scale})`;
|
|
263
|
-
scaleContainerRef.current.style.transformOrigin = "0 0";
|
|
264
|
-
|
|
265
|
-
iframeRef.current.style.width = `${scrollContainer?.clientWidth}px`;
|
|
266
|
-
iframeRef.current.style.height = `${scrollContainer?.scrollHeight}px`;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const handleClick = (e: React.MouseEvent) => {
|
|
270
|
-
if (!scrollContainer) return;
|
|
271
|
-
const iframeRect = iframeRef.current!.getBoundingClientRect();
|
|
272
|
-
const absY = e.clientY - iframeRect.top;
|
|
273
|
-
const relY = (absY / iframeRect.height) * scrollContainer.scrollHeight;
|
|
274
|
-
|
|
275
|
-
e.stopPropagation();
|
|
276
|
-
scrollDocumentTo(relY - viewport.height / 2);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
const handleScroll = useCallback(
|
|
280
|
-
(e: React.WheelEvent) => {
|
|
281
|
-
if (!scrollContainer) return;
|
|
282
|
-
scrollContainer.scrollBy({
|
|
283
|
-
behavior: "instant",
|
|
284
|
-
left: 0,
|
|
285
|
-
top: e.deltaY,
|
|
286
|
-
});
|
|
287
|
-
editorIframeRef.current?.contentWindow?.document.documentElement?.scrollBy(
|
|
288
|
-
{
|
|
289
|
-
behavior: "instant",
|
|
290
|
-
left: 0,
|
|
291
|
-
top: e.deltaY,
|
|
292
|
-
},
|
|
293
|
-
);
|
|
294
|
-
e.stopPropagation();
|
|
295
|
-
},
|
|
296
|
-
[editorIframeRef],
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
return (
|
|
300
|
-
<div
|
|
301
|
-
className="relative overflow-hidden bg-white"
|
|
302
|
-
ref={minimapContainerRef}
|
|
303
|
-
style={{
|
|
304
|
-
height: "100%",
|
|
305
|
-
width: miniMapWidth + "px",
|
|
306
|
-
boxShadow: "5px 0 5px -5px #333",
|
|
307
|
-
}}
|
|
308
|
-
>
|
|
309
|
-
<div
|
|
310
|
-
className="bg-opacity-50 absolute inset-0 overflow-hidden select-none"
|
|
311
|
-
style={{
|
|
312
|
-
boxShadow: "rgb(200, 200, 200) -10px 1px 13px -10px",
|
|
313
|
-
}}
|
|
314
|
-
>
|
|
315
|
-
<div
|
|
316
|
-
ref={minimapRef}
|
|
317
|
-
onClickCapture={handleClick}
|
|
318
|
-
onDragOverCapture={handleClick}
|
|
319
|
-
onWheelCapture={handleScroll}
|
|
320
|
-
className="h-full w-full cursor-pointer"
|
|
321
|
-
>
|
|
322
|
-
<div ref={scaleContainerRef}>
|
|
323
|
-
<iframe
|
|
324
|
-
className="pointer-events-none"
|
|
325
|
-
ref={iframeRef}
|
|
326
|
-
style={{ visibility: minimapReady ? "visible" : "hidden" }}
|
|
327
|
-
/>
|
|
328
|
-
</div>
|
|
329
|
-
</div>
|
|
330
|
-
</div>
|
|
331
|
-
{scrollTop !== undefined &&
|
|
332
|
-
scrollHeight !== undefined &&
|
|
333
|
-
minimapReady && (
|
|
334
|
-
<div
|
|
335
|
-
className="pointer-events-none absolute w-full bg-gray-300 opacity-60 hover:opacity-65"
|
|
336
|
-
style={{
|
|
337
|
-
top: scrollTop * scale + "px",
|
|
338
|
-
height: viewport.height * scale + "px",
|
|
339
|
-
}}
|
|
340
|
-
></div>
|
|
341
|
-
)}
|
|
342
|
-
{editContext.mode === "edit" && (
|
|
343
|
-
<PlaceholderDropZones
|
|
344
|
-
scale={scale}
|
|
345
|
-
iframe={iframeRef.current}
|
|
346
|
-
size="small"
|
|
347
|
-
/>
|
|
348
|
-
)}
|
|
349
|
-
<FieldEditedIndicators
|
|
350
|
-
scale={scale}
|
|
351
|
-
pageViewContext={pageViewContext}
|
|
352
|
-
scroll={scroll}
|
|
353
|
-
/>
|
|
354
|
-
{editContext.showComments && (
|
|
355
|
-
<CommentHighlightings iframe={iframeRef.current!} scale={scale} />
|
|
356
|
-
)}
|
|
357
|
-
{editContext.showSuggestedEdits && (
|
|
358
|
-
<SuggestionHighlightings iframe={iframeRef.current!} scale={scale} />
|
|
359
|
-
)}
|
|
360
|
-
</div>
|
|
361
|
-
);
|
|
362
|
-
}
|