betterstart-cli 0.0.97 → 0.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/adapters/next/integrations/mailchimp/integration.ts +1 -1
- package/dist/assets/adapters/next/integrations/r2/actions/r2.ts +1 -1
- package/dist/assets/adapters/next/integrations/r2/integration.ts +1 -1
- package/dist/assets/adapters/next/integrations/railway-bucket/actions/railway-bucket.ts +1 -1
- package/dist/assets/adapters/next/integrations/railway-bucket/integration.ts +1 -1
- package/dist/assets/adapters/next/integrations/resend/integration.ts +1 -1
- package/dist/assets/adapters/next/integrations/vercel-blob/actions/vercel-blob.ts +1 -1
- package/dist/assets/adapters/next/integrations/vercel-blob/integration.ts +1 -1
- package/dist/assets/adapters/next/presets/blog/preset.ts +1 -1
- package/dist/assets/adapters/next/presets/portfolio/preset.ts +1 -1
- package/dist/assets/adapters/next/templates/init/api/storage-read-route.ts +2 -1
- package/dist/assets/adapters/next/templates/init/api/upload-route.ts +3 -2
- package/dist/assets/adapters/next/templates/init/components/layouts/admin-providers.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/layouts/admin-sidebar-nav-link-skeleton.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/layouts/admin-sidebar.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/data-table/data-grid.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/data-table/data-table-pagination.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/data-table/data-table.tsx +2 -5
- package/dist/assets/adapters/next/templates/init/components/shared/delete-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/dev-mode/copyable-code-block.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/dev-mode/dev-mode-code-mirror.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/dev-mode/lifecycle-hooks-tab.tsx +7 -17
- package/dist/assets/adapters/next/templates/init/components/shared/dev-mode/snippets-tab.tsx +3 -13
- package/dist/assets/adapters/next/templates/init/components/shared/dev-mode-integrate.tsx +4 -4
- package/dist/assets/adapters/next/templates/init/components/shared/entity-filters-bar.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/entity-versions/entity-version-restore-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/entity-versions/entity-versions-button.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/media/edit-media-dialog-content.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/edit-media-dialog.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-delete-dialog.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-delete-drawer.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-filters-bar.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-gallery-dialog.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-grid-item.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-grid-pagination.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-grid.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-preview.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/media/media-url-importer.tsx +2 -2
- package/dist/assets/adapters/next/templates/init/components/shared/search-input.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/components/shared/sort-order-dialog.tsx +3 -4
- package/dist/assets/adapters/next/templates/init/components/shared/sort-order-item.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-blockquote.ts +1 -70
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-code-block.ts +1 -77
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-color-highlight.ts +3 -51
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-content-editor-media-insertion.ts +2 -2
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-content-editor-slash-menu.ts +6 -8
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-content-editor-source-mode.tsx +10 -8
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-content-editor-table-add-controls.ts +4 -4
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-content-editor.ts +7 -4
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-heading-dropdown-menu.ts +3 -66
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-heading.ts +1 -41
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-is-breakpoint.ts +0 -8
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-link-popover.ts +1 -83
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-list-dropdown-menu.ts +3 -61
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-list.ts +1 -43
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-mark.ts +1 -72
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-menu-navigation.ts +0 -35
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-table-button.ts +2 -2
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-tiptap-editor.ts +0 -11
- package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-undo-redo.ts +1 -65
- package/dist/assets/adapters/next/templates/init/hooks/use-admin-theme.tsx +2 -4
- package/dist/assets/adapters/next/templates/init/hooks/use-dev-mode-integration.ts +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/use-entity-versions.ts +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/use-local-storage.ts +2 -7
- package/dist/assets/adapters/next/templates/init/hooks/use-media-filters-bar.ts +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/use-media.ts +2 -2
- package/dist/assets/adapters/next/templates/init/hooks/use-page-boundary-blur-visibility.ts +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/use-page-scroll-threshold.ts +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/use-table-utils.ts +2 -2
- package/dist/assets/adapters/next/templates/init/hooks/use-upload.ts +6 -12
- package/dist/assets/adapters/next/templates/init/hooks/use-users.ts +1 -1
- package/dist/assets/adapters/next/templates/init/hooks/use-webhooks.ts +3 -2
- package/dist/assets/adapters/next/templates/init/lib/actions/audit/cleanup-audit-logs.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/audit/get-audit-logs.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/audit/record-audit-event.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/auth/auth.ts +4 -4
- package/dist/assets/adapters/next/templates/init/lib/actions/auth/middleware.ts +2 -10
- package/dist/assets/adapters/next/templates/init/lib/actions/email/form-delivery.ts +2 -2
- package/dist/assets/adapters/next/templates/init/lib/actions/email/provider.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/entity-versions/get-entity-versions.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/entity-versions/internal-create-entity-version.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/forms/get-all-form-settings.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/forms/get-form-settings.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/forms/upsert-form-settings.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/create-media.ts +2 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/delete-media-bulk.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/delete-media.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/get-media-by-id.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/get-media-by-ids.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/get-media.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/media/update-media.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/profile/change-own-password.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/profile/update-email.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/storage/provider.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/upload/upload-files.ts +2 -2
- package/dist/assets/adapters/next/templates/init/lib/actions/upload/upload-media-from-url.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/users/change-user-password.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/users/create-user.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/users/delete-user.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/users/get-users.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/users/update-user-role.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/create-webhook.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/delete-webhook.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/dispatch.ts +1 -2
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/get-webhook-deliveries.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/get-webhook-secret.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/get-webhook-subscriptions.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/get-webhooks.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/regenerate-webhook-secret.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/register.ts +2 -2
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/send-test-webhook.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/actions/webhooks/update-webhook.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/db/client.ts +1 -1
- package/dist/assets/adapters/next/templates/init/lib/db/core/schema.ts +0 -24
- package/dist/assets/adapters/next/templates/init/lib/lifecycle-hooks/register.ts +0 -7
- package/dist/assets/adapters/next/templates/init/lib/lifecycle-hooks/runner.ts +1 -1
- package/dist/assets/adapters/next/templates/init/pages/forgot-password-form.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/login-form.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/media/media-page-content.tsx +4 -4
- package/dist/assets/adapters/next/templates/init/pages/profile/profile-form.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/reset-password-form.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/audit-log/audit-log-columns.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/audit-log/audit-log-page-content.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/audit-log/audit-log-page.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/audit-log/audit-log-table.tsx +3 -2
- package/dist/assets/adapters/next/templates/init/pages/settings/forms/forms-settings-page-content.tsx +3 -2
- package/dist/assets/adapters/next/templates/init/pages/settings/forms/forms-settings-page.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/forms/forms-settings-table.tsx +4 -3
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhook-endpoint-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-columns.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-logs-columns.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-logs-page-content.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-logs-page.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-logs-table.tsx +2 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-page-content.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-page.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/settings/webhooks/webhooks-table.tsx +2 -1
- package/dist/assets/adapters/next/templates/init/pages/users/change-password-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/users/columns.tsx +3 -2
- package/dist/assets/adapters/next/templates/init/pages/users/create-user-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/users/delete-user-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/users/edit-role-dialog.tsx +1 -1
- package/dist/assets/adapters/next/templates/init/pages/users/users-page-content.tsx +2 -1
- package/dist/assets/adapters/next/templates/init/pages/users/users-table.tsx +4 -3
- package/dist/assets/adapters/next/templates/init/types/index.ts +0 -5
- package/dist/assets/adapters/next/templates/init/utils/date/date.ts +1 -6
- package/dist/assets/adapters/next/templates/init/utils/editor/content-editor-rich-extensions.ts +2 -2
- package/dist/assets/adapters/next/templates/init/utils/editor/markdown.ts +5 -5
- package/dist/assets/adapters/next/templates/init/utils/editor/slash-commands.ts +2 -2
- package/dist/assets/adapters/next/templates/init/utils/editor/table-add-controls.ts +1 -1
- package/dist/assets/adapters/next/templates/init/utils/editor/tiptap.ts +8 -127
- package/dist/assets/adapters/next/templates/init/utils/media/query.ts +1 -1
- package/dist/assets/adapters/next/templates/init/utils/seo/seo.ts +0 -10
- package/dist/assets/adapters/next/templates/init/utils/shared/cn.ts +2 -1
- package/dist/assets/adapters/next/templates/init/utils/validation/validation.ts +0 -12
- package/dist/assets/shared-assets/react-admin/custom/content-editor/editor-toolbar.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/horizontal-rule-button.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/index.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/main-toolbar-content.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/math-bubble-menu.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/custom/content-editor/math-button.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/math-editor-controls.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/math-popover-button.tsx +4 -3
- package/dist/assets/shared-assets/react-admin/custom/content-editor/remove-table-part-icon.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/selection-bubble-menu.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/custom/content-editor/slash-command-menu.tsx +3 -3
- package/dist/assets/shared-assets/react-admin/custom/content-editor/source-mode-dropdown-button.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/source-mode.tsx +5 -11
- package/dist/assets/shared-assets/react-admin/custom/content-editor/table-add-controls.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/table-bubble-menu.tsx +3 -3
- package/dist/assets/shared-assets/react-admin/custom/content-editor/table-button.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-extension/node-background-extension.ts +2 -25
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-node/media-gallery-placeholder-node/media-gallery-placeholder-node-extension.ts +0 -20
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-node/media-gallery-placeholder-node/media-gallery-placeholder-node.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-node/removable-image-node/removable-image-node.tsx +3 -3
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/blockquote-button/blockquote-button.tsx +3 -18
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/code-block-button/code-block-button.tsx +3 -18
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-button/color-highlight-button.tsx +2 -37
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-popover/color-highlight-popover-button.tsx +3 -5
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-popover/color-highlight-popover-content.tsx +3 -9
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-popover/color-highlight-popover.tsx +6 -12
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-popover/highlight-color-button.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-popover/highlight-colors.ts +2 -4
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/color-highlight-popover/source-color-highlight-popover.tsx +4 -9
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu-item.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.tsx +4 -19
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/link-popover/link-button.tsx +3 -5
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/link-popover/link-content.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/link-popover/link-control-popover.tsx +5 -3
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/link-popover/link-main.tsx +1 -13
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/link-popover/link-popover.tsx +5 -16
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/list-dropdown-menu/list-dropdown-menu-item.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/list-dropdown-menu/list-dropdown-menu.tsx +4 -19
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/mark-button/mark-button.tsx +3 -19
- package/dist/assets/shared-assets/react-admin/custom/content-editor/tiptap-ui/undo-redo-button/undo-redo-button.tsx +3 -19
- package/dist/assets/shared-assets/react-admin/custom/date-picker.tsx +1 -3
- package/dist/assets/shared-assets/react-admin/custom/date-range-picker.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/custom/gallery-field.tsx +5 -10
- package/dist/assets/shared-assets/react-admin/custom/icon-picker.tsx +7 -4
- package/dist/assets/shared-assets/react-admin/custom/media-field-empty-state.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/media-field.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/custom/nested-object-list-field.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/placeholder-card.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/placeholder.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/progressive-blur.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/sortable-gallery-item.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/custom/upload-dropzone.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/ui/accordion.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/alert-dialog.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/alert.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/avatar.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/badge.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/breadcrumb.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/button-group.tsx +2 -1
- package/dist/assets/shared-assets/react-admin/ui/button.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/calendar.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/card.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/carousel.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/chart.tsx +1 -2
- package/dist/assets/shared-assets/react-admin/ui/checkbox.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/combobox.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/command.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/context-menu.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/dialog.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/direction.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/drawer.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/dropdown-menu.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/empty.tsx +2 -1
- package/dist/assets/shared-assets/react-admin/ui/field.tsx +2 -1
- package/dist/assets/shared-assets/react-admin/ui/form.tsx +4 -10
- package/dist/assets/shared-assets/react-admin/ui/hover-card.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/input-group.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/input-otp.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/input.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/item.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/label.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/menubar.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/native-select.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/navigation-menu.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/pagination.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/popover.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/progress.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/radio-group.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/resizable.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/scroll-area.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/select.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/separator.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/sheet.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/sidebar.tsx +3 -10
- package/dist/assets/shared-assets/react-admin/ui/slider.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/sonner.tsx +2 -1
- package/dist/assets/shared-assets/react-admin/ui/switch.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/table.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/tabs.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/textarea.tsx +1 -1
- package/dist/assets/shared-assets/react-admin/ui/toggle-group.tsx +2 -2
- package/dist/assets/shared-assets/react-admin/ui/toggle.tsx +3 -2
- package/dist/assets/shared-assets/react-admin/ui/tooltip.tsx +1 -1
- package/dist/{chunk-MJWUGEMK.js → chunk-AIQWGMU7.js} +136 -5
- package/dist/chunk-AIQWGMU7.js.map +1 -0
- package/dist/cli.js +1097 -1194
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{template-reader-R2JIWUNK.js → template-reader-F2VFSDKV.js} +2 -2
- package/package.json +3 -3
- package/dist/assets/shared-assets/react-admin/dependencies.ts +0 -74
- package/dist/chunk-MJWUGEMK.js.map +0 -1
- /package/dist/{template-reader-R2JIWUNK.js.map → template-reader-F2VFSDKV.js.map} +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { Editor } from '@tiptap/react'
|
|
4
4
|
import { useTiptapEditor } from '@admin/hooks/content-editor/use-tiptap-editor'
|
|
5
|
-
// --- Lib ---
|
|
6
5
|
import {
|
|
7
6
|
findNodePosition,
|
|
8
7
|
getSelectedBlockNodes,
|
|
@@ -12,8 +11,6 @@ import {
|
|
|
12
11
|
selectionWithinConvertibleTypes
|
|
13
12
|
} from '@admin/utils/editor/tiptap'
|
|
14
13
|
import { NodeSelection, TextSelection } from '@tiptap/pm/state'
|
|
15
|
-
import type { Editor } from '@tiptap/react'
|
|
16
|
-
// --- Icons ---
|
|
17
14
|
import {
|
|
18
15
|
Heading5Icon as HeadingFiveIcon,
|
|
19
16
|
Heading4Icon as HeadingFourIcon,
|
|
@@ -26,26 +23,10 @@ import { useCallback, useEffect, useState } from 'react'
|
|
|
26
23
|
|
|
27
24
|
export type Level = 1 | 2 | 3 | 4 | 5 | 6
|
|
28
25
|
|
|
29
|
-
/**
|
|
30
|
-
* Configuration for the heading functionality
|
|
31
|
-
*/
|
|
32
26
|
export interface UseHeadingConfig {
|
|
33
|
-
/**
|
|
34
|
-
* The Tiptap editor instance.
|
|
35
|
-
*/
|
|
36
27
|
editor?: Editor | null
|
|
37
|
-
/**
|
|
38
|
-
* The heading level.
|
|
39
|
-
*/
|
|
40
28
|
level: Level
|
|
41
|
-
/**
|
|
42
|
-
* Whether the button should hide when heading is not available.
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
29
|
hideWhenUnavailable?: boolean
|
|
46
|
-
/**
|
|
47
|
-
* Callback function called after a successful heading toggle.
|
|
48
|
-
*/
|
|
49
30
|
onToggled?: () => void
|
|
50
31
|
}
|
|
51
32
|
|
|
@@ -67,9 +48,6 @@ export const HEADING_SHORTCUT_KEYS: Record<Level, string> = {
|
|
|
67
48
|
6: 'ctrl+alt+6'
|
|
68
49
|
}
|
|
69
50
|
|
|
70
|
-
/**
|
|
71
|
-
* Checks if heading can be toggled in the current editor state
|
|
72
|
-
*/
|
|
73
51
|
export function canToggle(editor: Editor | null, level?: Level, turnInto: boolean = true): boolean {
|
|
74
52
|
if (!editor || !editor.isEditable) return false
|
|
75
53
|
if (!isNodeInSchema('heading', editor) || isNodeTypeSelected(editor, ['image'])) return false
|
|
@@ -78,7 +56,6 @@ export function canToggle(editor: Editor | null, level?: Level, turnInto: boolea
|
|
|
78
56
|
return level ? editor.can().setNode('heading', { level }) : editor.can().setNode('heading')
|
|
79
57
|
}
|
|
80
58
|
|
|
81
|
-
// Ensure selection is in nodes we're allowed to convert
|
|
82
59
|
if (
|
|
83
60
|
!selectionWithinConvertibleTypes(editor, [
|
|
84
61
|
'paragraph',
|
|
@@ -92,16 +69,11 @@ export function canToggle(editor: Editor | null, level?: Level, turnInto: boolea
|
|
|
92
69
|
)
|
|
93
70
|
return false
|
|
94
71
|
|
|
95
|
-
// Either we can set heading directly on the selection,
|
|
96
|
-
// or we can clear formatting/nodes to arrive at a heading.
|
|
97
72
|
return level
|
|
98
73
|
? editor.can().setNode('heading', { level }) || editor.can().clearNodes()
|
|
99
74
|
: editor.can().setNode('heading') || editor.can().clearNodes()
|
|
100
75
|
}
|
|
101
76
|
|
|
102
|
-
/**
|
|
103
|
-
* Checks if heading is currently active
|
|
104
|
-
*/
|
|
105
77
|
export function isHeadingActive(editor: Editor | null, level?: Level | Level[]): boolean {
|
|
106
78
|
if (!editor || !editor.isEditable) return false
|
|
107
79
|
|
|
@@ -112,9 +84,6 @@ export function isHeadingActive(editor: Editor | null, level?: Level | Level[]):
|
|
|
112
84
|
return level ? editor.isActive('heading', { level }) : editor.isActive('heading')
|
|
113
85
|
}
|
|
114
86
|
|
|
115
|
-
/**
|
|
116
|
-
* Toggles heading in the editor
|
|
117
|
-
*/
|
|
118
87
|
export function toggleHeading(editor: Editor | null, level: Level | Level[]): boolean {
|
|
119
88
|
if (!editor || !editor.isEditable) return false
|
|
120
89
|
|
|
@@ -130,9 +99,6 @@ export function toggleHeading(editor: Editor | null, level: Level | Level[]): bo
|
|
|
130
99
|
|
|
131
100
|
const blocks = getSelectedBlockNodes(editor)
|
|
132
101
|
|
|
133
|
-
// In case a selection contains multiple blocks, we only allow
|
|
134
|
-
// toggling to nide if there's exactly one block selected
|
|
135
|
-
// we also dont block the canToggle since it will fall back to the bottom logic
|
|
136
102
|
const isPossibleToTurnInto =
|
|
137
103
|
selectionWithinConvertibleTypes(editor, [
|
|
138
104
|
'paragraph',
|
|
@@ -144,7 +110,6 @@ export function toggleHeading(editor: Editor | null, level: Level | Level[]): bo
|
|
|
144
110
|
'codeBlock'
|
|
145
111
|
]) && blocks.length === 1
|
|
146
112
|
|
|
147
|
-
// No selection, find the the cursor position
|
|
148
113
|
if (
|
|
149
114
|
(state.selection.empty || state.selection instanceof TextSelection) &&
|
|
150
115
|
isPossibleToTurnInto
|
|
@@ -163,7 +128,6 @@ export function toggleHeading(editor: Editor | null, level: Level | Level[]): bo
|
|
|
163
128
|
const selection = state.selection
|
|
164
129
|
let chain = editor.chain().focus()
|
|
165
130
|
|
|
166
|
-
// Handle NodeSelection
|
|
167
131
|
if (selection instanceof NodeSelection) {
|
|
168
132
|
const firstChild = selection.node.firstChild?.firstChild
|
|
169
133
|
const lastChild = selection.node.lastChild?.lastChild
|
|
@@ -194,9 +158,6 @@ export function toggleHeading(editor: Editor | null, level: Level | Level[]): bo
|
|
|
194
158
|
}
|
|
195
159
|
}
|
|
196
160
|
|
|
197
|
-
/**
|
|
198
|
-
* Determines if the heading button should be shown
|
|
199
|
-
*/
|
|
200
161
|
export function shouldShowButton(props: {
|
|
201
162
|
editor: Editor | null
|
|
202
163
|
level?: Level | Level[]
|
|
@@ -222,7 +183,6 @@ export function shouldShowButton(props: {
|
|
|
222
183
|
return true
|
|
223
184
|
}
|
|
224
185
|
|
|
225
|
-
/** Provides heading commands for ContentEditor controls. */
|
|
226
186
|
export function useHeading(config: UseHeadingConfig) {
|
|
227
187
|
const { editor: providedEditor, level, hideWhenUnavailable = false, onToggled } = config
|
|
228
188
|
|
|
@@ -4,12 +4,6 @@ import { useEffect, useState } from 'react'
|
|
|
4
4
|
|
|
5
5
|
type BreakpointMode = 'min' | 'max'
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Hook to detect whether the current viewport matches a given breakpoint rule.
|
|
9
|
-
* Example:
|
|
10
|
-
* useIsBreakpoint("max", 768) // true when width < 768
|
|
11
|
-
* useIsBreakpoint("min", 1024) // true when width >= 1024
|
|
12
|
-
*/
|
|
13
7
|
export function useIsBreakpoint(mode: BreakpointMode = 'max', breakpoint = 768) {
|
|
14
8
|
const [matches, setMatches] = useState<boolean | undefined>(undefined)
|
|
15
9
|
|
|
@@ -20,10 +14,8 @@ export function useIsBreakpoint(mode: BreakpointMode = 'max', breakpoint = 768)
|
|
|
20
14
|
const mql = window.matchMedia(query)
|
|
21
15
|
const onChange = (e: MediaQueryListEvent) => setMatches(e.matches)
|
|
22
16
|
|
|
23
|
-
// Set initial value
|
|
24
17
|
setMatches(mql.matches)
|
|
25
18
|
|
|
26
|
-
// Add listener
|
|
27
19
|
mql.addEventListener('change', onChange)
|
|
28
20
|
return () => mql.removeEventListener('change', onChange)
|
|
29
21
|
}, [mode, breakpoint])
|
|
@@ -1,55 +1,25 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { Editor } from '@tiptap/react'
|
|
4
4
|
import { useTiptapEditor } from '@admin/hooks/content-editor/use-tiptap-editor'
|
|
5
|
-
// --- Lib ---
|
|
6
5
|
import { isMarkInSchema, isNodeTypeSelected, sanitizeUrl } from '@admin/utils/editor/tiptap'
|
|
7
|
-
import type { Editor } from '@tiptap/react'
|
|
8
|
-
// --- Icons ---
|
|
9
6
|
import { LinkIcon } from 'lucide-react'
|
|
10
7
|
import { useCallback, useEffect, useState } from 'react'
|
|
11
8
|
|
|
12
|
-
/**
|
|
13
|
-
* Configuration for the link popover functionality
|
|
14
|
-
*/
|
|
15
9
|
export interface UseLinkPopoverConfig {
|
|
16
|
-
/**
|
|
17
|
-
* The Tiptap editor instance.
|
|
18
|
-
*/
|
|
19
10
|
editor?: Editor | null
|
|
20
|
-
/**
|
|
21
|
-
* Whether to hide the link popover when not available.
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
11
|
hideWhenUnavailable?: boolean
|
|
25
|
-
/**
|
|
26
|
-
* Callback function called when the link is set.
|
|
27
|
-
*/
|
|
28
12
|
onSetLink?: () => void
|
|
29
13
|
}
|
|
30
14
|
|
|
31
|
-
/**
|
|
32
|
-
* Configuration for the link handler functionality
|
|
33
|
-
*/
|
|
34
15
|
export interface LinkHandlerProps {
|
|
35
|
-
/**
|
|
36
|
-
* The Tiptap editor instance.
|
|
37
|
-
*/
|
|
38
16
|
editor: Editor | null
|
|
39
|
-
/**
|
|
40
|
-
* Callback function called when the link is set.
|
|
41
|
-
*/
|
|
42
17
|
onSetLink?: () => void
|
|
43
18
|
}
|
|
44
19
|
|
|
45
|
-
/**
|
|
46
|
-
* Checks if a link can be set in the current editor state
|
|
47
|
-
*/
|
|
48
20
|
export function canSetLink(editor: Editor | null): boolean {
|
|
49
21
|
if (!editor || !editor.isEditable) return false
|
|
50
22
|
|
|
51
|
-
// The third argument 'true' checks whether the current selection is inside an image caption, and prevents setting a link there
|
|
52
|
-
// If the selection is inside an image caption, we can't set a link
|
|
53
23
|
if (isNodeTypeSelected(editor, ['image'], true)) return false
|
|
54
24
|
try {
|
|
55
25
|
return editor.can().setMark('link')
|
|
@@ -58,17 +28,11 @@ export function canSetLink(editor: Editor | null): boolean {
|
|
|
58
28
|
}
|
|
59
29
|
}
|
|
60
30
|
|
|
61
|
-
/**
|
|
62
|
-
* Checks if a link is currently active in the editor
|
|
63
|
-
*/
|
|
64
31
|
export function isLinkActive(editor: Editor | null): boolean {
|
|
65
32
|
if (!editor || !editor.isEditable) return false
|
|
66
33
|
return editor.isActive('link')
|
|
67
34
|
}
|
|
68
35
|
|
|
69
|
-
/**
|
|
70
|
-
* Determines if the link button should be shown
|
|
71
|
-
*/
|
|
72
36
|
export function shouldShowLinkButton(props: {
|
|
73
37
|
editor: Editor | null
|
|
74
38
|
hideWhenUnavailable: boolean
|
|
@@ -79,17 +43,14 @@ export function shouldShowLinkButton(props: {
|
|
|
79
43
|
|
|
80
44
|
const linkInSchema = isMarkInSchema('link', editor)
|
|
81
45
|
|
|
82
|
-
// If hideWhenUnavailable is false, always show the button (even if disabled)
|
|
83
46
|
if (!hideWhenUnavailable) {
|
|
84
47
|
return true
|
|
85
48
|
}
|
|
86
49
|
|
|
87
|
-
// hideWhenUnavailable is true: hide if link is not in schema
|
|
88
50
|
if (!linkInSchema) {
|
|
89
51
|
return false
|
|
90
52
|
}
|
|
91
53
|
|
|
92
|
-
// hideWhenUnavailable is true: hide if we can't set a link (unless in code block)
|
|
93
54
|
if (!editor.isActive('code')) {
|
|
94
55
|
return canSetLink(editor)
|
|
95
56
|
}
|
|
@@ -97,9 +58,6 @@ export function shouldShowLinkButton(props: {
|
|
|
97
58
|
return true
|
|
98
59
|
}
|
|
99
60
|
|
|
100
|
-
/**
|
|
101
|
-
* Custom hook for handling link operations in a Tiptap editor
|
|
102
|
-
*/
|
|
103
61
|
export function useLinkHandler(props: LinkHandlerProps) {
|
|
104
62
|
const { editor, onSetLink } = props
|
|
105
63
|
const [url, setUrl] = useState<string | null>(null)
|
|
@@ -176,9 +134,6 @@ export function useLinkHandler(props: LinkHandlerProps) {
|
|
|
176
134
|
}
|
|
177
135
|
}
|
|
178
136
|
|
|
179
|
-
/**
|
|
180
|
-
* Custom hook for link popover state management
|
|
181
|
-
*/
|
|
182
137
|
export function useLinkState(props: { editor: Editor | null; hideWhenUnavailable: boolean }) {
|
|
183
138
|
const { editor, hideWhenUnavailable = false } = props
|
|
184
139
|
|
|
@@ -215,43 +170,6 @@ export function useLinkState(props: { editor: Editor | null; hideWhenUnavailable
|
|
|
215
170
|
}
|
|
216
171
|
}
|
|
217
172
|
|
|
218
|
-
/**
|
|
219
|
-
* Main hook that provides link popover functionality for Tiptap editor
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```tsx
|
|
223
|
-
* // Simple usage
|
|
224
|
-
* function MyLinkButton() {
|
|
225
|
-
* const { isVisible, canSet, isActive, Icon, label } = useLinkPopover()
|
|
226
|
-
*
|
|
227
|
-
* if (!isVisible) return null
|
|
228
|
-
*
|
|
229
|
-
* return <button disabled={!canSet}>Link</button>
|
|
230
|
-
* }
|
|
231
|
-
*
|
|
232
|
-
* // Advanced usage with configuration
|
|
233
|
-
* function MyAdvancedLinkButton() {
|
|
234
|
-
* const { isVisible, canSet, isActive, Icon, label } = useLinkPopover({
|
|
235
|
-
* editor: myEditor,
|
|
236
|
-
* hideWhenUnavailable: true,
|
|
237
|
-
* onSetLink: () => console.log('Link set!')
|
|
238
|
-
* })
|
|
239
|
-
*
|
|
240
|
-
* if (!isVisible) return null
|
|
241
|
-
*
|
|
242
|
-
* return (
|
|
243
|
-
* <MyButton
|
|
244
|
-
* disabled={!canSet}
|
|
245
|
-
* aria-label={label}
|
|
246
|
-
* aria-pressed={isActive}
|
|
247
|
-
* >
|
|
248
|
-
* <Icon />
|
|
249
|
-
* {label}
|
|
250
|
-
* </MyButton>
|
|
251
|
-
* )
|
|
252
|
-
* }
|
|
253
|
-
* ```
|
|
254
|
-
*/
|
|
255
173
|
export function useLinkPopover(config?: UseLinkPopoverConfig) {
|
|
256
174
|
const { editor: providedEditor, hideWhenUnavailable = false, onSetLink } = config || {}
|
|
257
175
|
|
package/dist/assets/adapters/next/templates/init/hooks/content-editor/use-list-dropdown-menu.ts
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { ListType } from './use-list'
|
|
4
|
+
import type { Editor } from '@tiptap/react'
|
|
4
5
|
import { useTiptapEditor } from '@admin/hooks/content-editor/use-tiptap-editor'
|
|
5
|
-
// --- Lib ---
|
|
6
6
|
import { isNodeInSchema } from '@admin/utils/editor/tiptap'
|
|
7
|
-
import type { Editor } from '@tiptap/react'
|
|
8
|
-
// --- Icons ---
|
|
9
7
|
import { ListIcon, ListOrderedIcon, ListTodoIcon } from 'lucide-react'
|
|
10
8
|
import { useEffect, useMemo, useState } from 'react'
|
|
11
|
-
import { canToggleList, isListActive,
|
|
9
|
+
import { canToggleList, isListActive, listIcons } from './use-list'
|
|
12
10
|
|
|
13
|
-
/**
|
|
14
|
-
* Configuration for the list dropdown menu functionality
|
|
15
|
-
*/
|
|
16
11
|
export interface UseListDropdownMenuConfig {
|
|
17
|
-
/**
|
|
18
|
-
* The Tiptap editor instance.
|
|
19
|
-
*/
|
|
20
12
|
editor?: Editor | null
|
|
21
|
-
/**
|
|
22
|
-
* The list types to display in the dropdown.
|
|
23
|
-
* @default ["bulletList", "orderedList", "taskList"]
|
|
24
|
-
*/
|
|
25
13
|
types?: ListType[]
|
|
26
|
-
/**
|
|
27
|
-
* Whether the dropdown should be hidden when no list types are available
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
14
|
hideWhenUnavailable?: boolean
|
|
31
15
|
}
|
|
32
16
|
|
|
@@ -92,9 +76,6 @@ export function shouldShowListDropdown(params: {
|
|
|
92
76
|
return true
|
|
93
77
|
}
|
|
94
78
|
|
|
95
|
-
/**
|
|
96
|
-
* Gets the currently active list type from the available types
|
|
97
|
-
*/
|
|
98
79
|
export function getActiveListType(
|
|
99
80
|
editor: Editor | null,
|
|
100
81
|
availableTypes: ListType[]
|
|
@@ -103,45 +84,6 @@ export function getActiveListType(
|
|
|
103
84
|
return availableTypes.find((type) => isListActive(editor, type))
|
|
104
85
|
}
|
|
105
86
|
|
|
106
|
-
/**
|
|
107
|
-
* Custom hook that provides list dropdown menu functionality for Tiptap editor
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```tsx
|
|
111
|
-
* // Simple usage
|
|
112
|
-
* function MyListDropdown() {
|
|
113
|
-
* const {
|
|
114
|
-
* isVisible,
|
|
115
|
-
* activeType,
|
|
116
|
-
* isAnyActive,
|
|
117
|
-
* canToggleAny,
|
|
118
|
-
* filteredLists,
|
|
119
|
-
* } = useListDropdownMenu()
|
|
120
|
-
*
|
|
121
|
-
* if (!isVisible) return null
|
|
122
|
-
*
|
|
123
|
-
* return (
|
|
124
|
-
* <DropdownMenu>
|
|
125
|
-
* // dropdown content
|
|
126
|
-
* </DropdownMenu>
|
|
127
|
-
* )
|
|
128
|
-
* }
|
|
129
|
-
*
|
|
130
|
-
* // Advanced usage with configuration
|
|
131
|
-
* function MyAdvancedListDropdown() {
|
|
132
|
-
* const {
|
|
133
|
-
* isVisible,
|
|
134
|
-
* activeType,
|
|
135
|
-
* } = useListDropdownMenu({
|
|
136
|
-
* editor: myEditor,
|
|
137
|
-
* types: ["bulletList", "orderedList"],
|
|
138
|
-
* hideWhenUnavailable: true,
|
|
139
|
-
* })
|
|
140
|
-
*
|
|
141
|
-
* // component implementation
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
87
|
export function useListDropdownMenu(config?: UseListDropdownMenuConfig) {
|
|
146
88
|
const {
|
|
147
89
|
editor: providedEditor,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { Editor } from '@tiptap/react'
|
|
4
4
|
import { useTiptapEditor } from '@admin/hooks/content-editor/use-tiptap-editor'
|
|
5
|
-
// --- Lib ---
|
|
6
5
|
import {
|
|
7
6
|
findNodePosition,
|
|
8
7
|
getSelectedBlockNodes,
|
|
@@ -12,33 +11,15 @@ import {
|
|
|
12
11
|
selectionWithinConvertibleTypes
|
|
13
12
|
} from '@admin/utils/editor/tiptap'
|
|
14
13
|
import { NodeSelection, TextSelection } from '@tiptap/pm/state'
|
|
15
|
-
import type { Editor } from '@tiptap/react'
|
|
16
|
-
// --- Icons ---
|
|
17
14
|
import { ListIcon, ListOrderedIcon, ListTodoIcon } from 'lucide-react'
|
|
18
15
|
import { useCallback, useEffect, useState } from 'react'
|
|
19
16
|
|
|
20
17
|
export type ListType = 'bulletList' | 'orderedList' | 'taskList'
|
|
21
18
|
|
|
22
|
-
/**
|
|
23
|
-
* Configuration for the list functionality
|
|
24
|
-
*/
|
|
25
19
|
export interface UseListConfig {
|
|
26
|
-
/**
|
|
27
|
-
* The Tiptap editor instance.
|
|
28
|
-
*/
|
|
29
20
|
editor?: Editor | null
|
|
30
|
-
/**
|
|
31
|
-
* The type of list to toggle.
|
|
32
|
-
*/
|
|
33
21
|
type: ListType
|
|
34
|
-
/**
|
|
35
|
-
* Whether the button should hide when list is not available.
|
|
36
|
-
* @default false
|
|
37
|
-
*/
|
|
38
22
|
hideWhenUnavailable?: boolean
|
|
39
|
-
/**
|
|
40
|
-
* Callback function called after a successful toggle.
|
|
41
|
-
*/
|
|
42
23
|
onToggled?: () => void
|
|
43
24
|
}
|
|
44
25
|
|
|
@@ -60,9 +41,6 @@ export const LIST_SHORTCUT_KEYS: Record<ListType, string> = {
|
|
|
60
41
|
taskList: 'mod+shift+9'
|
|
61
42
|
}
|
|
62
43
|
|
|
63
|
-
/**
|
|
64
|
-
* Checks if a list can be toggled in the current editor state
|
|
65
|
-
*/
|
|
66
44
|
export function canToggleList(
|
|
67
45
|
editor: Editor | null,
|
|
68
46
|
type: ListType,
|
|
@@ -84,7 +62,6 @@ export function canToggleList(
|
|
|
84
62
|
}
|
|
85
63
|
}
|
|
86
64
|
|
|
87
|
-
// Ensure selection is in nodes we're allowed to convert
|
|
88
65
|
if (
|
|
89
66
|
!selectionWithinConvertibleTypes(editor, [
|
|
90
67
|
'paragraph',
|
|
@@ -98,8 +75,6 @@ export function canToggleList(
|
|
|
98
75
|
)
|
|
99
76
|
return false
|
|
100
77
|
|
|
101
|
-
// Either we can set list directly on the selection,
|
|
102
|
-
// or we can clear formatting/nodes to arrive at a list.
|
|
103
78
|
switch (type) {
|
|
104
79
|
case 'bulletList':
|
|
105
80
|
return editor.can().toggleBulletList() || editor.can().clearNodes()
|
|
@@ -112,9 +87,6 @@ export function canToggleList(
|
|
|
112
87
|
}
|
|
113
88
|
}
|
|
114
89
|
|
|
115
|
-
/**
|
|
116
|
-
* Checks if list is currently active
|
|
117
|
-
*/
|
|
118
90
|
export function isListActive(editor: Editor | null, type: ListType): boolean {
|
|
119
91
|
if (!editor || !editor.isEditable) return false
|
|
120
92
|
|
|
@@ -130,9 +102,6 @@ export function isListActive(editor: Editor | null, type: ListType): boolean {
|
|
|
130
102
|
}
|
|
131
103
|
}
|
|
132
104
|
|
|
133
|
-
/**
|
|
134
|
-
* Toggles list in the editor
|
|
135
|
-
*/
|
|
136
105
|
export function toggleList(editor: Editor | null, type: ListType): boolean {
|
|
137
106
|
if (!editor || !editor.isEditable) return false
|
|
138
107
|
if (!canToggleList(editor, type)) return false
|
|
@@ -144,9 +113,6 @@ export function toggleList(editor: Editor | null, type: ListType): boolean {
|
|
|
144
113
|
|
|
145
114
|
const blocks = getSelectedBlockNodes(editor)
|
|
146
115
|
|
|
147
|
-
// In case a selection contains multiple blocks, we only allow
|
|
148
|
-
// toggling to nide if there's exactly one block selected
|
|
149
|
-
// we also dont block the canToggle since it will fall back to the bottom logic
|
|
150
116
|
const isPossibleToTurnInto =
|
|
151
117
|
selectionWithinConvertibleTypes(editor, [
|
|
152
118
|
'paragraph',
|
|
@@ -158,7 +124,6 @@ export function toggleList(editor: Editor | null, type: ListType): boolean {
|
|
|
158
124
|
'codeBlock'
|
|
159
125
|
]) && blocks.length === 1
|
|
160
126
|
|
|
161
|
-
// No selection, find the the cursor position
|
|
162
127
|
if (
|
|
163
128
|
(state.selection.empty || state.selection instanceof TextSelection) &&
|
|
164
129
|
isPossibleToTurnInto
|
|
@@ -178,7 +143,6 @@ export function toggleList(editor: Editor | null, type: ListType): boolean {
|
|
|
178
143
|
|
|
179
144
|
let chain = editor.chain().focus()
|
|
180
145
|
|
|
181
|
-
// Handle NodeSelection
|
|
182
146
|
if (selection instanceof NodeSelection) {
|
|
183
147
|
const firstChild = selection.node.firstChild?.firstChild
|
|
184
148
|
const lastChild = selection.node.lastChild?.lastChild
|
|
@@ -194,10 +158,8 @@ export function toggleList(editor: Editor | null, type: ListType): boolean {
|
|
|
194
158
|
}
|
|
195
159
|
|
|
196
160
|
if (editor.isActive(type)) {
|
|
197
|
-
// Unwrap list
|
|
198
161
|
chain.liftListItem('listItem').lift('bulletList').lift('orderedList').lift('taskList').run()
|
|
199
162
|
} else {
|
|
200
|
-
// Wrap in specific list type
|
|
201
163
|
const toggleMap: Record<ListType, () => typeof chain> = {
|
|
202
164
|
bulletList: () => chain.toggleBulletList(),
|
|
203
165
|
orderedList: () => chain.toggleOrderedList(),
|
|
@@ -218,9 +180,6 @@ export function toggleList(editor: Editor | null, type: ListType): boolean {
|
|
|
218
180
|
}
|
|
219
181
|
}
|
|
220
182
|
|
|
221
|
-
/**
|
|
222
|
-
* Determines if the list button should be shown
|
|
223
|
-
*/
|
|
224
183
|
export function shouldShowButton(props: {
|
|
225
184
|
editor: Editor | null
|
|
226
185
|
type: ListType
|
|
@@ -243,7 +202,6 @@ export function shouldShowButton(props: {
|
|
|
243
202
|
return true
|
|
244
203
|
}
|
|
245
204
|
|
|
246
|
-
/** Provides list commands for ContentEditor controls. */
|
|
247
205
|
export function useList(config: UseListConfig) {
|
|
248
206
|
const { editor: providedEditor, type, hideWhenUnavailable = false, onToggled } = config
|
|
249
207
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { Editor } from '@tiptap/react'
|
|
4
4
|
import { useTiptapEditor } from '@admin/hooks/content-editor/use-tiptap-editor'
|
|
5
|
-
// --- Lib ---
|
|
6
5
|
import { isMarkInSchema, isNodeTypeSelected } from '@admin/utils/editor/tiptap'
|
|
7
|
-
import type { Editor } from '@tiptap/react'
|
|
8
|
-
// --- Icons ---
|
|
9
6
|
import {
|
|
10
7
|
BoldIcon,
|
|
11
8
|
Code2Icon,
|
|
@@ -17,26 +14,10 @@ import { useCallback, useEffect, useState } from 'react'
|
|
|
17
14
|
|
|
18
15
|
export type Mark = 'bold' | 'italic' | 'strike' | 'code' | 'underline'
|
|
19
16
|
|
|
20
|
-
/**
|
|
21
|
-
* Configuration for the mark functionality
|
|
22
|
-
*/
|
|
23
17
|
export interface UseMarkConfig {
|
|
24
|
-
/**
|
|
25
|
-
* The Tiptap editor instance.
|
|
26
|
-
*/
|
|
27
18
|
editor?: Editor | null
|
|
28
|
-
/**
|
|
29
|
-
* The type of mark to toggle
|
|
30
|
-
*/
|
|
31
19
|
type: Mark
|
|
32
|
-
/**
|
|
33
|
-
* Whether the button should hide when mark is not available.
|
|
34
|
-
* @default false
|
|
35
|
-
*/
|
|
36
20
|
hideWhenUnavailable?: boolean
|
|
37
|
-
/**
|
|
38
|
-
* Callback function called after a successful mark toggle.
|
|
39
|
-
*/
|
|
40
21
|
onToggled?: () => void
|
|
41
22
|
}
|
|
42
23
|
|
|
@@ -56,9 +37,6 @@ export const MARK_SHORTCUT_KEYS: Record<Mark, string> = {
|
|
|
56
37
|
code: 'mod+e'
|
|
57
38
|
}
|
|
58
39
|
|
|
59
|
-
/**
|
|
60
|
-
* Checks if a mark can be toggled in the current editor state
|
|
61
|
-
*/
|
|
62
40
|
export function canToggleMark(editor: Editor | null, type: Mark): boolean {
|
|
63
41
|
if (!editor || !editor.isEditable) return false
|
|
64
42
|
if (!isMarkInSchema(type, editor) || isNodeTypeSelected(editor, ['image'])) return false
|
|
@@ -66,17 +44,11 @@ export function canToggleMark(editor: Editor | null, type: Mark): boolean {
|
|
|
66
44
|
return editor.can().toggleMark(type)
|
|
67
45
|
}
|
|
68
46
|
|
|
69
|
-
/**
|
|
70
|
-
* Checks if a mark is currently active
|
|
71
|
-
*/
|
|
72
47
|
export function isMarkActive(editor: Editor | null, type: Mark): boolean {
|
|
73
48
|
if (!editor || !editor.isEditable) return false
|
|
74
49
|
return editor.isActive(type)
|
|
75
50
|
}
|
|
76
51
|
|
|
77
|
-
/**
|
|
78
|
-
* Toggles a mark in the editor
|
|
79
|
-
*/
|
|
80
52
|
export function toggleMark(editor: Editor | null, type: Mark): boolean {
|
|
81
53
|
if (!editor || !editor.isEditable) return false
|
|
82
54
|
if (!canToggleMark(editor, type)) return false
|
|
@@ -84,9 +56,6 @@ export function toggleMark(editor: Editor | null, type: Mark): boolean {
|
|
|
84
56
|
return editor.chain().focus().toggleMark(type).run()
|
|
85
57
|
}
|
|
86
58
|
|
|
87
|
-
/**
|
|
88
|
-
* Determines if the mark button should be shown
|
|
89
|
-
*/
|
|
90
59
|
export function shouldShowButton(props: {
|
|
91
60
|
editor: Editor | null
|
|
92
61
|
type: Mark
|
|
@@ -109,50 +78,10 @@ export function shouldShowButton(props: {
|
|
|
109
78
|
return true
|
|
110
79
|
}
|
|
111
80
|
|
|
112
|
-
/**
|
|
113
|
-
* Gets the formatted mark name
|
|
114
|
-
*/
|
|
115
81
|
export function getFormattedMarkName(type: Mark): string {
|
|
116
82
|
return type.charAt(0).toUpperCase() + type.slice(1)
|
|
117
83
|
}
|
|
118
84
|
|
|
119
|
-
/**
|
|
120
|
-
* Custom hook that provides mark functionality for Tiptap editor
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```tsx
|
|
124
|
-
* // Simple usage
|
|
125
|
-
* function MySimpleBoldButton() {
|
|
126
|
-
* const { isVisible, handleMark } = useMark({ type: "bold" })
|
|
127
|
-
*
|
|
128
|
-
* if (!isVisible) return null
|
|
129
|
-
*
|
|
130
|
-
* return <button onClick={handleMark}>Bold</button>
|
|
131
|
-
* }
|
|
132
|
-
*
|
|
133
|
-
* // Advanced usage with configuration
|
|
134
|
-
* function MyAdvancedItalicButton() {
|
|
135
|
-
* const { isVisible, handleMark, label, isActive } = useMark({
|
|
136
|
-
* editor: myEditor,
|
|
137
|
-
* type: "italic",
|
|
138
|
-
* hideWhenUnavailable: true,
|
|
139
|
-
* onToggled: () => console.log('Mark toggled!')
|
|
140
|
-
* })
|
|
141
|
-
*
|
|
142
|
-
* if (!isVisible) return null
|
|
143
|
-
*
|
|
144
|
-
* return (
|
|
145
|
-
* <MyButton
|
|
146
|
-
* onClick={handleMark}
|
|
147
|
-
* aria-pressed={isActive}
|
|
148
|
-
* aria-label={label}
|
|
149
|
-
* >
|
|
150
|
-
* Italic
|
|
151
|
-
* </MyButton>
|
|
152
|
-
* )
|
|
153
|
-
* }
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
85
|
export function useMark(config: UseMarkConfig) {
|
|
157
86
|
const { editor: providedEditor, type, hideWhenUnavailable = false, onToggled } = config
|
|
158
87
|
|