@revealui/core 0.0.1-pre.4 → 0.2.1
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 +108 -152
- 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 +316 -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 +411 -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 +385 -0
- package/dist/caching/service-worker.d.ts +154 -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 +23 -0
- package/dist/client/admin/utils/auth.d.ts.map +1 -0
- package/dist/client/admin/utils/auth.js +52 -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 +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +13 -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 +34 -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/safe-parse.d.ts +26 -0
- package/dist/database/safe-parse.d.ts.map +1 -0
- package/dist/database/safe-parse.js +42 -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 +176 -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 +214 -0
- package/dist/error-handling/error-reporter.d.ts.map +1 -0
- package/dist/error-handling/error-reporter.js +477 -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 +86 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +92 -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 +16 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +21 -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 +126 -33
- package/dist/instance/RevealUIInstance.d.ts +6 -0
- package/dist/instance/RevealUIInstance.d.ts.map +1 -0
- package/dist/instance/RevealUIInstance.js +306 -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 +41 -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 +27 -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 +34 -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 +45 -0
- package/dist/license.d.ts +82 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +193 -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 +375 -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 +131 -0
- package/dist/optimization/code-splitting.d.ts.map +1 -0
- package/dist/optimization/code-splitting.js +277 -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 +255 -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 +476 -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 +517 -0
- package/dist/security/gdpr.d.ts +300 -0
- package/dist/security/gdpr.d.ts.map +1 -0
- package/dist/security/gdpr.js +465 -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 +12 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/generated.js +10 -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 +241 -724
- package/LICENSE_SUMMARY.md +0 -55
- package/NOTICE +0 -34
- 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 -5
- 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/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 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../../../src/client/richtext/RichTextEditor.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAS,aAAa,EAAe,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpG,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,KAAK,EACV,cAAc,IAAI,oBAAoB,EAEvC,MAAM,yBAAyB,CAAA;AAWhC,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,YAAY,CAAC,EAAE,oBAAoB,CAAA;IACnC,8CAA8C;IAC9C,YAAY,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CAAA;IACpD,oCAAoC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAA;IAC9D,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAA;IAC1D,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAA;IACvD,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,QAAQ,CAAA;IACvE,+DAA+D;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC9B,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AA+ID,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AA2B1D,wBAAgB,cAAc,CAAC,EAC7B,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,WAA+B,EAC/B,SAAc,EACd,QAAe,EACf,SAAiB,EACjB,OAAO,EACP,SAA4B,EAC5B,aAAqB,EACrB,UAAU,EACV,eAAe,EACf,eAAuB,EACvB,QAAQ,EACR,WAAW,EACX,UAAU,EACV,UAAU,GACX,EAAE,mBAAmB,2CA+GrB;AAMD,eAAO,MAAM,oBAAoB,0+FAmIhC,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* RevealUI Rich Text Editor
|
|
5
|
+
*
|
|
6
|
+
* A production-ready Lexical-based rich text editor component.
|
|
7
|
+
* Supports configurable features, onChange callbacks, and initial state.
|
|
8
|
+
*/
|
|
9
|
+
import { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
10
|
+
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
11
|
+
import { ListItemNode, ListNode } from '@lexical/list';
|
|
12
|
+
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
13
|
+
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
14
|
+
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
15
|
+
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
16
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
17
|
+
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
18
|
+
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
19
|
+
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
20
|
+
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
21
|
+
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
22
|
+
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
23
|
+
import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
|
|
24
|
+
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
25
|
+
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
26
|
+
import { logger } from '@revealui/core/utils/logger';
|
|
27
|
+
import { useCallback, useMemo } from 'react';
|
|
28
|
+
// Image node for upload feature (imported conditionally)
|
|
29
|
+
import { ImageNode } from './nodes/ImageNode.js';
|
|
30
|
+
import { CollaborationPlugin } from './plugins/CollaborationPlugin.js';
|
|
31
|
+
import { ImagePlugin } from './plugins/ImagePlugin.js';
|
|
32
|
+
import { PastePlugin } from './plugins/PastePlugin.js';
|
|
33
|
+
// ============================================
|
|
34
|
+
// THEME
|
|
35
|
+
// ============================================
|
|
36
|
+
const defaultTheme = {
|
|
37
|
+
paragraph: 'editor-paragraph',
|
|
38
|
+
quote: 'editor-quote',
|
|
39
|
+
heading: {
|
|
40
|
+
h1: 'editor-heading-h1',
|
|
41
|
+
h2: 'editor-heading-h2',
|
|
42
|
+
h3: 'editor-heading-h3',
|
|
43
|
+
h4: 'editor-heading-h4',
|
|
44
|
+
h5: 'editor-heading-h5',
|
|
45
|
+
h6: 'editor-heading-h6',
|
|
46
|
+
},
|
|
47
|
+
list: {
|
|
48
|
+
nested: {
|
|
49
|
+
listitem: 'editor-nested-listitem',
|
|
50
|
+
},
|
|
51
|
+
ol: 'editor-list-ol',
|
|
52
|
+
ul: 'editor-list-ul',
|
|
53
|
+
listitem: 'editor-listitem',
|
|
54
|
+
listitemChecked: 'editor-listitem-checked',
|
|
55
|
+
listitemUnchecked: 'editor-listitem-unchecked',
|
|
56
|
+
},
|
|
57
|
+
link: 'editor-link',
|
|
58
|
+
text: {
|
|
59
|
+
bold: 'editor-text-bold',
|
|
60
|
+
italic: 'editor-text-italic',
|
|
61
|
+
underline: 'editor-text-underline',
|
|
62
|
+
strikethrough: 'editor-text-strikethrough',
|
|
63
|
+
code: 'editor-text-code',
|
|
64
|
+
subscript: 'editor-text-subscript',
|
|
65
|
+
superscript: 'editor-text-superscript',
|
|
66
|
+
},
|
|
67
|
+
code: 'editor-code',
|
|
68
|
+
codeHighlight: {
|
|
69
|
+
atrule: 'editor-tokenAttr',
|
|
70
|
+
attr: 'editor-tokenAttr',
|
|
71
|
+
boolean: 'editor-tokenProperty',
|
|
72
|
+
builtin: 'editor-tokenSelector',
|
|
73
|
+
cdata: 'editor-tokenComment',
|
|
74
|
+
char: 'editor-tokenSelector',
|
|
75
|
+
class: 'editor-tokenFunction',
|
|
76
|
+
'class-name': 'editor-tokenFunction',
|
|
77
|
+
comment: 'editor-tokenComment',
|
|
78
|
+
constant: 'editor-tokenProperty',
|
|
79
|
+
deleted: 'editor-tokenProperty',
|
|
80
|
+
doctype: 'editor-tokenComment',
|
|
81
|
+
entity: 'editor-tokenOperator',
|
|
82
|
+
function: 'editor-tokenFunction',
|
|
83
|
+
important: 'editor-tokenVariable',
|
|
84
|
+
inserted: 'editor-tokenSelector',
|
|
85
|
+
keyword: 'editor-tokenAttr',
|
|
86
|
+
namespace: 'editor-tokenVariable',
|
|
87
|
+
number: 'editor-tokenProperty',
|
|
88
|
+
operator: 'editor-tokenOperator',
|
|
89
|
+
prolog: 'editor-tokenComment',
|
|
90
|
+
property: 'editor-tokenProperty',
|
|
91
|
+
punctuation: 'editor-tokenPunctuation',
|
|
92
|
+
regex: 'editor-tokenVariable',
|
|
93
|
+
selector: 'editor-tokenSelector',
|
|
94
|
+
string: 'editor-tokenSelector',
|
|
95
|
+
symbol: 'editor-tokenProperty',
|
|
96
|
+
tag: 'editor-tokenProperty',
|
|
97
|
+
url: 'editor-tokenOperator',
|
|
98
|
+
variable: 'editor-tokenVariable',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
// ============================================
|
|
102
|
+
// NODES CONFIGURATION
|
|
103
|
+
// ============================================
|
|
104
|
+
function getNodesFromFeatures(features) {
|
|
105
|
+
const nodeSet = new Set();
|
|
106
|
+
// Always include base nodes
|
|
107
|
+
nodeSet.add(HeadingNode);
|
|
108
|
+
nodeSet.add(QuoteNode);
|
|
109
|
+
// Check if upload feature is enabled (for ImageNode)
|
|
110
|
+
const hasUpload = features.some((f) => f.key === 'upload');
|
|
111
|
+
if (hasUpload) {
|
|
112
|
+
nodeSet.add(ImageNode);
|
|
113
|
+
}
|
|
114
|
+
features.forEach((feature) => {
|
|
115
|
+
switch (feature.key) {
|
|
116
|
+
case 'heading':
|
|
117
|
+
nodeSet.add(HeadingNode);
|
|
118
|
+
break;
|
|
119
|
+
case 'quote':
|
|
120
|
+
nodeSet.add(QuoteNode);
|
|
121
|
+
break;
|
|
122
|
+
case 'list':
|
|
123
|
+
case 'orderedList':
|
|
124
|
+
case 'unorderedList':
|
|
125
|
+
case 'checklist':
|
|
126
|
+
nodeSet.add(ListNode);
|
|
127
|
+
nodeSet.add(ListItemNode);
|
|
128
|
+
break;
|
|
129
|
+
case 'link':
|
|
130
|
+
nodeSet.add(LinkNode);
|
|
131
|
+
nodeSet.add(AutoLinkNode);
|
|
132
|
+
break;
|
|
133
|
+
case 'code':
|
|
134
|
+
case 'codeBlock':
|
|
135
|
+
nodeSet.add(CodeNode);
|
|
136
|
+
nodeSet.add(CodeHighlightNode);
|
|
137
|
+
break;
|
|
138
|
+
case 'horizontalRule':
|
|
139
|
+
nodeSet.add(HorizontalRuleNode);
|
|
140
|
+
break;
|
|
141
|
+
case 'table':
|
|
142
|
+
nodeSet.add(TableNode);
|
|
143
|
+
nodeSet.add(TableCellNode);
|
|
144
|
+
nodeSet.add(TableRowNode);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return Array.from(nodeSet);
|
|
149
|
+
}
|
|
150
|
+
// ============================================
|
|
151
|
+
// PLACEHOLDER COMPONENT
|
|
152
|
+
// ============================================
|
|
153
|
+
function Placeholder({ text }) {
|
|
154
|
+
return _jsx("div", { className: "editor-placeholder", children: text });
|
|
155
|
+
}
|
|
156
|
+
// ============================================
|
|
157
|
+
// TOOLBAR COMPONENT
|
|
158
|
+
// ============================================
|
|
159
|
+
import { FloatingToolbarPlugin } from './plugins/FloatingToolbarPlugin.js';
|
|
160
|
+
// Import the full-featured toolbar plugin
|
|
161
|
+
import { ToolbarPlugin } from './plugins/ToolbarPlugin.js';
|
|
162
|
+
export { FloatingToolbarPlugin } from './plugins/FloatingToolbarPlugin.js';
|
|
163
|
+
export { ToolbarPlugin } from './plugins/ToolbarPlugin.js';
|
|
164
|
+
// ============================================
|
|
165
|
+
// FEATURE PLUGINS COMPONENT
|
|
166
|
+
// ============================================
|
|
167
|
+
function FeaturePlugins({ features }) {
|
|
168
|
+
const hasFeature = (key) => features.some((f) => f.key === key);
|
|
169
|
+
return (_jsxs(_Fragment, { children: [(hasFeature('list') || hasFeature('orderedList') || hasFeature('unorderedList')) && (_jsx(ListPlugin, {})), hasFeature('checklist') && _jsx(CheckListPlugin, {}), hasFeature('link') && _jsx(LinkPlugin, {}), hasFeature('upload') && _jsx(ImagePlugin, {}), hasFeature('table') && _jsx(TablePlugin, {}), _jsx(PastePlugin, {})] }));
|
|
170
|
+
}
|
|
171
|
+
// ============================================
|
|
172
|
+
// MAIN EDITOR COMPONENT
|
|
173
|
+
// ============================================
|
|
174
|
+
export function RichTextEditor({ editorConfig, initialValue, onChange, onSerializedChange, placeholder = 'Start typing...', className = '', editable = true, autoFocus = false, onError, namespace = 'RevealUIEditor', collaborative = false, documentId, providerFactory, shouldBootstrap = false, username, cursorColor, clientType, agentModel, }) {
|
|
175
|
+
const features = editorConfig?.features ?? [];
|
|
176
|
+
// Build initial editor state from value
|
|
177
|
+
const initialEditorState = useMemo(() => {
|
|
178
|
+
if (!initialValue)
|
|
179
|
+
return undefined;
|
|
180
|
+
if (typeof initialValue === 'string') {
|
|
181
|
+
try {
|
|
182
|
+
return initialValue;
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// SerializedEditorState - convert to string
|
|
189
|
+
return JSON.stringify(initialValue);
|
|
190
|
+
}, [initialValue]);
|
|
191
|
+
// Error handler
|
|
192
|
+
const handleError = useCallback((error, editor) => {
|
|
193
|
+
logger.error('RichTextEditor error', { error });
|
|
194
|
+
onError?.(error, editor);
|
|
195
|
+
}, [onError]);
|
|
196
|
+
// Change handler
|
|
197
|
+
const handleChange = useCallback((state, editor) => {
|
|
198
|
+
onChange?.(state, editor);
|
|
199
|
+
if (onSerializedChange) {
|
|
200
|
+
const json = state.toJSON();
|
|
201
|
+
onSerializedChange(json);
|
|
202
|
+
}
|
|
203
|
+
}, [onChange, onSerializedChange]);
|
|
204
|
+
// Build nodes from features
|
|
205
|
+
const nodes = useMemo(() => getNodesFromFeatures(features), [features]);
|
|
206
|
+
// Lexical config
|
|
207
|
+
const initialConfig = useMemo(() => ({
|
|
208
|
+
namespace,
|
|
209
|
+
theme: defaultTheme,
|
|
210
|
+
nodes,
|
|
211
|
+
editable,
|
|
212
|
+
editorState: collaborative ? null : initialEditorState,
|
|
213
|
+
onError: handleError,
|
|
214
|
+
}), [namespace, nodes, editable, collaborative, initialEditorState, handleError]);
|
|
215
|
+
// Determine toolbar variant from features
|
|
216
|
+
const hasFloatingToolbar = features.some((f) => (f.type === 'toolbar' && f.position === 'floating') ||
|
|
217
|
+
f.key === 'floatingToolbar' ||
|
|
218
|
+
f.key === 'floating-toolbar');
|
|
219
|
+
const hasFixedToolbar = features.some((f) => (f.type === 'toolbar' && f.position === 'fixed') ||
|
|
220
|
+
f.key === 'fixedToolbar' ||
|
|
221
|
+
f.key === 'fixed-toolbar' ||
|
|
222
|
+
(!f.position && f.type === 'toolbar'));
|
|
223
|
+
return (_jsx("div", { className: `revealui-rich-text-editor ${className}`, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [hasFixedToolbar && _jsx(ToolbarPlugin, { features: features, variant: "fixed" }), hasFloatingToolbar && _jsx(FloatingToolbarPlugin, { features: features }), _jsxs("div", { className: "editor-container", children: [_jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "editor-input", "aria-placeholder": placeholder, placeholder: _jsx(Placeholder, { text: placeholder }) }), placeholder: null, ErrorBoundary: LexicalErrorBoundary }), collaborative && documentId && providerFactory ? (_jsx(CollaborationPlugin, { id: documentId, providerFactory: providerFactory, shouldBootstrap: shouldBootstrap, username: username, cursorColor: cursorColor, clientType: clientType, agentModel: agentModel })) : (_jsxs(_Fragment, { children: [_jsx(HistoryPlugin, {}), _jsx(OnChangePlugin, { onChange: handleChange })] })), _jsx(FeaturePlugins, { features: features }), autoFocus && _jsx(AutoFocusPlugin, {})] })] }) }));
|
|
224
|
+
}
|
|
225
|
+
// ============================================
|
|
226
|
+
// STYLES (CSS-in-JS for standalone usage)
|
|
227
|
+
// ============================================
|
|
228
|
+
export const richTextEditorStyles = `
|
|
229
|
+
.revealui-rich-text-editor {
|
|
230
|
+
border: 1px solid #e2e8f0;
|
|
231
|
+
border-radius: 8px;
|
|
232
|
+
overflow: hidden;
|
|
233
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.editor-toolbar {
|
|
237
|
+
display: flex;
|
|
238
|
+
gap: 4px;
|
|
239
|
+
padding: 8px;
|
|
240
|
+
border-bottom: 1px solid #e2e8f0;
|
|
241
|
+
background: #f8fafc;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.editor-toolbar--floating {
|
|
245
|
+
border-bottom: none;
|
|
246
|
+
border: 1px solid #e2e8f0;
|
|
247
|
+
border-radius: 8px;
|
|
248
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
249
|
+
background: white;
|
|
250
|
+
padding: 6px;
|
|
251
|
+
transition: opacity 0.2s ease;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.toolbar-btn {
|
|
255
|
+
padding: 6px 10px;
|
|
256
|
+
border: 1px solid #e2e8f0;
|
|
257
|
+
border-radius: 4px;
|
|
258
|
+
background: white;
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
font-size: 14px;
|
|
261
|
+
transition: all 0.15s ease;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.toolbar-btn:hover {
|
|
265
|
+
background: #f1f5f9;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.toolbar-btn.active {
|
|
269
|
+
background: #3b82f6;
|
|
270
|
+
color: white;
|
|
271
|
+
border-color: #3b82f6;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.editor-container {
|
|
275
|
+
position: relative;
|
|
276
|
+
min-height: 150px;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.editor-input {
|
|
280
|
+
padding: 16px;
|
|
281
|
+
outline: none;
|
|
282
|
+
min-height: 150px;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.editor-placeholder {
|
|
286
|
+
position: absolute;
|
|
287
|
+
top: 16px;
|
|
288
|
+
left: 16px;
|
|
289
|
+
color: #94a3b8;
|
|
290
|
+
pointer-events: none;
|
|
291
|
+
user-select: none;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.editor-paragraph {
|
|
295
|
+
margin: 0 0 8px 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.editor-heading-h1 { font-size: 2em; font-weight: bold; margin: 0 0 12px 0; }
|
|
299
|
+
.editor-heading-h2 { font-size: 1.5em; font-weight: bold; margin: 0 0 10px 0; }
|
|
300
|
+
.editor-heading-h3 { font-size: 1.25em; font-weight: bold; margin: 0 0 8px 0; }
|
|
301
|
+
.editor-heading-h4 { font-size: 1em; font-weight: bold; margin: 0 0 8px 0; }
|
|
302
|
+
.editor-heading-h5 { font-size: 0.875em; font-weight: bold; margin: 0 0 8px 0; }
|
|
303
|
+
.editor-heading-h6 { font-size: 0.75em; font-weight: bold; margin: 0 0 8px 0; }
|
|
304
|
+
|
|
305
|
+
.editor-quote {
|
|
306
|
+
border-left: 4px solid #e2e8f0;
|
|
307
|
+
padding-left: 16px;
|
|
308
|
+
margin: 0 0 8px 0;
|
|
309
|
+
color: #64748b;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.editor-list-ol { list-style: decimal; padding-left: 24px; margin: 0 0 8px 0; }
|
|
313
|
+
.editor-list-ul { list-style: disc; padding-left: 24px; margin: 0 0 8px 0; }
|
|
314
|
+
.editor-listitem { margin: 4px 0; }
|
|
315
|
+
|
|
316
|
+
.editor-link { color: #3b82f6; text-decoration: underline; }
|
|
317
|
+
|
|
318
|
+
.editor-text-bold { font-weight: bold; }
|
|
319
|
+
.editor-text-italic { font-style: italic; }
|
|
320
|
+
.editor-text-underline { text-decoration: underline; }
|
|
321
|
+
.editor-text-strikethrough { text-decoration: line-through; }
|
|
322
|
+
.editor-text-code {
|
|
323
|
+
background: #f1f5f9;
|
|
324
|
+
padding: 2px 4px;
|
|
325
|
+
border-radius: 4px;
|
|
326
|
+
font-family: monospace;
|
|
327
|
+
}
|
|
328
|
+
.editor-text-subscript { vertical-align: sub; font-size: smaller; }
|
|
329
|
+
.editor-text-superscript { vertical-align: super; font-size: smaller; }
|
|
330
|
+
|
|
331
|
+
.editor-code {
|
|
332
|
+
background: #1e293b;
|
|
333
|
+
color: #e2e8f0;
|
|
334
|
+
padding: 16px;
|
|
335
|
+
border-radius: 4px;
|
|
336
|
+
font-family: monospace;
|
|
337
|
+
overflow-x: auto;
|
|
338
|
+
margin: 8px 0;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.collab-cursors-container {
|
|
342
|
+
position: relative;
|
|
343
|
+
pointer-events: none;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.cursor-agent {
|
|
347
|
+
animation: cursor-agent-pulse 2s ease-in-out infinite;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@keyframes cursor-agent-pulse {
|
|
351
|
+
0%, 100% { opacity: 1; }
|
|
352
|
+
50% { opacity: 0.6; }
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.cursor-inactive {
|
|
356
|
+
opacity: 0.2;
|
|
357
|
+
transition: opacity 1s ease-out;
|
|
358
|
+
}
|
|
359
|
+
`;
|
|
360
|
+
export default RichTextEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ImageNodeData } from '../nodes/ImageNode.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
data: ImageNodeData;
|
|
5
|
+
nodeKey: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const ImageNodeComponent: React.FC<Props>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ImageNodeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageNodeComponent.d.ts","sourceRoot":"","sources":["../../../../src/client/richtext/components/ImageNodeComponent.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0J9C,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* RevealUI Rich Text Editor - Image Node Component
|
|
5
|
+
*
|
|
6
|
+
* React component for rendering and editing images in the editor.
|
|
7
|
+
*/
|
|
8
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
+
import { $getNodeByKey } from 'lexical';
|
|
10
|
+
import { useCallback, useState } from 'react';
|
|
11
|
+
import { OPEN_IMAGE_UPLOAD_COMMAND } from '../nodes/ImageNode.js';
|
|
12
|
+
export const ImageNodeComponent = (props) => {
|
|
13
|
+
const { data, nodeKey } = props;
|
|
14
|
+
const [editor] = useLexicalComposerContext();
|
|
15
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
16
|
+
const [editAlt, setEditAlt] = useState(data.alt || '');
|
|
17
|
+
const removeImage = useCallback(() => {
|
|
18
|
+
editor.update(() => {
|
|
19
|
+
const foundNode = $getNodeByKey(nodeKey);
|
|
20
|
+
if (foundNode) {
|
|
21
|
+
foundNode.remove();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}, [editor, nodeKey]);
|
|
25
|
+
const updateAlt = useCallback(() => {
|
|
26
|
+
if (editAlt !== data.alt) {
|
|
27
|
+
editor.update(() => {
|
|
28
|
+
const foundNode = $getNodeByKey(nodeKey);
|
|
29
|
+
if (foundNode && 'setData' in foundNode) {
|
|
30
|
+
;
|
|
31
|
+
foundNode.setData({
|
|
32
|
+
...data,
|
|
33
|
+
alt: editAlt,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
setIsEditing(false);
|
|
39
|
+
}, [editor, nodeKey, editAlt, data]);
|
|
40
|
+
const handleEdit = useCallback(() => {
|
|
41
|
+
editor.dispatchCommand(OPEN_IMAGE_UPLOAD_COMMAND, {
|
|
42
|
+
data,
|
|
43
|
+
nodeKey,
|
|
44
|
+
});
|
|
45
|
+
}, [editor, data, nodeKey]);
|
|
46
|
+
const [showControls, setShowControls] = useState(false);
|
|
47
|
+
return (_jsxs("figure", { className: "editor-image-container", style: { margin: '16px 0', textAlign: 'center' }, children: [_jsxs("div", { className: "editor-image-wrapper", style: { position: 'relative', display: 'inline-block' }, onMouseEnter: () => setShowControls(true), onMouseLeave: () => setShowControls(false), children: [_jsx("img", { src: data.src, alt: data.alt || '', width: data.width, height: data.height, style: {
|
|
48
|
+
maxWidth: '100%',
|
|
49
|
+
height: 'auto',
|
|
50
|
+
display: 'block',
|
|
51
|
+
}, onError: (e) => {
|
|
52
|
+
// Show placeholder on error
|
|
53
|
+
const target = e.target;
|
|
54
|
+
target.src =
|
|
55
|
+
'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="400" height="300"%3E%3Crect fill="%23e2e8f0" width="400" height="300"/%3E%3Ctext x="50%25" y="50%25" text-anchor="middle" dy=".3em" fill="%2394a3b8" font-family="sans-serif"%3EImage not found%3C/text%3E%3C/svg%3E';
|
|
56
|
+
} }), _jsxs("div", { className: "editor-image-controls", style: {
|
|
57
|
+
position: 'absolute',
|
|
58
|
+
top: '8px',
|
|
59
|
+
right: '8px',
|
|
60
|
+
display: 'flex',
|
|
61
|
+
gap: '4px',
|
|
62
|
+
opacity: showControls ? 1 : 0,
|
|
63
|
+
transition: 'opacity 0.2s',
|
|
64
|
+
pointerEvents: showControls ? 'auto' : 'none',
|
|
65
|
+
}, children: [_jsx("button", { type: "button", onClick: handleEdit, className: "editor-image-btn", style: {
|
|
66
|
+
padding: '4px 8px',
|
|
67
|
+
background: 'white',
|
|
68
|
+
border: '1px solid #e2e8f0',
|
|
69
|
+
borderRadius: '4px',
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
fontSize: '12px',
|
|
72
|
+
}, title: "Edit Image", "aria-label": "Edit Image", children: "\u270E" }), _jsx("button", { type: "button", onClick: removeImage, className: "editor-image-btn", style: {
|
|
73
|
+
padding: '4px 8px',
|
|
74
|
+
background: 'white',
|
|
75
|
+
border: '1px solid #e2e8f0',
|
|
76
|
+
borderRadius: '4px',
|
|
77
|
+
cursor: 'pointer',
|
|
78
|
+
fontSize: '12px',
|
|
79
|
+
}, title: "Remove Image", "aria-label": "Remove Image", children: "\u00D7" })] })] }), isEditing ? (_jsx("input", { type: "text", value: editAlt, onChange: (e) => setEditAlt(e.target.value), onBlur: updateAlt, onKeyDown: (e) => {
|
|
80
|
+
if (e.key === 'Enter') {
|
|
81
|
+
updateAlt();
|
|
82
|
+
}
|
|
83
|
+
else if (e.key === 'Escape') {
|
|
84
|
+
setEditAlt(data.alt || '');
|
|
85
|
+
setIsEditing(false);
|
|
86
|
+
}
|
|
87
|
+
}, placeholder: "Image alt text", style: {
|
|
88
|
+
width: '100%',
|
|
89
|
+
marginTop: '8px',
|
|
90
|
+
padding: '4px 8px',
|
|
91
|
+
border: '1px solid #e2e8f0',
|
|
92
|
+
borderRadius: '4px',
|
|
93
|
+
} })) : (data.caption && (_jsx("figcaption", { style: {
|
|
94
|
+
marginTop: '8px',
|
|
95
|
+
fontSize: '14px',
|
|
96
|
+
color: '#64748b',
|
|
97
|
+
fontStyle: 'italic',
|
|
98
|
+
}, children: data.caption })))] }));
|
|
99
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
interface ImageUploadButtonProps {
|
|
3
|
+
onUploadStart?: () => void;
|
|
4
|
+
onUploadComplete?: (url: string) => void;
|
|
5
|
+
onUploadError?: (error: Error) => void;
|
|
6
|
+
uploadEndpoint?: string;
|
|
7
|
+
acceptedFileTypes?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const ImageUploadButton: React.FC<ImageUploadButtonProps>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ImageUploadButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageUploadButton.d.ts","sourceRoot":"","sources":["../../../../src/client/richtext/components/ImageUploadButton.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,UAAU,sBAAsB;IAC9B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACtC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAqBD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA2H9D,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* RevealUI Rich Text Editor - Image Upload Button
|
|
5
|
+
*
|
|
6
|
+
* Component for uploading images and inserting them into the editor.
|
|
7
|
+
*/
|
|
8
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
+
import { logger } from '@revealui/core/utils/logger';
|
|
10
|
+
import { useCallback, useRef, useState } from 'react';
|
|
11
|
+
import { INSERT_IMAGE_COMMAND } from '../nodes/ImageNode.js';
|
|
12
|
+
const getUploadUrl = (payload) => {
|
|
13
|
+
if (!payload || typeof payload !== 'object') {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const result = payload;
|
|
17
|
+
if (typeof result.url === 'string')
|
|
18
|
+
return result.url;
|
|
19
|
+
if (typeof result.src === 'string')
|
|
20
|
+
return result.src;
|
|
21
|
+
if (result.data && typeof result.data.url === 'string')
|
|
22
|
+
return result.data.url;
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
export const ImageUploadButton = ({ onUploadStart, onUploadComplete, onUploadError, uploadEndpoint = '/api/media', acceptedFileTypes = 'image/jpeg,image/jpg,image/png,image/webp,image/gif', }) => {
|
|
26
|
+
const [editor] = useLexicalComposerContext();
|
|
27
|
+
const fileInputRef = useRef(null);
|
|
28
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
29
|
+
const handleFileSelect = useCallback(async (event) => {
|
|
30
|
+
const file = event.target.files?.[0];
|
|
31
|
+
if (!file)
|
|
32
|
+
return;
|
|
33
|
+
// Validate file type
|
|
34
|
+
if (!file.type.startsWith('image/')) {
|
|
35
|
+
onUploadError?.(new Error('File must be an image'));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Validate file size (default 10MB limit)
|
|
39
|
+
const maxSize = 10 * 1024 * 1024; // 10MB
|
|
40
|
+
if (file.size > maxSize) {
|
|
41
|
+
onUploadError?.(new Error('Image size must be less than 10MB'));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setIsUploading(true);
|
|
45
|
+
onUploadStart?.();
|
|
46
|
+
try {
|
|
47
|
+
// Read image dimensions
|
|
48
|
+
const imageDimensions = await new Promise((resolve, reject) => {
|
|
49
|
+
const img = new Image();
|
|
50
|
+
img.onload = () => {
|
|
51
|
+
resolve({ width: img.width, height: img.height });
|
|
52
|
+
};
|
|
53
|
+
img.onerror = reject;
|
|
54
|
+
img.src = URL.createObjectURL(file);
|
|
55
|
+
});
|
|
56
|
+
// Upload file
|
|
57
|
+
const formData = new FormData();
|
|
58
|
+
formData.append('file', file);
|
|
59
|
+
const response = await fetch(uploadEndpoint, {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
body: formData,
|
|
62
|
+
headers: {
|
|
63
|
+
// Don't set Content-Type - browser will set it with boundary for FormData
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
throw new Error(`Upload failed: ${response.statusText}`);
|
|
68
|
+
}
|
|
69
|
+
const result = (await response.json());
|
|
70
|
+
// Extract URL from response (adapt based on your API response structure)
|
|
71
|
+
const imageUrl = getUploadUrl(result);
|
|
72
|
+
if (!imageUrl) {
|
|
73
|
+
throw new Error('No URL returned from upload');
|
|
74
|
+
}
|
|
75
|
+
// Insert image into editor
|
|
76
|
+
editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
|
|
77
|
+
src: imageUrl,
|
|
78
|
+
alt: file.name.replace(/\.[^/.]+$/, ''), // Remove extension for alt text
|
|
79
|
+
width: imageDimensions.width,
|
|
80
|
+
height: imageDimensions.height,
|
|
81
|
+
});
|
|
82
|
+
onUploadComplete?.(imageUrl);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
logger.error('Image upload error', { error });
|
|
86
|
+
onUploadError?.(error instanceof Error ? error : new Error('Upload failed'));
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
setIsUploading(false);
|
|
90
|
+
// Reset file input
|
|
91
|
+
if (fileInputRef.current) {
|
|
92
|
+
fileInputRef.current.value = '';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [editor, uploadEndpoint, onUploadStart, onUploadComplete, onUploadError]);
|
|
96
|
+
const triggerFileSelect = useCallback(() => {
|
|
97
|
+
fileInputRef.current?.click();
|
|
98
|
+
}, []);
|
|
99
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { ref: fileInputRef, type: "file", accept: acceptedFileTypes, onChange: (event) => void handleFileSelect(event), style: { display: 'none' }, "aria-label": "Upload image" }), _jsx("button", { type: "button", onClick: triggerFileSelect, disabled: isUploading, className: "toolbar-btn", title: isUploading ? 'Uploading...' : 'Insert Image', "aria-label": "Insert Image", style: {
|
|
100
|
+
opacity: isUploading ? 0.6 : 1,
|
|
101
|
+
cursor: isUploading ? 'wait' : 'pointer',
|
|
102
|
+
}, children: isUploading ? '⏳' : '🖼️' })] }));
|
|
103
|
+
};
|