@revealui/core 0.0.1-pre.3 → 0.2.0
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/LICENSE +22 -202
- package/README.md +29 -180
- package/dist/api/compression.d.ts +83 -0
- package/dist/api/compression.d.ts.map +1 -0
- package/dist/api/compression.js +233 -0
- package/dist/api/payload-optimization.d.ts +138 -0
- package/dist/api/payload-optimization.d.ts.map +1 -0
- package/dist/api/payload-optimization.js +320 -0
- package/dist/api/rate-limit.d.ts +113 -0
- package/dist/api/rate-limit.d.ts.map +1 -0
- package/dist/api/rate-limit.js +301 -0
- package/dist/api/response-cache.d.ts +125 -0
- package/dist/api/response-cache.d.ts.map +1 -0
- package/dist/api/response-cache.js +335 -0
- package/dist/api/rest.d.ts +54 -0
- package/dist/api/rest.d.ts.map +1 -0
- package/dist/api/rest.js +464 -0
- package/dist/auth/access.d.ts +25 -0
- package/dist/auth/access.d.ts.map +1 -0
- package/dist/auth/access.js +20 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/cache/query-cache.d.ts +98 -0
- package/dist/cache/query-cache.d.ts.map +1 -0
- package/dist/cache/query-cache.js +260 -0
- package/dist/caching/app-cache.d.ts +237 -0
- package/dist/caching/app-cache.d.ts.map +1 -0
- package/dist/caching/app-cache.js +430 -0
- package/dist/caching/cdn-config.d.ts +155 -0
- package/dist/caching/cdn-config.d.ts.map +1 -0
- package/dist/caching/cdn-config.js +425 -0
- package/dist/caching/edge-cache.d.ts +177 -0
- package/dist/caching/edge-cache.d.ts.map +1 -0
- package/dist/caching/edge-cache.js +381 -0
- package/dist/caching/service-worker.d.ts +165 -0
- package/dist/caching/service-worker.d.ts.map +1 -0
- package/dist/caching/service-worker.js +437 -0
- package/dist/client/admin/RichText.d.ts +12 -0
- package/dist/client/admin/RichText.d.ts.map +1 -0
- package/dist/client/admin/RichText.js +5 -0
- package/dist/client/admin/components/AdminDashboard.d.ts +7 -0
- package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -0
- package/dist/client/admin/components/AdminDashboard.js +318 -0
- package/dist/client/admin/components/CollectionList.d.ts +16 -0
- package/dist/client/admin/components/CollectionList.d.ts.map +1 -0
- package/dist/client/admin/components/CollectionList.js +67 -0
- package/dist/client/admin/components/DocumentForm.d.ts +11 -0
- package/dist/client/admin/components/DocumentForm.d.ts.map +1 -0
- package/dist/client/admin/components/DocumentForm.js +99 -0
- package/dist/client/admin/components/GlobalForm.d.ts +11 -0
- package/dist/client/admin/components/GlobalForm.d.ts.map +1 -0
- package/dist/client/admin/components/GlobalForm.js +74 -0
- package/dist/client/admin/i18n/en.d.ts +25 -0
- package/dist/client/admin/i18n/en.d.ts.map +1 -0
- package/dist/client/admin/i18n/en.js +25 -0
- package/dist/client/admin/index.d.ts +10 -0
- package/dist/client/admin/index.d.ts.map +1 -0
- package/dist/client/admin/index.js +10 -0
- package/dist/client/admin/layout.d.ts +10 -0
- package/dist/client/admin/layout.d.ts.map +1 -0
- package/dist/client/admin/layout.js +6 -0
- package/dist/client/admin/page.d.ts +38 -0
- package/dist/client/admin/page.d.ts.map +1 -0
- package/dist/client/admin/page.js +15 -0
- package/dist/client/admin/utils/apiClient.d.ts +110 -0
- package/dist/client/admin/utils/apiClient.d.ts.map +1 -0
- package/dist/client/admin/utils/apiClient.js +220 -0
- package/dist/client/admin/utils/auth.d.ts +27 -0
- package/dist/client/admin/utils/auth.d.ts.map +1 -0
- package/dist/client/admin/utils/auth.js +58 -0
- package/dist/client/admin/utils/index.d.ts +6 -0
- package/dist/client/admin/utils/index.d.ts.map +1 -0
- package/dist/client/admin/utils/index.js +5 -0
- package/dist/client/admin/utils/serializeConfig.d.ts +7 -0
- package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -0
- package/dist/client/admin/utils/serializeConfig.js +35 -0
- package/dist/client/hooks.d.ts +18 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +29 -0
- package/dist/client/http/client.d.ts +15 -0
- package/dist/client/http/client.d.ts.map +1 -0
- package/dist/client/http/client.js +49 -0
- package/dist/client/http/fetchBanner.d.ts +18 -0
- package/dist/client/http/fetchBanner.d.ts.map +1 -0
- package/dist/client/http/fetchBanner.js +44 -0
- package/dist/client/http/fetchCard.d.ts +18 -0
- package/dist/client/http/fetchCard.d.ts.map +1 -0
- package/dist/client/http/fetchCard.js +46 -0
- package/dist/client/http/fetchEvents.d.ts +18 -0
- package/dist/client/http/fetchEvents.d.ts.map +1 -0
- package/dist/client/http/fetchEvents.js +44 -0
- package/dist/client/http/fetchHero.d.ts +17 -0
- package/dist/client/http/fetchHero.d.ts.map +1 -0
- package/dist/client/http/fetchHero.js +55 -0
- package/dist/client/http/fetchMainInfos.d.ts +17 -0
- package/dist/client/http/fetchMainInfos.d.ts.map +1 -0
- package/dist/client/http/fetchMainInfos.js +44 -0
- package/dist/client/http/fetchVideos.d.ts +13 -0
- package/dist/client/http/fetchVideos.d.ts.map +1 -0
- package/dist/client/http/fetchVideos.js +36 -0
- package/dist/client/http/index.d.ts +19 -0
- package/dist/client/http/index.d.ts.map +1 -0
- package/dist/client/http/index.js +11 -0
- package/dist/client/index.d.ts +12 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +15 -0
- package/dist/client/richtext/RichTextEditor.d.ts +48 -0
- package/dist/client/richtext/RichTextEditor.d.ts.map +1 -0
- package/dist/client/richtext/RichTextEditor.js +360 -0
- package/dist/client/richtext/components/ImageNodeComponent.d.ts +9 -0
- package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -0
- package/dist/client/richtext/components/ImageNodeComponent.js +99 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts +11 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -0
- package/dist/client/richtext/components/ImageUploadButton.js +103 -0
- package/dist/client/richtext/index.d.ts +92 -0
- package/dist/client/richtext/index.d.ts.map +1 -0
- package/dist/client/richtext/index.js +74 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts +20 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.js +29 -0
- package/dist/client/richtext/nodes/ImageNode.d.ts +51 -0
- package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -0
- package/dist/client/richtext/nodes/ImageNode.js +95 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts +13 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.js +8 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts +4 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.js +50 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts +7 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +248 -0
- package/dist/client/richtext/plugins/ImagePlugin.d.ts +3 -0
- package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/ImagePlugin.js +73 -0
- package/dist/client/richtext/plugins/PastePlugin.d.ts +2 -0
- package/dist/client/richtext/plugins/PastePlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/PastePlugin.js +36 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts +8 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.js +204 -0
- package/dist/client/ui/index.d.ts +111 -0
- package/dist/client/ui/index.d.ts.map +1 -0
- package/dist/client/ui/index.js +130 -0
- package/dist/collections/CollectionOperations.d.ts +27 -0
- package/dist/collections/CollectionOperations.d.ts.map +1 -0
- package/dist/collections/CollectionOperations.js +34 -0
- package/dist/collections/hooks.d.ts +11 -0
- package/dist/collections/hooks.d.ts.map +1 -0
- package/dist/collections/hooks.js +35 -0
- package/dist/collections/index.d.ts +2 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +1 -0
- package/dist/collections/operations/create.d.ts +10 -0
- package/dist/collections/operations/create.d.ts.map +1 -0
- package/dist/collections/operations/create.js +101 -0
- package/dist/collections/operations/delete.d.ts +10 -0
- package/dist/collections/operations/delete.d.ts.map +1 -0
- package/dist/collections/operations/delete.js +16 -0
- package/dist/collections/operations/fieldHooks.d.ts +21 -0
- package/dist/collections/operations/fieldHooks.d.ts.map +1 -0
- package/dist/collections/operations/fieldHooks.js +51 -0
- package/dist/collections/operations/find.d.ts +10 -0
- package/dist/collections/operations/find.d.ts.map +1 -0
- package/dist/collections/operations/find.js +124 -0
- package/dist/collections/operations/findById.d.ts +15 -0
- package/dist/collections/operations/findById.d.ts.map +1 -0
- package/dist/collections/operations/findById.js +59 -0
- package/dist/collections/operations/update.d.ts +10 -0
- package/dist/collections/operations/update.d.ts.map +1 -0
- package/dist/collections/operations/update.js +134 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +61 -0
- package/dist/config/runtime.d.ts +22 -0
- package/dist/config/runtime.d.ts.map +1 -0
- package/dist/config/runtime.js +32 -0
- package/dist/config/utils.d.ts +12 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +20 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +6 -0
- package/dist/database/ssl-config.d.ts +9 -0
- package/dist/database/ssl-config.d.ts.map +1 -0
- package/dist/database/ssl-config.js +7 -0
- package/dist/database/type-adapter.d.ts +113 -0
- package/dist/database/type-adapter.d.ts.map +1 -0
- package/dist/database/type-adapter.js +97 -0
- package/dist/database/universal-postgres.d.ts +45 -0
- package/dist/database/universal-postgres.d.ts.map +1 -0
- package/dist/database/universal-postgres.js +526 -0
- package/dist/dataloader.d.ts +26 -0
- package/dist/dataloader.d.ts.map +1 -0
- package/dist/dataloader.js +162 -0
- package/dist/error-handling/circuit-breaker.d.ts +262 -0
- package/dist/error-handling/circuit-breaker.d.ts.map +1 -0
- package/dist/error-handling/circuit-breaker.js +542 -0
- package/dist/error-handling/error-boundary.d.ts +94 -0
- package/dist/error-handling/error-boundary.d.ts.map +1 -0
- package/dist/error-handling/error-boundary.js +285 -0
- package/dist/error-handling/error-reporter.d.ts +213 -0
- package/dist/error-handling/error-reporter.d.ts.map +1 -0
- package/dist/error-handling/error-reporter.js +506 -0
- package/dist/error-handling/fallback-components.d.ts +131 -0
- package/dist/error-handling/fallback-components.d.ts.map +1 -0
- package/dist/error-handling/fallback-components.js +371 -0
- package/dist/error-handling/index.d.ts +16 -0
- package/dist/error-handling/index.d.ts.map +1 -0
- package/dist/error-handling/index.js +15 -0
- package/dist/error-handling/retry.d.ts +194 -0
- package/dist/error-handling/retry.d.ts.map +1 -0
- package/dist/error-handling/retry.js +450 -0
- package/dist/errors/index.d.ts +23 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +40 -0
- package/dist/factories/builders.d.ts +50 -0
- package/dist/factories/builders.d.ts.map +1 -0
- package/dist/factories/builders.js +77 -0
- package/dist/factories/index.d.ts +2 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +1 -0
- package/dist/features.d.ts +82 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +89 -0
- package/dist/fieldTraversal.d.ts +26 -0
- package/dist/fieldTraversal.d.ts.map +1 -0
- package/dist/fieldTraversal.js +132 -0
- package/dist/fields/config/types.d.ts +48 -0
- package/dist/fields/config/types.d.ts.map +1 -0
- package/dist/fields/config/types.js +20 -0
- package/dist/fields/getDefaultValue.d.ts +16 -0
- package/dist/fields/getDefaultValue.d.ts.map +1 -0
- package/dist/fields/getDefaultValue.js +20 -0
- package/dist/fields/getFieldPaths.d.ts +25 -0
- package/dist/fields/getFieldPaths.d.ts.map +1 -0
- package/dist/fields/getFieldPaths.js +23 -0
- package/dist/fields/hooks/afterRead/index.d.ts +36 -0
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/index.js +70 -0
- package/dist/fields/hooks/afterRead/promise.d.ts +46 -0
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/promise.js +178 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +44 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/traverseFields.js +37 -0
- package/dist/generated/agents/index.d.ts +8 -0
- package/dist/generated/agents/index.d.ts.map +1 -0
- package/dist/generated/agents/index.js +7 -0
- package/dist/generated/components/index.d.ts +8 -0
- package/dist/generated/components/index.d.ts.map +1 -0
- package/dist/generated/components/index.js +7 -0
- package/dist/generated/functions/index.d.ts +8 -0
- package/dist/generated/functions/index.d.ts.map +1 -0
- package/dist/generated/functions/index.js +7 -0
- package/dist/generated/hooks/index.d.ts +8 -0
- package/dist/generated/hooks/index.d.ts.map +1 -0
- package/dist/generated/hooks/index.js +7 -0
- package/dist/generated/index.d.ts +10 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +9 -0
- package/dist/generated/plans/index.d.ts +8 -0
- package/dist/generated/plans/index.d.ts.map +1 -0
- package/dist/generated/plans/index.js +7 -0
- package/dist/generated/prompts/index.d.ts +8 -0
- package/dist/generated/prompts/index.d.ts.map +1 -0
- package/dist/generated/prompts/index.js +7 -0
- package/dist/generated/tools/index.d.ts +8 -0
- package/dist/generated/tools/index.d.ts.map +1 -0
- package/dist/generated/tools/index.js +7 -0
- package/dist/generated/types/cms.d.ts +1766 -0
- package/dist/generated/types/cms.d.ts.map +1 -0
- package/dist/generated/types/cms.js +12 -0
- package/dist/generated/types/index.d.ts +19 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +28 -0
- package/dist/generated/types/neon.d.ts +11 -0
- package/dist/generated/types/neon.d.ts.map +1 -0
- package/dist/generated/types/neon.js +11 -0
- package/dist/generated/types/supabase.d.ts +193 -0
- package/dist/generated/types/supabase.d.ts.map +1 -0
- package/dist/generated/types/supabase.js +5 -0
- package/dist/globals/GlobalOperations.d.ts +24 -0
- package/dist/globals/GlobalOperations.d.ts.map +1 -0
- package/dist/globals/GlobalOperations.js +149 -0
- package/dist/globals/index.d.ts +2 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/index.js +1 -0
- package/dist/index.d.ts +64 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -33
- package/dist/instance/RevealUIInstance.d.ts +6 -0
- package/dist/instance/RevealUIInstance.d.ts.map +1 -0
- package/dist/instance/RevealUIInstance.js +312 -0
- package/dist/instance/index.d.ts +3 -0
- package/dist/instance/index.d.ts.map +1 -0
- package/dist/instance/index.js +2 -0
- package/dist/instance/logger.d.ts +31 -0
- package/dist/instance/logger.d.ts.map +1 -0
- package/dist/instance/logger.js +42 -0
- package/dist/instance/methods/create.d.ts +10 -0
- package/dist/instance/methods/create.d.ts.map +1 -0
- package/dist/instance/methods/create.js +38 -0
- package/dist/instance/methods/delete.d.ts +10 -0
- package/dist/instance/methods/delete.d.ts.map +1 -0
- package/dist/instance/methods/delete.js +24 -0
- package/dist/instance/methods/find.d.ts +10 -0
- package/dist/instance/methods/find.d.ts.map +1 -0
- package/dist/instance/methods/find.js +23 -0
- package/dist/instance/methods/findById.d.ts +13 -0
- package/dist/instance/methods/findById.d.ts.map +1 -0
- package/dist/instance/methods/findById.js +23 -0
- package/dist/instance/methods/hooks.d.ts +14 -0
- package/dist/instance/methods/hooks.d.ts.map +1 -0
- package/dist/instance/methods/hooks.js +32 -0
- package/dist/instance/methods/update.d.ts +10 -0
- package/dist/instance/methods/update.d.ts.map +1 -0
- package/dist/instance/methods/update.js +42 -0
- package/dist/license.d.ts +73 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +157 -0
- package/dist/monitoring/alerts.d.ts +118 -0
- package/dist/monitoring/alerts.d.ts.map +1 -0
- package/dist/monitoring/alerts.js +324 -0
- package/dist/monitoring/cleanup-manager.d.ts +71 -0
- package/dist/monitoring/cleanup-manager.d.ts.map +1 -0
- package/dist/monitoring/cleanup-manager.js +226 -0
- package/dist/monitoring/health-monitor.d.ts +22 -0
- package/dist/monitoring/health-monitor.d.ts.map +1 -0
- package/dist/monitoring/health-monitor.js +142 -0
- package/dist/monitoring/index.d.ts +14 -0
- package/dist/monitoring/index.d.ts.map +1 -0
- package/dist/monitoring/index.js +17 -0
- package/dist/monitoring/process-registry.d.ts +97 -0
- package/dist/monitoring/process-registry.d.ts.map +1 -0
- package/dist/monitoring/process-registry.js +222 -0
- package/dist/monitoring/query-monitor.d.ts +153 -0
- package/dist/monitoring/query-monitor.d.ts.map +1 -0
- package/dist/monitoring/query-monitor.js +209 -0
- package/dist/monitoring/types.d.ts +231 -0
- package/dist/monitoring/types.d.ts.map +1 -0
- package/dist/monitoring/types.js +42 -0
- package/dist/monitoring/zombie-detector.d.ts +81 -0
- package/dist/monitoring/zombie-detector.d.ts.map +1 -0
- package/dist/monitoring/zombie-detector.js +231 -0
- package/dist/nextjs/index.d.ts +4 -0
- package/dist/nextjs/index.d.ts.map +1 -0
- package/dist/nextjs/index.js +3 -0
- package/dist/nextjs/utilities.d.ts +5 -0
- package/dist/nextjs/utilities.d.ts.map +1 -0
- package/dist/nextjs/utilities.js +16 -0
- package/dist/nextjs/withRevealUI.d.ts +20 -0
- package/dist/nextjs/withRevealUI.d.ts.map +1 -0
- package/dist/nextjs/withRevealUI.js +181 -0
- package/dist/observability/alerts.d.ts +138 -0
- package/dist/observability/alerts.d.ts.map +1 -0
- package/dist/observability/alerts.js +390 -0
- package/dist/observability/health-check.d.ts +95 -0
- package/dist/observability/health-check.d.ts.map +1 -0
- package/dist/observability/health-check.js +345 -0
- package/dist/observability/index.d.ts +12 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/logger.d.ts +47 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +140 -0
- package/dist/observability/metrics.d.ts +205 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +429 -0
- package/dist/observability/tracing.d.ts +149 -0
- package/dist/observability/tracing.d.ts.map +1 -0
- package/dist/observability/tracing.js +381 -0
- package/dist/optimization/asset-optimizer.d.ts +202 -0
- package/dist/optimization/asset-optimizer.d.ts.map +1 -0
- package/dist/optimization/asset-optimizer.js +312 -0
- package/dist/optimization/build-optimizer.d.ts +202 -0
- package/dist/optimization/build-optimizer.d.ts.map +1 -0
- package/dist/optimization/build-optimizer.js +271 -0
- package/dist/optimization/bundle-analyzer.d.ts +98 -0
- package/dist/optimization/bundle-analyzer.d.ts.map +1 -0
- package/dist/optimization/bundle-analyzer.js +322 -0
- package/dist/optimization/code-splitting.d.ts +144 -0
- package/dist/optimization/code-splitting.d.ts.map +1 -0
- package/dist/optimization/code-splitting.js +290 -0
- package/dist/plugin/index.d.ts +12 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +4 -0
- package/dist/plugins/form-builder.d.ts +115 -0
- package/dist/plugins/form-builder.d.ts.map +1 -0
- package/dist/plugins/form-builder.js +239 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/nested-docs.d.ts +8 -0
- package/dist/plugins/nested-docs.d.ts.map +1 -0
- package/dist/plugins/nested-docs.js +67 -0
- package/dist/plugins/redirects.d.ts +17 -0
- package/dist/plugins/redirects.d.ts.map +1 -0
- package/dist/plugins/redirects.js +62 -0
- package/dist/queries/index.d.ts +2 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +1 -0
- package/dist/queries/queryBuilder.d.ts +47 -0
- package/dist/queries/queryBuilder.d.ts.map +1 -0
- package/dist/queries/queryBuilder.js +252 -0
- package/dist/relationships/analyzer.d.ts +39 -0
- package/dist/relationships/analyzer.d.ts.map +1 -0
- package/dist/relationships/analyzer.js +127 -0
- package/dist/relationships/index.d.ts +3 -0
- package/dist/relationships/index.d.ts.map +1 -0
- package/dist/relationships/index.js +2 -0
- package/dist/relationships/populate-helpers.d.ts +104 -0
- package/dist/relationships/populate-helpers.d.ts.map +1 -0
- package/dist/relationships/populate-helpers.js +187 -0
- package/dist/relationships/population.d.ts +42 -0
- package/dist/relationships/population.d.ts.map +1 -0
- package/dist/relationships/population.js +188 -0
- package/dist/revealui.d.ts +46 -0
- package/dist/revealui.d.ts.map +1 -0
- package/dist/revealui.js +92 -0
- package/dist/richtext/exports/client/rcc.d.ts +37 -0
- package/dist/richtext/exports/client/rcc.d.ts.map +1 -0
- package/dist/richtext/exports/client/rcc.js +182 -0
- package/dist/richtext/exports/server/rsc.d.ts +117 -0
- package/dist/richtext/exports/server/rsc.d.ts.map +1 -0
- package/dist/richtext/exports/server/rsc.js +288 -0
- package/dist/richtext/index.d.ts +161 -0
- package/dist/richtext/index.d.ts.map +1 -0
- package/dist/richtext/index.js +243 -0
- package/dist/richtext/lexical.d.ts +23 -0
- package/dist/richtext/lexical.d.ts.map +1 -0
- package/dist/richtext/lexical.js +35 -0
- package/dist/security/audit.d.ts +188 -0
- package/dist/security/audit.d.ts.map +1 -0
- package/dist/security/audit.js +431 -0
- package/dist/security/auth.d.ts +241 -0
- package/dist/security/auth.d.ts.map +1 -0
- package/dist/security/auth.js +474 -0
- package/dist/security/authorization.d.ts +235 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/authorization.js +434 -0
- package/dist/security/encryption.d.ts +214 -0
- package/dist/security/encryption.d.ts.map +1 -0
- package/dist/security/encryption.js +506 -0
- package/dist/security/gdpr.d.ts +300 -0
- package/dist/security/gdpr.d.ts.map +1 -0
- package/dist/security/gdpr.js +470 -0
- package/dist/security/headers.d.ts +182 -0
- package/dist/security/headers.d.ts.map +1 -0
- package/dist/security/headers.js +402 -0
- package/dist/security/index.d.ts +19 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +18 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +28 -0
- package/dist/server/renderPage.d.ts +69 -0
- package/dist/server/renderPage.d.ts.map +1 -0
- package/dist/server/renderPage.js +109 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +4 -0
- package/dist/storage/vercel-blob.d.ts +17 -0
- package/dist/storage/vercel-blob.d.ts.map +1 -0
- package/dist/storage/vercel-blob.js +83 -0
- package/dist/translations/index.d.ts +17 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +1 -0
- package/dist/types/access.d.ts +67 -0
- package/dist/types/access.d.ts.map +1 -0
- package/dist/types/access.js +8 -0
- package/dist/types/api.d.ts +57 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +8 -0
- package/dist/types/cms.d.ts +8 -0
- package/dist/types/cms.d.ts.map +1 -0
- package/dist/types/cms.js +6 -0
- package/dist/types/config.d.ts +152 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +9 -0
- package/dist/types/core.d.ts +11 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +9 -0
- package/dist/types/extensions.d.ts +116 -0
- package/dist/types/extensions.d.ts.map +1 -0
- package/dist/types/extensions.js +8 -0
- package/dist/types/frontend.d.ts +53 -0
- package/dist/types/frontend.d.ts.map +1 -0
- package/dist/types/frontend.js +7 -0
- package/dist/types/generated.d.ts +14 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/generated.js +11 -0
- package/dist/types/hooks.d.ts +53 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/hooks.js +8 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +61 -0
- package/dist/types/interfaces/app.d.ts +50 -0
- package/dist/types/interfaces/app.d.ts.map +1 -0
- package/dist/types/interfaces/app.js +5 -0
- package/dist/types/jobs.d.ts +112 -0
- package/dist/types/jobs.d.ts.map +1 -0
- package/dist/types/jobs.js +7 -0
- package/dist/types/legacy.d.ts +147 -0
- package/dist/types/legacy.d.ts.map +1 -0
- package/dist/types/legacy.js +8 -0
- package/dist/types/plugins.d.ts +17 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/plugins.js +8 -0
- package/dist/types/query.d.ts +99 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +24 -0
- package/dist/types/request.d.ts +40 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/request.js +8 -0
- package/dist/types/richtext.d.ts +23 -0
- package/dist/types/richtext.d.ts.map +1 -0
- package/dist/types/richtext.js +8 -0
- package/dist/types/runtime.d.ts +216 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/runtime.js +9 -0
- package/dist/types/schema.d.ts +9 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +7 -0
- package/dist/types/user.d.ts +48 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +8 -0
- package/dist/utils/access-conversion.d.ts +17 -0
- package/dist/utils/access-conversion.d.ts.map +1 -0
- package/dist/utils/access-conversion.js +96 -0
- package/dist/utils/api-wrapper.d.ts +63 -0
- package/dist/utils/api-wrapper.d.ts.map +1 -0
- package/dist/utils/api-wrapper.js +151 -0
- package/dist/utils/block-conversion.d.ts +21 -0
- package/dist/utils/block-conversion.d.ts.map +1 -0
- package/dist/utils/block-conversion.js +109 -0
- package/dist/utils/cache.d.ts +86 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +154 -0
- package/dist/utils/deep-clone.d.ts +25 -0
- package/dist/utils/deep-clone.d.ts.map +1 -0
- package/dist/utils/deep-clone.js +115 -0
- package/dist/utils/error-responses.d.ts +57 -0
- package/dist/utils/error-responses.d.ts.map +1 -0
- package/dist/utils/error-responses.js +96 -0
- package/dist/utils/errors.d.ts +97 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +397 -0
- package/dist/utils/field-conversion.d.ts +40 -0
- package/dist/utils/field-conversion.d.ts.map +1 -0
- package/dist/utils/field-conversion.js +275 -0
- package/dist/utils/flattenResult.d.ts +7 -0
- package/dist/utils/flattenResult.d.ts.map +1 -0
- package/dist/utils/flattenResult.js +23 -0
- package/dist/utils/getBlockSelect.d.ts +12 -0
- package/dist/utils/getBlockSelect.d.ts.map +1 -0
- package/dist/utils/getBlockSelect.js +12 -0
- package/dist/utils/getSelectMode.d.ts +8 -0
- package/dist/utils/getSelectMode.d.ts.map +1 -0
- package/dist/utils/getSelectMode.js +21 -0
- package/dist/utils/isValidID.d.ts +5 -0
- package/dist/utils/isValidID.d.ts.map +1 -0
- package/dist/utils/isValidID.js +13 -0
- package/dist/utils/json-parsing.d.ts +48 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +130 -0
- package/dist/utils/jwt-validation.d.ts +14 -0
- package/dist/utils/jwt-validation.d.ts.map +1 -0
- package/dist/utils/jwt-validation.js +36 -0
- package/dist/utils/logger-client.d.ts +32 -0
- package/dist/utils/logger-client.d.ts.map +1 -0
- package/dist/utils/logger-client.js +55 -0
- package/dist/utils/logger-server.d.ts +32 -0
- package/dist/utils/logger-server.d.ts.map +1 -0
- package/dist/utils/logger-server.js +68 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +12 -0
- package/dist/utils/request-context.d.ts +143 -0
- package/dist/utils/request-context.d.ts.map +1 -0
- package/dist/utils/request-context.js +168 -0
- package/dist/utils/request-headers.d.ts +15 -0
- package/dist/utils/request-headers.d.ts.map +1 -0
- package/dist/utils/request-headers.js +31 -0
- package/dist/utils/stripUnselectedFields.d.ts +10 -0
- package/dist/utils/stripUnselectedFields.d.ts.map +1 -0
- package/dist/utils/stripUnselectedFields.js +20 -0
- package/dist/utils/type-guards.d.ts +33 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +63 -0
- package/dist/utils/user.d.ts +14 -0
- package/dist/utils/user.d.ts.map +1 -0
- package/dist/utils/user.js +15 -0
- package/package.json +250 -697
- package/LICENSE_SUMMARY.md +0 -55
- package/NOTICE +0 -34
- package/dist/core/gaurds/logger/log404/index.spec.snapshot-1 +0 -8
- package/dist/core/gaurds/logger/log404/index.spec.snapshot-2 +0 -9
- package/dist/exports/RenderErrorPage.js +0 -3
- package/dist/exports/__internal.js +0 -3
- package/dist/exports/abort.js +0 -3
- package/dist/exports/bin-entry.js +0 -17
- package/dist/exports/cli.js +0 -3
- package/dist/exports/client.js +0 -3
- package/dist/exports/config.js +0 -1
- package/dist/exports/helpers.js +0 -1
- package/dist/exports/index.js +0 -33
- package/dist/exports/plugin.js +0 -3
- package/dist/exports/prerender.js +0 -3
- package/dist/exports/router.js +0 -3
- package/dist/exports/routing.js +0 -3
- package/dist/exports/server.js +0 -3
- package/dist/exports/setup.js +0 -3
- package/dist/exports/types.js +0 -1
- package/dist/integration/styles.css +0 -141
- package/dist/node/cli/index.js +0 -18
- package/dist/shared/RenderErrorPage.d.ts +0 -3
- package/dist/shared/RenderErrorPage.js +0 -3
- package/dist/shared/abort.js +0 -3
- package/dist/shared/route/routing.js +0 -3
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* RevealUI Rich Text Editor - Floating Toolbar Plugin
|
|
5
|
+
*
|
|
6
|
+
* A floating toolbar that appears above selected text, similar to Medium's editor.
|
|
7
|
+
*/
|
|
8
|
+
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
9
|
+
import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode, REMOVE_LIST_COMMAND, } from '@lexical/list';
|
|
10
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
11
|
+
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, } from '@lexical/rich-text';
|
|
12
|
+
import { $setBlocksType } from '@lexical/selection';
|
|
13
|
+
import { $findMatchingParent, $getNearestNodeOfType, mergeRegister } from '@lexical/utils';
|
|
14
|
+
import { $createParagraphNode, $getSelection, $isRangeSelection, $isRootOrShadowRoot, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, } from 'lexical';
|
|
15
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { createPortal } from 'react-dom';
|
|
17
|
+
import { ImageUploadButton } from '../components/ImageUploadButton.js';
|
|
18
|
+
export function FloatingToolbarPlugin({ features }) {
|
|
19
|
+
const [editor] = useLexicalComposerContext();
|
|
20
|
+
const toolbarRef = useRef(null);
|
|
21
|
+
const [position, setPosition] = useState({
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
visible: false,
|
|
25
|
+
});
|
|
26
|
+
const [state, setState] = useState({
|
|
27
|
+
isBold: false,
|
|
28
|
+
isItalic: false,
|
|
29
|
+
isUnderline: false,
|
|
30
|
+
isStrikethrough: false,
|
|
31
|
+
isCode: false,
|
|
32
|
+
isSubscript: false,
|
|
33
|
+
isSuperscript: false,
|
|
34
|
+
isLink: false,
|
|
35
|
+
blockType: 'paragraph',
|
|
36
|
+
canUndo: false,
|
|
37
|
+
canRedo: false,
|
|
38
|
+
});
|
|
39
|
+
// Update toolbar state and position based on selection
|
|
40
|
+
const updateToolbar = useCallback(() => {
|
|
41
|
+
const selection = $getSelection();
|
|
42
|
+
if (!$isRangeSelection(selection) || selection.isCollapsed()) {
|
|
43
|
+
setPosition((prev) => ({ ...prev, visible: false }));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Get DOM selection for positioning
|
|
47
|
+
const domSelection = window.getSelection();
|
|
48
|
+
if (!domSelection || domSelection.rangeCount === 0) {
|
|
49
|
+
setPosition((prev) => ({ ...prev, visible: false }));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const range = domSelection.getRangeAt(0);
|
|
53
|
+
const rect = range.getBoundingClientRect();
|
|
54
|
+
const editorRootElement = editor.getRootElement();
|
|
55
|
+
if (!editorRootElement) {
|
|
56
|
+
setPosition((prev) => ({ ...prev, visible: false }));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Calculate toolbar position
|
|
60
|
+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
61
|
+
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
62
|
+
// Position toolbar above selection, centered horizontally
|
|
63
|
+
const toolbarHeight = toolbarRef.current?.offsetHeight || 40;
|
|
64
|
+
const toolbarWidth = toolbarRef.current?.offsetWidth || 200;
|
|
65
|
+
const top = rect.top + scrollTop - toolbarHeight - 8; // 8px gap above selection
|
|
66
|
+
const left = rect.left + scrollLeft + rect.width / 2 - toolbarWidth / 2;
|
|
67
|
+
setPosition({
|
|
68
|
+
top: Math.max(8, top), // Don't go above viewport
|
|
69
|
+
left: Math.max(8, Math.min(left, window.innerWidth - toolbarWidth - 8)), // Keep within viewport
|
|
70
|
+
visible: true,
|
|
71
|
+
});
|
|
72
|
+
// Update formatting state
|
|
73
|
+
setState((prev) => ({
|
|
74
|
+
...prev,
|
|
75
|
+
isBold: selection.hasFormat('bold'),
|
|
76
|
+
isItalic: selection.hasFormat('italic'),
|
|
77
|
+
isUnderline: selection.hasFormat('underline'),
|
|
78
|
+
isStrikethrough: selection.hasFormat('strikethrough'),
|
|
79
|
+
isCode: selection.hasFormat('code'),
|
|
80
|
+
isSubscript: selection.hasFormat('subscript'),
|
|
81
|
+
isSuperscript: selection.hasFormat('superscript'),
|
|
82
|
+
}));
|
|
83
|
+
// Block type
|
|
84
|
+
const anchorNode = selection.anchor.getNode();
|
|
85
|
+
let element = anchorNode.getKey() === 'root'
|
|
86
|
+
? anchorNode
|
|
87
|
+
: $findMatchingParent(anchorNode, (e) => {
|
|
88
|
+
const parent = e.getParent();
|
|
89
|
+
return parent !== null && $isRootOrShadowRoot(parent);
|
|
90
|
+
});
|
|
91
|
+
if (element === null) {
|
|
92
|
+
element = anchorNode.getTopLevelElementOrThrow();
|
|
93
|
+
}
|
|
94
|
+
const elementKey = element.getKey();
|
|
95
|
+
const elementDOM = editor.getElementByKey(elementKey);
|
|
96
|
+
if (elementDOM !== null) {
|
|
97
|
+
// Check list type
|
|
98
|
+
if ($isListNode(element)) {
|
|
99
|
+
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
100
|
+
const type = parentList ? parentList.getListType() : element.getListType();
|
|
101
|
+
setState((prev) => ({
|
|
102
|
+
...prev,
|
|
103
|
+
blockType: type === 'bullet' ? 'bullet' : type === 'number' ? 'number' : 'check',
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// Check heading type
|
|
108
|
+
const type = $isHeadingNode(element) ? element.getTag() : element.getType();
|
|
109
|
+
if (type === 'paragraph' || type === 'root') {
|
|
110
|
+
setState((prev) => ({ ...prev, blockType: 'paragraph' }));
|
|
111
|
+
}
|
|
112
|
+
else if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(type)) {
|
|
113
|
+
setState((prev) => ({ ...prev, blockType: type }));
|
|
114
|
+
}
|
|
115
|
+
else if (type === 'quote') {
|
|
116
|
+
setState((prev) => ({ ...prev, blockType: 'quote' }));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Link state
|
|
121
|
+
const node = selection.anchor.getNode();
|
|
122
|
+
const parent = node.getParent();
|
|
123
|
+
setState((prev) => ({
|
|
124
|
+
...prev,
|
|
125
|
+
isLink: $isLinkNode(parent) || $isLinkNode(node),
|
|
126
|
+
}));
|
|
127
|
+
}, [editor]);
|
|
128
|
+
// Register listeners
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
return mergeRegister(editor.registerUpdateListener(({ editorState }) => {
|
|
131
|
+
editorState.read(() => {
|
|
132
|
+
updateToolbar();
|
|
133
|
+
});
|
|
134
|
+
}), editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
|
|
135
|
+
updateToolbar();
|
|
136
|
+
return false;
|
|
137
|
+
}, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CAN_UNDO_COMMAND, (payload) => {
|
|
138
|
+
setState((prev) => ({ ...prev, canUndo: payload }));
|
|
139
|
+
return false;
|
|
140
|
+
}, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CAN_REDO_COMMAND, (payload) => {
|
|
141
|
+
setState((prev) => ({ ...prev, canRedo: payload }));
|
|
142
|
+
return false;
|
|
143
|
+
}, COMMAND_PRIORITY_CRITICAL));
|
|
144
|
+
}, [editor, updateToolbar]);
|
|
145
|
+
// Handle window scroll/resize to reposition toolbar
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const handleScroll = () => {
|
|
148
|
+
updateToolbar();
|
|
149
|
+
};
|
|
150
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
151
|
+
window.addEventListener('resize', handleScroll);
|
|
152
|
+
return () => {
|
|
153
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
154
|
+
window.removeEventListener('resize', handleScroll);
|
|
155
|
+
};
|
|
156
|
+
}, [updateToolbar]);
|
|
157
|
+
// Format commands (same as ToolbarPlugin)
|
|
158
|
+
const formatBold = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
|
|
159
|
+
const formatItalic = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
|
|
160
|
+
const formatUnderline = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');
|
|
161
|
+
const undo = () => editor.dispatchCommand(UNDO_COMMAND, undefined);
|
|
162
|
+
const redo = () => editor.dispatchCommand(REDO_COMMAND, undefined);
|
|
163
|
+
// Block type commands
|
|
164
|
+
const formatParagraph = () => {
|
|
165
|
+
editor.update(() => {
|
|
166
|
+
const selection = $getSelection();
|
|
167
|
+
if ($isRangeSelection(selection)) {
|
|
168
|
+
$setBlocksType(selection, () => $createParagraphNode());
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
const formatHeading = (tag) => {
|
|
173
|
+
if (state.blockType !== tag) {
|
|
174
|
+
editor.update(() => {
|
|
175
|
+
const selection = $getSelection();
|
|
176
|
+
if ($isRangeSelection(selection)) {
|
|
177
|
+
$setBlocksType(selection, () => $createHeadingNode(tag));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const formatQuote = () => {
|
|
183
|
+
if (state.blockType !== 'quote') {
|
|
184
|
+
editor.update(() => {
|
|
185
|
+
const selection = $getSelection();
|
|
186
|
+
if ($isRangeSelection(selection)) {
|
|
187
|
+
$setBlocksType(selection, () => $createQuoteNode());
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const formatBulletList = () => {
|
|
193
|
+
if (state.blockType !== 'bullet') {
|
|
194
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const formatNumberedList = () => {
|
|
201
|
+
if (state.blockType !== 'number') {
|
|
202
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const insertLink = () => {
|
|
209
|
+
if (!state.isLink) {
|
|
210
|
+
const url = prompt('Enter URL:');
|
|
211
|
+
if (url) {
|
|
212
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
// Check which features are enabled
|
|
220
|
+
const hasFeature = (key) => features.some((f) => f.key === key);
|
|
221
|
+
// Check if floating toolbar should be shown
|
|
222
|
+
const showToolbar = features.some((f) => f.type === 'toolbar' && f.position === 'floating') ||
|
|
223
|
+
features.some((f) => f.key === 'floatingToolbar' || f.key === 'floating-toolbar');
|
|
224
|
+
if (!(showToolbar && position.visible)) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const toolbarContent = (
|
|
228
|
+
// biome-ignore lint: Floating toolbar needs absolute positioning and event handling
|
|
229
|
+
_jsxs("div", { ref: toolbarRef, className: "editor-toolbar editor-toolbar--floating", style: {
|
|
230
|
+
position: 'absolute',
|
|
231
|
+
top: `${position.top}px`,
|
|
232
|
+
left: `${position.left}px`,
|
|
233
|
+
zIndex: 1000,
|
|
234
|
+
opacity: position.visible ? 1 : 0,
|
|
235
|
+
pointerEvents: position.visible ? 'auto' : 'none',
|
|
236
|
+
}, onMouseDown: (e) => e.preventDefault(), children: [hasFeature('history') && (_jsxs("div", { className: "toolbar-group", children: [_jsx("button", { type: "button", disabled: !state.canUndo, onClick: undo, className: "toolbar-btn", title: "Undo (Ctrl+Z)", "aria-label": "Undo", children: "\u21B6" }), _jsx("button", { type: "button", disabled: !state.canRedo, onClick: redo, className: "toolbar-btn", title: "Redo (Ctrl+Y)", "aria-label": "Redo", children: "\u21B7" })] })), _jsxs("div", { className: "toolbar-group", children: [hasFeature('bold') && (_jsx("button", { type: "button", onClick: formatBold, className: `toolbar-btn ${state.isBold ? 'active' : ''}`, title: "Bold (Ctrl+B)", "aria-label": "Bold", "aria-pressed": state.isBold, children: _jsx("strong", { children: "B" }) })), hasFeature('italic') && (_jsx("button", { type: "button", onClick: formatItalic, className: `toolbar-btn ${state.isItalic ? 'active' : ''}`, title: "Italic (Ctrl+I)", "aria-label": "Italic", "aria-pressed": state.isItalic, children: _jsx("em", { children: "I" }) })), hasFeature('underline') && (_jsx("button", { type: "button", onClick: formatUnderline, className: `toolbar-btn ${state.isUnderline ? 'active' : ''}`, title: "Underline (Ctrl+U)", "aria-label": "Underline", "aria-pressed": state.isUnderline, children: _jsx("span", { style: { textDecoration: 'underline' }, children: "U" }) })), hasFeature('link') && (_jsx("button", { type: "button", onClick: insertLink, className: `toolbar-btn ${state.isLink ? 'active' : ''}`, title: "Insert Link", "aria-label": "Insert Link", "aria-pressed": state.isLink, children: "\uD83D\uDD17" })), hasFeature('upload') && _jsx(ImageUploadButton, {})] }), hasFeature('heading') && (_jsx("div", { className: "toolbar-group", children: _jsxs("select", { className: "toolbar-select", value: state.blockType, onChange: (e) => {
|
|
237
|
+
const value = e.target.value;
|
|
238
|
+
if (value === 'paragraph')
|
|
239
|
+
formatParagraph();
|
|
240
|
+
else if (value.startsWith('h'))
|
|
241
|
+
formatHeading(value);
|
|
242
|
+
else if (value === 'quote')
|
|
243
|
+
formatQuote();
|
|
244
|
+
}, children: [_jsx("option", { value: "paragraph", children: "Paragraph" }), _jsx("option", { value: "h1", children: "H1" }), _jsx("option", { value: "h2", children: "H2" }), _jsx("option", { value: "h3", children: "H3" })] }) })), (hasFeature('list') || hasFeature('orderedList') || hasFeature('unorderedList')) && (_jsxs("div", { className: "toolbar-group", children: [_jsx("button", { type: "button", onClick: formatBulletList, className: `toolbar-btn ${state.blockType === 'bullet' ? 'active' : ''}`, title: "Bullet List", "aria-label": "Bullet List", children: "\u2022" }), _jsx("button", { type: "button", onClick: formatNumberedList, className: `toolbar-btn ${state.blockType === 'number' ? 'active' : ''}`, title: "Numbered List", "aria-label": "Numbered List", children: "1." })] }))] }));
|
|
245
|
+
// Render via portal to body for proper positioning
|
|
246
|
+
return typeof document !== 'undefined' ? createPortal(toolbarContent, document.body) : null;
|
|
247
|
+
}
|
|
248
|
+
export default FloatingToolbarPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagePlugin.d.ts","sourceRoot":"","sources":["../../../../src/client/richtext/plugins/ImagePlugin.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAgF/B,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* RevealUI Rich Text Editor - Image Plugin
|
|
4
|
+
*
|
|
5
|
+
* Plugin for handling image insertion and management in the editor.
|
|
6
|
+
*/
|
|
7
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
|
+
import { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils';
|
|
9
|
+
import { $getNodeByKey, $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
10
|
+
import { useEffect, useState } from 'react';
|
|
11
|
+
import { $createImageNode, ImageNode, INSERT_IMAGE_COMMAND, OPEN_IMAGE_UPLOAD_COMMAND, } from '../nodes/ImageNode.js';
|
|
12
|
+
export const ImagePlugin = () => {
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
const [lastSelection, setLastSelection] = useState(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
return mergeRegister(editor.registerCommand(INSERT_IMAGE_COMMAND, ({ src, alt, width, height, caption }) => {
|
|
17
|
+
let selection = $getSelection();
|
|
18
|
+
if (!$isRangeSelection(selection)) {
|
|
19
|
+
selection = lastSelection;
|
|
20
|
+
if (!$isRangeSelection(selection)) {
|
|
21
|
+
// No selection, insert at root
|
|
22
|
+
editor.update(() => {
|
|
23
|
+
const imageNode = $createImageNode({
|
|
24
|
+
src,
|
|
25
|
+
alt,
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
caption,
|
|
29
|
+
});
|
|
30
|
+
$insertNodeToNearestRoot(imageNode);
|
|
31
|
+
});
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const focusNode = selection.focus.getNode();
|
|
36
|
+
if (focusNode !== null) {
|
|
37
|
+
editor.update(() => {
|
|
38
|
+
const imageNode = $createImageNode({
|
|
39
|
+
src,
|
|
40
|
+
alt,
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
caption,
|
|
44
|
+
});
|
|
45
|
+
$insertNodeToNearestRoot(imageNode);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(OPEN_IMAGE_UPLOAD_COMMAND, ({ data, nodeKey }) => {
|
|
50
|
+
// Handle image editing/replacement
|
|
51
|
+
if (nodeKey && data) {
|
|
52
|
+
editor.update(() => {
|
|
53
|
+
const node = $getNodeByKey(nodeKey);
|
|
54
|
+
if (node && node instanceof ImageNode) {
|
|
55
|
+
node.setData(data);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
// Handle new image upload - trigger file input
|
|
61
|
+
// This will be handled by ImageUploadButton component
|
|
62
|
+
return false;
|
|
63
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerUpdateListener(({ editorState }) => {
|
|
64
|
+
editorState.read(() => {
|
|
65
|
+
const selection = $getSelection();
|
|
66
|
+
if ($isRangeSelection(selection)) {
|
|
67
|
+
setLastSelection(selection);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}));
|
|
71
|
+
}, [editor, lastSelection]);
|
|
72
|
+
return null;
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PastePlugin.d.ts","sourceRoot":"","sources":["../../../../src/client/richtext/plugins/PastePlugin.tsx"],"names":[],"mappings":"AAcA,wBAAgB,WAAW,IAAI,IAAI,CAiClC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* Paste Handling Plugin
|
|
4
|
+
*
|
|
5
|
+
* Registers clipboard event handlers for rich text paste support.
|
|
6
|
+
* Uses @lexical/clipboard for HTML-to-Lexical conversion.
|
|
7
|
+
*/
|
|
8
|
+
import { $generateNodesFromDOM } from '@lexical/html';
|
|
9
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
+
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, PASTE_COMMAND } from 'lexical';
|
|
11
|
+
import { useEffect } from 'react';
|
|
12
|
+
export function PastePlugin() {
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
return editor.registerCommand(PASTE_COMMAND, (event) => {
|
|
16
|
+
const clipboardData = event.clipboardData;
|
|
17
|
+
if (!clipboardData)
|
|
18
|
+
return false;
|
|
19
|
+
const htmlData = clipboardData.getData('text/html');
|
|
20
|
+
if (!htmlData)
|
|
21
|
+
return false; // Let Lexical handle plain text paste
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
editor.update(() => {
|
|
24
|
+
const selection = $getSelection();
|
|
25
|
+
if (!$isRangeSelection(selection))
|
|
26
|
+
return;
|
|
27
|
+
const parser = new DOMParser();
|
|
28
|
+
const dom = parser.parseFromString(htmlData, 'text/html');
|
|
29
|
+
const nodes = $generateNodesFromDOM(editor, dom);
|
|
30
|
+
selection.insertNodes(nodes);
|
|
31
|
+
});
|
|
32
|
+
return true;
|
|
33
|
+
}, COMMAND_PRIORITY_LOW);
|
|
34
|
+
}, [editor]);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RichTextFeature } from '../../../richtext/index.js';
|
|
2
|
+
export interface ToolbarPluginProps {
|
|
3
|
+
features: RichTextFeature[];
|
|
4
|
+
variant?: 'fixed' | 'inline' | 'floating';
|
|
5
|
+
}
|
|
6
|
+
export declare function ToolbarPlugin({ features, variant }: ToolbarPluginProps): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export default ToolbarPlugin;
|
|
8
|
+
//# sourceMappingURL=ToolbarPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarPlugin.d.ts","sourceRoot":"","sources":["../../../../src/client/richtext/plugins/ToolbarPlugin.tsx"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAsCjE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;CAC1C;AAED,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,OAAiB,EAAE,EAAE,kBAAkB,kDA4ZhF;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* RevealUI Rich Text Editor - Toolbar Plugin
|
|
5
|
+
*
|
|
6
|
+
* A comprehensive toolbar with formatting commands for the Lexical editor.
|
|
7
|
+
*/
|
|
8
|
+
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
9
|
+
import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode, REMOVE_LIST_COMMAND, } from '@lexical/list';
|
|
10
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
11
|
+
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, } from '@lexical/rich-text';
|
|
12
|
+
import { $setBlocksType } from '@lexical/selection';
|
|
13
|
+
import { $findMatchingParent, $getNearestNodeOfType, mergeRegister } from '@lexical/utils';
|
|
14
|
+
import { $createParagraphNode, $getSelection, $isRangeSelection, $isRootOrShadowRoot, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, } from 'lexical';
|
|
15
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
16
|
+
import { ImageUploadButton } from '../components/ImageUploadButton.js';
|
|
17
|
+
export function ToolbarPlugin({ features, variant = 'fixed' }) {
|
|
18
|
+
const [editor] = useLexicalComposerContext();
|
|
19
|
+
const [state, setState] = useState({
|
|
20
|
+
isBold: false,
|
|
21
|
+
isItalic: false,
|
|
22
|
+
isUnderline: false,
|
|
23
|
+
isStrikethrough: false,
|
|
24
|
+
isCode: false,
|
|
25
|
+
isSubscript: false,
|
|
26
|
+
isSuperscript: false,
|
|
27
|
+
isLink: false,
|
|
28
|
+
blockType: 'paragraph',
|
|
29
|
+
canUndo: false,
|
|
30
|
+
canRedo: false,
|
|
31
|
+
});
|
|
32
|
+
// Update toolbar state based on selection
|
|
33
|
+
const updateToolbar = useCallback(() => {
|
|
34
|
+
const selection = $getSelection();
|
|
35
|
+
if ($isRangeSelection(selection)) {
|
|
36
|
+
// Text formatting
|
|
37
|
+
setState((prev) => ({
|
|
38
|
+
...prev,
|
|
39
|
+
isBold: selection.hasFormat('bold'),
|
|
40
|
+
isItalic: selection.hasFormat('italic'),
|
|
41
|
+
isUnderline: selection.hasFormat('underline'),
|
|
42
|
+
isStrikethrough: selection.hasFormat('strikethrough'),
|
|
43
|
+
isCode: selection.hasFormat('code'),
|
|
44
|
+
isSubscript: selection.hasFormat('subscript'),
|
|
45
|
+
isSuperscript: selection.hasFormat('superscript'),
|
|
46
|
+
}));
|
|
47
|
+
// Block type
|
|
48
|
+
const anchorNode = selection.anchor.getNode();
|
|
49
|
+
let element = anchorNode.getKey() === 'root'
|
|
50
|
+
? anchorNode
|
|
51
|
+
: $findMatchingParent(anchorNode, (e) => {
|
|
52
|
+
const parent = e.getParent();
|
|
53
|
+
return parent !== null && $isRootOrShadowRoot(parent);
|
|
54
|
+
});
|
|
55
|
+
if (element === null) {
|
|
56
|
+
element = anchorNode.getTopLevelElementOrThrow();
|
|
57
|
+
}
|
|
58
|
+
const elementKey = element.getKey();
|
|
59
|
+
const elementDOM = editor.getElementByKey(elementKey);
|
|
60
|
+
if (elementDOM !== null) {
|
|
61
|
+
// Check list type
|
|
62
|
+
if ($isListNode(element)) {
|
|
63
|
+
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
64
|
+
const type = parentList ? parentList.getListType() : element.getListType();
|
|
65
|
+
setState((prev) => ({
|
|
66
|
+
...prev,
|
|
67
|
+
blockType: type === 'bullet' ? 'bullet' : type === 'number' ? 'number' : 'check',
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Check heading type
|
|
72
|
+
const type = $isHeadingNode(element) ? element.getTag() : element.getType();
|
|
73
|
+
if (type === 'paragraph' || type === 'root') {
|
|
74
|
+
setState((prev) => ({ ...prev, blockType: 'paragraph' }));
|
|
75
|
+
}
|
|
76
|
+
else if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(type)) {
|
|
77
|
+
setState((prev) => ({ ...prev, blockType: type }));
|
|
78
|
+
}
|
|
79
|
+
else if (type === 'quote') {
|
|
80
|
+
setState((prev) => ({ ...prev, blockType: 'quote' }));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Link state
|
|
85
|
+
const node = selection.anchor.getNode();
|
|
86
|
+
const parent = node.getParent();
|
|
87
|
+
setState((prev) => ({
|
|
88
|
+
...prev,
|
|
89
|
+
isLink: $isLinkNode(parent) || $isLinkNode(node),
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}, [editor]);
|
|
93
|
+
// Register listeners
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
return mergeRegister(editor.registerUpdateListener(({ editorState }) => {
|
|
96
|
+
editorState.read(() => {
|
|
97
|
+
updateToolbar();
|
|
98
|
+
});
|
|
99
|
+
}), editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
|
|
100
|
+
updateToolbar();
|
|
101
|
+
return false;
|
|
102
|
+
}, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CAN_UNDO_COMMAND, (payload) => {
|
|
103
|
+
setState((prev) => ({ ...prev, canUndo: payload }));
|
|
104
|
+
return false;
|
|
105
|
+
}, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CAN_REDO_COMMAND, (payload) => {
|
|
106
|
+
setState((prev) => ({ ...prev, canRedo: payload }));
|
|
107
|
+
return false;
|
|
108
|
+
}, COMMAND_PRIORITY_CRITICAL));
|
|
109
|
+
}, [editor, updateToolbar]);
|
|
110
|
+
// Format commands
|
|
111
|
+
const formatBold = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
|
|
112
|
+
const formatItalic = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
|
|
113
|
+
const formatUnderline = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');
|
|
114
|
+
const formatStrikethrough = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
|
|
115
|
+
const formatCode = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code');
|
|
116
|
+
const formatSubscript = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'subscript');
|
|
117
|
+
const formatSuperscript = () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'superscript');
|
|
118
|
+
const undo = () => editor.dispatchCommand(UNDO_COMMAND, undefined);
|
|
119
|
+
const redo = () => editor.dispatchCommand(REDO_COMMAND, undefined);
|
|
120
|
+
// Block type commands
|
|
121
|
+
const formatParagraph = () => {
|
|
122
|
+
editor.update(() => {
|
|
123
|
+
const selection = $getSelection();
|
|
124
|
+
if ($isRangeSelection(selection)) {
|
|
125
|
+
$setBlocksType(selection, () => $createParagraphNode());
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const formatHeading = (tag) => {
|
|
130
|
+
if (state.blockType !== tag) {
|
|
131
|
+
editor.update(() => {
|
|
132
|
+
const selection = $getSelection();
|
|
133
|
+
if ($isRangeSelection(selection)) {
|
|
134
|
+
$setBlocksType(selection, () => $createHeadingNode(tag));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const formatQuote = () => {
|
|
140
|
+
if (state.blockType !== 'quote') {
|
|
141
|
+
editor.update(() => {
|
|
142
|
+
const selection = $getSelection();
|
|
143
|
+
if ($isRangeSelection(selection)) {
|
|
144
|
+
$setBlocksType(selection, () => $createQuoteNode());
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const formatBulletList = () => {
|
|
150
|
+
if (state.blockType !== 'bullet') {
|
|
151
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const formatNumberedList = () => {
|
|
158
|
+
if (state.blockType !== 'number') {
|
|
159
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const insertLink = () => {
|
|
166
|
+
if (!state.isLink) {
|
|
167
|
+
const url = prompt('Enter URL:');
|
|
168
|
+
if (url) {
|
|
169
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
// Check which features are enabled
|
|
177
|
+
const hasFeature = (key) => features.some((f) => f.key === key);
|
|
178
|
+
// Check if fixed toolbar should be shown (don't show for floating/inline)
|
|
179
|
+
const showToolbar = features.some((f) => {
|
|
180
|
+
// Check by feature key first (more reliable)
|
|
181
|
+
if (variant === 'fixed') {
|
|
182
|
+
return f.key === 'fixedToolbar' || f.key === 'fixed-toolbar';
|
|
183
|
+
}
|
|
184
|
+
// For inline/floating variants, check toolbar type (but skip fixed toolbar)
|
|
185
|
+
if (variant === 'inline' || variant === 'floating') {
|
|
186
|
+
if (f.type === 'toolbar') {
|
|
187
|
+
return f.position === variant || !f.position;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
});
|
|
192
|
+
if (!showToolbar)
|
|
193
|
+
return null;
|
|
194
|
+
return (_jsxs("div", { className: `editor-toolbar editor-toolbar--${variant}`, children: [hasFeature('history') && (_jsxs("div", { className: "toolbar-group", children: [_jsx("button", { type: "button", disabled: !state.canUndo, onClick: undo, className: "toolbar-btn", title: "Undo (Ctrl+Z)", "aria-label": "Undo", children: "\u21B6" }), _jsx("button", { type: "button", disabled: !state.canRedo, onClick: redo, className: "toolbar-btn", title: "Redo (Ctrl+Y)", "aria-label": "Redo", children: "\u21B7" })] })), hasFeature('heading') && (_jsx("div", { className: "toolbar-group", children: _jsxs("select", { className: "toolbar-select", value: state.blockType, onChange: (e) => {
|
|
195
|
+
const value = e.target.value;
|
|
196
|
+
if (value === 'paragraph')
|
|
197
|
+
formatParagraph();
|
|
198
|
+
else if (value.startsWith('h'))
|
|
199
|
+
formatHeading(value);
|
|
200
|
+
else if (value === 'quote')
|
|
201
|
+
formatQuote();
|
|
202
|
+
}, children: [_jsx("option", { value: "paragraph", children: "Paragraph" }), _jsx("option", { value: "h1", children: "Heading 1" }), _jsx("option", { value: "h2", children: "Heading 2" }), _jsx("option", { value: "h3", children: "Heading 3" }), _jsx("option", { value: "h4", children: "Heading 4" })] }) })), _jsxs("div", { className: "toolbar-group", children: [hasFeature('bold') && (_jsx("button", { type: "button", onClick: formatBold, className: `toolbar-btn ${state.isBold ? 'active' : ''}`, title: "Bold (Ctrl+B)", "aria-label": "Bold", "aria-pressed": state.isBold, children: _jsx("strong", { children: "B" }) })), hasFeature('italic') && (_jsx("button", { type: "button", onClick: formatItalic, className: `toolbar-btn ${state.isItalic ? 'active' : ''}`, title: "Italic (Ctrl+I)", "aria-label": "Italic", "aria-pressed": state.isItalic, children: _jsx("em", { children: "I" }) })), hasFeature('underline') && (_jsx("button", { type: "button", onClick: formatUnderline, className: `toolbar-btn ${state.isUnderline ? 'active' : ''}`, title: "Underline (Ctrl+U)", "aria-label": "Underline", "aria-pressed": state.isUnderline, children: _jsx("span", { style: { textDecoration: 'underline' }, children: "U" }) })), hasFeature('strikethrough') && (_jsx("button", { type: "button", onClick: formatStrikethrough, className: `toolbar-btn ${state.isStrikethrough ? 'active' : ''}`, title: "Strikethrough", "aria-label": "Strikethrough", "aria-pressed": state.isStrikethrough, children: _jsx("span", { style: { textDecoration: 'line-through' }, children: "S" }) })), hasFeature('code') && (_jsx("button", { type: "button", onClick: formatCode, className: `toolbar-btn ${state.isCode ? 'active' : ''}`, title: "Inline Code", "aria-label": "Inline Code", "aria-pressed": state.isCode, children: '</>' })), hasFeature('subscript') && (_jsxs("button", { type: "button", onClick: formatSubscript, className: `toolbar-btn ${state.isSubscript ? 'active' : ''}`, title: "Subscript", "aria-label": "Subscript", "aria-pressed": state.isSubscript, children: ["X", _jsx("sub", { children: "2" })] })), hasFeature('superscript') && (_jsxs("button", { type: "button", onClick: formatSuperscript, className: `toolbar-btn ${state.isSuperscript ? 'active' : ''}`, title: "Superscript", "aria-label": "Superscript", "aria-pressed": state.isSuperscript, children: ["X", _jsx("sup", { children: "2" })] }))] }), (hasFeature('list') || hasFeature('orderedList') || hasFeature('unorderedList')) && (_jsxs("div", { className: "toolbar-group", children: [_jsx("button", { type: "button", onClick: formatBulletList, className: `toolbar-btn ${state.blockType === 'bullet' ? 'active' : ''}`, title: "Bullet List", "aria-label": "Bullet List", children: "\u2022" }), _jsx("button", { type: "button", onClick: formatNumberedList, className: `toolbar-btn ${state.blockType === 'number' ? 'active' : ''}`, title: "Numbered List", "aria-label": "Numbered List", children: "1." })] })), hasFeature('link') && (_jsx("div", { className: "toolbar-group", children: _jsx("button", { type: "button", onClick: insertLink, className: `toolbar-btn ${state.isLink ? 'active' : ''}`, title: "Insert Link", "aria-label": "Insert Link", "aria-pressed": state.isLink, children: "\uD83D\uDD17" }) })), hasFeature('quote') && (_jsx("div", { className: "toolbar-group", children: _jsx("button", { type: "button", onClick: formatQuote, className: `toolbar-btn ${state.blockType === 'quote' ? 'active' : ''}`, title: "Block Quote", "aria-label": "Block Quote", children: "\"" }) })), hasFeature('upload') && (_jsx("div", { className: "toolbar-group", children: _jsx(ImageUploadButton, {}) }))] }));
|
|
203
|
+
}
|
|
204
|
+
export default ToolbarPlugin;
|