@alpaca-editor/core 1.0.3762-mono
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +3 -0
- package/dist/client-components/api.js +6 -0
- package/dist/client-components/index.js +36 -0
- package/dist/components/ActionButton.js +9 -0
- package/dist/components/Error.js +28 -0
- package/dist/config/config.js +654 -0
- package/dist/config/types.js +2 -0
- package/dist/editor/ComponentInfo.js +31 -0
- package/dist/editor/ConfirmationDialog.js +32 -0
- package/dist/editor/ContentTree.js +406 -0
- package/dist/editor/ContextMenu.js +117 -0
- package/dist/editor/Editor.js +55 -0
- package/dist/editor/EditorWarning.js +13 -0
- package/dist/editor/EditorWarnings.js +24 -0
- package/dist/editor/FieldEditorPopup.js +24 -0
- package/dist/editor/FieldHistory.js +40 -0
- package/dist/editor/FieldList.js +63 -0
- package/dist/editor/FieldListField.js +164 -0
- package/dist/editor/FieldListFieldWithFallbacks.js +114 -0
- package/dist/editor/FloatingToolbar.js +92 -0
- package/dist/editor/ImageEditor.js +55 -0
- package/dist/editor/InsertMenu.js +164 -0
- package/dist/editor/ItemInfo.js +30 -0
- package/dist/editor/LinkEditorDialog.js +89 -0
- package/dist/editor/MainLayout.js +46 -0
- package/dist/editor/NewEditorClient.js +9 -0
- package/dist/editor/PictureCropper.js +332 -0
- package/dist/editor/PictureEditor.js +104 -0
- package/dist/editor/PictureEditorDialog.js +194 -0
- package/dist/editor/ScrollingContentTree.js +30 -0
- package/dist/editor/Terminal.js +109 -0
- package/dist/editor/Titlebar.js +11 -0
- package/dist/editor/ai/AiPopup.js +25 -0
- package/dist/editor/ai/AiResponseMessage.js +24 -0
- package/dist/editor/ai/AiTerminal.js +241 -0
- package/dist/editor/ai/AiToolCall.js +18 -0
- package/dist/editor/ai/EditorAiTerminal.js +9 -0
- package/dist/editor/ai/editorAiContext.js +14 -0
- package/dist/editor/client/DialogContext.js +29 -0
- package/dist/editor/client/EditorClient.js +1336 -0
- package/dist/editor/client/GenericDialog.js +27 -0
- package/dist/editor/client/editContext.js +59 -0
- package/dist/editor/client/helpers.js +31 -0
- package/dist/editor/client/itemsRepository.js +255 -0
- package/dist/editor/client/operations.js +398 -0
- package/dist/editor/client/pageModelBuilder.js +129 -0
- package/dist/editor/commands/commands.js +2 -0
- package/dist/editor/commands/componentCommands.js +277 -0
- package/dist/editor/commands/createVersionCommand.js +26 -0
- package/dist/editor/commands/deleteVersionCommand.js +55 -0
- package/dist/editor/commands/itemCommands.js +134 -0
- package/dist/editor/commands/localizeItem/LocalizeItemDialog.js +94 -0
- package/dist/editor/commands/undo.js +32 -0
- package/dist/editor/component-designer/ComponentDesigner.js +58 -0
- package/dist/editor/component-designer/ComponentDesignerAiTerminal.js +9 -0
- package/dist/editor/component-designer/ComponentDesignerMenu.js +67 -0
- package/dist/editor/component-designer/ComponentEditor.js +59 -0
- package/dist/editor/component-designer/ComponentRenderingCodeEditor.js +16 -0
- package/dist/editor/component-designer/ComponentRenderingEditor.js +71 -0
- package/dist/editor/component-designer/ComponentsDropdown.js +22 -0
- package/dist/editor/component-designer/PlaceholdersEditor.js +70 -0
- package/dist/editor/component-designer/RenderingsDropdown.js +25 -0
- package/dist/editor/component-designer/TemplateEditor.js +144 -0
- package/dist/editor/component-designer/aiContext.js +18 -0
- package/dist/editor/componentTreeHelper.js +97 -0
- package/dist/editor/control-center/ControlCenterMenu.js +59 -0
- package/dist/editor/control-center/IndexOverview.js +27 -0
- package/dist/editor/control-center/IndexSettings.js +106 -0
- package/dist/editor/control-center/Status.js +7 -0
- package/dist/editor/editor-warnings/ItemLocked.js +40 -0
- package/dist/editor/editor-warnings/NoLanguageWriteAccess.js +16 -0
- package/dist/editor/editor-warnings/NoWorkflowWriteAccess.js +16 -0
- package/dist/editor/editor-warnings/NoWriteAccess.js +14 -0
- package/dist/editor/editor-warnings/ValidationErrors.js +27 -0
- package/dist/editor/field-types/AttachmentEditor.js +7 -0
- package/dist/editor/field-types/CheckboxEditor.js +32 -0
- package/dist/editor/field-types/DropLinkEditor.js +51 -0
- package/dist/editor/field-types/DropListEditor.js +58 -0
- package/dist/editor/field-types/ImageFieldEditor.js +36 -0
- package/dist/editor/field-types/InternalLinkFieldEditor.js +64 -0
- package/dist/editor/field-types/LinkFieldEditor.js +58 -0
- package/dist/editor/field-types/MultiLineText.js +35 -0
- package/dist/editor/field-types/PictureFieldEditor.js +59 -0
- package/dist/editor/field-types/RawEditor.js +33 -0
- package/dist/editor/field-types/ReactQuill.js +366 -0
- package/dist/editor/field-types/RichTextEditor.js +46 -0
- package/dist/editor/field-types/RichTextEditorComponent.js +72 -0
- package/dist/editor/field-types/SingleLineText.js +92 -0
- package/dist/editor/field-types/TreeListEditor.js +137 -0
- package/dist/editor/fieldTypes.js +2 -0
- package/dist/editor/media-selector/AiImageSearch.js +110 -0
- package/dist/editor/media-selector/AiImageSearchPrompt.js +58 -0
- package/dist/editor/media-selector/MediaSelector.js +11 -0
- package/dist/editor/media-selector/Preview.js +9 -0
- package/dist/editor/media-selector/Thumbnails.js +11 -0
- package/dist/editor/media-selector/TreeSelector.js +171 -0
- package/dist/editor/media-selector/UploadZone.js +80 -0
- package/dist/editor/menubar/ActionsMenu.js +33 -0
- package/dist/editor/menubar/ActiveUsers.js +13 -0
- package/dist/editor/menubar/ApproveAndPublish.js +13 -0
- package/dist/editor/menubar/BrowseHistory.js +14 -0
- package/dist/editor/menubar/ItemLanguageVersion.js +36 -0
- package/dist/editor/menubar/LanguageSelector.js +33 -0
- package/dist/editor/menubar/Menu.js +65 -0
- package/dist/editor/menubar/NavButtons.js +43 -0
- package/dist/editor/menubar/PageSelector.js +50 -0
- package/dist/editor/menubar/PageViewerControls.js +37 -0
- package/dist/editor/menubar/Separator.js +8 -0
- package/dist/editor/menubar/SiteInfo.js +26 -0
- package/dist/editor/menubar/User.js +18 -0
- package/dist/editor/menubar/VersionSelector.js +49 -0
- package/dist/editor/page-editor-chrome/CommentHighlighting.js +214 -0
- package/dist/editor/page-editor-chrome/CommentHighlightings.js +17 -0
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +27 -0
- package/dist/editor/page-editor-chrome/FieldActionIndicators.js +15 -0
- package/dist/editor/page-editor-chrome/FieldEditedIndicator.js +27 -0
- package/dist/editor/page-editor-chrome/FieldEditedIndicators.js +15 -0
- package/dist/editor/page-editor-chrome/FrameMenu.js +178 -0
- package/dist/editor/page-editor-chrome/FrameMenus.js +24 -0
- package/dist/editor/page-editor-chrome/InlineEditor.js +101 -0
- package/dist/editor/page-editor-chrome/LockedFieldIndicator.js +35 -0
- package/dist/editor/page-editor-chrome/NoLayout.js +21 -0
- package/dist/editor/page-editor-chrome/PageEditorChrome.js +65 -0
- package/dist/editor/page-editor-chrome/PictureEditorOverlay.js +109 -0
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +82 -0
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.js +147 -0
- package/dist/editor/page-viewer/DeviceToolbar.js +21 -0
- package/dist/editor/page-viewer/EditorForm.js +130 -0
- package/dist/editor/page-viewer/MiniMap.js +257 -0
- package/dist/editor/page-viewer/PageViewer.js +64 -0
- package/dist/editor/page-viewer/PageViewerFrame.js +696 -0
- package/dist/editor/page-viewer/pageViewContext.js +117 -0
- package/dist/editor/pageModel.js +2 -0
- package/dist/editor/picture-shared.js +28 -0
- package/dist/editor/reviews/Comment.js +112 -0
- package/dist/editor/reviews/Comments.js +24 -0
- package/dist/editor/reviews/PreviewInfo.js +13 -0
- package/dist/editor/reviews/Reviews.js +165 -0
- package/dist/editor/reviews/reviewCommands.js +44 -0
- package/dist/editor/reviews/useReviews.js +48 -0
- package/dist/editor/services/aiService.js +99 -0
- package/dist/editor/services/componentDesignerService.js +79 -0
- package/dist/editor/services/contentService.js +104 -0
- package/dist/editor/services/editService.js +322 -0
- package/dist/editor/services/indexService.js +25 -0
- package/dist/editor/services/reviewsService.js +43 -0
- package/dist/editor/services/serviceHelper.js +67 -0
- package/dist/editor/services/systemService.js +7 -0
- package/dist/editor/services/translationService.js +15 -0
- package/dist/editor/services-server/api.js +119 -0
- package/dist/editor/services-server/graphQL.js +56 -0
- package/dist/editor/sidebar/ComponentPalette.js +55 -0
- package/dist/editor/sidebar/ComponentTree.js +362 -0
- package/dist/editor/sidebar/Debug.js +60 -0
- package/dist/editor/sidebar/DictionaryEditor.js +160 -0
- package/dist/editor/sidebar/EditHistory.js +74 -0
- package/dist/editor/sidebar/GraphQL.js +115 -0
- package/dist/editor/sidebar/Insert.js +24 -0
- package/dist/editor/sidebar/MainContentTree.js +52 -0
- package/dist/editor/sidebar/Performance.js +34 -0
- package/dist/editor/sidebar/Sessions.js +31 -0
- package/dist/editor/sidebar/Sidebar.js +15 -0
- package/dist/editor/sidebar/SidebarView.js +76 -0
- package/dist/editor/sidebar/Translations.js +160 -0
- package/dist/editor/sidebar/Validation.js +52 -0
- package/dist/editor/sidebar/ViewSelector.js +15 -0
- package/dist/editor/sidebar/Workbox.js +80 -0
- package/dist/editor/ui/CenteredMessage.js +7 -0
- package/dist/editor/ui/CopyToClipboardButton.js +17 -0
- package/dist/editor/ui/DialogButtons.js +7 -0
- package/dist/editor/ui/Icons.js +75 -0
- package/dist/editor/ui/ItemNameDialog.js +45 -0
- package/dist/editor/ui/ItemNameDialogNew.js +61 -0
- package/dist/editor/ui/ItemSearch.js +93 -0
- package/dist/editor/ui/PerfectTree.js +223 -0
- package/dist/editor/ui/Section.js +12 -0
- package/dist/editor/ui/SimpleIconButton.js +11 -0
- package/dist/editor/ui/SimpleMenu.js +9 -0
- package/dist/editor/ui/SimpleTable.js +11 -0
- package/dist/editor/ui/SimpleTabs.js +21 -0
- package/dist/editor/ui/SimpleToolbar.js +7 -0
- package/dist/editor/ui/Spinner.js +7 -0
- package/dist/editor/ui/Splitter.js +187 -0
- package/dist/editor/ui/StackedPanels.js +69 -0
- package/dist/editor/ui/Toolbar.js +7 -0
- package/dist/editor/utils/id-helper.js +7 -0
- package/dist/editor/utils/insertOptions.js +45 -0
- package/dist/editor/utils/itemutils.js +25 -0
- package/dist/editor/utils/useMemoDebug.js +20 -0
- package/dist/editor/utils.js +328 -0
- package/dist/editor/views/CompareView.js +147 -0
- package/dist/editor/views/EditView.js +17 -0
- package/dist/editor/views/ItemEditor.js +24 -0
- package/dist/editor/views/SingleEditView.js +25 -0
- package/dist/index.js +22 -0
- package/dist/page-wizard/PageWizard.js +62 -0
- package/dist/page-wizard/SelectWizard.js +43 -0
- package/dist/page-wizard/WizardSteps.js +71 -0
- package/dist/page-wizard/service.js +26 -0
- package/dist/page-wizard/startPageWizardCommand.js +23 -0
- package/dist/page-wizard/steps/BuildPageStep.js +138 -0
- package/dist/page-wizard/steps/CollectStep.js +124 -0
- package/dist/page-wizard/steps/ComponentTypesSelector.js +211 -0
- package/dist/page-wizard/steps/Components.js +94 -0
- package/dist/page-wizard/steps/CreatePage.js +142 -0
- package/dist/page-wizard/steps/CreatePageAndLayoutStep.js +230 -0
- package/dist/page-wizard/steps/EditButton.js +7 -0
- package/dist/page-wizard/steps/FieldEditor.js +30 -0
- package/dist/page-wizard/steps/Generate.js +11 -0
- package/dist/page-wizard/steps/ImagesStep.js +159 -0
- package/dist/page-wizard/steps/LayoutStep.js +120 -0
- package/dist/page-wizard/steps/SelectStep.js +150 -0
- package/dist/page-wizard/steps/schema.js +140 -0
- package/dist/page-wizard/steps/usePageCreator.js +194 -0
- package/dist/splash-screen/NewPage.js +131 -0
- package/dist/splash-screen/SectionHeadline.js +9 -0
- package/dist/splash-screen/SplashScreen.js +81 -0
- package/dist/tour/Tour.js +321 -0
- package/dist/tour/default-tour.js +231 -0
- package/dist/tour/preview-tour.js +93 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types.js +2 -0
- package/eslint.config.mjs +4 -0
- package/images/bg-shape-black.webp +0 -0
- package/package.json +52 -0
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +43 -0
- package/src/components/Error.tsx +57 -0
- package/src/config/config.tsx +737 -0
- package/src/config/types.ts +263 -0
- package/src/editor/ComponentInfo.tsx +77 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +654 -0
- package/src/editor/ContextMenu.tsx +155 -0
- package/src/editor/Editor.tsx +91 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +74 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +387 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +211 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +129 -0
- package/src/editor/InsertMenu.tsx +332 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +192 -0
- package/src/editor/MainLayout.tsx +94 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +505 -0
- package/src/editor/PictureEditor.tsx +206 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +47 -0
- package/src/editor/Terminal.tsx +215 -0
- package/src/editor/Titlebar.tsx +23 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +82 -0
- package/src/editor/ai/AiTerminal.tsx +450 -0
- package/src/editor/ai/AiToolCall.tsx +46 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/DialogContext.tsx +49 -0
- package/src/editor/client/EditorClient.tsx +1831 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +330 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +391 -0
- package/src/editor/client/operations.ts +610 -0
- package/src/editor/client/pageModelBuilder.ts +182 -0
- package/src/editor/commands/commands.ts +23 -0
- package/src/editor/commands/componentCommands.tsx +408 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +186 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -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 +183 -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 +114 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +71 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Status.tsx +7 -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 +15 -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 +75 -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 +112 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +63 -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 +108 -0
- package/src/editor/field-types/SingleLineText.tsx +150 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +186 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +95 -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/menubar/ActionsMenu.tsx +47 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +37 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +52 -0
- package/src/editor/menubar/LanguageSelector.tsx +152 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +139 -0
- package/src/editor/menubar/PageViewerControls.tsx +99 -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 +143 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +287 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +44 -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 +263 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +147 -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 +119 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +154 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +171 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +233 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +247 -0
- package/src/editor/page-viewer/MiniMap.tsx +351 -0
- package/src/editor/page-viewer/PageViewer.tsx +127 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1030 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +191 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +265 -0
- package/src/editor/reviews/Comments.tsx +50 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +155 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +159 -0
- package/src/editor/services/editService.ts +462 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +45 -0
- package/src/editor/services/serviceHelper.ts +95 -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 +146 -0
- package/src/editor/sidebar/ComponentTree.tsx +512 -0
- package/src/editor/sidebar/ComponentTree2.tsxx +490 -0
- package/src/editor/sidebar/Debug.tsx +105 -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 +95 -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 +150 -0
- package/src/editor/sidebar/Translations.tsx +276 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +49 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +23 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +585 -0
- package/src/editor/ui/ItemNameDialog.tsx +94 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +173 -0
- package/src/editor/ui/PerfectTree.tsx +550 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +43 -0
- package/src/editor/ui/SimpleMenu.tsx +48 -0
- package/src/editor/ui/SimpleTable.tsx +63 -0
- package/src/editor/ui/SimpleTabs.tsx +55 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +7 -0
- package/src/editor/ui/Splitter.tsx +247 -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 +435 -0
- package/src/editor/views/CompareView.tsx +256 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/SingleEditView.tsx +44 -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/index.ts +7 -0
- package/src/page-wizard/PageWizard.tsx +163 -0
- package/src/page-wizard/SelectWizard.tsx +109 -0
- package/src/page-wizard/WizardSteps.tsx +207 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +27 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +266 -0
- package/src/page-wizard/steps/CollectStep.tsx +233 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +443 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/CreatePage.tsx +285 -0
- package/src/page-wizard/steps/CreatePageAndLayoutStep.tsx +384 -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 +32 -0
- package/src/page-wizard/steps/ImagesStep.tsx +318 -0
- package/src/page-wizard/steps/LayoutStep.tsx +228 -0
- package/src/page-wizard/steps/SelectStep.tsx +256 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +279 -0
- package/src/splash-screen/NewPage.tsx +232 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +156 -0
- package/src/tour/Tour.tsx +558 -0
- package/src/tour/default-tour.tsx +300 -0
- package/src/tour/preview-tour.tsx +127 -0
- package/src/types.ts +302 -0
- package/styles.css +476 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
/*
|
|
2
|
+
React-Quill
|
|
3
|
+
https://github.com/zenoamaro/react-quill
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from "react";
|
|
7
|
+
import isEqual from "lodash/isEqual";
|
|
8
|
+
|
|
9
|
+
import Quill, {
|
|
10
|
+
type EmitterSource,
|
|
11
|
+
type Range as RangeStatic,
|
|
12
|
+
QuillOptions as QuillOptionsStatic,
|
|
13
|
+
} from "quill";
|
|
14
|
+
import type DeltaStatic from "quill-delta";
|
|
15
|
+
|
|
16
|
+
// Merged namespace hack to export types along with default object
|
|
17
|
+
// See: https://github.com/Microsoft/TypeScript/issues/2719
|
|
18
|
+
namespace ReactQuill {
|
|
19
|
+
export type Value = string | DeltaStatic;
|
|
20
|
+
export type Range = RangeStatic | null;
|
|
21
|
+
|
|
22
|
+
export interface QuillOptions extends QuillOptionsStatic {
|
|
23
|
+
scrollingContainer?: HTMLElement | string | undefined;
|
|
24
|
+
strict?: boolean | undefined;
|
|
25
|
+
tabIndex?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ReactQuillProps {
|
|
29
|
+
bounds?: string | HTMLElement;
|
|
30
|
+
children?: React.ReactElement<any>;
|
|
31
|
+
className?: string;
|
|
32
|
+
defaultValue?: Value;
|
|
33
|
+
formats?: string[];
|
|
34
|
+
id?: string;
|
|
35
|
+
modules?: QuillOptions["modules"];
|
|
36
|
+
onChange?(
|
|
37
|
+
value: string,
|
|
38
|
+
delta: DeltaStatic,
|
|
39
|
+
source: EmitterSource,
|
|
40
|
+
editor: UnprivilegedEditor
|
|
41
|
+
): void;
|
|
42
|
+
onChangeSelection?(
|
|
43
|
+
selection: Range,
|
|
44
|
+
source: EmitterSource,
|
|
45
|
+
editor: UnprivilegedEditor
|
|
46
|
+
): void;
|
|
47
|
+
onFocus?(
|
|
48
|
+
selection: Range,
|
|
49
|
+
source: EmitterSource,
|
|
50
|
+
editor: UnprivilegedEditor
|
|
51
|
+
): void;
|
|
52
|
+
onBlur?(
|
|
53
|
+
previousSelection: Range,
|
|
54
|
+
source: EmitterSource,
|
|
55
|
+
editor: UnprivilegedEditor
|
|
56
|
+
): void;
|
|
57
|
+
onKeyDown?: React.EventHandler<any>;
|
|
58
|
+
onKeyPress?: React.EventHandler<any>;
|
|
59
|
+
onKeyUp?: React.EventHandler<any>;
|
|
60
|
+
placeholder?: string;
|
|
61
|
+
preserveWhitespace?: boolean;
|
|
62
|
+
readOnly?: boolean;
|
|
63
|
+
scrollingContainer?: string | HTMLElement;
|
|
64
|
+
style?: React.CSSProperties;
|
|
65
|
+
tabIndex?: number;
|
|
66
|
+
theme?: string;
|
|
67
|
+
value?: Value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface UnprivilegedEditor {
|
|
71
|
+
getLength: Quill["getLength"];
|
|
72
|
+
getText: Quill["getText"];
|
|
73
|
+
getHTML: Quill["getSemanticHTML"];
|
|
74
|
+
getBounds: Quill["getBounds"];
|
|
75
|
+
getSelection: Quill["getSelection"];
|
|
76
|
+
getContents: Quill["getContents"];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Re-import everything from namespace into scope for comfort
|
|
81
|
+
import Value = ReactQuill.Value;
|
|
82
|
+
import Range = ReactQuill.Range;
|
|
83
|
+
import QuillOptions = ReactQuill.QuillOptions;
|
|
84
|
+
import ReactQuillProps = ReactQuill.ReactQuillProps;
|
|
85
|
+
import UnprivilegedEditor = ReactQuill.UnprivilegedEditor;
|
|
86
|
+
|
|
87
|
+
interface ReactQuillState {
|
|
88
|
+
generation: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class ReactQuill extends React.Component<
|
|
92
|
+
ReactQuillProps,
|
|
93
|
+
ReactQuillState
|
|
94
|
+
> {
|
|
95
|
+
static displayName = "React Quill";
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
Export Quill to be able to call `register`
|
|
99
|
+
*/
|
|
100
|
+
static Quill = Quill;
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
Changing one of these props should cause a full re-render and a
|
|
104
|
+
re-instantiation of the Quill editor.
|
|
105
|
+
*/
|
|
106
|
+
dirtyProps: (keyof ReactQuillProps)[] = [
|
|
107
|
+
"modules",
|
|
108
|
+
"formats",
|
|
109
|
+
"bounds",
|
|
110
|
+
"theme",
|
|
111
|
+
"children",
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
Changing one of these props should cause a regular update. These are mostly
|
|
116
|
+
props that act on the container, rather than the quillized editing area.
|
|
117
|
+
*/
|
|
118
|
+
cleanProps: (keyof ReactQuillProps)[] = [
|
|
119
|
+
"id",
|
|
120
|
+
"className",
|
|
121
|
+
"style",
|
|
122
|
+
"placeholder",
|
|
123
|
+
"tabIndex",
|
|
124
|
+
"onChange",
|
|
125
|
+
"onChangeSelection",
|
|
126
|
+
"onFocus",
|
|
127
|
+
"onBlur",
|
|
128
|
+
"onKeyPress",
|
|
129
|
+
"onKeyDown",
|
|
130
|
+
"onKeyUp",
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
static defaultProps = {
|
|
134
|
+
theme: "snow",
|
|
135
|
+
modules: {},
|
|
136
|
+
readOnly: false,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
state: ReactQuillState = {
|
|
140
|
+
generation: 0,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
The Quill Editor instance.
|
|
145
|
+
*/
|
|
146
|
+
editor?: Quill;
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
Reference to the element holding the Quill editing area.
|
|
150
|
+
*/
|
|
151
|
+
editingArea?: React.ReactInstance | null;
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
Tracks the internal value of the Quill editor
|
|
155
|
+
*/
|
|
156
|
+
value: Value;
|
|
157
|
+
|
|
158
|
+
/*
|
|
159
|
+
Tracks the internal selection of the Quill editor
|
|
160
|
+
*/
|
|
161
|
+
selection: Range = null;
|
|
162
|
+
|
|
163
|
+
/*
|
|
164
|
+
Used to compare whether deltas from `onChange` are being used as `value`.
|
|
165
|
+
*/
|
|
166
|
+
lastDeltaChangeSet?: DeltaStatic;
|
|
167
|
+
|
|
168
|
+
/*
|
|
169
|
+
Stores the contents of the editor to be restored after regeneration.
|
|
170
|
+
*/
|
|
171
|
+
regenerationSnapshot?: {
|
|
172
|
+
delta: DeltaStatic;
|
|
173
|
+
selection: Range;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
A weaker, unprivileged proxy for the editor that does not allow accidentally
|
|
178
|
+
modifying editor state.
|
|
179
|
+
*/
|
|
180
|
+
unprivilegedEditor?: UnprivilegedEditor;
|
|
181
|
+
|
|
182
|
+
private editingAreaRef = React.createRef<HTMLDivElement | HTMLPreElement>();
|
|
183
|
+
|
|
184
|
+
constructor(props: ReactQuillProps) {
|
|
185
|
+
super(props);
|
|
186
|
+
const value = this.isControlled() ? props.value : props.defaultValue;
|
|
187
|
+
this.value = value ?? "";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
validateProps(props: ReactQuillProps): void {
|
|
191
|
+
if (React.Children.count(props.children) > 1)
|
|
192
|
+
throw new Error(
|
|
193
|
+
"The Quill editing area can only be composed of a single React element."
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
if (React.Children.count(props.children)) {
|
|
197
|
+
const child = React.Children.only(props.children);
|
|
198
|
+
if (child?.type === "textarea")
|
|
199
|
+
throw new Error(
|
|
200
|
+
"Quill does not support editing on a <textarea>. Use a <div> instead."
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (this.lastDeltaChangeSet && props.value === this.lastDeltaChangeSet)
|
|
205
|
+
throw new Error(
|
|
206
|
+
"You are passing the `delta` object from the `onChange` event back " +
|
|
207
|
+
"as `value`. You most probably want `editor.getContents()` instead. " +
|
|
208
|
+
"See: https://github.com/zenoamaro/react-quill#using-deltas"
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
shouldComponentUpdate(
|
|
213
|
+
nextProps: ReactQuillProps,
|
|
214
|
+
nextState: ReactQuillState
|
|
215
|
+
) {
|
|
216
|
+
this.validateProps(nextProps);
|
|
217
|
+
|
|
218
|
+
// If the editor hasn't been instantiated yet, or the component has been
|
|
219
|
+
// regenerated, we already know we should update.
|
|
220
|
+
if (!this.editor || this.state.generation !== nextState.generation) {
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Handle value changes in-place
|
|
225
|
+
if ("value" in nextProps) {
|
|
226
|
+
const prevContents = this.getEditorContents();
|
|
227
|
+
const nextContents = nextProps.value ?? "";
|
|
228
|
+
|
|
229
|
+
// NOTE: Seeing that Quill is missing a way to prevent edits, we have to
|
|
230
|
+
// settle for a hybrid between controlled and uncontrolled mode. We
|
|
231
|
+
// can't prevent the change, but we'll still override content
|
|
232
|
+
// whenever `value` differs from current state.
|
|
233
|
+
// NOTE: Comparing an HTML string and a Quill Delta will always trigger a
|
|
234
|
+
// change, regardless of whether they represent the same document.
|
|
235
|
+
if (!this.isEqualValue(nextContents, prevContents)) {
|
|
236
|
+
this.setEditorContents(this.editor, nextContents);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Handle read-only changes in-place
|
|
241
|
+
if (nextProps.readOnly !== this.props.readOnly) {
|
|
242
|
+
this.setEditorReadOnly(this.editor, nextProps.readOnly!);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Clean and Dirty props require a render
|
|
246
|
+
return [...this.cleanProps, ...this.dirtyProps].some((prop) => {
|
|
247
|
+
return !isEqual(nextProps[prop], this.props[prop]);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
shouldComponentRegenerate(nextProps: ReactQuillProps): boolean {
|
|
252
|
+
// Whenever a `dirtyProp` changes, the editor needs reinstantiation.
|
|
253
|
+
return this.dirtyProps.some((prop) => {
|
|
254
|
+
return !isEqual(nextProps[prop], this.props[prop]);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
componentDidMount() {
|
|
259
|
+
this.instantiateEditor();
|
|
260
|
+
this.setEditorContents(this.editor!, this.getEditorContents());
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
componentWillUnmount() {
|
|
264
|
+
this.destroyEditor();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
componentDidUpdate(prevProps: ReactQuillProps, prevState: ReactQuillState) {
|
|
268
|
+
// If we're changing one of the `dirtyProps`, the entire Quill Editor needs
|
|
269
|
+
// to be re-instantiated. Regenerating the editor will cause the whole tree,
|
|
270
|
+
// including the container, to be cleaned up and re-rendered from scratch.
|
|
271
|
+
// Store the contents so they can be restored later.
|
|
272
|
+
if (this.editor && this.shouldComponentRegenerate(prevProps)) {
|
|
273
|
+
const delta = this.editor.getContents();
|
|
274
|
+
const selection = this.editor.getSelection();
|
|
275
|
+
this.regenerationSnapshot = { delta, selection };
|
|
276
|
+
this.setState({ generation: this.state.generation + 1 });
|
|
277
|
+
this.destroyEditor();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// The component has been regenerated, so it must be re-instantiated, and
|
|
281
|
+
// its content must be restored to the previous values from the snapshot.
|
|
282
|
+
if (this.state.generation !== prevState.generation) {
|
|
283
|
+
const { delta, selection } = this.regenerationSnapshot!;
|
|
284
|
+
delete this.regenerationSnapshot;
|
|
285
|
+
this.instantiateEditor();
|
|
286
|
+
const editor = this.editor!;
|
|
287
|
+
editor.setContents(delta);
|
|
288
|
+
postpone(() => this.setEditorSelection(editor, selection));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
instantiateEditor(): void {
|
|
293
|
+
if (this.editor) {
|
|
294
|
+
this.hookEditor(this.editor);
|
|
295
|
+
} else {
|
|
296
|
+
this.editor = this.createEditor(
|
|
297
|
+
this.getEditingArea(),
|
|
298
|
+
this.getEditorConfig()
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
destroyEditor(): void {
|
|
304
|
+
if (!this.editor) return;
|
|
305
|
+
this.unhookEditor(this.editor);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/*
|
|
309
|
+
We consider the component to be controlled if `value` is being sent in props.
|
|
310
|
+
*/
|
|
311
|
+
isControlled(): boolean {
|
|
312
|
+
return "value" in this.props;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
getEditorConfig(): QuillOptions {
|
|
316
|
+
return {
|
|
317
|
+
bounds: this.props.bounds,
|
|
318
|
+
formats: this.props.formats,
|
|
319
|
+
modules: this.props.modules,
|
|
320
|
+
placeholder: this.props.placeholder,
|
|
321
|
+
readOnly: this.props.readOnly,
|
|
322
|
+
scrollingContainer: this.props.scrollingContainer,
|
|
323
|
+
tabIndex: this.props.tabIndex,
|
|
324
|
+
theme: this.props.theme,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
getEditor(): Quill {
|
|
329
|
+
if (!this.editor) throw new Error("Accessing non-instantiated editor");
|
|
330
|
+
return this.editor;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
Creates an editor on the given element. The editor will be passed the
|
|
335
|
+
configuration, have its events bound,
|
|
336
|
+
*/
|
|
337
|
+
createEditor(element: HTMLElement, config: QuillOptions) {
|
|
338
|
+
const editor = new Quill(element, config);
|
|
339
|
+
if (config.tabIndex != null) {
|
|
340
|
+
this.setEditorTabIndex(editor, config.tabIndex);
|
|
341
|
+
}
|
|
342
|
+
this.hookEditor(editor);
|
|
343
|
+
return editor;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
hookEditor(editor: Quill) {
|
|
347
|
+
// Expose the editor on change events via a weaker, unprivileged proxy
|
|
348
|
+
// object that does not allow accidentally modifying editor state.
|
|
349
|
+
this.unprivilegedEditor = this.makeUnprivilegedEditor(editor);
|
|
350
|
+
// Using `editor-change` allows picking up silent updates, like selection
|
|
351
|
+
// changes on typing.
|
|
352
|
+
editor.on("editor-change", this.onEditorChange);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
unhookEditor(editor: Quill) {
|
|
356
|
+
editor.off("editor-change", this.onEditorChange);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
getEditorContents(): Value {
|
|
360
|
+
return this.value;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
getEditorSelection(): Range {
|
|
364
|
+
return this.selection;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/*
|
|
368
|
+
True if the value is a Delta instance or a Delta look-alike.
|
|
369
|
+
*/
|
|
370
|
+
isDelta(value: any): boolean {
|
|
371
|
+
return value && value.ops;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/*
|
|
375
|
+
Special comparison function that knows how to compare Deltas.
|
|
376
|
+
*/
|
|
377
|
+
isEqualValue(value: any, nextValue: any): boolean {
|
|
378
|
+
if (this.isDelta(value) && this.isDelta(nextValue)) {
|
|
379
|
+
return isEqual(value.ops, nextValue.ops);
|
|
380
|
+
} else {
|
|
381
|
+
return isEqual(value, nextValue);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/*
|
|
386
|
+
Replace the contents of the editor, but keep the previous selection hanging
|
|
387
|
+
around so that the cursor won't move.
|
|
388
|
+
*/
|
|
389
|
+
setEditorContents(editor: Quill, value: Value) {
|
|
390
|
+
this.value = value;
|
|
391
|
+
|
|
392
|
+
//const sel = this.getEditorSelection();
|
|
393
|
+
if (typeof value === "string") {
|
|
394
|
+
editor.setContents(editor.clipboard.convert({ html: value }));
|
|
395
|
+
} else {
|
|
396
|
+
editor.setContents(value);
|
|
397
|
+
}
|
|
398
|
+
// THIS STEALS FOCUS!
|
|
399
|
+
// postpone(() => this.setEditorSelection(editor, sel));
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
setEditorSelection(editor: Quill, range: Range) {
|
|
403
|
+
this.selection = range;
|
|
404
|
+
if (range) {
|
|
405
|
+
// Validate bounds before applying.
|
|
406
|
+
const length = editor.getLength();
|
|
407
|
+
range.index = Math.max(0, Math.min(range.index, length - 1));
|
|
408
|
+
range.length = Math.max(
|
|
409
|
+
0,
|
|
410
|
+
Math.min(range.length, length - 1 - range.index)
|
|
411
|
+
);
|
|
412
|
+
editor.setSelection(range);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
setEditorTabIndex(editor: Quill, tabIndex: number) {
|
|
417
|
+
if (editor?.scroll?.domNode) {
|
|
418
|
+
(editor.scroll.domNode as HTMLElement).tabIndex = tabIndex;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
setEditorReadOnly(editor: Quill, value: boolean) {
|
|
423
|
+
if (value) {
|
|
424
|
+
editor.disable();
|
|
425
|
+
} else {
|
|
426
|
+
editor.enable();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/*
|
|
431
|
+
Returns a weaker, unprivileged proxy object that only exposes read-only
|
|
432
|
+
accessors found on the editor instance, without any state-modifying methods.
|
|
433
|
+
*/
|
|
434
|
+
makeUnprivilegedEditor(editor: Quill) {
|
|
435
|
+
const e = editor;
|
|
436
|
+
return {
|
|
437
|
+
getHTML: () => e.root.innerHTML,
|
|
438
|
+
getLength: e.getLength.bind(e),
|
|
439
|
+
getText: e.getText.bind(e),
|
|
440
|
+
getContents: e.getContents.bind(e),
|
|
441
|
+
getSelection: e.getSelection.bind(e),
|
|
442
|
+
getBounds: e.getBounds.bind(e),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
getEditingArea(): HTMLElement {
|
|
447
|
+
if (!this.editingAreaRef.current) {
|
|
448
|
+
throw new Error("Editing area is not available");
|
|
449
|
+
}
|
|
450
|
+
return this.editingAreaRef.current;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/*
|
|
454
|
+
Renders an editor area, unless it has been provided one to clone.
|
|
455
|
+
*/
|
|
456
|
+
renderEditingArea(): React.ReactNode {
|
|
457
|
+
const { children, preserveWhitespace } = this.props;
|
|
458
|
+
const { generation } = this.state;
|
|
459
|
+
|
|
460
|
+
if (React.Children.count(children)) {
|
|
461
|
+
return React.cloneElement(React.Children.only(children)!, {
|
|
462
|
+
ref: this.editingAreaRef,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return preserveWhitespace ? (
|
|
467
|
+
<pre
|
|
468
|
+
ref={this.editingAreaRef as React.LegacyRef<HTMLPreElement>}
|
|
469
|
+
key={generation}
|
|
470
|
+
/>
|
|
471
|
+
) : (
|
|
472
|
+
<div
|
|
473
|
+
ref={this.editingAreaRef as React.LegacyRef<HTMLDivElement>}
|
|
474
|
+
key={generation}
|
|
475
|
+
/>
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
render() {
|
|
480
|
+
return (
|
|
481
|
+
<div
|
|
482
|
+
id={this.props.id}
|
|
483
|
+
style={this.props.style}
|
|
484
|
+
key={this.state.generation}
|
|
485
|
+
className={`quill ${this.props.className ?? ""}`}
|
|
486
|
+
onKeyPress={this.props.onKeyPress}
|
|
487
|
+
onKeyDownCapture={this.props.onKeyDown}
|
|
488
|
+
onKeyUp={this.props.onKeyUp}
|
|
489
|
+
>
|
|
490
|
+
{this.renderEditingArea()}
|
|
491
|
+
</div>
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
onEditorChange = (
|
|
496
|
+
eventName: "text-change" | "selection-change",
|
|
497
|
+
rangeOrDelta: Range | DeltaStatic,
|
|
498
|
+
//oldRangeOrDelta: Range | DeltaStatic,
|
|
499
|
+
source: EmitterSource
|
|
500
|
+
) => {
|
|
501
|
+
if (eventName === "text-change") {
|
|
502
|
+
this.onEditorChangeText?.(
|
|
503
|
+
this.editor!.root.innerHTML,
|
|
504
|
+
rangeOrDelta as DeltaStatic,
|
|
505
|
+
source,
|
|
506
|
+
this.unprivilegedEditor!
|
|
507
|
+
);
|
|
508
|
+
} else if (eventName === "selection-change") {
|
|
509
|
+
this.onEditorChangeSelection?.(
|
|
510
|
+
rangeOrDelta as RangeStatic,
|
|
511
|
+
source,
|
|
512
|
+
this.unprivilegedEditor!
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
onEditorChangeText(
|
|
518
|
+
value: string,
|
|
519
|
+
delta: DeltaStatic,
|
|
520
|
+
source: EmitterSource,
|
|
521
|
+
editor: UnprivilegedEditor
|
|
522
|
+
): void {
|
|
523
|
+
if (!this.editor) return;
|
|
524
|
+
|
|
525
|
+
// We keep storing the same type of value as what the user gives us,
|
|
526
|
+
// so that value comparisons will be more stable and predictable.
|
|
527
|
+
const nextContents = this.isDelta(this.value)
|
|
528
|
+
? editor.getContents()
|
|
529
|
+
: editor.getHTML();
|
|
530
|
+
|
|
531
|
+
if (nextContents !== this.getEditorContents()) {
|
|
532
|
+
// Taint this `delta` object, so we can recognize whether the user
|
|
533
|
+
// is trying to send it back as `value`, preventing a likely loop.
|
|
534
|
+
this.lastDeltaChangeSet = delta;
|
|
535
|
+
|
|
536
|
+
this.value = nextContents;
|
|
537
|
+
this.props.onChange?.(value, delta, source, editor);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
onEditorChangeSelection(
|
|
542
|
+
nextSelection: RangeStatic,
|
|
543
|
+
source: EmitterSource,
|
|
544
|
+
editor: UnprivilegedEditor
|
|
545
|
+
): void {
|
|
546
|
+
if (!this.editor) return;
|
|
547
|
+
const currentSelection = this.getEditorSelection();
|
|
548
|
+
const hasGainedFocus = !currentSelection && nextSelection;
|
|
549
|
+
const hasLostFocus = currentSelection && !nextSelection;
|
|
550
|
+
|
|
551
|
+
if (isEqual(nextSelection, currentSelection)) return;
|
|
552
|
+
|
|
553
|
+
this.selection = nextSelection;
|
|
554
|
+
this.props.onChangeSelection?.(nextSelection, source, editor);
|
|
555
|
+
|
|
556
|
+
if (hasGainedFocus) {
|
|
557
|
+
this.props.onFocus?.(nextSelection, source, editor);
|
|
558
|
+
} else if (hasLostFocus) {
|
|
559
|
+
this.props.onBlur?.(currentSelection, source, editor);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
focus(): void {
|
|
564
|
+
if (!this.editor) return;
|
|
565
|
+
this.editor.focus();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
blur(): void {
|
|
569
|
+
if (!this.editor) return;
|
|
570
|
+
this.selection = null;
|
|
571
|
+
this.editor.blur();
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/*
|
|
576
|
+
Small helper to execute a function in the next micro-tick.
|
|
577
|
+
*/
|
|
578
|
+
function postpone(fn: (value: void) => void) {
|
|
579
|
+
Promise.resolve().then(fn);
|
|
580
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import dynamic from "next/dynamic";
|
|
4
|
+
import { Field } from "../pageModel";
|
|
5
|
+
|
|
6
|
+
const RichTextEditorComponent = dynamic(
|
|
7
|
+
() =>
|
|
8
|
+
import("./RichTextEditorComponent").then(
|
|
9
|
+
(dnd) => dnd.RichTextEditorComponent
|
|
10
|
+
),
|
|
11
|
+
{ ssr: false }
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export function RichTextEditor({
|
|
15
|
+
field,
|
|
16
|
+
readOnly,
|
|
17
|
+
}: {
|
|
18
|
+
field: Field;
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
}) {
|
|
21
|
+
return <RichTextEditorComponent field={field} readOnly={readOnly} />;
|
|
22
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useEditContextRef,
|
|
5
|
+
useModifiedFieldsContext,
|
|
6
|
+
} from "../client/editContext";
|
|
7
|
+
|
|
8
|
+
import { useThrottledCallback } from "use-debounce";
|
|
9
|
+
import { useEffect, useRef, useState } from "react";
|
|
10
|
+
|
|
11
|
+
import { ReactQuill } from "./ReactQuill";
|
|
12
|
+
import "react-quill-new/dist/quill.snow.css";
|
|
13
|
+
import { classNames } from "primereact/utils";
|
|
14
|
+
import { Field } from "../pageModel";
|
|
15
|
+
|
|
16
|
+
export function RichTextEditorComponent({
|
|
17
|
+
field,
|
|
18
|
+
readOnly,
|
|
19
|
+
}: {
|
|
20
|
+
field: Field;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
}) {
|
|
23
|
+
const editContextRef = useEditContextRef();
|
|
24
|
+
const modifiedFieldsContext = useModifiedFieldsContext();
|
|
25
|
+
|
|
26
|
+
const state = useRef({ focus: false });
|
|
27
|
+
const inputRef = useRef<ReactQuill>(null);
|
|
28
|
+
|
|
29
|
+
if (!editContextRef.current) return;
|
|
30
|
+
|
|
31
|
+
const [value, setValue] = useState(field.value as string);
|
|
32
|
+
const fieldItem = field.descriptor.item;
|
|
33
|
+
|
|
34
|
+
if (!fieldItem) return;
|
|
35
|
+
|
|
36
|
+
const modifiedField = modifiedFieldsContext?.modifiedFields.find(
|
|
37
|
+
(x) =>
|
|
38
|
+
x.fieldId === field.id &&
|
|
39
|
+
x.item.id === fieldItem.id &&
|
|
40
|
+
x.item.language === fieldItem.language &&
|
|
41
|
+
x.item.version === fieldItem.version
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (
|
|
46
|
+
!state.current.focus ||
|
|
47
|
+
!document.activeElement?.classList.contains("ql-editor")
|
|
48
|
+
) {
|
|
49
|
+
if (field.isHistoric) setValue(field.value as string);
|
|
50
|
+
else setValue(modifiedField?.value ?? (field.value as string));
|
|
51
|
+
}
|
|
52
|
+
}, [field.value, modifiedFieldsContext?.modifiedFields]);
|
|
53
|
+
|
|
54
|
+
const debouncedSetFieldvalue = useThrottledCallback((value) => {
|
|
55
|
+
editContextRef.current?.operations.editField({
|
|
56
|
+
field: field.descriptor,
|
|
57
|
+
value: value,
|
|
58
|
+
refresh: "none",
|
|
59
|
+
});
|
|
60
|
+
}, editContextRef.current?.configuration.debounceFieldEditsInterval);
|
|
61
|
+
|
|
62
|
+
const handleChange = (newValue: string) => {
|
|
63
|
+
if (newValue === "<p><br></p>" && !field.value) return;
|
|
64
|
+
if (newValue !== value && state.current.focus && !readOnly) {
|
|
65
|
+
setValue(newValue);
|
|
66
|
+
debouncedSetFieldvalue(newValue);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
// Primereact 10.6.6: - Editor takes focus on value change
|
|
72
|
+
|
|
73
|
+
// <Editor
|
|
74
|
+
// className="focus-shadow"
|
|
75
|
+
// key={fieldItem.id + field.id + fieldItem.language + fieldItem.version}
|
|
76
|
+
// disabled={readOnly}
|
|
77
|
+
// value={value}
|
|
78
|
+
// style={{ width: "100%" }}
|
|
79
|
+
// // onTextChange={(e) => {
|
|
80
|
+
// // const val = e.htmlValue ?? "";
|
|
81
|
+
// // setValue(val);
|
|
82
|
+
// // debouncedSetFieldvalue(val);
|
|
83
|
+
// // }}
|
|
84
|
+
// />
|
|
85
|
+
<div
|
|
86
|
+
className={classNames(
|
|
87
|
+
readOnly ? "bg-gray-100" : "bg-white",
|
|
88
|
+
"focus-shadow"
|
|
89
|
+
)}
|
|
90
|
+
>
|
|
91
|
+
<ReactQuill
|
|
92
|
+
ref={inputRef}
|
|
93
|
+
theme="snow"
|
|
94
|
+
value={value}
|
|
95
|
+
onChange={handleChange}
|
|
96
|
+
onFocus={() => {
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
state.current.focus = true;
|
|
99
|
+
}, 101);
|
|
100
|
+
}}
|
|
101
|
+
onBlur={() => {
|
|
102
|
+
state.current.focus = false;
|
|
103
|
+
}}
|
|
104
|
+
readOnly={readOnly}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|