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,299 @@
|
|
|
1
|
+
import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';
|
|
2
|
+
import { Extension } from '@tiptap/core';
|
|
3
|
+
import { Suggestion } from '@tiptap/suggestion';
|
|
4
|
+
import { mount, unmount } from 'svelte';
|
|
5
|
+
import { httpUrlSchema, youtubeUrlSchema } from './editor.schemas.js';
|
|
6
|
+
import SlashPopup from './SlashPopup.svelte';
|
|
7
|
+
function defaultPromptUrl(opts) {
|
|
8
|
+
if (typeof window === 'undefined')
|
|
9
|
+
return Promise.resolve(null);
|
|
10
|
+
return Promise.resolve(window.prompt(opts.title, opts.initialValue ?? opts.placeholder ?? ''));
|
|
11
|
+
}
|
|
12
|
+
export function buildDefaultSlashCommands(ctx = {}) {
|
|
13
|
+
const commands = [
|
|
14
|
+
{
|
|
15
|
+
id: 'paragraph',
|
|
16
|
+
label: 'Text',
|
|
17
|
+
description: 'Plain paragraph',
|
|
18
|
+
icon: 'lucide:pilcrow',
|
|
19
|
+
keywords: ['p', 'text', 'paragraph'],
|
|
20
|
+
run: ({ editor }) => editor.chain().focus().setParagraph().run()
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'h1',
|
|
24
|
+
label: 'Heading 1',
|
|
25
|
+
description: 'Large section heading',
|
|
26
|
+
icon: 'lucide:heading-1',
|
|
27
|
+
keywords: ['h1', 'header', 'title'],
|
|
28
|
+
run: ({ editor }) => editor.chain().focus().toggleHeading({ level: 1 }).run()
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'h2',
|
|
32
|
+
label: 'Heading 2',
|
|
33
|
+
description: 'Medium section heading',
|
|
34
|
+
icon: 'lucide:heading-2',
|
|
35
|
+
keywords: ['h2', 'subtitle'],
|
|
36
|
+
run: ({ editor }) => editor.chain().focus().toggleHeading({ level: 2 }).run()
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'h3',
|
|
40
|
+
label: 'Heading 3',
|
|
41
|
+
description: 'Small section heading',
|
|
42
|
+
icon: 'lucide:heading-3',
|
|
43
|
+
keywords: ['h3'],
|
|
44
|
+
run: ({ editor }) => editor.chain().focus().toggleHeading({ level: 3 }).run()
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'bulletList',
|
|
48
|
+
label: 'Bullet list',
|
|
49
|
+
description: 'Unordered list',
|
|
50
|
+
icon: 'lucide:list',
|
|
51
|
+
keywords: ['ul', 'bullet', 'list'],
|
|
52
|
+
run: ({ editor }) => editor.chain().focus().toggleBulletList().run()
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'orderedList',
|
|
56
|
+
label: 'Numbered list',
|
|
57
|
+
description: 'Ordered list',
|
|
58
|
+
icon: 'lucide:list-ordered',
|
|
59
|
+
keywords: ['ol', 'numbered', 'ordered'],
|
|
60
|
+
run: ({ editor }) => editor.chain().focus().toggleOrderedList().run()
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'blockquote',
|
|
64
|
+
label: 'Quote',
|
|
65
|
+
description: 'Highlight a passage',
|
|
66
|
+
icon: 'lucide:quote',
|
|
67
|
+
keywords: ['quote', 'blockquote'],
|
|
68
|
+
run: ({ editor }) => editor.chain().focus().toggleBlockquote().run()
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'codeBlock',
|
|
72
|
+
label: 'Code block',
|
|
73
|
+
description: 'Fenced code with syntax highlighting',
|
|
74
|
+
icon: 'lucide:square-code',
|
|
75
|
+
keywords: ['code', 'pre', 'fence'],
|
|
76
|
+
run: ({ editor }) => editor.chain().focus().toggleCodeBlock().run()
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'horizontalRule',
|
|
80
|
+
label: 'Divider',
|
|
81
|
+
description: 'Horizontal rule',
|
|
82
|
+
icon: 'lucide:minus',
|
|
83
|
+
keywords: ['hr', 'divider', 'rule', 'separator'],
|
|
84
|
+
run: ({ editor }) => editor.chain().focus().setHorizontalRule().run()
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
const promptUrl = ctx.promptUrl ?? defaultPromptUrl;
|
|
88
|
+
if (ctx.image) {
|
|
89
|
+
commands.push({
|
|
90
|
+
id: 'image',
|
|
91
|
+
label: 'Image',
|
|
92
|
+
description: 'Insert an image from URL',
|
|
93
|
+
icon: 'lucide:image',
|
|
94
|
+
keywords: ['image', 'picture', 'photo'],
|
|
95
|
+
run: async ({ editor }) => {
|
|
96
|
+
const url = await promptUrl({
|
|
97
|
+
title: 'Image URL',
|
|
98
|
+
placeholder: 'https://example.com/image.png',
|
|
99
|
+
schema: httpUrlSchema
|
|
100
|
+
});
|
|
101
|
+
if (!url)
|
|
102
|
+
return;
|
|
103
|
+
editor.chain().focus().setImage({ src: url }).run();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (ctx.tables) {
|
|
108
|
+
commands.push({
|
|
109
|
+
id: 'table',
|
|
110
|
+
label: 'Table',
|
|
111
|
+
description: 'Insert a 3×3 table',
|
|
112
|
+
icon: 'lucide:table',
|
|
113
|
+
keywords: ['table', 'grid'],
|
|
114
|
+
run: ({ editor }) => {
|
|
115
|
+
editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (ctx.youtube) {
|
|
120
|
+
commands.push({
|
|
121
|
+
id: 'youtube',
|
|
122
|
+
label: 'YouTube',
|
|
123
|
+
description: 'Embed a YouTube video',
|
|
124
|
+
icon: 'lucide:youtube',
|
|
125
|
+
keywords: ['youtube', 'video', 'embed'],
|
|
126
|
+
run: async ({ editor }) => {
|
|
127
|
+
const url = await promptUrl({
|
|
128
|
+
title: 'Embed YouTube video',
|
|
129
|
+
description: 'Paste the share link or full URL.',
|
|
130
|
+
placeholder: 'https://youtu.be/...',
|
|
131
|
+
confirmLabel: 'Embed',
|
|
132
|
+
schema: youtubeUrlSchema
|
|
133
|
+
});
|
|
134
|
+
if (!url)
|
|
135
|
+
return;
|
|
136
|
+
editor.commands.setYoutubeVideo({ src: url });
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return commands;
|
|
141
|
+
}
|
|
142
|
+
let slashSeq = 0;
|
|
143
|
+
function substringFilter(commands, query) {
|
|
144
|
+
const q = query.trim().toLowerCase();
|
|
145
|
+
if (!q)
|
|
146
|
+
return commands;
|
|
147
|
+
return commands.filter((cmd) => {
|
|
148
|
+
if (cmd.label.toLowerCase().includes(q))
|
|
149
|
+
return true;
|
|
150
|
+
if (cmd.description?.toLowerCase().includes(q))
|
|
151
|
+
return true;
|
|
152
|
+
if (cmd.keywords?.some((k) => k.toLowerCase().includes(q)))
|
|
153
|
+
return true;
|
|
154
|
+
return cmd.id.toLowerCase().includes(q);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function buildSuggestionRender() {
|
|
158
|
+
let handle = null;
|
|
159
|
+
return {
|
|
160
|
+
onStart: (props) => {
|
|
161
|
+
if (typeof document === 'undefined')
|
|
162
|
+
return;
|
|
163
|
+
const seq = ++slashSeq;
|
|
164
|
+
const listboxId = `svelora-slash-listbox-${seq}`;
|
|
165
|
+
const optionIdPrefix = `svelora-slash-${seq}-`;
|
|
166
|
+
const editorDom = props.editor.view.dom;
|
|
167
|
+
const container = document.createElement('div');
|
|
168
|
+
container.setAttribute('data-editor-slash-container', '');
|
|
169
|
+
container.style.cssText = 'position:absolute;top:0;left:0;z-index:50;';
|
|
170
|
+
document.body.appendChild(container);
|
|
171
|
+
const state = $state({
|
|
172
|
+
items: props.items,
|
|
173
|
+
selectedIndex: 0,
|
|
174
|
+
listboxId,
|
|
175
|
+
optionIdPrefix,
|
|
176
|
+
onPick: (i) => {
|
|
177
|
+
const cmd = state.items[i];
|
|
178
|
+
if (!cmd)
|
|
179
|
+
return;
|
|
180
|
+
props.command(cmd);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
const component = mount(SlashPopup, {
|
|
184
|
+
target: container,
|
|
185
|
+
props: state
|
|
186
|
+
});
|
|
187
|
+
editorDom.setAttribute('aria-controls', listboxId);
|
|
188
|
+
editorDom.setAttribute('aria-expanded', 'true');
|
|
189
|
+
const stopActiveDescendant = $effect.root(() => {
|
|
190
|
+
$effect(() => {
|
|
191
|
+
if (state.items.length > 0) {
|
|
192
|
+
editorDom.setAttribute('aria-activedescendant', `${optionIdPrefix}${state.selectedIndex}`);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
editorDom.removeAttribute('aria-activedescendant');
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
handle = {
|
|
200
|
+
container,
|
|
201
|
+
component,
|
|
202
|
+
state,
|
|
203
|
+
cleanup: null,
|
|
204
|
+
editorDom,
|
|
205
|
+
stopActiveDescendant
|
|
206
|
+
};
|
|
207
|
+
const rect = props.clientRect?.();
|
|
208
|
+
if (rect) {
|
|
209
|
+
const virtualEl = { getBoundingClientRect: () => rect };
|
|
210
|
+
handle.cleanup = autoUpdate(virtualEl, container, () => {
|
|
211
|
+
void computePosition(virtualEl, container, {
|
|
212
|
+
placement: 'bottom-start',
|
|
213
|
+
middleware: [offset(6), flip(), shift({ padding: 8 })]
|
|
214
|
+
}).then(({ x, y }) => {
|
|
215
|
+
container.style.left = `${x}px`;
|
|
216
|
+
container.style.top = `${y}px`;
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
onUpdate: (props) => {
|
|
222
|
+
if (!handle)
|
|
223
|
+
return;
|
|
224
|
+
handle.state.items = props.items;
|
|
225
|
+
handle.state.selectedIndex = 0;
|
|
226
|
+
},
|
|
227
|
+
onKeyDown: (props) => {
|
|
228
|
+
if (!handle)
|
|
229
|
+
return false;
|
|
230
|
+
const len = Math.max(handle.state.items.length, 1);
|
|
231
|
+
if (props.event.key === 'ArrowDown') {
|
|
232
|
+
handle.state.selectedIndex = (handle.state.selectedIndex + 1) % len;
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
if (props.event.key === 'ArrowUp') {
|
|
236
|
+
handle.state.selectedIndex = (handle.state.selectedIndex + len - 1) % len;
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
if (props.event.key === 'Enter') {
|
|
240
|
+
handle.state.onPick(handle.state.selectedIndex);
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
},
|
|
245
|
+
onExit: () => {
|
|
246
|
+
if (!handle)
|
|
247
|
+
return;
|
|
248
|
+
handle.cleanup?.();
|
|
249
|
+
handle.stopActiveDescendant?.();
|
|
250
|
+
if (handle.editorDom) {
|
|
251
|
+
handle.editorDom.removeAttribute('aria-controls');
|
|
252
|
+
handle.editorDom.removeAttribute('aria-expanded');
|
|
253
|
+
handle.editorDom.removeAttribute('aria-activedescendant');
|
|
254
|
+
}
|
|
255
|
+
unmount(handle.component);
|
|
256
|
+
handle.container.remove();
|
|
257
|
+
handle = null;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
export const SlashCommandsExtension = Extension.create({
|
|
262
|
+
name: 'slashCommands',
|
|
263
|
+
addOptions() {
|
|
264
|
+
return {
|
|
265
|
+
suggestion: {
|
|
266
|
+
char: '/',
|
|
267
|
+
startOfLine: false,
|
|
268
|
+
allowSpaces: false,
|
|
269
|
+
command: ({ editor, range, props }) => {
|
|
270
|
+
editor.chain().focus().deleteRange(range).run();
|
|
271
|
+
props.run({ editor });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
addProseMirrorPlugins() {
|
|
277
|
+
return [
|
|
278
|
+
Suggestion({
|
|
279
|
+
editor: this.editor,
|
|
280
|
+
...this.options.suggestion
|
|
281
|
+
})
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
export function buildSlashExtension(commands, trigger = '/') {
|
|
286
|
+
return SlashCommandsExtension.configure({
|
|
287
|
+
suggestion: {
|
|
288
|
+
char: trigger,
|
|
289
|
+
startOfLine: false,
|
|
290
|
+
allowSpaces: false,
|
|
291
|
+
items: ({ query }) => substringFilter(commands, query),
|
|
292
|
+
render: buildSuggestionRender,
|
|
293
|
+
command: ({ editor, range, props }) => {
|
|
294
|
+
editor.chain().focus().deleteRange(range).run();
|
|
295
|
+
props.run({ editor });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SuggestionOptions } from '@tiptap/suggestion';
|
|
2
|
+
import type { MentionItem } from './editor.types.js';
|
|
3
|
+
interface BuildMentionSuggestionOptions {
|
|
4
|
+
onQuery: (query: string) => Promise<MentionItem[]>;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildMentionSuggestion(options: BuildMentionSuggestionOptions): Omit<SuggestionOptions, 'editor'>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';
|
|
2
|
+
let mentionSeq = 0;
|
|
3
|
+
function createPopup() {
|
|
4
|
+
const popup = document.createElement('div');
|
|
5
|
+
popup.setAttribute('data-editor-mention-popup', '');
|
|
6
|
+
popup.className = [
|
|
7
|
+
'absolute z-50 min-w-44 max-w-72 overflow-hidden',
|
|
8
|
+
'rounded-lg border border-outline-variant bg-surface shadow-lg',
|
|
9
|
+
'py-1 max-h-64 overflow-y-auto'
|
|
10
|
+
].join(' ');
|
|
11
|
+
return popup;
|
|
12
|
+
}
|
|
13
|
+
function renderItems(state) {
|
|
14
|
+
if (!state.listEl)
|
|
15
|
+
return;
|
|
16
|
+
state.listEl.innerHTML = '';
|
|
17
|
+
if (state.items.length === 0) {
|
|
18
|
+
const empty = document.createElement('div');
|
|
19
|
+
empty.className = 'px-3 py-2 text-sm text-on-surface-variant';
|
|
20
|
+
empty.textContent = 'No matches';
|
|
21
|
+
state.listEl.appendChild(empty);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
state.items.forEach((item, i) => {
|
|
25
|
+
const row = document.createElement('button');
|
|
26
|
+
row.type = 'button';
|
|
27
|
+
row.setAttribute('data-mention-item', '');
|
|
28
|
+
row.setAttribute('data-index', String(i));
|
|
29
|
+
row.setAttribute('role', 'option');
|
|
30
|
+
row.id = `${state.optionIdPrefix}${i}`;
|
|
31
|
+
row.setAttribute('aria-selected', i === state.selectedIndex ? 'true' : 'false');
|
|
32
|
+
row.className = [
|
|
33
|
+
'flex w-full items-center gap-2 px-3 py-1.5 text-sm text-start',
|
|
34
|
+
'hover:bg-surface-container-high',
|
|
35
|
+
i === state.selectedIndex
|
|
36
|
+
? 'bg-primary-container text-on-primary-container'
|
|
37
|
+
: 'text-on-surface'
|
|
38
|
+
].join(' ');
|
|
39
|
+
if (item.avatar) {
|
|
40
|
+
const img = document.createElement('img');
|
|
41
|
+
img.src = item.avatar;
|
|
42
|
+
img.alt = '';
|
|
43
|
+
img.className = 'size-5 rounded-full shrink-0 object-cover';
|
|
44
|
+
row.appendChild(img);
|
|
45
|
+
}
|
|
46
|
+
const label = document.createElement('span');
|
|
47
|
+
label.className = 'truncate';
|
|
48
|
+
label.textContent = item.label;
|
|
49
|
+
row.appendChild(label);
|
|
50
|
+
row.addEventListener('mousedown', (e) => {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
state.pickItem(i);
|
|
53
|
+
});
|
|
54
|
+
state.listEl?.appendChild(row);
|
|
55
|
+
});
|
|
56
|
+
if (state.editorDom && state.items.length > 0) {
|
|
57
|
+
state.editorDom.setAttribute('aria-activedescendant', `${state.optionIdPrefix}${state.selectedIndex}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function buildMentionSuggestion(options) {
|
|
61
|
+
return {
|
|
62
|
+
items: async ({ query }) => {
|
|
63
|
+
try {
|
|
64
|
+
return await options.onQuery(query);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
render: () => {
|
|
71
|
+
let state = null;
|
|
72
|
+
return {
|
|
73
|
+
onStart: (props) => {
|
|
74
|
+
if (typeof document === 'undefined')
|
|
75
|
+
return;
|
|
76
|
+
const seq = ++mentionSeq;
|
|
77
|
+
const listboxId = `ps-mention-listbox-${seq}`;
|
|
78
|
+
const optionIdPrefix = `ps-mention-${seq}-`;
|
|
79
|
+
const editorDom = props.editor.view.dom;
|
|
80
|
+
const popupEl = createPopup();
|
|
81
|
+
const listEl = document.createElement('div');
|
|
82
|
+
listEl.setAttribute('role', 'listbox');
|
|
83
|
+
listEl.id = listboxId;
|
|
84
|
+
listEl.setAttribute('aria-label', 'Mentions');
|
|
85
|
+
popupEl.appendChild(listEl);
|
|
86
|
+
document.body.appendChild(popupEl);
|
|
87
|
+
editorDom.setAttribute('aria-controls', listboxId);
|
|
88
|
+
editorDom.setAttribute('aria-expanded', 'true');
|
|
89
|
+
state = {
|
|
90
|
+
items: props.items,
|
|
91
|
+
selectedIndex: 0,
|
|
92
|
+
popupEl,
|
|
93
|
+
listEl,
|
|
94
|
+
cleanup: null,
|
|
95
|
+
editorDom,
|
|
96
|
+
listboxId,
|
|
97
|
+
optionIdPrefix,
|
|
98
|
+
pickItem: (i) => {
|
|
99
|
+
const it = state?.items[i];
|
|
100
|
+
if (!it)
|
|
101
|
+
return;
|
|
102
|
+
props.command({ ...it });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
renderItems(state);
|
|
106
|
+
const rect = props.clientRect?.();
|
|
107
|
+
if (rect) {
|
|
108
|
+
const virtualEl = {
|
|
109
|
+
getBoundingClientRect: () => rect
|
|
110
|
+
};
|
|
111
|
+
state.cleanup = autoUpdate(virtualEl, popupEl, () => {
|
|
112
|
+
void computePosition(virtualEl, popupEl, {
|
|
113
|
+
placement: 'bottom-start',
|
|
114
|
+
middleware: [offset(6), flip(), shift({ padding: 8 })]
|
|
115
|
+
}).then(({ x, y }) => {
|
|
116
|
+
popupEl.style.left = `${x}px`;
|
|
117
|
+
popupEl.style.top = `${y}px`;
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
onUpdate: (props) => {
|
|
123
|
+
if (!state)
|
|
124
|
+
return;
|
|
125
|
+
state.items = props.items;
|
|
126
|
+
state.selectedIndex = 0;
|
|
127
|
+
renderItems(state);
|
|
128
|
+
},
|
|
129
|
+
onKeyDown: (props) => {
|
|
130
|
+
if (!state)
|
|
131
|
+
return false;
|
|
132
|
+
const { event } = props;
|
|
133
|
+
if (event.key === 'ArrowDown') {
|
|
134
|
+
state.selectedIndex =
|
|
135
|
+
(state.selectedIndex + 1) % Math.max(state.items.length, 1);
|
|
136
|
+
renderItems(state);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
if (event.key === 'ArrowUp') {
|
|
140
|
+
state.selectedIndex =
|
|
141
|
+
(state.selectedIndex + state.items.length - 1) %
|
|
142
|
+
Math.max(state.items.length, 1);
|
|
143
|
+
renderItems(state);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
if (event.key === 'Enter') {
|
|
147
|
+
state.pickItem(state.selectedIndex);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
},
|
|
152
|
+
onExit: () => {
|
|
153
|
+
state?.cleanup?.();
|
|
154
|
+
state?.popupEl?.remove();
|
|
155
|
+
if (state?.editorDom) {
|
|
156
|
+
state.editorDom.removeAttribute('aria-controls');
|
|
157
|
+
state.editorDom.removeAttribute('aria-expanded');
|
|
158
|
+
state.editorDom.removeAttribute('aria-activedescendant');
|
|
159
|
+
}
|
|
160
|
+
state = null;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { EditorReactiveState, ToolbarAction } from './editor.types.js';
|
|
3
|
+
export interface ToolbarActionDef {
|
|
4
|
+
icon: string;
|
|
5
|
+
label: string;
|
|
6
|
+
isActive?: (state: EditorReactiveState) => boolean | undefined;
|
|
7
|
+
isDisabled?: (state: EditorReactiveState) => boolean | undefined;
|
|
8
|
+
run: (editor: Editor) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const TOOLBAR_ACTIONS: Record<ToolbarAction, ToolbarActionDef>;
|
|
11
|
+
export declare const DEFAULT_TOOLBAR: (ToolbarAction | '|')[];
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
function promptForLink(editor) {
|
|
2
|
+
const previous = editor.getAttributes('link').href ?? 'https://';
|
|
3
|
+
const url = typeof window === 'undefined' ? null : window.prompt('URL', previous);
|
|
4
|
+
if (url === null)
|
|
5
|
+
return;
|
|
6
|
+
if (url.trim() === '') {
|
|
7
|
+
editor.chain().focus().extendMarkRange('link').unsetLink().run();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run();
|
|
11
|
+
}
|
|
12
|
+
export const TOOLBAR_ACTIONS = {
|
|
13
|
+
bold: {
|
|
14
|
+
icon: 'lucide:bold',
|
|
15
|
+
label: 'Bold',
|
|
16
|
+
isActive: (s) => s.active.bold,
|
|
17
|
+
run: (ed) => ed.chain().focus().toggleBold().run()
|
|
18
|
+
},
|
|
19
|
+
italic: {
|
|
20
|
+
icon: 'lucide:italic',
|
|
21
|
+
label: 'Italic',
|
|
22
|
+
isActive: (s) => s.active.italic,
|
|
23
|
+
run: (ed) => ed.chain().focus().toggleItalic().run()
|
|
24
|
+
},
|
|
25
|
+
underline: {
|
|
26
|
+
icon: 'lucide:underline',
|
|
27
|
+
label: 'Underline',
|
|
28
|
+
isActive: (s) => s.active.underline,
|
|
29
|
+
run: (ed) => ed.chain().focus().toggleUnderline().run()
|
|
30
|
+
},
|
|
31
|
+
strike: {
|
|
32
|
+
icon: 'lucide:strikethrough',
|
|
33
|
+
label: 'Strikethrough',
|
|
34
|
+
isActive: (s) => s.active.strike,
|
|
35
|
+
run: (ed) => ed.chain().focus().toggleStrike().run()
|
|
36
|
+
},
|
|
37
|
+
code: {
|
|
38
|
+
icon: 'lucide:code',
|
|
39
|
+
label: 'Inline code',
|
|
40
|
+
isActive: (s) => s.active.code,
|
|
41
|
+
run: (ed) => ed.chain().focus().toggleCode().run()
|
|
42
|
+
},
|
|
43
|
+
h1: {
|
|
44
|
+
icon: 'lucide:heading-1',
|
|
45
|
+
label: 'Heading 1',
|
|
46
|
+
isActive: (s) => s.active.h1,
|
|
47
|
+
run: (ed) => ed.chain().focus().toggleHeading({ level: 1 }).run()
|
|
48
|
+
},
|
|
49
|
+
h2: {
|
|
50
|
+
icon: 'lucide:heading-2',
|
|
51
|
+
label: 'Heading 2',
|
|
52
|
+
isActive: (s) => s.active.h2,
|
|
53
|
+
run: (ed) => ed.chain().focus().toggleHeading({ level: 2 }).run()
|
|
54
|
+
},
|
|
55
|
+
h3: {
|
|
56
|
+
icon: 'lucide:heading-3',
|
|
57
|
+
label: 'Heading 3',
|
|
58
|
+
isActive: (s) => s.active.h3,
|
|
59
|
+
run: (ed) => ed.chain().focus().toggleHeading({ level: 3 }).run()
|
|
60
|
+
},
|
|
61
|
+
paragraph: {
|
|
62
|
+
icon: 'lucide:pilcrow',
|
|
63
|
+
label: 'Paragraph',
|
|
64
|
+
isActive: (s) => s.active.paragraph,
|
|
65
|
+
run: (ed) => ed.chain().focus().setParagraph().run()
|
|
66
|
+
},
|
|
67
|
+
bulletList: {
|
|
68
|
+
icon: 'lucide:list',
|
|
69
|
+
label: 'Bullet list',
|
|
70
|
+
isActive: (s) => s.active.bulletList,
|
|
71
|
+
run: (ed) => ed.chain().focus().toggleBulletList().run()
|
|
72
|
+
},
|
|
73
|
+
orderedList: {
|
|
74
|
+
icon: 'lucide:list-ordered',
|
|
75
|
+
label: 'Numbered list',
|
|
76
|
+
isActive: (s) => s.active.orderedList,
|
|
77
|
+
run: (ed) => ed.chain().focus().toggleOrderedList().run()
|
|
78
|
+
},
|
|
79
|
+
blockquote: {
|
|
80
|
+
icon: 'lucide:quote',
|
|
81
|
+
label: 'Quote',
|
|
82
|
+
isActive: (s) => s.active.blockquote,
|
|
83
|
+
run: (ed) => ed.chain().focus().toggleBlockquote().run()
|
|
84
|
+
},
|
|
85
|
+
codeBlock: {
|
|
86
|
+
icon: 'lucide:square-code',
|
|
87
|
+
label: 'Code block',
|
|
88
|
+
isActive: (s) => s.active.codeBlock,
|
|
89
|
+
run: (ed) => ed.chain().focus().toggleCodeBlock().run()
|
|
90
|
+
},
|
|
91
|
+
horizontalRule: {
|
|
92
|
+
icon: 'lucide:minus',
|
|
93
|
+
label: 'Horizontal rule',
|
|
94
|
+
run: (ed) => ed.chain().focus().setHorizontalRule().run()
|
|
95
|
+
},
|
|
96
|
+
link: {
|
|
97
|
+
icon: 'lucide:link',
|
|
98
|
+
label: 'Insert link',
|
|
99
|
+
isActive: (s) => s.active.link,
|
|
100
|
+
run: promptForLink
|
|
101
|
+
},
|
|
102
|
+
unlink: {
|
|
103
|
+
icon: 'lucide:unlink',
|
|
104
|
+
label: 'Remove link',
|
|
105
|
+
isDisabled: (s) => !s.active.link,
|
|
106
|
+
run: (ed) => ed.chain().focus().unsetLink().run()
|
|
107
|
+
},
|
|
108
|
+
alignLeft: {
|
|
109
|
+
icon: 'lucide:align-left',
|
|
110
|
+
label: 'Align left',
|
|
111
|
+
isActive: (s) => s.active.alignLeft,
|
|
112
|
+
run: (ed) => ed.chain().focus().setTextAlign('left').run()
|
|
113
|
+
},
|
|
114
|
+
alignCenter: {
|
|
115
|
+
icon: 'lucide:align-center',
|
|
116
|
+
label: 'Align center',
|
|
117
|
+
isActive: (s) => s.active.alignCenter,
|
|
118
|
+
run: (ed) => ed.chain().focus().setTextAlign('center').run()
|
|
119
|
+
},
|
|
120
|
+
alignRight: {
|
|
121
|
+
icon: 'lucide:align-right',
|
|
122
|
+
label: 'Align right',
|
|
123
|
+
isActive: (s) => s.active.alignRight,
|
|
124
|
+
run: (ed) => ed.chain().focus().setTextAlign('right').run()
|
|
125
|
+
},
|
|
126
|
+
alignJustify: {
|
|
127
|
+
icon: 'lucide:align-justify',
|
|
128
|
+
label: 'Align justify',
|
|
129
|
+
isActive: (s) => s.active.alignJustify,
|
|
130
|
+
run: (ed) => ed.chain().focus().setTextAlign('justify').run()
|
|
131
|
+
},
|
|
132
|
+
undo: {
|
|
133
|
+
icon: 'lucide:undo-2',
|
|
134
|
+
label: 'Undo',
|
|
135
|
+
isDisabled: (s) => !s.can.undo,
|
|
136
|
+
run: (ed) => ed.chain().focus().undo().run()
|
|
137
|
+
},
|
|
138
|
+
redo: {
|
|
139
|
+
icon: 'lucide:redo-2',
|
|
140
|
+
label: 'Redo',
|
|
141
|
+
isDisabled: (s) => !s.can.redo,
|
|
142
|
+
run: (ed) => ed.chain().focus().redo().run()
|
|
143
|
+
},
|
|
144
|
+
clearFormatting: {
|
|
145
|
+
icon: 'lucide:remove-formatting',
|
|
146
|
+
label: 'Clear formatting',
|
|
147
|
+
run: (ed) => ed.chain().focus().unsetAllMarks().clearNodes().run()
|
|
148
|
+
},
|
|
149
|
+
image: {
|
|
150
|
+
icon: 'lucide:image',
|
|
151
|
+
label: 'Insert image',
|
|
152
|
+
run: (ed) => {
|
|
153
|
+
if (typeof window === 'undefined')
|
|
154
|
+
return;
|
|
155
|
+
const url = window.prompt('Image URL', 'https://');
|
|
156
|
+
if (!url)
|
|
157
|
+
return;
|
|
158
|
+
ed.chain().focus().setImage({ src: url }).run();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
table: {
|
|
162
|
+
icon: 'lucide:table',
|
|
163
|
+
label: 'Insert table',
|
|
164
|
+
run: (ed) => {
|
|
165
|
+
ed.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
youtube: {
|
|
169
|
+
icon: 'lucide:youtube',
|
|
170
|
+
label: 'Insert YouTube video',
|
|
171
|
+
run: (ed) => {
|
|
172
|
+
if (typeof window === 'undefined')
|
|
173
|
+
return;
|
|
174
|
+
const url = window.prompt('YouTube URL', 'https://youtu.be/');
|
|
175
|
+
if (!url)
|
|
176
|
+
return;
|
|
177
|
+
ed.commands.setYoutubeVideo({ src: url });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
export const DEFAULT_TOOLBAR = [
|
|
182
|
+
'bold',
|
|
183
|
+
'italic',
|
|
184
|
+
'underline',
|
|
185
|
+
'strike',
|
|
186
|
+
'|',
|
|
187
|
+
'h1',
|
|
188
|
+
'h2',
|
|
189
|
+
'h3',
|
|
190
|
+
'|',
|
|
191
|
+
'bulletList',
|
|
192
|
+
'orderedList',
|
|
193
|
+
'blockquote',
|
|
194
|
+
'codeBlock',
|
|
195
|
+
'|',
|
|
196
|
+
'link',
|
|
197
|
+
'|',
|
|
198
|
+
'alignLeft',
|
|
199
|
+
'alignCenter',
|
|
200
|
+
'alignRight',
|
|
201
|
+
'|',
|
|
202
|
+
'undo',
|
|
203
|
+
'redo'
|
|
204
|
+
];
|