@peteai/presentation-editor 0.0.5 → 0.0.7
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 +38 -38
- package/dist/components/editor/active-layers-buttons.svelte +56 -0
- package/dist/components/{presentation-editor → editor}/active-layers.svelte +89 -48
- package/dist/components/{presentation-editor/cognition-slides.d.ts → editor/cognition-pages.d.ts} +1 -1
- package/dist/components/{presentation-editor/cognition-slides.js → editor/cognition-pages.js} +1 -1
- package/dist/components/{presentation-editor → editor}/cursor-tooltip.svelte +6 -2
- package/dist/components/editor/cursor-tooltip.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/dragged.svelte +7 -3
- package/dist/components/editor/dragged.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor/presentation-editor.svelte → editor/editor.svelte} +53 -48
- package/dist/components/editor/editor.svelte.d.ts +4 -0
- package/dist/components/editor/editor.svelte.js +1167 -0
- package/dist/components/{presentation-editor → editor}/header.svelte +11 -7
- package/dist/components/editor/header.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/hotkeys.svelte +41 -16
- package/dist/components/editor/index.d.ts +3 -0
- package/dist/components/editor/index.js +3 -0
- package/dist/components/{presentation-editor → editor}/layers/active-background-border.svelte +2 -2
- package/dist/components/{presentation-editor → editor}/layers/active-layer-border.svelte +5 -8
- package/dist/components/editor/layers/buttons/border-button/border-button-colors.svelte +59 -0
- package/dist/components/editor/layers/buttons/border-button/border-button-colors.svelte.d.ts +9 -0
- package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/border-button.svelte +47 -65
- package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/corner-radius-button.svelte +24 -28
- package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/flip-button.svelte +11 -12
- package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/opacity-button.svelte +32 -38
- package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/corner-scale-control.svelte +27 -32
- package/dist/components/editor/layers/controls/group-resize-control/group-resize-control.svelte +418 -0
- package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/rotate-control.svelte +27 -34
- package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/side-resize-control.svelte +9 -13
- package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/side-scale-control.svelte +13 -15
- package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/side-scale-control.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor → editor}/layers/index.d.ts +3 -2
- package/dist/components/{presentation-editor → editor}/layers/index.js +6 -3
- package/dist/components/{presentation-editor → editor}/layers/layer-button.svelte +14 -8
- package/dist/components/{presentation-editor → editor}/layers/layer-thumb-wrapper.svelte +5 -6
- package/dist/components/{presentation-editor → editor}/layers/layer-wrapper.svelte +46 -57
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-content-image.svelte +2 -2
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer-buttons.svelte +6 -6
- package/dist/components/editor/layers/types/background/background-layer-content.svelte +21 -0
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer-content.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer.svelte +5 -7
- package/dist/components/editor/layers/types/group/group-child-wrapper.svelte +44 -0
- package/dist/components/editor/layers/types/group/group-child-wrapper.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/group/group-layer-content.svelte +45 -0
- package/dist/components/editor/layers/types/group/group-layer-content.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/group/group-layer.svelte +33 -0
- package/dist/components/editor/layers/types/group/group-layer.svelte.d.ts +8 -0
- package/dist/components/editor/layers/types/group/index.d.ts +3 -0
- package/dist/components/editor/layers/types/group/index.js +3 -0
- package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-active.svelte +10 -13
- package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-content.svelte +14 -11
- package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer.svelte +8 -14
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/alignment-button.svelte +13 -14
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/alignment-button.svelte.d.ts +2 -2
- package/dist/components/editor/layers/types/text/buttons/bold-button/bold-button.svelte +65 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/bold-button/bold-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/case-button.svelte +24 -30
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/case-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/color-button.svelte +4 -4
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/color-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/font-family-button.svelte +4 -4
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/font-family-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/font-size-button.svelte +33 -40
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/font-size-button.svelte.d.ts +2 -2
- package/dist/components/editor/layers/types/text/buttons/italic-button/italic-button.svelte +65 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/italic-button/italic-button.svelte.d.ts +2 -2
- package/dist/components/editor/layers/types/text/buttons/list-button/list-button.svelte +113 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/list-button/list-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/strikethrough-button.svelte +10 -11
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/strikethrough-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/underline-button.svelte +10 -11
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/underline-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/utils.d.ts +2 -0
- package/dist/components/editor/layers/types/text/editor/utils.js +166 -0
- package/dist/components/editor/layers/types/text/extensions/list/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/list/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/list/list.d.ts +67 -0
- package/dist/components/editor/layers/types/text/extensions/list/list.js +237 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/list-item.d.ts +13 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/list-item.js +264 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/list-item-paragraph.d.ts +14 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/list-item-paragraph.js +27 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/paragraph.d.ts +6 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/paragraph.js +28 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/preserve-formatting-on-clear.d.ts +2 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/preserve-formatting-on-clear.js +74 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/text-transform.js +1 -4
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions.js +13 -23
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/html-content.svelte +0 -9
- package/dist/components/editor/layers/types/text/index.d.ts +5 -0
- package/dist/components/editor/layers/types/text/index.js +5 -0
- package/dist/components/{presentation-editor/layers/types/html/html-layer-content.svelte → editor/layers/types/text/text-layer-content.svelte} +2 -2
- package/dist/components/editor/layers/types/text/text-layer-content.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/text/text-layer-edit.svelte +114 -0
- package/dist/components/editor/layers/types/text/text-layer-edit.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/text/text-layer.svelte +125 -0
- package/dist/components/editor/layers/types/text/text-layer.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/layers/utils.d.ts +9 -16
- package/dist/components/{presentation-editor → editor}/layers/utils.js +65 -68
- package/dist/components/{presentation-editor → editor}/menu/background-menu-content.svelte +24 -24
- package/dist/components/{presentation-editor → editor}/menu/background-menu-content.svelte.d.ts +4 -4
- package/dist/components/{presentation-editor → editor}/menu/layer-menu-content.svelte +62 -38
- package/dist/components/{presentation-editor/menu/slide-menu-content.svelte → editor/menu/page-menu-content.svelte} +19 -19
- package/dist/components/editor/menu/page-menu-content.svelte.d.ts +9 -0
- package/dist/components/{presentation-editor/slide-editor.svelte → editor/page-editor.svelte} +25 -24
- package/dist/components/editor/page-editor.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor/slide-inner.svelte → editor/page-inner.svelte} +5 -5
- package/dist/components/{presentation-editor/sidebar/sidebar.svelte.d.ts → editor/page-inner.svelte.d.ts} +3 -3
- package/dist/components/editor/page.svelte +69 -0
- package/dist/components/editor/page.svelte.d.ts +4 -0
- package/dist/components/editor/pages-navigation/page-preview.svelte +36 -0
- package/dist/components/editor/pages-navigation/page-preview.svelte.d.ts +8 -0
- package/dist/components/{presentation-editor/slides-navigation/slide-preview.svelte → editor/pages-navigation/pages-navigation-item.svelte} +21 -41
- package/dist/components/editor/pages-navigation/pages-navigation-item.svelte.d.ts +11 -0
- package/dist/components/{presentation-editor/slides-navigation/slides-navigation.svelte → editor/pages-navigation/pages-navigation.svelte} +26 -21
- package/dist/components/editor/pages-navigation/pages-navigation.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-color.svelte +1 -1
- package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte +2 -2
- package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar.svelte +92 -89
- package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar-button.svelte +3 -3
- package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar.svelte +34 -39
- package/dist/components/{presentation-editor/sidebar/position-slidebar.svelte → editor/sidebar/position-sidebar.svelte} +28 -20
- package/dist/components/editor/sidebar/position-sidebar.svelte.d.ts +3 -0
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab-button.svelte +5 -5
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab.svelte +5 -5
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-uploads-tab.svelte +4 -4
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-wrapper.svelte +6 -4
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar.svelte +11 -7
- package/dist/components/editor/sidebar/sidebar.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/sidebar/uploads-image.svelte +3 -3
- package/dist/components/editor/types.d.ts +282 -0
- package/dist/components/{presentation-editor → editor}/utils.d.ts +14 -6
- package/dist/components/{presentation-editor → editor}/utils.js +97 -63
- package/dist/components/ui/color-picker/color-picker.svelte +2 -2
- package/dist/components/ui/context-menu/context-menu-checkbox-item.svelte +2 -2
- package/dist/components/ui/context-menu/context-menu-radio-item.svelte +1 -1
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dialog/dialog-content.svelte +3 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +3 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +2 -2
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dropdown-menu/index.d.ts +1 -0
- package/dist/components/ui/slider/slider.svelte +28 -20
- package/dist/index.d.ts +12 -6
- package/dist/index.js +5 -3
- package/package.json +43 -39
- package/dist/components/presentation-editor/active-layers-buttons.svelte +0 -53
- package/dist/components/presentation-editor/cursor-tooltip.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/dragged.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/header.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/index.d.ts +0 -2
- package/dist/components/presentation-editor/index.js +0 -2
- package/dist/components/presentation-editor/layers/controls/group-resize-control/group-resize-control.svelte +0 -337
- package/dist/components/presentation-editor/layers/types/background/background-layer-content.svelte +0 -19
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte +0 -71
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte +0 -71
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte +0 -90
- package/dist/components/presentation-editor/layers/types/html/editor/utils.js +0 -88
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/index.d.ts +0 -3
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/index.js +0 -3
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/unstyled-list.d.ts +0 -47
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/unstyled-list.js +0 -74
- package/dist/components/presentation-editor/layers/types/html/html-layer-content.svelte.d.ts +0 -9
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte +0 -103
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte +0 -105
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/html/index.d.ts +0 -5
- package/dist/components/presentation-editor/layers/types/html/index.js +0 -5
- package/dist/components/presentation-editor/menu/slide-menu-content.svelte.d.ts +0 -9
- package/dist/components/presentation-editor/presentation-editor.svelte.d.ts +0 -4
- package/dist/components/presentation-editor/presentation-editor.svelte.js +0 -813
- package/dist/components/presentation-editor/sidebar/position-slidebar.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/slide-editor.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/slide-inner.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/slides-navigation/slide-preview.svelte.d.ts +0 -11
- package/dist/components/presentation-editor/slides-navigation/slides-navigation.svelte.d.ts +0 -3
- package/dist/components/presentation-editor/types.d.ts +0 -158
- /package/dist/components/{presentation-editor → editor}/active-layers-buttons.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/active-layers.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient-def.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient-def.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/fonts.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/fonts.js +0 -0
- /package/dist/components/{presentation-editor → editor}/hotkeys.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/active-background-border.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/active-layer-border.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/border-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/corner-radius-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/flip-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/opacity-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/corner-scale-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/group-resize-control/group-resize-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/group-resize-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/group-resize-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/rotate-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/side-resize-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/layer-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/layer-thumb-wrapper.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/layer-wrapper.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/background-content-image.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer-buttons.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-active.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/bold-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/bold-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/italic-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/italic-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/list-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/list-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/Editor.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/Editor.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/createEditor.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/createEditor.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/editor-content.svelte +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/editor-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/types.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/types.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor.css +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/font-family.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/font-family.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/font-size.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/font-size.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/line-height.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/line-height.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/selection.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/selection.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/text-transform.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/html-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/menu/layer-menu-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-color.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-uploads-tab.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-wrapper.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/uploads-image.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/snapping-guides.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/snapping-guides.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/types.js +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, untrack } from 'svelte';
|
|
3
|
+
import type { EditorEvents } from '@tiptap/core';
|
|
4
|
+
import type {
|
|
5
|
+
TextLayer,
|
|
6
|
+
GroupLayer,
|
|
7
|
+
TextLayerInitial,
|
|
8
|
+
HistoryAction,
|
|
9
|
+
} from '../../../types.js';
|
|
10
|
+
import { getEditorContext } from '../../../editor.svelte.js';
|
|
11
|
+
import { EditorContent } from './editor/index.js';
|
|
12
|
+
import { createDebouncedCallback } from '../../../../../utils.js';
|
|
13
|
+
|
|
14
|
+
import './editor.css';
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
layer: TextLayer;
|
|
18
|
+
groupLayer?: GroupLayer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let { layer = $bindable(), groupLayer = $bindable() }: Props = $props();
|
|
22
|
+
|
|
23
|
+
const editor = getEditorContext();
|
|
24
|
+
|
|
25
|
+
const pageId = editor.activePage.id;
|
|
26
|
+
const layerId = layer.id;
|
|
27
|
+
const layerState = layer;
|
|
28
|
+
const groupLayerState = groupLayer;
|
|
29
|
+
|
|
30
|
+
let bbox = $derived(
|
|
31
|
+
groupLayerState
|
|
32
|
+
? editor.getAbsoluteGroupLayers(groupLayerState, [layerState]).find((l) => l.id === layerId)!
|
|
33
|
+
: layerState,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const { htmlEditor } = editor;
|
|
37
|
+
|
|
38
|
+
let initial: TextLayerInitial | null = null;
|
|
39
|
+
|
|
40
|
+
const debouncedUpdates = createDebouncedCallback((actions: HistoryAction[]) => {
|
|
41
|
+
console.log('debouncedUpdates', actions);
|
|
42
|
+
editor.historyPush(actions);
|
|
43
|
+
initial = null;
|
|
44
|
+
}, 750);
|
|
45
|
+
|
|
46
|
+
const onUpdate = async (e: EditorEvents['update']) => {
|
|
47
|
+
console.log('editor update', e.editor.getJSON());
|
|
48
|
+
if (!initial) {
|
|
49
|
+
initial = editor.createTextLayerInitial(editor.activePage, layerState);
|
|
50
|
+
}
|
|
51
|
+
const html = e.editor.getJSON();
|
|
52
|
+
const actions = await editor.applyHtmlToLayer(initial, html);
|
|
53
|
+
// save update only when there is a content
|
|
54
|
+
if (e.editor.state.doc.textContent.trim().length) {
|
|
55
|
+
debouncedUpdates(actions);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const checkIfEmpty = () => {
|
|
60
|
+
if (initial && !$htmlEditor.isFocused && !$htmlEditor.state.doc.textContent.trim().length) {
|
|
61
|
+
Object.assign(layerState, {
|
|
62
|
+
html: initial.layer.initial.html,
|
|
63
|
+
x: initial.layer.initial.x,
|
|
64
|
+
y: initial.layer.initial.y,
|
|
65
|
+
height: initial.layer.initial.height,
|
|
66
|
+
});
|
|
67
|
+
editor.removeLayers(pageId, layerId);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
$htmlEditor.on('update', onUpdate);
|
|
72
|
+
|
|
73
|
+
onDestroy(() => {
|
|
74
|
+
$htmlEditor.off('update', onUpdate);
|
|
75
|
+
checkIfEmpty();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
$effect(() => {
|
|
79
|
+
if (editor.activeAction?.type !== 'edit') {
|
|
80
|
+
checkIfEmpty();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
$htmlEditor.chain().setContent(layer.html).selectAll().run();
|
|
85
|
+
|
|
86
|
+
// update html when it changes by history undo/redo
|
|
87
|
+
$effect(() => {
|
|
88
|
+
if (editor.activeAction?.type !== 'edit') {
|
|
89
|
+
untrack(() => $htmlEditor)
|
|
90
|
+
.chain()
|
|
91
|
+
.setContent(layer.html)
|
|
92
|
+
.selectAll()
|
|
93
|
+
.run();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<div class="absolute origin-top-left select-none">
|
|
99
|
+
<div
|
|
100
|
+
class="pointer-events-auto select-text"
|
|
101
|
+
style:width={`${bbox.width * bbox.scale * editor.zoom}px`}
|
|
102
|
+
style:height={`${bbox.height * bbox.scale * editor.zoom}px`}
|
|
103
|
+
style:transform={`translate(${bbox.x * editor.zoom}px, ${bbox.y * editor.zoom}px) rotate(${bbox.rotate}deg)`}
|
|
104
|
+
>
|
|
105
|
+
<div
|
|
106
|
+
class="origin-top-left"
|
|
107
|
+
style:width="{bbox.width}px"
|
|
108
|
+
style:height="{bbox.height}px"
|
|
109
|
+
style:transform={`scale(${bbox.scale * editor.zoom})`}
|
|
110
|
+
>
|
|
111
|
+
<EditorContent editor={$htmlEditor} />
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TextLayer, GroupLayer } from '../../../types.js';
|
|
2
|
+
import './editor.css';
|
|
3
|
+
interface Props {
|
|
4
|
+
layer: TextLayer;
|
|
5
|
+
groupLayer?: GroupLayer;
|
|
6
|
+
}
|
|
7
|
+
declare const TextLayerEdit: import("svelte").Component<Props, {}, "layer" | "groupLayer">;
|
|
8
|
+
type TextLayerEdit = ReturnType<typeof TextLayerEdit>;
|
|
9
|
+
export default TextLayerEdit;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { BROWSER } from 'esm-env';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
import type { TextLayer } from '../../../types.js';
|
|
5
|
+
import { getEditorContext } from '../../../editor.svelte.js';
|
|
6
|
+
import { TextLayerContent } from './index.js';
|
|
7
|
+
import { calculateBoundingBox } from '../../utils.js';
|
|
8
|
+
import { extractNodeFonts } from './editor/utils.js';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
layer: TextLayer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { layer }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const editor = getEditorContext();
|
|
17
|
+
|
|
18
|
+
let ref: HTMLElement | null = $state(null);
|
|
19
|
+
|
|
20
|
+
if (BROWSER) {
|
|
21
|
+
Promise.all(extractNodeFonts(layer.html).map(editor.loadFont)).finally(() => {
|
|
22
|
+
if (ref) {
|
|
23
|
+
Object.assign(layer, { height: ref.offsetHeight });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onMount(() => {
|
|
29
|
+
if (ref) {
|
|
30
|
+
Object.assign(layer, { height: ref.offsetHeight });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const canEdit = () => {
|
|
35
|
+
if (editor.activeAction) return false;
|
|
36
|
+
if (editor.activePage.locked) return false;
|
|
37
|
+
if (editor.activeSelection.type === 'root-layers') {
|
|
38
|
+
if (!editor.activeLayers.find((l) => l.id === layer.id)) return false;
|
|
39
|
+
if (layer.locked) return false;
|
|
40
|
+
} else if (editor.activeSelection.type === 'child-layer') {
|
|
41
|
+
if (!editor.activeGroupAndChild) return false;
|
|
42
|
+
const { groupLayer, childLayer } = editor.activeGroupAndChild;
|
|
43
|
+
if (childLayer.id !== layer.id) return false;
|
|
44
|
+
if (groupLayer.locked) return false;
|
|
45
|
+
} else {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
let tryToEdit = false;
|
|
52
|
+
|
|
53
|
+
const onMouseDown = (e: MouseEvent) => {
|
|
54
|
+
if (e.button !== 0) return;
|
|
55
|
+
console.log('mousedown', layer.id, e);
|
|
56
|
+
if (!canEdit()) return;
|
|
57
|
+
tryToEdit = true;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const onClick = (e: MouseEvent) => {
|
|
61
|
+
console.log('click', layer.id, e);
|
|
62
|
+
if (!tryToEdit) return;
|
|
63
|
+
tryToEdit = false;
|
|
64
|
+
if (!canEdit()) return;
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
console.log('edit layer', layer.id);
|
|
67
|
+
editor.activeAction = { id: layer.id, type: 'edit' };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onDragEnter = (e: DragEvent) => {
|
|
71
|
+
console.log('dragenter text layer', e);
|
|
72
|
+
|
|
73
|
+
if (editor.dragged) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
editor.dragged = {
|
|
77
|
+
...editor.dragged,
|
|
78
|
+
hidden: false,
|
|
79
|
+
inside: true,
|
|
80
|
+
sticky: true,
|
|
81
|
+
customScale: null,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const onDragOver = (e: DragEvent) => {
|
|
87
|
+
// console.log('dragover text layer', e);
|
|
88
|
+
if (editor.dragged) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const onDrop = (e: DragEvent) => {
|
|
95
|
+
if (!ref) return;
|
|
96
|
+
console.log('drop text layer', e);
|
|
97
|
+
|
|
98
|
+
const { dragged } = editor;
|
|
99
|
+
if (dragged) {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
e.stopPropagation();
|
|
102
|
+
const bbox = calculateBoundingBox(layer);
|
|
103
|
+
const rect = ref.getBoundingClientRect();
|
|
104
|
+
const x = (e.clientX - rect.left - dragged.offsetX) / editor.zoom + bbox.x;
|
|
105
|
+
const y = (e.clientY - rect.top - dragged.offsetY) / editor.zoom + bbox.y;
|
|
106
|
+
editor.dropDragged(x, y);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
112
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
113
|
+
<div
|
|
114
|
+
class="h-full w-full"
|
|
115
|
+
style:opacity={editor.activeAction?.id === layer.id && editor.activeAction?.type === 'edit'
|
|
116
|
+
? 0
|
|
117
|
+
: null}
|
|
118
|
+
onclick={onClick}
|
|
119
|
+
onmousedown={onMouseDown}
|
|
120
|
+
ondragenter={onDragEnter}
|
|
121
|
+
ondragover={onDragOver}
|
|
122
|
+
ondrop={onDrop}
|
|
123
|
+
>
|
|
124
|
+
<TextLayerContent {layer} bind:ref />
|
|
125
|
+
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImageLayer, Layer } from '../types.js';
|
|
2
2
|
type Origin = 'top-left' | 'top-right' | 'center-left' | 'center-right' | 'bottom-left' | 'bottom-right' | 'left' | 'right' | 'top' | 'bottom';
|
|
3
3
|
export type Point = {
|
|
4
4
|
x: number;
|
|
@@ -10,6 +10,7 @@ export type Transform = {
|
|
|
10
10
|
width: number;
|
|
11
11
|
height: number;
|
|
12
12
|
rotate: number;
|
|
13
|
+
scale: number;
|
|
13
14
|
};
|
|
14
15
|
export declare const rotatePointOld: (point: {
|
|
15
16
|
x: number;
|
|
@@ -18,7 +19,7 @@ export declare const rotatePointOld: (point: {
|
|
|
18
19
|
x: number;
|
|
19
20
|
y: number;
|
|
20
21
|
};
|
|
21
|
-
export declare const calculateLayerTransform: (layer: Layer) => Transform;
|
|
22
|
+
export declare const calculateLayerTransform: (layer: Layer, groupScale?: number) => Transform;
|
|
22
23
|
export declare const calculateNewPosition: (origin: Origin, transform: Transform, newWidth: number, newHeight: number) => {
|
|
23
24
|
newX: number;
|
|
24
25
|
newY: number;
|
|
@@ -32,10 +33,6 @@ export declare function calculateBoundingBox(transform: Transform): {
|
|
|
32
33
|
export declare function degToRad(deg: number): number;
|
|
33
34
|
export declare function rotatePoint(p: Point, origin: Point, angleRad: number): Point;
|
|
34
35
|
export declare function getRotatedCorners(rect: Transform): Point[];
|
|
35
|
-
export declare function calculateBoundingBoxSize(width: number, height: number, rotate: number): {
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
};
|
|
39
36
|
export declare function isRotatedVertically(rotate: number): boolean;
|
|
40
37
|
interface ScaleResult {
|
|
41
38
|
width: number;
|
|
@@ -49,14 +46,16 @@ export declare function getRotatedBoundingBox(center: Point, width: number, heig
|
|
|
49
46
|
width: number;
|
|
50
47
|
height: number;
|
|
51
48
|
};
|
|
52
|
-
export declare function calculateGroupRotatedBoundingBox(
|
|
53
|
-
export declare function calculateRelativeRects(bbox: Transform,
|
|
49
|
+
export declare function calculateGroupRotatedBoundingBox(transforms: Transform[], rotate?: number): Transform;
|
|
50
|
+
export declare function calculateRelativeRects(bbox: Transform, absoluteRects: Transform[]): {
|
|
54
51
|
x: number;
|
|
55
52
|
y: number;
|
|
53
|
+
rotate: number;
|
|
56
54
|
width: number;
|
|
57
55
|
height: number;
|
|
58
|
-
|
|
56
|
+
scale: number;
|
|
59
57
|
}[];
|
|
58
|
+
export declare function calculateAbsoluteRects(bbox: Transform, rects: Transform[]): Transform[];
|
|
60
59
|
export declare const checkPolygonsIntersect: (a: {
|
|
61
60
|
x: number;
|
|
62
61
|
y: number;
|
|
@@ -64,12 +63,7 @@ export declare const checkPolygonsIntersect: (a: {
|
|
|
64
63
|
x: number;
|
|
65
64
|
y: number;
|
|
66
65
|
}[]) => boolean;
|
|
67
|
-
export declare function calculateGroupBoundingBox(transforms: Transform[]):
|
|
68
|
-
x: number;
|
|
69
|
-
y: number;
|
|
70
|
-
width: number;
|
|
71
|
-
height: number;
|
|
72
|
-
};
|
|
66
|
+
export declare function calculateGroupBoundingBox(transforms: Transform[]): Transform;
|
|
73
67
|
export declare function calculateImageCover(image: {
|
|
74
68
|
width: number;
|
|
75
69
|
height: number;
|
|
@@ -87,5 +81,4 @@ export declare function calculateImageCover(image: {
|
|
|
87
81
|
export declare const defaultColor = "#000000";
|
|
88
82
|
export declare function extractBorderColors(layers: ImageLayer[]): string[] | undefined;
|
|
89
83
|
export declare function buildBackgroundCircleStyle(colors: string[]): string;
|
|
90
|
-
export declare function applyHtmlToLayer(layer: HtmlLayer, html: HtmlLayer['html']): Promise<Pick<HtmlLayer, 'html' | 'x' | 'y' | 'height'>>;
|
|
91
84
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { tick } from 'svelte';
|
|
2
1
|
export const rotatePointOld = (point, angleRad) => {
|
|
3
2
|
const cos = Math.cos(angleRad);
|
|
4
3
|
const sin = Math.sin(angleRad);
|
|
@@ -33,15 +32,17 @@ const getPoints = (origin, width, height) => {
|
|
|
33
32
|
throw new Error(`Unknown origin: ${origin}`);
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
|
-
export const calculateLayerTransform = (layer) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
export const calculateLayerTransform = (layer, groupScale = 1) => ({
|
|
36
|
+
x: layer.x * groupScale,
|
|
37
|
+
y: layer.y * groupScale,
|
|
38
|
+
width: layer.width * groupScale,
|
|
39
|
+
height: layer.height * groupScale,
|
|
40
|
+
rotate: layer.rotate,
|
|
41
|
+
scale: layer.scale,
|
|
42
|
+
});
|
|
42
43
|
export const calculateNewPosition = (origin, transform, newWidth, newHeight) => {
|
|
43
|
-
const { x, y, width, height, rotate } = transform;
|
|
44
|
-
const oldPoint = getPoints(origin, width, height);
|
|
44
|
+
const { x, y, width, height, rotate, scale } = transform;
|
|
45
|
+
const oldPoint = getPoints(origin, width * scale, height * scale);
|
|
45
46
|
const newPoint = getPoints(origin, newWidth, newHeight);
|
|
46
47
|
let deltaX = newPoint.x - oldPoint.x;
|
|
47
48
|
let deltaY = newPoint.y - oldPoint.y;
|
|
@@ -53,23 +54,23 @@ export const calculateNewPosition = (origin, transform, newWidth, newHeight) =>
|
|
|
53
54
|
deltaY = rotatedNewCenter.y - rotatedOldCenter.y;
|
|
54
55
|
}
|
|
55
56
|
return {
|
|
56
|
-
newX: x - deltaX - (newWidth - width) / 2,
|
|
57
|
-
newY: y - deltaY - (newHeight - height) / 2,
|
|
57
|
+
newX: x - deltaX - (newWidth - width * scale) / 2,
|
|
58
|
+
newY: y - deltaY - (newHeight - height * scale) / 2,
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
61
|
export function calculateBoundingBox(transform) {
|
|
61
|
-
const { x, y, width, height, rotate } = transform;
|
|
62
|
+
const { x, y, width, height, rotate, scale } = transform;
|
|
62
63
|
if (rotate === 0) {
|
|
63
|
-
return { x, y, width, height };
|
|
64
|
+
return { x, y, width: width * scale, height: height * scale };
|
|
64
65
|
}
|
|
65
66
|
const radians = (rotate * Math.PI) / 180;
|
|
66
67
|
const origins = ['top-left', 'top-right'];
|
|
67
|
-
const corners = origins.map((position) => rotatePointOld(getPoints(position, width, height), radians));
|
|
68
|
+
const corners = origins.map((position) => rotatePointOld(getPoints(position, width * scale, height * scale), radians));
|
|
68
69
|
const maxX = Math.max(...corners.map((corner) => Math.abs(corner.x)));
|
|
69
70
|
const maxY = Math.max(...corners.map((corner) => Math.abs(corner.y)));
|
|
70
71
|
return {
|
|
71
|
-
x: x + width / 2 - maxX,
|
|
72
|
-
y: y + height / 2 - maxY,
|
|
72
|
+
x: x + (width * scale) / 2 - maxX,
|
|
73
|
+
y: y + (height * scale) / 2 - maxY,
|
|
73
74
|
width: maxX * 2,
|
|
74
75
|
height: maxY * 2,
|
|
75
76
|
};
|
|
@@ -88,11 +89,11 @@ export function rotatePoint(p, origin, angleRad) {
|
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
export function getRotatedCorners(rect) {
|
|
91
|
-
const cx = rect.x + rect.width / 2;
|
|
92
|
-
const cy = rect.y + rect.height / 2;
|
|
92
|
+
const cx = rect.x + (rect.width * rect.scale) / 2;
|
|
93
|
+
const cy = rect.y + (rect.height * rect.scale) / 2;
|
|
93
94
|
const angle = degToRad(rect.rotate);
|
|
94
|
-
const hw = rect.width / 2;
|
|
95
|
-
const hh = rect.height / 2;
|
|
95
|
+
const hw = (rect.width * rect.scale) / 2;
|
|
96
|
+
const hh = (rect.height * rect.scale) / 2;
|
|
96
97
|
const corners = [
|
|
97
98
|
{ x: cx - hw, y: cy - hh },
|
|
98
99
|
{ x: cx + hw, y: cy - hh },
|
|
@@ -101,15 +102,6 @@ export function getRotatedCorners(rect) {
|
|
|
101
102
|
];
|
|
102
103
|
return corners.map((p) => rotatePoint(p, { x: cx, y: cy }, angle));
|
|
103
104
|
}
|
|
104
|
-
export function calculateBoundingBoxSize(width, height, rotate) {
|
|
105
|
-
const theta = degToRad(rotate);
|
|
106
|
-
const cosTheta = Math.abs(Math.cos(theta));
|
|
107
|
-
const sinTheta = Math.abs(Math.sin(theta));
|
|
108
|
-
return {
|
|
109
|
-
width: width * cosTheta + height * sinTheta,
|
|
110
|
-
height: width * sinTheta + height * cosTheta,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
105
|
export function isRotatedVertically(rotate) {
|
|
114
106
|
const rotationNormalized = ((rotate % 360) + 360) % 360;
|
|
115
107
|
const rotationShifted = (rotationNormalized + 45) % 360;
|
|
@@ -170,12 +162,12 @@ export function getRotatedBoundingBox(center, width, height, rotate) {
|
|
|
170
162
|
height: maxY - minY,
|
|
171
163
|
};
|
|
172
164
|
}
|
|
173
|
-
export function calculateGroupRotatedBoundingBox(
|
|
174
|
-
if (!
|
|
175
|
-
return
|
|
176
|
-
const allCorners =
|
|
177
|
-
const theta = degToRad(-
|
|
178
|
-
// Rotate all points to align with desired
|
|
165
|
+
export function calculateGroupRotatedBoundingBox(transforms, rotate = 0) {
|
|
166
|
+
if (!rotate)
|
|
167
|
+
return calculateGroupBoundingBox(transforms);
|
|
168
|
+
const allCorners = transforms.flatMap((t) => getRotatedCorners(t));
|
|
169
|
+
const theta = degToRad(-rotate); // inverse to align bbox with axes
|
|
170
|
+
// Rotate all points to align with desired angle
|
|
179
171
|
const rotatedPoints = allCorners.map((p) => rotatePoint(p, { x: 0, y: 0 }, theta));
|
|
180
172
|
// Compute AABB of rotated points
|
|
181
173
|
const xs = rotatedPoints.map((p) => p.x);
|
|
@@ -191,36 +183,59 @@ export function calculateGroupRotatedBoundingBox(rects, groupRotate = 0) {
|
|
|
191
183
|
y: (minY + maxY) / 2,
|
|
192
184
|
};
|
|
193
185
|
// Rotate center back to original space
|
|
194
|
-
const center = rotatePoint(centerRotated, { x: 0, y: 0 }, degToRad(
|
|
195
|
-
|
|
186
|
+
const center = rotatePoint(centerRotated, { x: 0, y: 0 }, degToRad(rotate));
|
|
187
|
+
return {
|
|
196
188
|
x: center.x - width / 2,
|
|
197
189
|
y: center.y - height / 2,
|
|
198
190
|
width,
|
|
199
191
|
height,
|
|
200
|
-
rotate
|
|
192
|
+
rotate,
|
|
193
|
+
scale: 1,
|
|
201
194
|
};
|
|
202
|
-
return bbox;
|
|
203
195
|
}
|
|
204
|
-
export function calculateRelativeRects(bbox,
|
|
196
|
+
export function calculateRelativeRects(bbox, absoluteRects) {
|
|
205
197
|
const theta = degToRad(-bbox.rotate); // inverse to align bbox with axes
|
|
206
|
-
const bboxCenter = {
|
|
207
|
-
|
|
208
|
-
|
|
198
|
+
const bboxCenter = {
|
|
199
|
+
x: bbox.x + (bbox.width * bbox.scale) / 2,
|
|
200
|
+
y: bbox.y + (bbox.height * bbox.scale) / 2,
|
|
201
|
+
};
|
|
202
|
+
return absoluteRects.map((rect) => {
|
|
203
|
+
// Get center of original absolute rect
|
|
209
204
|
const center = {
|
|
210
|
-
x: rect.x + rect.width / 2,
|
|
211
|
-
y: rect.y + rect.height / 2,
|
|
205
|
+
x: rect.x + (rect.width * rect.scale) / 2,
|
|
206
|
+
y: rect.y + (rect.height * rect.scale) / 2,
|
|
212
207
|
};
|
|
213
208
|
// Rotate center ralatively to the bbox center
|
|
214
209
|
const relativeCenter = rotatePoint(center, bboxCenter, theta);
|
|
215
210
|
return {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
height: rect.height,
|
|
211
|
+
...rect,
|
|
212
|
+
x: (relativeCenter.x - bbox.x) / bbox.scale - (rect.width * rect.scale) / 2,
|
|
213
|
+
y: (relativeCenter.y - bbox.y) / bbox.scale - (rect.height * rect.scale) / 2,
|
|
220
214
|
rotate: rect.rotate - bbox.rotate,
|
|
221
215
|
};
|
|
222
216
|
});
|
|
223
217
|
}
|
|
218
|
+
export function calculateAbsoluteRects(bbox, rects) {
|
|
219
|
+
const theta = degToRad(bbox.rotate);
|
|
220
|
+
const bboxCenter = {
|
|
221
|
+
x: bbox.x + (bbox.width * bbox.scale) / 2,
|
|
222
|
+
y: bbox.y + (bbox.height * bbox.scale) / 2,
|
|
223
|
+
};
|
|
224
|
+
return rects.map((rect) => {
|
|
225
|
+
const relativeCenter = {
|
|
226
|
+
x: bbox.x + (rect.x + (rect.width * rect.scale) / 2) * bbox.scale,
|
|
227
|
+
y: bbox.y + (rect.y + (rect.height * rect.scale) / 2) * bbox.scale,
|
|
228
|
+
};
|
|
229
|
+
const center = rotatePoint(relativeCenter, bboxCenter, theta);
|
|
230
|
+
return {
|
|
231
|
+
...rect,
|
|
232
|
+
x: center.x - (rect.width * rect.scale * bbox.scale) / 2,
|
|
233
|
+
y: center.y - (rect.height * rect.scale * bbox.scale) / 2,
|
|
234
|
+
rotate: rect.rotate + bbox.rotate,
|
|
235
|
+
scale: rect.scale * bbox.scale,
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
}
|
|
224
239
|
export const checkPolygonsIntersect = (a, b) => {
|
|
225
240
|
const polygons = [a, b];
|
|
226
241
|
for (const polygon of polygons) {
|
|
@@ -259,7 +274,7 @@ export function calculateGroupBoundingBox(transforms) {
|
|
|
259
274
|
minY = Math.min(minY, bbox.y);
|
|
260
275
|
maxY = Math.max(maxY, bbox.y + bbox.height);
|
|
261
276
|
});
|
|
262
|
-
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
277
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY, rotate: 0, scale: 1 };
|
|
263
278
|
}
|
|
264
279
|
const minScaleToContain = (rotatedRect, rect) => {
|
|
265
280
|
const { width: rw, height: rh, rotate } = rotatedRect;
|
|
@@ -307,21 +322,3 @@ export function buildBackgroundCircleStyle(colors) {
|
|
|
307
322
|
.join(', ');
|
|
308
323
|
return `background-image: conic-gradient(${gradientColors})`;
|
|
309
324
|
}
|
|
310
|
-
export async function applyHtmlToLayer(layer, html) {
|
|
311
|
-
layer.html = html;
|
|
312
|
-
await tick();
|
|
313
|
-
const { x, y, width, height } = layer;
|
|
314
|
-
const redo = { html, x, y, height };
|
|
315
|
-
const layerContent = document.getElementById(`layer-content-${layer.id}`);
|
|
316
|
-
if (layerContent && layerContent.offsetHeight !== layer.height) {
|
|
317
|
-
const scale = layer.scale || 1;
|
|
318
|
-
const rotate = layer.rotate || 0;
|
|
319
|
-
const newHeight = layerContent.offsetHeight * scale;
|
|
320
|
-
const { newX, newY } = calculateNewPosition(`top-left`, { x, y, width: width * scale, height: height * scale, rotate }, width * scale, newHeight);
|
|
321
|
-
redo.x = newX;
|
|
322
|
-
redo.y = newY;
|
|
323
|
-
redo.height = newHeight / scale;
|
|
324
|
-
}
|
|
325
|
-
Object.assign(layer, redo);
|
|
326
|
-
return redo;
|
|
327
|
-
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import CopyIcon from 'lucide
|
|
3
|
-
import PasteIcon from 'lucide
|
|
4
|
-
import DuplicateIcon from 'lucide
|
|
5
|
-
import AddIcon from 'lucide
|
|
6
|
-
import TrashIcon from 'lucide
|
|
7
|
-
import LockIcon from 'lucide
|
|
8
|
-
import UnlockIcon from 'lucide
|
|
9
|
-
import ExtractImageIcon from 'lucide
|
|
2
|
+
import CopyIcon from '@lucide/svelte/icons/copy';
|
|
3
|
+
import PasteIcon from '@lucide/svelte/icons/clipboard';
|
|
4
|
+
import DuplicateIcon from '@lucide/svelte/icons/copy-plus';
|
|
5
|
+
import AddIcon from '@lucide/svelte/icons/file-plus-2';
|
|
6
|
+
import TrashIcon from '@lucide/svelte/icons/trash-2';
|
|
7
|
+
import LockIcon from '@lucide/svelte/icons/lock-keyhole';
|
|
8
|
+
import UnlockIcon from '@lucide/svelte/icons/lock-keyhole-open';
|
|
9
|
+
import ExtractImageIcon from '@lucide/svelte/icons/square-arrow-out-up-right';
|
|
10
10
|
import * as DropdownMenu from '../../ui/dropdown-menu/index.js';
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
11
|
+
import type { Editor } from '../editor.svelte.js';
|
|
12
|
+
import type { Page } from '../types.js';
|
|
13
13
|
import { checkIfMac } from '../../../utils.js';
|
|
14
14
|
|
|
15
15
|
interface Props {
|
|
16
|
-
editor:
|
|
17
|
-
|
|
16
|
+
editor: Editor;
|
|
17
|
+
page: Page;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
let { editor,
|
|
20
|
+
let { editor, page }: Props = $props();
|
|
21
21
|
|
|
22
|
-
const locked = $derived(
|
|
22
|
+
const locked = $derived(page.locked || page.backgroundLocked);
|
|
23
23
|
|
|
24
24
|
const isMac = checkIfMac();
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
|
-
<DropdownMenu.Item onclick={() => editor.
|
|
27
|
+
<DropdownMenu.Item onclick={() => editor.copyPage(page.id)}>
|
|
28
28
|
<CopyIcon />
|
|
29
29
|
Copy
|
|
30
30
|
<DropdownMenu.Shortcut>{isMac ? '⌘C' : 'Ctrl+C'}</DropdownMenu.Shortcut>
|
|
31
31
|
</DropdownMenu.Item>
|
|
32
32
|
<DropdownMenu.Item
|
|
33
33
|
onclick={() => editor.clipboardPaste()}
|
|
34
|
-
disabled={!editor.clipboard || (
|
|
34
|
+
disabled={!editor.clipboard || (page.locked && !('layers' in editor.clipboard))}
|
|
35
35
|
>
|
|
36
36
|
<PasteIcon />
|
|
37
37
|
Paste
|
|
38
38
|
<DropdownMenu.Shortcut>{isMac ? '⌘V' : 'Ctrl+V'}</DropdownMenu.Shortcut>
|
|
39
39
|
</DropdownMenu.Item>
|
|
40
|
-
<DropdownMenu.Item onclick={() => editor.
|
|
40
|
+
<DropdownMenu.Item onclick={() => editor.addPage()}>
|
|
41
41
|
<AddIcon />
|
|
42
42
|
Add page
|
|
43
43
|
<DropdownMenu.Shortcut>{isMac ? '⌘⏎' : 'Ctrl+⏎'}</DropdownMenu.Shortcut>
|
|
44
44
|
</DropdownMenu.Item>
|
|
45
|
-
<DropdownMenu.Item onclick={() => editor.
|
|
45
|
+
<DropdownMenu.Item onclick={() => editor.duplicatePage(page)}>
|
|
46
46
|
<DuplicateIcon />
|
|
47
47
|
Duplicate page
|
|
48
48
|
<DropdownMenu.Shortcut>{isMac ? '⌘D' : 'Ctrl+D'}</DropdownMenu.Shortcut>
|
|
49
49
|
</DropdownMenu.Item>
|
|
50
|
-
<DropdownMenu.Item onclick={() => editor.removeBackground(
|
|
50
|
+
<DropdownMenu.Item onclick={() => editor.removeBackground(page.id)} disabled={locked}>
|
|
51
51
|
<TrashIcon />
|
|
52
|
-
{#if
|
|
52
|
+
{#if page.backgroundImage}
|
|
53
53
|
Delete background image
|
|
54
54
|
{:else}
|
|
55
55
|
Delete background
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
|
|
60
60
|
<DropdownMenu.Separator />
|
|
61
61
|
|
|
62
|
-
<DropdownMenu.Item onclick={() => editor.backgroundToggleLocked(
|
|
63
|
-
{#if
|
|
62
|
+
<DropdownMenu.Item onclick={() => editor.backgroundToggleLocked(page.id)} disabled={page.locked}>
|
|
63
|
+
{#if page.backgroundLocked}
|
|
64
64
|
<UnlockIcon />
|
|
65
65
|
Unlock background
|
|
66
66
|
{:else}
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
<DropdownMenu.Shortcut>{isMac ? '⌥⇧L' : 'Alt+Shift+L'}</DropdownMenu.Shortcut>
|
|
71
71
|
</DropdownMenu.Item>
|
|
72
72
|
|
|
73
|
-
{#if
|
|
73
|
+
{#if page.backgroundImage}
|
|
74
74
|
<DropdownMenu.Separator />
|
|
75
75
|
|
|
76
|
-
<DropdownMenu.Item onclick={() => editor.backgroundImageToLayer(
|
|
76
|
+
<DropdownMenu.Item onclick={() => editor.backgroundImageToLayer(page.id)} disabled={locked}>
|
|
77
77
|
<ExtractImageIcon />
|
|
78
78
|
Detach image from background
|
|
79
79
|
</DropdownMenu.Item>
|
package/dist/components/{presentation-editor → editor}/menu/background-menu-content.svelte.d.ts
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Editor } from '../editor.svelte.js';
|
|
2
|
+
import type { Page } from '../types.js';
|
|
3
3
|
interface Props {
|
|
4
|
-
editor:
|
|
5
|
-
|
|
4
|
+
editor: Editor;
|
|
5
|
+
page: Page;
|
|
6
6
|
}
|
|
7
7
|
declare const BackgroundMenuContent: import("svelte").Component<Props, {}, "">;
|
|
8
8
|
type BackgroundMenuContent = ReturnType<typeof BackgroundMenuContent>;
|