@keboola/design 11.0.0 → 11.0.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/dist/AIKit-Dre37SJr.js +1320 -0
- package/dist/AIKit-Dre37SJr.js.map +1 -0
- package/dist/Alert-DfZq9kGe.js +133 -0
- package/dist/Alert-DfZq9kGe.js.map +1 -0
- package/dist/AlertModal-BUC4Es8o.js +222 -0
- package/dist/AlertModal-BUC4Es8o.js.map +1 -0
- package/dist/AppShell-B5GQN6Zs.js +143 -0
- package/dist/AppShell-B5GQN6Zs.js.map +1 -0
- package/dist/AutoSaveTextarea-BeuWuszr.js +58 -0
- package/dist/{chunk-UGT6DKWM.js.map → AutoSaveTextarea-BeuWuszr.js.map} +1 -1
- package/dist/Badge-Ch26CXoP.js +195 -0
- package/dist/Badge-Ch26CXoP.js.map +1 -0
- package/dist/BrandEditor-B8o9zdZO.js +903 -0
- package/dist/BrandEditor-B8o9zdZO.js.map +1 -0
- package/dist/BrandLogo-CJkRd0F8.js +46 -0
- package/dist/BrandLogo-CJkRd0F8.js.map +1 -0
- package/dist/Breadcrumb-DJp7WwSv.js +330 -0
- package/dist/Breadcrumb-DJp7WwSv.js.map +1 -0
- package/dist/Button-nzmDNS2q.js +391 -0
- package/dist/Button-nzmDNS2q.js.map +1 -0
- package/dist/Calendar-cG5NIJ4O.js +6768 -0
- package/dist/Calendar-cG5NIJ4O.js.map +1 -0
- package/dist/Card-BAoZ35CV.js +105 -0
- package/dist/Card-BAoZ35CV.js.map +1 -0
- package/dist/Checkbox-GJ8-srt4.js +97 -0
- package/dist/Checkbox-GJ8-srt4.js.map +1 -0
- package/dist/Clipboard-CBJZiviP.js +58 -0
- package/dist/Clipboard-CBJZiviP.js.map +1 -0
- package/dist/ClipboardButton-ez5V3fkk.js +43 -0
- package/dist/ClipboardButton-ez5V3fkk.js.map +1 -0
- package/dist/CodeEditor-BfQJfbhL.js +952 -0
- package/dist/CodeEditor-BfQJfbhL.js.map +1 -0
- package/dist/Collapsible-BQXWEOBC.js +34 -0
- package/dist/Collapsible-BQXWEOBC.js.map +1 -0
- package/dist/ColorInput-Dx8Dsv7Y.js +180 -0
- package/dist/ColorInput-Dx8Dsv7Y.js.map +1 -0
- package/dist/ColorModeSwitch-CCqj7tjE.js +77 -0
- package/dist/ColorModeSwitch-CCqj7tjE.js.map +1 -0
- package/dist/Combobox-c_xBjf0P.js +439 -0
- package/dist/Combobox-c_xBjf0P.js.map +1 -0
- package/dist/Command-CQ_bQsJp.js +102 -0
- package/dist/Command-CQ_bQsJp.js.map +1 -0
- package/dist/CopyField-BJ96zvXs.js +322 -0
- package/dist/CopyField-BJ96zvXs.js.map +1 -0
- package/dist/DateInput-CMD3dY-T.js +141 -0
- package/dist/DateInput-CMD3dY-T.js.map +1 -0
- package/dist/DatePicker-BbFbmsGl.js +24 -0
- package/dist/DatePicker-BbFbmsGl.js.map +1 -0
- package/dist/DateRangeInput-D3BhiKyk.js +139 -0
- package/dist/DateRangeInput-D3BhiKyk.js.map +1 -0
- package/dist/DateRangePicker-BiUgtt_M.js +159 -0
- package/dist/DateRangePicker-BiUgtt_M.js.map +1 -0
- package/dist/DiagramSkeleton-lwBS2YBa.js +11 -0
- package/dist/DiagramSkeleton-lwBS2YBa.js.map +1 -0
- package/dist/DiffView-ppTIzh2h.js +429 -0
- package/dist/DiffView-ppTIzh2h.js.map +1 -0
- package/dist/DropdownMenu-B6ZbYvaM.js +327 -0
- package/dist/DropdownMenu-B6ZbYvaM.js.map +1 -0
- package/dist/FieldBox-D7DYtX_m.js +70 -0
- package/dist/FieldBox-D7DYtX_m.js.map +1 -0
- package/dist/FileUpload-sXRv7JiY.js +2527 -0
- package/dist/FileUpload-sXRv7JiY.js.map +1 -0
- package/dist/Form-BDCef6O9.js +371 -0
- package/dist/Form-BDCef6O9.js.map +1 -0
- package/dist/FormGroup-S9mPNHKH.js +124 -0
- package/dist/FormGroup-S9mPNHKH.js.map +1 -0
- package/dist/FullScreenModal-CJa2VkJ2.js +96 -0
- package/dist/FullScreenModal-CJa2VkJ2.js.map +1 -0
- package/dist/HoverCard-WfDkLK1s.js +31 -0
- package/dist/HoverCard-WfDkLK1s.js.map +1 -0
- package/dist/InputGroup-BJWsI35s.js +292 -0
- package/dist/InputGroup-BJWsI35s.js.map +1 -0
- package/dist/Kbd-CxHAo1oo.js +111 -0
- package/dist/Kbd-CxHAo1oo.js.map +1 -0
- package/dist/MarkedText-Ckbft5mw.js +44 -0
- package/dist/MarkedText-Ckbft5mw.js.map +1 -0
- package/dist/MermaidDiagram-BB06gymm.js +399 -0
- package/dist/MermaidDiagram-BB06gymm.js.map +1 -0
- package/dist/Modal-BA5Wc3sx.js +185 -0
- package/dist/Modal-BA5Wc3sx.js.map +1 -0
- package/dist/ModalTitle-C76ke2eo.js +28 -0
- package/dist/ModalTitle-C76ke2eo.js.map +1 -0
- package/dist/MultiActionButtonGroup-CiBHxsSk.js +33 -0
- package/dist/MultiActionButtonGroup-CiBHxsSk.js.map +1 -0
- package/dist/Navbar-t16usFZQ.js +322 -0
- package/dist/Navbar-t16usFZQ.js.map +1 -0
- package/dist/OtpInput-CbbymqYs.js +93 -0
- package/dist/OtpInput-CbbymqYs.js.map +1 -0
- package/dist/PageHeader-Q3IpCnQd.js +177 -0
- package/dist/PageHeader-Q3IpCnQd.js.map +1 -0
- package/dist/PageLayout-DSVM-ASz.js +176 -0
- package/dist/PageLayout-DSVM-ASz.js.map +1 -0
- package/dist/PageToolbar-0_1OBzaZ.js +153 -0
- package/dist/PageToolbar-0_1OBzaZ.js.map +1 -0
- package/dist/Pagination-CM_Rszz-.js +70 -0
- package/dist/Pagination-CM_Rszz-.js.map +1 -0
- package/dist/Popconfirm-BGe1jLov.js +170 -0
- package/dist/Popconfirm-BGe1jLov.js.map +1 -0
- package/dist/Popover-Ca0V6AD1.js +92 -0
- package/dist/Popover-Ca0V6AD1.js.map +1 -0
- package/dist/RadioGroup-sIveSsNa.js +233 -0
- package/dist/RadioGroup-sIveSsNa.js.map +1 -0
- package/dist/Resizable-D3vYToZH.js +52 -0
- package/dist/Resizable-D3vYToZH.js.map +1 -0
- package/dist/Search-3UiqNZRj.js +184 -0
- package/dist/Search-3UiqNZRj.js.map +1 -0
- package/dist/SearchInput-D2fcOv7E.js +102 -0
- package/dist/SearchInput-D2fcOv7E.js.map +1 -0
- package/dist/SectionNav--7bw2b6u.js +276 -0
- package/dist/SectionNav--7bw2b6u.js.map +1 -0
- package/dist/Select-4YX38G5h.js +181 -0
- package/dist/Select-4YX38G5h.js.map +1 -0
- package/dist/Sheet-BQrX8-h5.js +169 -0
- package/dist/Sheet-BQrX8-h5.js.map +1 -0
- package/dist/Sidebar-ROaR_AqC.js +799 -0
- package/dist/Sidebar-ROaR_AqC.js.map +1 -0
- package/dist/Slider-Da_3mS5v.js +127 -0
- package/dist/Slider-Da_3mS5v.js.map +1 -0
- package/dist/Stepper-C8sm9ZFM.js +325 -0
- package/dist/Stepper-C8sm9ZFM.js.map +1 -0
- package/dist/Switch-CX2A0v50.js +201 -0
- package/dist/Switch-CX2A0v50.js.map +1 -0
- package/dist/Table-CvYuTuNU.js +104 -0
- package/dist/Table-CvYuTuNU.js.map +1 -0
- package/dist/Tabs-EAihyqCt.js +74 -0
- package/dist/Tabs-EAihyqCt.js.map +1 -0
- package/dist/TextInput-BGed-V13.js +110 -0
- package/dist/TextInput-BGed-V13.js.map +1 -0
- package/dist/ThemeProvider-QncUrfJn.js +203 -0
- package/dist/ThemeProvider-QncUrfJn.js.map +1 -0
- package/dist/TimePicker-B_NegL-7.js +98 -0
- package/dist/TimePicker-B_NegL-7.js.map +1 -0
- package/dist/Timeline-6btyJl4D.js +154 -0
- package/dist/Timeline-6btyJl4D.js.map +1 -0
- package/dist/Toast-DQSbs3oA.js +49 -0
- package/dist/Toast-DQSbs3oA.js.map +1 -0
- package/dist/ToggleGroup-Cy_10Mvu.js +47 -0
- package/dist/ToggleGroup-Cy_10Mvu.js.map +1 -0
- package/dist/Workbench-BzE-Vvd9.js +293 -0
- package/dist/Workbench-BzE-Vvd9.js.map +1 -0
- package/dist/ZoomableSvg-DG9PnAm8.js +248 -0
- package/dist/ZoomableSvg-DG9PnAm8.js.map +1 -0
- package/dist/charts.d.ts +110 -103
- package/dist/charts.js +303 -254
- package/dist/charts.js.map +1 -1
- package/dist/classNames-BzrkDnOD.js +9 -0
- package/dist/classNames-BzrkDnOD.js.map +1 -0
- package/dist/constants-D6JcsD4_.d.ts +41 -0
- package/dist/context-KxxeMHbR.js +62 -0
- package/dist/context-KxxeMHbR.js.map +1 -0
- package/dist/editors.d.ts +180 -173
- package/dist/editors.js +747 -428
- package/dist/editors.js.map +1 -1
- package/dist/escapeStringRegexp-8MxP2knR.js +6 -0
- package/dist/escapeStringRegexp-8MxP2knR.js.map +1 -0
- package/dist/icons-Cek151jC.js +640 -0
- package/dist/icons-Cek151jC.js.map +1 -0
- package/dist/icons.d.ts +2 -41
- package/dist/icons.js +2 -9
- package/dist/index-m-kQEWiY.d.ts +54 -0
- package/dist/index.d.ts +6183 -9885
- package/dist/index.js +112 -124
- package/dist/internal/blocks/AIKit.js +2 -30
- package/dist/internal/blocks/AppShell.js +2 -11
- package/dist/internal/blocks/AutoSaveTextarea.js +2 -14
- package/dist/internal/blocks/BrandEditor.js +2 -23
- package/dist/internal/blocks/ChartPanel.js +45 -9
- package/dist/internal/blocks/ChartPanel.js.map +1 -1
- package/dist/internal/blocks/ClipboardButton.js +2 -12
- package/dist/internal/blocks/ColorInput.js +2 -13
- package/dist/internal/blocks/ColorModeSwitch.js +2 -13
- package/dist/internal/blocks/Command.js +2 -15
- package/dist/internal/blocks/CopyField.js +2 -11
- package/dist/internal/blocks/DashboardHero.js +58 -8
- package/dist/internal/blocks/DashboardHero.js.map +1 -1
- package/dist/internal/blocks/DateInput.js +2 -16
- package/dist/internal/blocks/DateRangeInput.js +2 -16
- package/dist/internal/blocks/EmptyConfigurationActionCard.js +15 -9
- package/dist/internal/blocks/EmptyConfigurationActionCard.js.map +1 -1
- package/dist/internal/blocks/EmptyState.js +141 -3
- package/dist/internal/blocks/EmptyState.js.map +1 -1
- package/dist/internal/blocks/ErrorState.js +178 -4
- package/dist/internal/blocks/ErrorState.js.map +1 -1
- package/dist/internal/blocks/ExportMenu.js +40 -12
- package/dist/internal/blocks/ExportMenu.js.map +1 -1
- package/dist/internal/blocks/Form.js +2 -29
- package/dist/internal/blocks/FormGroup.js +2 -18
- package/dist/internal/blocks/GoogleButton.js +94 -9
- package/dist/internal/blocks/GoogleButton.js.map +1 -1
- package/dist/internal/blocks/MicrosoftButton.js +63 -9
- package/dist/internal/blocks/MicrosoftButton.js.map +1 -1
- package/dist/internal/blocks/MultiActionButtonGroup.js +2 -12
- package/dist/internal/blocks/MultiCombobox.js +187 -13
- package/dist/internal/blocks/MultiCombobox.js.map +1 -1
- package/dist/internal/blocks/NumberInput.js +43 -11
- package/dist/internal/blocks/NumberInput.js.map +1 -1
- package/dist/internal/blocks/OtpInput.js +2 -10
- package/dist/internal/blocks/PageHeader.js +2 -9
- package/dist/internal/blocks/PageLayout.js +2 -9
- package/dist/internal/blocks/PageToolbar.js +2 -13
- package/dist/internal/blocks/PasswordInput.js +96 -12
- package/dist/internal/blocks/PasswordInput.js.map +1 -1
- package/dist/internal/blocks/SearchInput.js +2 -12
- package/dist/internal/blocks/SearchInputWithNavigation.js +64 -15
- package/dist/internal/blocks/SearchInputWithNavigation.js.map +1 -1
- package/dist/internal/blocks/SectionNav.js +2 -15
- package/dist/internal/blocks/SplitButton.js +45 -13
- package/dist/internal/blocks/SplitButton.js.map +1 -1
- package/dist/internal/blocks/StatCard.js +96 -9
- package/dist/internal/blocks/StatCard.js.map +1 -1
- package/dist/internal/blocks/TextInput.js +2 -13
- package/dist/internal/blocks/Textarea.js +31 -12
- package/dist/internal/blocks/Textarea.js.map +1 -1
- package/dist/internal/blocks/TimeInput.js +76 -16
- package/dist/internal/blocks/TimeInput.js.map +1 -1
- package/dist/internal/components/Alert.js +2 -11
- package/dist/internal/components/AlertModal.js +2 -11
- package/dist/internal/components/Avatar.js +52 -8
- package/dist/internal/components/Avatar.js.map +1 -1
- package/dist/internal/components/Badge.js +2 -9
- package/dist/internal/components/BrandLogo.js +2 -11
- package/dist/internal/components/Breadcrumb.js +2 -14
- package/dist/internal/components/Button.js +2 -10
- package/dist/internal/components/ButtonGroup.js +65 -8
- package/dist/internal/components/ButtonGroup.js.map +1 -1
- package/dist/internal/components/Calendar.js +2 -9
- package/dist/internal/components/Card.js +2 -9
- package/dist/internal/components/Checkbox.js +2 -11
- package/dist/internal/components/Clipboard.js +2 -9
- package/dist/internal/components/Collapsible.js +2 -9
- package/dist/internal/components/CollapsiblePanel.js +86 -10
- package/dist/internal/components/CollapsiblePanel.js.map +1 -1
- package/dist/internal/components/Combobox.js +2 -13
- package/dist/internal/components/DatePicker.js +2 -11
- package/dist/internal/components/DateRangePicker.js +2 -17
- package/dist/internal/components/DiffView.js +2 -9
- package/dist/internal/components/DotsLoader.js +17 -4
- package/dist/internal/components/DotsLoader.js.map +1 -1
- package/dist/internal/components/DropdownMenu.js +2 -11
- package/dist/internal/components/EmptySearchContent.js +11 -3
- package/dist/internal/components/EmptySearchContent.js.map +1 -1
- package/dist/internal/components/FileUpload.js +2 -11
- package/dist/internal/components/FullScreenModal.js +2 -12
- package/dist/internal/components/HelpBlock.js +24 -3
- package/dist/internal/components/HelpBlock.js.map +1 -1
- package/dist/internal/components/HoverCard.js +2 -9
- package/dist/internal/components/InputGroup.js +2 -11
- package/dist/internal/components/Kbd.js +2 -9
- package/dist/internal/components/Label.js +38 -8
- package/dist/internal/components/Label.js.map +1 -1
- package/dist/internal/components/Link.js +21 -8
- package/dist/internal/components/Link.js.map +1 -1
- package/dist/internal/components/MarkedText.js +2 -5
- package/dist/internal/components/MergeEditor/ConflictStatus/ConflictStatusIndicator.js +19 -9
- package/dist/internal/components/MergeEditor/ConflictStatus/ConflictStatusIndicator.js.map +1 -1
- package/dist/internal/components/MergeEditor/PaneHeader.js +12 -3
- package/dist/internal/components/MergeEditor/PaneHeader.js.map +1 -1
- package/dist/internal/components/MergeEditor/constants.js +17 -3
- package/dist/internal/components/MergeEditor/constants.js.map +1 -1
- package/dist/internal/components/MergeEditor/useMergeDiff.js +2 -5
- package/dist/internal/components/Modal.js +2 -13
- package/dist/internal/components/Navbar.js +2 -14
- package/dist/internal/components/Pagination.js +2 -11
- package/dist/internal/components/PanelWithDetails.js +30 -10
- package/dist/internal/components/PanelWithDetails.js.map +1 -1
- package/dist/internal/components/Popconfirm.js +2 -12
- package/dist/internal/components/Popover.js +2 -9
- package/dist/internal/components/Progress.js +46 -8
- package/dist/internal/components/Progress.js.map +1 -1
- package/dist/internal/components/RadioGroup.js +2 -12
- package/dist/internal/components/Resizable.js +2 -9
- package/dist/internal/components/ScrollArea.js +41 -8
- package/dist/internal/components/ScrollArea.js.map +1 -1
- package/dist/internal/components/Search.js +2 -10
- package/dist/internal/components/Select.js +2 -12
- package/dist/internal/components/Separator.js +83 -8
- package/dist/internal/components/Separator.js.map +1 -1
- package/dist/internal/components/Sheet.js +2 -12
- package/dist/internal/components/Sidebar.js +2 -20
- package/dist/internal/components/Skeleton/Skeleton.js +38 -8
- package/dist/internal/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/internal/components/Skeleton/SkeletonList.js +40 -9
- package/dist/internal/components/Skeleton/SkeletonList.js.map +1 -1
- package/dist/internal/components/Slider.js +2 -11
- package/dist/internal/components/SpotlightBackdrop.js +131 -8
- package/dist/internal/components/SpotlightBackdrop.js.map +1 -1
- package/dist/internal/components/Stepper.js +2 -10
- package/dist/internal/components/Switch.js +2 -10
- package/dist/internal/components/Table.js +2 -10
- package/dist/internal/components/Tabs.js +2 -12
- package/dist/internal/components/ThemeProvider.js +3 -10
- package/dist/internal/components/TimePicker.js +2 -12
- package/dist/internal/components/Timeline.js +2 -10
- package/dist/internal/components/Toast.js +3 -11
- package/dist/internal/components/Toggle.js +168 -8
- package/dist/internal/components/Toggle.js.map +1 -1
- package/dist/internal/components/ToggleGroup.js +2 -9
- package/dist/internal/components/Tooltip.js +2 -8
- package/dist/internal/components/Truncated.js +44 -8
- package/dist/internal/components/Truncated.js.map +1 -1
- package/dist/internal/components/Workbench.js +2 -11
- package/dist/internal/components/ZoomableSvg.js +2 -13
- package/dist/internal/hooks/useAutosizeInput.js +76 -3
- package/dist/internal/hooks/useAutosizeInput.js.map +1 -1
- package/dist/internal/hooks/useScrollbarPosition.js +44 -4
- package/dist/internal/hooks/useScrollbarPosition.js.map +1 -1
- package/dist/internal/hooks/useStableCallback.js +28 -3
- package/dist/internal/hooks/useStableCallback.js.map +1 -1
- package/dist/internal/utils/mergeRefs.js +19 -3
- package/dist/internal/utils/mergeRefs.js.map +1 -1
- package/dist/internal/utils.js +5 -8
- package/dist/markdown-editor.d.ts +72 -72
- package/dist/markdown-editor.js +1122 -1207
- package/dist/markdown-editor.js.map +1 -1
- package/dist/mermaid.d.ts +12 -12
- package/dist/mermaid.js +2 -18
- package/dist/rjsf.d.ts +33 -34
- package/dist/rjsf.js +1541 -1671
- package/dist/rjsf.js.map +1 -1
- package/dist/rolldown-runtime-Bdc48AWt.js +33 -0
- package/dist/styles-DSUP_-9Z.js +158 -0
- package/dist/styles-DSUP_-9Z.js.map +1 -0
- package/dist/testing.d.ts +8 -7
- package/dist/testing.js +36 -21
- package/dist/testing.js.map +1 -1
- package/dist/themeTokens-BNg98Mu9.js +85 -0
- package/dist/themeTokens-BNg98Mu9.js.map +1 -0
- package/dist/toast-CjkURw0M.js +184 -0
- package/dist/toast-CjkURw0M.js.map +1 -0
- package/dist/useColorSchemeState-CYqcUfSH.js +61 -0
- package/dist/useColorSchemeState-CYqcUfSH.js.map +1 -0
- package/dist/useControllableState-M6494mCT.js +31 -0
- package/dist/useControllableState-M6494mCT.js.map +1 -0
- package/dist/useElement-DkF6esWL.js +15 -0
- package/dist/useElement-DkF6esWL.js.map +1 -0
- package/dist/useMergeDiff-CvowEXJ1.js +465 -0
- package/dist/useMergeDiff-CvowEXJ1.js.map +1 -0
- package/dist/utils-D0c5VAyF.js +308 -0
- package/dist/utils-D0c5VAyF.js.map +1 -0
- package/package.json +8 -8
- package/dist/MermaidDiagram-ZU5KAVRT.js +0 -18
- package/dist/MermaidDiagram-ZU5KAVRT.js.map +0 -1
- package/dist/chunk-2YYJDKSP.js +0 -51
- package/dist/chunk-2YYJDKSP.js.map +0 -1
- package/dist/chunk-3P5UUCFI.js +0 -385
- package/dist/chunk-3P5UUCFI.js.map +0 -1
- package/dist/chunk-3QDFDDWZ.js +0 -99
- package/dist/chunk-3QDFDDWZ.js.map +0 -1
- package/dist/chunk-3W27OLK5.js +0 -15
- package/dist/chunk-3W27OLK5.js.map +0 -1
- package/dist/chunk-4FIZZONW.js +0 -40
- package/dist/chunk-4FIZZONW.js.map +0 -1
- package/dist/chunk-4GIAXOJG.js +0 -133
- package/dist/chunk-4GIAXOJG.js.map +0 -1
- package/dist/chunk-52NDNMK7.js +0 -99
- package/dist/chunk-52NDNMK7.js.map +0 -1
- package/dist/chunk-576G5OES.js +0 -201
- package/dist/chunk-576G5OES.js.map +0 -1
- package/dist/chunk-5AIE6SET.js +0 -659
- package/dist/chunk-5AIE6SET.js.map +0 -1
- package/dist/chunk-5FTNAZRW.js +0 -327
- package/dist/chunk-5FTNAZRW.js.map +0 -1
- package/dist/chunk-5IG2S7ZY.js +0 -70
- package/dist/chunk-5IG2S7ZY.js.map +0 -1
- package/dist/chunk-5QCXHNCW.js +0 -404
- package/dist/chunk-5QCXHNCW.js.map +0 -1
- package/dist/chunk-6DUMGC7Y.js +0 -105
- package/dist/chunk-6DUMGC7Y.js.map +0 -1
- package/dist/chunk-6J25CVST.js +0 -174
- package/dist/chunk-6J25CVST.js.map +0 -1
- package/dist/chunk-6NN35XOP.js +0 -120
- package/dist/chunk-6NN35XOP.js.map +0 -1
- package/dist/chunk-6NZBVA4T.js +0 -24
- package/dist/chunk-6NZBVA4T.js.map +0 -1
- package/dist/chunk-6W5BHRCL.js +0 -295
- package/dist/chunk-6W5BHRCL.js.map +0 -1
- package/dist/chunk-72BKRCEG.js +0 -409
- package/dist/chunk-72BKRCEG.js.map +0 -1
- package/dist/chunk-7GTI3PPI.js +0 -95
- package/dist/chunk-7GTI3PPI.js.map +0 -1
- package/dist/chunk-7P6PLZ4B.js +0 -74
- package/dist/chunk-7P6PLZ4B.js.map +0 -1
- package/dist/chunk-7WZWY5IA.js +0 -46
- package/dist/chunk-7WZWY5IA.js.map +0 -1
- package/dist/chunk-AIYO2632.js +0 -489
- package/dist/chunk-AIYO2632.js.map +0 -1
- package/dist/chunk-ANFZWPNE.js +0 -112
- package/dist/chunk-ANFZWPNE.js.map +0 -1
- package/dist/chunk-ANZTVAJU.js +0 -73
- package/dist/chunk-ANZTVAJU.js.map +0 -1
- package/dist/chunk-BD5BTJKX.js +0 -166
- package/dist/chunk-BD5BTJKX.js.map +0 -1
- package/dist/chunk-BHGIDSRJ.js +0 -140
- package/dist/chunk-BHGIDSRJ.js.map +0 -1
- package/dist/chunk-BSQWZITZ.js +0 -507
- package/dist/chunk-BSQWZITZ.js.map +0 -1
- package/dist/chunk-D3LAIK62.js +0 -23
- package/dist/chunk-D3LAIK62.js.map +0 -1
- package/dist/chunk-DODCR43C.js +0 -155
- package/dist/chunk-DODCR43C.js.map +0 -1
- package/dist/chunk-EEK5NGZF.js +0 -40
- package/dist/chunk-EEK5NGZF.js.map +0 -1
- package/dist/chunk-ENRG7TXA.js +0 -11
- package/dist/chunk-ENRG7TXA.js.map +0 -1
- package/dist/chunk-EQRMGIGY.js +0 -239
- package/dist/chunk-EQRMGIGY.js.map +0 -1
- package/dist/chunk-ERAHK5YQ.js +0 -495
- package/dist/chunk-ERAHK5YQ.js.map +0 -1
- package/dist/chunk-F3FOFY2P.js +0 -124
- package/dist/chunk-F3FOFY2P.js.map +0 -1
- package/dist/chunk-F6BTWFOC.js +0 -507
- package/dist/chunk-F6BTWFOC.js.map +0 -1
- package/dist/chunk-F6J6NNAL.js +0 -34
- package/dist/chunk-F6J6NNAL.js.map +0 -1
- package/dist/chunk-FCHJ7D5O.js +0 -59
- package/dist/chunk-FCHJ7D5O.js.map +0 -1
- package/dist/chunk-FFJTEQCC.js +0 -80
- package/dist/chunk-FFJTEQCC.js.map +0 -1
- package/dist/chunk-FUFMVW7O.js +0 -64
- package/dist/chunk-FUFMVW7O.js.map +0 -1
- package/dist/chunk-FVPGQ6UE.js +0 -25
- package/dist/chunk-FVPGQ6UE.js.map +0 -1
- package/dist/chunk-G3PMV62Z.js +0 -33
- package/dist/chunk-G3PMV62Z.js.map +0 -1
- package/dist/chunk-GACFOW3E.js +0 -51
- package/dist/chunk-GACFOW3E.js.map +0 -1
- package/dist/chunk-GDT6HQMK.js +0 -42
- package/dist/chunk-GDT6HQMK.js.map +0 -1
- package/dist/chunk-HLGU22C6.js +0 -2589
- package/dist/chunk-HLGU22C6.js.map +0 -1
- package/dist/chunk-HPMYYGP7.js +0 -134
- package/dist/chunk-HPMYYGP7.js.map +0 -1
- package/dist/chunk-I2UCOD45.js +0 -197
- package/dist/chunk-I2UCOD45.js.map +0 -1
- package/dist/chunk-IEGDZUVM.js +0 -75
- package/dist/chunk-IEGDZUVM.js.map +0 -1
- package/dist/chunk-IIS7INHF.js +0 -47
- package/dist/chunk-IIS7INHF.js.map +0 -1
- package/dist/chunk-ITELSEFU.js +0 -256
- package/dist/chunk-ITELSEFU.js.map +0 -1
- package/dist/chunk-IXAYNBOY.js +0 -407
- package/dist/chunk-IXAYNBOY.js.map +0 -1
- package/dist/chunk-JUW2ETEI.js +0 -191
- package/dist/chunk-JUW2ETEI.js.map +0 -1
- package/dist/chunk-K65C7CVE.js +0 -127
- package/dist/chunk-K65C7CVE.js.map +0 -1
- package/dist/chunk-KDI64MCY.js +0 -189
- package/dist/chunk-KDI64MCY.js.map +0 -1
- package/dist/chunk-KN4ASMH5.js +0 -160
- package/dist/chunk-KN4ASMH5.js.map +0 -1
- package/dist/chunk-KQW7QNTU.js +0 -1549
- package/dist/chunk-KQW7QNTU.js.map +0 -1
- package/dist/chunk-KR7NXXHC.js +0 -66
- package/dist/chunk-KR7NXXHC.js.map +0 -1
- package/dist/chunk-KRZKIVMA.js +0 -142
- package/dist/chunk-KRZKIVMA.js.map +0 -1
- package/dist/chunk-KTTLLKGQ.js +0 -185
- package/dist/chunk-KTTLLKGQ.js.map +0 -1
- package/dist/chunk-KWKSHPDP.js +0 -234
- package/dist/chunk-KWKSHPDP.js.map +0 -1
- package/dist/chunk-KZVC7OYG.js +0 -57
- package/dist/chunk-KZVC7OYG.js.map +0 -1
- package/dist/chunk-L5DHUN2V.js +0 -204
- package/dist/chunk-L5DHUN2V.js.map +0 -1
- package/dist/chunk-LCTGEH57.js +0 -1376
- package/dist/chunk-LCTGEH57.js.map +0 -1
- package/dist/chunk-LXLIQ2D6.js +0 -12
- package/dist/chunk-LXLIQ2D6.js.map +0 -1
- package/dist/chunk-M4CTURKX.js +0 -84
- package/dist/chunk-M4CTURKX.js.map +0 -1
- package/dist/chunk-M6LTUPVP.js +0 -301
- package/dist/chunk-M6LTUPVP.js.map +0 -1
- package/dist/chunk-MA6RRHDT.js +0 -291
- package/dist/chunk-MA6RRHDT.js.map +0 -1
- package/dist/chunk-MODE4QIA.js +0 -6
- package/dist/chunk-MODE4QIA.js.map +0 -1
- package/dist/chunk-MVILMVGG.js +0 -118
- package/dist/chunk-MVILMVGG.js.map +0 -1
- package/dist/chunk-MWS4VCLV.js +0 -17
- package/dist/chunk-MWS4VCLV.js.map +0 -1
- package/dist/chunk-NEUX74SO.js +0 -315
- package/dist/chunk-NEUX74SO.js.map +0 -1
- package/dist/chunk-NFHKYBRD.js +0 -156
- package/dist/chunk-NFHKYBRD.js.map +0 -1
- package/dist/chunk-NHJNNXD3.js +0 -89
- package/dist/chunk-NHJNNXD3.js.map +0 -1
- package/dist/chunk-O2BF3HZL.js +0 -33
- package/dist/chunk-O2BF3HZL.js.map +0 -1
- package/dist/chunk-OANXCZYD.js +0 -212
- package/dist/chunk-OANXCZYD.js.map +0 -1
- package/dist/chunk-ODJF7YIP.js +0 -230
- package/dist/chunk-ODJF7YIP.js.map +0 -1
- package/dist/chunk-ON4BJTHI.js +0 -101
- package/dist/chunk-ON4BJTHI.js.map +0 -1
- package/dist/chunk-OTL5WXIJ.js +0 -16
- package/dist/chunk-OTL5WXIJ.js.map +0 -1
- package/dist/chunk-PACNBKJV.js +0 -47
- package/dist/chunk-PACNBKJV.js.map +0 -1
- package/dist/chunk-PROCA7K7.js +0 -23
- package/dist/chunk-PROCA7K7.js.map +0 -1
- package/dist/chunk-QGMIPA67.js +0 -85
- package/dist/chunk-QGMIPA67.js.map +0 -1
- package/dist/chunk-QQA37LFB.js +0 -190
- package/dist/chunk-QQA37LFB.js.map +0 -1
- package/dist/chunk-QZAWRSEB.js +0 -61
- package/dist/chunk-QZAWRSEB.js.map +0 -1
- package/dist/chunk-R74KGWNS.js +0 -699
- package/dist/chunk-R74KGWNS.js.map +0 -1
- package/dist/chunk-RFDLHMKL.js +0 -110
- package/dist/chunk-RFDLHMKL.js.map +0 -1
- package/dist/chunk-RL64HN7S.js +0 -40
- package/dist/chunk-RL64HN7S.js.map +0 -1
- package/dist/chunk-RMRQKPL7.js +0 -115
- package/dist/chunk-RMRQKPL7.js.map +0 -1
- package/dist/chunk-RQVK4IYC.js +0 -606
- package/dist/chunk-RQVK4IYC.js.map +0 -1
- package/dist/chunk-RTW56PWZ.js +0 -59
- package/dist/chunk-RTW56PWZ.js.map +0 -1
- package/dist/chunk-RUTPQNLR.js +0 -266
- package/dist/chunk-RUTPQNLR.js.map +0 -1
- package/dist/chunk-S6TAF63G.js +0 -25
- package/dist/chunk-S6TAF63G.js.map +0 -1
- package/dist/chunk-SBGAUGXY.js +0 -224
- package/dist/chunk-SBGAUGXY.js.map +0 -1
- package/dist/chunk-SC275NHZ.js +0 -407
- package/dist/chunk-SC275NHZ.js.map +0 -1
- package/dist/chunk-SCQPU4UE.js +0 -97
- package/dist/chunk-SCQPU4UE.js.map +0 -1
- package/dist/chunk-SFFF2WQP.js +0 -8
- package/dist/chunk-SFFF2WQP.js.map +0 -1
- package/dist/chunk-SJYMHZKA.js +0 -36
- package/dist/chunk-SJYMHZKA.js.map +0 -1
- package/dist/chunk-SLCCUJVN.js +0 -125
- package/dist/chunk-SLCCUJVN.js.map +0 -1
- package/dist/chunk-SVBSNSD4.js +0 -259
- package/dist/chunk-SVBSNSD4.js.map +0 -1
- package/dist/chunk-SVPLTL35.js +0 -62
- package/dist/chunk-SVPLTL35.js.map +0 -1
- package/dist/chunk-SWQFYNYG.js +0 -338
- package/dist/chunk-SWQFYNYG.js.map +0 -1
- package/dist/chunk-THHB4EWS.js +0 -72
- package/dist/chunk-THHB4EWS.js.map +0 -1
- package/dist/chunk-TUCDD33E.js +0 -246
- package/dist/chunk-TUCDD33E.js.map +0 -1
- package/dist/chunk-TV4WAP2R.js +0 -14
- package/dist/chunk-TV4WAP2R.js.map +0 -1
- package/dist/chunk-U3A6YBTZ.js +0 -134
- package/dist/chunk-U3A6YBTZ.js.map +0 -1
- package/dist/chunk-UGT6DKWM.js +0 -95
- package/dist/chunk-VSERHUWD.js +0 -212
- package/dist/chunk-VSERHUWD.js.map +0 -1
- package/dist/chunk-VYG7BDXC.js +0 -49
- package/dist/chunk-VYG7BDXC.js.map +0 -1
- package/dist/chunk-WETKNYZX.js +0 -52
- package/dist/chunk-WETKNYZX.js.map +0 -1
- package/dist/chunk-WGG4AML3.js +0 -216
- package/dist/chunk-WGG4AML3.js.map +0 -1
- package/dist/chunk-WKAUEL6I.js +0 -30
- package/dist/chunk-WKAUEL6I.js.map +0 -1
- package/dist/chunk-WPOLA5CG.js +0 -81
- package/dist/chunk-WPOLA5CG.js.map +0 -1
- package/dist/chunk-WPVETCGJ.js +0 -254
- package/dist/chunk-WPVETCGJ.js.map +0 -1
- package/dist/chunk-WTSM3A7E.js +0 -13
- package/dist/chunk-WTSM3A7E.js.map +0 -1
- package/dist/chunk-WU3F2K3T.js +0 -148
- package/dist/chunk-WU3F2K3T.js.map +0 -1
- package/dist/chunk-WZZK2DTZ.js +0 -39
- package/dist/chunk-WZZK2DTZ.js.map +0 -1
- package/dist/chunk-X4IHLKRD.js +0 -42
- package/dist/chunk-X4IHLKRD.js.map +0 -1
- package/dist/chunk-XAHEXZJC.js +0 -80
- package/dist/chunk-XAHEXZJC.js.map +0 -1
- package/dist/chunk-XCYGJDUX.js +0 -31
- package/dist/chunk-XCYGJDUX.js.map +0 -1
- package/dist/chunk-Y4W3JORC.js +0 -104
- package/dist/chunk-Y4W3JORC.js.map +0 -1
- package/dist/chunk-YFZJ3ZLG.js +0 -1297
- package/dist/chunk-YFZJ3ZLG.js.map +0 -1
- package/dist/chunk-YI3WLXEN.js +0 -4387
- package/dist/chunk-YI3WLXEN.js.map +0 -1
- package/dist/chunk-ZBKFSPD3.js +0 -29
- package/dist/chunk-ZBKFSPD3.js.map +0 -1
- package/dist/chunk-ZOERRQ6A.js +0 -79
- package/dist/chunk-ZOERRQ6A.js.map +0 -1
- package/dist/chunk-ZSTGUKHU.js +0 -10
- package/dist/chunk-ZSTGUKHU.js.map +0 -1
- package/dist/chunk-ZUEHDL27.js +0 -65
- package/dist/chunk-ZUEHDL27.js.map +0 -1
- package/dist/constants-D3gaMY-W.d.ts +0 -39
- package/dist/icons.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/blocks/AIKit.js.map +0 -1
- package/dist/internal/blocks/AppShell.js.map +0 -1
- package/dist/internal/blocks/AutoSaveTextarea.js.map +0 -1
- package/dist/internal/blocks/BrandEditor.js.map +0 -1
- package/dist/internal/blocks/ClipboardButton.js.map +0 -1
- package/dist/internal/blocks/ColorInput.js.map +0 -1
- package/dist/internal/blocks/ColorModeSwitch.js.map +0 -1
- package/dist/internal/blocks/Command.js.map +0 -1
- package/dist/internal/blocks/CopyField.js.map +0 -1
- package/dist/internal/blocks/DateInput.js.map +0 -1
- package/dist/internal/blocks/DateRangeInput.js.map +0 -1
- package/dist/internal/blocks/Form.js.map +0 -1
- package/dist/internal/blocks/FormGroup.js.map +0 -1
- package/dist/internal/blocks/MultiActionButtonGroup.js.map +0 -1
- package/dist/internal/blocks/OtpInput.js.map +0 -1
- package/dist/internal/blocks/PageHeader.js.map +0 -1
- package/dist/internal/blocks/PageLayout.js.map +0 -1
- package/dist/internal/blocks/PageToolbar.js.map +0 -1
- package/dist/internal/blocks/SearchInput.js.map +0 -1
- package/dist/internal/blocks/SectionNav.js.map +0 -1
- package/dist/internal/blocks/TextInput.js.map +0 -1
- package/dist/internal/components/Alert.js.map +0 -1
- package/dist/internal/components/AlertModal.js.map +0 -1
- package/dist/internal/components/Badge.js.map +0 -1
- package/dist/internal/components/BrandLogo.js.map +0 -1
- package/dist/internal/components/Breadcrumb.js.map +0 -1
- package/dist/internal/components/Button.js.map +0 -1
- package/dist/internal/components/Calendar.js.map +0 -1
- package/dist/internal/components/Card.js.map +0 -1
- package/dist/internal/components/Checkbox.js.map +0 -1
- package/dist/internal/components/Clipboard.js.map +0 -1
- package/dist/internal/components/Collapsible.js.map +0 -1
- package/dist/internal/components/Combobox.js.map +0 -1
- package/dist/internal/components/DatePicker.js.map +0 -1
- package/dist/internal/components/DateRangePicker.js.map +0 -1
- package/dist/internal/components/DiffView.js.map +0 -1
- package/dist/internal/components/DropdownMenu.js.map +0 -1
- package/dist/internal/components/FileUpload.js.map +0 -1
- package/dist/internal/components/FullScreenModal.js.map +0 -1
- package/dist/internal/components/HoverCard.js.map +0 -1
- package/dist/internal/components/InputGroup.js.map +0 -1
- package/dist/internal/components/Kbd.js.map +0 -1
- package/dist/internal/components/MarkedText.js.map +0 -1
- package/dist/internal/components/MergeEditor/useMergeDiff.js.map +0 -1
- package/dist/internal/components/Modal.js.map +0 -1
- package/dist/internal/components/Navbar.js.map +0 -1
- package/dist/internal/components/Pagination.js.map +0 -1
- package/dist/internal/components/Popconfirm.js.map +0 -1
- package/dist/internal/components/Popover.js.map +0 -1
- package/dist/internal/components/RadioGroup.js.map +0 -1
- package/dist/internal/components/Resizable.js.map +0 -1
- package/dist/internal/components/Search.js.map +0 -1
- package/dist/internal/components/Select.js.map +0 -1
- package/dist/internal/components/Sheet.js.map +0 -1
- package/dist/internal/components/Sidebar.js.map +0 -1
- package/dist/internal/components/Slider.js.map +0 -1
- package/dist/internal/components/Stepper.js.map +0 -1
- package/dist/internal/components/Switch.js.map +0 -1
- package/dist/internal/components/Table.js.map +0 -1
- package/dist/internal/components/Tabs.js.map +0 -1
- package/dist/internal/components/ThemeProvider.js.map +0 -1
- package/dist/internal/components/TimePicker.js.map +0 -1
- package/dist/internal/components/Timeline.js.map +0 -1
- package/dist/internal/components/Toast.js.map +0 -1
- package/dist/internal/components/ToggleGroup.js.map +0 -1
- package/dist/internal/components/Tooltip.js.map +0 -1
- package/dist/internal/components/Workbench.js.map +0 -1
- package/dist/internal/components/ZoomableSvg.js.map +0 -1
- package/dist/internal/utils.js.map +0 -1
- package/dist/mermaid.js.map +0 -1
package/dist/markdown-editor.js
CHANGED
|
@@ -1,1237 +1,1152 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (renderer) return /* @__PURE__ */ jsx(Fragment, { children: renderer({ src, alt }) });
|
|
59
|
-
return /* @__PURE__ */ jsx("img", { src, alt });
|
|
1
|
+
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
|
+
import { Tooltip } from "./utils-D0c5VAyF.js";
|
|
3
|
+
import { AlignCenter, AlignJustify, AlignLeft, AlignRight, Bold, ChevronDown, Code, Heading1, Heading2, Heading3, Italic, Link, List, ListOrdered, Quote, SquareCode, Strikethrough, Type, Underline } from "./icons-Cek151jC.js";
|
|
4
|
+
import { Button } from "./Button-nzmDNS2q.js";
|
|
5
|
+
import { ButtonGroup } from "./internal/components/ButtonGroup.js";
|
|
6
|
+
import { DropdownMenu } from "./DropdownMenu-B6ZbYvaM.js";
|
|
7
|
+
import { Label } from "./internal/components/Label.js";
|
|
8
|
+
import { TextInput } from "./TextInput-BGed-V13.js";
|
|
9
|
+
import { FormGroup } from "./FormGroup-S9mPNHKH.js";
|
|
10
|
+
import { Skeleton } from "./internal/components/Skeleton/Skeleton.js";
|
|
11
|
+
import { toast } from "./toast-CjkURw0M.js";
|
|
12
|
+
import { Suspense, createContext, lazy, use, useCallback, useEffect, useRef, useState } from "react";
|
|
13
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
import { $createCodeNode, $isCodeNode, CodeNode } from "@lexical/code";
|
|
16
|
+
import { $createLinkNode, $isLinkNode, LinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
|
|
17
|
+
import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListItemNode, ListNode, REMOVE_LIST_COMMAND } from "@lexical/list";
|
|
18
|
+
import { $convertFromMarkdownString, $convertToMarkdownString, CHECK_LIST, TRANSFORMERS } from "@lexical/markdown";
|
|
19
|
+
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
20
|
+
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
|
|
21
|
+
import { ClickableLinkPlugin } from "@lexical/react/LexicalClickableLinkPlugin";
|
|
22
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
23
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
24
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
25
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
26
|
+
import { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
27
|
+
import { HorizontalRulePlugin } from "@lexical/react/LexicalHorizontalRulePlugin";
|
|
28
|
+
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
29
|
+
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
30
|
+
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
31
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
32
|
+
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
33
|
+
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
34
|
+
import { $createParagraphNode, $createTextNode, $getNodeByKey, $getSelection, $insertNodes, $isRangeSelection, $setSelection, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_HIGH, DROP_COMMAND, DecoratorNode, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, KEY_DOWN_COMMAND, PASTE_COMMAND } from "lexical";
|
|
35
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
36
|
+
import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
|
|
37
|
+
//#region src/blocks/MarkdownEditor/context.ts
|
|
38
|
+
const ImageRendererContext = createContext(null);
|
|
39
|
+
const ImageRendererProvider = ImageRendererContext;
|
|
40
|
+
const useImageRenderer = () => use(ImageRendererContext);
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/blocks/MarkdownEditor/nodes/ImageNodeComponent.tsx
|
|
43
|
+
const isPlaceholder = (src) => src.startsWith("upload-placeholder-");
|
|
44
|
+
const ImageNodeComponent = ({ src, alt }) => {
|
|
45
|
+
const renderer = useImageRenderer();
|
|
46
|
+
if (isPlaceholder(src)) return /* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: "tw:inline-flex tw:items-center tw:gap-1 tw:rounded tw:bg-neutral-100 tw:px-2 tw:py-1 tw:text-xs tw:text-neutral-400",
|
|
48
|
+
children: "Uploading image…"
|
|
49
|
+
});
|
|
50
|
+
if (renderer) return /* @__PURE__ */ jsx(Fragment$1, { children: renderer({
|
|
51
|
+
src,
|
|
52
|
+
alt
|
|
53
|
+
}) });
|
|
54
|
+
return /* @__PURE__ */ jsx("img", {
|
|
55
|
+
src,
|
|
56
|
+
alt
|
|
57
|
+
});
|
|
60
58
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/blocks/MarkdownEditor/nodes/ImageNode.tsx
|
|
61
|
+
var ImageNode = class ImageNode extends DecoratorNode {
|
|
62
|
+
__src;
|
|
63
|
+
__altText;
|
|
64
|
+
static getType() {
|
|
65
|
+
return "image";
|
|
66
|
+
}
|
|
67
|
+
static clone(node) {
|
|
68
|
+
return new ImageNode(node.__src, node.__altText, node.__key);
|
|
69
|
+
}
|
|
70
|
+
constructor(src, altText, key) {
|
|
71
|
+
super(key);
|
|
72
|
+
this.__src = src;
|
|
73
|
+
this.__altText = altText;
|
|
74
|
+
}
|
|
75
|
+
getSrc() {
|
|
76
|
+
return this.__src;
|
|
77
|
+
}
|
|
78
|
+
getAlt() {
|
|
79
|
+
return this.__altText;
|
|
80
|
+
}
|
|
81
|
+
setSrc(src) {
|
|
82
|
+
const writable = this.getWritable();
|
|
83
|
+
writable.__src = src;
|
|
84
|
+
}
|
|
85
|
+
setAlt(altText) {
|
|
86
|
+
const writable = this.getWritable();
|
|
87
|
+
writable.__altText = altText;
|
|
88
|
+
}
|
|
89
|
+
createDOM(config) {
|
|
90
|
+
const span = document.createElement("span");
|
|
91
|
+
const className = config.theme.image;
|
|
92
|
+
if (typeof className === "string") span.className = className;
|
|
93
|
+
return span;
|
|
94
|
+
}
|
|
95
|
+
updateDOM() {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
decorate() {
|
|
99
|
+
return /* @__PURE__ */ jsx(ImageNodeComponent, {
|
|
100
|
+
src: this.__src,
|
|
101
|
+
alt: this.__altText
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
isInline() {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
static importJSON(serializedNode) {
|
|
108
|
+
return $createImageNode(serializedNode.src, serializedNode.altText);
|
|
109
|
+
}
|
|
110
|
+
exportJSON() {
|
|
111
|
+
return {
|
|
112
|
+
type: "image",
|
|
113
|
+
version: 1,
|
|
114
|
+
src: this.__src,
|
|
115
|
+
altText: this.__altText
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
exportDOM() {
|
|
119
|
+
const element = document.createElement("img");
|
|
120
|
+
element.setAttribute("src", this.__src);
|
|
121
|
+
element.setAttribute("alt", this.__altText);
|
|
122
|
+
return { element };
|
|
123
|
+
}
|
|
124
|
+
static importDOM() {
|
|
125
|
+
return { img: () => ({
|
|
126
|
+
conversion: (domNode) => {
|
|
127
|
+
const src = domNode.getAttribute("src") || "";
|
|
128
|
+
const alt = domNode.getAttribute("alt") || "";
|
|
129
|
+
return { node: $createImageNode(src, alt) };
|
|
130
|
+
},
|
|
131
|
+
priority: 0
|
|
132
|
+
}) };
|
|
133
|
+
}
|
|
135
134
|
};
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const $createImageNode = (src, altText) => {
|
|
136
|
+
return new ImageNode(src, altText);
|
|
138
137
|
};
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
const $isImageNode = (node) => {
|
|
139
|
+
return node instanceof ImageNode;
|
|
141
140
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{
|
|
157
|
-
fallback: /* @__PURE__ */ jsx("div", { className: "tw:my-3 tw:overflow-hidden tw:rounded-card tw:border tw:border-neutral-150 tw:bg-neutral-50 tw:p-6", children: /* @__PURE__ */ jsx(Skeleton, { className: "tw:h-40" }) }),
|
|
158
|
-
children: /* @__PURE__ */ jsx(MermaidDiagram, { code })
|
|
159
|
-
}
|
|
160
|
-
);
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/blocks/MarkdownEditor/nodes/MermaidNodeComponent.tsx
|
|
143
|
+
const MermaidDiagram = lazy(() => import("./MermaidDiagram-BB06gymm.js").then((n) => n.MermaidDiagram_exports).then((m) => ({ default: m.MermaidDiagram }), (error) => {
|
|
144
|
+
console.error("[MarkdownEditor] failed to load MermaidDiagram chunk", error);
|
|
145
|
+
return { default: ({ code }) => /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: code }) }) };
|
|
146
|
+
}));
|
|
147
|
+
const MermaidNodeComponent = ({ code }) => {
|
|
148
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
149
|
+
fallback: /* @__PURE__ */ jsx("div", {
|
|
150
|
+
className: "tw:my-3 tw:overflow-hidden tw:rounded-card tw:border tw:border-neutral-150 tw:bg-neutral-50 tw:p-6",
|
|
151
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "tw:h-40" })
|
|
152
|
+
}),
|
|
153
|
+
children: /* @__PURE__ */ jsx(MermaidDiagram, { code })
|
|
154
|
+
});
|
|
161
155
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/blocks/MarkdownEditor/nodes/MermaidNode.tsx
|
|
158
|
+
var MermaidNode = class MermaidNode extends DecoratorNode {
|
|
159
|
+
__code;
|
|
160
|
+
static getType() {
|
|
161
|
+
return "mermaid";
|
|
162
|
+
}
|
|
163
|
+
static clone(node) {
|
|
164
|
+
return new MermaidNode(node.__code, node.__key);
|
|
165
|
+
}
|
|
166
|
+
constructor(code, key) {
|
|
167
|
+
super(key);
|
|
168
|
+
this.__code = code;
|
|
169
|
+
}
|
|
170
|
+
getCode() {
|
|
171
|
+
return this.__code;
|
|
172
|
+
}
|
|
173
|
+
setCode(code) {
|
|
174
|
+
const writable = this.getWritable();
|
|
175
|
+
writable.__code = code;
|
|
176
|
+
}
|
|
177
|
+
createDOM() {
|
|
178
|
+
const div = document.createElement("div");
|
|
179
|
+
div.setAttribute("data-lexical-mermaid", "true");
|
|
180
|
+
return div;
|
|
181
|
+
}
|
|
182
|
+
updateDOM() {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
decorate() {
|
|
186
|
+
return /* @__PURE__ */ jsx(MermaidNodeComponent, { code: this.__code });
|
|
187
|
+
}
|
|
188
|
+
isInline() {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
static importJSON(serializedNode) {
|
|
192
|
+
return $createMermaidNode(serializedNode.code);
|
|
193
|
+
}
|
|
194
|
+
exportJSON() {
|
|
195
|
+
return {
|
|
196
|
+
type: "mermaid",
|
|
197
|
+
version: 1,
|
|
198
|
+
code: this.__code
|
|
199
|
+
};
|
|
200
|
+
}
|
|
205
201
|
};
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
const $createMermaidNode = (code) => {
|
|
203
|
+
return new MermaidNode(code);
|
|
208
204
|
};
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
const $isMermaidNode = (node) => {
|
|
206
|
+
return node instanceof MermaidNode;
|
|
211
207
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/blocks/MarkdownEditor/plugins/ImagePastePlugin.tsx
|
|
210
|
+
const ACCEPTED_IMAGE_TYPES = [
|
|
211
|
+
"image/png",
|
|
212
|
+
"image/jpeg",
|
|
213
|
+
"image/gif",
|
|
214
|
+
"image/webp",
|
|
215
|
+
"image/svg+xml"
|
|
218
216
|
];
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
226
|
-
};
|
|
227
|
-
var isAcceptedImageType = (type) => ACCEPTED_IMAGE_TYPES.includes(type);
|
|
228
|
-
var getImageFilesFromDataTransfer = (dataTransfer) => {
|
|
229
|
-
if (!dataTransfer) return [];
|
|
230
|
-
if (dataTransfer.items.length > 0) {
|
|
231
|
-
const files = [];
|
|
232
|
-
for (const item of dataTransfer.items) {
|
|
233
|
-
if (item.kind === "file" && isAcceptedImageType(item.type)) {
|
|
234
|
-
const file = item.getAsFile();
|
|
235
|
-
if (file) files.push(file);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (files.length > 0) return files;
|
|
239
|
-
}
|
|
240
|
-
return Array.from(dataTransfer.files).filter((file) => isAcceptedImageType(file.type));
|
|
241
|
-
};
|
|
242
|
-
var escapeMarkdownAlt = (text) => text.replace(/[[\]()]/g, "");
|
|
243
|
-
var ImagePastePlugin = ({ onImageUpload }) => {
|
|
244
|
-
const [editor] = useLexicalComposerContext();
|
|
245
|
-
const onImageUploadRef = useRef(onImageUpload);
|
|
246
|
-
onImageUploadRef.current = onImageUpload;
|
|
247
|
-
useEffect(() => {
|
|
248
|
-
const uploadFile = (file) => {
|
|
249
|
-
const upload = onImageUploadRef.current;
|
|
250
|
-
if (!upload) return;
|
|
251
|
-
if (file.size > MAX_IMAGE_SIZE) {
|
|
252
|
-
toast.error(`Image "${file.name}" is too large. Maximum size is 10 MB.`);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
let nodeKey = null;
|
|
256
|
-
editor.update(() => {
|
|
257
|
-
const placeholderNode = $createImageNode(
|
|
258
|
-
`${PLACEHOLDER_PREFIX}${generatePlaceholderId()}`,
|
|
259
|
-
"Uploading image\u2026"
|
|
260
|
-
);
|
|
261
|
-
$insertNodes([placeholderNode]);
|
|
262
|
-
nodeKey = placeholderNode.getKey();
|
|
263
|
-
});
|
|
264
|
-
if (!nodeKey) return;
|
|
265
|
-
const capturedKey = nodeKey;
|
|
266
|
-
upload(file).then(({ url }) => {
|
|
267
|
-
editor.update(() => {
|
|
268
|
-
const node = $getNodeByKey(capturedKey);
|
|
269
|
-
if ($isImageNode(node)) {
|
|
270
|
-
const altText = escapeMarkdownAlt(file.name.replace(/\.[^.]+$/, "") || "image");
|
|
271
|
-
node.setSrc(url);
|
|
272
|
-
node.setAlt(altText);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}).catch((error) => {
|
|
276
|
-
console.error("[MarkdownEditor] image upload failed", error);
|
|
277
|
-
toast.error(`Failed to upload "${file.name}". Please try again.`);
|
|
278
|
-
editor.update(() => {
|
|
279
|
-
const node = $getNodeByKey(capturedKey);
|
|
280
|
-
if (node) node.remove();
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
const removePaste = editor.registerCommand(
|
|
285
|
-
PASTE_COMMAND,
|
|
286
|
-
(event) => {
|
|
287
|
-
if (!onImageUploadRef.current) return false;
|
|
288
|
-
if (!(event instanceof ClipboardEvent)) return false;
|
|
289
|
-
const files = getImageFilesFromDataTransfer(event.clipboardData);
|
|
290
|
-
if (files.length === 0) return false;
|
|
291
|
-
event.preventDefault();
|
|
292
|
-
Promise.resolve().then(() => files.forEach(uploadFile));
|
|
293
|
-
return true;
|
|
294
|
-
},
|
|
295
|
-
COMMAND_PRIORITY_CRITICAL
|
|
296
|
-
);
|
|
297
|
-
const removeDrop = editor.registerCommand(
|
|
298
|
-
DROP_COMMAND,
|
|
299
|
-
(event) => {
|
|
300
|
-
if (!onImageUploadRef.current) return false;
|
|
301
|
-
const files = getImageFilesFromDataTransfer(event.dataTransfer);
|
|
302
|
-
if (files.length === 0) return false;
|
|
303
|
-
event.preventDefault();
|
|
304
|
-
Promise.resolve().then(() => files.forEach(uploadFile));
|
|
305
|
-
return true;
|
|
306
|
-
},
|
|
307
|
-
COMMAND_PRIORITY_CRITICAL
|
|
308
|
-
);
|
|
309
|
-
return () => {
|
|
310
|
-
removePaste();
|
|
311
|
-
removeDrop();
|
|
312
|
-
};
|
|
313
|
-
}, [editor]);
|
|
314
|
-
return null;
|
|
217
|
+
const MAX_IMAGE_SIZE = 10485760;
|
|
218
|
+
const PLACEHOLDER_PREFIX = "upload-placeholder-";
|
|
219
|
+
const generatePlaceholderId = () => {
|
|
220
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
221
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
315
222
|
};
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const singleLineRef = useRef(singleLine);
|
|
329
|
-
singleLineRef.current = singleLine;
|
|
330
|
-
const blurOnEscapeRef = useRef(blurOnEscape);
|
|
331
|
-
blurOnEscapeRef.current = blurOnEscape;
|
|
332
|
-
const skipBlurSaveExternalRef = skipBlurSaveRef;
|
|
333
|
-
useEffect(() => {
|
|
334
|
-
return editor.registerCommand(
|
|
335
|
-
KEY_DOWN_COMMAND,
|
|
336
|
-
(event) => {
|
|
337
|
-
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
338
|
-
event.preventDefault();
|
|
339
|
-
onSaveRef.current?.();
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
if (event.key === "Enter" && !event.shiftKey && !event.altKey && singleLineRef.current) {
|
|
343
|
-
event.preventDefault();
|
|
344
|
-
editor.getRootElement()?.blur();
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
if (event.key === "Escape" && blurOnEscapeRef.current) {
|
|
348
|
-
if (skipBlurSaveExternalRef) skipBlurSaveExternalRef.current = true;
|
|
349
|
-
onCancelRef.current?.();
|
|
350
|
-
editor.getRootElement()?.blur();
|
|
351
|
-
return true;
|
|
352
|
-
}
|
|
353
|
-
return false;
|
|
354
|
-
},
|
|
355
|
-
COMMAND_PRIORITY_HIGH
|
|
356
|
-
);
|
|
357
|
-
}, [editor, skipBlurSaveExternalRef]);
|
|
358
|
-
return null;
|
|
223
|
+
const isAcceptedImageType = (type) => ACCEPTED_IMAGE_TYPES.includes(type);
|
|
224
|
+
const getImageFilesFromDataTransfer = (dataTransfer) => {
|
|
225
|
+
if (!dataTransfer) return [];
|
|
226
|
+
if (dataTransfer.items.length > 0) {
|
|
227
|
+
const files = [];
|
|
228
|
+
for (const item of dataTransfer.items) if (item.kind === "file" && isAcceptedImageType(item.type)) {
|
|
229
|
+
const file = item.getAsFile();
|
|
230
|
+
if (file) files.push(file);
|
|
231
|
+
}
|
|
232
|
+
if (files.length > 0) return files;
|
|
233
|
+
}
|
|
234
|
+
return Array.from(dataTransfer.files).filter((file) => isAcceptedImageType(file.type));
|
|
359
235
|
};
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
236
|
+
const escapeMarkdownAlt = (text) => text.replace(/[[\]()]/g, "");
|
|
237
|
+
const ImagePastePlugin = ({ onImageUpload }) => {
|
|
238
|
+
const [editor] = useLexicalComposerContext();
|
|
239
|
+
const onImageUploadRef = useRef(onImageUpload);
|
|
240
|
+
onImageUploadRef.current = onImageUpload;
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
const uploadFile = (file) => {
|
|
243
|
+
const upload = onImageUploadRef.current;
|
|
244
|
+
if (!upload) return;
|
|
245
|
+
if (file.size > MAX_IMAGE_SIZE) {
|
|
246
|
+
toast.error(`Image "${file.name}" is too large. Maximum size is 10 MB.`);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
let nodeKey = null;
|
|
250
|
+
editor.update(() => {
|
|
251
|
+
const placeholderNode = $createImageNode(`${PLACEHOLDER_PREFIX}${generatePlaceholderId()}`, "Uploading image…");
|
|
252
|
+
$insertNodes([placeholderNode]);
|
|
253
|
+
nodeKey = placeholderNode.getKey();
|
|
254
|
+
});
|
|
255
|
+
if (!nodeKey) return;
|
|
256
|
+
const capturedKey = nodeKey;
|
|
257
|
+
upload(file).then(({ url }) => {
|
|
258
|
+
editor.update(() => {
|
|
259
|
+
const node = $getNodeByKey(capturedKey);
|
|
260
|
+
if ($isImageNode(node)) {
|
|
261
|
+
const altText = escapeMarkdownAlt(file.name.replace(/\.[^.]+$/, "") || "image");
|
|
262
|
+
node.setSrc(url);
|
|
263
|
+
node.setAlt(altText);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}).catch((error) => {
|
|
267
|
+
console.error("[MarkdownEditor] image upload failed", error);
|
|
268
|
+
toast.error(`Failed to upload "${file.name}". Please try again.`);
|
|
269
|
+
editor.update(() => {
|
|
270
|
+
const node = $getNodeByKey(capturedKey);
|
|
271
|
+
if (node) node.remove();
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
const removePaste = editor.registerCommand(PASTE_COMMAND, (event) => {
|
|
276
|
+
if (!onImageUploadRef.current) return false;
|
|
277
|
+
if (!(event instanceof ClipboardEvent)) return false;
|
|
278
|
+
const files = getImageFilesFromDataTransfer(event.clipboardData);
|
|
279
|
+
if (files.length === 0) return false;
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
Promise.resolve().then(() => files.forEach(uploadFile));
|
|
282
|
+
return true;
|
|
283
|
+
}, COMMAND_PRIORITY_CRITICAL);
|
|
284
|
+
const removeDrop = editor.registerCommand(DROP_COMMAND, (event) => {
|
|
285
|
+
if (!onImageUploadRef.current) return false;
|
|
286
|
+
const files = getImageFilesFromDataTransfer(event.dataTransfer);
|
|
287
|
+
if (files.length === 0) return false;
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
Promise.resolve().then(() => files.forEach(uploadFile));
|
|
290
|
+
return true;
|
|
291
|
+
}, COMMAND_PRIORITY_CRITICAL);
|
|
292
|
+
return () => {
|
|
293
|
+
removePaste();
|
|
294
|
+
removeDrop();
|
|
295
|
+
};
|
|
296
|
+
}, [editor]);
|
|
297
|
+
return null;
|
|
375
298
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/blocks/MarkdownEditor/plugins/KeyboardPlugin.tsx
|
|
301
|
+
const KeyboardPlugin = ({ onSave, onCancel, singleLine, blurOnEscape, skipBlurSaveRef }) => {
|
|
302
|
+
const [editor] = useLexicalComposerContext();
|
|
303
|
+
const onSaveRef = useRef(onSave);
|
|
304
|
+
onSaveRef.current = onSave;
|
|
305
|
+
const onCancelRef = useRef(onCancel);
|
|
306
|
+
onCancelRef.current = onCancel;
|
|
307
|
+
const singleLineRef = useRef(singleLine);
|
|
308
|
+
singleLineRef.current = singleLine;
|
|
309
|
+
const blurOnEscapeRef = useRef(blurOnEscape);
|
|
310
|
+
blurOnEscapeRef.current = blurOnEscape;
|
|
311
|
+
const skipBlurSaveExternalRef = skipBlurSaveRef;
|
|
312
|
+
useEffect(() => {
|
|
313
|
+
return editor.registerCommand(KEY_DOWN_COMMAND, (event) => {
|
|
314
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
315
|
+
event.preventDefault();
|
|
316
|
+
onSaveRef.current?.();
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
if (event.key === "Enter" && !event.shiftKey && !event.altKey && singleLineRef.current) {
|
|
320
|
+
event.preventDefault();
|
|
321
|
+
editor.getRootElement()?.blur();
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
if (event.key === "Escape" && blurOnEscapeRef.current) {
|
|
325
|
+
if (skipBlurSaveExternalRef) skipBlurSaveExternalRef.current = true;
|
|
326
|
+
onCancelRef.current?.();
|
|
327
|
+
editor.getRootElement()?.blur();
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
}, COMMAND_PRIORITY_HIGH);
|
|
332
|
+
}, [editor, skipBlurSaveExternalRef]);
|
|
333
|
+
return null;
|
|
387
334
|
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Custom transformers = our additions + built-in Lexical transformers.
|
|
337
|
+
* MERMAID is placed before TRANSFORMERS so it intercepts ` ```mermaid ``` ` before the generic CODE transformer.
|
|
338
|
+
* IMAGE is placed before built-in LINK to prevent `` from being parsed as `!` + link.
|
|
339
|
+
*/
|
|
340
|
+
const CUSTOM_TRANSFORMERS = [
|
|
341
|
+
{
|
|
342
|
+
dependencies: [ImageNode],
|
|
343
|
+
export: (node) => {
|
|
344
|
+
if (!$isImageNode(node)) return null;
|
|
345
|
+
return `})`;
|
|
346
|
+
},
|
|
347
|
+
importRegExp: /!\[([^\]]*)\]\(([^)]+)\)/,
|
|
348
|
+
regExp: /!\[([^\]]*)\]\(([^)]+)\)$/,
|
|
349
|
+
replace: (textNode, match) => {
|
|
350
|
+
const [, alt = "", src = ""] = match;
|
|
351
|
+
const imageNode = $createImageNode(src, alt);
|
|
352
|
+
textNode.replace(imageNode);
|
|
353
|
+
},
|
|
354
|
+
trigger: ")",
|
|
355
|
+
type: "text-match"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
dependencies: [HorizontalRuleNode],
|
|
359
|
+
export: (node) => {
|
|
360
|
+
return $isHorizontalRuleNode(node) ? "---" : null;
|
|
361
|
+
},
|
|
362
|
+
regExp: /^(---|\*\*\*|___)$/,
|
|
363
|
+
replace: (parentNode) => {
|
|
364
|
+
const node = $createHorizontalRuleNode();
|
|
365
|
+
parentNode.replace(node);
|
|
366
|
+
},
|
|
367
|
+
type: "element"
|
|
368
|
+
},
|
|
369
|
+
CHECK_LIST,
|
|
370
|
+
{
|
|
371
|
+
dependencies: [MermaidNode],
|
|
372
|
+
export: (node) => {
|
|
373
|
+
if (!$isMermaidNode(node)) return null;
|
|
374
|
+
return "```mermaid\n" + node.getCode() + "\n```";
|
|
375
|
+
},
|
|
376
|
+
regExpStart: /^[ \t]*(`{3,})mermaid(?:\s.*)?$/,
|
|
377
|
+
regExpEnd: {
|
|
378
|
+
optional: true,
|
|
379
|
+
regExp: /^[ \t]*`{3,}$/
|
|
380
|
+
},
|
|
381
|
+
replace: (rootNode, _children, _startMatch, _endMatch, linesInBetween) => {
|
|
382
|
+
if (!linesInBetween) return;
|
|
383
|
+
const code = linesInBetween.join("\n").trim();
|
|
384
|
+
if (code) rootNode.append($createMermaidNode(code));
|
|
385
|
+
},
|
|
386
|
+
handleImportAfterStartMatch: ({ lines, rootNode, startLineIndex, startMatch }) => {
|
|
387
|
+
const fence = startMatch[1];
|
|
388
|
+
if (!fence) return [false, startLineIndex];
|
|
389
|
+
const fenceLength = fence.trim().length;
|
|
390
|
+
const endRegex = new RegExp(`^[ \\t]*\`{${fenceLength},}$`);
|
|
391
|
+
for (let i = startLineIndex + 1; i < lines.length; i++) if (endRegex.test(lines[i] ?? "")) {
|
|
392
|
+
const code = lines.slice(startLineIndex + 1, i).join("\n").trim();
|
|
393
|
+
if (code) rootNode.append($createMermaidNode(code));
|
|
394
|
+
return [true, i];
|
|
395
|
+
}
|
|
396
|
+
const code = lines.slice(startLineIndex + 1).join("\n").trim();
|
|
397
|
+
if (code) rootNode.append($createMermaidNode(code));
|
|
398
|
+
return [true, lines.length - 1];
|
|
399
|
+
},
|
|
400
|
+
type: "multiline-element"
|
|
401
|
+
},
|
|
402
|
+
...TRANSFORMERS
|
|
439
403
|
];
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
404
|
+
/**
|
|
405
|
+
* No transformers = plain text. `singleLine` mode edits entity names / titles, which are
|
|
406
|
+
* plain text, not markdown. Parsing inline formatting here corrupts ordinary names: e.g.
|
|
407
|
+
* `staging_chargebee_invoices` would render the `_chargebee_` span as italics, and Lexical
|
|
408
|
+
* escapes the underscores on export (`\_`) to prevent exactly that — but those backslashes
|
|
409
|
+
* then leak into the persisted name. Dropping every transformer keeps `_`, `*`, `` ` ``, `~`
|
|
410
|
+
* literal on both import and export; pair the empty set with `unescapeMarkdownText` on export
|
|
411
|
+
* to strip Lexical's escaping (see MarkdownSyncPlugin).
|
|
412
|
+
*/
|
|
413
|
+
const SINGLE_LINE_TRANSFORMERS = [];
|
|
414
|
+
const TABLE_FENCE_LANG = "__kbc_table__";
|
|
415
|
+
const isTableLine = (line) => {
|
|
416
|
+
const trimmed = line.trim();
|
|
417
|
+
return trimmed.startsWith("|") && trimmed.endsWith("|");
|
|
445
418
|
};
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (tableLines.length > 0) flushTable();
|
|
481
|
-
return result.join("\n");
|
|
419
|
+
const CODE_FENCE_REGEX = /^[ \t]*`{3,}/;
|
|
420
|
+
/** Wrap GFM tables in code fences so they survive Lexical's markdown round-trip. */
|
|
421
|
+
const preprocessMarkdown = (markdown) => {
|
|
422
|
+
const lines = markdown.split("\n");
|
|
423
|
+
const result = [];
|
|
424
|
+
let tableLines = [];
|
|
425
|
+
let insideCodeFence = false;
|
|
426
|
+
const flushTable = () => {
|
|
427
|
+
if (tableLines.length >= 2) {
|
|
428
|
+
result.push(`\`\`\`${TABLE_FENCE_LANG}`);
|
|
429
|
+
result.push(...tableLines);
|
|
430
|
+
result.push("```");
|
|
431
|
+
} else result.push(...tableLines);
|
|
432
|
+
tableLines = [];
|
|
433
|
+
};
|
|
434
|
+
for (const line of lines) {
|
|
435
|
+
if (CODE_FENCE_REGEX.test(line)) {
|
|
436
|
+
if (tableLines.length > 0) flushTable();
|
|
437
|
+
insideCodeFence = !insideCodeFence;
|
|
438
|
+
result.push(line);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (insideCodeFence) {
|
|
442
|
+
result.push(line);
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (isTableLine(line)) tableLines.push(line);
|
|
446
|
+
else {
|
|
447
|
+
if (tableLines.length > 0) flushTable();
|
|
448
|
+
result.push(line);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (tableLines.length > 0) flushTable();
|
|
452
|
+
return result.join("\n");
|
|
482
453
|
};
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
454
|
+
/** Unwrap code-fenced tables back to raw GFM table markdown. */
|
|
455
|
+
const postprocessMarkdown = (markdown) => {
|
|
456
|
+
const regex = new RegExp(`\`\`\`${TABLE_FENCE_LANG}\\n([\\s\\S]*?)\\n\`\`\``, "g");
|
|
457
|
+
return markdown.replace(regex, "$1");
|
|
486
458
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
}, [editor]);
|
|
532
|
-
return null;
|
|
459
|
+
/**
|
|
460
|
+
* Reverses the backslash-escaping Lexical applies to markdown punctuation (`* _ ` ~ \`) when
|
|
461
|
+
* exporting text nodes. Used for `singleLine` (plain-text) mode, where the export value is a
|
|
462
|
+
* bare entity name — the escaping would otherwise persist as literal backslashes in the name.
|
|
463
|
+
*/
|
|
464
|
+
const unescapeMarkdownText = (markdown) => markdown.replace(/\\([*_`~\\])/g, "$1");
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/blocks/MarkdownEditor/plugins/MarkdownSyncPlugin.tsx
|
|
467
|
+
const IMPORT_TAG = "markdown-import";
|
|
468
|
+
const MarkdownSyncPlugin = ({ value, editable, onChange, transformers = CUSTOM_TRANSFORMERS, singleLine = false }) => {
|
|
469
|
+
const [editor] = useLexicalComposerContext();
|
|
470
|
+
const lastExportedRef = useRef(value);
|
|
471
|
+
const onChangeRef = useRef(onChange);
|
|
472
|
+
onChangeRef.current = onChange;
|
|
473
|
+
const transformersRef = useRef(transformers);
|
|
474
|
+
transformersRef.current = transformers;
|
|
475
|
+
const singleLineRef = useRef(singleLine);
|
|
476
|
+
singleLineRef.current = singleLine;
|
|
477
|
+
useEffect(() => {
|
|
478
|
+
editor.setEditable(editable);
|
|
479
|
+
}, [editor, editable]);
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
if (value === lastExportedRef.current) return;
|
|
482
|
+
lastExportedRef.current = value;
|
|
483
|
+
editor.update(() => {
|
|
484
|
+
$convertFromMarkdownString(preprocessMarkdown(value), transformersRef.current);
|
|
485
|
+
}, { tag: IMPORT_TAG });
|
|
486
|
+
}, [editor, value]);
|
|
487
|
+
useEffect(() => {
|
|
488
|
+
return editor.registerUpdateListener(({ tags }) => {
|
|
489
|
+
if (tags.has(IMPORT_TAG)) return;
|
|
490
|
+
editor.getEditorState().read(() => {
|
|
491
|
+
const raw = $convertToMarkdownString(transformersRef.current);
|
|
492
|
+
const markdown = singleLineRef.current ? unescapeMarkdownText(raw) : postprocessMarkdown(raw);
|
|
493
|
+
if (markdown !== lastExportedRef.current) {
|
|
494
|
+
lastExportedRef.current = markdown;
|
|
495
|
+
onChangeRef.current?.(markdown);
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
}, [editor]);
|
|
500
|
+
return null;
|
|
533
501
|
};
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/blocks/MarkdownEditor/plugins/toolbar/AlignmentDropdown.tsx
|
|
504
|
+
const ALIGNMENT_OPTIONS = [
|
|
505
|
+
{
|
|
506
|
+
value: "left",
|
|
507
|
+
label: "Left",
|
|
508
|
+
icon: AlignLeft
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
value: "center",
|
|
512
|
+
label: "Center",
|
|
513
|
+
icon: AlignCenter
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
value: "right",
|
|
517
|
+
label: "Right",
|
|
518
|
+
icon: AlignRight
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
value: "justify",
|
|
522
|
+
label: "Justify",
|
|
523
|
+
icon: AlignJustify
|
|
524
|
+
}
|
|
539
525
|
];
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
/* @__PURE__ */ jsx(DropdownMenu.Content, { align: "start", className: "tw:min-w-32", children: ALIGNMENT_OPTIONS.map(({ value, label, icon: IconComp }) => /* @__PURE__ */ jsxs(
|
|
581
|
-
DropdownMenu.Item,
|
|
582
|
-
{
|
|
583
|
-
onSelect: () => handleSelect(value),
|
|
584
|
-
className: cn(
|
|
585
|
-
"tw:flex tw:items-center tw:gap-2",
|
|
586
|
-
alignment === value && "tw:bg-secondary-50 tw:text-secondary-500"
|
|
587
|
-
),
|
|
588
|
-
children: [
|
|
589
|
-
/* @__PURE__ */ jsx(IconComp, { className: "tw:size-4" }),
|
|
590
|
-
label
|
|
591
|
-
]
|
|
592
|
-
},
|
|
593
|
-
value
|
|
594
|
-
)) })
|
|
595
|
-
] });
|
|
526
|
+
const ALIGNMENT_ICONS = Object.fromEntries(ALIGNMENT_OPTIONS.map(({ value, icon }) => [value, icon]));
|
|
527
|
+
const AlignmentDropdown = ({ editor, alignment }) => {
|
|
528
|
+
const savedSelectionRef = useRef(null);
|
|
529
|
+
const handleOpenChange = (open) => {
|
|
530
|
+
if (open) editor.getEditorState().read(() => {
|
|
531
|
+
const selection = $getSelection();
|
|
532
|
+
savedSelectionRef.current = selection ? selection.clone() : null;
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
const handleSelect = (align) => {
|
|
536
|
+
editor.update(() => {
|
|
537
|
+
if (savedSelectionRef.current) $setSelection(savedSelectionRef.current);
|
|
538
|
+
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, align);
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
const CurrentAlignmentIcon = ALIGNMENT_ICONS[alignment] ?? AlignLeft;
|
|
542
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
543
|
+
onOpenChange: handleOpenChange,
|
|
544
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
545
|
+
tooltip: "Text alignment",
|
|
546
|
+
placement: "top",
|
|
547
|
+
triggerAsChild: true,
|
|
548
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Trigger, {
|
|
549
|
+
asChild: true,
|
|
550
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
551
|
+
type: "button",
|
|
552
|
+
className: cn("tw:flex tw:h-7 tw:cursor-pointer tw:items-center tw:gap-1 tw:rounded tw:border-0 tw:bg-transparent tw:px-1.5 tw:text-xs tw:text-muted-foreground", "tw:hover:bg-accent"),
|
|
553
|
+
children: [/* @__PURE__ */ jsx(CurrentAlignmentIcon, { className: "tw:size-4" }), /* @__PURE__ */ jsx(ChevronDown, { className: "tw:size-3" })]
|
|
554
|
+
})
|
|
555
|
+
})
|
|
556
|
+
}), /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
557
|
+
align: "start",
|
|
558
|
+
className: "tw:min-w-32",
|
|
559
|
+
children: ALIGNMENT_OPTIONS.map(({ value, label, icon: IconComp }) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
|
|
560
|
+
onSelect: () => handleSelect(value),
|
|
561
|
+
className: cn("tw:flex tw:items-center tw:gap-2", alignment === value && "tw:bg-secondary-50 tw:text-secondary-500"),
|
|
562
|
+
children: [/* @__PURE__ */ jsx(IconComp, { className: "tw:size-4" }), label]
|
|
563
|
+
}, value))
|
|
564
|
+
})]
|
|
565
|
+
});
|
|
596
566
|
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/blocks/MarkdownEditor/plugins/toolbar/BlockTypeDropdown.tsx
|
|
569
|
+
const BLOCK_TYPE_META = {
|
|
570
|
+
paragraph: {
|
|
571
|
+
label: "Normal",
|
|
572
|
+
icon: Type,
|
|
573
|
+
selectable: true
|
|
574
|
+
},
|
|
575
|
+
h1: {
|
|
576
|
+
label: "Heading 1",
|
|
577
|
+
icon: Heading1,
|
|
578
|
+
selectable: true
|
|
579
|
+
},
|
|
580
|
+
h2: {
|
|
581
|
+
label: "Heading 2",
|
|
582
|
+
icon: Heading2,
|
|
583
|
+
selectable: true
|
|
584
|
+
},
|
|
585
|
+
h3: {
|
|
586
|
+
label: "Heading 3",
|
|
587
|
+
icon: Heading3,
|
|
588
|
+
selectable: true
|
|
589
|
+
},
|
|
590
|
+
bullet: {
|
|
591
|
+
label: "Bullet List",
|
|
592
|
+
icon: List,
|
|
593
|
+
selectable: false
|
|
594
|
+
},
|
|
595
|
+
number: {
|
|
596
|
+
label: "Numbered List",
|
|
597
|
+
icon: ListOrdered,
|
|
598
|
+
selectable: false
|
|
599
|
+
},
|
|
600
|
+
quote: {
|
|
601
|
+
label: "Quote",
|
|
602
|
+
icon: Quote,
|
|
603
|
+
selectable: false
|
|
604
|
+
},
|
|
605
|
+
code: {
|
|
606
|
+
label: "Code Block",
|
|
607
|
+
icon: SquareCode,
|
|
608
|
+
selectable: false
|
|
609
|
+
}
|
|
606
610
|
};
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
/* @__PURE__ */ jsx(IconComp, { className: "tw:size-4" }),
|
|
672
|
-
label
|
|
673
|
-
]
|
|
674
|
-
},
|
|
675
|
-
value
|
|
676
|
-
)) })
|
|
677
|
-
] });
|
|
611
|
+
const BLOCK_TYPE_OPTIONS = Object.entries(BLOCK_TYPE_META).filter(([, meta]) => meta.selectable).map(([value, { label, icon }]) => ({
|
|
612
|
+
value,
|
|
613
|
+
label,
|
|
614
|
+
icon
|
|
615
|
+
}));
|
|
616
|
+
const isBlockType = (value) => Object.prototype.hasOwnProperty.call(BLOCK_TYPE_META, value);
|
|
617
|
+
const BlockTypeDropdown = ({ editor, blockType }) => {
|
|
618
|
+
const savedSelectionRef = useRef(null);
|
|
619
|
+
const currentMeta = isBlockType(blockType) ? BLOCK_TYPE_META[blockType] : null;
|
|
620
|
+
const CurrentBlockIcon = currentMeta?.icon ?? Type;
|
|
621
|
+
const handleOpenChange = (open) => {
|
|
622
|
+
if (open) editor.getEditorState().read(() => {
|
|
623
|
+
const selection = $getSelection();
|
|
624
|
+
savedSelectionRef.current = selection ? selection.clone() : null;
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
const handleSelect = (type) => {
|
|
628
|
+
editor.update(() => {
|
|
629
|
+
if (savedSelectionRef.current) $setSelection(savedSelectionRef.current);
|
|
630
|
+
const selection = $getSelection();
|
|
631
|
+
if (!$isRangeSelection(selection)) return;
|
|
632
|
+
if (type === "bullet") {
|
|
633
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (type === "number") {
|
|
637
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const anchorNode = selection.anchor.getNode();
|
|
641
|
+
const element = $getNearestBlockElementAncestorOrThrow(anchorNode);
|
|
642
|
+
const newNode = type === "h1" || type === "h2" || type === "h3" ? $createHeadingNode(type) : type === "quote" ? $createQuoteNode() : type === "code" ? $createCodeNode() : $createParagraphNode();
|
|
643
|
+
element.getChildren().forEach((child) => newNode.append(child));
|
|
644
|
+
element.replace(newNode);
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
648
|
+
onOpenChange: handleOpenChange,
|
|
649
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
650
|
+
tooltip: "Change block type",
|
|
651
|
+
placement: "top",
|
|
652
|
+
triggerAsChild: true,
|
|
653
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Trigger, {
|
|
654
|
+
asChild: true,
|
|
655
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
656
|
+
type: "button",
|
|
657
|
+
className: cn("tw:flex tw:h-7 tw:cursor-pointer tw:items-center tw:gap-1.5 tw:rounded tw:border-0 tw:bg-transparent tw:px-1.5 tw:text-xs tw:text-muted-foreground", "tw:hover:bg-accent"),
|
|
658
|
+
children: [
|
|
659
|
+
/* @__PURE__ */ jsx(CurrentBlockIcon, { className: "tw:size-4" }),
|
|
660
|
+
currentMeta?.label ?? "Normal",
|
|
661
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "tw:size-3" })
|
|
662
|
+
]
|
|
663
|
+
})
|
|
664
|
+
})
|
|
665
|
+
}), /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
666
|
+
align: "start",
|
|
667
|
+
className: "tw:min-w-40",
|
|
668
|
+
children: BLOCK_TYPE_OPTIONS.map(({ value, label, icon: IconComp }) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
|
|
669
|
+
onSelect: () => handleSelect(value),
|
|
670
|
+
className: cn("tw:flex tw:items-center tw:gap-2", blockType === value && "tw:bg-secondary-50 tw:text-secondary-500"),
|
|
671
|
+
children: [/* @__PURE__ */ jsx(IconComp, { className: "tw:size-4" }), label]
|
|
672
|
+
}, value))
|
|
673
|
+
})]
|
|
674
|
+
});
|
|
678
675
|
};
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
const linkNode = $createLinkNode(url);
|
|
713
|
-
const textNode = $createTextNode(label || url);
|
|
714
|
-
linkNode.append(textNode);
|
|
715
|
-
if ($isRangeSelection(selection)) {
|
|
716
|
-
selection.insertNodes([linkNode]);
|
|
717
|
-
}
|
|
718
|
-
});
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/blocks/MarkdownEditor/plugins/toolbar/ToolbarButton.tsx
|
|
678
|
+
const ToolbarButton = ({ active, disabled, onClick, tooltip, children, className: extraClassName }) => /* @__PURE__ */ jsx(Tooltip, {
|
|
679
|
+
tooltip,
|
|
680
|
+
placement: "top",
|
|
681
|
+
triggerAsChild: true,
|
|
682
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
683
|
+
type: "button",
|
|
684
|
+
disabled,
|
|
685
|
+
onClick,
|
|
686
|
+
className: cn("tw:flex tw:h-7 tw:min-w-7 tw:cursor-pointer tw:items-center tw:justify-center tw:rounded tw:border-0 tw:bg-transparent tw:px-1 tw:text-xs tw:text-muted-foreground", "tw:hover:bg-accent tw:disabled:cursor-not-allowed tw:disabled:opacity-30", active && "tw:bg-secondary-100 tw:text-secondary-500", extraClassName),
|
|
687
|
+
children
|
|
688
|
+
})
|
|
689
|
+
});
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/blocks/MarkdownEditor/plugins/toolbar/LinkPanel.tsx
|
|
692
|
+
const insertLink = (editor, url, label, savedSelection) => {
|
|
693
|
+
editor.update(() => {
|
|
694
|
+
$setSelection(savedSelection);
|
|
695
|
+
const selection = $getSelection();
|
|
696
|
+
if ($isRangeSelection(selection)) {
|
|
697
|
+
const selectedText = selection.getTextContent();
|
|
698
|
+
if (selectedText && label === selectedText) {
|
|
699
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const linkNode = $createLinkNode(url);
|
|
704
|
+
const textNode = $createTextNode(label || url);
|
|
705
|
+
linkNode.append(textNode);
|
|
706
|
+
if ($isRangeSelection(selection)) selection.insertNodes([linkNode]);
|
|
707
|
+
});
|
|
719
708
|
};
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
709
|
+
const LinkPanel = ({ editor, isLink }) => {
|
|
710
|
+
const [open, setOpen] = useState(false);
|
|
711
|
+
const [url, setUrl] = useState("");
|
|
712
|
+
const [label, setLabel] = useState("");
|
|
713
|
+
const savedSelectionRef = useRef(null);
|
|
714
|
+
const panelRef = useRef(null);
|
|
715
|
+
const handleOpen = () => {
|
|
716
|
+
editor.getEditorState().read(() => {
|
|
717
|
+
const selection = $getSelection();
|
|
718
|
+
savedSelectionRef.current = selection ? selection.clone() : null;
|
|
719
|
+
if ($isRangeSelection(selection)) {
|
|
720
|
+
const text = selection.getTextContent();
|
|
721
|
+
if (text) setLabel(text);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
setOpen(true);
|
|
725
|
+
};
|
|
726
|
+
const handleClose = () => {
|
|
727
|
+
setOpen(false);
|
|
728
|
+
setUrl("");
|
|
729
|
+
setLabel("");
|
|
730
|
+
savedSelectionRef.current = null;
|
|
731
|
+
editor.focus();
|
|
732
|
+
};
|
|
733
|
+
const handleSubmit = () => {
|
|
734
|
+
const trimmedUrl = url.trim();
|
|
735
|
+
if (!trimmedUrl) return;
|
|
736
|
+
insertLink(editor, trimmedUrl, label.trim(), savedSelectionRef.current);
|
|
737
|
+
handleClose();
|
|
738
|
+
};
|
|
739
|
+
const handleKeyDown = (e) => {
|
|
740
|
+
if (e.key === "Enter") {
|
|
741
|
+
e.preventDefault();
|
|
742
|
+
handleSubmit();
|
|
743
|
+
}
|
|
744
|
+
if (e.key === "Escape") {
|
|
745
|
+
e.preventDefault();
|
|
746
|
+
handleClose();
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
if (isLink) return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
750
|
+
active: true,
|
|
751
|
+
onClick: () => editor.dispatchCommand(TOGGLE_LINK_COMMAND, null),
|
|
752
|
+
tooltip: "Remove Link",
|
|
753
|
+
children: /* @__PURE__ */ jsx(Link, { className: "tw:size-4" })
|
|
754
|
+
});
|
|
755
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
756
|
+
className: "tw:relative",
|
|
757
|
+
children: [/* @__PURE__ */ jsx(ToolbarButton, {
|
|
758
|
+
active: open,
|
|
759
|
+
onClick: handleOpen,
|
|
760
|
+
tooltip: "Insert Link",
|
|
761
|
+
children: /* @__PURE__ */ jsx(Link, { className: "tw:size-4" })
|
|
762
|
+
}), open && /* @__PURE__ */ jsx("div", {
|
|
763
|
+
ref: panelRef,
|
|
764
|
+
className: "tw:absolute tw:left-0 tw:top-full tw:z-50 tw:mt-1 tw:w-80 tw:rounded-md tw:border tw:border-border tw:bg-popover tw:p-3 tw:text-popover-foreground tw:shadow-lg",
|
|
765
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
766
|
+
className: "tw:flex tw:flex-col tw:gap-2",
|
|
767
|
+
children: [
|
|
768
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [/* @__PURE__ */ jsx(Label, {
|
|
769
|
+
htmlFor: "link-label",
|
|
770
|
+
className: "tw:mb-1 tw:text-xs",
|
|
771
|
+
children: "Label"
|
|
772
|
+
}), /* @__PURE__ */ jsx(TextInput, {
|
|
773
|
+
id: "link-label",
|
|
774
|
+
autoFocus: true,
|
|
775
|
+
placeholder: "Link text",
|
|
776
|
+
value: label,
|
|
777
|
+
onValueChange: setLabel,
|
|
778
|
+
onKeyDown: handleKeyDown,
|
|
779
|
+
variant: "secondary"
|
|
780
|
+
})] }),
|
|
781
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [/* @__PURE__ */ jsx(Label, {
|
|
782
|
+
htmlFor: "link-url",
|
|
783
|
+
className: "tw:mb-1 tw:text-xs",
|
|
784
|
+
children: "URL"
|
|
785
|
+
}), /* @__PURE__ */ jsx(TextInput, {
|
|
786
|
+
id: "link-url",
|
|
787
|
+
placeholder: "https://…",
|
|
788
|
+
value: url,
|
|
789
|
+
onValueChange: setUrl,
|
|
790
|
+
onKeyDown: handleKeyDown,
|
|
791
|
+
variant: "secondary"
|
|
792
|
+
})] }),
|
|
793
|
+
/* @__PURE__ */ jsxs(ButtonGroup, { children: [/* @__PURE__ */ jsx(Button, {
|
|
794
|
+
size: "small",
|
|
795
|
+
variant: "outline",
|
|
796
|
+
onClick: handleClose,
|
|
797
|
+
children: "Cancel"
|
|
798
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
799
|
+
size: "small",
|
|
800
|
+
onClick: handleSubmit,
|
|
801
|
+
disabled: !url.trim(),
|
|
802
|
+
children: "Add link"
|
|
803
|
+
})] })
|
|
804
|
+
]
|
|
805
|
+
})
|
|
806
|
+
})]
|
|
807
|
+
});
|
|
816
808
|
};
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
tooltip: "Quote",
|
|
1027
|
-
children: /* @__PURE__ */ jsx(Quote, { className: "tw:size-4" })
|
|
1028
|
-
}
|
|
1029
|
-
),
|
|
1030
|
-
/* @__PURE__ */ jsx(
|
|
1031
|
-
ToolbarButton,
|
|
1032
|
-
{
|
|
1033
|
-
active: blockType === "code",
|
|
1034
|
-
onClick: () => {
|
|
1035
|
-
editor.update(() => {
|
|
1036
|
-
const selection = $getSelection();
|
|
1037
|
-
if (!$isRangeSelection(selection)) return;
|
|
1038
|
-
const anchorNode = selection.anchor.getNode();
|
|
1039
|
-
const element = $getNearestBlockElementAncestorOrThrow(anchorNode);
|
|
1040
|
-
const newNode = blockType === "code" ? $createParagraphNode() : $createCodeNode();
|
|
1041
|
-
element.getChildren().forEach((child) => newNode.append(child));
|
|
1042
|
-
element.replace(newNode);
|
|
1043
|
-
});
|
|
1044
|
-
},
|
|
1045
|
-
tooltip: "Code Block",
|
|
1046
|
-
children: /* @__PURE__ */ jsx(SquareCode, { className: "tw:size-4" })
|
|
1047
|
-
}
|
|
1048
|
-
)
|
|
1049
|
-
]
|
|
1050
|
-
}
|
|
1051
|
-
),
|
|
1052
|
-
document.body
|
|
1053
|
-
);
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region src/blocks/MarkdownEditor/plugins/toolbar/ToolbarDivider.tsx
|
|
811
|
+
const ToolbarDivider = () => /* @__PURE__ */ jsx("div", { className: "tw:mx-0.5 tw:h-5 tw:w-px tw:bg-border" });
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region src/blocks/MarkdownEditor/plugins/ToolbarPlugin.tsx
|
|
814
|
+
const ELEMENT_FORMAT_TYPES = [
|
|
815
|
+
"left",
|
|
816
|
+
"center",
|
|
817
|
+
"right",
|
|
818
|
+
"justify",
|
|
819
|
+
"start",
|
|
820
|
+
"end",
|
|
821
|
+
""
|
|
822
|
+
];
|
|
823
|
+
const isElementFormatType = (value) => ELEMENT_FORMAT_TYPES.includes(value);
|
|
824
|
+
const toElementFormatType = (value) => isElementFormatType(value) ? value : "left";
|
|
825
|
+
const ToolbarPlugin = () => {
|
|
826
|
+
const [editor] = useLexicalComposerContext();
|
|
827
|
+
const [isBold, setIsBold] = useState(false);
|
|
828
|
+
const [isItalic, setIsItalic] = useState(false);
|
|
829
|
+
const [isUnderline, setIsUnderline] = useState(false);
|
|
830
|
+
const [isStrikethrough, setIsStrikethrough] = useState(false);
|
|
831
|
+
const [isCode, setIsCode] = useState(false);
|
|
832
|
+
const [isLink, setIsLink] = useState(false);
|
|
833
|
+
const [blockType, setBlockType] = useState("paragraph");
|
|
834
|
+
const [alignment, setAlignment] = useState("left");
|
|
835
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
836
|
+
const [position, setPosition] = useState(null);
|
|
837
|
+
const toolbarRef = useRef(null);
|
|
838
|
+
const isMouseDownRef = useRef(false);
|
|
839
|
+
const hasSelectionRef = useRef(false);
|
|
840
|
+
const updatePosition = useCallback(() => {
|
|
841
|
+
const nativeSelection = window.getSelection();
|
|
842
|
+
if (!nativeSelection || nativeSelection.rangeCount === 0) return;
|
|
843
|
+
const rect = nativeSelection.getRangeAt(0).getBoundingClientRect();
|
|
844
|
+
if (rect.width > 0) {
|
|
845
|
+
const toolbarWidth = toolbarRef.current?.offsetWidth ?? 300;
|
|
846
|
+
setPosition({
|
|
847
|
+
top: rect.top + window.scrollY - 8,
|
|
848
|
+
left: Math.max(8, rect.left + window.scrollX + rect.width / 2 - toolbarWidth / 2)
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
}, []);
|
|
852
|
+
useEffect(() => {
|
|
853
|
+
const handleMouseDown = () => {
|
|
854
|
+
isMouseDownRef.current = true;
|
|
855
|
+
};
|
|
856
|
+
const handleMouseUp = () => {
|
|
857
|
+
isMouseDownRef.current = false;
|
|
858
|
+
if (hasSelectionRef.current) setIsVisible(true);
|
|
859
|
+
};
|
|
860
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
861
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
862
|
+
return () => {
|
|
863
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
|
864
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
865
|
+
};
|
|
866
|
+
}, []);
|
|
867
|
+
const updateToolbar = useCallback(() => {
|
|
868
|
+
const selection = $getSelection();
|
|
869
|
+
if (!$isRangeSelection(selection)) {
|
|
870
|
+
hasSelectionRef.current = false;
|
|
871
|
+
setIsVisible(false);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
const hasSelection = !selection.isCollapsed() && selection.getTextContent().length > 0;
|
|
875
|
+
hasSelectionRef.current = hasSelection;
|
|
876
|
+
if (!hasSelection) setIsVisible(false);
|
|
877
|
+
else if (!isMouseDownRef.current) setIsVisible(true);
|
|
878
|
+
if (hasSelection) updatePosition();
|
|
879
|
+
setIsBold(selection.hasFormat("bold"));
|
|
880
|
+
setIsItalic(selection.hasFormat("italic"));
|
|
881
|
+
setIsUnderline(selection.hasFormat("underline"));
|
|
882
|
+
setIsStrikethrough(selection.hasFormat("strikethrough"));
|
|
883
|
+
setIsCode(selection.hasFormat("code"));
|
|
884
|
+
const node = selection.anchor.getNode();
|
|
885
|
+
const parent = node.getParent();
|
|
886
|
+
setIsLink($isLinkNode(parent) || $isLinkNode(node));
|
|
887
|
+
const blockElement = $getNearestBlockElementAncestorOrThrow(node);
|
|
888
|
+
if ($isListNode(blockElement)) {
|
|
889
|
+
const listType = blockElement.getListType();
|
|
890
|
+
setBlockType(listType === "number" ? "number" : "bullet");
|
|
891
|
+
} else if ($isHeadingNode(blockElement)) setBlockType(blockElement.getTag());
|
|
892
|
+
else if ($isCodeNode(blockElement)) setBlockType("code");
|
|
893
|
+
else if ($isQuoteNode(blockElement)) setBlockType("quote");
|
|
894
|
+
else setBlockType("paragraph");
|
|
895
|
+
setAlignment(toElementFormatType(blockElement.getFormatType()));
|
|
896
|
+
}, [updatePosition]);
|
|
897
|
+
useEffect(() => {
|
|
898
|
+
const unregisterUpdate = editor.registerUpdateListener(({ editorState }) => {
|
|
899
|
+
editorState.read(() => {
|
|
900
|
+
updateToolbar();
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
return () => {
|
|
904
|
+
unregisterUpdate();
|
|
905
|
+
};
|
|
906
|
+
}, [editor, updateToolbar]);
|
|
907
|
+
if (!isVisible || !position) return null;
|
|
908
|
+
return createPortal(/* @__PURE__ */ jsxs("div", {
|
|
909
|
+
ref: toolbarRef,
|
|
910
|
+
role: "toolbar",
|
|
911
|
+
"aria-label": "Formatting options",
|
|
912
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
913
|
+
style: {
|
|
914
|
+
top: position.top,
|
|
915
|
+
left: position.left
|
|
916
|
+
},
|
|
917
|
+
className: "tw:absolute tw:z-[1060] tw:flex tw:-translate-y-full tw:items-center tw:gap-0.5 tw:rounded-lg tw:border tw:border-border tw:bg-popover tw:px-1.5 tw:py-1 tw:text-popover-foreground tw:shadow-lg",
|
|
918
|
+
children: [
|
|
919
|
+
/* @__PURE__ */ jsx(BlockTypeDropdown, {
|
|
920
|
+
editor,
|
|
921
|
+
blockType
|
|
922
|
+
}),
|
|
923
|
+
/* @__PURE__ */ jsx(ToolbarDivider, {}),
|
|
924
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
925
|
+
active: isBold,
|
|
926
|
+
onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold"),
|
|
927
|
+
tooltip: "Bold (Ctrl+B)",
|
|
928
|
+
children: /* @__PURE__ */ jsx(Bold, { className: "tw:size-4" })
|
|
929
|
+
}),
|
|
930
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
931
|
+
active: isItalic,
|
|
932
|
+
onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, "italic"),
|
|
933
|
+
tooltip: "Italic (Ctrl+I)",
|
|
934
|
+
children: /* @__PURE__ */ jsx(Italic, { className: "tw:size-4" })
|
|
935
|
+
}),
|
|
936
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
937
|
+
active: isUnderline,
|
|
938
|
+
onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, "underline"),
|
|
939
|
+
tooltip: "Underline (Ctrl+U)",
|
|
940
|
+
children: /* @__PURE__ */ jsx(Underline, { className: "tw:size-4" })
|
|
941
|
+
}),
|
|
942
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
943
|
+
active: isStrikethrough,
|
|
944
|
+
onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, "strikethrough"),
|
|
945
|
+
tooltip: "Strikethrough",
|
|
946
|
+
children: /* @__PURE__ */ jsx(Strikethrough, { className: "tw:size-4" })
|
|
947
|
+
}),
|
|
948
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
949
|
+
active: isCode,
|
|
950
|
+
onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, "code"),
|
|
951
|
+
tooltip: "Inline Code",
|
|
952
|
+
children: /* @__PURE__ */ jsx(Code, { className: "tw:size-4" })
|
|
953
|
+
}),
|
|
954
|
+
/* @__PURE__ */ jsx(ToolbarDivider, {}),
|
|
955
|
+
/* @__PURE__ */ jsx(LinkPanel, {
|
|
956
|
+
editor,
|
|
957
|
+
isLink
|
|
958
|
+
}),
|
|
959
|
+
/* @__PURE__ */ jsx(ToolbarDivider, {}),
|
|
960
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
961
|
+
active: blockType === "bullet",
|
|
962
|
+
onClick: () => {
|
|
963
|
+
if (blockType === "bullet") editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
|
|
964
|
+
else editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
|
|
965
|
+
},
|
|
966
|
+
tooltip: "Bullet List",
|
|
967
|
+
children: /* @__PURE__ */ jsx(List, { className: "tw:size-4" })
|
|
968
|
+
}),
|
|
969
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
970
|
+
active: blockType === "number",
|
|
971
|
+
onClick: () => {
|
|
972
|
+
if (blockType === "number") editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
|
|
973
|
+
else editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
|
|
974
|
+
},
|
|
975
|
+
tooltip: "Numbered List",
|
|
976
|
+
children: /* @__PURE__ */ jsx(ListOrdered, { className: "tw:size-4" })
|
|
977
|
+
}),
|
|
978
|
+
/* @__PURE__ */ jsx(ToolbarDivider, {}),
|
|
979
|
+
/* @__PURE__ */ jsx(AlignmentDropdown, {
|
|
980
|
+
editor,
|
|
981
|
+
alignment
|
|
982
|
+
}),
|
|
983
|
+
/* @__PURE__ */ jsx(ToolbarDivider, {}),
|
|
984
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
985
|
+
active: blockType === "quote",
|
|
986
|
+
onClick: () => {
|
|
987
|
+
editor.update(() => {
|
|
988
|
+
const selection = $getSelection();
|
|
989
|
+
if (!$isRangeSelection(selection)) return;
|
|
990
|
+
const anchorNode = selection.anchor.getNode();
|
|
991
|
+
const element = $getNearestBlockElementAncestorOrThrow(anchorNode);
|
|
992
|
+
const newNode = blockType === "quote" ? $createParagraphNode() : $createQuoteNode();
|
|
993
|
+
element.getChildren().forEach((child) => newNode.append(child));
|
|
994
|
+
element.replace(newNode);
|
|
995
|
+
});
|
|
996
|
+
},
|
|
997
|
+
tooltip: "Quote",
|
|
998
|
+
children: /* @__PURE__ */ jsx(Quote, { className: "tw:size-4" })
|
|
999
|
+
}),
|
|
1000
|
+
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
1001
|
+
active: blockType === "code",
|
|
1002
|
+
onClick: () => {
|
|
1003
|
+
editor.update(() => {
|
|
1004
|
+
const selection = $getSelection();
|
|
1005
|
+
if (!$isRangeSelection(selection)) return;
|
|
1006
|
+
const anchorNode = selection.anchor.getNode();
|
|
1007
|
+
const element = $getNearestBlockElementAncestorOrThrow(anchorNode);
|
|
1008
|
+
const newNode = blockType === "code" ? $createParagraphNode() : $createCodeNode();
|
|
1009
|
+
element.getChildren().forEach((child) => newNode.append(child));
|
|
1010
|
+
element.replace(newNode);
|
|
1011
|
+
});
|
|
1012
|
+
},
|
|
1013
|
+
tooltip: "Code Block",
|
|
1014
|
+
children: /* @__PURE__ */ jsx(SquareCode, { className: "tw:size-4" })
|
|
1015
|
+
})
|
|
1016
|
+
]
|
|
1017
|
+
}), document.body);
|
|
1054
1018
|
};
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1019
|
+
//#endregion
|
|
1020
|
+
//#region src/blocks/MarkdownEditor/theme.ts
|
|
1021
|
+
/**
|
|
1022
|
+
* Lexical editor theme — maps node types to CSS classes.
|
|
1023
|
+
* The editor container uses `tw:prose` so semantic elements (headings, lists, blockquotes, etc.)
|
|
1024
|
+
* are styled by Tailwind Typography. We only need explicit classes for text formatting
|
|
1025
|
+
* (bold, italic, etc.) because Lexical renders those as `<span>` elements.
|
|
1026
|
+
*/
|
|
1027
|
+
const editorTheme = {
|
|
1028
|
+
link: "tw:cursor-pointer tw:!text-primary tw:underline",
|
|
1029
|
+
text: {
|
|
1030
|
+
bold: "tw:font-bold",
|
|
1031
|
+
italic: "tw:italic",
|
|
1032
|
+
strikethrough: "tw:line-through",
|
|
1033
|
+
underline: "tw:underline",
|
|
1034
|
+
code: "tw:rounded tw:bg-muted tw:px-1 tw:py-0.5 tw:font-mono tw:text-[0.85em]"
|
|
1035
|
+
},
|
|
1036
|
+
list: {
|
|
1037
|
+
ol: "tw:!list-decimal",
|
|
1038
|
+
ul: "tw:!list-disc",
|
|
1039
|
+
checklist: "tw:!list-none tw:!pl-0",
|
|
1040
|
+
listitemChecked: [
|
|
1041
|
+
"tw:relative tw:!pl-6 tw:list-none tw:outline-hidden tw:line-through tw:text-muted-foreground",
|
|
1042
|
+
"tw:before:content-[\"\"] tw:before:absolute tw:before:left-0 tw:before:top-[3px]",
|
|
1043
|
+
"tw:before:size-4 tw:before:rounded tw:before:border tw:before:border-solid",
|
|
1044
|
+
"tw:before:bg-primary tw:before:border-primary tw:before:cursor-pointer",
|
|
1045
|
+
"tw:after:content-[\"\"] tw:after:absolute tw:after:left-[5.5px] tw:after:top-[5.5px]",
|
|
1046
|
+
"tw:after:w-1 tw:after:h-2 tw:after:border-primary-foreground tw:after:border-solid",
|
|
1047
|
+
"tw:after:border-r-[1.5px] tw:after:border-b-[1.5px] tw:after:border-t-0 tw:after:border-l-0",
|
|
1048
|
+
"tw:after:rotate-45"
|
|
1049
|
+
].join(" "),
|
|
1050
|
+
listitemUnchecked: [
|
|
1051
|
+
"tw:relative tw:!pl-6 tw:list-none tw:outline-hidden",
|
|
1052
|
+
"tw:before:content-[\"\"] tw:before:absolute tw:before:left-0 tw:before:top-[3px]",
|
|
1053
|
+
"tw:before:size-4 tw:before:rounded tw:before:border tw:before:border-solid",
|
|
1054
|
+
"tw:before:border-input tw:before:bg-background tw:before:cursor-pointer"
|
|
1055
|
+
].join(" ")
|
|
1056
|
+
}
|
|
1087
1057
|
};
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/blocks/MarkdownEditor/MarkdownEditor.tsx
|
|
1060
|
+
const EDITOR_NODES = [
|
|
1061
|
+
ImageNode,
|
|
1062
|
+
MermaidNode,
|
|
1063
|
+
HeadingNode,
|
|
1064
|
+
QuoteNode,
|
|
1065
|
+
ListNode,
|
|
1066
|
+
ListItemNode,
|
|
1067
|
+
CodeNode,
|
|
1068
|
+
LinkNode,
|
|
1069
|
+
HorizontalRuleNode
|
|
1098
1070
|
];
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
{
|
|
1177
|
-
contentEditable: /* @__PURE__ */ jsx(
|
|
1178
|
-
ContentEditable,
|
|
1179
|
-
{
|
|
1180
|
-
className: cn("tw:outline-hidden", useDefaultMinHeight && "tw:min-h-[100px]"),
|
|
1181
|
-
style: customMinHeight,
|
|
1182
|
-
"aria-placeholder": placeholder ?? "",
|
|
1183
|
-
placeholder: placeholder ? /* @__PURE__ */ jsx(
|
|
1184
|
-
"div",
|
|
1185
|
-
{
|
|
1186
|
-
className: cn(
|
|
1187
|
-
"tw:pointer-events-none tw:absolute tw:select-none tw:text-muted-foreground",
|
|
1188
|
-
compact ? "tw:left-1.5 tw:top-0.5" : "tw:left-2 tw:top-[calc(0.5rem+0.35em)]"
|
|
1189
|
-
),
|
|
1190
|
-
children: placeholder
|
|
1191
|
-
}
|
|
1192
|
-
) : /* @__PURE__ */ jsx("div", {})
|
|
1193
|
-
}
|
|
1194
|
-
),
|
|
1195
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
1196
|
-
}
|
|
1197
|
-
)
|
|
1198
|
-
}
|
|
1199
|
-
),
|
|
1200
|
-
/* @__PURE__ */ jsx(HistoryPlugin, {}),
|
|
1201
|
-
/* @__PURE__ */ jsx(LinkPlugin, {}),
|
|
1202
|
-
/* @__PURE__ */ jsx(ClickableLinkPlugin, { newTab: true }),
|
|
1203
|
-
!singleLine && /* @__PURE__ */ jsx(ListPlugin, {}),
|
|
1204
|
-
!singleLine && /* @__PURE__ */ jsx(CheckListPlugin, {}),
|
|
1205
|
-
!singleLine && /* @__PURE__ */ jsx(HorizontalRulePlugin, {}),
|
|
1206
|
-
/* @__PURE__ */ jsx(TabIndentationPlugin, {}),
|
|
1207
|
-
/* @__PURE__ */ jsx(MarkdownShortcutPlugin, { transformers }),
|
|
1208
|
-
/* @__PURE__ */ jsx(
|
|
1209
|
-
MarkdownSyncPlugin,
|
|
1210
|
-
{
|
|
1211
|
-
value,
|
|
1212
|
-
editable,
|
|
1213
|
-
onChange,
|
|
1214
|
-
transformers,
|
|
1215
|
-
singleLine
|
|
1216
|
-
}
|
|
1217
|
-
),
|
|
1218
|
-
/* @__PURE__ */ jsx(ImagePastePlugin, { onImageUpload }),
|
|
1219
|
-
/* @__PURE__ */ jsx(
|
|
1220
|
-
KeyboardPlugin,
|
|
1221
|
-
{
|
|
1222
|
-
onSave,
|
|
1223
|
-
onCancel,
|
|
1224
|
-
singleLine,
|
|
1225
|
-
blurOnEscape: singleLine || saveOnBlur,
|
|
1226
|
-
skipBlurSaveRef
|
|
1227
|
-
}
|
|
1228
|
-
),
|
|
1229
|
-
autoFocus && /* @__PURE__ */ jsx(AutoFocusPlugin, {})
|
|
1230
|
-
]
|
|
1231
|
-
}
|
|
1232
|
-
) }) });
|
|
1071
|
+
const MarkdownEditor = ({ value, onChange, readOnly = false, placeholder, autoFocus = false, disabled = false, onSave, onCancel, onImageUpload, className, imageRenderer, showToolbar = false, compact = false, saveOnBlur = false, singleLine = false, clampDisplay = false, minRows }) => {
|
|
1072
|
+
const editable = !readOnly && !disabled;
|
|
1073
|
+
const transformers = singleLine ? SINGLE_LINE_TRANSFORMERS : CUSTOM_TRANSFORMERS;
|
|
1074
|
+
const useDefaultMinHeight = !compact && minRows === void 0;
|
|
1075
|
+
const customMinHeight = !compact && minRows !== void 0 ? { minHeight: `${minRows * 1.75}em` } : void 0;
|
|
1076
|
+
const [initialConfig] = useState(() => ({
|
|
1077
|
+
namespace: "MarkdownEditor",
|
|
1078
|
+
theme: editorTheme,
|
|
1079
|
+
nodes: EDITOR_NODES,
|
|
1080
|
+
onError: (error) => {
|
|
1081
|
+
console.error("[MarkdownEditor] uncaught editor error", error);
|
|
1082
|
+
},
|
|
1083
|
+
editable,
|
|
1084
|
+
editorState: () => {
|
|
1085
|
+
$convertFromMarkdownString(preprocessMarkdown(value), transformers);
|
|
1086
|
+
}
|
|
1087
|
+
}));
|
|
1088
|
+
const skipBlurSaveRef = useRef(false);
|
|
1089
|
+
const handleBlur = saveOnBlur && onSave ? (event) => {
|
|
1090
|
+
if (skipBlurSaveRef.current) {
|
|
1091
|
+
skipBlurSaveRef.current = false;
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
if (!event.currentTarget.contains(event.relatedTarget)) onSave();
|
|
1095
|
+
} : void 0;
|
|
1096
|
+
return /* @__PURE__ */ jsx(LexicalComposer, {
|
|
1097
|
+
initialConfig,
|
|
1098
|
+
children: /* @__PURE__ */ jsx(ImageRendererProvider, {
|
|
1099
|
+
value: imageRenderer ?? null,
|
|
1100
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1101
|
+
className: cn(!compact && "tw:prose", compact && "tw:[&_p]:m-0 tw:[&_p+p]:mt-2", clampDisplay && "tw:[&:not(:focus-within)]:line-clamp-2", className),
|
|
1102
|
+
onBlur: handleBlur,
|
|
1103
|
+
children: [
|
|
1104
|
+
showToolbar && editable && /* @__PURE__ */ jsx(ToolbarPlugin, {}),
|
|
1105
|
+
/* @__PURE__ */ jsx("div", {
|
|
1106
|
+
className: cn("tw:relative tw:rounded-md tw:transition-colors", compact ? "tw:px-1.5 tw:py-0.5 tw:-mx-1.5 tw:-my-0.5" : "tw:p-2", editable && "tw:cursor-text tw:hover:bg-muted tw:focus-within:ring-2 tw:focus-within:ring-ring/40"),
|
|
1107
|
+
children: /* @__PURE__ */ jsx(RichTextPlugin, {
|
|
1108
|
+
contentEditable: /* @__PURE__ */ jsx(ContentEditable, {
|
|
1109
|
+
className: cn("tw:outline-hidden", useDefaultMinHeight && "tw:min-h-[100px]"),
|
|
1110
|
+
style: customMinHeight,
|
|
1111
|
+
"aria-placeholder": placeholder ?? "",
|
|
1112
|
+
placeholder: placeholder ? /* @__PURE__ */ jsx("div", {
|
|
1113
|
+
className: cn("tw:pointer-events-none tw:absolute tw:select-none tw:text-muted-foreground", compact ? "tw:left-1.5 tw:top-0.5" : "tw:left-2 tw:top-[calc(0.5rem+0.35em)]"),
|
|
1114
|
+
children: placeholder
|
|
1115
|
+
}) : /* @__PURE__ */ jsx("div", {})
|
|
1116
|
+
}),
|
|
1117
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
1118
|
+
})
|
|
1119
|
+
}),
|
|
1120
|
+
/* @__PURE__ */ jsx(HistoryPlugin, {}),
|
|
1121
|
+
/* @__PURE__ */ jsx(LinkPlugin, {}),
|
|
1122
|
+
/* @__PURE__ */ jsx(ClickableLinkPlugin, { newTab: true }),
|
|
1123
|
+
!singleLine && /* @__PURE__ */ jsx(ListPlugin, {}),
|
|
1124
|
+
!singleLine && /* @__PURE__ */ jsx(CheckListPlugin, {}),
|
|
1125
|
+
!singleLine && /* @__PURE__ */ jsx(HorizontalRulePlugin, {}),
|
|
1126
|
+
/* @__PURE__ */ jsx(TabIndentationPlugin, {}),
|
|
1127
|
+
/* @__PURE__ */ jsx(MarkdownShortcutPlugin, { transformers }),
|
|
1128
|
+
/* @__PURE__ */ jsx(MarkdownSyncPlugin, {
|
|
1129
|
+
value,
|
|
1130
|
+
editable,
|
|
1131
|
+
onChange,
|
|
1132
|
+
transformers,
|
|
1133
|
+
singleLine
|
|
1134
|
+
}),
|
|
1135
|
+
/* @__PURE__ */ jsx(ImagePastePlugin, { onImageUpload }),
|
|
1136
|
+
/* @__PURE__ */ jsx(KeyboardPlugin, {
|
|
1137
|
+
onSave,
|
|
1138
|
+
onCancel,
|
|
1139
|
+
singleLine,
|
|
1140
|
+
blurOnEscape: singleLine || saveOnBlur,
|
|
1141
|
+
skipBlurSaveRef
|
|
1142
|
+
}),
|
|
1143
|
+
autoFocus && /* @__PURE__ */ jsx(AutoFocusPlugin, {})
|
|
1144
|
+
]
|
|
1145
|
+
})
|
|
1146
|
+
})
|
|
1147
|
+
});
|
|
1233
1148
|
};
|
|
1234
|
-
|
|
1149
|
+
//#endregion
|
|
1235
1150
|
export { MarkdownEditor };
|
|
1236
|
-
|
|
1151
|
+
|
|
1237
1152
|
//# sourceMappingURL=markdown-editor.js.map
|