svelora 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/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/Accordion/Accordion.svelte +207 -0
- package/dist/Accordion/Accordion.svelte.d.ts +6 -0
- package/dist/Accordion/accordion.types.d.ts +225 -0
- package/dist/Accordion/accordion.types.js +1 -0
- package/dist/Accordion/accordion.variants.d.ts +88 -0
- package/dist/Accordion/accordion.variants.js +28 -0
- package/dist/Accordion/index.d.ts +2 -0
- package/dist/Accordion/index.js +1 -0
- package/dist/Alert/Alert.svelte +131 -0
- package/dist/Alert/Alert.svelte.d.ts +5 -0
- package/dist/Alert/alert.types.d.ts +103 -0
- package/dist/Alert/alert.types.js +1 -0
- package/dist/Alert/alert.variants.d.ts +213 -0
- package/dist/Alert/alert.variants.js +293 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/index.js +1 -0
- package/dist/Avatar/Avatar.svelte +114 -0
- package/dist/Avatar/Avatar.svelte.d.ts +6 -0
- package/dist/Avatar/avatar.types.d.ts +73 -0
- package/dist/Avatar/avatar.types.js +1 -0
- package/dist/Avatar/avatar.variants.d.ts +316 -0
- package/dist/Avatar/avatar.variants.js +39 -0
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Avatar/index.js +1 -0
- package/dist/AvatarGroup/AvatarGroup.svelte +71 -0
- package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +5 -0
- package/dist/AvatarGroup/avatar-group.types.d.ts +49 -0
- package/dist/AvatarGroup/avatar-group.types.js +1 -0
- package/dist/AvatarGroup/avatar-group.variants.d.ts +258 -0
- package/dist/AvatarGroup/avatar-group.variants.js +35 -0
- package/dist/AvatarGroup/index.d.ts +2 -0
- package/dist/AvatarGroup/index.js +1 -0
- package/dist/Badge/Badge.svelte +79 -0
- package/dist/Badge/Badge.svelte.d.ts +5 -0
- package/dist/Badge/badge.types.d.ts +83 -0
- package/dist/Badge/badge.types.js +1 -0
- package/dist/Badge/badge.variants.d.ts +303 -0
- package/dist/Badge/badge.variants.js +259 -0
- package/dist/Badge/index.d.ts +2 -0
- package/dist/Badge/index.js +1 -0
- package/dist/Banner/Banner.svelte +130 -0
- package/dist/Banner/Banner.svelte.d.ts +5 -0
- package/dist/Banner/banner.types.d.ts +148 -0
- package/dist/Banner/banner.types.js +1 -0
- package/dist/Banner/banner.variants.d.ts +293 -0
- package/dist/Banner/banner.variants.js +86 -0
- package/dist/Banner/index.d.ts +2 -0
- package/dist/Banner/index.js +1 -0
- package/dist/Breadcrumb/Breadcrumb.svelte +79 -0
- package/dist/Breadcrumb/Breadcrumb.svelte.d.ts +5 -0
- package/dist/Breadcrumb/breadcrumb.types.d.ts +66 -0
- package/dist/Breadcrumb/breadcrumb.types.js +1 -0
- package/dist/Breadcrumb/breadcrumb.variants.d.ts +138 -0
- package/dist/Breadcrumb/breadcrumb.variants.js +53 -0
- package/dist/Breadcrumb/index.d.ts +2 -0
- package/dist/Breadcrumb/index.js +1 -0
- package/dist/Button/Button.svelte +177 -0
- package/dist/Button/Button.svelte.d.ts +5 -0
- package/dist/Button/button.types.d.ts +151 -0
- package/dist/Button/button.types.js +1 -0
- package/dist/Button/button.variants.d.ts +388 -0
- package/dist/Button/button.variants.js +461 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/index.js +1 -0
- package/dist/Calendar/Calendar.svelte +344 -0
- package/dist/Calendar/Calendar.svelte.d.ts +6 -0
- package/dist/Calendar/calendar.types.d.ts +122 -0
- package/dist/Calendar/calendar.types.js +1 -0
- package/dist/Calendar/calendar.variants.d.ts +553 -0
- package/dist/Calendar/calendar.variants.js +368 -0
- package/dist/Calendar/index.d.ts +2 -0
- package/dist/Calendar/index.js +1 -0
- package/dist/Card/Card.svelte +54 -0
- package/dist/Card/Card.svelte.d.ts +5 -0
- package/dist/Card/card.types.d.ts +36 -0
- package/dist/Card/card.types.js +1 -0
- package/dist/Card/card.variants.d.ts +108 -0
- package/dist/Card/card.variants.js +32 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/Card/index.js +1 -0
- package/dist/Carousel/Carousel.svelte +277 -0
- package/dist/Carousel/Carousel.svelte.d.ts +26 -0
- package/dist/Carousel/carousel.types.d.ts +251 -0
- package/dist/Carousel/carousel.types.js +1 -0
- package/dist/Carousel/carousel.variants.d.ts +408 -0
- package/dist/Carousel/carousel.variants.js +88 -0
- package/dist/Carousel/index.d.ts +2 -0
- package/dist/Carousel/index.js +1 -0
- package/dist/Checkbox/Checkbox.svelte +161 -0
- package/dist/Checkbox/Checkbox.svelte.d.ts +6 -0
- package/dist/Checkbox/checkbox.types.d.ts +101 -0
- package/dist/Checkbox/checkbox.types.js +1 -0
- package/dist/Checkbox/checkbox.variants.d.ts +448 -0
- package/dist/Checkbox/checkbox.variants.js +209 -0
- package/dist/Checkbox/index.d.ts +2 -0
- package/dist/Checkbox/index.js +1 -0
- package/dist/CheckboxGroup/CheckboxGroup.svelte +219 -0
- package/dist/CheckboxGroup/CheckboxGroup.svelte.d.ts +5 -0
- package/dist/CheckboxGroup/checkbox-group.types.d.ts +130 -0
- package/dist/CheckboxGroup/checkbox-group.types.js +1 -0
- package/dist/CheckboxGroup/checkbox-group.variants.d.ts +553 -0
- package/dist/CheckboxGroup/checkbox-group.variants.js +231 -0
- package/dist/CheckboxGroup/index.d.ts +2 -0
- package/dist/CheckboxGroup/index.js +1 -0
- package/dist/Chip/Chip.svelte +51 -0
- package/dist/Chip/Chip.svelte.d.ts +5 -0
- package/dist/Chip/chip.types.d.ts +66 -0
- package/dist/Chip/chip.types.js +1 -0
- package/dist/Chip/chip.variants.d.ts +418 -0
- package/dist/Chip/chip.variants.js +74 -0
- package/dist/Chip/index.d.ts +2 -0
- package/dist/Chip/index.js +1 -0
- package/dist/Collapsible/Collapsible.svelte +69 -0
- package/dist/Collapsible/Collapsible.svelte.d.ts +6 -0
- package/dist/Collapsible/CollapsibleTestWrapper.svelte +17 -0
- package/dist/Collapsible/CollapsibleTestWrapper.svelte.d.ts +4 -0
- package/dist/Collapsible/collapsible.types.d.ts +77 -0
- package/dist/Collapsible/collapsible.types.js +1 -0
- package/dist/Collapsible/collapsible.variants.d.ts +53 -0
- package/dist/Collapsible/collapsible.variants.js +21 -0
- package/dist/Collapsible/index.d.ts +2 -0
- package/dist/Collapsible/index.js +1 -0
- package/dist/Command/Command.svelte +183 -0
- package/dist/Command/Command.svelte.d.ts +6 -0
- package/dist/Command/CommandTestWrapper.svelte +13 -0
- package/dist/Command/CommandTestWrapper.svelte.d.ts +4 -0
- package/dist/Command/command.types.d.ts +100 -0
- package/dist/Command/command.types.js +1 -0
- package/dist/Command/command.variants.d.ts +226 -0
- package/dist/Command/command.variants.js +86 -0
- package/dist/Command/index.d.ts +2 -0
- package/dist/Command/index.js +1 -0
- package/dist/Container/Container.svelte +21 -0
- package/dist/Container/Container.svelte.d.ts +5 -0
- package/dist/Container/container.types.d.ts +19 -0
- package/dist/Container/container.types.js +1 -0
- package/dist/Container/container.variants.d.ts +29 -0
- package/dist/Container/container.variants.js +9 -0
- package/dist/Container/index.d.ts +2 -0
- package/dist/Container/index.js +1 -0
- package/dist/ContextMenu/ContextMenu.svelte +344 -0
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +6 -0
- package/dist/ContextMenu/context-menu.types.d.ts +265 -0
- package/dist/ContextMenu/context-menu.types.js +1 -0
- package/dist/ContextMenu/context-menu.variants.d.ts +307 -0
- package/dist/ContextMenu/context-menu.variants.js +144 -0
- package/dist/ContextMenu/index.d.ts +2 -0
- package/dist/ContextMenu/index.js +1 -0
- package/dist/Drawer/Drawer.svelte +207 -0
- package/dist/Drawer/Drawer.svelte.d.ts +6 -0
- package/dist/Drawer/DrawerTriggerTestWrapper.svelte +10 -0
- package/dist/Drawer/DrawerTriggerTestWrapper.svelte.d.ts +18 -0
- package/dist/Drawer/drawer.types.d.ts +116 -0
- package/dist/Drawer/drawer.types.js +1 -0
- package/dist/Drawer/drawer.variants.d.ts +193 -0
- package/dist/Drawer/drawer.variants.js +139 -0
- package/dist/Drawer/index.d.ts +2 -0
- package/dist/Drawer/index.js +1 -0
- package/dist/DropdownMenu/DropdownMenu.svelte +363 -0
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +6 -0
- package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte +12 -0
- package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte.d.ts +7 -0
- package/dist/DropdownMenu/dropdown-menu.types.d.ts +279 -0
- package/dist/DropdownMenu/dropdown-menu.types.js +1 -0
- package/dist/DropdownMenu/dropdown-menu.variants.d.ts +312 -0
- package/dist/DropdownMenu/dropdown-menu.variants.js +149 -0
- package/dist/DropdownMenu/index.d.ts +2 -0
- package/dist/DropdownMenu/index.js +1 -0
- package/dist/Editor/Editor.svelte +756 -0
- package/dist/Editor/Editor.svelte.d.ts +6 -0
- package/dist/Editor/EditorUrlPrompt.svelte +94 -0
- package/dist/Editor/EditorUrlPrompt.svelte.d.ts +15 -0
- package/dist/Editor/SlashPopup.svelte +74 -0
- package/dist/Editor/SlashPopup.svelte.d.ts +11 -0
- package/dist/Editor/editor.extensions.d.ts +23 -0
- package/dist/Editor/editor.extensions.js +132 -0
- package/dist/Editor/editor.schemas.d.ts +5 -0
- package/dist/Editor/editor.schemas.js +27 -0
- package/dist/Editor/editor.slash.svelte.d.ts +25 -0
- package/dist/Editor/editor.slash.svelte.js +299 -0
- package/dist/Editor/editor.suggestion.d.ts +7 -0
- package/dist/Editor/editor.suggestion.js +165 -0
- package/dist/Editor/editor.toolbar.d.ts +11 -0
- package/dist/Editor/editor.toolbar.js +204 -0
- package/dist/Editor/editor.types.d.ts +367 -0
- package/dist/Editor/editor.types.js +1 -0
- package/dist/Editor/editor.variants.d.ts +303 -0
- package/dist/Editor/editor.variants.js +135 -0
- package/dist/Editor/index.d.ts +55 -0
- package/dist/Editor/index.js +54 -0
- package/dist/Empty/Empty.svelte +118 -0
- package/dist/Empty/Empty.svelte.d.ts +5 -0
- package/dist/Empty/empty.types.d.ts +91 -0
- package/dist/Empty/empty.types.js +1 -0
- package/dist/Empty/empty.variants.d.ts +308 -0
- package/dist/Empty/empty.variants.js +73 -0
- package/dist/Empty/index.d.ts +2 -0
- package/dist/Empty/index.js +1 -0
- package/dist/FieldGroup/FieldGroup.svelte +53 -0
- package/dist/FieldGroup/FieldGroup.svelte.d.ts +5 -0
- package/dist/FieldGroup/field-group.types.d.ts +37 -0
- package/dist/FieldGroup/field-group.types.js +1 -0
- package/dist/FieldGroup/field-group.variants.d.ts +116 -0
- package/dist/FieldGroup/field-group.variants.js +49 -0
- package/dist/FieldGroup/index.d.ts +2 -0
- package/dist/FieldGroup/index.js +1 -0
- package/dist/FileUpload/FileUpload.svelte +639 -0
- package/dist/FileUpload/FileUpload.svelte.d.ts +8 -0
- package/dist/FileUpload/file-upload.types.d.ts +203 -0
- package/dist/FileUpload/file-upload.types.js +1 -0
- package/dist/FileUpload/file-upload.variants.d.ts +397 -0
- package/dist/FileUpload/file-upload.variants.js +224 -0
- package/dist/FileUpload/index.d.ts +2 -0
- package/dist/FileUpload/index.js +1 -0
- package/dist/Form/Form.svelte +197 -0
- package/dist/Form/Form.svelte.d.ts +26 -0
- package/dist/Form/form.context.svelte.d.ts +64 -0
- package/dist/Form/form.context.svelte.js +478 -0
- package/dist/Form/form.types.d.ts +164 -0
- package/dist/Form/form.types.js +12 -0
- package/dist/Form/form.variants.d.ts +39 -0
- package/dist/Form/form.variants.js +17 -0
- package/dist/Form/index.d.ts +4 -0
- package/dist/Form/index.js +6 -0
- package/dist/Form/validate-schema.d.ts +13 -0
- package/dist/Form/validate-schema.js +113 -0
- package/dist/FormField/FormField.svelte +186 -0
- package/dist/FormField/FormField.svelte.d.ts +5 -0
- package/dist/FormField/form-field.types.d.ts +109 -0
- package/dist/FormField/form-field.types.js +1 -0
- package/dist/FormField/form-field.variants.d.ts +313 -0
- package/dist/FormField/form-field.variants.js +74 -0
- package/dist/FormField/index.d.ts +2 -0
- package/dist/FormField/index.js +1 -0
- package/dist/Icon/Icon.svelte +46 -0
- package/dist/Icon/Icon.svelte.d.ts +6 -0
- package/dist/Icon/icon.types.d.ts +49 -0
- package/dist/Icon/icon.types.js +1 -0
- package/dist/Icon/index.d.ts +2 -0
- package/dist/Icon/index.js +1 -0
- package/dist/Input/Input.svelte +199 -0
- package/dist/Input/Input.svelte.d.ts +26 -0
- package/dist/Input/index.d.ts +2 -0
- package/dist/Input/index.js +1 -0
- package/dist/Input/input.types.d.ts +113 -0
- package/dist/Input/input.types.js +1 -0
- package/dist/Input/input.variants.d.ts +398 -0
- package/dist/Input/input.variants.js +387 -0
- package/dist/Kbd/Kbd.svelte +45 -0
- package/dist/Kbd/Kbd.svelte.d.ts +5 -0
- package/dist/Kbd/index.d.ts +3 -0
- package/dist/Kbd/index.js +2 -0
- package/dist/Kbd/kbd.types.d.ts +91 -0
- package/dist/Kbd/kbd.types.js +1 -0
- package/dist/Kbd/kbd.variants.d.ts +180 -0
- package/dist/Kbd/kbd.variants.js +168 -0
- package/dist/Kbd/useKbd.svelte.d.ts +29 -0
- package/dist/Kbd/useKbd.svelte.js +248 -0
- package/dist/Link/Link.svelte +168 -0
- package/dist/Link/Link.svelte.d.ts +5 -0
- package/dist/Link/index.d.ts +2 -0
- package/dist/Link/index.js +1 -0
- package/dist/Link/link.types.d.ts +86 -0
- package/dist/Link/link.types.js +1 -0
- package/dist/Link/link.variants.d.ts +113 -0
- package/dist/Link/link.variants.js +43 -0
- package/dist/Modal/Modal.svelte +218 -0
- package/dist/Modal/Modal.svelte.d.ts +5 -0
- package/dist/Modal/ModalTriggerTestWrapper.svelte +10 -0
- package/dist/Modal/ModalTriggerTestWrapper.svelte.d.ts +18 -0
- package/dist/Modal/index.d.ts +2 -0
- package/dist/Modal/index.js +1 -0
- package/dist/Modal/modal.types.d.ts +155 -0
- package/dist/Modal/modal.types.js +1 -0
- package/dist/Modal/modal.variants.d.ts +303 -0
- package/dist/Modal/modal.variants.js +90 -0
- package/dist/Pagination/Pagination.svelte +253 -0
- package/dist/Pagination/Pagination.svelte.d.ts +6 -0
- package/dist/Pagination/index.d.ts +2 -0
- package/dist/Pagination/index.js +1 -0
- package/dist/Pagination/pagination.types.d.ts +191 -0
- package/dist/Pagination/pagination.types.js +1 -0
- package/dist/Pagination/pagination.variants.d.ts +160 -0
- package/dist/Pagination/pagination.variants.js +125 -0
- package/dist/PinInput/PinInput.svelte +162 -0
- package/dist/PinInput/PinInput.svelte.d.ts +6 -0
- package/dist/PinInput/index.d.ts +2 -0
- package/dist/PinInput/index.js +1 -0
- package/dist/PinInput/pin-input.types.d.ts +110 -0
- package/dist/PinInput/pin-input.types.js +1 -0
- package/dist/PinInput/pin-input.variants.d.ts +303 -0
- package/dist/PinInput/pin-input.variants.js +196 -0
- package/dist/Popover/Popover.svelte +122 -0
- package/dist/Popover/Popover.svelte.d.ts +6 -0
- package/dist/Popover/index.d.ts +2 -0
- package/dist/Popover/index.js +1 -0
- package/dist/Popover/popover.types.d.ts +58 -0
- package/dist/Popover/popover.types.js +1 -0
- package/dist/Popover/popover.variants.d.ts +53 -0
- package/dist/Popover/popover.variants.js +31 -0
- package/dist/Progress/Progress.svelte +135 -0
- package/dist/Progress/Progress.svelte.d.ts +6 -0
- package/dist/Progress/index.d.ts +2 -0
- package/dist/Progress/index.js +1 -0
- package/dist/Progress/progress.types.d.ts +71 -0
- package/dist/Progress/progress.types.js +1 -0
- package/dist/Progress/progress.variants.d.ts +513 -0
- package/dist/Progress/progress.variants.js +204 -0
- package/dist/RadioGroup/RadioGroup.svelte +226 -0
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +6 -0
- package/dist/RadioGroup/index.d.ts +2 -0
- package/dist/RadioGroup/index.js +1 -0
- package/dist/RadioGroup/radio-group.types.d.ts +111 -0
- package/dist/RadioGroup/radio-group.types.js +1 -0
- package/dist/RadioGroup/radio-group.variants.d.ts +543 -0
- package/dist/RadioGroup/radio-group.variants.js +232 -0
- package/dist/Select/Select.svelte +461 -0
- package/dist/Select/Select.svelte.d.ts +6 -0
- package/dist/Select/index.d.ts +2 -0
- package/dist/Select/index.js +1 -0
- package/dist/Select/select.types.d.ts +263 -0
- package/dist/Select/select.types.js +1 -0
- package/dist/Select/select.variants.d.ts +713 -0
- package/dist/Select/select.variants.js +482 -0
- package/dist/SelectMenu/SelectMenu.svelte +637 -0
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +5 -0
- package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte +11 -0
- package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte.d.ts +7 -0
- package/dist/SelectMenu/index.d.ts +2 -0
- package/dist/SelectMenu/index.js +1 -0
- package/dist/SelectMenu/select-menu.types.d.ts +326 -0
- package/dist/SelectMenu/select-menu.types.js +1 -0
- package/dist/SelectMenu/select-menu.variants.d.ts +795 -0
- package/dist/SelectMenu/select-menu.variants.js +70 -0
- package/dist/Separator/Separator.svelte +77 -0
- package/dist/Separator/Separator.svelte.d.ts +6 -0
- package/dist/Separator/index.d.ts +2 -0
- package/dist/Separator/index.js +1 -0
- package/dist/Separator/separator.types.d.ts +53 -0
- package/dist/Separator/separator.types.js +1 -0
- package/dist/Separator/separator.variants.d.ts +509 -0
- package/dist/Separator/separator.variants.js +110 -0
- package/dist/Skeleton/Skeleton.svelte +39 -0
- package/dist/Skeleton/Skeleton.svelte.d.ts +5 -0
- package/dist/Skeleton/index.d.ts +2 -0
- package/dist/Skeleton/index.js +1 -0
- package/dist/Skeleton/skeleton.types.d.ts +27 -0
- package/dist/Skeleton/skeleton.types.js +1 -0
- package/dist/Skeleton/skeleton.variants.d.ts +18 -0
- package/dist/Skeleton/skeleton.variants.js +12 -0
- package/dist/Slideover/Slideover.svelte +212 -0
- package/dist/Slideover/Slideover.svelte.d.ts +5 -0
- package/dist/Slideover/SlideoverTriggerTestWrapper.svelte +10 -0
- package/dist/Slideover/SlideoverTriggerTestWrapper.svelte.d.ts +18 -0
- package/dist/Slideover/index.d.ts +2 -0
- package/dist/Slideover/index.js +1 -0
- package/dist/Slideover/slideover.types.d.ts +154 -0
- package/dist/Slideover/slideover.types.js +1 -0
- package/dist/Slideover/slideover.variants.d.ts +298 -0
- package/dist/Slideover/slideover.variants.js +145 -0
- package/dist/Slider/Slider.svelte +129 -0
- package/dist/Slider/Slider.svelte.d.ts +6 -0
- package/dist/Slider/index.d.ts +2 -0
- package/dist/Slider/index.js +1 -0
- package/dist/Slider/slider.types.d.ts +55 -0
- package/dist/Slider/slider.types.js +1 -0
- package/dist/Slider/slider.variants.d.ts +383 -0
- package/dist/Slider/slider.variants.js +102 -0
- package/dist/Stepper/Stepper.svelte +254 -0
- package/dist/Stepper/Stepper.svelte.d.ts +5 -0
- package/dist/Stepper/index.d.ts +2 -0
- package/dist/Stepper/index.js +1 -0
- package/dist/Stepper/stepper.types.d.ts +223 -0
- package/dist/Stepper/stepper.types.js +1 -0
- package/dist/Stepper/stepper.variants.d.ts +428 -0
- package/dist/Stepper/stepper.variants.js +204 -0
- package/dist/Switch/Switch.svelte +150 -0
- package/dist/Switch/Switch.svelte.d.ts +6 -0
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Switch/index.js +1 -0
- package/dist/Switch/switch.types.d.ts +80 -0
- package/dist/Switch/switch.types.js +1 -0
- package/dist/Switch/switch.variants.d.ts +433 -0
- package/dist/Switch/switch.variants.js +171 -0
- package/dist/Table/Table.svelte +667 -0
- package/dist/Table/Table.svelte.d.ts +26 -0
- package/dist/Table/index.d.ts +2 -0
- package/dist/Table/index.js +1 -0
- package/dist/Table/table.types.d.ts +202 -0
- package/dist/Table/table.types.js +1 -0
- package/dist/Table/table.utils.d.ts +54 -0
- package/dist/Table/table.utils.js +167 -0
- package/dist/Table/table.variants.d.ts +205 -0
- package/dist/Table/table.variants.js +126 -0
- package/dist/Tabs/Tabs.svelte +188 -0
- package/dist/Tabs/Tabs.svelte.d.ts +6 -0
- package/dist/Tabs/index.d.ts +2 -0
- package/dist/Tabs/index.js +1 -0
- package/dist/Tabs/tabs.types.d.ts +207 -0
- package/dist/Tabs/tabs.types.js +1 -0
- package/dist/Tabs/tabs.variants.d.ts +298 -0
- package/dist/Tabs/tabs.variants.js +251 -0
- package/dist/Textarea/Textarea.svelte +215 -0
- package/dist/Textarea/Textarea.svelte.d.ts +5 -0
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Textarea/index.js +1 -0
- package/dist/Textarea/textarea.types.d.ts +103 -0
- package/dist/Textarea/textarea.types.js +1 -0
- package/dist/Textarea/textarea.variants.d.ts +403 -0
- package/dist/Textarea/textarea.variants.js +404 -0
- package/dist/ThemeModeButton/ThemeModeButton.svelte +74 -0
- package/dist/ThemeModeButton/ThemeModeButton.svelte.d.ts +5 -0
- package/dist/ThemeModeButton/index.d.ts +2 -0
- package/dist/ThemeModeButton/index.js +1 -0
- package/dist/ThemeModeButton/theme-mode-button.types.d.ts +69 -0
- package/dist/ThemeModeButton/theme-mode-button.types.js +1 -0
- package/dist/ThemeModeButton/theme-mode-button.variants.d.ts +21 -0
- package/dist/ThemeModeButton/theme-mode-button.variants.js +17 -0
- package/dist/Timeline/Timeline.svelte +116 -0
- package/dist/Timeline/Timeline.svelte.d.ts +5 -0
- package/dist/Timeline/index.d.ts +2 -0
- package/dist/Timeline/index.js +1 -0
- package/dist/Timeline/timeline.types.d.ts +138 -0
- package/dist/Timeline/timeline.types.js +1 -0
- package/dist/Timeline/timeline.variants.d.ts +413 -0
- package/dist/Timeline/timeline.variants.js +201 -0
- package/dist/Toast/Toaster.svelte +619 -0
- package/dist/Toast/Toaster.svelte.d.ts +5 -0
- package/dist/Toast/index.d.ts +4 -0
- package/dist/Toast/index.js +2 -0
- package/dist/Toast/toast.d.ts +38 -0
- package/dist/Toast/toast.js +73 -0
- package/dist/Toast/toast.types.d.ts +19 -0
- package/dist/Toast/toast.types.js +1 -0
- package/dist/Toast/toast.variants.d.ts +7 -0
- package/dist/Toast/toast.variants.js +5 -0
- package/dist/Tooltip/Tooltip.svelte +151 -0
- package/dist/Tooltip/Tooltip.svelte.d.ts +6 -0
- package/dist/Tooltip/TooltipTestWrapper.svelte +8 -0
- package/dist/Tooltip/TooltipTestWrapper.svelte.d.ts +4 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/Tooltip/index.js +1 -0
- package/dist/Tooltip/tooltip.types.d.ts +62 -0
- package/dist/Tooltip/tooltip.types.js +1 -0
- package/dist/Tooltip/tooltip.variants.d.ts +68 -0
- package/dist/Tooltip/tooltip.variants.js +35 -0
- package/dist/User/User.svelte +98 -0
- package/dist/User/User.svelte.d.ts +5 -0
- package/dist/User/index.d.ts +2 -0
- package/dist/User/index.js +1 -0
- package/dist/User/user.types.d.ts +78 -0
- package/dist/User/user.types.js +1 -0
- package/dist/User/user.variants.d.ts +368 -0
- package/dist/User/user.variants.js +85 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.js +108 -0
- package/dist/hooks/HookContextProbe.svelte +7 -0
- package/dist/hooks/HookContextProbe.svelte.d.ts +18 -0
- package/dist/hooks/HookContextProvider.svelte +9 -0
- package/dist/hooks/HookContextProvider.svelte.d.ts +18 -0
- package/dist/hooks/HookEmitProbe.svelte +14 -0
- package/dist/hooks/HookEmitProbe.svelte.d.ts +18 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useClickOutside.svelte.d.ts +31 -0
- package/dist/hooks/useClickOutside.svelte.js +37 -0
- package/dist/hooks/useClipboard.svelte.d.ts +30 -0
- package/dist/hooks/useClipboard.svelte.js +45 -0
- package/dist/hooks/useDebounce.svelte.d.ts +36 -0
- package/dist/hooks/useDebounce.svelte.js +56 -0
- package/dist/hooks/useEscapeKeydown.svelte.d.ts +31 -0
- package/dist/hooks/useEscapeKeydown.svelte.js +37 -0
- package/dist/hooks/useFormField.svelte.d.ts +54 -0
- package/dist/hooks/useFormField.svelte.js +65 -0
- package/dist/hooks/useInfiniteScroll.svelte.d.ts +57 -0
- package/dist/hooks/useInfiniteScroll.svelte.js +69 -0
- package/dist/hooks/useMediaQuery.svelte.d.ts +31 -0
- package/dist/hooks/useMediaQuery.svelte.js +38 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +57 -0
- package/dist/theme.css +680 -0
- package/package.json +237 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
<script lang="ts" module>import type { EditorProps } from './editor.types.js';
|
|
2
|
+
export type Props = EditorProps;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { type AnyExtension, Editor } from '@tiptap/core'
|
|
7
|
+
import BubbleMenuExt from '@tiptap/extension-bubble-menu'
|
|
8
|
+
import { untrack } from 'svelte'
|
|
9
|
+
import { getComponentConfig } from '../config.js'
|
|
10
|
+
import { useFormField, useFormFieldEmit } from '../hooks/useFormField.svelte.js'
|
|
11
|
+
import Icon from '../Icon/Icon.svelte'
|
|
12
|
+
import Tooltip from '../Tooltip/Tooltip.svelte'
|
|
13
|
+
import EditorUrlPrompt from './EditorUrlPrompt.svelte'
|
|
14
|
+
import { buildExtensions } from './editor.extensions.js'
|
|
15
|
+
import {
|
|
16
|
+
httpUrlSchema,
|
|
17
|
+
isSafeImageSrc,
|
|
18
|
+
type UrlSchema,
|
|
19
|
+
youtubeUrlSchema
|
|
20
|
+
} from './editor.schemas.js'
|
|
21
|
+
import { buildDefaultSlashCommands } from './editor.slash.svelte.js'
|
|
22
|
+
import { buildMentionSuggestion } from './editor.suggestion.js'
|
|
23
|
+
import { DEFAULT_TOOLBAR, TOOLBAR_ACTIONS, type ToolbarActionDef } from './editor.toolbar.js'
|
|
24
|
+
import type {
|
|
25
|
+
EditorApi,
|
|
26
|
+
EditorJSON,
|
|
27
|
+
EditorReactiveState,
|
|
28
|
+
ToolbarAction
|
|
29
|
+
} from './editor.types.js'
|
|
30
|
+
import { editorDefaults, editorVariants } from './editor.variants.js'
|
|
31
|
+
|
|
32
|
+
const config = getComponentConfig('editor', editorDefaults)
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
ref = $bindable(null),
|
|
36
|
+
api = $bindable(),
|
|
37
|
+
value = $bindable(),
|
|
38
|
+
output = 'html',
|
|
39
|
+
placeholder,
|
|
40
|
+
id,
|
|
41
|
+
name,
|
|
42
|
+
onValueChange,
|
|
43
|
+
onFocus,
|
|
44
|
+
onBlur,
|
|
45
|
+
readonly = false,
|
|
46
|
+
disabled = false,
|
|
47
|
+
autofocus = false,
|
|
48
|
+
maxLength,
|
|
49
|
+
showCount = false,
|
|
50
|
+
toolbar = true,
|
|
51
|
+
stickyToolbar = false,
|
|
52
|
+
bubbleMenu = false,
|
|
53
|
+
headingLevels = [1, 2, 3],
|
|
54
|
+
autolink = true,
|
|
55
|
+
linkOpenInNewTab = true,
|
|
56
|
+
markdownAllowHtml = false,
|
|
57
|
+
image = false,
|
|
58
|
+
onImageUpload,
|
|
59
|
+
onImageUploadError,
|
|
60
|
+
tables = false,
|
|
61
|
+
onMention,
|
|
62
|
+
mentionTrigger = '@',
|
|
63
|
+
slash = false,
|
|
64
|
+
slashCommands,
|
|
65
|
+
slashTrigger = '/',
|
|
66
|
+
youtube = false,
|
|
67
|
+
dragHandle = false,
|
|
68
|
+
extensions: extraExtensions,
|
|
69
|
+
extensionsOverride,
|
|
70
|
+
size = config.defaultVariants.size ?? 'md',
|
|
71
|
+
color = config.defaultVariants.color ?? 'primary',
|
|
72
|
+
class: className,
|
|
73
|
+
ui,
|
|
74
|
+
toolbarSlot,
|
|
75
|
+
bubbleMenuSlot,
|
|
76
|
+
header,
|
|
77
|
+
footer,
|
|
78
|
+
...restProps
|
|
79
|
+
}: Props = $props()
|
|
80
|
+
|
|
81
|
+
const formFieldContext = useFormField()
|
|
82
|
+
const emit = useFormFieldEmit()
|
|
83
|
+
|
|
84
|
+
const resolvedOutput = untrack(() => output)
|
|
85
|
+
|
|
86
|
+
function getMarkdownStorage(ed: Editor): { getMarkdown?: () => string } | undefined {
|
|
87
|
+
return (ed.storage as unknown as Record<string, unknown>).markdown as
|
|
88
|
+
| { getMarkdown?: () => string }
|
|
89
|
+
| undefined
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const hasError = $derived(
|
|
93
|
+
formFieldContext?.error !== undefined && formFieldContext?.error !== false
|
|
94
|
+
)
|
|
95
|
+
const resolvedColor = $derived(hasError ? 'error' : color)
|
|
96
|
+
const resolvedId = $derived(id ?? formFieldContext?.ariaId)
|
|
97
|
+
const resolvedName = $derived(name ?? formFieldContext?.name)
|
|
98
|
+
const ariaDescribedBy = $derived(
|
|
99
|
+
!formFieldContext
|
|
100
|
+
? undefined
|
|
101
|
+
: hasError
|
|
102
|
+
? `${formFieldContext.ariaId}-error`
|
|
103
|
+
: `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
let contentElement: HTMLDivElement | null = $state(null)
|
|
107
|
+
let bubbleElement: HTMLDivElement | null = $state(null)
|
|
108
|
+
let editor: Editor | null = $state(null)
|
|
109
|
+
|
|
110
|
+
let editorState = $state<EditorReactiveState>({
|
|
111
|
+
active: {},
|
|
112
|
+
can: { undo: false, redo: false },
|
|
113
|
+
charCount: 0,
|
|
114
|
+
wordCount: 0,
|
|
115
|
+
isEmpty: true,
|
|
116
|
+
isFocused: false
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
function syncState(ed: Editor): void {
|
|
120
|
+
const cc = ed.storage.characterCount
|
|
121
|
+
const can = ed.can()
|
|
122
|
+
editorState = {
|
|
123
|
+
active: {
|
|
124
|
+
bold: ed.isActive('bold'),
|
|
125
|
+
italic: ed.isActive('italic'),
|
|
126
|
+
underline: ed.isActive('underline'),
|
|
127
|
+
strike: ed.isActive('strike'),
|
|
128
|
+
code: ed.isActive('code'),
|
|
129
|
+
h1: ed.isActive('heading', { level: 1 }),
|
|
130
|
+
h2: ed.isActive('heading', { level: 2 }),
|
|
131
|
+
h3: ed.isActive('heading', { level: 3 }),
|
|
132
|
+
paragraph: ed.isActive('paragraph'),
|
|
133
|
+
bulletList: ed.isActive('bulletList'),
|
|
134
|
+
orderedList: ed.isActive('orderedList'),
|
|
135
|
+
blockquote: ed.isActive('blockquote'),
|
|
136
|
+
codeBlock: ed.isActive('codeBlock'),
|
|
137
|
+
link: ed.isActive('link'),
|
|
138
|
+
alignLeft: ed.isActive({ textAlign: 'left' }),
|
|
139
|
+
alignCenter: ed.isActive({ textAlign: 'center' }),
|
|
140
|
+
alignRight: ed.isActive({ textAlign: 'right' }),
|
|
141
|
+
alignJustify: ed.isActive({ textAlign: 'justify' }),
|
|
142
|
+
image: ed.isActive('image'),
|
|
143
|
+
table: ed.isActive('table'),
|
|
144
|
+
youtube: ed.isActive('youtube')
|
|
145
|
+
},
|
|
146
|
+
can: {
|
|
147
|
+
undo: can.undo(),
|
|
148
|
+
redo: can.redo()
|
|
149
|
+
},
|
|
150
|
+
charCount: typeof cc?.characters === 'function' ? cc.characters() : 0,
|
|
151
|
+
wordCount: typeof cc?.words === 'function' ? cc.words() : 0,
|
|
152
|
+
isEmpty: ed.isEmpty,
|
|
153
|
+
isFocused: ed.isFocused
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function serialize(ed: Editor): string | EditorJSON {
|
|
158
|
+
if (resolvedOutput === 'json') return ed.getJSON() as EditorJSON
|
|
159
|
+
if (resolvedOutput === 'markdown') {
|
|
160
|
+
const md = getMarkdownStorage(ed)
|
|
161
|
+
if (md && typeof md.getMarkdown === 'function') {
|
|
162
|
+
return md.getMarkdown()
|
|
163
|
+
}
|
|
164
|
+
return ed.getHTML()
|
|
165
|
+
}
|
|
166
|
+
return ed.getHTML()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function isContentEqual(a: unknown, b: unknown): boolean {
|
|
170
|
+
if (a === b) return true
|
|
171
|
+
if (typeof a !== typeof b) return false
|
|
172
|
+
if (typeof a === 'string' && typeof b === 'string') return a === b
|
|
173
|
+
try {
|
|
174
|
+
return JSON.stringify(a) === JSON.stringify(b)
|
|
175
|
+
} catch {
|
|
176
|
+
return false
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function resolveSlashCommands() {
|
|
181
|
+
if (slashCommands) return slashCommands
|
|
182
|
+
if (!slash) return undefined
|
|
183
|
+
return buildDefaultSlashCommands({
|
|
184
|
+
image,
|
|
185
|
+
tables,
|
|
186
|
+
youtube,
|
|
187
|
+
promptUrl: (opts) =>
|
|
188
|
+
new Promise<string | null>((resolve) => {
|
|
189
|
+
let done = false
|
|
190
|
+
const settle = (value: string | null): void => {
|
|
191
|
+
if (done) return
|
|
192
|
+
done = true
|
|
193
|
+
resolve(value)
|
|
194
|
+
}
|
|
195
|
+
openUrlPrompt({
|
|
196
|
+
...opts,
|
|
197
|
+
onConfirm: (value) => settle(value),
|
|
198
|
+
onCancel: () => settle(null)
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function resolveExtensions(): AnyExtension[] | Promise<AnyExtension[]> {
|
|
205
|
+
if (extensionsOverride) return extensionsOverride
|
|
206
|
+
return buildExtensions({
|
|
207
|
+
headingLevels,
|
|
208
|
+
placeholder,
|
|
209
|
+
autolink,
|
|
210
|
+
linkOpenInNewTab,
|
|
211
|
+
maxLength,
|
|
212
|
+
image,
|
|
213
|
+
tables,
|
|
214
|
+
youtube,
|
|
215
|
+
dragHandle,
|
|
216
|
+
markdown: resolvedOutput === 'markdown',
|
|
217
|
+
markdownAllowHtml,
|
|
218
|
+
mentionTrigger,
|
|
219
|
+
mentionSuggestion: onMention
|
|
220
|
+
? buildMentionSuggestion({ onQuery: onMention })
|
|
221
|
+
: undefined,
|
|
222
|
+
slashCommands: resolveSlashCommands(),
|
|
223
|
+
slashTrigger,
|
|
224
|
+
extra: [
|
|
225
|
+
...(extraExtensions ?? []),
|
|
226
|
+
...(bubbleMenu && bubbleElement
|
|
227
|
+
? [
|
|
228
|
+
BubbleMenuExt.configure({
|
|
229
|
+
element: bubbleElement,
|
|
230
|
+
options: {
|
|
231
|
+
placement: 'top'
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
: [])
|
|
236
|
+
]
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
let suppressUpdate = false
|
|
241
|
+
let lastEmitted: string | EditorJSON | undefined
|
|
242
|
+
|
|
243
|
+
$effect(() => {
|
|
244
|
+
if (!contentElement) return
|
|
245
|
+
|
|
246
|
+
const initialContent = untrack(() => value ?? '')
|
|
247
|
+
const initialEditable = untrack(() => !disabled && !readonly)
|
|
248
|
+
const initialAutofocus = untrack(() => autofocus)
|
|
249
|
+
const initialAttrs = untrack(() => ({
|
|
250
|
+
id: resolvedId,
|
|
251
|
+
...(resolvedName ? { 'data-name': resolvedName } : {}),
|
|
252
|
+
...(ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}),
|
|
253
|
+
...(hasError ? { 'aria-invalid': 'true' } : {})
|
|
254
|
+
}))
|
|
255
|
+
const el = contentElement
|
|
256
|
+
const result = untrack(() => resolveExtensions())
|
|
257
|
+
|
|
258
|
+
let ed: Editor | null = null
|
|
259
|
+
let cancelled = false
|
|
260
|
+
|
|
261
|
+
const create = (exts: AnyExtension[]) => {
|
|
262
|
+
if (cancelled) return
|
|
263
|
+
ed = new Editor({
|
|
264
|
+
element: el,
|
|
265
|
+
extensions: exts,
|
|
266
|
+
content: initialContent,
|
|
267
|
+
editable: initialEditable,
|
|
268
|
+
autofocus: initialAutofocus,
|
|
269
|
+
editorProps: {
|
|
270
|
+
attributes: initialAttrs as Record<string, string>
|
|
271
|
+
},
|
|
272
|
+
onCreate: ({ editor: e }) => syncState(e),
|
|
273
|
+
onUpdate: ({ editor: e }) => {
|
|
274
|
+
syncState(e)
|
|
275
|
+
if (suppressUpdate) return
|
|
276
|
+
const serialized = serialize(e)
|
|
277
|
+
lastEmitted = serialized
|
|
278
|
+
value = serialized
|
|
279
|
+
emit.onInput()
|
|
280
|
+
onValueChange?.(serialized)
|
|
281
|
+
},
|
|
282
|
+
onSelectionUpdate: ({ editor: e }) => syncState(e),
|
|
283
|
+
onFocus: ({ editor: e }) => {
|
|
284
|
+
syncState(e)
|
|
285
|
+
emit.onFocus()
|
|
286
|
+
onFocus?.()
|
|
287
|
+
},
|
|
288
|
+
onBlur: ({ editor: e }) => {
|
|
289
|
+
syncState(e)
|
|
290
|
+
emit.onBlur()
|
|
291
|
+
onBlur?.()
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
editor = ed
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (result instanceof Promise) {
|
|
298
|
+
result.then(create)
|
|
299
|
+
} else {
|
|
300
|
+
create(result)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return () => {
|
|
304
|
+
cancelled = true
|
|
305
|
+
ed?.destroy()
|
|
306
|
+
editor = null
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
$effect(() => {
|
|
311
|
+
if (!editor) return
|
|
312
|
+
const target = !disabled && !readonly
|
|
313
|
+
if (editor.isEditable !== target) {
|
|
314
|
+
editor.setEditable(target)
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
$effect(() => {
|
|
319
|
+
if (!contentElement) return
|
|
320
|
+
const pm = contentElement.querySelector('.ProseMirror') as HTMLElement | null
|
|
321
|
+
if (!pm) return
|
|
322
|
+
if (hasError) pm.setAttribute('aria-invalid', 'true')
|
|
323
|
+
else pm.removeAttribute('aria-invalid')
|
|
324
|
+
if (ariaDescribedBy) pm.setAttribute('aria-describedby', ariaDescribedBy)
|
|
325
|
+
else pm.removeAttribute('aria-describedby')
|
|
326
|
+
if (resolvedId) pm.setAttribute('id', resolvedId)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
$effect(() => {
|
|
330
|
+
if (!editor) return
|
|
331
|
+
if (value === undefined) return
|
|
332
|
+
if (typeof value === 'string' && value === lastEmitted) return
|
|
333
|
+
const current = serialize(editor)
|
|
334
|
+
if (isContentEqual(current, value)) return
|
|
335
|
+
suppressUpdate = true
|
|
336
|
+
editor.commands.setContent(value as string | EditorJSON, { emitUpdate: false })
|
|
337
|
+
suppressUpdate = false
|
|
338
|
+
syncState(editor)
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
const apiInstance: EditorApi = {
|
|
342
|
+
get editor() {
|
|
343
|
+
return editor
|
|
344
|
+
},
|
|
345
|
+
get state() {
|
|
346
|
+
return editorState
|
|
347
|
+
},
|
|
348
|
+
focus(position) {
|
|
349
|
+
editor?.commands.focus(position)
|
|
350
|
+
},
|
|
351
|
+
run(action) {
|
|
352
|
+
if (!editor) return
|
|
353
|
+
TOOLBAR_ACTIONS[action].run(editor)
|
|
354
|
+
},
|
|
355
|
+
getValue(format) {
|
|
356
|
+
if (!editor) return resolvedOutput === 'json' ? ({} as EditorJSON) : ''
|
|
357
|
+
const fmt = format ?? resolvedOutput
|
|
358
|
+
if (fmt === 'json') return editor.getJSON() as EditorJSON
|
|
359
|
+
if (fmt === 'markdown') {
|
|
360
|
+
const md = getMarkdownStorage(editor)
|
|
361
|
+
if (md && typeof md.getMarkdown === 'function') return md.getMarkdown()
|
|
362
|
+
return editor.getHTML()
|
|
363
|
+
}
|
|
364
|
+
return editor.getHTML()
|
|
365
|
+
},
|
|
366
|
+
setValue(next) {
|
|
367
|
+
if (!editor) return
|
|
368
|
+
suppressUpdate = true
|
|
369
|
+
editor.commands.setContent(next as string | EditorJSON, { emitUpdate: false })
|
|
370
|
+
suppressUpdate = false
|
|
371
|
+
syncState(editor)
|
|
372
|
+
},
|
|
373
|
+
clear() {
|
|
374
|
+
editor?.chain().focus().clearContent().run()
|
|
375
|
+
},
|
|
376
|
+
insert(content) {
|
|
377
|
+
editor
|
|
378
|
+
?.chain()
|
|
379
|
+
.focus()
|
|
380
|
+
.insertContent(content as string | EditorJSON)
|
|
381
|
+
.run()
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
api = apiInstance
|
|
386
|
+
|
|
387
|
+
const resolvedToolbar = $derived.by<(ToolbarAction | '|')[]>(() => {
|
|
388
|
+
if (toolbar === false) return []
|
|
389
|
+
if (toolbar === true) return DEFAULT_TOOLBAR
|
|
390
|
+
return toolbar as (ToolbarAction | '|')[]
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
const classes = $derived.by(() => {
|
|
394
|
+
const slots = editorVariants({
|
|
395
|
+
size,
|
|
396
|
+
color: resolvedColor,
|
|
397
|
+
sticky: stickyToolbar
|
|
398
|
+
})
|
|
399
|
+
const c = config.slots
|
|
400
|
+
const u = ui ?? {}
|
|
401
|
+
return {
|
|
402
|
+
root: slots.root({ class: [c.root, className, u.root] }),
|
|
403
|
+
toolbar: slots.toolbar({ class: [c.toolbar, u.toolbar] }),
|
|
404
|
+
toolbarButton: slots.toolbarButton({ class: [c.toolbarButton, u.toolbarButton] }),
|
|
405
|
+
toolbarSeparator: slots.toolbarSeparator({
|
|
406
|
+
class: [c.toolbarSeparator, u.toolbarSeparator]
|
|
407
|
+
}),
|
|
408
|
+
content: slots.content({ class: [c.content, u.content] }),
|
|
409
|
+
footer: slots.footer({ class: [c.footer, u.footer] }),
|
|
410
|
+
countLabel: slots.countLabel({ class: [c.countLabel, u.countLabel] }),
|
|
411
|
+
bubbleMenu: slots.bubbleMenu({ class: [c.bubbleMenu, u.bubbleMenu] })
|
|
412
|
+
}
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
interface UrlPromptState {
|
|
416
|
+
open: boolean
|
|
417
|
+
title: string
|
|
418
|
+
description?: string
|
|
419
|
+
placeholder: string
|
|
420
|
+
initialValue: string
|
|
421
|
+
confirmLabel: string
|
|
422
|
+
schema?: UrlSchema
|
|
423
|
+
onConfirm?: (url: string) => void
|
|
424
|
+
onCancel?: () => void
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
let urlPrompt = $state<UrlPromptState>({
|
|
428
|
+
open: false,
|
|
429
|
+
title: 'Enter URL',
|
|
430
|
+
placeholder: 'https://',
|
|
431
|
+
initialValue: '',
|
|
432
|
+
confirmLabel: 'Insert'
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
function openUrlPrompt(opts: {
|
|
436
|
+
title: string
|
|
437
|
+
description?: string
|
|
438
|
+
placeholder?: string
|
|
439
|
+
initialValue?: string
|
|
440
|
+
confirmLabel?: string
|
|
441
|
+
schema?: UrlSchema
|
|
442
|
+
onConfirm: (url: string) => void
|
|
443
|
+
onCancel?: () => void
|
|
444
|
+
}): void {
|
|
445
|
+
urlPrompt = {
|
|
446
|
+
open: true,
|
|
447
|
+
title: opts.title,
|
|
448
|
+
description: opts.description,
|
|
449
|
+
placeholder: opts.placeholder ?? 'https://',
|
|
450
|
+
initialValue: opts.initialValue ?? '',
|
|
451
|
+
confirmLabel: opts.confirmLabel ?? 'Insert',
|
|
452
|
+
schema: opts.schema,
|
|
453
|
+
onConfirm: opts.onConfirm,
|
|
454
|
+
onCancel: opts.onCancel
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
let fileInput: HTMLInputElement | null = $state(null)
|
|
459
|
+
|
|
460
|
+
async function handleFileSelected(event: Event): Promise<void> {
|
|
461
|
+
if (!editor) return
|
|
462
|
+
const input = event.currentTarget as HTMLInputElement
|
|
463
|
+
const file = input.files?.[0]
|
|
464
|
+
input.value = ''
|
|
465
|
+
if (!file) return
|
|
466
|
+
if (!onImageUpload) return
|
|
467
|
+
try {
|
|
468
|
+
const url = await onImageUpload(file)
|
|
469
|
+
if (!isSafeImageSrc(url)) {
|
|
470
|
+
return
|
|
471
|
+
}
|
|
472
|
+
editor.chain().focus().setImage({ src: url }).run()
|
|
473
|
+
} catch (err) {
|
|
474
|
+
if (onImageUploadError) {
|
|
475
|
+
onImageUploadError(err)
|
|
476
|
+
} else {
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function openImagePicker(): void {
|
|
482
|
+
if (!editor) return
|
|
483
|
+
if (!onImageUpload) {
|
|
484
|
+
openUrlPrompt({
|
|
485
|
+
title: 'Image URL',
|
|
486
|
+
placeholder: 'https://example.com/image.png',
|
|
487
|
+
schema: httpUrlSchema,
|
|
488
|
+
onConfirm: (url) => {
|
|
489
|
+
editor?.chain().focus().setImage({ src: url }).run()
|
|
490
|
+
}
|
|
491
|
+
})
|
|
492
|
+
return
|
|
493
|
+
}
|
|
494
|
+
fileInput?.click()
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function openYoutubePrompt(): void {
|
|
498
|
+
if (!editor) return
|
|
499
|
+
openUrlPrompt({
|
|
500
|
+
title: 'Embed YouTube video',
|
|
501
|
+
description: 'Paste the share link or full URL.',
|
|
502
|
+
placeholder: 'https://youtu.be/...',
|
|
503
|
+
confirmLabel: 'Embed',
|
|
504
|
+
schema: youtubeUrlSchema,
|
|
505
|
+
onConfirm: (url) => {
|
|
506
|
+
editor?.commands.setYoutubeVideo({ src: url })
|
|
507
|
+
}
|
|
508
|
+
})
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function openLinkPrompt(): void {
|
|
512
|
+
if (!editor) return
|
|
513
|
+
const previous = (editor.getAttributes('link').href as string | undefined) ?? ''
|
|
514
|
+
openUrlPrompt({
|
|
515
|
+
title: 'Insert link',
|
|
516
|
+
placeholder: 'https://',
|
|
517
|
+
initialValue: previous,
|
|
518
|
+
schema: httpUrlSchema,
|
|
519
|
+
onConfirm: (url) => {
|
|
520
|
+
editor?.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
|
|
521
|
+
}
|
|
522
|
+
})
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
let tableMenuOpen = $state(false)
|
|
526
|
+
let tablePickerRows = $state(0)
|
|
527
|
+
let tablePickerCols = $state(0)
|
|
528
|
+
let tablePickerEl: HTMLDivElement | null = $state(null)
|
|
529
|
+
let tableButtonEl: HTMLButtonElement | null = $state(null)
|
|
530
|
+
const TABLE_MAX_ROWS = 8
|
|
531
|
+
const TABLE_MAX_COLS = 8
|
|
532
|
+
|
|
533
|
+
function insertTable(rows: number, cols: number): void {
|
|
534
|
+
if (!editor) return
|
|
535
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run()
|
|
536
|
+
tableMenuOpen = false
|
|
537
|
+
tablePickerRows = 0
|
|
538
|
+
tablePickerCols = 0
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
$effect(() => {
|
|
542
|
+
if (!tableMenuOpen) return
|
|
543
|
+
function onDocPointerDown(event: PointerEvent): void {
|
|
544
|
+
const target = event.target as Node | null
|
|
545
|
+
if (!target) return
|
|
546
|
+
if (tablePickerEl?.contains(target)) return
|
|
547
|
+
if (tableButtonEl?.contains(target)) return
|
|
548
|
+
tableMenuOpen = false
|
|
549
|
+
tablePickerRows = 0
|
|
550
|
+
tablePickerCols = 0
|
|
551
|
+
}
|
|
552
|
+
document.addEventListener('pointerdown', onDocPointerDown, true)
|
|
553
|
+
return () => document.removeEventListener('pointerdown', onDocPointerDown, true)
|
|
554
|
+
})
|
|
555
|
+
|
|
556
|
+
function runAction(def: ToolbarActionDef, id: ToolbarAction): void {
|
|
557
|
+
if (!editor) return
|
|
558
|
+
if (id === 'image') {
|
|
559
|
+
openImagePicker()
|
|
560
|
+
return
|
|
561
|
+
}
|
|
562
|
+
if (id === 'youtube') {
|
|
563
|
+
openYoutubePrompt()
|
|
564
|
+
return
|
|
565
|
+
}
|
|
566
|
+
if (id === 'link') {
|
|
567
|
+
openLinkPrompt()
|
|
568
|
+
return
|
|
569
|
+
}
|
|
570
|
+
if (id === 'table') {
|
|
571
|
+
tableMenuOpen = !tableMenuOpen
|
|
572
|
+
return
|
|
573
|
+
}
|
|
574
|
+
def.run(editor)
|
|
575
|
+
}
|
|
576
|
+
</script>
|
|
577
|
+
|
|
578
|
+
<div
|
|
579
|
+
bind:this={ref}
|
|
580
|
+
class={classes.root}
|
|
581
|
+
data-disabled={disabled}
|
|
582
|
+
data-readonly={readonly}
|
|
583
|
+
data-error={hasError ? '' : undefined}
|
|
584
|
+
{...restProps}
|
|
585
|
+
>
|
|
586
|
+
{#if toolbarSlot}
|
|
587
|
+
{@render toolbarSlot({ state: editorState, api: apiInstance })}
|
|
588
|
+
{:else if toolbar !== false}
|
|
589
|
+
<div class={classes.toolbar} role="toolbar" aria-label="Editor toolbar">
|
|
590
|
+
{#each resolvedToolbar as item, i (i)}
|
|
591
|
+
{#if item === '|'}
|
|
592
|
+
<span class={classes.toolbarSeparator} aria-hidden="true"></span>
|
|
593
|
+
{:else}
|
|
594
|
+
{@const def = TOOLBAR_ACTIONS[item]}
|
|
595
|
+
{@const active = def.isActive?.(editorState) ?? false}
|
|
596
|
+
{@const inactive = def.isDisabled?.(editorState) ?? false}
|
|
597
|
+
{#if item === 'table'}
|
|
598
|
+
<Tooltip text={def.label}>
|
|
599
|
+
<span class="relative inline-flex">
|
|
600
|
+
<button
|
|
601
|
+
bind:this={tableButtonEl}
|
|
602
|
+
type="button"
|
|
603
|
+
class={classes.toolbarButton}
|
|
604
|
+
data-active={active || tableMenuOpen}
|
|
605
|
+
data-action={item}
|
|
606
|
+
disabled={disabled || readonly || inactive}
|
|
607
|
+
aria-label={def.label}
|
|
608
|
+
aria-expanded={tableMenuOpen}
|
|
609
|
+
aria-haspopup="dialog"
|
|
610
|
+
onclick={() => runAction(def, item)}
|
|
611
|
+
>
|
|
612
|
+
<Icon name={def.icon} />
|
|
613
|
+
</button>
|
|
614
|
+
{#if tableMenuOpen}
|
|
615
|
+
<div
|
|
616
|
+
bind:this={tablePickerEl}
|
|
617
|
+
class="absolute top-full left-0 z-30 mt-1 w-max rounded-lg border border-outline-variant bg-surface p-2 shadow-md"
|
|
618
|
+
data-editor-table-picker
|
|
619
|
+
role="dialog"
|
|
620
|
+
aria-label="Insert table"
|
|
621
|
+
>
|
|
622
|
+
<div
|
|
623
|
+
class="mb-2 text-center text-xs text-on-surface-variant"
|
|
624
|
+
>
|
|
625
|
+
{tablePickerRows || 1} × {tablePickerCols || 1}
|
|
626
|
+
</div>
|
|
627
|
+
<div
|
|
628
|
+
class="grid grid-cols-8 gap-0.5"
|
|
629
|
+
role="presentation"
|
|
630
|
+
onmouseleave={() => {
|
|
631
|
+
tablePickerRows = 0
|
|
632
|
+
tablePickerCols = 0
|
|
633
|
+
}}
|
|
634
|
+
>
|
|
635
|
+
{#each Array.from({ length: TABLE_MAX_ROWS * TABLE_MAX_COLS }, (_v, i) => i) as idx (idx)}
|
|
636
|
+
{@const r = Math.floor(idx / TABLE_MAX_COLS) + 1}
|
|
637
|
+
{@const c = (idx % TABLE_MAX_COLS) + 1}
|
|
638
|
+
{@const on =
|
|
639
|
+
r <= tablePickerRows && c <= tablePickerCols}
|
|
640
|
+
<button
|
|
641
|
+
type="button"
|
|
642
|
+
class="size-5 rounded border border-outline-variant {on
|
|
643
|
+
? 'border-primary bg-primary'
|
|
644
|
+
: 'bg-surface-container hover:border-primary/50'}"
|
|
645
|
+
aria-label={`Insert ${r}×${c} table`}
|
|
646
|
+
onmouseenter={() => {
|
|
647
|
+
tablePickerRows = r
|
|
648
|
+
tablePickerCols = c
|
|
649
|
+
}}
|
|
650
|
+
onmousedown={(e) => {
|
|
651
|
+
e.preventDefault()
|
|
652
|
+
insertTable(r, c)
|
|
653
|
+
}}
|
|
654
|
+
></button>
|
|
655
|
+
{/each}
|
|
656
|
+
</div>
|
|
657
|
+
</div>
|
|
658
|
+
{/if}
|
|
659
|
+
</span>
|
|
660
|
+
</Tooltip>
|
|
661
|
+
{:else}
|
|
662
|
+
<Tooltip text={def.label}>
|
|
663
|
+
<button
|
|
664
|
+
type="button"
|
|
665
|
+
class={classes.toolbarButton}
|
|
666
|
+
data-active={active}
|
|
667
|
+
data-action={item}
|
|
668
|
+
disabled={disabled || readonly || inactive}
|
|
669
|
+
aria-label={def.label}
|
|
670
|
+
aria-pressed={def.isActive ? active : undefined}
|
|
671
|
+
onclick={() => runAction(def, item)}
|
|
672
|
+
>
|
|
673
|
+
<Icon name={def.icon} />
|
|
674
|
+
</button>
|
|
675
|
+
</Tooltip>
|
|
676
|
+
{/if}
|
|
677
|
+
{/if}
|
|
678
|
+
{/each}
|
|
679
|
+
</div>
|
|
680
|
+
{/if}
|
|
681
|
+
|
|
682
|
+
{#if header}
|
|
683
|
+
{@render header()}
|
|
684
|
+
{/if}
|
|
685
|
+
|
|
686
|
+
<div
|
|
687
|
+
bind:this={contentElement}
|
|
688
|
+
class={classes.content}
|
|
689
|
+
data-editor-content
|
|
690
|
+
role="textbox"
|
|
691
|
+
aria-multiline="true"
|
|
692
|
+
aria-readonly={readonly}
|
|
693
|
+
aria-disabled={disabled}
|
|
694
|
+
></div>
|
|
695
|
+
|
|
696
|
+
{#if footer}
|
|
697
|
+
{@render footer()}
|
|
698
|
+
{:else if showCount || maxLength !== undefined}
|
|
699
|
+
<div class={classes.footer} data-editor-footer>
|
|
700
|
+
<span class={classes.countLabel} data-editor-count>
|
|
701
|
+
{editorState.charCount}{#if maxLength !== undefined} / {maxLength}{/if}
|
|
702
|
+
chars
|
|
703
|
+
</span>
|
|
704
|
+
<span class={classes.countLabel}>{editorState.wordCount} words</span>
|
|
705
|
+
</div>
|
|
706
|
+
{/if}
|
|
707
|
+
|
|
708
|
+
{#if image}
|
|
709
|
+
<input
|
|
710
|
+
bind:this={fileInput}
|
|
711
|
+
type="file"
|
|
712
|
+
accept="image/*"
|
|
713
|
+
class="hidden"
|
|
714
|
+
data-editor-image-input
|
|
715
|
+
tabindex="-1"
|
|
716
|
+
aria-hidden="true"
|
|
717
|
+
onchange={handleFileSelected}
|
|
718
|
+
/>
|
|
719
|
+
{/if}
|
|
720
|
+
|
|
721
|
+
{#if bubbleMenu}
|
|
722
|
+
<div bind:this={bubbleElement} class={classes.bubbleMenu} data-editor-bubble>
|
|
723
|
+
{#if bubbleMenuSlot}
|
|
724
|
+
{@render bubbleMenuSlot({ state: editorState, api: apiInstance })}
|
|
725
|
+
{:else}
|
|
726
|
+
{#each ['bold', 'italic', 'link'] as const as item (item)}
|
|
727
|
+
{@const def = TOOLBAR_ACTIONS[item]}
|
|
728
|
+
{@const active = def.isActive?.(editorState) ?? false}
|
|
729
|
+
<button
|
|
730
|
+
type="button"
|
|
731
|
+
class={classes.toolbarButton}
|
|
732
|
+
data-active={active}
|
|
733
|
+
data-action={item}
|
|
734
|
+
aria-label={def.label}
|
|
735
|
+
aria-pressed={active}
|
|
736
|
+
onclick={() => runAction(def, item)}
|
|
737
|
+
>
|
|
738
|
+
<Icon name={def.icon} />
|
|
739
|
+
</button>
|
|
740
|
+
{/each}
|
|
741
|
+
{/if}
|
|
742
|
+
</div>
|
|
743
|
+
{/if}
|
|
744
|
+
</div>
|
|
745
|
+
|
|
746
|
+
<EditorUrlPrompt
|
|
747
|
+
bind:open={urlPrompt.open}
|
|
748
|
+
title={urlPrompt.title}
|
|
749
|
+
description={urlPrompt.description}
|
|
750
|
+
placeholder={urlPrompt.placeholder}
|
|
751
|
+
initialValue={urlPrompt.initialValue}
|
|
752
|
+
confirmLabel={urlPrompt.confirmLabel}
|
|
753
|
+
schema={urlPrompt.schema}
|
|
754
|
+
onConfirm={(url) => urlPrompt.onConfirm?.(url)}
|
|
755
|
+
onCancel={() => urlPrompt.onCancel?.()}
|
|
756
|
+
/>
|