@keboola/design 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -1
- package/dist/icon-names.d.cts +7 -0
- package/dist/icon-names.d.ts +7 -0
- package/dist/icons.cjs +4 -0
- package/dist/icons.d.cts +6 -0
- package/dist/icons.d.ts +6 -0
- package/dist/icons.js +1 -1
- package/dist/index.cjs +127 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10184 -0
- package/dist/index.d.ts +10184 -0
- package/dist/index.js +163 -133
- package/dist/index.js.map +1 -1
- package/dist/markdown-editor.cjs +30 -33
- package/dist/markdown-editor.cjs.map +1 -1
- package/dist/markdown-editor.d.cts +74 -0
- package/dist/markdown-editor.d.ts +74 -0
- package/dist/markdown-editor.js +30 -33
- package/dist/markdown-editor.js.map +1 -1
- package/dist/mermaid.cjs +18 -14
- package/dist/mermaid.cjs.map +1 -1
- package/dist/mermaid.d.cts +11 -0
- package/dist/mermaid.d.ts +11 -0
- package/dist/mermaid.js +18 -14
- package/dist/mermaid.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +79 -9
- package/src/blocks/AIKit/AnswerSummary.stories.tsx +0 -38
- package/src/blocks/AIKit/AnswerSummary.tsx +0 -63
- package/src/blocks/AIKit/CollapsibleStepHeader.stories.tsx +0 -53
- package/src/blocks/AIKit/CollapsibleStepHeader.tsx +0 -64
- package/src/blocks/AIKit/InlineStepDetail.stories.tsx +0 -25
- package/src/blocks/AIKit/InlineStepDetail.tsx +0 -13
- package/src/blocks/AIKit/InlineStepLabel.stories.tsx +0 -37
- package/src/blocks/AIKit/InlineStepLabel.tsx +0 -36
- package/src/blocks/AIKit/MessageBubble.stories.tsx +0 -145
- package/src/blocks/AIKit/MessageBubble.tsx +0 -68
- package/src/blocks/AIKit/PlanApproval.stories.tsx +0 -121
- package/src/blocks/AIKit/PlanApproval.test.tsx +0 -241
- package/src/blocks/AIKit/PlanApproval.tsx +0 -363
- package/src/blocks/AIKit/PlanRewritingIndicator.test.tsx +0 -17
- package/src/blocks/AIKit/PlanRewritingIndicator.tsx +0 -20
- package/src/blocks/AIKit/PromptInput.stories.tsx +0 -106
- package/src/blocks/AIKit/PromptInput.test.tsx +0 -53
- package/src/blocks/AIKit/PromptInput.tsx +0 -218
- package/src/blocks/AIKit/PromptInputAction.tsx +0 -18
- package/src/blocks/AIKit/PromptInputSubmit.tsx +0 -59
- package/src/blocks/AIKit/Question.stories.tsx +0 -235
- package/src/blocks/AIKit/Question.tsx +0 -350
- package/src/blocks/AIKit/QuestionBlock.stories.tsx +0 -99
- package/src/blocks/AIKit/QuestionBlock.tsx +0 -83
- package/src/blocks/AIKit/SuggestedPrompt.stories.tsx +0 -82
- package/src/blocks/AIKit/SuggestedPrompt.tsx +0 -42
- package/src/blocks/AIKit/ThinkingIndicator.stories.tsx +0 -21
- package/src/blocks/AIKit/ThinkingIndicator.tsx +0 -14
- package/src/blocks/AIKit/index.ts +0 -12
- package/src/blocks/AutoSaveTextarea/AutoSaveTextarea.stories.tsx +0 -78
- package/src/blocks/AutoSaveTextarea/AutoSaveTextarea.tsx +0 -103
- package/src/blocks/AutoSaveTextarea/index.ts +0 -1
- package/src/blocks/ClipboardButton/ClipboardButton.stories.tsx +0 -28
- package/src/blocks/ClipboardButton/ClipboardButton.tsx +0 -43
- package/src/blocks/ClipboardButton/ClipboardInline.tsx +0 -40
- package/src/blocks/ClipboardButton/index.ts +0 -2
- package/src/blocks/ColorInput/ColorInput.stories.tsx +0 -109
- package/src/blocks/ColorInput/ColorInput.test.tsx +0 -163
- package/src/blocks/ColorInput/ColorInput.tsx +0 -171
- package/src/blocks/ColorInput/ColorPicker.tsx +0 -42
- package/src/blocks/ColorInput/index.ts +0 -1
- package/src/blocks/ColorInput/utils.test.ts +0 -189
- package/src/blocks/ColorInput/utils.ts +0 -74
- package/src/blocks/EmptyConfigurationActionCard/EmptyConfigurationActionCard.stories.tsx +0 -30
- package/src/blocks/EmptyConfigurationActionCard/EmptyConfigurationActionCard.tsx +0 -20
- package/src/blocks/EmptyConfigurationActionCard/index.ts +0 -1
- package/src/blocks/EmptyState/EmptyState.stories.tsx +0 -93
- package/src/blocks/EmptyState/EmptyState.tsx +0 -146
- package/src/blocks/EmptyState/index.ts +0 -1
- package/src/blocks/ErrorState/ErrorState.stories.tsx +0 -125
- package/src/blocks/ErrorState/ErrorState.tsx +0 -162
- package/src/blocks/ErrorState/index.ts +0 -1
- package/src/blocks/Form/components/FormBody.tsx +0 -27
- package/src/blocks/Form/components/SubmitButton.tsx +0 -30
- package/src/blocks/Form/connectors/CheckboxField.tsx +0 -34
- package/src/blocks/Form/connectors/FieldShell.tsx +0 -46
- package/src/blocks/Form/connectors/NumberField.tsx +0 -36
- package/src/blocks/Form/connectors/PasswordField.tsx +0 -38
- package/src/blocks/Form/connectors/SelectField.tsx +0 -73
- package/src/blocks/Form/connectors/SwitchField.tsx +0 -34
- package/src/blocks/Form/connectors/TextAreaField.tsx +0 -36
- package/src/blocks/Form/connectors/TextField.tsx +0 -36
- package/src/blocks/Form/contexts.ts +0 -4
- package/src/blocks/Form/formHook.ts +0 -45
- package/src/blocks/Form/index.ts +0 -2
- package/src/blocks/Form/setServerFieldErrors.test.ts +0 -38
- package/src/blocks/Form/setServerFieldErrors.ts +0 -21
- package/src/blocks/InputOtp/InputOtp.stories.tsx +0 -214
- package/src/blocks/InputOtp/InputOtp.test.tsx +0 -162
- package/src/blocks/InputOtp/InputOtp.tsx +0 -62
- package/src/blocks/InputOtp/InputOtpGroup.tsx +0 -13
- package/src/blocks/InputOtp/InputOtpSeparator.tsx +0 -23
- package/src/blocks/InputOtp/InputOtpSlot.styles.ts +0 -52
- package/src/blocks/InputOtp/InputOtpSlot.tsx +0 -44
- package/src/blocks/InputOtp/context.ts +0 -23
- package/src/blocks/InputOtp/index.ts +0 -23
- package/src/blocks/MermaidDiagram/MermaidDiagram.stories.tsx +0 -87
- package/src/blocks/MermaidDiagram/MermaidDiagram.tsx +0 -266
- package/src/blocks/MermaidDiagram/index.ts +0 -1
- package/src/blocks/MultiActionButtonGroup/MultiActionButton.stories.tsx +0 -119
- package/src/blocks/MultiActionButtonGroup/MultiActionButton.tsx +0 -41
- package/src/blocks/MultiActionButtonGroup/MultiActionButtonGroup.tsx +0 -16
- package/src/blocks/MultiActionButtonGroup/index.ts +0 -1
- package/src/blocks/MultiCombobox/MultiCombobox.stories.tsx +0 -324
- package/src/blocks/MultiCombobox/MultiCombobox.tsx +0 -257
- package/src/blocks/MultiCombobox/index.ts +0 -1
- package/src/blocks/NumberInput/NumberInput.stories.tsx +0 -112
- package/src/blocks/NumberInput/NumberInput.test.tsx +0 -148
- package/src/blocks/NumberInput/NumberInput.tsx +0 -89
- package/src/blocks/NumberInput/index.ts +0 -1
- package/src/blocks/PageHeader/AGENTS.md +0 -137
- package/src/blocks/PageHeader/PageHeader.stories.tsx +0 -371
- package/src/blocks/PageHeader/PageHeader.tsx +0 -22
- package/src/blocks/PageHeader/PageHeaderDetail.tsx +0 -84
- package/src/blocks/PageHeader/PageHeaderIndex.tsx +0 -75
- package/src/blocks/PageHeader/index.ts +0 -1
- package/src/blocks/PageHeader/styles.ts +0 -6
- package/src/blocks/PageLayout/AGENTS.md +0 -94
- package/src/blocks/PageLayout/PageLayout.stories.tsx +0 -146
- package/src/blocks/PageLayout/PageLayout.tsx +0 -139
- package/src/blocks/PageLayout/index.ts +0 -1
- package/src/blocks/PageToolbar/PageToolbar.stories.tsx +0 -353
- package/src/blocks/PageToolbar/PageToolbar.tsx +0 -160
- package/src/blocks/PageToolbar/PageToolbarToken.tsx +0 -61
- package/src/blocks/PageToolbar/index.ts +0 -1
- package/src/blocks/PasswordInput/PasswordInput.stories.tsx +0 -114
- package/src/blocks/PasswordInput/PasswordInput.test.tsx +0 -219
- package/src/blocks/PasswordInput/PasswordInput.tsx +0 -180
- package/src/blocks/PasswordInput/index.ts +0 -1
- package/src/blocks/SearchInput/SearchInput.stories.tsx +0 -127
- package/src/blocks/SearchInput/SearchInput.test.tsx +0 -162
- package/src/blocks/SearchInput/SearchInput.tsx +0 -172
- package/src/blocks/SearchInput/index.ts +0 -1
- package/src/blocks/SearchInputWithNavigation/SearchInputWithNavigation.stories.tsx +0 -73
- package/src/blocks/SearchInputWithNavigation/SearchInputWithNavigation.tsx +0 -92
- package/src/blocks/SearchInputWithNavigation/index.ts +0 -1
- package/src/blocks/SplitButton/SplitButton.stories.tsx +0 -91
- package/src/blocks/SplitButton/SplitButton.tsx +0 -81
- package/src/blocks/SplitButton/index.ts +0 -1
- package/src/blocks/Tagger/TagItem.tsx +0 -32
- package/src/blocks/Tagger/TagSelectPopover/TagSelectCreateItem.tsx +0 -44
- package/src/blocks/Tagger/TagSelectPopover/TagSelectItem.tsx +0 -31
- package/src/blocks/Tagger/TagSelectPopover/TagSelectList.tsx +0 -67
- package/src/blocks/Tagger/TagSelectPopover/TagSelectPopover.tsx +0 -34
- package/src/blocks/Tagger/TagSelectPopover/TagSelectValue.tsx +0 -47
- package/src/blocks/Tagger/TagSelectPopover/index.ts +0 -1
- package/src/blocks/Tagger/Tagger.stories.tsx +0 -80
- package/src/blocks/Tagger/Tagger.tsx +0 -101
- package/src/blocks/Tagger/index.ts +0 -1
- package/src/blocks/Tagger/types.ts +0 -11
- package/src/blocks/Textarea/Textarea.stories.tsx +0 -47
- package/src/blocks/Textarea/Textarea.tsx +0 -50
- package/src/blocks/Textarea/index.ts +0 -1
- package/src/components/Alert/Alert.stories.tsx +0 -101
- package/src/components/Alert/Alert.tsx +0 -121
- package/src/components/Alert/AlertAction.tsx +0 -31
- package/src/components/Alert/AlertCollapsibleIcon.tsx +0 -25
- package/src/components/Alert/AlertDescription.tsx +0 -36
- package/src/components/Alert/AlertIcon.tsx +0 -40
- package/src/components/Alert/AlertRoot.tsx +0 -64
- package/src/components/Alert/AlertTitle.tsx +0 -25
- package/src/components/Alert/index.ts +0 -1
- package/src/components/Avatar.stories.tsx +0 -22
- package/src/components/Avatar.tsx +0 -88
- package/src/components/Badge/Badge.stories.tsx +0 -122
- package/src/components/Badge/Badge.tsx +0 -71
- package/src/components/Badge/BadgeAddon.tsx +0 -63
- package/src/components/Badge/BadgeButton.tsx +0 -40
- package/src/components/Badge/BadgeLabel.tsx +0 -37
- package/src/components/Badge/BadgeRoot.tsx +0 -21
- package/src/components/Badge/index.ts +0 -1
- package/src/components/Badge/styles.ts +0 -74
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +0 -135
- package/src/components/Breadcrumb/Breadcrumb.tsx +0 -23
- package/src/components/Breadcrumb/BreadcrumbEllipsis.tsx +0 -43
- package/src/components/Breadcrumb/BreadcrumbItem.tsx +0 -9
- package/src/components/Breadcrumb/BreadcrumbLink.tsx +0 -48
- package/src/components/Breadcrumb/BreadcrumbList.tsx +0 -26
- package/src/components/Breadcrumb/BreadcrumbPage.tsx +0 -22
- package/src/components/Breadcrumb/BreadcrumbSeparator.tsx +0 -28
- package/src/components/Breadcrumb/index.ts +0 -1
- package/src/components/Button/Button.stories.tsx +0 -80
- package/src/components/Button/Button.tsx +0 -110
- package/src/components/Button/ButtonInline.stories.tsx +0 -54
- package/src/components/Button/ButtonInline.tsx +0 -77
- package/src/components/Button/index.ts +0 -3
- package/src/components/Button/styles.ts +0 -313
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +0 -140
- package/src/components/ButtonGroup/ButtonGroup.tsx +0 -79
- package/src/components/ButtonGroup/index.ts +0 -1
- package/src/components/Calendar/Calendar.stories.tsx +0 -101
- package/src/components/Calendar/Calendar.tsx +0 -44
- package/src/components/Calendar/index.ts +0 -2
- package/src/components/Card/Card.stories.tsx +0 -60
- package/src/components/Card/Card.tsx +0 -42
- package/src/components/Card/CardContent.tsx +0 -5
- package/src/components/Card/CardHeader.tsx +0 -5
- package/src/components/Card/CardTitle.tsx +0 -13
- package/src/components/Card/index.ts +0 -1
- package/src/components/Card/styles.ts +0 -32
- package/src/components/Checkbox/Checkbox.stories.tsx +0 -210
- package/src/components/Checkbox/Checkbox.test.tsx +0 -140
- package/src/components/Checkbox/Checkbox.tsx +0 -83
- package/src/components/Checkbox/index.ts +0 -1
- package/src/components/Checkbox/styles.ts +0 -77
- package/src/components/Clipboard/Clipboard.stories.tsx +0 -44
- package/src/components/Clipboard/Clipboard.tsx +0 -89
- package/src/components/Clipboard/index.ts +0 -1
- package/src/components/CodeEditor/ButtonToolbar.tsx +0 -14
- package/src/components/CodeEditor/CodeEditor.tsx +0 -155
- package/src/components/CodeEditor/SqlEditor.stories.tsx +0 -76
- package/src/components/CodeEditor/SqlEditor.tsx +0 -206
- package/src/components/CodeEditor/ToggleComponentHelp.tsx +0 -7
- package/src/components/CodeEditor/activeQueryHighlight.test.ts +0 -178
- package/src/components/CodeEditor/activeQueryHighlight.ts +0 -245
- package/src/components/CodeEditor/helpers.ts +0 -100
- package/src/components/CodeEditor/highlighting.ts +0 -184
- package/src/components/CodeEditor/index.ts +0 -3
- package/src/components/CodeEditor/search.ts +0 -186
- package/src/components/Collapse.stories.tsx +0 -56
- package/src/components/Collapse.tsx +0 -61
- package/src/components/Collapsible/Collapsible.stories.tsx +0 -55
- package/src/components/Collapsible/Collapsible.tsx +0 -11
- package/src/components/Collapsible/CollapsibleContent.tsx +0 -25
- package/src/components/Collapsible/index.ts +0 -1
- package/src/components/CollapsiblePanel.stories.tsx +0 -25
- package/src/components/CollapsiblePanel.tsx +0 -127
- package/src/components/Combobox/Combobox.stories.tsx +0 -426
- package/src/components/Combobox/Combobox.test.tsx +0 -165
- package/src/components/Combobox/Combobox.tsx +0 -345
- package/src/components/Combobox/ComboboxChips.tsx +0 -68
- package/src/components/Combobox/ComboboxContent.tsx +0 -95
- package/src/components/Combobox/ComboboxEmpty.tsx +0 -30
- package/src/components/Combobox/ComboboxInput.tsx +0 -10
- package/src/components/Combobox/ComboboxInputGroup.tsx +0 -38
- package/src/components/Combobox/ComboboxItem.tsx +0 -70
- package/src/components/Combobox/ComboboxItemIndicator.tsx +0 -78
- package/src/components/Combobox/ComboboxList.tsx +0 -32
- package/src/components/Combobox/ComboboxRoot.tsx +0 -5
- package/src/components/Combobox/ComboboxSeparator.tsx +0 -20
- package/src/components/Combobox/Group/ComboboxCollection.tsx +0 -7
- package/src/components/Combobox/Group/ComboboxGroup.tsx +0 -23
- package/src/components/Combobox/Group/ComboboxGroupLabel.tsx +0 -38
- package/src/components/Combobox/Group/index.ts +0 -3
- package/src/components/Combobox/index.ts +0 -1
- package/src/components/Combobox/types.ts +0 -22
- package/src/components/Combobox/utils.test.ts +0 -95
- package/src/components/Combobox/utils.ts +0 -103
- package/src/components/Command/Command.stories.tsx +0 -367
- package/src/components/Command/Command.tsx +0 -37
- package/src/components/Command/CommandContent.tsx +0 -19
- package/src/components/Command/CommandEmpty.tsx +0 -6
- package/src/components/Command/CommandGroup.tsx +0 -26
- package/src/components/Command/CommandInput.tsx +0 -27
- package/src/components/Command/CommandItem/CheckIndicator.tsx +0 -86
- package/src/components/Command/CommandItem/CommandItem.tsx +0 -94
- package/src/components/Command/CommandItem/index.ts +0 -1
- package/src/components/Command/CommandList.tsx +0 -32
- package/src/components/Command/CommandSeparator.tsx +0 -13
- package/src/components/Command/index.ts +0 -6
- package/src/components/DatePicker/DatePicker.tsx +0 -37
- package/src/components/DatePicker/index.ts +0 -1
- package/src/components/DiffView/DiffView.stories.tsx +0 -80
- package/src/components/DiffView/DiffView.tsx +0 -131
- package/src/components/DiffView/DiffViewMark.tsx +0 -21
- package/src/components/DiffView/DiffViewTd.tsx +0 -84
- package/src/components/DiffView/DiffViewTh.tsx +0 -23
- package/src/components/DiffView/index.ts +0 -11
- package/src/components/DiffView/util.test.ts +0 -231
- package/src/components/DiffView/util.ts +0 -311
- package/src/components/DotsLoader.tsx +0 -22
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +0 -310
- package/src/components/DropdownMenu/DropdownMenu.tsx +0 -61
- package/src/components/DropdownMenu/DropdownMenuCheckboxItem.tsx +0 -55
- package/src/components/DropdownMenu/DropdownMenuContent.tsx +0 -52
- package/src/components/DropdownMenu/DropdownMenuContext.tsx +0 -13
- package/src/components/DropdownMenu/DropdownMenuItem.tsx +0 -80
- package/src/components/DropdownMenu/DropdownMenuItemDescription.tsx +0 -42
- package/src/components/DropdownMenu/DropdownMenuItemIndicator.tsx +0 -104
- package/src/components/DropdownMenu/DropdownMenuLabel.tsx +0 -21
- package/src/components/DropdownMenu/DropdownMenuRadioGroup/DropdownMenuRadioGroup.tsx +0 -31
- package/src/components/DropdownMenu/DropdownMenuRadioGroup/DropdownMenuRadioItem.tsx +0 -67
- package/src/components/DropdownMenu/DropdownMenuRadioGroup/index.ts +0 -2
- package/src/components/DropdownMenu/DropdownMenuSeparator.tsx +0 -35
- package/src/components/DropdownMenu/DropdownMenuSub/DropdownMenuSub.tsx +0 -3
- package/src/components/DropdownMenu/DropdownMenuSub/DropdownMenuSubContent.tsx +0 -21
- package/src/components/DropdownMenu/DropdownMenuSub/DropdownMenuSubTrigger.tsx +0 -17
- package/src/components/DropdownMenu/DropdownMenuSub/index.ts +0 -3
- package/src/components/DropdownMenu/DropdownMenuTrigger.tsx +0 -19
- package/src/components/DropdownMenu/ItemIcon.tsx +0 -30
- package/src/components/DropdownMenu/index.ts +0 -1
- package/src/components/DropdownMenu/styles.ts +0 -82
- package/src/components/EmptySearchContent.stories.tsx +0 -12
- package/src/components/EmptySearchContent.tsx +0 -13
- package/src/components/FieldBox/FieldBox.stories.tsx +0 -138
- package/src/components/FieldBox/FieldBox.tsx +0 -43
- package/src/components/FieldBox/FieldBoxDescription.tsx +0 -18
- package/src/components/FieldBox/FieldBoxTitle.tsx +0 -20
- package/src/components/FieldBox/index.ts +0 -1
- package/src/components/FieldBox/styles.ts +0 -37
- package/src/components/FormGroup/FormGroup.stories.tsx +0 -120
- package/src/components/FormGroup/FormGroup.tsx +0 -48
- package/src/components/FormGroup/FormGroupColorInput.tsx +0 -15
- package/src/components/FormGroup/FormGroupHelp.tsx +0 -17
- package/src/components/FormGroup/FormGroupNumberInput.tsx +0 -15
- package/src/components/FormGroup/FormGroupTextInput.tsx +0 -15
- package/src/components/FormGroup/FormGroupTextarea.tsx +0 -12
- package/src/components/FormGroup/context.ts +0 -11
- package/src/components/FormGroup/index.ts +0 -2
- package/src/components/FormGroup/types.ts +0 -5
- package/src/components/FullScreenModal/FullScreenModal.tsx +0 -8
- package/src/components/FullScreenModal/FullScreenModalBody.tsx +0 -16
- package/src/components/FullScreenModal/FullScreenModalHeader.tsx +0 -92
- package/src/components/FullScreenModal/FullScreenModalRoot.tsx +0 -79
- package/src/components/FullScreenModal/index.ts +0 -3
- package/src/components/HelpBlock/HelpBlock.stories.tsx +0 -28
- package/src/components/HelpBlock/HelpBlock.tsx +0 -31
- package/src/components/HelpBlock/index.ts +0 -1
- package/src/components/HoverCard/HoverCard.stories.tsx +0 -77
- package/src/components/HoverCard/HoverCard.tsx +0 -13
- package/src/components/HoverCard/HoverCardContent.tsx +0 -68
- package/src/components/HoverCard/index.ts +0 -1
- package/src/components/Icon/Icon.stories.tsx +0 -26
- package/src/components/Icon/Icon.tsx +0 -10
- package/src/components/Icon/Icons.mdx +0 -28
- package/src/components/Icon/constants.ts +0 -1
- package/src/components/Icon/index.ts +0 -27
- package/src/components/Input/DateInput/DateInput.stories.tsx +0 -58
- package/src/components/Input/DateInput/DateInput.tsx +0 -143
- package/src/components/Input/DateInput/helpers.test.ts +0 -102
- package/src/components/Input/DateInput/helpers.ts +0 -59
- package/src/components/Input/DateInput/index.ts +0 -1
- package/src/components/Input/DateRangeInput/DateRangeInput.stories.tsx +0 -66
- package/src/components/Input/DateRangeInput/DateRangeInput.tsx +0 -139
- package/src/components/Input/DateRangeInput/helpers.test.ts +0 -146
- package/src/components/Input/DateRangeInput/helpers.ts +0 -36
- package/src/components/Input/DateRangeInput/index.ts +0 -1
- package/src/components/Input/Input.stories.tsx +0 -93
- package/src/components/Input/Input.test.tsx +0 -112
- package/src/components/Input/Input.tsx +0 -163
- package/src/components/Input/TextInput/TextInput.stories.tsx +0 -68
- package/src/components/Input/TextInput/TextInput.test.tsx +0 -52
- package/src/components/Input/TextInput/TextInput.tsx +0 -73
- package/src/components/Input/TextInput/index.ts +0 -1
- package/src/components/Input/TimeInput/TimeInput.stories.tsx +0 -89
- package/src/components/Input/TimeInput/TimeInput.tsx +0 -106
- package/src/components/Input/TimeInput/index.ts +0 -1
- package/src/components/Input/index.ts +0 -4
- package/src/components/Input/utils.ts +0 -11
- package/src/components/InputGroup/InputGroup.stories.tsx +0 -215
- package/src/components/InputGroup/InputGroup.tsx +0 -228
- package/src/components/InputGroup/InputGroupAddon.tsx +0 -57
- package/src/components/InputGroup/InputGroupButton.tsx +0 -25
- package/src/components/InputGroup/InputGroupInput.tsx +0 -34
- package/src/components/InputGroup/InputGroupText.tsx +0 -21
- package/src/components/InputGroup/InputGroupTextArea.tsx +0 -78
- package/src/components/InputGroup/index.ts +0 -1
- package/src/components/Kbd/Kbd.stories.tsx +0 -82
- package/src/components/Kbd/Kbd.tsx +0 -17
- package/src/components/Kbd/KbdGroup.tsx +0 -35
- package/src/components/Kbd/KbdSeparator.tsx +0 -9
- package/src/components/Kbd/index.ts +0 -3
- package/src/components/Kbd/keyboardKeys.ts +0 -40
- package/src/components/Kbd/styles.ts +0 -39
- package/src/components/Label/Label.stories.tsx +0 -53
- package/src/components/Label/Label.tsx +0 -31
- package/src/components/Label/index.ts +0 -1
- package/src/components/Link.stories.tsx +0 -19
- package/src/components/Link.tsx +0 -37
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +0 -182
- package/src/components/MarkdownEditor/MarkdownEditor.test.ts +0 -171
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +0 -245
- package/src/components/MarkdownEditor/context.ts +0 -10
- package/src/components/MarkdownEditor/index.ts +0 -1
- package/src/components/MarkdownEditor/nodes/ImageNode.tsx +0 -115
- package/src/components/MarkdownEditor/nodes/ImageNodeComponent.tsx +0 -18
- package/src/components/MarkdownEditor/nodes/MermaidNode.tsx +0 -72
- package/src/components/MarkdownEditor/nodes/MermaidNodeComponent.tsx +0 -35
- package/src/components/MarkdownEditor/plugins/ImagePastePlugin.tsx +0 -149
- package/src/components/MarkdownEditor/plugins/KeyboardPlugin.tsx +0 -81
- package/src/components/MarkdownEditor/plugins/MarkdownSyncPlugin.tsx +0 -65
- package/src/components/MarkdownEditor/plugins/ToolbarPlugin.tsx +0 -284
- package/src/components/MarkdownEditor/plugins/toolbar/AlignmentDropdown.tsx +0 -99
- package/src/components/MarkdownEditor/plugins/toolbar/BlockTypeDropdown.tsx +0 -142
- package/src/components/MarkdownEditor/plugins/toolbar/LinkPanel.tsx +0 -160
- package/src/components/MarkdownEditor/plugins/toolbar/ToolbarButton.tsx +0 -36
- package/src/components/MarkdownEditor/plugins/toolbar/ToolbarDivider.tsx +0 -1
- package/src/components/MarkdownEditor/theme.ts +0 -39
- package/src/components/MarkdownEditor/transformers.ts +0 -189
- package/src/components/MarkedText/MarkedText.stories.tsx +0 -46
- package/src/components/MarkedText/MarkedText.tsx +0 -36
- package/src/components/MarkedText/index.ts +0 -1
- package/src/components/MarkedText/utils.test.ts +0 -193
- package/src/components/MarkedText/utils.ts +0 -37
- package/src/components/MergeEditor/AcceptControls/AcceptButton.tsx +0 -25
- package/src/components/MergeEditor/AcceptControls/AcceptControls.tsx +0 -77
- package/src/components/MergeEditor/ConflictStatus/ConflictStatusIndicator.tsx +0 -38
- package/src/components/MergeEditor/MergeEditor.stories.tsx +0 -226
- package/src/components/MergeEditor/MergeEditor.tsx +0 -125
- package/src/components/MergeEditor/MergePane.tsx +0 -113
- package/src/components/MergeEditor/PaneHeader.tsx +0 -11
- package/src/components/MergeEditor/constants.ts +0 -48
- package/src/components/MergeEditor/decorations.ts +0 -126
- package/src/components/MergeEditor/helpers.test.ts +0 -172
- package/src/components/MergeEditor/helpers.ts +0 -118
- package/src/components/MergeEditor/index.ts +0 -5
- package/src/components/MergeEditor/useMergeDiff.ts +0 -573
- package/src/components/MergeEditor/useScrollSync.ts +0 -79
- package/src/components/Modal/Modal.stories.tsx +0 -680
- package/src/components/Modal/Modal.tsx +0 -49
- package/src/components/Modal/ModalBody.tsx +0 -33
- package/src/components/Modal/ModalCloseIcon.tsx +0 -31
- package/src/components/Modal/ModalContent.tsx +0 -95
- package/src/components/Modal/ModalDescription.tsx +0 -20
- package/src/components/Modal/ModalFooter.tsx +0 -20
- package/src/components/Modal/ModalHeader.tsx +0 -61
- package/src/components/Modal/ModalIcon.tsx +0 -109
- package/src/components/Modal/ModalOverlay.tsx +0 -42
- package/src/components/Modal/ModalTitle.tsx +0 -12
- package/src/components/Modal/index.ts +0 -1
- package/src/components/Navbar/Navbar.stories.tsx +0 -191
- package/src/components/Navbar/Navbar.tsx +0 -80
- package/src/components/Navbar/NavbarContent.tsx +0 -20
- package/src/components/Navbar/NavbarFooter.tsx +0 -11
- package/src/components/Navbar/NavbarHeader.tsx +0 -11
- package/src/components/Navbar/NavbarMenu.tsx +0 -30
- package/src/components/Navbar/NavbarMenuAvatar.tsx +0 -67
- package/src/components/Navbar/NavbarMenuButton.tsx +0 -135
- package/src/components/Navbar/NavbarMenuItem.tsx +0 -9
- package/src/components/Navbar/NavbarMenuItemAdornment.tsx +0 -65
- package/src/components/Navbar/index.ts +0 -1
- package/src/components/Pagination/Pagination.stories.tsx +0 -131
- package/src/components/Pagination/Pagination.tsx +0 -34
- package/src/components/Pagination/PaginationButton.tsx +0 -36
- package/src/components/Pagination/PaginationContent.tsx +0 -12
- package/src/components/Pagination/PaginationEllipsis.tsx +0 -26
- package/src/components/Pagination/PaginationItem.tsx +0 -9
- package/src/components/Pagination/PaginationNext.tsx +0 -20
- package/src/components/Pagination/PaginationPrevious.tsx +0 -14
- package/src/components/Pagination/index.ts +0 -1
- package/src/components/PanelWithDetails.stories.tsx +0 -28
- package/src/components/PanelWithDetails.tsx +0 -65
- package/src/components/Popconfirm/Popconfirm.stories.tsx +0 -373
- package/src/components/Popconfirm/Popconfirm.tsx +0 -82
- package/src/components/Popconfirm/PopconfirmBody.tsx +0 -5
- package/src/components/Popconfirm/PopconfirmCancel.tsx +0 -45
- package/src/components/Popconfirm/PopconfirmConfirm.tsx +0 -57
- package/src/components/Popconfirm/PopconfirmContent.tsx +0 -33
- package/src/components/Popconfirm/PopconfirmFooter.tsx +0 -9
- package/src/components/Popconfirm/PopconfirmTrigger.tsx +0 -22
- package/src/components/Popconfirm/context.ts +0 -19
- package/src/components/Popconfirm/index.ts +0 -1
- package/src/components/Popover/Popover.stories.tsx +0 -85
- package/src/components/Popover/Popover.tsx +0 -15
- package/src/components/Popover/PopoverContent.tsx +0 -103
- package/src/components/Popover/index.ts +0 -1
- package/src/components/Progress/Progress.stories.tsx +0 -67
- package/src/components/Progress/Progress.tsx +0 -45
- package/src/components/Progress/index.ts +0 -1
- package/src/components/RadioGroup/Radio.tsx +0 -61
- package/src/components/RadioGroup/RadioGroup.stories.tsx +0 -300
- package/src/components/RadioGroup/RadioGroup.tsx +0 -64
- package/src/components/RadioGroup/RadioGroupItem.tsx +0 -60
- package/src/components/RadioGroup/RadioGroupItemButton.tsx +0 -79
- package/src/components/RadioGroup/RadioGroupSeparator.tsx +0 -12
- package/src/components/RadioGroup/context.ts +0 -13
- package/src/components/RadioGroup/index.ts +0 -1
- package/src/components/Resizable/Resizable.stories.tsx +0 -50
- package/src/components/Resizable/ResizableHandle.tsx +0 -50
- package/src/components/Resizable/ResizablePanel.tsx +0 -12
- package/src/components/Resizable/ResizablePanelGroup.tsx +0 -19
- package/src/components/Resizable/index.ts +0 -3
- package/src/components/ScrollArea/ScrollArea.stories.tsx +0 -43
- package/src/components/ScrollArea/ScrollArea.tsx +0 -50
- package/src/components/ScrollArea/ScrollBar.tsx +0 -32
- package/src/components/ScrollArea/index.ts +0 -2
- package/src/components/Search/ClearButton.tsx +0 -42
- package/src/components/Search/Search.stories.tsx +0 -77
- package/src/components/Search/Search.test.tsx +0 -224
- package/src/components/Search/Search.tsx +0 -139
- package/src/components/Search/SearchForm.tsx +0 -37
- package/src/components/Search/index.ts +0 -2
- package/src/components/Search/styles.ts +0 -88
- package/src/components/Search/utils.ts +0 -11
- package/src/components/Select/Select.stories.tsx +0 -109
- package/src/components/Select/Select.tsx +0 -141
- package/src/components/Select/SelectContent.tsx +0 -110
- package/src/components/Select/SelectGroup.tsx +0 -10
- package/src/components/Select/SelectItem.tsx +0 -72
- package/src/components/Select/SelectLabel.tsx +0 -32
- package/src/components/Select/SelectRoot.tsx +0 -6
- package/src/components/Select/SelectSeparator.tsx +0 -13
- package/src/components/Select/SelectTrigger.tsx +0 -161
- package/src/components/Select/index.ts +0 -1
- package/src/components/Separator/Separator.stories.tsx +0 -60
- package/src/components/Separator/Separator.test.tsx +0 -39
- package/src/components/Separator/Separator.tsx +0 -115
- package/src/components/Separator/index.ts +0 -1
- package/src/components/Sheet/Sheet.stories.tsx +0 -63
- package/src/components/Sheet/Sheet.tsx +0 -21
- package/src/components/Sheet/SheetBody.tsx +0 -12
- package/src/components/Sheet/SheetContent.tsx +0 -131
- package/src/components/Sheet/SheetFooter.tsx +0 -9
- package/src/components/Sheet/SheetHeader.tsx +0 -39
- package/src/components/Sheet/SheetOverlay.tsx +0 -11
- package/src/components/Sheet/SheetTitle.tsx +0 -12
- package/src/components/Sheet/index.ts +0 -1
- package/src/components/Sidebar/Sidebar.stories.tsx +0 -849
- package/src/components/Sidebar/Sidebar.tsx +0 -225
- package/src/components/Sidebar/SidebarContent.tsx +0 -61
- package/src/components/Sidebar/SidebarFillTrigger.tsx +0 -25
- package/src/components/Sidebar/SidebarFooter.tsx +0 -13
- package/src/components/Sidebar/SidebarGroup/SidebarGroup.tsx +0 -23
- package/src/components/Sidebar/SidebarGroup/SidebarGroupAction.tsx +0 -53
- package/src/components/Sidebar/SidebarGroup/SidebarGroupContent.tsx +0 -20
- package/src/components/Sidebar/SidebarGroup/SidebarGroupLabel.tsx +0 -76
- package/src/components/Sidebar/SidebarGroup/index.ts +0 -4
- package/src/components/Sidebar/SidebarHeader.tsx +0 -20
- package/src/components/Sidebar/SidebarInstanceContext.ts +0 -18
- package/src/components/Sidebar/SidebarMenu/SidebarMenu.tsx +0 -28
- package/src/components/Sidebar/SidebarMenu/SidebarMenuAction.tsx +0 -69
- package/src/components/Sidebar/SidebarMenu/SidebarMenuBadge.tsx +0 -56
- package/src/components/Sidebar/SidebarMenu/SidebarMenuButton.tsx +0 -110
- package/src/components/Sidebar/SidebarMenu/SidebarMenuCard.tsx +0 -108
- package/src/components/Sidebar/SidebarMenu/SidebarMenuIcon.tsx +0 -30
- package/src/components/Sidebar/SidebarMenu/SidebarMenuItem.tsx +0 -9
- package/src/components/Sidebar/SidebarMenu/SidebarMenuSub.tsx +0 -139
- package/src/components/Sidebar/SidebarMenu/SidebarMenuSubItem.tsx +0 -106
- package/src/components/Sidebar/SidebarMenu/SidebarSearchInput.tsx +0 -88
- package/src/components/Sidebar/SidebarMenu/index.ts +0 -10
- package/src/components/Sidebar/SidebarProvider/SidebarProvider.tsx +0 -171
- package/src/components/Sidebar/SidebarProvider/context.ts +0 -35
- package/src/components/Sidebar/SidebarProvider/index.ts +0 -2
- package/src/components/Sidebar/SidebarProvider/useHoverTracking.test.ts +0 -199
- package/src/components/Sidebar/SidebarProvider/useHoverTracking.ts +0 -72
- package/src/components/Sidebar/SidebarProvider/useSidebarState.ts +0 -50
- package/src/components/Sidebar/SidebarProvider/useTransitionPresence.test.ts +0 -179
- package/src/components/Sidebar/SidebarProvider/useTransitionPresence.ts +0 -53
- package/src/components/Sidebar/SidebarResizeHandle.tsx +0 -28
- package/src/components/Sidebar/SidebarSeparator.tsx +0 -15
- package/src/components/Sidebar/SidebarTrigger.tsx +0 -40
- package/src/components/Sidebar/index.ts +0 -3
- package/src/components/Sidebar/types.ts +0 -6
- package/src/components/Sidebar/useResizeSidebar.ts +0 -112
- package/src/components/Sidebar/utils.test.ts +0 -178
- package/src/components/Sidebar/utils.ts +0 -70
- package/src/components/Skeleton/Skeleton.stories.tsx +0 -106
- package/src/components/Skeleton/Skeleton.tsx +0 -77
- package/src/components/Skeleton/SkeletonList.stories.tsx +0 -11
- package/src/components/Skeleton/SkeletonList.tsx +0 -65
- package/src/components/Slider/Slider.stories.tsx +0 -99
- package/src/components/Slider/Slider.tsx +0 -85
- package/src/components/Slider/SliderThumb.tsx +0 -57
- package/src/components/Slider/SliderTrack.tsx +0 -49
- package/src/components/Slider/index.ts +0 -1
- package/src/components/Slider/useInteracting.test.ts +0 -159
- package/src/components/Slider/useInteracting.ts +0 -64
- package/src/components/Switch/Switch.stories.tsx +0 -177
- package/src/components/Switch/Switch.tsx +0 -58
- package/src/components/Switch/index.ts +0 -1
- package/src/components/Switch/styles.ts +0 -173
- package/src/components/Table/Table.stories.tsx +0 -328
- package/src/components/Table/Table.tsx +0 -68
- package/src/components/Table/TableBody.tsx +0 -22
- package/src/components/Table/TableCell.tsx +0 -7
- package/src/components/Table/TableFooter.tsx +0 -15
- package/src/components/Table/TableHead.tsx +0 -15
- package/src/components/Table/TableHeader.tsx +0 -20
- package/src/components/Table/TableRow.tsx +0 -11
- package/src/components/Table/index.ts +0 -1
- package/src/components/Tabs.stories.tsx +0 -123
- package/src/components/Tabs.tsx +0 -134
- package/src/components/ThemeProvider/AIGradientSvg.tsx +0 -18
- package/src/components/ThemeProvider/ThemeProvider.tsx +0 -25
- package/src/components/ThemeProvider/index.ts +0 -1
- package/src/components/TimePicker/TimePicker.tsx +0 -95
- package/src/components/TimePicker/TimePickerButton.tsx +0 -39
- package/src/components/TimePicker/index.ts +0 -1
- package/src/components/TimePicker/utils.ts +0 -31
- package/src/components/Timeline/Timeline.stories.tsx +0 -246
- package/src/components/Timeline/Timeline.tsx +0 -35
- package/src/components/Timeline/TimelineConnector.tsx +0 -158
- package/src/components/Timeline/TimelineContent.tsx +0 -18
- package/src/components/Timeline/TimelineItem.tsx +0 -14
- package/src/components/Timeline/index.ts +0 -1
- package/src/components/Timeline/useLastLineHeight.ts +0 -36
- package/src/components/Toast/Toast.stories.tsx +0 -178
- package/src/components/Toast/ToastAction.tsx +0 -40
- package/src/components/Toast/ToastDescription.tsx +0 -28
- package/src/components/Toast/ToastDismiss.tsx +0 -36
- package/src/components/Toast/ToastDuration.tsx +0 -43
- package/src/components/Toast/ToastRoot.tsx +0 -135
- package/src/components/Toast/ToastTitle.tsx +0 -33
- package/src/components/Toast/Toaster.tsx +0 -25
- package/src/components/Toast/index.ts +0 -3
- package/src/components/Toast/toast.tsx +0 -94
- package/src/components/Toast/useNotification.tsx +0 -33
- package/src/components/Toggle/Toggle.stories.tsx +0 -67
- package/src/components/Toggle/Toggle.tsx +0 -202
- package/src/components/Toggle/index.ts +0 -1
- package/src/components/ToggleGroup/ToggleGroup.stories.tsx +0 -60
- package/src/components/ToggleGroup/ToggleGroup.tsx +0 -99
- package/src/components/ToggleGroup/index.ts +0 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +0 -82
- package/src/components/Tooltip/Tooltip.tsx +0 -110
- package/src/components/Tooltip/TooltipContent.tsx +0 -90
- package/src/components/Tooltip/TooltipRoot.tsx +0 -12
- package/src/components/Tooltip/TooltipTrigger.tsx +0 -42
- package/src/components/Tooltip/index.ts +0 -1
- package/src/components/Truncated.stories.tsx +0 -72
- package/src/components/Truncated.tsx +0 -78
- package/src/components/ZoomableSvg/ZoomableSvg.stories.tsx +0 -53
- package/src/components/ZoomableSvg/ZoomableSvg.tsx +0 -200
- package/src/components/ZoomableSvg/index.ts +0 -1
- package/src/constants/keyCodes.ts +0 -5
- package/src/docs/Colors.mdx +0 -19
- package/src/docs/Spacing.mdx +0 -35
- package/src/docs/Typography.mdx +0 -63
- package/src/docs/components/Typeset.tsx +0 -35
- package/src/hooks/useAutosizeInput.stories.tsx +0 -142
- package/src/hooks/useAutosizeInput.test.tsx +0 -77
- package/src/hooks/useAutosizeInput.tsx +0 -107
- package/src/hooks/useElement.ts +0 -16
- package/src/hooks/useScrollbarPosition.ts +0 -68
- package/src/icon-names.ts +0 -20
- package/src/icons/Keboola.tsx +0 -28
- package/src/icons/icons.stories.tsx +0 -174
- package/src/icons/index.ts +0 -188
- package/src/index.ts +0 -90
- package/src/patterns/AlertWithAction.stories.tsx +0 -30
- package/src/patterns/CardWithEmptyState.stories.tsx +0 -66
- package/src/patterns/ConfirmDialog.stories.tsx +0 -72
- package/src/patterns/CreatableMultiCombobox.stories.tsx +0 -33
- package/src/patterns/DataCardWithSkeleton.stories.tsx +0 -48
- package/src/patterns/DisabledButtonTooltip.stories.tsx +0 -30
- package/src/patterns/FilterToolbar.stories.tsx +0 -275
- package/src/patterns/InfoTooltip.stories.tsx +0 -56
- package/src/patterns/ListDetail.stories.tsx +0 -65
- package/src/patterns/ModalForm.stories.tsx +0 -59
- package/src/patterns/PageHeaderTabs.stories.tsx +0 -48
- package/src/utils/classNames.test.ts +0 -16
- package/src/utils/classNames.ts +0 -27
- package/src/utils/copyToClipboard.ts +0 -3
- package/src/utils/createChangeInputEvent.ts +0 -28
- package/src/utils/createPrefixedString.ts +0 -2
- package/src/utils/debounce.test.ts +0 -63
- package/src/utils/debounce.ts +0 -17
- package/src/utils/decorators.tsx +0 -16
- package/src/utils/escapeStringRegexp.ts +0 -4
- package/src/utils/index.ts +0 -11
- package/src/utils/isMac.ts +0 -26
- package/src/utils/legacyIcon.tsx +0 -28
- package/src/utils/mergeRefs.ts +0 -23
- package/src/utils/noop.ts +0 -1
- package/src/utils/useSHA256.ts +0 -21
- package/src/vite-env.d.ts +0 -1
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { CodeNode } from '@lexical/code';
|
|
2
|
-
import { LinkNode } from '@lexical/link';
|
|
3
|
-
import { ListItemNode, ListNode } from '@lexical/list';
|
|
4
|
-
import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
|
|
5
|
-
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
6
|
-
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
7
|
-
import { createEditor } from 'lexical';
|
|
8
|
-
import { describe, expect, test } from 'vitest';
|
|
9
|
-
|
|
10
|
-
import { ImageNode } from './nodes/ImageNode';
|
|
11
|
-
import { MermaidNode } from './nodes/MermaidNode';
|
|
12
|
-
import { CUSTOM_TRANSFORMERS, postprocessMarkdown, preprocessMarkdown } from './transformers';
|
|
13
|
-
|
|
14
|
-
const EDITOR_NODES = [
|
|
15
|
-
ImageNode,
|
|
16
|
-
MermaidNode,
|
|
17
|
-
HeadingNode,
|
|
18
|
-
QuoteNode,
|
|
19
|
-
ListNode,
|
|
20
|
-
ListItemNode,
|
|
21
|
-
CodeNode,
|
|
22
|
-
LinkNode,
|
|
23
|
-
HorizontalRuleNode,
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const roundTrip = (markdown: string): string => {
|
|
27
|
-
const editor = createEditor({
|
|
28
|
-
nodes: EDITOR_NODES,
|
|
29
|
-
onError: (e) => {
|
|
30
|
-
throw e;
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const container = document.createElement('div');
|
|
35
|
-
editor.setRootElement(container);
|
|
36
|
-
|
|
37
|
-
editor.update(
|
|
38
|
-
() => {
|
|
39
|
-
$convertFromMarkdownString(preprocessMarkdown(markdown), CUSTOM_TRANSFORMERS);
|
|
40
|
-
},
|
|
41
|
-
{ discrete: true },
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
let result = '';
|
|
45
|
-
editor.getEditorState().read(() => {
|
|
46
|
-
result = postprocessMarkdown($convertToMarkdownString(CUSTOM_TRANSFORMERS));
|
|
47
|
-
});
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
describe('Markdown round-trip', () => {
|
|
52
|
-
test('empty string', () => {
|
|
53
|
-
expect(roundTrip('')).toBe('');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('single paragraph', () => {
|
|
57
|
-
expect(roundTrip('Hello world')).toBe('Hello world');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('multiple paragraphs', () => {
|
|
61
|
-
const md = 'First paragraph\n\nSecond paragraph';
|
|
62
|
-
expect(roundTrip(md)).toBe(md);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('headings', () => {
|
|
66
|
-
const md = '# Heading 1\n\n## Heading 2\n\n### Heading 3';
|
|
67
|
-
expect(roundTrip(md)).toBe(md);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('bold and italic', () => {
|
|
71
|
-
const md = 'Some **bold** and *italic* text';
|
|
72
|
-
expect(roundTrip(md)).toBe(md);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('strikethrough', () => {
|
|
76
|
-
const md = 'Some ~~deleted~~ text';
|
|
77
|
-
expect(roundTrip(md)).toBe(md);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('inline code', () => {
|
|
81
|
-
const md = 'Use `console.log()` for debugging';
|
|
82
|
-
expect(roundTrip(md)).toBe(md);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('unordered list', () => {
|
|
86
|
-
const md = '- Item one\n- Item two\n- Item three';
|
|
87
|
-
expect(roundTrip(md)).toBe(md);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('ordered list', () => {
|
|
91
|
-
const md = '1. First\n2. Second\n3. Third';
|
|
92
|
-
expect(roundTrip(md)).toBe(md);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('code block with language', () => {
|
|
96
|
-
const md = '```javascript\nconst x = 1;\nconsole.log(x);\n```';
|
|
97
|
-
expect(roundTrip(md)).toBe(md);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('code block (snowflake)', () => {
|
|
101
|
-
const md = '```snowflake\nSELECT * FROM table;\n```';
|
|
102
|
-
expect(roundTrip(md)).toBe(md);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test('link', () => {
|
|
106
|
-
const md = 'Visit [Google](https://google.com) for search';
|
|
107
|
-
expect(roundTrip(md)).toBe(md);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('image with regular URL', () => {
|
|
111
|
-
const md = '';
|
|
112
|
-
expect(roundTrip(md)).toBe(md);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('image with kbc-file URL', () => {
|
|
116
|
-
const md = '';
|
|
117
|
-
expect(roundTrip(md)).toBe(md);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test('blockquote', () => {
|
|
121
|
-
const md = '> This is a quote';
|
|
122
|
-
expect(roundTrip(md)).toBe(md);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('horizontal rule', () => {
|
|
126
|
-
const md = 'Above\n\n---\n\nBelow';
|
|
127
|
-
expect(roundTrip(md)).toBe(md);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('GFM table (preserved via code fence)', () => {
|
|
131
|
-
const md = ['| Header 1 | Header 2 |', '| --- | --- |', '| Cell 1 | Cell 2 |'].join('\n');
|
|
132
|
-
expect(roundTrip(md)).toBe(md);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('mermaid diagram', () => {
|
|
136
|
-
const md = '```mermaid\ngraph TD\n A --> B\n```';
|
|
137
|
-
expect(roundTrip(md)).toBe(md);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe('Table preprocessing', () => {
|
|
142
|
-
test('wraps tables in code fences', () => {
|
|
143
|
-
const input = '| A | B |\n| --- | --- |\n| 1 | 2 |';
|
|
144
|
-
const result = preprocessMarkdown(input);
|
|
145
|
-
expect(result).toContain('```__kbc_table__');
|
|
146
|
-
expect(result).toContain('| A | B |');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test('unwraps code-fenced tables', () => {
|
|
150
|
-
const input = '```__kbc_table__\n| A | B |\n| --- | --- |\n| 1 | 2 |\n```';
|
|
151
|
-
expect(postprocessMarkdown(input)).toBe('| A | B |\n| --- | --- |\n| 1 | 2 |');
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test('does not wrap single pipe line', () => {
|
|
155
|
-
const input = '| just a pipe |';
|
|
156
|
-
expect(preprocessMarkdown(input)).toBe(input);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test('handles table surrounded by paragraphs', () => {
|
|
160
|
-
const input = 'Before\n\n| A | B |\n| --- | --- |\n| 1 | 2 |\n\nAfter';
|
|
161
|
-
const processed = preprocessMarkdown(input);
|
|
162
|
-
expect(processed).toContain('```__kbc_table__');
|
|
163
|
-
expect(processed).toContain('Before');
|
|
164
|
-
expect(processed).toContain('After');
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test('does not wrap pipe lines inside fenced code blocks', () => {
|
|
168
|
-
const input = '```\n| A | B |\n| --- | --- |\n| 1 | 2 |\n```';
|
|
169
|
-
expect(preprocessMarkdown(input)).toBe(input);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { useRef, useState } from 'react';
|
|
2
|
-
import type { FocusEvent, ReactNode } from 'react';
|
|
3
|
-
import { CodeNode } from '@lexical/code';
|
|
4
|
-
import { LinkNode } from '@lexical/link';
|
|
5
|
-
import { ListItemNode, ListNode } from '@lexical/list';
|
|
6
|
-
import { $convertFromMarkdownString } from '@lexical/markdown';
|
|
7
|
-
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
8
|
-
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
9
|
-
import { ClickableLinkPlugin } from '@lexical/react/LexicalClickableLinkPlugin';
|
|
10
|
-
import type { InitialConfigType } from '@lexical/react/LexicalComposer';
|
|
11
|
-
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
12
|
-
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
13
|
-
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
14
|
-
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
15
|
-
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
16
|
-
import { HorizontalRulePlugin } from '@lexical/react/LexicalHorizontalRulePlugin';
|
|
17
|
-
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
18
|
-
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
19
|
-
import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin';
|
|
20
|
-
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
21
|
-
import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
|
|
22
|
-
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
23
|
-
|
|
24
|
-
import { cn } from '../../utils';
|
|
25
|
-
|
|
26
|
-
import { ImageNode } from './nodes/ImageNode';
|
|
27
|
-
import { MermaidNode } from './nodes/MermaidNode';
|
|
28
|
-
import { ImagePastePlugin } from './plugins/ImagePastePlugin';
|
|
29
|
-
import { KeyboardPlugin } from './plugins/KeyboardPlugin';
|
|
30
|
-
import { MarkdownSyncPlugin } from './plugins/MarkdownSyncPlugin';
|
|
31
|
-
import { ToolbarPlugin } from './plugins/ToolbarPlugin';
|
|
32
|
-
import { ImageRendererProvider } from './context';
|
|
33
|
-
import { editorTheme } from './theme';
|
|
34
|
-
import { CUSTOM_TRANSFORMERS, preprocessMarkdown, SINGLE_LINE_TRANSFORMERS } from './transformers';
|
|
35
|
-
|
|
36
|
-
export type MarkdownEditorProps = {
|
|
37
|
-
/** Markdown string (controlled) */
|
|
38
|
-
value: string;
|
|
39
|
-
onChange?: (markdown: string) => void;
|
|
40
|
-
/**
|
|
41
|
-
* Renders content but never accepts input. Use for permanent view-only contexts
|
|
42
|
-
* (e.g. a current user lacks edit permission). Toolbar is hidden.
|
|
43
|
-
*/
|
|
44
|
-
readOnly?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Temporarily blocks input but signals intent to re-enable
|
|
47
|
-
* (e.g. while a save is in flight). Functionally identical to `readOnly` today.
|
|
48
|
-
*/
|
|
49
|
-
disabled?: boolean;
|
|
50
|
-
placeholder?: string;
|
|
51
|
-
autoFocus?: boolean;
|
|
52
|
-
/** Invoked on Cmd/Ctrl+Enter — typically used to commit a form. */
|
|
53
|
-
onSave?: () => void;
|
|
54
|
-
/**
|
|
55
|
-
* Invoked on Escape in inline-edit mode (`singleLine || saveOnBlur`). Per the
|
|
56
|
-
* inline-editable-text pattern spec, Esc reverts the in-progress edit — callers
|
|
57
|
-
* reset `value` to the last-committed state inside this handler.
|
|
58
|
-
*/
|
|
59
|
-
onCancel?: () => void;
|
|
60
|
-
/**
|
|
61
|
-
* Async image upload. Resolved URL is embedded as the image src
|
|
62
|
-
* (`` in the underlying markdown).
|
|
63
|
-
*/
|
|
64
|
-
onImageUpload?: (file: File) => Promise<{ url: string }>;
|
|
65
|
-
className?: string;
|
|
66
|
-
imageRenderer?: (props: { src: string; alt: string }) => ReactNode;
|
|
67
|
-
showToolbar?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Strips the prose typography wrapper, removes the min-height, and tightens padding so
|
|
70
|
-
* the editor visually blends with surrounding text. Use for inline / Linear-style edit
|
|
71
|
-
* affordances inside headings, list rows, or table cells. Pair with `className` to set
|
|
72
|
-
* the caller's typography.
|
|
73
|
-
*/
|
|
74
|
-
compact?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Calls `onSave` when focus leaves the editor (and is not moved into the toolbar).
|
|
77
|
-
* `onChange` already keeps the caller's value in sync — `onSave` is the "commit" signal.
|
|
78
|
-
*/
|
|
79
|
-
saveOnBlur?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Disables block-level markdown (lists, headings, code blocks, HR) and makes a plain
|
|
82
|
-
* Enter press trigger `onSave` and blur the editor. Shift+Enter still inserts a soft
|
|
83
|
-
* line break. Use for editable titles.
|
|
84
|
-
*/
|
|
85
|
-
singleLine?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Clamps content to ~2 lines with a bottom fade in the display (not-focused) state;
|
|
88
|
-
* focus expands the editor to full height (no clamp). Per the inline-editable-text
|
|
89
|
-
* pattern spec for description-style slots — fade replaces truncation/ellipsis.
|
|
90
|
-
*/
|
|
91
|
-
clampDisplay?: boolean;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const EDITOR_NODES = [
|
|
95
|
-
ImageNode,
|
|
96
|
-
MermaidNode,
|
|
97
|
-
HeadingNode,
|
|
98
|
-
QuoteNode,
|
|
99
|
-
ListNode,
|
|
100
|
-
ListItemNode,
|
|
101
|
-
CodeNode,
|
|
102
|
-
LinkNode,
|
|
103
|
-
HorizontalRuleNode,
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
export const MarkdownEditor = ({
|
|
107
|
-
value,
|
|
108
|
-
onChange,
|
|
109
|
-
readOnly = false,
|
|
110
|
-
placeholder,
|
|
111
|
-
autoFocus = false,
|
|
112
|
-
disabled = false,
|
|
113
|
-
onSave,
|
|
114
|
-
onCancel,
|
|
115
|
-
onImageUpload,
|
|
116
|
-
className,
|
|
117
|
-
imageRenderer,
|
|
118
|
-
showToolbar = false,
|
|
119
|
-
compact = false,
|
|
120
|
-
saveOnBlur = false,
|
|
121
|
-
singleLine = false,
|
|
122
|
-
clampDisplay = false,
|
|
123
|
-
}: MarkdownEditorProps) => {
|
|
124
|
-
const editable = !readOnly && !disabled;
|
|
125
|
-
const transformers = singleLine ? SINGLE_LINE_TRANSFORMERS : CUSTOM_TRANSFORMERS;
|
|
126
|
-
|
|
127
|
-
// Lexical reads editorState only on first render; later prop changes are applied by MarkdownSyncPlugin.
|
|
128
|
-
const [initialConfig] = useState<InitialConfigType>(() => ({
|
|
129
|
-
namespace: 'MarkdownEditor',
|
|
130
|
-
theme: editorTheme,
|
|
131
|
-
nodes: EDITOR_NODES,
|
|
132
|
-
onError: (error: Error) => {
|
|
133
|
-
console.error('[MarkdownEditor] uncaught editor error', error);
|
|
134
|
-
},
|
|
135
|
-
editable,
|
|
136
|
-
editorState: () => {
|
|
137
|
-
$convertFromMarkdownString(preprocessMarkdown(value), transformers);
|
|
138
|
-
},
|
|
139
|
-
}));
|
|
140
|
-
|
|
141
|
-
// Set to `true` by KeyboardPlugin before it programmatically blurs on Escape so the
|
|
142
|
-
// blur handler can skip its `onSave` — otherwise blur-after-cancel would commit the
|
|
143
|
-
// value we just reverted. Reset on read inside handleBlur.
|
|
144
|
-
const skipBlurSaveRef = useRef(false);
|
|
145
|
-
|
|
146
|
-
const handleBlur =
|
|
147
|
-
saveOnBlur && onSave
|
|
148
|
-
? (event: FocusEvent<HTMLDivElement>) => {
|
|
149
|
-
if (skipBlurSaveRef.current) {
|
|
150
|
-
skipBlurSaveRef.current = false;
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
// Only fire when focus leaves the editor wrapper entirely (not when moving into the toolbar).
|
|
154
|
-
if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {
|
|
155
|
-
onSave();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
: undefined;
|
|
159
|
-
|
|
160
|
-
return (
|
|
161
|
-
<LexicalComposer initialConfig={initialConfig}>
|
|
162
|
-
<ImageRendererProvider value={imageRenderer ?? null}>
|
|
163
|
-
<div
|
|
164
|
-
className={cn(
|
|
165
|
-
!compact && 'tw-prose',
|
|
166
|
-
// Compact mode drops `tw-prose`, so Lexical's <p> wrappers fall back to the browser
|
|
167
|
-
// default `margin: 1em 0` — visually huge at heading sizes. Zero them, and use the
|
|
168
|
-
// adjacent-sibling selector for paragraph spacing so single-paragraph blocks (titles,
|
|
169
|
-
// short descriptions) stay tight while multi-paragraph blocks still breathe.
|
|
170
|
-
compact && '[&_p]:tw-m-0 [&_p+p]:tw-mt-2',
|
|
171
|
-
// Display-state clamp: 2 lines + bottom fade. Drops in focus-within so editing
|
|
172
|
-
// expands to full height. Fade replaces ellipsis per the pattern spec — the
|
|
173
|
-
// mask gradient overlays line-clamp's default ellipsis so it's invisible.
|
|
174
|
-
clampDisplay &&
|
|
175
|
-
'[&:not(:focus-within)]:tw-line-clamp-2 [&:not(:focus-within)]:[mask-image:linear-gradient(to_bottom,black_50%,transparent)]',
|
|
176
|
-
className,
|
|
177
|
-
)}
|
|
178
|
-
onBlur={handleBlur}
|
|
179
|
-
>
|
|
180
|
-
{showToolbar && editable && <ToolbarPlugin />}
|
|
181
|
-
<div
|
|
182
|
-
className={cn(
|
|
183
|
-
'tw-relative tw-rounded-md tw-transition-colors',
|
|
184
|
-
// In compact mode the padding lets the hover bg / focus ring extend past the text,
|
|
185
|
-
// but a matching negative margin shifts the wrapper outward so the text itself stays
|
|
186
|
-
// aligned with the parent's content edge (i.e. with where static text would render).
|
|
187
|
-
compact ? 'tw-px-1.5 tw-py-0.5 -tw-mx-1.5 -tw-my-0.5' : 'tw-p-2',
|
|
188
|
-
editable &&
|
|
189
|
-
'tw-cursor-text hover:tw-bg-neutral-50 focus-within:tw-ring-2 focus-within:tw-ring-secondary-500/40',
|
|
190
|
-
)}
|
|
191
|
-
>
|
|
192
|
-
<RichTextPlugin
|
|
193
|
-
contentEditable={
|
|
194
|
-
<ContentEditable
|
|
195
|
-
className={cn('tw-outline-none', !compact && 'tw-min-h-[100px]')}
|
|
196
|
-
aria-placeholder={placeholder ?? ''}
|
|
197
|
-
placeholder={
|
|
198
|
-
placeholder ? (
|
|
199
|
-
<div
|
|
200
|
-
className={cn(
|
|
201
|
-
'tw-pointer-events-none tw-absolute tw-select-none tw-text-neutral-400',
|
|
202
|
-
compact
|
|
203
|
-
? 'tw-left-1.5 tw-top-0.5'
|
|
204
|
-
: 'tw-left-2 tw-top-[calc(0.5rem+0.35em)]',
|
|
205
|
-
)}
|
|
206
|
-
>
|
|
207
|
-
{placeholder}
|
|
208
|
-
</div>
|
|
209
|
-
) : (
|
|
210
|
-
<div />
|
|
211
|
-
)
|
|
212
|
-
}
|
|
213
|
-
/>
|
|
214
|
-
}
|
|
215
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
216
|
-
/>
|
|
217
|
-
</div>
|
|
218
|
-
<HistoryPlugin />
|
|
219
|
-
<LinkPlugin />
|
|
220
|
-
<ClickableLinkPlugin newTab />
|
|
221
|
-
{!singleLine && <ListPlugin />}
|
|
222
|
-
{!singleLine && <CheckListPlugin />}
|
|
223
|
-
{!singleLine && <HorizontalRulePlugin />}
|
|
224
|
-
<TabIndentationPlugin />
|
|
225
|
-
<MarkdownShortcutPlugin transformers={transformers} />
|
|
226
|
-
<MarkdownSyncPlugin
|
|
227
|
-
value={value}
|
|
228
|
-
editable={editable}
|
|
229
|
-
onChange={onChange}
|
|
230
|
-
transformers={transformers}
|
|
231
|
-
/>
|
|
232
|
-
<ImagePastePlugin onImageUpload={onImageUpload} />
|
|
233
|
-
<KeyboardPlugin
|
|
234
|
-
onSave={onSave}
|
|
235
|
-
onCancel={onCancel}
|
|
236
|
-
singleLine={singleLine}
|
|
237
|
-
blurOnEscape={singleLine || saveOnBlur}
|
|
238
|
-
skipBlurSaveRef={skipBlurSaveRef}
|
|
239
|
-
/>
|
|
240
|
-
{autoFocus && <AutoFocusPlugin />}
|
|
241
|
-
</div>
|
|
242
|
-
</ImageRendererProvider>
|
|
243
|
-
</LexicalComposer>
|
|
244
|
-
);
|
|
245
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createContext, use } from 'react';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
type ImageRenderer = (props: { src: string; alt: string }) => ReactNode;
|
|
5
|
-
|
|
6
|
-
const ImageRendererContext = createContext<ImageRenderer | null>(null);
|
|
7
|
-
|
|
8
|
-
export const ImageRendererProvider = ImageRendererContext;
|
|
9
|
-
|
|
10
|
-
export const useImageRenderer = (): ImageRenderer | null => use(ImageRendererContext);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/only-export-components -- Lexical convention: $create/$is helpers co-locate with node */
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
DOMConversionMap,
|
|
5
|
-
DOMExportOutput,
|
|
6
|
-
EditorConfig,
|
|
7
|
-
LexicalNode,
|
|
8
|
-
NodeKey,
|
|
9
|
-
SerializedLexicalNode,
|
|
10
|
-
Spread,
|
|
11
|
-
} from 'lexical';
|
|
12
|
-
import { DecoratorNode } from 'lexical';
|
|
13
|
-
|
|
14
|
-
import { ImageNodeComponent } from './ImageNodeComponent';
|
|
15
|
-
|
|
16
|
-
type SerializedImageNode = Spread<{ src: string; altText: string }, SerializedLexicalNode>;
|
|
17
|
-
|
|
18
|
-
export class ImageNode extends DecoratorNode<ReactNode> {
|
|
19
|
-
__src: string;
|
|
20
|
-
__altText: string;
|
|
21
|
-
|
|
22
|
-
static override getType(): string {
|
|
23
|
-
return 'image';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static override clone(node: ImageNode): ImageNode {
|
|
27
|
-
return new ImageNode(node.__src, node.__altText, node.__key);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
constructor(src: string, altText: string, key?: NodeKey) {
|
|
31
|
-
super(key);
|
|
32
|
-
this.__src = src;
|
|
33
|
-
this.__altText = altText;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getSrc(): string {
|
|
37
|
-
return this.__src;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getAlt(): string {
|
|
41
|
-
return this.__altText;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
setSrc(src: string): void {
|
|
45
|
-
const writable = this.getWritable();
|
|
46
|
-
writable.__src = src;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
setAlt(altText: string): void {
|
|
50
|
-
const writable = this.getWritable();
|
|
51
|
-
writable.__altText = altText;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
override createDOM(config: EditorConfig): HTMLElement {
|
|
55
|
-
const span = document.createElement('span');
|
|
56
|
-
const className = config.theme.image;
|
|
57
|
-
if (typeof className === 'string') {
|
|
58
|
-
span.className = className;
|
|
59
|
-
}
|
|
60
|
-
return span;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override updateDOM(): boolean {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override decorate(): ReactNode {
|
|
68
|
-
return <ImageNodeComponent src={this.__src} alt={this.__altText} />;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
override isInline(): boolean {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static override importJSON(serializedNode: SerializedImageNode): ImageNode {
|
|
76
|
-
return $createImageNode(serializedNode.src, serializedNode.altText);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
override exportJSON(): SerializedImageNode {
|
|
80
|
-
return {
|
|
81
|
-
type: 'image',
|
|
82
|
-
version: 1,
|
|
83
|
-
src: this.__src,
|
|
84
|
-
altText: this.__altText,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
override exportDOM(): DOMExportOutput {
|
|
89
|
-
const element = document.createElement('img');
|
|
90
|
-
element.setAttribute('src', this.__src);
|
|
91
|
-
element.setAttribute('alt', this.__altText);
|
|
92
|
-
return { element };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
static override importDOM(): DOMConversionMap | null {
|
|
96
|
-
return {
|
|
97
|
-
img: () => ({
|
|
98
|
-
conversion: (domNode: HTMLElement) => {
|
|
99
|
-
const src = domNode.getAttribute('src') || '';
|
|
100
|
-
const alt = domNode.getAttribute('alt') || '';
|
|
101
|
-
return { node: $createImageNode(src, alt) };
|
|
102
|
-
},
|
|
103
|
-
priority: 0,
|
|
104
|
-
}),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const $createImageNode = (src: string, altText: string): ImageNode => {
|
|
110
|
-
return new ImageNode(src, altText);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const $isImageNode = (node: LexicalNode | null | undefined): node is ImageNode => {
|
|
114
|
-
return node instanceof ImageNode;
|
|
115
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useImageRenderer } from '../context';
|
|
2
|
-
|
|
3
|
-
const isPlaceholder = (src: string) => src.startsWith('upload-placeholder-');
|
|
4
|
-
|
|
5
|
-
export const ImageNodeComponent = ({ src, alt }: { src: string; alt: string }) => {
|
|
6
|
-
const renderer = useImageRenderer();
|
|
7
|
-
|
|
8
|
-
if (isPlaceholder(src)) {
|
|
9
|
-
return (
|
|
10
|
-
<span 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">
|
|
11
|
-
Uploading image…
|
|
12
|
-
</span>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (renderer) return <>{renderer({ src, alt })}</>;
|
|
17
|
-
return <img src={src} alt={alt} />;
|
|
18
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/only-export-components -- Lexical convention: $create/$is helpers co-locate with node */
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
import type { LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
4
|
-
import { DecoratorNode } from 'lexical';
|
|
5
|
-
|
|
6
|
-
import { MermaidNodeComponent } from './MermaidNodeComponent';
|
|
7
|
-
|
|
8
|
-
type SerializedMermaidNode = Spread<{ code: string }, SerializedLexicalNode>;
|
|
9
|
-
|
|
10
|
-
export class MermaidNode extends DecoratorNode<ReactNode> {
|
|
11
|
-
__code: string;
|
|
12
|
-
|
|
13
|
-
static override getType(): string {
|
|
14
|
-
return 'mermaid';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static override clone(node: MermaidNode): MermaidNode {
|
|
18
|
-
return new MermaidNode(node.__code, node.__key);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
constructor(code: string, key?: NodeKey) {
|
|
22
|
-
super(key);
|
|
23
|
-
this.__code = code;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getCode(): string {
|
|
27
|
-
return this.__code;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
setCode(code: string): void {
|
|
31
|
-
const writable = this.getWritable();
|
|
32
|
-
writable.__code = code;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
override createDOM(): HTMLElement {
|
|
36
|
-
const div = document.createElement('div');
|
|
37
|
-
div.setAttribute('data-lexical-mermaid', 'true');
|
|
38
|
-
return div;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
override updateDOM(): boolean {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
override decorate(): ReactNode {
|
|
46
|
-
return <MermaidNodeComponent code={this.__code} />;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
override isInline(): boolean {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static override importJSON(serializedNode: SerializedMermaidNode): MermaidNode {
|
|
54
|
-
return $createMermaidNode(serializedNode.code);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
override exportJSON(): SerializedMermaidNode {
|
|
58
|
-
return {
|
|
59
|
-
type: 'mermaid',
|
|
60
|
-
version: 1,
|
|
61
|
-
code: this.__code,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const $createMermaidNode = (code: string): MermaidNode => {
|
|
67
|
-
return new MermaidNode(code);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const $isMermaidNode = (node: LexicalNode | null | undefined): node is MermaidNode => {
|
|
71
|
-
return node instanceof MermaidNode;
|
|
72
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { lazy, Suspense } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Skeleton } from '../../../components/Skeleton/Skeleton';
|
|
4
|
-
|
|
5
|
-
const MermaidDiagram = lazy(() =>
|
|
6
|
-
import('../../../blocks/MermaidDiagram/MermaidDiagram').then(
|
|
7
|
-
(m) => ({ default: m.MermaidDiagram }),
|
|
8
|
-
(error: unknown) => {
|
|
9
|
-
// Falling back to raw code on chunk-load failure (typically a stale tab after deploy).
|
|
10
|
-
// Logging so we don't silently swap implementations.
|
|
11
|
-
console.error('[MarkdownEditor] failed to load MermaidDiagram chunk', error);
|
|
12
|
-
return {
|
|
13
|
-
default: ({ code }: { code: string }) => (
|
|
14
|
-
<pre>
|
|
15
|
-
<code>{code}</code>
|
|
16
|
-
</pre>
|
|
17
|
-
),
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export const MermaidNodeComponent = ({ code }: { code: string }) => {
|
|
24
|
-
return (
|
|
25
|
-
<Suspense
|
|
26
|
-
fallback={
|
|
27
|
-
<div className="tw-my-3 tw-overflow-hidden tw-rounded-card tw-border tw-border-neutral-150 tw-bg-neutral-50 tw-p-6">
|
|
28
|
-
<Skeleton className="tw-h-40" />
|
|
29
|
-
</div>
|
|
30
|
-
}
|
|
31
|
-
>
|
|
32
|
-
<MermaidDiagram code={code} />
|
|
33
|
-
</Suspense>
|
|
34
|
-
);
|
|
35
|
-
};
|