@peteai/presentation-editor 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/components/presentation-editor/app.css +12 -0
- package/dist/components/presentation-editor/cognition-slides.d.ts +56 -0
- package/dist/components/presentation-editor/cognition-slides.js +182 -0
- package/dist/components/presentation-editor/cursor-tooltip.svelte +29 -0
- package/dist/components/presentation-editor/cursor-tooltip.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/dragged.svelte +31 -0
- package/dist/components/presentation-editor/dragged.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/header.svelte +66 -0
- package/dist/components/presentation-editor/header.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/index.d.ts +2 -0
- package/dist/components/presentation-editor/index.js +2 -0
- package/dist/components/presentation-editor/layers/active-background-border.svelte +16 -0
- package/dist/components/presentation-editor/layers/active-background-border.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/layers/active-layer-border.svelte +30 -0
- package/dist/components/presentation-editor/layers/active-layer-border.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/buttons/border-button/border-button.svelte +231 -0
- package/dist/components/presentation-editor/layers/buttons/border-button/border-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/buttons/border-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/buttons/border-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/corner-radius-button.svelte +88 -0
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/corner-radius-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/buttons/flip-button/flip-button.svelte +39 -0
- package/dist/components/presentation-editor/layers/buttons/flip-button/flip-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/buttons/flip-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/buttons/flip-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/buttons/opacity-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/buttons/opacity-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/buttons/opacity-button/opacity-button.svelte +93 -0
- package/dist/components/presentation-editor/layers/buttons/opacity-button/opacity-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/corner-scale-control.svelte +179 -0
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/corner-scale-control.svelte.d.ts +184 -0
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/index.js +4 -0
- package/dist/components/presentation-editor/layers/controls/rotate-control/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/controls/rotate-control/index.js +4 -0
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte +105 -0
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/controls/side-resize-control/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/controls/side-resize-control/index.js +4 -0
- package/dist/components/presentation-editor/layers/controls/side-resize-control/side-resize-control.svelte +220 -0
- package/dist/components/presentation-editor/layers/controls/side-resize-control/side-resize-control.svelte.d.ts +215 -0
- package/dist/components/presentation-editor/layers/controls/side-scale-control/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/controls/side-scale-control/index.js +4 -0
- package/dist/components/presentation-editor/layers/controls/side-scale-control/side-scale-control.svelte +141 -0
- package/dist/components/presentation-editor/layers/controls/side-scale-control/side-scale-control.svelte.d.ts +114 -0
- package/dist/components/presentation-editor/layers/hovered-layer.svelte +34 -0
- package/dist/components/presentation-editor/layers/hovered-layer.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/index.d.ts +10 -0
- package/dist/components/presentation-editor/layers/index.js +22 -0
- package/dist/components/presentation-editor/layers/layer-button.svelte +38 -0
- package/dist/components/presentation-editor/layers/layer-button.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/layer-thumb-wrapper.svelte +36 -0
- package/dist/components/presentation-editor/layers/layer-thumb-wrapper.svelte.d.ts +15 -0
- package/dist/components/presentation-editor/layers/layer-wrapper.svelte +288 -0
- package/dist/components/presentation-editor/layers/layer-wrapper.svelte.d.ts +10 -0
- package/dist/components/presentation-editor/layers/types/background/background-content.svelte +11 -0
- package/dist/components/presentation-editor/layers/types/background/background-content.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-buttons.svelte +81 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-buttons.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-thumb.svelte +12 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-thumb.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer.svelte +103 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/background/index.d.ts +5 -0
- package/dist/components/presentation-editor/layers/types/background/index.js +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/alignment-button.svelte +45 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/alignment-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte +19 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/case-button.svelte +37 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/case-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/color-button.svelte +88 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/color-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/font-size-button.svelte +132 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/font-size-button.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte +19 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte +37 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/strikethrough-button.svelte +19 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/strikethrough-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/underline-button.svelte +20 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/underline-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/editor/Editor.d.ts +4 -0
- package/dist/components/presentation-editor/layers/types/html/editor/Editor.js +4 -0
- package/dist/components/presentation-editor/layers/types/html/editor/createEditor.d.ts +5 -0
- package/dist/components/presentation-editor/layers/types/html/editor/createEditor.js +18 -0
- package/dist/components/presentation-editor/layers/types/html/editor/editor-content.svelte +60 -0
- package/dist/components/presentation-editor/layers/types/html/editor/editor-content.svelte.d.ts +5 -0
- package/dist/components/presentation-editor/layers/types/html/editor/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/editor/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/editor/types.d.ts +10 -0
- package/dist/components/presentation-editor/layers/types/html/editor/types.js +1 -0
- package/dist/components/presentation-editor/layers/types/html/editor.css +7 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/font-size.d.ts +20 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/font-size.js +44 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/line-height/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/line-height/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/line-height/line-height.d.ts +22 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/line-height/line-height.js +44 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/selection/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/selection/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/selection/selection.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/selection/selection.js +30 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/text-transform/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/text-transform/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/text-transform/text-transform.d.ts +20 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/text-transform/text-transform.js +50 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/unstyled-list.d.ts +47 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/unstyled-list.js +74 -0
- package/dist/components/presentation-editor/layers/types/html/html-content.svelte +21 -0
- package/dist/components/presentation-editor/layers/types/html/html-content.svelte.d.ts +5 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-active.svelte +159 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-active.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-buttons.svelte +42 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-buttons.svelte.d.ts +10 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-thumb.svelte +24 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-thumb.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte +97 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/index.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/index.js +58 -0
- package/dist/components/presentation-editor/layers/types/image/image-content.svelte +96 -0
- package/dist/components/presentation-editor/layers/types/image/image-content.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer-active.svelte +39 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer-active.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer-buttons.svelte +21 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer-buttons.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer-thumb.svelte +13 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer-thumb.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer.svelte +80 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/image/index.d.ts +5 -0
- package/dist/components/presentation-editor/layers/types/image/index.js +5 -0
- package/dist/components/presentation-editor/layers/utils.d.ts +32 -0
- package/dist/components/presentation-editor/layers/utils.js +92 -0
- package/dist/components/presentation-editor/presentation-editor.svelte +336 -0
- package/dist/components/presentation-editor/presentation-editor.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/presentation-editor.svelte.js +352 -0
- package/dist/components/presentation-editor/sidebar/images-library.svelte +108 -0
- package/dist/components/presentation-editor/sidebar/images-library.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/layers.svelte +94 -0
- package/dist/components/presentation-editor/sidebar/layers.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/sidebar/sidebar.svelte +20 -0
- package/dist/components/presentation-editor/sidebar/sidebar.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/uploads-image.svelte +64 -0
- package/dist/components/presentation-editor/sidebar/uploads-image.svelte.d.ts +5 -0
- package/dist/components/presentation-editor/slide-editor.svelte +106 -0
- package/dist/components/presentation-editor/slide-editor.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/slide-inner.svelte +53 -0
- package/dist/components/presentation-editor/slide-inner.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-delete-button.svelte +32 -0
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-delete-button.svelte.d.ts +10 -0
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-duplicate-button.svelte +34 -0
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-duplicate-button.svelte.d.ts +10 -0
- package/dist/components/presentation-editor/slides-navigation/slide-preview.svelte +134 -0
- package/dist/components/presentation-editor/slides-navigation/slide-preview.svelte.d.ts +11 -0
- package/dist/components/presentation-editor/slides-navigation/slides-navigation.svelte +100 -0
- package/dist/components/presentation-editor/slides-navigation/slides-navigation.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/snapping-guides.svelte +41 -0
- package/dist/components/presentation-editor/snapping-guides.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/types.d.ts +118 -0
- package/dist/components/presentation-editor/types.js +1 -0
- package/dist/components/presentation-editor/utils.d.ts +5 -0
- package/dist/components/presentation-editor/utils.js +348 -0
- package/dist/components/ui/button/button.svelte +94 -0
- package/dist/components/ui/button/button.svelte.d.ts +155 -0
- package/dist/components/ui/button/index.d.ts +2 -0
- package/dist/components/ui/button/index.js +4 -0
- package/dist/components/ui/context-menu/context-menu-checkbox-item.svelte +40 -0
- package/dist/components/ui/context-menu/context-menu-checkbox-item.svelte.d.ts +8 -0
- package/dist/components/ui/context-menu/context-menu-content.svelte +24 -0
- package/dist/components/ui/context-menu/context-menu-content.svelte.d.ts +7 -0
- package/dist/components/ui/context-menu/context-menu-group-heading.svelte +19 -0
- package/dist/components/ui/context-menu/context-menu-group-heading.svelte.d.ts +7 -0
- package/dist/components/ui/context-menu/context-menu-item.svelte +23 -0
- package/dist/components/ui/context-menu/context-menu-item.svelte.d.ts +7 -0
- package/dist/components/ui/context-menu/context-menu-radio-item.svelte +30 -0
- package/dist/components/ui/context-menu/context-menu-radio-item.svelte.d.ts +4 -0
- package/dist/components/ui/context-menu/context-menu-separator.svelte +16 -0
- package/dist/components/ui/context-menu/context-menu-separator.svelte.d.ts +4 -0
- package/dist/components/ui/context-menu/context-menu-shortcut.svelte +20 -0
- package/dist/components/ui/context-menu/context-menu-shortcut.svelte.d.ts +5 -0
- package/dist/components/ui/context-menu/context-menu-sub-content.svelte +19 -0
- package/dist/components/ui/context-menu/context-menu-sub-content.svelte.d.ts +4 -0
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte +28 -0
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte.d.ts +7 -0
- package/dist/components/ui/context-menu/index.d.ts +16 -0
- package/dist/components/ui/context-menu/index.js +18 -0
- package/dist/components/ui/dialog/dialog-content.svelte +38 -0
- package/dist/components/ui/dialog/dialog-content.svelte.d.ts +9 -0
- package/dist/components/ui/dialog/dialog-description.svelte +16 -0
- package/dist/components/ui/dialog/dialog-description.svelte.d.ts +4 -0
- package/dist/components/ui/dialog/dialog-footer.svelte +20 -0
- package/dist/components/ui/dialog/dialog-footer.svelte.d.ts +5 -0
- package/dist/components/ui/dialog/dialog-header.svelte +20 -0
- package/dist/components/ui/dialog/dialog-header.svelte.d.ts +5 -0
- package/dist/components/ui/dialog/dialog-overlay.svelte +19 -0
- package/dist/components/ui/dialog/dialog-overlay.svelte.d.ts +4 -0
- package/dist/components/ui/dialog/dialog-title.svelte +16 -0
- package/dist/components/ui/dialog/dialog-title.svelte.d.ts +4 -0
- package/dist/components/ui/dialog/index.d.ts +12 -0
- package/dist/components/ui/dialog/index.js +14 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +40 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +8 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +21 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +4 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +19 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +7 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +23 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +7 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte +23 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +8 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +30 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +4 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte +16 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +4 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +20 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +5 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +19 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +4 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +28 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +7 -0
- package/dist/components/ui/dropdown-menu/index.d.ts +25 -0
- package/dist/components/ui/dropdown-menu/index.js +17 -0
- package/dist/components/ui/input/index.d.ts +2 -0
- package/dist/components/ui/input/index.js +4 -0
- package/dist/components/ui/input/input.svelte +22 -0
- package/dist/components/ui/input/input.svelte.d.ts +5 -0
- package/dist/components/ui/label/index.d.ts +2 -0
- package/dist/components/ui/label/index.js +4 -0
- package/dist/components/ui/label/label.svelte +19 -0
- package/dist/components/ui/label/label.svelte.d.ts +4 -0
- package/dist/components/ui/popover/index.d.ts +6 -0
- package/dist/components/ui/popover/index.js +8 -0
- package/dist/components/ui/popover/popover-content.svelte +25 -0
- package/dist/components/ui/popover/popover-content.svelte.d.ts +4 -0
- package/dist/components/ui/scroll-area/index.d.ts +3 -0
- package/dist/components/ui/scroll-area/index.js +5 -0
- package/dist/components/ui/scroll-area/scroll-area-scrollbar.svelte +29 -0
- package/dist/components/ui/scroll-area/scroll-area-scrollbar.svelte.d.ts +4 -0
- package/dist/components/ui/scroll-area/scroll-area.svelte +34 -0
- package/dist/components/ui/scroll-area/scroll-area.svelte.d.ts +10 -0
- package/dist/components/ui/separator/index.d.ts +2 -0
- package/dist/components/ui/separator/index.js +4 -0
- package/dist/components/ui/separator/separator.svelte +22 -0
- package/dist/components/ui/separator/separator.svelte.d.ts +4 -0
- package/dist/components/ui/slider/index.d.ts +2 -0
- package/dist/components/ui/slider/index.js +4 -0
- package/dist/components/ui/slider/slider.svelte +34 -0
- package/dist/components/ui/slider/slider.svelte.d.ts +4 -0
- package/dist/components/ui/toggle/index.d.ts +3 -0
- package/dist/components/ui/toggle/index.js +5 -0
- package/dist/components/ui/toggle/toggle.svelte +51 -0
- package/dist/components/ui/toggle/toggle.svelte.d.ts +90 -0
- package/dist/components/ui/tooltip/index.d.ts +6 -0
- package/dist/components/ui/tooltip/index.js +8 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte +21 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +4 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.js +154 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +31 -0
- package/package.json +99 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import uniqid from 'uniqid';
|
|
2
|
+
import { getContext, setContext } from 'svelte';
|
|
3
|
+
import { cognitionImages, cognitionSlides } from './cognition-slides.js';
|
|
4
|
+
import { cognitionSlideToJson } from './utils.js';
|
|
5
|
+
import { calculateBoundingBox } from './layers/utils.js';
|
|
6
|
+
export class PresentationEditor {
|
|
7
|
+
mode = 'multiple';
|
|
8
|
+
slides = $state(cognitionSlides.map(cognitionSlideToJson)); // getSlides()
|
|
9
|
+
images = $state(cognitionImages);
|
|
10
|
+
width = 1920;
|
|
11
|
+
height = 1080;
|
|
12
|
+
zoom = $state(0.4);
|
|
13
|
+
generateId = () => uniqid();
|
|
14
|
+
onImageUpload;
|
|
15
|
+
onSlideAdd;
|
|
16
|
+
onSlideUpdate;
|
|
17
|
+
onSlideRemove;
|
|
18
|
+
onLayerAdd;
|
|
19
|
+
onLayerUpdate;
|
|
20
|
+
onLayerRemove;
|
|
21
|
+
activeSlide = $state();
|
|
22
|
+
clipboard = null;
|
|
23
|
+
slideSelected = $state(false);
|
|
24
|
+
activeLayer = $state();
|
|
25
|
+
activeBackground = $state(false);
|
|
26
|
+
htmlEditor = $state.raw(null);
|
|
27
|
+
activeAction = $state(null);
|
|
28
|
+
historyActions = $state([]);
|
|
29
|
+
historyIndex = $state(-1);
|
|
30
|
+
dragged = $state();
|
|
31
|
+
fileDragged = $state(false);
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
if (options.mode === 'single') {
|
|
34
|
+
const { slide, ...rest } = options;
|
|
35
|
+
Object.assign(this, { ...rest });
|
|
36
|
+
if (slide) {
|
|
37
|
+
Object.assign(this, { slides: [slide] });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
Object.assign(this, options);
|
|
42
|
+
}
|
|
43
|
+
if (!this.slides.length) {
|
|
44
|
+
this.addSlide({ index: 0 });
|
|
45
|
+
}
|
|
46
|
+
// initial sorting
|
|
47
|
+
this.sortSlides();
|
|
48
|
+
this.slides.forEach((slide) => this.sortLayers(slide.layers));
|
|
49
|
+
this.activeSlide = this.slides[0];
|
|
50
|
+
setPresentationEditorContext(this);
|
|
51
|
+
}
|
|
52
|
+
sortLayers(layers) {
|
|
53
|
+
layers.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
54
|
+
}
|
|
55
|
+
sortSlides() {
|
|
56
|
+
this.slides.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
57
|
+
}
|
|
58
|
+
findSlideIndex(slideId) {
|
|
59
|
+
return this.slides.findIndex(({ id }) => id === slideId);
|
|
60
|
+
}
|
|
61
|
+
buildEmptySlide(sortOrder = 1) {
|
|
62
|
+
return {
|
|
63
|
+
id: this.generateId(),
|
|
64
|
+
sortOrder,
|
|
65
|
+
backgroundColor: null,
|
|
66
|
+
layers: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
addSlide({ slide = this.buildEmptySlide(), index = this.findSlideIndex(this.activeSlide.id) + 1, } = {}) {
|
|
70
|
+
if (this.mode !== 'multiple')
|
|
71
|
+
return;
|
|
72
|
+
const prevSlide = this.slides[index - 1];
|
|
73
|
+
const nextSlide = this.slides[index];
|
|
74
|
+
if (!prevSlide && !nextSlide)
|
|
75
|
+
return;
|
|
76
|
+
const sortOrder = nextSlide && prevSlide
|
|
77
|
+
? (prevSlide.sortOrder + nextSlide.sortOrder) / 2
|
|
78
|
+
: prevSlide
|
|
79
|
+
? prevSlide.sortOrder + 1
|
|
80
|
+
: nextSlide.sortOrder - 1;
|
|
81
|
+
this.historyPush({ type: 'slideAdd', slide: { ...slide, sortOrder } });
|
|
82
|
+
}
|
|
83
|
+
removeSlide(slide) {
|
|
84
|
+
if (this.mode !== 'multiple')
|
|
85
|
+
return;
|
|
86
|
+
this.historyPush({ type: 'slideRemove', slide });
|
|
87
|
+
}
|
|
88
|
+
duplicateSlide(slide) {
|
|
89
|
+
if (this.mode !== 'multiple')
|
|
90
|
+
return;
|
|
91
|
+
const { layers, ...rest } = slide;
|
|
92
|
+
const duplicate = {
|
|
93
|
+
...rest,
|
|
94
|
+
id: this.generateId(),
|
|
95
|
+
layers: layers.map((layer) => ({ ...layer, id: this.generateId() })),
|
|
96
|
+
};
|
|
97
|
+
this.addSlide({ slide: duplicate });
|
|
98
|
+
}
|
|
99
|
+
async addImageLayer({ image, x, y, width, height, sortOrder, ...rest }) {
|
|
100
|
+
const imageLayer = {
|
|
101
|
+
id: this.generateId(),
|
|
102
|
+
type: 'image',
|
|
103
|
+
x,
|
|
104
|
+
y,
|
|
105
|
+
width,
|
|
106
|
+
height,
|
|
107
|
+
image,
|
|
108
|
+
sortOrder: sortOrder ??
|
|
109
|
+
(this.activeSlide.layers.length
|
|
110
|
+
? this.activeSlide.layers[this.activeSlide.layers.length - 1].sortOrder + 1
|
|
111
|
+
: 1),
|
|
112
|
+
rotate: null,
|
|
113
|
+
opacity: null,
|
|
114
|
+
scale: null,
|
|
115
|
+
offsetX: null,
|
|
116
|
+
offsetY: null,
|
|
117
|
+
cornerRadius: null,
|
|
118
|
+
flipX: false,
|
|
119
|
+
flipY: false,
|
|
120
|
+
borderStyle: null,
|
|
121
|
+
borderWidth: null,
|
|
122
|
+
borderColor: null,
|
|
123
|
+
...rest,
|
|
124
|
+
};
|
|
125
|
+
console.log('imageLayer', imageLayer);
|
|
126
|
+
this.historyPush({ type: 'layerAdd', layer: { ...imageLayer } });
|
|
127
|
+
}
|
|
128
|
+
addLayer({ layer, index = this.activeSlide.layers.length }) {
|
|
129
|
+
const prev = this.activeSlide.layers[index - 1];
|
|
130
|
+
const next = this.activeSlide.layers[index];
|
|
131
|
+
if (!prev && !next)
|
|
132
|
+
return;
|
|
133
|
+
const sortOrder = next && prev
|
|
134
|
+
? (prev.sortOrder + next.sortOrder) / 2
|
|
135
|
+
: prev
|
|
136
|
+
? prev.sortOrder + 1
|
|
137
|
+
: next.sortOrder - 1;
|
|
138
|
+
this.historyPush({ type: 'layerAdd', layer: { ...layer, sortOrder } });
|
|
139
|
+
}
|
|
140
|
+
duplicateLayer(layer) {
|
|
141
|
+
const increment = 50;
|
|
142
|
+
const scale = layer.scale || 1;
|
|
143
|
+
const xIncrement = layer.x + (layer.width * scale) / 2 > this.width / 2 ? -increment : increment;
|
|
144
|
+
const yIncrement = layer.y + (layer.height * scale) / 2 > this.height / 2 ? -increment : increment;
|
|
145
|
+
let xAdjust = 0;
|
|
146
|
+
let iteration = 1;
|
|
147
|
+
const tryToDuplicate = () => {
|
|
148
|
+
const duplicate = {
|
|
149
|
+
...layer,
|
|
150
|
+
id: this.generateId(),
|
|
151
|
+
x: layer.x + xAdjust + xIncrement * iteration,
|
|
152
|
+
y: layer.y + yIncrement * iteration,
|
|
153
|
+
};
|
|
154
|
+
const occupied = this.activeSlide.layers.some((l) => l.x === duplicate.x &&
|
|
155
|
+
l.y === duplicate.y &&
|
|
156
|
+
l.width === duplicate.width &&
|
|
157
|
+
l.height === duplicate.height);
|
|
158
|
+
if (occupied) {
|
|
159
|
+
iteration++;
|
|
160
|
+
tryToDuplicate();
|
|
161
|
+
}
|
|
162
|
+
else if (this.checkIfLayerInBounds(duplicate, true)) {
|
|
163
|
+
this.addLayer({ layer: duplicate });
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
xAdjust += xIncrement;
|
|
167
|
+
iteration = 0;
|
|
168
|
+
const newX = layer.x + xAdjust;
|
|
169
|
+
if (newX >= 0 && newX < this.width) {
|
|
170
|
+
tryToDuplicate();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
tryToDuplicate();
|
|
175
|
+
}
|
|
176
|
+
setActiveSlide(slideId) {
|
|
177
|
+
if (this.mode !== 'multiple')
|
|
178
|
+
return;
|
|
179
|
+
const slide = this.slides.find(({ id }) => id === slideId);
|
|
180
|
+
if (slide) {
|
|
181
|
+
this.setActiveLayer(null);
|
|
182
|
+
// this.historyReset();
|
|
183
|
+
this.activeSlide = slide;
|
|
184
|
+
this.slideSelected = true;
|
|
185
|
+
return slide;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
setActiveLayer(layer) {
|
|
189
|
+
this.activeAction = null;
|
|
190
|
+
this.activeLayer = layer;
|
|
191
|
+
this.activeBackground = false;
|
|
192
|
+
this.slideSelected = false;
|
|
193
|
+
}
|
|
194
|
+
setActiveBackground(value) {
|
|
195
|
+
this.activeAction = null;
|
|
196
|
+
this.activeLayer = null;
|
|
197
|
+
this.activeBackground = value;
|
|
198
|
+
this.slideSelected = false;
|
|
199
|
+
}
|
|
200
|
+
async applyChanges(action, type) {
|
|
201
|
+
if (this.mode === 'multiple' && (action.type === 'slideAdd' || action.type === 'slideRemove')) {
|
|
202
|
+
if ((action.type === 'slideAdd' && type === 'redo') ||
|
|
203
|
+
(action.type === 'slideRemove' && type === 'undo')) {
|
|
204
|
+
let newSlide = { ...action.slide };
|
|
205
|
+
if (this.onSlideAdd) {
|
|
206
|
+
newSlide = await this.onSlideAdd(action.slide);
|
|
207
|
+
}
|
|
208
|
+
this.slides.push(newSlide);
|
|
209
|
+
this.sortSlides();
|
|
210
|
+
this.setActiveSlide(newSlide.id);
|
|
211
|
+
if (action.type === 'slideRemove' && action.newSlide) {
|
|
212
|
+
const slideId = action.newSlide.id;
|
|
213
|
+
const index = this.slides.findIndex(({ id }) => id === slideId);
|
|
214
|
+
if (~index) {
|
|
215
|
+
this.slides.splice(index, 1);
|
|
216
|
+
this.onSlideRemove?.(action.newSlide.id);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const index = this.slides.findIndex(({ id }) => id === action.slide.id);
|
|
222
|
+
if (~index) {
|
|
223
|
+
this.slides.splice(index, 1);
|
|
224
|
+
this.onSlideRemove?.(action.slide.id);
|
|
225
|
+
if (!this.slides.length && action.type === 'slideRemove') {
|
|
226
|
+
let newSlide = this.buildEmptySlide();
|
|
227
|
+
if (this.onSlideAdd) {
|
|
228
|
+
newSlide = await this.onSlideAdd(action.slide);
|
|
229
|
+
}
|
|
230
|
+
this.slides.push(newSlide);
|
|
231
|
+
this.setActiveSlide(newSlide.id);
|
|
232
|
+
action.newSlide = newSlide;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
this.setActiveSlide(this.slides[index > 0 ? index - 1 : 0].id);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const slide = this.slides.find(({ id }) => id === action.slideId);
|
|
242
|
+
if (!slide)
|
|
243
|
+
return;
|
|
244
|
+
if (this.mode === 'multiple' && action.type === 'slide') {
|
|
245
|
+
Object.assign(slide, action[type]);
|
|
246
|
+
if ('sortOrder' in action[type]) {
|
|
247
|
+
this.sortSlides();
|
|
248
|
+
}
|
|
249
|
+
this.onSlideUpdate?.(action.slideId, action[type]);
|
|
250
|
+
}
|
|
251
|
+
else if (action.type === 'layerAdd' || action.type === 'layerRemove') {
|
|
252
|
+
if ((action.type === 'layerAdd' && type === 'redo') ||
|
|
253
|
+
(action.type === 'layerRemove' && type === 'undo')) {
|
|
254
|
+
let layer = { ...action.layer };
|
|
255
|
+
if (this.onLayerAdd) {
|
|
256
|
+
layer = await this.onLayerAdd(action.slideId, action.layer);
|
|
257
|
+
}
|
|
258
|
+
slide.layers.push(layer);
|
|
259
|
+
this.sortLayers(slide.layers);
|
|
260
|
+
this.setActiveLayer(layer);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const index = slide.layers.findIndex(({ id }) => id === action.layer.id);
|
|
264
|
+
if (~index) {
|
|
265
|
+
slide.layers.splice(index, 1);
|
|
266
|
+
this.onLayerRemove?.(action.slideId, action.layer.id, action.layer.type);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else if (!action.type || action.type === 'layer') {
|
|
271
|
+
const layer = slide.layers.find(({ id }) => id === action.layer.id);
|
|
272
|
+
if (!layer)
|
|
273
|
+
return;
|
|
274
|
+
Object.assign(layer, action[type]);
|
|
275
|
+
if ('sortOrder' in action[type]) {
|
|
276
|
+
this.sortLayers(slide.layers);
|
|
277
|
+
}
|
|
278
|
+
this.onLayerUpdate?.(action.slideId, action.layer.id, action.layer.type, action[type]);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
historyReset() {
|
|
283
|
+
this.historyActions = [];
|
|
284
|
+
this.historyIndex = -1;
|
|
285
|
+
}
|
|
286
|
+
async historyPush(newAction, slideId) {
|
|
287
|
+
const action = { ...newAction, slideId: slideId ?? this.activeSlide.id };
|
|
288
|
+
this.historyActions = [...this.historyActions.slice(0, this.historyIndex + 1), action];
|
|
289
|
+
this.historyIndex = this.historyActions.length - 1;
|
|
290
|
+
await this.applyChanges(action, 'redo');
|
|
291
|
+
}
|
|
292
|
+
async historyUndo() {
|
|
293
|
+
if (this.historyIndex >= 0) {
|
|
294
|
+
const action = this.historyActions[this.historyIndex];
|
|
295
|
+
this.historyIndex--;
|
|
296
|
+
await this.applyChanges(action, 'undo');
|
|
297
|
+
if (this.activeLayer) {
|
|
298
|
+
if (action.type === 'layerAdd' && action.layer.id === this.activeLayer.id) {
|
|
299
|
+
this.setActiveLayer(null);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
async historyRedo() {
|
|
305
|
+
if (this.historyIndex < this.historyActions.length - 1) {
|
|
306
|
+
this.historyIndex++;
|
|
307
|
+
const action = this.historyActions[this.historyIndex];
|
|
308
|
+
await this.applyChanges(action, 'redo');
|
|
309
|
+
if (this.activeLayer) {
|
|
310
|
+
if (action.type === 'layerRemove' && action.layer.id === this.activeLayer.id) {
|
|
311
|
+
this.setActiveLayer(null);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async removeBackground() {
|
|
317
|
+
await this.historyPush({
|
|
318
|
+
type: 'slide',
|
|
319
|
+
undo: { backgroundColor: this.activeSlide.backgroundColor },
|
|
320
|
+
redo: { backgroundColor: null },
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
async removeLayer(layer) {
|
|
324
|
+
await this.historyPush({
|
|
325
|
+
type: 'layerRemove',
|
|
326
|
+
layer: this.activeAction?.layer ?? layer,
|
|
327
|
+
});
|
|
328
|
+
this.setActiveLayer(null);
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
checkIfLayerInBounds(layer, check = false) {
|
|
332
|
+
const bBox = calculateBoundingBox(layer);
|
|
333
|
+
const scale = layer.scale || 1;
|
|
334
|
+
if (bBox.x > this.width ||
|
|
335
|
+
bBox.y > this.height ||
|
|
336
|
+
bBox.x + bBox.width * scale < 0 ||
|
|
337
|
+
bBox.y * scale + bBox.height < 0) {
|
|
338
|
+
if (!check) {
|
|
339
|
+
this.removeLayer(layer);
|
|
340
|
+
}
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const presentationEditorKey = Symbol('presentationEditor');
|
|
347
|
+
export function setPresentationEditorContext(presentationEditor) {
|
|
348
|
+
setContext(presentationEditorKey, presentationEditor);
|
|
349
|
+
}
|
|
350
|
+
export function getPresentationEditorContext() {
|
|
351
|
+
return getContext(presentationEditorKey);
|
|
352
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CloudUploadIcon from 'lucide-svelte/icons/cloud-upload';
|
|
3
|
+
import ImageIcon from 'lucide-svelte/icons/image';
|
|
4
|
+
import { Button, buttonVariants } from '../../ui/button/index.js';
|
|
5
|
+
import * as Dialog from '../../ui/dialog/index.js';
|
|
6
|
+
import { Input } from '../../ui/input/index.js';
|
|
7
|
+
import { Label } from '../../ui/label/index.js';
|
|
8
|
+
import UploadsImage from './uploads-image.svelte';
|
|
9
|
+
import { checkImage } from '../utils.js';
|
|
10
|
+
import { getPresentationEditorContext } from '../presentation-editor.svelte.js';
|
|
11
|
+
|
|
12
|
+
const editor = getPresentationEditorContext();
|
|
13
|
+
|
|
14
|
+
let open = $state(false);
|
|
15
|
+
let url = $state('');
|
|
16
|
+
let error = $state(false);
|
|
17
|
+
|
|
18
|
+
const resetState = () => {
|
|
19
|
+
url = '';
|
|
20
|
+
error = false;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const onFormSubmit = (e: Event) => {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
|
|
26
|
+
console.log('submit', url);
|
|
27
|
+
checkImage(url)
|
|
28
|
+
.then((image) => {
|
|
29
|
+
console.log('image', image);
|
|
30
|
+
editor.images.push({
|
|
31
|
+
id: editor.generateId(),
|
|
32
|
+
src: url,
|
|
33
|
+
width: image.width,
|
|
34
|
+
height: image.height,
|
|
35
|
+
});
|
|
36
|
+
error = false;
|
|
37
|
+
open = false;
|
|
38
|
+
url = '';
|
|
39
|
+
})
|
|
40
|
+
.catch((err) => {
|
|
41
|
+
console.log('err', err);
|
|
42
|
+
error = true;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class="relative flex h-full shrink-0 flex-col gap-2">
|
|
48
|
+
{#if editor.fileDragged}
|
|
49
|
+
<div
|
|
50
|
+
class="bg-background absolute inset-0 z-10 flex h-full w-full flex-col items-center justify-center"
|
|
51
|
+
>
|
|
52
|
+
<div class="grid gap-6">
|
|
53
|
+
<div class="grid justify-center">
|
|
54
|
+
<CloudUploadIcon class="m-auto h-8 w-8" />
|
|
55
|
+
<span class="text-center font-semibold">Drop files to upload</span>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="grid w-full justify-center">
|
|
59
|
+
<div class="flex items-center justify-center gap-1">
|
|
60
|
+
<ImageIcon class="h-4 w-4" />
|
|
61
|
+
<p class="text-sm font-semibold">Images</p>
|
|
62
|
+
</div>
|
|
63
|
+
<p class="text-muted-foreground text-xs">GIF, JPG, PNG</p>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
{/if}
|
|
68
|
+
<div class="text-xl font-medium text-gray-500">Images</div>
|
|
69
|
+
<div class="-m-1">
|
|
70
|
+
{#each editor.images as image}
|
|
71
|
+
<UploadsImage {image} />
|
|
72
|
+
{/each}
|
|
73
|
+
</div>
|
|
74
|
+
<div>
|
|
75
|
+
<Dialog.Root bind:open onOpenChange={resetState}>
|
|
76
|
+
<Dialog.Trigger class={buttonVariants({ variant: 'default' })}>Upload Image</Dialog.Trigger>
|
|
77
|
+
<Dialog.Content>
|
|
78
|
+
<form onsubmit={onFormSubmit}>
|
|
79
|
+
<Dialog.Header>
|
|
80
|
+
<Dialog.Title>Upload Image</Dialog.Title>
|
|
81
|
+
<Dialog.Description>Add image to the library by URL or drop it here.</Dialog.Description
|
|
82
|
+
>
|
|
83
|
+
</Dialog.Header>
|
|
84
|
+
<div class="grid gap-4 py-4">
|
|
85
|
+
<div class="grid grid-cols-4 items-center gap-4">
|
|
86
|
+
<Label for="url" class="text-right">Image URL</Label>
|
|
87
|
+
<Input
|
|
88
|
+
type="url"
|
|
89
|
+
id="url"
|
|
90
|
+
placeholder="https://..."
|
|
91
|
+
bind:value={url}
|
|
92
|
+
class="col-span-3"
|
|
93
|
+
/>
|
|
94
|
+
{#if error}
|
|
95
|
+
<div class="text-destructive col-span-3 col-start-2 text-sm font-medium">
|
|
96
|
+
Invalid
|
|
97
|
+
</div>
|
|
98
|
+
{/if}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
<Dialog.Footer>
|
|
102
|
+
<Button type="submit">Add</Button>
|
|
103
|
+
</Dialog.Footer>
|
|
104
|
+
</form>
|
|
105
|
+
</Dialog.Content>
|
|
106
|
+
</Dialog.Root>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { flip } from 'svelte/animate';
|
|
3
|
+
import { dndzone } from 'svelte-dnd-action';
|
|
4
|
+
import {
|
|
5
|
+
LayerButton,
|
|
6
|
+
LayerThumbWrapper,
|
|
7
|
+
BackgroundLayerThumb,
|
|
8
|
+
HtmlLayerThumb,
|
|
9
|
+
ImageLayerThumb,
|
|
10
|
+
} from '../layers/index.js';
|
|
11
|
+
import { getPresentationEditorContext } from '../presentation-editor.svelte.js';
|
|
12
|
+
|
|
13
|
+
const editor = getPresentationEditorContext();
|
|
14
|
+
|
|
15
|
+
const flipDurationMs = 300;
|
|
16
|
+
const otherOptions = { flipDurationMs, type: 'layers', dropTargetStyle: {} };
|
|
17
|
+
|
|
18
|
+
function handleDndConsider(e) {
|
|
19
|
+
editor.activeSlide.layers = e.detail.items;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function handleDndFinalize(e) {
|
|
23
|
+
console.log('handleDndFinalize', e);
|
|
24
|
+
|
|
25
|
+
editor.activeSlide.layers = e.detail.items;
|
|
26
|
+
|
|
27
|
+
const index = e.detail.items.findIndex((item) => item.id === e.detail.info.id);
|
|
28
|
+
const item = e.detail.items[index];
|
|
29
|
+
|
|
30
|
+
let redo;
|
|
31
|
+
const prev = e.detail.items[index - 1];
|
|
32
|
+
const next = e.detail.items[index + 1];
|
|
33
|
+
if (prev && next) {
|
|
34
|
+
if (!(prev.sortOrder < item.sortOrder && next.sortOrder > item.sortOrder)) {
|
|
35
|
+
redo = { sortOrder: (prev.sortOrder + next.sortOrder) / 2 };
|
|
36
|
+
}
|
|
37
|
+
} else if (next) {
|
|
38
|
+
if (next && next.sortOrder <= item.sortOrder) {
|
|
39
|
+
redo = { sortOrder: next.sortOrder - 1 };
|
|
40
|
+
}
|
|
41
|
+
} else if (prev) {
|
|
42
|
+
if (prev && prev.sortOrder >= item.sortOrder) {
|
|
43
|
+
redo = { sortOrder: prev.sortOrder + 1 };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (redo) {
|
|
48
|
+
editor.historyPush({
|
|
49
|
+
type: 'layer',
|
|
50
|
+
layer: { id: item.id, type: item.type },
|
|
51
|
+
undo: { sortOrder: item.sortOrder },
|
|
52
|
+
redo,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div class="flex flex-col gap-2">
|
|
59
|
+
<div class="text-xl font-medium text-gray-500">Layers</div>
|
|
60
|
+
<div class="flex-1 resize-none overflow-y-auto">
|
|
61
|
+
<div class="flex flex-col gap-2">
|
|
62
|
+
<section
|
|
63
|
+
class="flex flex-col-reverse gap-2"
|
|
64
|
+
aria-label="Layers"
|
|
65
|
+
use:dndzone={{ items: editor.activeSlide.layers, ...otherOptions }}
|
|
66
|
+
onconsider={handleDndConsider}
|
|
67
|
+
onfinalize={handleDndFinalize}
|
|
68
|
+
>
|
|
69
|
+
{#each editor.activeSlide.layers as layer (layer.id)}
|
|
70
|
+
<div aria-label={layer.type} animate:flip={{ duration: flipDurationMs }}>
|
|
71
|
+
<LayerButton {layer}>
|
|
72
|
+
<LayerThumbWrapper {layer} thumb={{ width: 192, height: 32 }}>
|
|
73
|
+
{#snippet children({ thumbScale })}
|
|
74
|
+
{#if layer.type === 'html'}
|
|
75
|
+
<HtmlLayerThumb {layer} {thumbScale} />
|
|
76
|
+
{:else if layer.type === 'image'}
|
|
77
|
+
<ImageLayerThumb {layer} {thumbScale} />
|
|
78
|
+
{/if}
|
|
79
|
+
{/snippet}
|
|
80
|
+
</LayerThumbWrapper>
|
|
81
|
+
</LayerButton>
|
|
82
|
+
</div>
|
|
83
|
+
{/each}
|
|
84
|
+
</section>
|
|
85
|
+
<LayerButton>
|
|
86
|
+
<div class="absolute top-1/2 h-28 w-48 -translate-y-1/2">
|
|
87
|
+
<div class="h-full w-full">
|
|
88
|
+
<BackgroundLayerThumb slide={editor.activeSlide} />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</LayerButton>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const Layers: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type Layers = InstanceType<typeof Layers>;
|
|
18
|
+
export default Layers;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ActiveSidebar } from '../types.js';
|
|
3
|
+
import ImagesLibrary from './images-library.svelte';
|
|
4
|
+
import Layers from './layers.svelte';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
activeSidebarTab: ActiveSidebar;
|
|
8
|
+
}
|
|
9
|
+
let { activeSidebarTab }: Props = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if activeSidebarTab}
|
|
13
|
+
<div class="w-80 shrink-0 border-r border-gray-200 bg-background p-2">
|
|
14
|
+
{#if activeSidebarTab === 'layers'}
|
|
15
|
+
<Layers />
|
|
16
|
+
{:else if activeSidebarTab === 'images'}
|
|
17
|
+
<ImagesLibrary />
|
|
18
|
+
{/if}
|
|
19
|
+
</div>
|
|
20
|
+
{/if}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getPresentationEditorContext } from '../presentation-editor.svelte.js';
|
|
3
|
+
import { generateId } from '../../../utils.js';
|
|
4
|
+
|
|
5
|
+
let { image } = $props();
|
|
6
|
+
|
|
7
|
+
const editor = getPresentationEditorContext();
|
|
8
|
+
|
|
9
|
+
const id = generateId();
|
|
10
|
+
|
|
11
|
+
const onDocumentDragEnter = (e: DragEvent) => {
|
|
12
|
+
console.log('document dragenter', e);
|
|
13
|
+
if (editor.dragged) {
|
|
14
|
+
editor.dragged = { ...editor.dragged, hidden: false, scale: null, sticky: true };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const onDragStart = (e: DragEvent) => {
|
|
19
|
+
if (!e.target || !e.dataTransfer) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log('dragstart', e, $state.snapshot(image));
|
|
24
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
25
|
+
editor.dragged = {
|
|
26
|
+
id,
|
|
27
|
+
hidden: false,
|
|
28
|
+
sticky: true,
|
|
29
|
+
image,
|
|
30
|
+
x: e.clientX,
|
|
31
|
+
y: e.clientY,
|
|
32
|
+
offsetX: e.offsetX,
|
|
33
|
+
offsetY: e.offsetY,
|
|
34
|
+
initialScale: (e.target as HTMLElement).clientHeight / image.height,
|
|
35
|
+
};
|
|
36
|
+
addEventListener('dragenter', onDocumentDragEnter);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const onDragEnd = (e: DragEvent) => {
|
|
40
|
+
console.log('dragend', e);
|
|
41
|
+
removeEventListener('dragend', onDocumentDragEnter);
|
|
42
|
+
editor.dragged = null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const onDrag = (e: DragEvent) => {
|
|
46
|
+
// console.log('drag', e);
|
|
47
|
+
const { dragged } = editor;
|
|
48
|
+
if (dragged && dragged.sticky && (e.clientX || e.clientY)) {
|
|
49
|
+
editor.dragged = { ...dragged, x: e.clientX, y: e.clientY };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
55
|
+
<div
|
|
56
|
+
class="m-1 inline-block h-20"
|
|
57
|
+
draggable={true}
|
|
58
|
+
ondragstart={onDragStart}
|
|
59
|
+
ondragend={onDragEnd}
|
|
60
|
+
ondrag={onDrag}
|
|
61
|
+
style:opacity={editor.dragged?.id === id ? 0 : null}
|
|
62
|
+
>
|
|
63
|
+
<img src={image.src} alt="" crossorigin="anonymous" class="h-full" draggable={false} />
|
|
64
|
+
</div>
|