xertica-ui 2.4.0 → 2.5.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/CHANGELOG.md +621 -564
- package/README.md +443 -417
- package/assets/xertica-logo.svg +37 -37
- package/assets/xertica-x-logo.svg +20 -20
- package/bin/cli.ts +1244 -1244
- package/bin/generate-tokens.ts +9 -9
- package/bin/language-config.ts +358 -358
- package/components/assistant/code-block/CodeBlock.tsx +268 -268
- package/components/assistant/formatted-document/FormattedDocument.tsx +147 -147
- package/components/assistant/modern-chat-input/ModernChatInput.tsx +564 -564
- package/components/assistant/xertica-assistant/parts/AssistantCollapsedView.tsx +99 -99
- package/components/assistant/xertica-assistant/parts/AssistantConversationList.tsx +104 -104
- package/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.tsx +81 -81
- package/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.tsx +88 -88
- package/components/assistant/xertica-assistant/parts/AssistantHeader.tsx +75 -75
- package/components/assistant/xertica-assistant/parts/AssistantMessageBubble.tsx +564 -564
- package/components/assistant/xertica-assistant/parts/AssistantTabBar.tsx +67 -67
- package/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.tsx +103 -103
- package/components/assistant/xertica-assistant/use-assistant.ts +615 -615
- package/components/assistant/xertica-assistant/xertica-assistant.tsx +611 -611
- package/components/blocks/card-patterns/ActivityCard.tsx +100 -100
- package/components/blocks/card-patterns/ActivityCardSkeleton.tsx +56 -56
- package/components/blocks/card-patterns/FeatureCardSkeleton.tsx +58 -58
- package/components/blocks/card-patterns/NotificationCard.tsx +140 -140
- package/components/blocks/card-patterns/NotificationCardSkeleton.tsx +81 -81
- package/components/blocks/card-patterns/ProfileCard.tsx +112 -112
- package/components/blocks/card-patterns/ProfileCardSkeleton.tsx +69 -69
- package/components/blocks/card-patterns/ProjectCard.tsx +123 -123
- package/components/blocks/card-patterns/ProjectCardSkeleton.tsx +67 -67
- package/components/blocks/card-patterns/QuickActionCardSkeleton.tsx +44 -44
- package/components/blocks/card-patterns/card-patterns.stories.tsx +594 -594
- package/components/blocks/card-patterns/index.ts +29 -29
- package/components/brand/language-selector/LanguageSelector.tsx +102 -102
- package/components/brand/language-selector/language-selector.stories.tsx +111 -111
- package/components/brand/language-selector/language-selector.test.tsx +101 -101
- package/components/brand/theme-toggle/ThemeToggle.tsx +74 -74
- package/components/brand/xertica-provider/XerticaProvider.tsx +112 -109
- package/components/brand/xertica-provider/xertica-provider.mdx +61 -61
- package/components/index.ts +86 -86
- package/components/layout/sidebar/sidebar.mdx +1 -1
- package/components/layout/sidebar/sidebar.stories.tsx +201 -0
- package/components/layout/sidebar/sidebar.tsx +1164 -1079
- package/components/media/FloatingMediaWrapper.tsx +371 -371
- package/components/media/audio-player/AudioPlayer.tsx +768 -768
- package/components/media/video-player/VideoPlayer.tsx +310 -310
- package/components/pages/forgot-password-page/ForgotPasswordPage.tsx +188 -188
- package/components/pages/home-content/HomeContent.tsx +120 -120
- package/components/pages/home-content/home-content.mdx +62 -62
- package/components/pages/home-page/HomePage.tsx +78 -78
- package/components/pages/home-page/home-page.mdx +53 -53
- package/components/pages/login-page/LoginPage.tsx +218 -218
- package/components/pages/reset-password-page/ResetPasswordPage.tsx +243 -243
- package/components/pages/template-content/TemplateContent.tsx +1354 -1354
- package/components/pages/template-content/template-content.mdx +61 -61
- package/components/pages/template-page/TemplatePage.stories.tsx +8 -15
- package/components/pages/template-page/template-page.mdx +53 -53
- package/components/pages/verify-email-page/VerifyEmailPage.tsx +206 -206
- package/components/shared/error-boundary.stories.tsx +114 -114
- package/components/shared/error-boundary.tsx +150 -150
- package/components/shared/error-fallbacks.tsx +222 -222
- package/components/ui/accordion/accordion.mdx +8 -8
- package/components/ui/alert/alert.mdx +8 -8
- package/components/ui/alert-dialog/alert-dialog.mdx +8 -8
- package/components/ui/aspect-ratio/aspect-ratio.mdx +8 -8
- package/components/ui/assistant-chart/assistant-chart.mdx +8 -8
- package/components/ui/avatar/avatar.mdx +8 -8
- package/components/ui/badge/badge.mdx +8 -8
- package/components/ui/breadcrumb/breadcrumb.mdx +8 -8
- package/components/ui/button/button.mdx +8 -8
- package/components/ui/calendar/calendar.mdx +8 -8
- package/components/ui/card/card.mdx +8 -8
- package/components/ui/carousel/carousel.mdx +8 -8
- package/components/ui/chart/chart.mdx +8 -8
- package/components/ui/chart/chart.test.tsx +1 -1
- package/components/ui/chart/chart.tsx +13 -6
- package/components/ui/checkbox/checkbox.mdx +8 -8
- package/components/ui/collapsible/collapsible.mdx +8 -8
- package/components/ui/command/command.mdx +8 -8
- package/components/ui/context-menu/context-menu.mdx +8 -8
- package/components/ui/dialog/dialog.mdx +8 -8
- package/components/ui/drawer/drawer.mdx +8 -8
- package/components/ui/dropdown-menu/dropdown-menu.mdx +8 -8
- package/components/ui/empty/empty.mdx +8 -8
- package/components/ui/file-upload/file-upload.mdx +8 -8
- package/components/ui/hover-card/hover-card.mdx +8 -8
- package/components/ui/input/input.mdx +8 -8
- package/components/ui/input-otp/input-otp.mdx +8 -8
- package/components/ui/label/label.mdx +8 -8
- package/components/ui/map/map.mdx +8 -8
- package/components/ui/menubar/menubar.mdx +8 -8
- package/components/ui/navigation-menu/navigation-menu.mdx +8 -8
- package/components/ui/notification-badge/notification-badge.mdx +8 -8
- package/components/ui/pagination/pagination.mdx +8 -8
- package/components/ui/popover/popover.mdx +8 -8
- package/components/ui/progress/progress.mdx +8 -8
- package/components/ui/radio-group/radio-group.mdx +8 -8
- package/components/ui/rating/rating.mdx +8 -8
- package/components/ui/resizable/resizable.mdx +8 -8
- package/components/ui/route-map/route-map.mdx +8 -8
- package/components/ui/scroll-area/scroll-area.mdx +8 -8
- package/components/ui/search/search.mdx +8 -8
- package/components/ui/select/select.mdx +8 -8
- package/components/ui/separator/separator.mdx +8 -8
- package/components/ui/sheet/sheet.mdx +8 -8
- package/components/ui/simple-map/simple-map.mdx +8 -8
- package/components/ui/skeleton/skeleton.mdx +8 -8
- package/components/ui/slider/slider.mdx +8 -8
- package/components/ui/sonner/sonner.mdx +8 -8
- package/components/ui/stats-card/index.ts +2 -2
- package/components/ui/stats-card/stats-card-skeleton.tsx +60 -60
- package/components/ui/stats-card/stats-card.mdx +8 -8
- package/components/ui/stats-card/stats-card.stories.tsx +117 -99
- package/components/ui/stats-card/stats-card.tsx +18 -2
- package/components/ui/stepper/stepper.mdx +8 -8
- package/components/ui/switch/switch.mdx +8 -8
- package/components/ui/table/table.mdx +8 -8
- package/components/ui/tabs/tabs.mdx +8 -8
- package/components/ui/textarea/textarea.mdx +8 -8
- package/components/ui/timeline/timeline.mdx +8 -8
- package/components/ui/toggle/toggle.mdx +8 -8
- package/components/ui/toggle-group/toggle-group.mdx +8 -8
- package/components/ui/tooltip/tooltip.mdx +8 -8
- package/components/ui/tree-view/tree-view.mdx +8 -8
- package/components.json +153 -533
- package/contexts/AuthContext.tsx +121 -121
- package/contexts/BrandColorsContext.tsx +39 -8
- package/contexts/LanguageContext.test.tsx +121 -121
- package/contexts/LanguageContext.tsx +250 -250
- package/contexts/theme-data.ts +51 -0
- package/dist/AssistantChart-BKVtGUKF.js +3383 -0
- package/dist/AssistantChart-BZTPJ5dP.cjs +3551 -0
- package/dist/{AssistantChart-BAx9VQvb.cjs → AssistantChart-Bdd44uBn.cjs} +388 -127
- package/dist/{AssistantChart-CVko2A1W.js → AssistantChart-CFhDdGyU.js} +391 -130
- package/dist/{AssistantChart-CVzmmhx4.js → AssistantChart-C_hwFRRr.js} +4 -4
- package/dist/{AssistantChart-BAudAfne.cjs → AssistantChart-CldVCVDe.cjs} +5 -5
- package/dist/{AssistantChart-BP8upjMk.js → AssistantChart-Cu3m7RBo.js} +5 -5
- package/dist/AssistantChart-CxGjH7Qk.js +3477 -0
- package/dist/AssistantChart-DIpshm3i.js +4784 -0
- package/dist/AssistantChart-DMJJ_Amf.js +3383 -0
- package/dist/AssistantChart-D_PTeu8P.cjs +3503 -0
- package/dist/{AssistantChart-9w31gdAb.cjs → AssistantChart-DoZCyS5r.cjs} +4 -4
- package/dist/AssistantChart-WeycT5Pd.cjs +3551 -0
- package/dist/AssistantChart-zjsy2GaZ.cjs +4810 -0
- package/dist/AudioPlayer-B1lt5cPl.cjs +989 -0
- package/dist/AudioPlayer-BZ7bibzU.cjs +982 -0
- package/dist/AudioPlayer-BpRPS4-1.cjs +1277 -0
- package/dist/AudioPlayer-C12BjQBV.cjs +997 -0
- package/dist/{AudioPlayer-1ypwE2Wh.cjs → AudioPlayer-CFeV8t-5.cjs} +1 -1
- package/dist/{AudioPlayer-DuKXrCfy.js → AudioPlayer-CGRUtUdN.js} +1 -1
- package/dist/AudioPlayer-Coly3q5R.js +1278 -0
- package/dist/AudioPlayer-CySJIyvL.js +937 -0
- package/dist/AudioPlayer-DMcG_c7L.js +990 -0
- package/dist/AudioPlayer-DcFKRJE_.js +998 -0
- package/dist/AudioPlayer-IAU5q5T1.cjs +936 -0
- package/dist/AudioPlayer-e8LfNoqO.js +983 -0
- package/dist/BrandColorsContext-565dDHd5.js +660 -0
- package/dist/BrandColorsContext-BMRJ04Wf.js +718 -0
- package/dist/BrandColorsContext-BcJbtkqn.cjs +659 -0
- package/dist/BrandColorsContext-BwY-b6M4.cjs +725 -0
- package/dist/{xertica-assistant-Qp3ydksa.cjs → CodeBlock-7TTgmdGG.cjs} +263 -51
- package/dist/{xertica-assistant-gnCJdcZY.js → CodeBlock-BeSt1h5P.js} +219 -7
- package/dist/CodeBlock-BgfYL_rD.cjs +2094 -0
- package/dist/CodeBlock-BlcqlA9M.cjs +2094 -0
- package/dist/CodeBlock-Bnmeu5ez.cjs +2094 -0
- package/dist/CodeBlock-BtfPlbAI.js +2078 -0
- package/dist/CodeBlock-CIySIuYr.js +2078 -0
- package/dist/CodeBlock-CuPtUM-7.cjs +2094 -0
- package/dist/CodeBlock-D6ffWXgc.js +2078 -0
- package/dist/CodeBlock-D8dcwbit.cjs +2094 -0
- package/dist/CodeBlock-DMZrFnlw.cjs +2094 -0
- package/dist/CodeBlock-DlBehYN8.js +2078 -0
- package/dist/CodeBlock-DnYNI8rQ.js +2078 -0
- package/dist/CodeBlock-DvKWbSnE.cjs +2094 -0
- package/dist/CodeBlock-DwMCfkFY.js +2078 -0
- package/dist/CodeBlock-Dy6CNYyj.js +2078 -0
- package/dist/CodeBlock-U1pPOQI7.cjs +2094 -0
- package/dist/CodeBlock-f_GpNhEB.js +2078 -0
- package/dist/CodeBlock-oB6u8nI1.js +2078 -0
- package/dist/CodeBlock-tZC31B73.cjs +2094 -0
- package/dist/FeatureCard-CxC-7C-C.cjs +300 -0
- package/dist/FeatureCard-DbHWCb4E.js +301 -0
- package/dist/ImageWithFallback-CGtidP6B.cjs +4542 -0
- package/dist/ImageWithFallback-lsg3pdFg.js +4508 -0
- package/dist/{LanguageContext-DvUt5jBg.cjs → LanguageContext-B_KFTCzT.cjs} +2 -2
- package/dist/{LanguageContext-BwhwC3G2.js → LanguageContext-CS14yCpi.js} +2 -2
- package/dist/{XerticaXLogo-DHz5SugF.js → LanguageSelector-B5YfbHra.js} +115 -136
- package/dist/{XerticaXLogo-DTee_y8X.cjs → LanguageSelector-D6uacAIM.cjs} +115 -136
- package/dist/LayoutContext-B45-e9DI.cjs +93 -0
- package/dist/LayoutContext-BAql6ZRY.js +97 -0
- package/dist/LayoutContext-Bav3UMEA.js +94 -0
- package/dist/LayoutContext-BvK-ggDa.cjs +96 -0
- package/dist/{ThemeContext-Bo-W2WZH.js → ThemeContext-BWq9ACPo.js} +8 -13
- package/dist/{ThemeContext-ept8jhXI.js → ThemeContext-BXjrgUjW.js} +261 -200
- package/dist/{ThemeContext-BblcjQup.cjs → ThemeContext-Bmod0Cg2.cjs} +8 -13
- package/dist/ThemeContext-BoH4NLfN.js +734 -0
- package/dist/{ThemeContext-BbBNoFTG.js → ThemeContext-C2EwAPDt.js} +2 -2
- package/dist/{ThemeContext-U4dEYc6C.cjs → ThemeContext-CGk3KK0k.cjs} +1 -8
- package/dist/{ThemeContext-D3LzacmG.js → ThemeContext-CQSo4Iwc.js} +1 -8
- package/dist/{ThemeContext-CP3a0jxy.cjs → ThemeContext-j5aGtPky.cjs} +262 -193
- package/dist/ThemeContext-r69W20Xg.cjs +733 -0
- package/dist/{ThemeContext-Cmr8Ex8H.cjs → ThemeContext-vTjumZeM.cjs} +2 -2
- package/dist/{VerifyEmailPage-BRSP-Pwt.cjs → VerifyEmailPage--1Vurewl.cjs} +3 -3
- package/dist/{VerifyEmailPage-CbgjOF0v.js → VerifyEmailPage-1WwWczAn.js} +12 -22
- package/dist/{VerifyEmailPage-DF2ilhum.cjs → VerifyEmailPage-B4peJjAT.cjs} +356 -334
- package/dist/{VerifyEmailPage-CR7kb5df.cjs → VerifyEmailPage-BComraR7.cjs} +12 -22
- package/dist/{VerifyEmailPage-u_Dn7t1U.cjs → VerifyEmailPage-Bp1XXl3H.cjs} +4 -4
- package/dist/{VerifyEmailPage-CkBYfsNy.cjs → VerifyEmailPage-By3Jf__L.cjs} +4 -4
- package/dist/{VerifyEmailPage-Bv8Ah_TK.cjs → VerifyEmailPage-ByerOcm4.cjs} +20 -23
- package/dist/{VerifyEmailPage-BE-L9mB7.js → VerifyEmailPage-C0c2e5n0.js} +7 -7
- package/dist/{VerifyEmailPage-EhudUdqF.js → VerifyEmailPage-C5TNQTBa.js} +355 -343
- package/dist/{VerifyEmailPage-Dt7zgA4w.cjs → VerifyEmailPage-CFLMls1p.cjs} +4 -4
- package/dist/{VerifyEmailPage-Bvfv8HVQ.js → VerifyEmailPage-CGIwmWrm.js} +461 -379
- package/dist/{VerifyEmailPage-Cyl55sJb.js → VerifyEmailPage-CJLz3jrn.js} +20 -23
- package/dist/VerifyEmailPage-COiyNl1y.js +2825 -0
- package/dist/{VerifyEmailPage-DMBh4NM9.cjs → VerifyEmailPage-CYXtbKi3.cjs} +1 -1
- package/dist/{VerifyEmailPage-DTtFfC-J.js → VerifyEmailPage-CgMxRb4z.js} +3 -3
- package/dist/VerifyEmailPage-CpqqpLpo.cjs +3305 -0
- package/dist/VerifyEmailPage-CqKsR2v8.js +2827 -0
- package/dist/{VerifyEmailPage-Bae2cBXT.cjs → VerifyEmailPage-Cwi3kbol.cjs} +7 -7
- package/dist/{VerifyEmailPage-X14vhdyl.js → VerifyEmailPage-DGhuIqkb.js} +4 -4
- package/dist/{VerifyEmailPage-BIBOKV7Z.js → VerifyEmailPage-DSBMRHtl.js} +36 -41
- package/dist/{VerifyEmailPage-D-FRj5TU.cjs → VerifyEmailPage-De6bQjrz.cjs} +36 -41
- package/dist/{VerifyEmailPage-BJjAMUTW.js → VerifyEmailPage-DgIid028.js} +4 -4
- package/dist/VerifyEmailPage-DjQKRlUS.cjs +2824 -0
- package/dist/{VerifyEmailPage-CdYPSJoO.js → VerifyEmailPage-DvMLZgFt.js} +1 -1
- package/dist/{VerifyEmailPage-C_ihbcth.js → VerifyEmailPage-MTD7AG1Z.js} +4 -4
- package/dist/VerifyEmailPage-s-1X3LDJ.cjs +2826 -0
- package/dist/XerticaOrbe-KL1RBHzw.cjs +1354 -0
- package/dist/XerticaOrbe-zwS1p2a8.js +1355 -0
- package/dist/XerticaProvider-6btlAlzc.js +17 -0
- package/dist/{XerticaProvider-siSt9uG2.js → XerticaProvider-B7EVH-NF.js} +2 -2
- package/dist/{XerticaProvider-AbWlr7Af.cjs → XerticaProvider-BIrqfZ-i.cjs} +11 -8
- package/dist/XerticaProvider-BNoNOxQ5.cjs +16 -0
- package/dist/XerticaProvider-BlY2limY.cjs +38 -0
- package/dist/{XerticaProvider-CWgby5mY.js → XerticaProvider-C1DKnvLh.js} +4 -4
- package/dist/{XerticaProvider-AChwphCO.cjs → XerticaProvider-CBGc4EMA.cjs} +4 -4
- package/dist/{XerticaProvider-BITjgC5p.js → XerticaProvider-CEoWMTxu.js} +2 -2
- package/dist/XerticaProvider-CeS5G_n5.cjs +45 -0
- package/dist/{XerticaProvider-By8q3Roe.cjs → XerticaProvider-CllrbMEJ.cjs} +2 -2
- package/dist/{XerticaProvider-B8CaV7xu.cjs → XerticaProvider-D-yNhF94.cjs} +1 -1
- package/dist/XerticaProvider-DDuiIcKo.js +39 -0
- package/dist/{XerticaProvider-DQtvJU7m.js → XerticaProvider-DYq4JWtg.js} +1 -1
- package/dist/{XerticaProvider-CWs6EwNa.js → XerticaProvider-Dt5HEzbQ.js} +10 -10
- package/dist/{XerticaProvider-CW9hpCdF.cjs → XerticaProvider-ET0ihewn.cjs} +2 -2
- package/dist/XerticaProvider-cI9hSs27.cjs +38 -0
- package/dist/XerticaProvider-hSwhNQex.js +39 -0
- package/dist/XerticaProvider-ra2NciRq.js +43 -0
- package/dist/{XerticaXLogo-ChryA6xj.js → XerticaXLogo-B7xQ5dhi.js} +1 -1
- package/dist/{XerticaXLogo-CziKMQil.cjs → XerticaXLogo-CQUUjXoH.cjs} +8 -8
- package/dist/{XerticaXLogo-DfUvz-lD.js → XerticaXLogo-Cmsp-Eey.js} +9 -9
- package/dist/{XerticaXLogo-CFuIlYFH.js → XerticaXLogo-DZbo4vOE.js} +12 -12
- package/dist/{XerticaXLogo-8TTzBjHw.cjs → XerticaXLogo-Zw2B276b.cjs} +1 -1
- package/dist/{XerticaXLogo-kslQ8Tk_.cjs → XerticaXLogo-bvZSgwGF.cjs} +13 -7
- package/dist/alert-dialog-BOje--vD.js +847 -0
- package/dist/alert-dialog-BtEuQqrg.cjs +870 -0
- package/dist/{alert-dialog-yckpaOpy.cjs → alert-dialog-DSKByiKZ.cjs} +3 -3
- package/dist/{alert-dialog-iDe5VE5o.js → alert-dialog-s-vmNkJ_.js} +3 -3
- package/dist/assistant.cjs.js +1 -1
- package/dist/assistant.es.js +1 -1
- package/dist/brand.cjs.js +1 -1
- package/dist/brand.es.js +1 -1
- package/dist/breadcrumb-CqJ7bHY5.js +161 -0
- package/dist/breadcrumb-m9Hb2_XN.cjs +177 -0
- package/dist/cli.js +45 -9
- package/dist/components/assistant/xertica-assistant/hooks/index.d.ts +6 -0
- package/dist/components/assistant/xertica-assistant/hooks/use-assistant-conversations.d.ts +21 -0
- package/dist/components/assistant/xertica-assistant/hooks/use-assistant-messages.d.ts +49 -0
- package/dist/components/assistant/xertica-assistant/hooks/use-assistant-suggestions.d.ts +16 -0
- package/dist/components/blocks/audio-player/AudioPlayer.d.ts +35 -0
- package/dist/components/blocks/audio-player/index.d.ts +1 -0
- package/dist/components/blocks/document-editor/DocumentEditor.d.ts +26 -0
- package/dist/components/blocks/document-editor/index.d.ts +1 -0
- package/dist/components/blocks/podcast-player/PodcastPlayer.d.ts +41 -0
- package/dist/components/blocks/podcast-player/index.d.ts +1 -0
- package/dist/components/brand/xertica-provider/XerticaProvider.d.ts +3 -1
- package/dist/components/ui/chart/chart.d.ts +12 -3
- package/dist/components/ui/chart/parts/chart-dashboard.d.ts +113 -0
- package/dist/components/ui/chart/parts/chart-metric.d.ts +118 -0
- package/dist/components/ui/chart/parts/chart-primitives.d.ts +101 -0
- package/dist/components/ui/chart/parts/chart-shared.d.ts +20 -0
- package/dist/components/ui/chart/parts/chart-utils.d.ts +12 -0
- package/dist/components/ui/chart/parts/index.d.ts +5 -0
- package/dist/components/ui/stats-card/stats-card.d.ts +10 -0
- package/dist/contexts/theme-data.d.ts +4 -0
- package/dist/dropdown-menu-BDB5CmQs.cjs +247 -0
- package/dist/dropdown-menu-DQidbKBD.js +231 -0
- package/dist/google-maps-loader-BFWp6VPd.js +287 -0
- package/dist/google-maps-loader-BKcdgFbu.cjs +312 -0
- package/dist/{google-maps-loader-t2IlYBzw.js → google-maps-loader-CTYySAun.js} +4 -0
- package/dist/google-maps-loader-CumCNXeG.js +312 -0
- package/dist/{google-maps-loader-BqsYL48U.cjs → google-maps-loader-Y-QkD-Li.cjs} +5 -0
- package/dist/google-maps-loader-eS3uQ5TA.cjs +287 -0
- package/dist/header-Cgy6vYPk.cjs +731 -0
- package/dist/header-DRlT4jgI.js +715 -0
- package/dist/header-Dux00SI4.cjs +731 -0
- package/dist/header-EkGKXPsD.js +715 -0
- package/dist/header-WfEywpyc.cjs +731 -0
- package/dist/header-tifNQn2U.js +715 -0
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +1 -1
- package/dist/index-BhapVLVj.js +8 -0
- package/dist/{index-D3RLKRAs.cjs → index-COtD8bRW.cjs} +1 -1
- package/dist/index-D6fxYEY8.cjs +7 -0
- package/dist/index-DAIp0_HK.js +8 -0
- package/dist/index-DW5tYe26.js +8 -0
- package/dist/index-GA__GvnG.cjs +7 -0
- package/dist/index.cjs.js +6 -6
- package/dist/index.es.js +6 -6
- package/dist/index.umd.js +1043 -470
- package/dist/input-2R4loU86.js +127 -0
- package/dist/input-DWANSKGb.cjs +145 -0
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.es.js +1 -1
- package/dist/pages.cjs.js +1 -1
- package/dist/pages.es.js +1 -1
- package/dist/progress-DPtzoVV8.js +175 -0
- package/dist/progress-EeaoqqUs.cjs +191 -0
- package/dist/rich-text-editor-0mraWT5y.cjs +2376 -0
- package/dist/rich-text-editor-B-IkcPD0.js +2874 -0
- package/dist/rich-text-editor-B2CKz7nx.cjs +2903 -0
- package/dist/rich-text-editor-B6jMRLzk.cjs +1939 -0
- package/dist/rich-text-editor-B8_oYcIR.js +1730 -0
- package/dist/rich-text-editor-B9UbSXNb.js +1203 -0
- package/dist/rich-text-editor-BYuRBNBU.js +2373 -0
- package/dist/rich-text-editor-Bb9pySTs.cjs +2374 -0
- package/dist/rich-text-editor-BcL6L3cm.cjs +2374 -0
- package/dist/rich-text-editor-BoVZYtTs.cjs +2391 -0
- package/dist/rich-text-editor-Bp3zQqMC.js +2954 -0
- package/dist/rich-text-editor-CMgSN_w2.js +1189 -0
- package/dist/rich-text-editor-CPV1lEPH.cjs +1748 -0
- package/dist/rich-text-editor-CeucBdIv.cjs +2971 -0
- package/dist/rich-text-editor-CoKqbCtu.cjs +1799 -0
- package/dist/rich-text-editor-Cw56T_mB.js +2356 -0
- package/dist/rich-text-editor-Cyt8qs2b.js +1921 -0
- package/dist/rich-text-editor-D6H84OcX.cjs +1220 -0
- package/dist/rich-text-editor-D76gD-QI.js +2328 -0
- package/dist/rich-text-editor-DKkokOnA.js +1781 -0
- package/dist/rich-text-editor-DNsdpN64.cjs +2359 -0
- package/dist/rich-text-editor-DfG8bCyY.js +2358 -0
- package/dist/rich-text-editor-DloeW0wc.js +2832 -0
- package/dist/rich-text-editor-Dxjw31Z4.js +2341 -0
- package/dist/rich-text-editor-DzP0Epmb.js +2356 -0
- package/dist/rich-text-editor-bRkNoeZY.cjs +2891 -0
- package/dist/rich-text-editor-lyYE2ZG5.cjs +1207 -0
- package/dist/rich-text-editor-skplNlBM.cjs +2345 -0
- package/dist/select-Bkbr0f-Z.cjs +162 -0
- package/dist/select-CvIVdX2n.js +145 -0
- package/dist/{sidebar-CplprZpM.js → sidebar-0ocFLSks.js} +127 -50
- package/dist/{sidebar-CA6_ek3f.js → sidebar-B6SlKZYN.js} +40 -49
- package/dist/{sidebar-CmvwjnVb.js → sidebar-BViy8Eeu.js} +17 -9
- package/dist/{sidebar-Dz7bd3zP.js → sidebar-BbVIQvlP.js} +1 -1
- package/dist/{sidebar-CVUGHOS_.cjs → sidebar-BxGXsDAd.cjs} +16 -8
- package/dist/sidebar-CK_0ZQHj.cjs +803 -0
- package/dist/sidebar-CUuOvYhK.js +787 -0
- package/dist/{sidebar-B3EYhli0.cjs → sidebar-CeTMuzOx.cjs} +128 -47
- package/dist/{sidebar-KIS0C2JH.js → sidebar-CrQDDdcz.js} +24 -33
- package/dist/{sidebar-zowjejT2.cjs → sidebar-DAaY8bRU.cjs} +24 -33
- package/dist/{sidebar-B9NR0lCe.cjs → sidebar-DQj1z3jG.cjs} +227 -269
- package/dist/sidebar-Djn5syhi.cjs +786 -0
- package/dist/sidebar-LluMXfam.js +759 -0
- package/dist/sidebar-_rT7rBMk.js +787 -0
- package/dist/{sidebar-BvF5I2Ue.cjs → sidebar-nzPoVHBQ.cjs} +41 -46
- package/dist/{sidebar-C5B_LHek.cjs → sidebar-q7P2Godd.cjs} +1 -1
- package/dist/slider-Bc5Hd0y1.js +56 -0
- package/dist/slider-N7hFFj6X.cjs +73 -0
- package/dist/tooltip-Ded96neP.cjs +137 -0
- package/dist/tooltip-HDOoD2-0.js +120 -0
- package/dist/ui.cjs.js +2 -2
- package/dist/ui.es.js +2 -2
- package/dist/use-audio-player-B31J-aqh.cjs +187 -0
- package/dist/use-audio-player-BkmEmj8Q.js +185 -0
- package/dist/use-audio-player-CLFTWFW1.cjs +184 -0
- package/dist/use-audio-player-CLLn00I6.js +188 -0
- package/dist/{use-audio-player-Dn1NR9xN.cjs → use-audio-player-NKsWyjWu.cjs} +7 -3
- package/dist/{use-audio-player-Bkh23vQ3.js → use-audio-player-nv8ZSGa1.js} +7 -3
- package/dist/use-file-upload-BcjEo2S5.js +404 -0
- package/dist/use-file-upload-CRJR68Tj.cjs +403 -0
- package/dist/use-mobile-B0hNy_Y6.cjs +4303 -0
- package/dist/use-mobile-BXuYROXM.js +4202 -0
- package/dist/use-mobile-Bbd51ASU.cjs +4392 -0
- package/dist/use-mobile-Bk6CX-TC.js +4359 -0
- package/dist/use-mobile-BvYdisLP.js +4202 -0
- package/dist/use-mobile-BzuxjzNX.cjs +4392 -0
- package/dist/use-mobile-CG2-SdXV.cjs +4235 -0
- package/dist/use-mobile-CKb5pqTs.js +4269 -0
- package/dist/use-mobile-CYuAuGDl.js +4202 -0
- package/dist/use-mobile-CaENcqm-.js +4508 -0
- package/dist/use-mobile-CbrYgJGJ.js +4203 -0
- package/dist/use-mobile-Cd4xPrKq.cjs +46 -0
- package/dist/use-mobile-DMOvImGQ.cjs +4542 -0
- package/dist/use-mobile-DRB3BQgD.cjs +4235 -0
- package/dist/use-mobile-DZvv7QMR.js +4359 -0
- package/dist/use-mobile-DdI_TXam.cjs +4235 -0
- package/dist/use-mobile-DlceKf8a.js +4359 -0
- package/dist/use-mobile-DsOnow1o.cjs +4236 -0
- package/dist/use-mobile-Kcj6jSnK.cjs +4392 -0
- package/dist/use-mobile-bnKcua_i.js +4202 -0
- package/dist/use-mobile-j4w2Jrf1.js +30 -0
- package/dist/use-mobile-ncXBeE2z.cjs +4235 -0
- package/dist/use-rich-text-editor-DjiddBGv.js +282 -0
- package/dist/use-rich-text-editor-lpeswbCs.cjs +281 -0
- package/dist/xertica-assistant-BdiZag0h.js +2187 -0
- package/dist/xertica-assistant-CrgTb6Hs.cjs +2155 -0
- package/dist/xertica-assistant-CyikE3N_.js +2173 -0
- package/dist/xertica-assistant-DCsnQyi5.js +2156 -0
- package/dist/xertica-assistant-DUBpmEgo.cjs +2186 -0
- package/dist/xertica-assistant-QFUnv5I2.cjs +2180 -0
- package/dist/{xertica-assistant-Bj3vBCq_.cjs → xertica-assistant-V_IdW4WF.cjs} +27 -9
- package/dist/{xertica-assistant-BMqdyRVi.js → xertica-assistant-ciJaWqm1.js} +28 -10
- package/dist/{xertica-assistant-B1IaHXnB.cjs → xertica-assistant-dyP7KHM5.cjs} +533 -392
- package/dist/{xertica-assistant-DPsESB6t.js → xertica-assistant-yX1CFBBo.js} +535 -394
- package/dist/xertica-ui.css +2 -2
- package/docs/architecture-improvements.md +456 -456
- package/docs/architecture.md +312 -312
- package/docs/components/assistant.md +428 -428
- package/docs/components/branding.md +252 -252
- package/docs/components/card-patterns.md +447 -447
- package/docs/components/error-boundary.md +201 -201
- package/docs/components/hooks.md +432 -432
- package/docs/components/language-selector.md +176 -176
- package/docs/components/pages.md +323 -323
- package/docs/components/sidebar.md +19 -2
- package/docs/components/stats-card.md +20 -2
- package/docs/doc-audit.md +244 -244
- package/docs/getting-started.md +616 -616
- package/docs/guidelines.md +330 -330
- package/docs/i18n.md +480 -480
- package/docs/installation.md +268 -268
- package/docs/llms.md +295 -295
- package/docs/state-management.md +289 -289
- package/guidelines/Guidelines.md +409 -409
- package/llms-compact.txt +30 -1
- package/llms-full.txt +11553 -7133
- package/llms.txt +1 -1
- package/package.json +219 -219
- package/styles/xertica/base.css +90 -90
- package/styles/xertica/tokens.css +9 -9
- package/templates/.prettierignore +4 -4
- package/templates/.prettierrc +10 -10
- package/templates/CLAUDE.md +180 -180
- package/templates/guidelines/Guidelines.md +865 -577
- package/templates/package.json +69 -69
- package/templates/src/app/App.tsx +46 -46
- package/templates/src/app/components/AuthGuard.tsx +131 -131
- package/templates/src/features/assistant/data/mock.ts +75 -75
- package/templates/src/features/assistant/hooks/useAssistantConfig.ts +20 -20
- package/templates/src/features/assistant/index.ts +5 -5
- package/templates/src/features/auth/ui/AuthPageShell.tsx +32 -32
- package/templates/src/features/auth/ui/ForgotPasswordContent.tsx +70 -70
- package/templates/src/features/auth/ui/LoginContent.tsx +92 -92
- package/templates/src/features/auth/ui/ResetPasswordContent.tsx +183 -183
- package/templates/src/features/auth/ui/SocialLoginButtons.tsx +78 -78
- package/templates/src/features/auth/ui/VerifyEmailContent.tsx +80 -80
- package/templates/src/features/home/data/mock.ts +41 -41
- package/templates/src/features/home/hooks/useFeatureCards.ts +20 -20
- package/templates/src/features/home/index.ts +11 -11
- package/templates/src/features/home/ui/HomeContent.tsx +117 -117
- package/templates/src/features/template/ui/CrudTemplate.tsx +112 -112
- package/templates/src/features/template/ui/DashboardTemplate.tsx +110 -110
- package/templates/src/features/template/ui/FormTemplate.tsx +117 -117
- package/templates/src/features/template/ui/LoginTemplate.tsx +59 -59
- package/templates/src/features/template/ui/TemplateContent.tsx +1322 -1322
- package/templates/src/i18n.ts +124 -124
- package/templates/src/locales/en/common.json +21 -21
- package/templates/src/locales/en/components/activityCard.json +10 -10
- package/templates/src/locales/en/components/assistant.json +119 -119
- package/templates/src/locales/en/components/media.json +29 -29
- package/templates/src/locales/en/components/notificationCard.json +5 -5
- package/templates/src/locales/en/components/profileCard.json +8 -8
- package/templates/src/locales/en/components/projectCard.json +10 -10
- package/templates/src/locales/en/components/sidebar.json +14 -14
- package/templates/src/locales/en/components/stats.json +8 -8
- package/templates/src/locales/en/components/team.json +14 -14
- package/templates/src/locales/en/errors.json +9 -9
- package/templates/src/locales/en/languageSelector.json +7 -7
- package/templates/src/locales/en/nav.json +6 -6
- package/templates/src/locales/en/pages/crudTemplate.json +25 -25
- package/templates/src/locales/en/pages/dashboardTemplate.json +20 -20
- package/templates/src/locales/en/pages/forgotPassword.json +10 -10
- package/templates/src/locales/en/pages/formTemplate.json +16 -16
- package/templates/src/locales/en/pages/home.json +7 -7
- package/templates/src/locales/en/pages/login.json +15 -15
- package/templates/src/locales/en/pages/loginTemplate.json +9 -9
- package/templates/src/locales/en/pages/resetPassword.json +18 -18
- package/templates/src/locales/en/pages/templates.json +317 -317
- package/templates/src/locales/en/pages/verifyEmail.json +12 -12
- package/templates/src/locales/en/themeToggle.json +6 -6
- package/templates/src/locales/es/common.json +21 -21
- package/templates/src/locales/es/components/activityCard.json +10 -10
- package/templates/src/locales/es/components/assistant.json +119 -119
- package/templates/src/locales/es/components/media.json +29 -29
- package/templates/src/locales/es/components/notificationCard.json +5 -5
- package/templates/src/locales/es/components/profileCard.json +8 -8
- package/templates/src/locales/es/components/projectCard.json +10 -10
- package/templates/src/locales/es/components/sidebar.json +14 -14
- package/templates/src/locales/es/components/stats.json +8 -8
- package/templates/src/locales/es/components/team.json +14 -14
- package/templates/src/locales/es/errors.json +9 -9
- package/templates/src/locales/es/languageSelector.json +7 -7
- package/templates/src/locales/es/nav.json +6 -6
- package/templates/src/locales/es/pages/crudTemplate.json +25 -25
- package/templates/src/locales/es/pages/dashboardTemplate.json +20 -20
- package/templates/src/locales/es/pages/forgotPassword.json +10 -10
- package/templates/src/locales/es/pages/formTemplate.json +16 -16
- package/templates/src/locales/es/pages/home.json +7 -7
- package/templates/src/locales/es/pages/login.json +15 -15
- package/templates/src/locales/es/pages/loginTemplate.json +9 -9
- package/templates/src/locales/es/pages/resetPassword.json +18 -18
- package/templates/src/locales/es/pages/templates.json +317 -317
- package/templates/src/locales/es/pages/verifyEmail.json +12 -12
- package/templates/src/locales/es/themeToggle.json +6 -6
- package/templates/src/locales/pt-BR/common.json +21 -21
- package/templates/src/locales/pt-BR/components/activityCard.json +10 -10
- package/templates/src/locales/pt-BR/components/assistant.json +119 -119
- package/templates/src/locales/pt-BR/components/media.json +29 -29
- package/templates/src/locales/pt-BR/components/notificationCard.json +5 -5
- package/templates/src/locales/pt-BR/components/profileCard.json +8 -8
- package/templates/src/locales/pt-BR/components/projectCard.json +10 -10
- package/templates/src/locales/pt-BR/components/sidebar.json +14 -14
- package/templates/src/locales/pt-BR/components/stats.json +8 -8
- package/templates/src/locales/pt-BR/components/team.json +14 -14
- package/templates/src/locales/pt-BR/errors.json +9 -9
- package/templates/src/locales/pt-BR/languageSelector.json +7 -7
- package/templates/src/locales/pt-BR/nav.json +6 -6
- package/templates/src/locales/pt-BR/pages/crudTemplate.json +25 -25
- package/templates/src/locales/pt-BR/pages/dashboardTemplate.json +20 -20
- package/templates/src/locales/pt-BR/pages/forgotPassword.json +10 -10
- package/templates/src/locales/pt-BR/pages/formTemplate.json +16 -16
- package/templates/src/locales/pt-BR/pages/home.json +7 -7
- package/templates/src/locales/pt-BR/pages/login.json +15 -15
- package/templates/src/locales/pt-BR/pages/loginTemplate.json +9 -9
- package/templates/src/locales/pt-BR/pages/resetPassword.json +18 -18
- package/templates/src/locales/pt-BR/pages/templates.json +317 -317
- package/templates/src/locales/pt-BR/pages/verifyEmail.json +12 -12
- package/templates/src/locales/pt-BR/themeToggle.json +6 -6
- package/templates/src/pages/AssistantPage.tsx +470 -470
- package/templates/src/pages/HomePage.tsx +53 -53
- package/templates/src/shared/error-boundary.tsx +150 -150
- package/templates/src/shared/error-fallbacks.tsx +222 -222
- package/templates/src/styles/xertica/tokens.css +9 -9
- package/templates/vite.config.js +20 -20
- package/templates/vite.config.ts +55 -55
- package/dist/ThemeContext-CpqYShLq.cjs +0 -324
- package/dist/ThemeContext-Du2nE1PL.js +0 -325
- package/dist/ThemeContext-GeEBTJ3q.cjs +0 -1621
- package/dist/ThemeContext-JyLK9B1o.js +0 -1622
- package/dist/VerifyEmailPage-BiRm7Nh4.cjs +0 -3213
- package/dist/VerifyEmailPage-hdB8JQGv.cjs +0 -3213
- package/dist/VerifyEmailPage-vYHbYK3q.js +0 -3214
- package/dist/XerticaProvider-CUYJZc32.js +0 -49
- package/dist/XerticaProvider-CjQAQPcn.cjs +0 -48
- package/dist/XerticaProvider-D5lLumH-.js +0 -49
- package/dist/XerticaProvider-qQUDop71.cjs +0 -48
- package/dist/XerticaXLogo-BWaag64t.js +0 -252
- package/dist/XerticaXLogo-CU-U-GP4.cjs +0 -251
- package/dist/index-CkTUgOwX.js +0 -8
- package/dist/sidebar-OTO_up7Z.js +0 -801
- package/dist/{rich-text-editor-BmsjY03B.js → rich-text-editor-DgF8s7xW.js} +26 -26
- package/dist/{rich-text-editor-GS2kpTAK.cjs → rich-text-editor-mWoaSCE4.cjs} +26 -26
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { useRef, useState, useCallback, useEffect } from "react";
|
|
2
|
+
function useRichTextEditor({
|
|
3
|
+
value,
|
|
4
|
+
onChange
|
|
5
|
+
}) {
|
|
6
|
+
const editorRef = useRef(null);
|
|
7
|
+
const searchInputRef = useRef(null);
|
|
8
|
+
const linkInputRef = useRef(null);
|
|
9
|
+
const savedSelection = useRef(null);
|
|
10
|
+
const [wordCount, setWordCount] = useState(0);
|
|
11
|
+
const [characterCount, setCharacterCount] = useState(0);
|
|
12
|
+
const [activeFormats, setActiveFormats] = useState({
|
|
13
|
+
bold: false,
|
|
14
|
+
italic: false,
|
|
15
|
+
underline: false,
|
|
16
|
+
justifyLeft: false,
|
|
17
|
+
justifyCenter: false,
|
|
18
|
+
justifyRight: false,
|
|
19
|
+
insertUnorderedList: false,
|
|
20
|
+
insertOrderedList: false,
|
|
21
|
+
link: false,
|
|
22
|
+
h1: false,
|
|
23
|
+
h2: false,
|
|
24
|
+
h3: false,
|
|
25
|
+
p: true
|
|
26
|
+
});
|
|
27
|
+
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
|
28
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
29
|
+
const [linkUrl, setLinkUrl] = useState("https://");
|
|
30
|
+
const [isLinkOpen, setIsLinkOpen] = useState(false);
|
|
31
|
+
const [hasSavedSelection, setHasSavedSelection] = useState(false);
|
|
32
|
+
const findParentTag = useCallback((node, tagName) => {
|
|
33
|
+
let current = node;
|
|
34
|
+
while (current && current !== editorRef.current) {
|
|
35
|
+
if (current.nodeName === tagName) return current;
|
|
36
|
+
current = current.parentNode;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}, []);
|
|
40
|
+
const updateActiveFormatsRef = useRef(() => {
|
|
41
|
+
});
|
|
42
|
+
const updateActiveFormats = useCallback(() => {
|
|
43
|
+
let formatBlock = "";
|
|
44
|
+
try {
|
|
45
|
+
formatBlock = document.queryCommandValue("formatBlock");
|
|
46
|
+
} catch (_e) {
|
|
47
|
+
}
|
|
48
|
+
const selection = window.getSelection();
|
|
49
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
50
|
+
const focusNode = selection == null ? void 0 : selection.focusNode;
|
|
51
|
+
setActiveFormats({
|
|
52
|
+
bold: document.queryCommandState("bold"),
|
|
53
|
+
italic: document.queryCommandState("italic"),
|
|
54
|
+
underline: document.queryCommandState("underline"),
|
|
55
|
+
justifyLeft: document.queryCommandState("justifyLeft"),
|
|
56
|
+
justifyCenter: document.queryCommandState("justifyCenter"),
|
|
57
|
+
justifyRight: document.queryCommandState("justifyRight"),
|
|
58
|
+
insertUnorderedList: document.queryCommandState("insertUnorderedList"),
|
|
59
|
+
insertOrderedList: document.queryCommandState("insertOrderedList"),
|
|
60
|
+
link: !!(findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A")),
|
|
61
|
+
h1: formatBlock === "h1" || formatBlock === "H1",
|
|
62
|
+
h2: formatBlock === "h2" || formatBlock === "H2",
|
|
63
|
+
h3: formatBlock === "h3" || formatBlock === "H3",
|
|
64
|
+
p: formatBlock === "p" || formatBlock === "P" || formatBlock === "div" || formatBlock === "DIV" || formatBlock === ""
|
|
65
|
+
});
|
|
66
|
+
}, [findParentTag]);
|
|
67
|
+
updateActiveFormatsRef.current = updateActiveFormats;
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (editorRef.current && editorRef.current.innerHTML !== value) {
|
|
70
|
+
editorRef.current.innerHTML = value;
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (editorRef.current && document.activeElement !== editorRef.current && editorRef.current.innerHTML !== value) {
|
|
75
|
+
editorRef.current.innerHTML = value;
|
|
76
|
+
const text = editorRef.current.innerText || "";
|
|
77
|
+
setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
|
|
78
|
+
setCharacterCount(text.trim() ? text.length : 0);
|
|
79
|
+
}
|
|
80
|
+
}, [value]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const handleSelectionChange = () => {
|
|
83
|
+
if (document.activeElement === editorRef.current) {
|
|
84
|
+
updateActiveFormatsRef.current();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
document.addEventListener("selectionchange", handleSelectionChange);
|
|
88
|
+
return () => document.removeEventListener("selectionchange", handleSelectionChange);
|
|
89
|
+
}, []);
|
|
90
|
+
const handleInput = useCallback(() => {
|
|
91
|
+
if (editorRef.current) {
|
|
92
|
+
onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
|
|
93
|
+
updateActiveFormats();
|
|
94
|
+
const text = editorRef.current.innerText || "";
|
|
95
|
+
setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
|
|
96
|
+
setCharacterCount(text.trim() ? text.length : 0);
|
|
97
|
+
}
|
|
98
|
+
}, [onChange, updateActiveFormats]);
|
|
99
|
+
const execCommand = useCallback((command, val = "") => {
|
|
100
|
+
var _a;
|
|
101
|
+
document.execCommand(command, false, val);
|
|
102
|
+
updateActiveFormats();
|
|
103
|
+
(_a = editorRef.current) == null ? void 0 : _a.focus();
|
|
104
|
+
if (editorRef.current) {
|
|
105
|
+
onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
|
|
106
|
+
}
|
|
107
|
+
}, [onChange, updateActiveFormats]);
|
|
108
|
+
const performSearch = useCallback((text, backward = false) => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
if (!text || !editorRef.current) return;
|
|
111
|
+
const editor = editorRef.current;
|
|
112
|
+
const selection = window.getSelection();
|
|
113
|
+
if (!selection) return;
|
|
114
|
+
const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT);
|
|
115
|
+
const segments = [];
|
|
116
|
+
let offset = 0;
|
|
117
|
+
let node;
|
|
118
|
+
while (node = walker.nextNode()) {
|
|
119
|
+
segments.push({ node, start: offset });
|
|
120
|
+
offset += node.length;
|
|
121
|
+
}
|
|
122
|
+
const fullText = segments.reduce((acc, s) => acc + (s.node.textContent ?? ""), "");
|
|
123
|
+
let searchFrom = 0;
|
|
124
|
+
if (selection.rangeCount > 0) {
|
|
125
|
+
const range2 = selection.getRangeAt(0);
|
|
126
|
+
if (editor.contains(range2.startContainer)) {
|
|
127
|
+
const seg = segments.find((s) => s.node === range2.startContainer);
|
|
128
|
+
if (seg) {
|
|
129
|
+
searchFrom = backward ? seg.start + range2.startOffset - 1 : seg.start + range2.endOffset;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const lowerFull = fullText.toLowerCase();
|
|
134
|
+
const lowerQuery = text.toLowerCase();
|
|
135
|
+
let matchStart = -1;
|
|
136
|
+
if (backward) {
|
|
137
|
+
matchStart = lowerFull.lastIndexOf(lowerQuery, Math.max(0, searchFrom));
|
|
138
|
+
if (matchStart === -1) matchStart = lowerFull.lastIndexOf(lowerQuery);
|
|
139
|
+
} else {
|
|
140
|
+
matchStart = lowerFull.indexOf(lowerQuery, searchFrom);
|
|
141
|
+
if (matchStart === -1) matchStart = lowerFull.indexOf(lowerQuery);
|
|
142
|
+
}
|
|
143
|
+
if (matchStart === -1) return;
|
|
144
|
+
const matchEnd = matchStart + text.length;
|
|
145
|
+
const range = document.createRange();
|
|
146
|
+
let startSet = false;
|
|
147
|
+
let endSet = false;
|
|
148
|
+
for (let i = 0; i < segments.length && !endSet; i++) {
|
|
149
|
+
const seg = segments[i];
|
|
150
|
+
const segEnd = seg.start + seg.node.length;
|
|
151
|
+
if (!startSet && matchStart < segEnd && matchStart >= seg.start) {
|
|
152
|
+
range.setStart(seg.node, matchStart - seg.start);
|
|
153
|
+
startSet = true;
|
|
154
|
+
}
|
|
155
|
+
if (startSet && matchEnd <= segEnd) {
|
|
156
|
+
range.setEnd(seg.node, matchEnd - seg.start);
|
|
157
|
+
endSet = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (startSet && endSet) {
|
|
161
|
+
selection.removeAllRanges();
|
|
162
|
+
selection.addRange(range);
|
|
163
|
+
(_b = (_a = range.startContainer.parentElement) == null ? void 0 : _a.scrollIntoView) == null ? void 0 : _b.call(_a, { block: "nearest" });
|
|
164
|
+
}
|
|
165
|
+
}, []);
|
|
166
|
+
const handleCreateLink = useCallback(() => {
|
|
167
|
+
if (savedSelection.current) {
|
|
168
|
+
const selection2 = window.getSelection();
|
|
169
|
+
selection2 == null ? void 0 : selection2.removeAllRanges();
|
|
170
|
+
selection2 == null ? void 0 : selection2.addRange(savedSelection.current);
|
|
171
|
+
}
|
|
172
|
+
const selection = window.getSelection();
|
|
173
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
174
|
+
const existingLink = findParentTag(anchorNode || null, "A");
|
|
175
|
+
if (existingLink) {
|
|
176
|
+
if (linkUrl) {
|
|
177
|
+
existingLink.setAttribute("href", linkUrl);
|
|
178
|
+
existingLink.setAttribute("target", "_blank");
|
|
179
|
+
existingLink.setAttribute("rel", "noopener noreferrer");
|
|
180
|
+
existingLink.style.color = "hsl(var(--primary))";
|
|
181
|
+
existingLink.style.textDecoration = "underline";
|
|
182
|
+
existingLink.style.cursor = "pointer";
|
|
183
|
+
}
|
|
184
|
+
handleInput();
|
|
185
|
+
setIsLinkOpen(false);
|
|
186
|
+
savedSelection.current = null;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!selection || selection.rangeCount === 0 || selection.isCollapsed) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (linkUrl) {
|
|
193
|
+
document.execCommand("createLink", false, linkUrl);
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
var _a;
|
|
196
|
+
const anchor = findParentTag(((_a = window.getSelection()) == null ? void 0 : _a.anchorNode) || null, "A");
|
|
197
|
+
if (anchor) {
|
|
198
|
+
anchor.setAttribute("target", "_blank");
|
|
199
|
+
anchor.setAttribute("rel", "noopener noreferrer");
|
|
200
|
+
anchor.style.color = "hsl(var(--primary))";
|
|
201
|
+
anchor.style.textDecoration = "underline";
|
|
202
|
+
anchor.style.cursor = "pointer";
|
|
203
|
+
}
|
|
204
|
+
handleInput();
|
|
205
|
+
}, 10);
|
|
206
|
+
setIsLinkOpen(false);
|
|
207
|
+
savedSelection.current = null;
|
|
208
|
+
}
|
|
209
|
+
}, [linkUrl, findParentTag, handleInput]);
|
|
210
|
+
const handleUnlink = useCallback(() => {
|
|
211
|
+
const selection = window.getSelection();
|
|
212
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
213
|
+
const existingLink = findParentTag(anchorNode || null, "A");
|
|
214
|
+
if (existingLink) {
|
|
215
|
+
const parent = existingLink.parentNode;
|
|
216
|
+
while (existingLink.firstChild) {
|
|
217
|
+
parent == null ? void 0 : parent.insertBefore(existingLink.firstChild, existingLink);
|
|
218
|
+
}
|
|
219
|
+
parent == null ? void 0 : parent.removeChild(existingLink);
|
|
220
|
+
handleInput();
|
|
221
|
+
} else {
|
|
222
|
+
document.execCommand("unlink", false, "");
|
|
223
|
+
}
|
|
224
|
+
}, [findParentTag, handleInput]);
|
|
225
|
+
const onLinkPopoverOpenChange = useCallback((open) => {
|
|
226
|
+
if (open) {
|
|
227
|
+
const selection = window.getSelection();
|
|
228
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
229
|
+
const focusNode = selection == null ? void 0 : selection.focusNode;
|
|
230
|
+
const existingLink = findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A");
|
|
231
|
+
if (existingLink) {
|
|
232
|
+
setLinkUrl(existingLink.getAttribute("href") || "https://");
|
|
233
|
+
} else {
|
|
234
|
+
setLinkUrl("https://");
|
|
235
|
+
}
|
|
236
|
+
if (selection && selection.rangeCount > 0 && (!selection.isCollapsed || existingLink)) {
|
|
237
|
+
savedSelection.current = selection.getRangeAt(0).cloneRange();
|
|
238
|
+
setHasSavedSelection(true);
|
|
239
|
+
} else {
|
|
240
|
+
savedSelection.current = null;
|
|
241
|
+
setHasSavedSelection(false);
|
|
242
|
+
}
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
var _a;
|
|
245
|
+
return (_a = linkInputRef.current) == null ? void 0 : _a.focus();
|
|
246
|
+
}, 100);
|
|
247
|
+
} else {
|
|
248
|
+
setHasSavedSelection(false);
|
|
249
|
+
}
|
|
250
|
+
setIsLinkOpen(open);
|
|
251
|
+
}, [findParentTag]);
|
|
252
|
+
return {
|
|
253
|
+
// Refs
|
|
254
|
+
editorRef,
|
|
255
|
+
searchInputRef,
|
|
256
|
+
linkInputRef,
|
|
257
|
+
// State
|
|
258
|
+
activeFormats,
|
|
259
|
+
isSearchOpen,
|
|
260
|
+
setIsSearchOpen,
|
|
261
|
+
searchQuery,
|
|
262
|
+
setSearchQuery,
|
|
263
|
+
linkUrl,
|
|
264
|
+
setLinkUrl,
|
|
265
|
+
isLinkOpen,
|
|
266
|
+
hasSavedSelection,
|
|
267
|
+
// Computed
|
|
268
|
+
wordCount,
|
|
269
|
+
characterCount,
|
|
270
|
+
// Handlers
|
|
271
|
+
updateActiveFormats,
|
|
272
|
+
execCommand,
|
|
273
|
+
handleInput,
|
|
274
|
+
performSearch,
|
|
275
|
+
handleCreateLink,
|
|
276
|
+
handleUnlink,
|
|
277
|
+
onLinkPopoverOpenChange
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
export {
|
|
281
|
+
useRichTextEditor as u
|
|
282
|
+
};
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
function useRichTextEditor({
|
|
4
|
+
value,
|
|
5
|
+
onChange
|
|
6
|
+
}) {
|
|
7
|
+
const editorRef = React.useRef(null);
|
|
8
|
+
const searchInputRef = React.useRef(null);
|
|
9
|
+
const linkInputRef = React.useRef(null);
|
|
10
|
+
const savedSelection = React.useRef(null);
|
|
11
|
+
const [wordCount, setWordCount] = React.useState(0);
|
|
12
|
+
const [characterCount, setCharacterCount] = React.useState(0);
|
|
13
|
+
const [activeFormats, setActiveFormats] = React.useState({
|
|
14
|
+
bold: false,
|
|
15
|
+
italic: false,
|
|
16
|
+
underline: false,
|
|
17
|
+
justifyLeft: false,
|
|
18
|
+
justifyCenter: false,
|
|
19
|
+
justifyRight: false,
|
|
20
|
+
insertUnorderedList: false,
|
|
21
|
+
insertOrderedList: false,
|
|
22
|
+
link: false,
|
|
23
|
+
h1: false,
|
|
24
|
+
h2: false,
|
|
25
|
+
h3: false,
|
|
26
|
+
p: true
|
|
27
|
+
});
|
|
28
|
+
const [isSearchOpen, setIsSearchOpen] = React.useState(false);
|
|
29
|
+
const [searchQuery, setSearchQuery] = React.useState("");
|
|
30
|
+
const [linkUrl, setLinkUrl] = React.useState("https://");
|
|
31
|
+
const [isLinkOpen, setIsLinkOpen] = React.useState(false);
|
|
32
|
+
const [hasSavedSelection, setHasSavedSelection] = React.useState(false);
|
|
33
|
+
const findParentTag = React.useCallback((node, tagName) => {
|
|
34
|
+
let current = node;
|
|
35
|
+
while (current && current !== editorRef.current) {
|
|
36
|
+
if (current.nodeName === tagName) return current;
|
|
37
|
+
current = current.parentNode;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}, []);
|
|
41
|
+
const updateActiveFormatsRef = React.useRef(() => {
|
|
42
|
+
});
|
|
43
|
+
const updateActiveFormats = React.useCallback(() => {
|
|
44
|
+
let formatBlock = "";
|
|
45
|
+
try {
|
|
46
|
+
formatBlock = document.queryCommandValue("formatBlock");
|
|
47
|
+
} catch (_e) {
|
|
48
|
+
}
|
|
49
|
+
const selection = window.getSelection();
|
|
50
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
51
|
+
const focusNode = selection == null ? void 0 : selection.focusNode;
|
|
52
|
+
setActiveFormats({
|
|
53
|
+
bold: document.queryCommandState("bold"),
|
|
54
|
+
italic: document.queryCommandState("italic"),
|
|
55
|
+
underline: document.queryCommandState("underline"),
|
|
56
|
+
justifyLeft: document.queryCommandState("justifyLeft"),
|
|
57
|
+
justifyCenter: document.queryCommandState("justifyCenter"),
|
|
58
|
+
justifyRight: document.queryCommandState("justifyRight"),
|
|
59
|
+
insertUnorderedList: document.queryCommandState("insertUnorderedList"),
|
|
60
|
+
insertOrderedList: document.queryCommandState("insertOrderedList"),
|
|
61
|
+
link: !!(findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A")),
|
|
62
|
+
h1: formatBlock === "h1" || formatBlock === "H1",
|
|
63
|
+
h2: formatBlock === "h2" || formatBlock === "H2",
|
|
64
|
+
h3: formatBlock === "h3" || formatBlock === "H3",
|
|
65
|
+
p: formatBlock === "p" || formatBlock === "P" || formatBlock === "div" || formatBlock === "DIV" || formatBlock === ""
|
|
66
|
+
});
|
|
67
|
+
}, [findParentTag]);
|
|
68
|
+
updateActiveFormatsRef.current = updateActiveFormats;
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
if (editorRef.current && editorRef.current.innerHTML !== value) {
|
|
71
|
+
editorRef.current.innerHTML = value;
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
if (editorRef.current && document.activeElement !== editorRef.current && editorRef.current.innerHTML !== value) {
|
|
76
|
+
editorRef.current.innerHTML = value;
|
|
77
|
+
const text = editorRef.current.innerText || "";
|
|
78
|
+
setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
|
|
79
|
+
setCharacterCount(text.trim() ? text.length : 0);
|
|
80
|
+
}
|
|
81
|
+
}, [value]);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
const handleSelectionChange = () => {
|
|
84
|
+
if (document.activeElement === editorRef.current) {
|
|
85
|
+
updateActiveFormatsRef.current();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
document.addEventListener("selectionchange", handleSelectionChange);
|
|
89
|
+
return () => document.removeEventListener("selectionchange", handleSelectionChange);
|
|
90
|
+
}, []);
|
|
91
|
+
const handleInput = React.useCallback(() => {
|
|
92
|
+
if (editorRef.current) {
|
|
93
|
+
onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
|
|
94
|
+
updateActiveFormats();
|
|
95
|
+
const text = editorRef.current.innerText || "";
|
|
96
|
+
setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
|
|
97
|
+
setCharacterCount(text.trim() ? text.length : 0);
|
|
98
|
+
}
|
|
99
|
+
}, [onChange, updateActiveFormats]);
|
|
100
|
+
const execCommand = React.useCallback((command, val = "") => {
|
|
101
|
+
var _a;
|
|
102
|
+
document.execCommand(command, false, val);
|
|
103
|
+
updateActiveFormats();
|
|
104
|
+
(_a = editorRef.current) == null ? void 0 : _a.focus();
|
|
105
|
+
if (editorRef.current) {
|
|
106
|
+
onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
|
|
107
|
+
}
|
|
108
|
+
}, [onChange, updateActiveFormats]);
|
|
109
|
+
const performSearch = React.useCallback((text, backward = false) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
if (!text || !editorRef.current) return;
|
|
112
|
+
const editor = editorRef.current;
|
|
113
|
+
const selection = window.getSelection();
|
|
114
|
+
if (!selection) return;
|
|
115
|
+
const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT);
|
|
116
|
+
const segments = [];
|
|
117
|
+
let offset = 0;
|
|
118
|
+
let node;
|
|
119
|
+
while (node = walker.nextNode()) {
|
|
120
|
+
segments.push({ node, start: offset });
|
|
121
|
+
offset += node.length;
|
|
122
|
+
}
|
|
123
|
+
const fullText = segments.reduce((acc, s) => acc + (s.node.textContent ?? ""), "");
|
|
124
|
+
let searchFrom = 0;
|
|
125
|
+
if (selection.rangeCount > 0) {
|
|
126
|
+
const range2 = selection.getRangeAt(0);
|
|
127
|
+
if (editor.contains(range2.startContainer)) {
|
|
128
|
+
const seg = segments.find((s) => s.node === range2.startContainer);
|
|
129
|
+
if (seg) {
|
|
130
|
+
searchFrom = backward ? seg.start + range2.startOffset - 1 : seg.start + range2.endOffset;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const lowerFull = fullText.toLowerCase();
|
|
135
|
+
const lowerQuery = text.toLowerCase();
|
|
136
|
+
let matchStart = -1;
|
|
137
|
+
if (backward) {
|
|
138
|
+
matchStart = lowerFull.lastIndexOf(lowerQuery, Math.max(0, searchFrom));
|
|
139
|
+
if (matchStart === -1) matchStart = lowerFull.lastIndexOf(lowerQuery);
|
|
140
|
+
} else {
|
|
141
|
+
matchStart = lowerFull.indexOf(lowerQuery, searchFrom);
|
|
142
|
+
if (matchStart === -1) matchStart = lowerFull.indexOf(lowerQuery);
|
|
143
|
+
}
|
|
144
|
+
if (matchStart === -1) return;
|
|
145
|
+
const matchEnd = matchStart + text.length;
|
|
146
|
+
const range = document.createRange();
|
|
147
|
+
let startSet = false;
|
|
148
|
+
let endSet = false;
|
|
149
|
+
for (let i = 0; i < segments.length && !endSet; i++) {
|
|
150
|
+
const seg = segments[i];
|
|
151
|
+
const segEnd = seg.start + seg.node.length;
|
|
152
|
+
if (!startSet && matchStart < segEnd && matchStart >= seg.start) {
|
|
153
|
+
range.setStart(seg.node, matchStart - seg.start);
|
|
154
|
+
startSet = true;
|
|
155
|
+
}
|
|
156
|
+
if (startSet && matchEnd <= segEnd) {
|
|
157
|
+
range.setEnd(seg.node, matchEnd - seg.start);
|
|
158
|
+
endSet = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (startSet && endSet) {
|
|
162
|
+
selection.removeAllRanges();
|
|
163
|
+
selection.addRange(range);
|
|
164
|
+
(_b = (_a = range.startContainer.parentElement) == null ? void 0 : _a.scrollIntoView) == null ? void 0 : _b.call(_a, { block: "nearest" });
|
|
165
|
+
}
|
|
166
|
+
}, []);
|
|
167
|
+
const handleCreateLink = React.useCallback(() => {
|
|
168
|
+
if (savedSelection.current) {
|
|
169
|
+
const selection2 = window.getSelection();
|
|
170
|
+
selection2 == null ? void 0 : selection2.removeAllRanges();
|
|
171
|
+
selection2 == null ? void 0 : selection2.addRange(savedSelection.current);
|
|
172
|
+
}
|
|
173
|
+
const selection = window.getSelection();
|
|
174
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
175
|
+
const existingLink = findParentTag(anchorNode || null, "A");
|
|
176
|
+
if (existingLink) {
|
|
177
|
+
if (linkUrl) {
|
|
178
|
+
existingLink.setAttribute("href", linkUrl);
|
|
179
|
+
existingLink.setAttribute("target", "_blank");
|
|
180
|
+
existingLink.setAttribute("rel", "noopener noreferrer");
|
|
181
|
+
existingLink.style.color = "hsl(var(--primary))";
|
|
182
|
+
existingLink.style.textDecoration = "underline";
|
|
183
|
+
existingLink.style.cursor = "pointer";
|
|
184
|
+
}
|
|
185
|
+
handleInput();
|
|
186
|
+
setIsLinkOpen(false);
|
|
187
|
+
savedSelection.current = null;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (!selection || selection.rangeCount === 0 || selection.isCollapsed) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (linkUrl) {
|
|
194
|
+
document.execCommand("createLink", false, linkUrl);
|
|
195
|
+
setTimeout(() => {
|
|
196
|
+
var _a;
|
|
197
|
+
const anchor = findParentTag(((_a = window.getSelection()) == null ? void 0 : _a.anchorNode) || null, "A");
|
|
198
|
+
if (anchor) {
|
|
199
|
+
anchor.setAttribute("target", "_blank");
|
|
200
|
+
anchor.setAttribute("rel", "noopener noreferrer");
|
|
201
|
+
anchor.style.color = "hsl(var(--primary))";
|
|
202
|
+
anchor.style.textDecoration = "underline";
|
|
203
|
+
anchor.style.cursor = "pointer";
|
|
204
|
+
}
|
|
205
|
+
handleInput();
|
|
206
|
+
}, 10);
|
|
207
|
+
setIsLinkOpen(false);
|
|
208
|
+
savedSelection.current = null;
|
|
209
|
+
}
|
|
210
|
+
}, [linkUrl, findParentTag, handleInput]);
|
|
211
|
+
const handleUnlink = React.useCallback(() => {
|
|
212
|
+
const selection = window.getSelection();
|
|
213
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
214
|
+
const existingLink = findParentTag(anchorNode || null, "A");
|
|
215
|
+
if (existingLink) {
|
|
216
|
+
const parent = existingLink.parentNode;
|
|
217
|
+
while (existingLink.firstChild) {
|
|
218
|
+
parent == null ? void 0 : parent.insertBefore(existingLink.firstChild, existingLink);
|
|
219
|
+
}
|
|
220
|
+
parent == null ? void 0 : parent.removeChild(existingLink);
|
|
221
|
+
handleInput();
|
|
222
|
+
} else {
|
|
223
|
+
document.execCommand("unlink", false, "");
|
|
224
|
+
}
|
|
225
|
+
}, [findParentTag, handleInput]);
|
|
226
|
+
const onLinkPopoverOpenChange = React.useCallback((open) => {
|
|
227
|
+
if (open) {
|
|
228
|
+
const selection = window.getSelection();
|
|
229
|
+
const anchorNode = selection == null ? void 0 : selection.anchorNode;
|
|
230
|
+
const focusNode = selection == null ? void 0 : selection.focusNode;
|
|
231
|
+
const existingLink = findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A");
|
|
232
|
+
if (existingLink) {
|
|
233
|
+
setLinkUrl(existingLink.getAttribute("href") || "https://");
|
|
234
|
+
} else {
|
|
235
|
+
setLinkUrl("https://");
|
|
236
|
+
}
|
|
237
|
+
if (selection && selection.rangeCount > 0 && (!selection.isCollapsed || existingLink)) {
|
|
238
|
+
savedSelection.current = selection.getRangeAt(0).cloneRange();
|
|
239
|
+
setHasSavedSelection(true);
|
|
240
|
+
} else {
|
|
241
|
+
savedSelection.current = null;
|
|
242
|
+
setHasSavedSelection(false);
|
|
243
|
+
}
|
|
244
|
+
setTimeout(() => {
|
|
245
|
+
var _a;
|
|
246
|
+
return (_a = linkInputRef.current) == null ? void 0 : _a.focus();
|
|
247
|
+
}, 100);
|
|
248
|
+
} else {
|
|
249
|
+
setHasSavedSelection(false);
|
|
250
|
+
}
|
|
251
|
+
setIsLinkOpen(open);
|
|
252
|
+
}, [findParentTag]);
|
|
253
|
+
return {
|
|
254
|
+
// Refs
|
|
255
|
+
editorRef,
|
|
256
|
+
searchInputRef,
|
|
257
|
+
linkInputRef,
|
|
258
|
+
// State
|
|
259
|
+
activeFormats,
|
|
260
|
+
isSearchOpen,
|
|
261
|
+
setIsSearchOpen,
|
|
262
|
+
searchQuery,
|
|
263
|
+
setSearchQuery,
|
|
264
|
+
linkUrl,
|
|
265
|
+
setLinkUrl,
|
|
266
|
+
isLinkOpen,
|
|
267
|
+
hasSavedSelection,
|
|
268
|
+
// Computed
|
|
269
|
+
wordCount,
|
|
270
|
+
characterCount,
|
|
271
|
+
// Handlers
|
|
272
|
+
updateActiveFormats,
|
|
273
|
+
execCommand,
|
|
274
|
+
handleInput,
|
|
275
|
+
performSearch,
|
|
276
|
+
handleCreateLink,
|
|
277
|
+
handleUnlink,
|
|
278
|
+
onLinkPopoverOpenChange
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
exports.useRichTextEditor = useRichTextEditor;
|