@contember/create 2.1.0-rc.3 → 2.2.0-alpha.10
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/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs +1 -2
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js +1 -2
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +79 -67
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +72 -60
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/development/src/lib/version.cjs +2 -2
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/lib/version.js.map +1 -1
- package/dist/development/src/paths.cjs +3 -3
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/production/run.cjs +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs +1 -2
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js +1 -2
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +79 -67
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +72 -60
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/production/src/lib/version.cjs +2 -2
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/lib/version.js.map +1 -1
- package/dist/production/src/paths.cjs +3 -3
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +16 -4
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/index.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts +3 -2
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +10 -2
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/resources/templates/default/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- package/resources/templates/default/admin/lib/binding/binding.tsx +19 -4
- package/resources/templates/default/admin/lib/binding/delete.tsx +37 -3
- package/resources/templates/default/admin/lib/binding/hooks.tsx +65 -3
- package/resources/templates/default/admin/lib/binding/identity.tsx +17 -4
- package/resources/templates/default/admin/lib/binding/index.ts +5 -5
- package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +15 -3
- package/resources/templates/default/admin/lib/binding/persist.tsx +27 -5
- package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +15 -11
- package/resources/templates/default/admin/lib/block-repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/board/board.tsx +2 -2
- package/resources/templates/default/admin/lib/board/index.ts +1 -1
- package/resources/templates/default/admin/lib/buttons/back-button.tsx +22 -2
- package/resources/templates/default/admin/lib/buttons/index.ts +2 -2
- package/resources/templates/default/admin/lib/buttons/link-back-button.tsx +11 -2
- package/resources/templates/default/admin/lib/datagrid/cells.tsx +3 -3
- package/resources/templates/default/admin/lib/datagrid/column-header.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/columns.tsx +28 -14
- package/resources/templates/default/admin/lib/datagrid/elements.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/empty.tsx +1 -1
- package/resources/templates/default/admin/lib/datagrid/export.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +13 -13
- package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +37 -16
- package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +13 -12
- package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +56 -22
- package/resources/templates/default/admin/lib/datagrid/filters/index.ts +7 -7
- package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +18 -0
- package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +10 -13
- package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +8 -8
- package/resources/templates/default/admin/lib/datagrid/filters/text.tsx +9 -9
- package/resources/templates/default/admin/lib/datagrid/grid.tsx +31 -23
- package/resources/templates/default/admin/lib/datagrid/index.ts +12 -12
- package/resources/templates/default/admin/lib/datagrid/labels.tsx +22 -4
- package/resources/templates/default/admin/lib/datagrid/layout-switcher.tsx +10 -4
- package/resources/templates/default/admin/lib/datagrid/loader.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/pagination.tsx +16 -6
- package/resources/templates/default/admin/lib/datagrid/table.tsx +8 -6
- package/resources/templates/default/admin/lib/datagrid/tiles.tsx +6 -5
- package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +15 -19
- package/resources/templates/default/admin/lib/datagrid/ui.tsx +3 -3
- package/resources/templates/default/admin/lib/dev/index.ts +2 -2
- package/resources/templates/default/admin/lib/dev/login-panel.tsx +12 -3
- package/resources/templates/default/admin/lib/dev/todo.tsx +12 -0
- package/resources/templates/default/admin/lib/dict.ts +0 -261
- package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +85 -4
- package/resources/templates/default/admin/lib/dimensions/index.ts +1 -1
- package/resources/templates/default/admin/lib/editor/block-editor.tsx +72 -3
- package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +54 -11
- package/resources/templates/default/admin/lib/editor/common/buttons.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/ListItemRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/editor-block.tsx +54 -3
- package/resources/templates/default/admin/lib/editor/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/plugins.tsx +46 -2
- package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +44 -0
- package/resources/templates/default/admin/lib/editor/rich-text.tsx +31 -3
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +34 -2
- package/resources/templates/default/admin/lib/errors/index.ts +1 -1
- package/resources/templates/default/admin/lib/errors/use-error-formatter.ts +22 -1
- package/resources/templates/default/admin/lib/field/formatted-field.tsx +16 -1
- package/resources/templates/default/admin/lib/field/index.ts +2 -1
- package/resources/templates/default/admin/lib/field/list-field.tsx +56 -0
- package/resources/templates/default/admin/lib/form/container.tsx +33 -3
- package/resources/templates/default/admin/lib/form/index.ts +6 -5
- package/resources/templates/default/admin/lib/form/inputs.tsx +105 -6
- package/resources/templates/default/admin/lib/form/labels.tsx +1 -1
- package/resources/templates/default/admin/lib/form/select.tsx +162 -5
- package/resources/templates/default/admin/lib/form/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +159 -5
- package/resources/templates/default/admin/lib/form/upload.tsx +116 -3
- package/resources/templates/default/admin/lib/formatting/formatting.ts +106 -1
- package/resources/templates/default/admin/lib/formatting/index.ts +1 -1
- package/resources/templates/default/admin/lib/images/formatImageResizeUrl.ts +19 -0
- package/resources/templates/default/admin/lib/images/index.ts +1 -1
- package/resources/templates/default/admin/lib/index.ts +54 -0
- package/resources/templates/default/admin/lib/labels/index.ts +2 -2
- package/resources/templates/default/admin/lib/layout/index.ts +3 -3
- package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +5 -5
- package/resources/templates/default/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/default/admin/lib/outdated-application-dialog/index.ts +1 -1
- package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/repeater/repeater.tsx +26 -9
- package/resources/templates/default/admin/lib/select/create-new.tsx +19 -3
- package/resources/templates/default/admin/lib/select/filter.tsx +8 -2
- package/resources/templates/default/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/default/admin/lib/select/index.ts +6 -6
- package/resources/templates/default/admin/lib/select/list.tsx +30 -6
- package/resources/templates/default/admin/lib/select/multi-select.tsx +41 -4
- package/resources/templates/default/admin/lib/select/select.tsx +44 -6
- package/resources/templates/default/admin/lib/select/sortable-select.tsx +15 -6
- package/resources/templates/default/admin/lib/select/ui.tsx +100 -4
- package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +770 -0
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +12 -5
- package/resources/templates/default/admin/lib/tenant/forms/confirm-email-change.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +23 -8
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +46 -8
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +7 -5
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
- package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +14 -5
- package/resources/templates/default/admin/lib/tenant/forms/verify-email.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInvite.ts +41 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +32 -3
- package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +10 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +161 -23
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +11 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +28 -19
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +17 -6
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +3 -1
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- package/resources/templates/default/admin/lib/toast/index.ts +2 -2
- package/resources/templates/default/admin/lib/toast/toast.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +114 -3
- package/resources/templates/default/admin/lib/ui/avatar.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/button.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/card.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/collapsible.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/dimension.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/divider.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dropdown.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/input.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/label.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/loader.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/menu.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/overlay.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/popover.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/progress.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/property-list.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/scroll-area.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/select.tsx +44 -2
- package/resources/templates/default/admin/lib/ui/separator.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sheet.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +8 -8
- package/resources/templates/default/admin/lib/ui/skeleton.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sortable.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/switch.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/table.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/textarea.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/toggle-group.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/toggle.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/dropzone.tsx +20 -3
- package/resources/templates/default/admin/lib/upload/index.ts +3 -3
- package/resources/templates/default/admin/lib/upload/repeater.tsx +5 -1
- package/resources/templates/default/admin/lib/upload/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/upload-progress.tsx +6 -6
- package/resources/templates/default/admin/lib/upload/view.tsx +4 -4
- package/resources/templates/default/admin/lib/utils/cn.ts +18 -0
- package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +33 -0
- package/resources/templates/default/admin/lib/utils/index.ts +2 -2
- package/resources/templates/default/admin/lib/utils/uic.tsx +59 -0
- package/resources/templates/default/admin/lib/utils/use-mobile.ts +19 -0
- package/resources/templates/default/admin/package.json +1 -0
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- package/resources/templates/default/scripts/assemble-ui-lib.mjs +132 -0
- package/resources/templates/default/scripts/update-ui-lib.sh +101 -185
- package/src/commands/WorkspaceCreateCommand.ts +45 -17
- package/src/commands/index.ts +1 -1
- package/src/lib/FileSystem.ts +2 -2
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/lib/version.ts +1 -1
- package/src/run.ts +11 -10
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReactNode, useCallback, useMemo } from 'react'
|
|
2
|
-
import { EditorCanvas } from './common/editor-canvas'
|
|
3
|
-
import { EditorEditableCanvas } from './common/editor-editable-canvas'
|
|
2
|
+
import { EditorCanvas } from './common/editor-canvas.js'
|
|
3
|
+
import { EditorEditableCanvas } from './common/editor-editable-canvas.js'
|
|
4
4
|
import { BlockEditor, BlockEditorProps, withReferences } from '@contember/react-slate-editor'
|
|
5
5
|
import { Component, SugaredRelativeEntityList, SugaredRelativeSingleField } from '@contember/interface'
|
|
6
6
|
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'
|
|
7
7
|
import { useSlate, useSlateStatic } from 'slate-react'
|
|
8
|
-
import { blockEditorPlugins } from './plugins'
|
|
8
|
+
import { blockEditorPlugins } from './plugins.js'
|
|
9
9
|
import {
|
|
10
10
|
closestCenter,
|
|
11
11
|
DndContext,
|
|
@@ -22,11 +22,80 @@ import { Transforms } from 'slate'
|
|
|
22
22
|
export type BlockEditorFieldProps =
|
|
23
23
|
& BlockEditorProps
|
|
24
24
|
& {
|
|
25
|
+
/** Field for storing related entities */
|
|
25
26
|
referencesField: SugaredRelativeEntityList['field']
|
|
27
|
+
/** Field for entity type discrimination */
|
|
26
28
|
referenceDiscriminationField: SugaredRelativeSingleField['field']
|
|
29
|
+
/** Editor placeholder text */
|
|
27
30
|
placeholder?: string
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/**
|
|
34
|
+
* BlockEditorField component - Rich text editor with drag-and-drop block management
|
|
35
|
+
*
|
|
36
|
+
* ## Purpose
|
|
37
|
+
* Provides a structured content editing experience with sortable blocks and reference management
|
|
38
|
+
*
|
|
39
|
+
* ## Features
|
|
40
|
+
* - Drag-and-drop block reordering
|
|
41
|
+
* - Reference entity integration
|
|
42
|
+
* - Slate.js editor core
|
|
43
|
+
* - Plugin system extensibility
|
|
44
|
+
* - Collision detection and measuring strategies
|
|
45
|
+
*
|
|
46
|
+
* ## Example: Basic usage
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <BlockEditorField
|
|
49
|
+
* field="data"
|
|
50
|
+
* referencesField="references"
|
|
51
|
+
* referenceDiscriminationField="type"
|
|
52
|
+
* >
|
|
53
|
+
* <EditorBlockToolbar>
|
|
54
|
+
* <EditorReferenceTrigger referenceType="image">
|
|
55
|
+
* <BlockButton><ImageIcon /> Image</BlockButton>
|
|
56
|
+
* </EditorReferenceTrigger>
|
|
57
|
+
* </EditorBlockToolbar>
|
|
58
|
+
*
|
|
59
|
+
* <EditorBlock name="image" label="Image">
|
|
60
|
+
* <ImageField baseField="image" urlField="url" />
|
|
61
|
+
* </EditorBlock>
|
|
62
|
+
* </BlockEditorField>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* ## Example with custom plugins and toolbars (inline and block)
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <BlockEditorField
|
|
68
|
+
* field="data"
|
|
69
|
+
* referencesField="references"
|
|
70
|
+
* referenceDiscriminationField="type"
|
|
71
|
+
* plugins={[
|
|
72
|
+
* editor => {
|
|
73
|
+
* editor.registerElement({
|
|
74
|
+
* type: 'link',
|
|
75
|
+
* isInline: true,
|
|
76
|
+
* render: LinkElement,
|
|
77
|
+
* })
|
|
78
|
+
* },
|
|
79
|
+
* ]}
|
|
80
|
+
* >
|
|
81
|
+
* <EditorBlockToolbar>
|
|
82
|
+
* <EditorReferenceTrigger referenceType="image">
|
|
83
|
+
* <BlockButton>
|
|
84
|
+
* <ImageIcon /> Image
|
|
85
|
+
* </BlockButton>
|
|
86
|
+
* </EditorReferenceTrigger>
|
|
87
|
+
* </EditorBlockToolbar>
|
|
88
|
+
*
|
|
89
|
+
* <EditorBlock name="quote" label="Quote">
|
|
90
|
+
* <EditorBlockContent />
|
|
91
|
+
* </EditorBlock>
|
|
92
|
+
*
|
|
93
|
+
* <EditorBlock name="image" label="Image">
|
|
94
|
+
* <ImageField baseField="image" urlField="url" />
|
|
95
|
+
* </EditorBlock>
|
|
96
|
+
* </BlockEditorField>
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
30
99
|
export const BlockEditorField = Component<BlockEditorFieldProps>(({ placeholder, children, ...props }) => {
|
|
31
100
|
return (
|
|
32
101
|
<BlockEditor
|
|
@@ -15,18 +15,61 @@ import {
|
|
|
15
15
|
withTables,
|
|
16
16
|
withUnderline,
|
|
17
17
|
} from '@contember/react-slate-editor-base'
|
|
18
|
-
import { AnchorRenderer } from './elements/AnchorRenderer'
|
|
19
|
-
import { ParagraphRenderer } from './elements/ParagraphRenderer'
|
|
20
|
-
import { HeadingRenderer } from './elements/HeadingRenderer'
|
|
21
|
-
import { ListItemRenderer } from './elements/ListItemRenderer'
|
|
22
|
-
import { OrderedListRenderer } from './elements/OrderedListRenderer'
|
|
23
|
-
import { UnorderedListRenderer } from './elements/UnorderedListRenderer'
|
|
24
|
-
import { HorizontalRuleRenderer } from './elements/HorizontalRuleRenderer'
|
|
25
|
-
import { ScrollTargetRenderer } from './elements/ScrollTargetRenderer'
|
|
26
|
-
import { TableElementRenderer } from './elements/TableElementRenderer'
|
|
27
|
-
import { TableCellElementRenderer } from './elements/TableCellElementRenderer'
|
|
28
|
-
import { TableRowElementRenderer } from './elements/TableRowElementRenderer'
|
|
18
|
+
import { AnchorRenderer } from './elements/AnchorRenderer.js'
|
|
19
|
+
import { ParagraphRenderer } from './elements/ParagraphRenderer.js'
|
|
20
|
+
import { HeadingRenderer } from './elements/HeadingRenderer.js'
|
|
21
|
+
import { ListItemRenderer } from './elements/ListItemRenderer.js'
|
|
22
|
+
import { OrderedListRenderer } from './elements/OrderedListRenderer.js'
|
|
23
|
+
import { UnorderedListRenderer } from './elements/UnorderedListRenderer.js'
|
|
24
|
+
import { HorizontalRuleRenderer } from './elements/HorizontalRuleRenderer.js'
|
|
25
|
+
import { ScrollTargetRenderer } from './elements/ScrollTargetRenderer.js'
|
|
26
|
+
import { TableElementRenderer } from './elements/TableElementRenderer.js'
|
|
27
|
+
import { TableCellElementRenderer } from './elements/TableCellElementRenderer.js'
|
|
28
|
+
import { TableRowElementRenderer } from './elements/TableRowElementRenderer.js'
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* baseEditorPlugins - Core plugin configuration for Slate.js editor components
|
|
32
|
+
*
|
|
33
|
+
* ### Plugin Structure
|
|
34
|
+
* Contains renderer configurations and basic formatting capabilities for:
|
|
35
|
+
*
|
|
36
|
+
* ## Structural Elements
|
|
37
|
+
* - **anchor**: Link handling with `AnchorRenderer`
|
|
38
|
+
* - **paragraph**: Text blocks with `ParagraphRenderer`
|
|
39
|
+
* - **heading**: Headings with `HeadingRenderer`
|
|
40
|
+
* - **list**: List structures with:
|
|
41
|
+
* - `ListItemRenderer`
|
|
42
|
+
* - `OrderedListRenderer`
|
|
43
|
+
* - `UnorderedListRenderer`
|
|
44
|
+
* - **horizontalRule**: Dividers with `HorizontalRuleRenderer`
|
|
45
|
+
* - **scrollTarget**: Navigation anchors with `ScrollTargetRenderer`
|
|
46
|
+
* - **table**: Tabular data with:
|
|
47
|
+
* - `TableElementRenderer`
|
|
48
|
+
* - `TableCellElementRenderer`
|
|
49
|
+
* - `TableRowElementRenderer`
|
|
50
|
+
*
|
|
51
|
+
* ## Text Formatting
|
|
52
|
+
* - **bold**: Bold text formatting
|
|
53
|
+
* - **code**: Inline code styling
|
|
54
|
+
* - **highlight**: Text highlighting
|
|
55
|
+
* - **italic**: Italic text
|
|
56
|
+
* - **newline**: Manual line breaks
|
|
57
|
+
* - **strikeThrough**: Strikethrough text
|
|
58
|
+
* - **underline**: Underlined text
|
|
59
|
+
*
|
|
60
|
+
* ### Usage
|
|
61
|
+
* ```tsx
|
|
62
|
+
* // Create editor with base configuration
|
|
63
|
+
* <RichTextEditor
|
|
64
|
+
* plugins={[
|
|
65
|
+
* baseEditorPlugins.paragraph,
|
|
66
|
+
* baseEditorPlugins.heading,
|
|
67
|
+
* baseEditorPlugins.bold,
|
|
68
|
+
* baseEditorPlugins.italic
|
|
69
|
+
* ]}
|
|
70
|
+
* />
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
30
73
|
export const baseEditorPlugins = {
|
|
31
74
|
anchor: withAnchors({
|
|
32
75
|
render: AnchorRenderer,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HeadingElement } from '@contember/react-slate-editor-base'
|
|
2
2
|
import React, { FunctionComponent } from 'react'
|
|
3
3
|
import type { RenderElementProps } from 'slate-react'
|
|
4
|
-
import { cn } from '
|
|
4
|
+
import { cn } from '~/lib'
|
|
5
5
|
|
|
6
6
|
export interface HeadingRendererProps extends Omit<RenderElementProps, 'element'> {
|
|
7
7
|
element: HeadingElement
|
package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HorizontalRuleElement } from '@contember/react-slate-editor-base'
|
|
2
2
|
import type { FunctionComponent } from 'react'
|
|
3
3
|
import { RenderElementProps, useSelected } from 'slate-react'
|
|
4
|
-
import { BlockElement } from './BlockElement'
|
|
4
|
+
import { BlockElement } from './BlockElement.js'
|
|
5
5
|
|
|
6
6
|
export interface HorizontalRuleRendererProps extends Omit<RenderElementProps, 'element'> {
|
|
7
7
|
element: HorizontalRuleElement
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RenderElementProps } from 'slate-react'
|
|
2
2
|
import { FunctionComponent } from 'react'
|
|
3
3
|
import { ListItemElement } from '@contember/react-slate-editor-base'
|
|
4
|
-
import { BlockElement } from './BlockElement'
|
|
4
|
+
import { BlockElement } from './BlockElement.js'
|
|
5
5
|
|
|
6
6
|
export interface ListItemRendererProps extends Omit<RenderElementProps, 'element'> {
|
|
7
7
|
element: ListItemElement
|
package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderElementProps } from 'slate-react'
|
|
2
2
|
import { FunctionComponent } from 'react'
|
|
3
|
-
import { BlockElement } from './BlockElement'
|
|
3
|
+
import { BlockElement } from './BlockElement.js'
|
|
4
4
|
import { OrderedListElement } from '@contember/react-slate-editor-base'
|
|
5
5
|
|
|
6
6
|
export interface OrderedListRendererProps extends Omit<RenderElementProps, 'element'> {
|
package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { assertNever } from '@contember/utilities'
|
|
|
3
3
|
import { memo, useCallback } from 'react'
|
|
4
4
|
import { Transforms } from 'slate'
|
|
5
5
|
import { ReactEditor, RenderElementProps, useSelected, useSlateStatic } from 'slate-react'
|
|
6
|
-
import { BlockElement } from './BlockElement'
|
|
6
|
+
import { BlockElement } from './BlockElement.js'
|
|
7
7
|
|
|
8
8
|
export interface TableElementRendererProps extends Omit<RenderElementProps, 'element'> {
|
|
9
9
|
element: TableElement
|
package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RenderElementProps } from 'slate-react'
|
|
2
2
|
import { FunctionComponent } from 'react'
|
|
3
3
|
import { UnorderedListElement } from '@contember/react-slate-editor-base'
|
|
4
|
-
import { BlockElement } from './BlockElement'
|
|
4
|
+
import { BlockElement } from './BlockElement.js'
|
|
5
5
|
|
|
6
6
|
export interface UnorderedListRendererProps extends Omit<RenderElementProps, 'element'> {
|
|
7
7
|
element: UnorderedListElement
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './baseEditorPlugins'
|
|
2
|
-
export * from './editor-canvas'
|
|
3
|
-
export * from './editor-inline-toolbar'
|
|
4
|
-
export * from './editor-block-toolbar'
|
|
5
|
-
export * from './editor-editable-canvas'
|
|
6
|
-
export * from './elements/BlockElement'
|
|
1
|
+
export * from './baseEditorPlugins.js'
|
|
2
|
+
export * from './editor-canvas.js'
|
|
3
|
+
export * from './editor-inline-toolbar.js'
|
|
4
|
+
export * from './editor-block-toolbar.js'
|
|
5
|
+
export * from './editor-editable-canvas.js'
|
|
6
|
+
export * from './elements/BlockElement.js'
|
|
@@ -1,20 +1,54 @@
|
|
|
1
|
-
import { Button } from '
|
|
1
|
+
import { Button } from '~/lib'
|
|
2
2
|
import { PencilIcon, TrashIcon } from 'lucide-react'
|
|
3
|
-
import { Popover, PopoverContent, PopoverTrigger } from '
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from '~/lib'
|
|
4
4
|
import { Component } from '@contember/interface'
|
|
5
5
|
import { ReactNode, useCallback } from 'react'
|
|
6
6
|
import { Block, BlockContent, BlockRendererProps, useEditorBlockElement } from '@contember/react-slate-editor'
|
|
7
|
-
import { BlockElement } from './common/elements/BlockElement'
|
|
7
|
+
import { BlockElement } from './common/elements/BlockElement.js'
|
|
8
8
|
import { ReactEditor, useSlateStatic } from 'slate-react'
|
|
9
9
|
import { Node, Transforms } from 'slate'
|
|
10
10
|
|
|
11
11
|
export interface EditorBlockProps {
|
|
12
|
+
/** Unique block type identifier */
|
|
12
13
|
name: string
|
|
14
|
+
/** Display name for block type */
|
|
13
15
|
label: ReactNode
|
|
16
|
+
/** Primary block content */
|
|
14
17
|
children: ReactNode
|
|
18
|
+
/** Alternate configuration UI (optional) */
|
|
15
19
|
alternate?: ReactNode
|
|
16
20
|
}
|
|
17
21
|
|
|
22
|
+
/**
|
|
23
|
+
* EditorBlock component - Configurable content block for rich text editor
|
|
24
|
+
*
|
|
25
|
+
* ## Purpose
|
|
26
|
+
* Creates reusable, customizable content blocks within a Slate.js editor instance
|
|
27
|
+
*
|
|
28
|
+
* ## Features
|
|
29
|
+
* - Drag-and-drop enabled block structure
|
|
30
|
+
* - Alternate configuration UI via popover
|
|
31
|
+
* - Block type labeling and identification
|
|
32
|
+
*
|
|
33
|
+
* ## Example: Basic usage
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <BlockEditorField
|
|
36
|
+
* field="data"
|
|
37
|
+
* referencesField="references"
|
|
38
|
+
* referenceDiscriminationField="type"
|
|
39
|
+
* >
|
|
40
|
+
* <EditorBlockToolbar>
|
|
41
|
+
* <EditorReferenceTrigger referenceType="image">
|
|
42
|
+
* <BlockButton><ImageIcon /> Image</BlockButton>
|
|
43
|
+
* </EditorReferenceTrigger>
|
|
44
|
+
* </EditorBlockToolbar>
|
|
45
|
+
*
|
|
46
|
+
* <EditorBlock name="image" label="Image">
|
|
47
|
+
* <ImageField baseField="image" urlField="url" />
|
|
48
|
+
* </EditorBlock>
|
|
49
|
+
* </BlockEditorField>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
18
52
|
export const EditorBlock = Component<EditorBlockProps>(() => {
|
|
19
53
|
return null
|
|
20
54
|
}, blockProps => {
|
|
@@ -29,6 +63,23 @@ export const EditorBlock = Component<EditorBlockProps>(() => {
|
|
|
29
63
|
)
|
|
30
64
|
})
|
|
31
65
|
|
|
66
|
+
/**
|
|
67
|
+
* EditorBlockContent component - Editable content area for blocks
|
|
68
|
+
*
|
|
69
|
+
* ## Purpose
|
|
70
|
+
* Provides the main editable region within a content block
|
|
71
|
+
*
|
|
72
|
+
* ## Features
|
|
73
|
+
* - Automatic placeholder text when empty
|
|
74
|
+
* - ContentEditable management
|
|
75
|
+
* - Text presence detection
|
|
76
|
+
* - Proper padding and positioning
|
|
77
|
+
*
|
|
78
|
+
* ## Example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <EditorBlockContent />
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
32
83
|
export const EditorBlockContent = Component(() => {
|
|
33
84
|
const el = useEditorBlockElement().element
|
|
34
85
|
const hasText = Node.string(el).length > 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './common'
|
|
2
|
-
export * from './block-editor'
|
|
3
|
-
export * from './editor-block'
|
|
4
|
-
export * from './plugins'
|
|
5
|
-
export * from './rich-text'
|
|
6
|
-
export * from './rich-text-view'
|
|
1
|
+
export * from './common/index.js'
|
|
2
|
+
export * from './block-editor.js'
|
|
3
|
+
export * from './editor-block.js'
|
|
4
|
+
export * from './plugins.js'
|
|
5
|
+
export * from './rich-text.js'
|
|
6
|
+
export * from './rich-text-view.js'
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { withSortable } from '@contember/react-slate-editor'
|
|
2
|
-
import { SortableBlock } from './sortable-block'
|
|
3
|
-
import { baseEditorPlugins } from './common/baseEditorPlugins'
|
|
2
|
+
import { SortableBlock } from './sortable-block.js'
|
|
3
|
+
import { baseEditorPlugins } from './common/baseEditorPlugins.js'
|
|
4
4
|
|
|
5
5
|
const plugins = baseEditorPlugins
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* richTextFieldPlugins - Basic text formatting plugins for Slate editor
|
|
9
|
+
*
|
|
10
|
+
* ## Purpose
|
|
11
|
+
* Provides essential inline formatting tools for rich text fields
|
|
12
|
+
*
|
|
13
|
+
* ## Included Features:
|
|
14
|
+
* - Anchor/links
|
|
15
|
+
* - Bold/italic/underline
|
|
16
|
+
* - Code blocks
|
|
17
|
+
* - Text highlighting
|
|
18
|
+
* - Strikethrough
|
|
19
|
+
* - Manual newlines
|
|
20
|
+
*
|
|
21
|
+
* ## Example Usage
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <RichTextEditor plugins={richTextFieldPlugins} />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
7
26
|
export const richTextFieldPlugins = [
|
|
8
27
|
plugins.anchor,
|
|
9
28
|
plugins.bold,
|
|
@@ -15,6 +34,31 @@ export const richTextFieldPlugins = [
|
|
|
15
34
|
plugins.underline,
|
|
16
35
|
]
|
|
17
36
|
|
|
37
|
+
/**
|
|
38
|
+
* blockEditorPlugins - Advanced content editing plugins with structural elements
|
|
39
|
+
*
|
|
40
|
+
* ## Purpose
|
|
41
|
+
* Enables complex document structures and block management in Slate editor
|
|
42
|
+
*
|
|
43
|
+
* ## Additional Features beyond richTextFieldPlugins:
|
|
44
|
+
* - Paragraph/heading formatting
|
|
45
|
+
* - Lists (ordered/unordered)
|
|
46
|
+
* - Horizontal rules
|
|
47
|
+
* - Tables
|
|
48
|
+
* - Scroll targets
|
|
49
|
+
* - Drag-and-drop block sorting
|
|
50
|
+
*
|
|
51
|
+
* ## Key Integration
|
|
52
|
+
* - `withSortable` enables block reordering
|
|
53
|
+
* - Requires `SortableBlock` component for drag handles
|
|
54
|
+
*
|
|
55
|
+
* ## Example Usage
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <BlockEditor plugins={blockEditorPlugins}>
|
|
58
|
+
* <SortableBlock name="section" />
|
|
59
|
+
* </BlockEditor>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
18
62
|
export const blockEditorPlugins = [
|
|
19
63
|
plugins.anchor,
|
|
20
64
|
plugins.paragraph,
|
|
@@ -3,10 +3,54 @@ import { RichTextFieldRenderer, RichTextFieldRendererProps } from '@contember/re
|
|
|
3
3
|
|
|
4
4
|
export type RichTextRendererProps =
|
|
5
5
|
& {
|
|
6
|
+
/** Field containing rich text content */
|
|
6
7
|
field: SugaredRelativeSingleField['field']
|
|
7
8
|
}
|
|
8
9
|
& Omit<RichTextFieldRendererProps, 'source'>
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* RichTextView component - Displays formatted rich text content from a Contember field
|
|
13
|
+
*
|
|
14
|
+
* ## Purpose
|
|
15
|
+
* Renders stored rich text content with proper formatting and structure
|
|
16
|
+
*
|
|
17
|
+
* ## Features
|
|
18
|
+
* - Safe JSON parsing of stored rich text data
|
|
19
|
+
* - Conditional rendering when content is empty
|
|
20
|
+
* - Integration with Contember's rich text rendering system
|
|
21
|
+
* - Customizable through RichTextFieldRenderer props
|
|
22
|
+
*
|
|
23
|
+
* ## Example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <RichTextView field="content" />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Example with renderers
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const renderLeaf = (leaf: Leaf) => {
|
|
31
|
+
* let content = <>{leaf.text}</>
|
|
32
|
+
*
|
|
33
|
+
* if (leaf.isBold) {
|
|
34
|
+
* content = <strong>{content}</strong>
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* if (leaf.isItalic) {
|
|
38
|
+
* content = <em>{content}</em>
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* if (leaf.isUnderlined) {
|
|
42
|
+
* content = <u>{content}</u>
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* return content
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* <RichTextView
|
|
49
|
+
* field="content"
|
|
50
|
+
* renderLeaf={renderLeaf}
|
|
51
|
+
* />
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
10
54
|
export const RichTextView = Component<RichTextRendererProps>(({ field, ...props }) => {
|
|
11
55
|
return (
|
|
12
56
|
<FieldView<string>
|
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
import { Editable, useSlateStatic } from 'slate-react'
|
|
2
|
-
import { EditorCanvas } from './common/editor-canvas'
|
|
2
|
+
import { EditorCanvas } from './common/editor-canvas.js'
|
|
3
3
|
import { RichTextEditor } from '@contember/react-slate-editor'
|
|
4
4
|
import { Component, SugaredRelativeSingleField, useMutationState } from '@contember/interface'
|
|
5
5
|
import * as React from 'react'
|
|
6
6
|
import { ReactNode } from 'react'
|
|
7
|
-
import { FormContainer, FormContainerProps } from '../form'
|
|
7
|
+
import { FormContainer, FormContainerProps } from '../form/index.js'
|
|
8
8
|
import { FormFieldScope } from '@contember/react-form'
|
|
9
|
-
import { richTextFieldPlugins } from './plugins'
|
|
9
|
+
import { richTextFieldPlugins } from './plugins.js'
|
|
10
10
|
|
|
11
11
|
export type RichTextFieldProps =
|
|
12
12
|
& {
|
|
13
|
+
/** Form field name for storing content */
|
|
13
14
|
field: SugaredRelativeSingleField['field']
|
|
14
15
|
children: ReactNode
|
|
15
16
|
}
|
|
16
17
|
& Omit<FormContainerProps, 'children'>
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* RichTextField component - Form-integrated rich text editor with basic formatting
|
|
21
|
+
*
|
|
22
|
+
* ## Purpose
|
|
23
|
+
* Provides a rich text editing experience within Contember forms with common formatting tools
|
|
24
|
+
*
|
|
25
|
+
* ## Features
|
|
26
|
+
* - Integrated with Contember form field management
|
|
27
|
+
* - Basic text formatting (bold, italic, code, etc.)
|
|
28
|
+
* - Read-only state during mutations
|
|
29
|
+
* - Custom placeholder support
|
|
30
|
+
* - Plugin-based architecture
|
|
31
|
+
*
|
|
32
|
+
* ## Example: Basic usage
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <RichTextField field="content" />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ## Example: With custom placeholder
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <RichTextField
|
|
40
|
+
* field="content"
|
|
41
|
+
* label="Article body"
|
|
42
|
+
* placeholder="Enter your text here"
|
|
43
|
+
* />
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
18
46
|
export const RichTextField = Component<RichTextFieldProps>(({ field, description, label, children }) => {
|
|
19
47
|
return (
|
|
20
48
|
<FormFieldScope field={field}>
|
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
import React, { ReactNode, useEffect } from 'react'
|
|
2
2
|
import { Element } from 'slate'
|
|
3
3
|
import { useSortable } from '@dnd-kit/sortable'
|
|
4
|
-
import { uic } from '
|
|
4
|
+
import { uic } from '~/lib'
|
|
5
5
|
import { GripVerticalIcon } from 'lucide-react'
|
|
6
|
-
import { DropIndicator } from '
|
|
6
|
+
import { DropIndicator } from '~/lib'
|
|
7
7
|
import { Portal } from '@radix-ui/react-portal'
|
|
8
8
|
import { DragOverlay } from '@dnd-kit/core'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* BlockEditorHandle component - Drag handle for sortable blocks
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <BlockEditorHandle />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
10
18
|
export const BlockEditorHandle = uic('span', {
|
|
11
19
|
baseClass:
|
|
12
20
|
'absolute top-1/2 -left-3 h-6 w-6 flex justify-end items-center opacity-10 hover:opacity-100 transition-opacity -translate-y-1/2 cursor-grab',
|
|
13
21
|
beforeChildren: <GripVerticalIcon size={16} />,
|
|
14
22
|
})
|
|
15
23
|
|
|
24
|
+
/**
|
|
25
|
+
* SortableBlock component - Drag-and-drop enabled block container for Slate editor
|
|
26
|
+
*
|
|
27
|
+
* ## Purpose
|
|
28
|
+
* Implements sortable functionality for editor blocks with visual feedback and overlay
|
|
29
|
+
*
|
|
30
|
+
* ## Example: Basic usage
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <SortableBlock element={slateElement}>
|
|
33
|
+
* <BlockContent />
|
|
34
|
+
* </SortableBlock>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ## Example: Used within a BlockEditor
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <BlockEditor
|
|
40
|
+
* plugins={[
|
|
41
|
+
* withSortable({
|
|
42
|
+
* render: SortableBlock,
|
|
43
|
+
* }),
|
|
44
|
+
* ]}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
16
48
|
export const SortableBlock = ({ children, element }: { children: ReactNode; element: Element }) => {
|
|
17
49
|
const sortable = useSortable({
|
|
18
50
|
id: element.key as string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './use-error-formatter'
|
|
1
|
+
export * from './use-error-formatter.js'
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import { ReactNode, useCallback } from 'react'
|
|
2
|
-
import { dict } from '
|
|
2
|
+
import { dict } from '~/lib'
|
|
3
3
|
import { ErrorAccessor } from '@contember/interface'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* `useErrorFormatter` is a custom hook that formats an array of errors into readable messages.
|
|
7
|
+
* It processes validation and execution errors and returns corresponding user-friendly messages.
|
|
8
|
+
*
|
|
9
|
+
* ## Returns
|
|
10
|
+
* A memoized callback function that takes an array of `ErrorAccessor.Error` and returns an array of `ReactNode` messages.
|
|
11
|
+
*
|
|
12
|
+
* ## Example: Formatting validation and execution errors
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const formatErrors = useErrorFormatter();
|
|
15
|
+
*
|
|
16
|
+
* const errors = [
|
|
17
|
+
* { type: 'validation', code: 'fieldRequired', message: 'This field is required' },
|
|
18
|
+
* { type: 'execution', code: 'UniqueConstraintViolation' }
|
|
19
|
+
* ];
|
|
20
|
+
*
|
|
21
|
+
* const formattedErrors = formatErrors(errors);
|
|
22
|
+
*
|
|
23
|
+
* return <>{formattedErrors.map((error, i) => <div key={i}>{error}</div>)}</>;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
5
26
|
export const useErrorFormatter = () => {
|
|
6
27
|
return useCallback((errors: ErrorAccessor.Error[]): ReactNode[] => {
|
|
7
28
|
return errors.map((it, i) => {
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { Component, FieldView, SugaredRelativeSingleField } from '@contember/interface'
|
|
2
|
-
import { getFormatter } from '../formatting'
|
|
2
|
+
import { getFormatter } from '../formatting/index.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Props for the {@link FormattedField} component.
|
|
6
|
+
*/
|
|
4
7
|
export interface FormattedFieldProps {
|
|
8
|
+
/**
|
|
9
|
+
* The field to render.
|
|
10
|
+
*/
|
|
5
11
|
field: SugaredRelativeSingleField['field']
|
|
6
12
|
}
|
|
7
13
|
|
|
14
|
+
/**
|
|
15
|
+
* `FormattedField` is a wrapper around {@link FieldView} that applies a formatter to the field's value
|
|
16
|
+
* based on its schema definition.
|
|
17
|
+
*
|
|
18
|
+
* ## Example: Rendering a formatted field
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <FormattedField field={myField} />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
8
23
|
export const FormattedField = Component<FormattedFieldProps>(({ field }) => {
|
|
9
24
|
return <FieldView field={field} render={it => getFormatter(it.schema)(it.value)} />
|
|
10
25
|
})
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './formatted-field'
|
|
1
|
+
export * from './formatted-field.js'
|
|
2
|
+
export * from './list-field.js'
|