@peteai/presentation-editor 0.0.1 → 0.0.3
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 +172 -38
- package/dist/components/presentation-editor/active-layers-buttons.svelte +53 -0
- package/dist/components/presentation-editor/active-layers-buttons.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/active-layers.svelte +181 -0
- package/dist/components/presentation-editor/active-layers.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient-def.svelte +81 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient-def.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient.svelte +21 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator-gradient.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator.svelte +23 -0
- package/dist/components/presentation-editor/color-indicator/color-indicator.svelte.d.ts +6 -0
- package/dist/components/presentation-editor/color-indicator/index.d.ts +4 -0
- package/dist/components/presentation-editor/color-indicator/index.js +6 -0
- package/dist/components/presentation-editor/cursor-tooltip.svelte +1 -1
- package/dist/components/presentation-editor/dragged.svelte +21 -11
- package/dist/components/presentation-editor/fonts.d.ts +3 -0
- package/dist/components/presentation-editor/fonts.js +1278 -0
- package/dist/components/presentation-editor/header.svelte +21 -33
- package/dist/components/presentation-editor/header.svelte.d.ts +16 -6
- package/dist/components/presentation-editor/hotkeys.svelte +85 -0
- package/dist/components/presentation-editor/{sidebar/layers.svelte.d.ts → hotkeys.svelte.d.ts} +3 -3
- package/dist/components/presentation-editor/layers/active-background-border.svelte +3 -7
- package/dist/components/presentation-editor/layers/active-layer-border.svelte +2 -5
- package/dist/components/presentation-editor/layers/active-layer-border.svelte.d.ts +0 -1
- package/dist/components/presentation-editor/layers/buttons/border-button/border-button.svelte +113 -129
- package/dist/components/presentation-editor/layers/buttons/border-button/border-button.svelte.d.ts +2 -2
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/corner-radius-button.svelte +51 -32
- package/dist/components/presentation-editor/layers/buttons/corner-radius-button/corner-radius-button.svelte.d.ts +2 -2
- package/dist/components/presentation-editor/layers/buttons/flip-button/flip-button.svelte +30 -7
- package/dist/components/presentation-editor/layers/buttons/flip-button/flip-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/buttons/opacity-button/opacity-button.svelte +76 -33
- package/dist/components/presentation-editor/layers/buttons/opacity-button/opacity-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/corner-scale-control.svelte +89 -59
- package/dist/components/presentation-editor/layers/controls/corner-scale-control/corner-scale-control.svelte.d.ts +5 -100
- package/dist/components/presentation-editor/layers/controls/group-resize-control/group-resize-control.svelte +337 -0
- package/dist/components/presentation-editor/layers/controls/group-resize-control/group-resize-control.svelte.d.ts +104 -0
- package/dist/components/presentation-editor/layers/controls/group-resize-control/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/controls/group-resize-control/index.js +4 -0
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte +128 -43
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte.d.ts +1 -5
- package/dist/components/presentation-editor/layers/controls/side-resize-control/side-resize-control.svelte +68 -57
- package/dist/components/presentation-editor/layers/controls/side-resize-control/side-resize-control.svelte.d.ts +2 -110
- package/dist/components/presentation-editor/layers/controls/side-scale-control/side-scale-control.svelte +45 -32
- package/dist/components/presentation-editor/layers/controls/side-scale-control/side-scale-control.svelte.d.ts +2 -54
- package/dist/components/presentation-editor/layers/index.d.ts +4 -5
- package/dist/components/presentation-editor/layers/index.js +7 -8
- package/dist/components/presentation-editor/layers/layer-button.svelte +25 -7
- package/dist/components/presentation-editor/layers/layer-wrapper.svelte +212 -162
- package/dist/components/presentation-editor/layers/layer-wrapper.svelte.d.ts +2 -2
- package/dist/components/presentation-editor/layers/types/background/background-content-image.svelte +41 -0
- package/dist/components/presentation-editor/layers/types/background/background-content-image.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-buttons.svelte +28 -74
- package/dist/components/presentation-editor/layers/types/background/background-layer-buttons.svelte.d.ts +2 -17
- package/dist/components/presentation-editor/layers/types/background/background-layer-content.svelte +19 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer-content.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/background/background-layer.svelte +69 -61
- package/dist/components/presentation-editor/layers/types/background/background-layer.svelte.d.ts +2 -3
- package/dist/components/presentation-editor/layers/types/background/index.d.ts +2 -3
- package/dist/components/presentation-editor/layers/types/background/index.js +2 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/alignment-button.svelte +55 -12
- package/dist/components/presentation-editor/layers/types/html/buttons/alignment-button/alignment-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte +60 -8
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/case-button.svelte +59 -24
- package/dist/components/presentation-editor/layers/types/html/buttons/case-button/case-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/color-button.svelte +27 -76
- package/dist/components/presentation-editor/layers/types/html/buttons/color-button/color-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/font-family-button.svelte +36 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/font-family-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/index.d.ts +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-family-button/index.js +2 -0
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/font-size-button.svelte +72 -29
- package/dist/components/presentation-editor/layers/types/html/buttons/font-size-button/font-size-button.svelte.d.ts +3 -5
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte +60 -8
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte +71 -18
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/strikethrough-button.svelte +54 -8
- package/dist/components/presentation-editor/layers/types/html/buttons/strikethrough-button/strikethrough-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/underline-button.svelte +54 -9
- package/dist/components/presentation-editor/layers/types/html/buttons/underline-button/underline-button.svelte.d.ts +3 -3
- package/dist/components/presentation-editor/layers/types/html/editor/createEditor.js +2 -2
- package/dist/components/presentation-editor/layers/types/html/editor/utils.d.ts +11 -0
- package/dist/components/presentation-editor/layers/types/html/editor/utils.js +88 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/font-family.d.ts +27 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/font-family.js +40 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/index.d.ts +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-family/index.js +3 -0
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/font-size.d.ts +5 -1
- package/dist/components/presentation-editor/layers/types/html/extensions/font-size/font-size.js +3 -7
- package/dist/components/presentation-editor/layers/types/html/extensions.d.ts +1 -0
- package/dist/components/presentation-editor/layers/types/html/extensions.js +56 -0
- package/dist/components/presentation-editor/layers/types/html/html-content.svelte +26 -5
- package/dist/components/presentation-editor/layers/types/html/html-layer-content.svelte +26 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-content.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte +103 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte +61 -53
- package/dist/components/presentation-editor/layers/types/html/index.d.ts +3 -5
- package/dist/components/presentation-editor/layers/types/html/index.js +3 -56
- package/dist/components/presentation-editor/layers/types/image/{image-content.svelte → image-layer-content.svelte} +11 -3
- package/dist/components/presentation-editor/layers/types/image/image-layer-content.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/layers/types/image/image-layer.svelte +51 -21
- package/dist/components/presentation-editor/layers/types/image/index.d.ts +2 -4
- package/dist/components/presentation-editor/layers/types/image/index.js +2 -4
- package/dist/components/presentation-editor/layers/utils.d.ts +68 -9
- package/dist/components/presentation-editor/layers/utils.js +260 -25
- package/dist/components/presentation-editor/menu/background-menu-content.svelte +80 -0
- package/dist/components/presentation-editor/menu/background-menu-content.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/menu/layer-menu-content.svelte +183 -0
- package/dist/components/presentation-editor/menu/layer-menu-content.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/menu/slide-menu-content.svelte +67 -0
- package/dist/components/presentation-editor/menu/slide-menu-content.svelte.d.ts +9 -0
- package/dist/components/presentation-editor/presentation-editor.svelte +120 -176
- package/dist/components/presentation-editor/presentation-editor.svelte.d.ts +1 -4
- package/dist/components/presentation-editor/presentation-editor.svelte.js +597 -136
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-color.svelte +58 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-color.svelte.d.ts +10 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte +144 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar.svelte +404 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/color-sidebar.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/index.d.ts +2 -0
- package/dist/components/presentation-editor/sidebar/color-sidebar/index.js +2 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar-button.svelte +26 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar-button.svelte.d.ts +8 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar.svelte +216 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/font-sidebar.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/index.d.ts +2 -0
- package/dist/components/presentation-editor/sidebar/font-sidebar/index.js +2 -0
- package/dist/components/presentation-editor/sidebar/position-slidebar.svelte +130 -0
- package/dist/components/presentation-editor/sidebar/position-slidebar.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab-button.svelte +90 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab-button.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab.svelte +82 -0
- package/dist/components/presentation-editor/sidebar/sidebar-text-tab.svelte.d.ts +18 -0
- package/dist/components/presentation-editor/sidebar/{images-library.svelte → sidebar-uploads-tab.svelte} +0 -1
- package/dist/components/presentation-editor/sidebar/sidebar-uploads-tab.svelte.d.ts +3 -0
- package/dist/components/presentation-editor/sidebar/sidebar-wrapper.svelte +25 -0
- package/dist/components/presentation-editor/sidebar/sidebar-wrapper.svelte.d.ts +7 -0
- package/dist/components/presentation-editor/sidebar/sidebar.svelte +71 -15
- package/dist/components/presentation-editor/sidebar/sidebar.svelte.d.ts +16 -5
- package/dist/components/presentation-editor/sidebar/uploads-image.svelte +28 -11
- package/dist/components/presentation-editor/slide-editor.svelte +20 -22
- package/dist/components/presentation-editor/slide-inner.svelte +19 -18
- package/dist/components/presentation-editor/slides-navigation/slide-preview.svelte +61 -52
- package/dist/components/presentation-editor/slides-navigation/slides-navigation.svelte +6 -8
- package/dist/components/presentation-editor/snapping-guides.svelte +3 -3
- package/dist/components/presentation-editor/types.d.ts +67 -27
- package/dist/components/presentation-editor/utils.d.ts +50 -1
- package/dist/components/presentation-editor/utils.js +101 -6
- package/dist/components/ui/button/button.svelte +3 -2
- package/dist/components/ui/button/button.svelte.d.ts +5 -82
- package/dist/components/ui/color-picker/color-picker-alpha-grid.svelte +43 -0
- package/dist/components/ui/color-picker/color-picker-alpha-grid.svelte.d.ts +8 -0
- package/dist/components/ui/color-picker/color-picker.svelte +344 -0
- package/dist/components/ui/color-picker/color-picker.svelte.d.ts +13 -0
- package/dist/components/ui/color-picker/index.d.ts +3 -0
- package/dist/components/ui/color-picker/index.js +5 -0
- package/dist/components/ui/context-menu/context-menu-shortcut.svelte +6 -3
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +6 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/infinite-loader/index.d.ts +4 -0
- package/dist/components/ui/infinite-loader/index.js +4 -0
- package/dist/components/ui/infinite-loader/infinite-loader-loop-tracker.d.ts +13 -0
- package/dist/components/ui/infinite-loader/infinite-loader-loop-tracker.js +44 -0
- package/dist/components/ui/infinite-loader/infinite-loader-state.svelte.d.ts +15 -0
- package/dist/components/ui/infinite-loader/infinite-loader-state.svelte.js +28 -0
- package/dist/components/ui/infinite-loader/infinite-loader.svelte +149 -0
- package/dist/components/ui/infinite-loader/infinite-loader.svelte.d.ts +17 -0
- package/dist/components/ui/input/input.svelte +1 -1
- package/dist/components/ui/slider/slider.svelte +20 -18
- package/dist/components/ui/tabs/index.d.ts +6 -0
- package/dist/components/ui/tabs/index.js +8 -0
- package/dist/components/ui/tabs/tabs-content.svelte +19 -0
- package/dist/components/ui/tabs/tabs-content.svelte.d.ts +4 -0
- package/dist/components/ui/tabs/tabs-list.svelte +19 -0
- package/dist/components/ui/tabs/tabs-list.svelte.d.ts +4 -0
- package/dist/components/ui/tabs/tabs-trigger.svelte +19 -0
- package/dist/components/ui/tabs/tabs-trigger.svelte.d.ts +4 -0
- package/dist/components/ui/toggle/toggle.svelte +3 -2
- package/dist/components/ui/toggle/toggle.svelte.d.ts +2 -46
- package/dist/index.d.ts +5 -6
- package/dist/index.js +1 -4
- package/dist/plugin.js +3 -2
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/package.json +28 -25
- package/dist/components/presentation-editor/app.css +0 -12
- package/dist/components/presentation-editor/layers/hovered-layer.svelte +0 -34
- package/dist/components/presentation-editor/layers/hovered-layer.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/background/background-content.svelte +0 -11
- package/dist/components/presentation-editor/layers/types/background/background-content.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/background/background-layer-thumb.svelte +0 -12
- package/dist/components/presentation-editor/layers/types/background/background-layer-thumb.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/html/html-layer-active.svelte +0 -159
- package/dist/components/presentation-editor/layers/types/html/html-layer-active.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/html/html-layer-buttons.svelte +0 -42
- package/dist/components/presentation-editor/layers/types/html/html-layer-buttons.svelte.d.ts +0 -10
- package/dist/components/presentation-editor/layers/types/html/html-layer-thumb.svelte +0 -24
- package/dist/components/presentation-editor/layers/types/html/html-layer-thumb.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/image/image-content.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/image/image-layer-buttons.svelte +0 -21
- package/dist/components/presentation-editor/layers/types/image/image-layer-buttons.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/image/image-layer-thumb.svelte +0 -13
- package/dist/components/presentation-editor/layers/types/image/image-layer-thumb.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/sidebar/images-library.svelte.d.ts +0 -3
- package/dist/components/presentation-editor/sidebar/layers.svelte +0 -94
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-delete-button.svelte +0 -32
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-delete-button.svelte.d.ts +0 -10
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-duplicate-button.svelte +0 -34
- package/dist/components/presentation-editor/slides-navigation/buttons/slide-duplicate-button.svelte.d.ts +0 -10
|
@@ -1,41 +1,31 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onMount, tick } from 'svelte';
|
|
2
|
+
import { onDestroy, onMount, tick } from 'svelte';
|
|
3
|
+
import { get } from 'svelte/store';
|
|
3
4
|
import CheckIcon from 'lucide-svelte/icons/check';
|
|
4
5
|
import * as DropdownMenu from '../ui/dropdown-menu/index.js';
|
|
5
6
|
import { Slider } from '../ui/slider/index.js';
|
|
6
7
|
import { buttonVariants } from '../ui/button/index.js';
|
|
7
|
-
import type {
|
|
8
|
+
import type { Image } from './types.js';
|
|
8
9
|
import { checkImage } from './utils.js';
|
|
9
10
|
import {
|
|
10
11
|
PresentationEditor,
|
|
11
12
|
type PresentationEditorOptions,
|
|
12
13
|
} from './presentation-editor.svelte.js';
|
|
14
|
+
import Hotkeys from './hotkeys.svelte';
|
|
13
15
|
import Header from './header.svelte';
|
|
14
|
-
import Sidebar from './sidebar/sidebar.svelte';
|
|
15
16
|
import SlideEditor from './slide-editor.svelte';
|
|
16
17
|
import SlidesNavigation from './slides-navigation/slides-navigation.svelte';
|
|
17
18
|
import CursorTooltip from './cursor-tooltip.svelte';
|
|
18
19
|
import Dragged from './dragged.svelte';
|
|
20
|
+
import Sidebar from './sidebar/sidebar.svelte';
|
|
19
21
|
|
|
20
22
|
let editorOptions: PresentationEditorOptions = $props();
|
|
21
23
|
|
|
22
|
-
const presentationEditor = new PresentationEditor(editorOptions);
|
|
23
|
-
|
|
24
|
-
let activeSidebarTab: ActiveSidebar = $state('images');
|
|
25
|
-
|
|
26
|
-
const toggleActiveSidebarTab = (name: ActiveSidebar) => {
|
|
27
|
-
const newTab = activeSidebarTab === name ? null : name;
|
|
28
|
-
if (newTab !== activeSidebarTab && (newTab === null || activeSidebarTab === null)) {
|
|
29
|
-
onResize();
|
|
30
|
-
}
|
|
31
|
-
activeSidebarTab = newTab;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
let fittedToScreen = $state(false);
|
|
35
|
-
let filledToScreen = $state(false);
|
|
24
|
+
export const presentationEditor = new PresentationEditor(editorOptions);
|
|
36
25
|
|
|
37
26
|
const sliderMin = -2.304;
|
|
38
27
|
const sliderMax = 1.61;
|
|
28
|
+
const sliderStep = 0.001;
|
|
39
29
|
const zoomMin = 0.1;
|
|
40
30
|
const zoomMax = 5;
|
|
41
31
|
const referenceSlider = 0;
|
|
@@ -56,17 +46,12 @@
|
|
|
56
46
|
};
|
|
57
47
|
|
|
58
48
|
const convertZoomToSlider = (value: number) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return (value - intercept2) / slope2;
|
|
63
|
-
}
|
|
49
|
+
return value <= referenceZoom
|
|
50
|
+
? Math.round((value - intercept1) / slope1 / sliderStep) * sliderStep
|
|
51
|
+
: Math.round((value - intercept2) / slope2 / sliderStep) * sliderStep;
|
|
64
52
|
};
|
|
65
53
|
|
|
66
54
|
let sliderValue = $state(convertZoomToSlider(presentationEditor.zoom));
|
|
67
|
-
const setZoom = (zoom: number) => {
|
|
68
|
-
sliderValue = convertZoomToSlider(zoom);
|
|
69
|
-
};
|
|
70
55
|
|
|
71
56
|
let viewportRef: HTMLDivElement | null = $state(null);
|
|
72
57
|
let wrapperRef: HTMLDivElement | null = $state(null);
|
|
@@ -76,10 +61,8 @@
|
|
|
76
61
|
|
|
77
62
|
let centerX = 0;
|
|
78
63
|
let centerY = 0;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
filledToScreen = false;
|
|
82
|
-
const newZoom = convertSliderToZoom(sliderValue);
|
|
64
|
+
export const setZoom = async (zoom: number) => {
|
|
65
|
+
presentationEditor.zoomSnapping = null;
|
|
83
66
|
if (viewportRef) {
|
|
84
67
|
const centeringPrecision = 0.001;
|
|
85
68
|
const newCenterX =
|
|
@@ -89,37 +72,34 @@
|
|
|
89
72
|
|
|
90
73
|
centerX = Math.abs(centerX - newCenterX) < centeringPrecision ? centerX : newCenterX;
|
|
91
74
|
centerY = Math.abs(centerY - newCenterY) < centeringPrecision ? centerY : newCenterY;
|
|
92
|
-
|
|
93
|
-
presentationEditor.zoom = newZoom;
|
|
94
|
-
tick().then(() => {
|
|
95
|
-
if (viewportRef) {
|
|
96
|
-
viewportRef.scrollLeft = centerX * viewportRef.scrollWidth - viewportRef.clientWidth / 2;
|
|
97
|
-
viewportRef.scrollTop = centerY * viewportRef.scrollHeight - viewportRef.clientHeight / 2;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
} else {
|
|
101
|
-
presentationEditor.zoom = newZoom;
|
|
102
75
|
}
|
|
103
|
-
|
|
76
|
+
presentationEditor.zoom = zoom;
|
|
77
|
+
await tick();
|
|
78
|
+
if (viewportRef) {
|
|
79
|
+
viewportRef.scrollLeft = centerX * viewportRef.scrollWidth - viewportRef.clientWidth / 2;
|
|
80
|
+
viewportRef.scrollTop = centerY * viewportRef.scrollHeight - viewportRef.clientHeight / 2;
|
|
81
|
+
}
|
|
82
|
+
sliderValue = convertZoomToSlider(zoom);
|
|
83
|
+
};
|
|
104
84
|
|
|
105
85
|
export const fillScreen = async () => {
|
|
106
86
|
if (viewportRef && wrapperRef) {
|
|
107
|
-
|
|
87
|
+
await setZoom(
|
|
108
88
|
(presentationEditor.zoom *
|
|
109
89
|
(viewportRef.clientWidth - (wrapperRef.clientWidth - scaledWidth))) /
|
|
110
90
|
scaledWidth,
|
|
111
91
|
);
|
|
112
92
|
tick().then(() => {
|
|
113
|
-
|
|
93
|
+
presentationEditor.zoomSnapping = 'fill';
|
|
114
94
|
});
|
|
115
95
|
}
|
|
116
96
|
};
|
|
117
97
|
|
|
118
|
-
export const fitToScreen = () => {
|
|
98
|
+
export const fitToScreen = async () => {
|
|
119
99
|
if (viewportRef && wrapperRef) {
|
|
120
100
|
viewportRef.scrollLeft = 0;
|
|
121
101
|
viewportRef.scrollTop = 0;
|
|
122
|
-
|
|
102
|
+
await setZoom(
|
|
123
103
|
presentationEditor.zoom *
|
|
124
104
|
Math.min(
|
|
125
105
|
(viewportRef.clientWidth - (wrapperRef.clientWidth - scaledWidth)) / scaledWidth,
|
|
@@ -127,69 +107,27 @@
|
|
|
127
107
|
),
|
|
128
108
|
);
|
|
129
109
|
tick().then(() => {
|
|
130
|
-
|
|
110
|
+
presentationEditor.zoomSnapping = 'fit';
|
|
131
111
|
});
|
|
132
112
|
}
|
|
133
113
|
};
|
|
134
114
|
|
|
135
|
-
const onKeyDown = (e: KeyboardEvent) => {
|
|
136
|
-
console.log('keydown', e);
|
|
137
|
-
if (e.key === 'Escape') {
|
|
138
|
-
if (presentationEditor.activeAction) {
|
|
139
|
-
presentationEditor.activeAction = null;
|
|
140
|
-
} else {
|
|
141
|
-
presentationEditor.setActiveBackground(!!presentationEditor.activeLayer);
|
|
142
|
-
}
|
|
143
|
-
} else if (['Delete', 'Backspace'].includes(e.key)) {
|
|
144
|
-
if (presentationEditor.activeLayer) {
|
|
145
|
-
presentationEditor.removeLayer(presentationEditor.activeLayer);
|
|
146
|
-
} else if (presentationEditor.activeBackground) {
|
|
147
|
-
presentationEditor.removeBackground();
|
|
148
|
-
} else if (presentationEditor.slideSelected) {
|
|
149
|
-
presentationEditor.removeSlide(presentationEditor.activeSlide);
|
|
150
|
-
}
|
|
151
|
-
} else if (e.key === 'z') {
|
|
152
|
-
if (e.metaKey || e.ctrlKey) {
|
|
153
|
-
if (e.shiftKey) {
|
|
154
|
-
presentationEditor.historyRedo();
|
|
155
|
-
} else {
|
|
156
|
-
presentationEditor.historyUndo();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
} else if (e.key === 'y' && (e.metaKey || e.ctrlKey)) {
|
|
160
|
-
presentationEditor.historyRedo();
|
|
161
|
-
} else if (e.key === 'd' && (e.metaKey || e.ctrlKey)) {
|
|
162
|
-
if (presentationEditor.slideSelected) {
|
|
163
|
-
presentationEditor.duplicateSlide(presentationEditor.activeSlide);
|
|
164
|
-
e.preventDefault();
|
|
165
|
-
}
|
|
166
|
-
} else if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
|
|
167
|
-
if (presentationEditor.activeLayer) {
|
|
168
|
-
presentationEditor.clipboard = presentationEditor.activeLayer;
|
|
169
|
-
} else if (presentationEditor.slideSelected) {
|
|
170
|
-
presentationEditor.clipboard = presentationEditor.activeSlide;
|
|
171
|
-
}
|
|
172
|
-
} else if (e.key === 'v' && (e.metaKey || e.ctrlKey)) {
|
|
173
|
-
if (presentationEditor.clipboard) {
|
|
174
|
-
if ('type' in presentationEditor.clipboard) {
|
|
175
|
-
presentationEditor.duplicateLayer(presentationEditor.clipboard);
|
|
176
|
-
} else if ('layers' in presentationEditor.clipboard) {
|
|
177
|
-
presentationEditor.duplicateSlide(presentationEditor.clipboard);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
115
|
const onResize = () => {
|
|
184
116
|
tick().then(() => {
|
|
185
|
-
if (
|
|
117
|
+
if (presentationEditor.zoomSnapping === 'fit') {
|
|
186
118
|
fitToScreen();
|
|
187
|
-
} else if (
|
|
119
|
+
} else if (presentationEditor.zoomSnapping === 'fill') {
|
|
188
120
|
fillScreen();
|
|
189
121
|
}
|
|
190
122
|
});
|
|
191
123
|
};
|
|
192
124
|
|
|
125
|
+
$effect(() => {
|
|
126
|
+
presentationEditor.activeSidebarPopup;
|
|
127
|
+
presentationEditor.activeSidebarTab;
|
|
128
|
+
onResize();
|
|
129
|
+
});
|
|
130
|
+
|
|
193
131
|
const onDragOver = (e: DragEvent) => {
|
|
194
132
|
// console.log('dragover windown', e);
|
|
195
133
|
e.preventDefault();
|
|
@@ -199,25 +137,26 @@
|
|
|
199
137
|
};
|
|
200
138
|
|
|
201
139
|
const onDrop = async (e: DragEvent) => {
|
|
202
|
-
console.log('drop
|
|
203
|
-
|
|
204
|
-
let dropToSlide = false;
|
|
205
|
-
const viewportRect = viewportRef?.getBoundingClientRect();
|
|
206
|
-
const wrapperRect = wrapperRef?.getBoundingClientRect();
|
|
207
|
-
if (viewportRect && wrapperRect) {
|
|
208
|
-
const minLeft = Math.max(viewportRect.left, wrapperRect.left);
|
|
209
|
-
const maxRight = Math.min(viewportRect.right, wrapperRect.right);
|
|
210
|
-
const minTop = Math.max(viewportRect.top, wrapperRect.top);
|
|
211
|
-
const maxBottom = Math.min(viewportRect.bottom, wrapperRect.bottom);
|
|
212
|
-
|
|
213
|
-
dropToSlide =
|
|
214
|
-
e.pageX > minLeft && e.pageX < maxRight && e.pageY > minTop && e.pageY < maxBottom;
|
|
215
|
-
}
|
|
140
|
+
console.log('drop editor', e);
|
|
216
141
|
|
|
217
142
|
e.preventDefault();
|
|
218
143
|
e.stopPropagation();
|
|
144
|
+
|
|
219
145
|
presentationEditor.fileDragged = false;
|
|
220
146
|
if (e.dataTransfer?.items.length) {
|
|
147
|
+
let dropToSlide = false;
|
|
148
|
+
const viewportRect = viewportRef?.getBoundingClientRect();
|
|
149
|
+
const wrapperRect = wrapperRef?.getBoundingClientRect();
|
|
150
|
+
if (viewportRect && wrapperRect) {
|
|
151
|
+
const minLeft = Math.max(viewportRect.left, wrapperRect.left);
|
|
152
|
+
const maxRight = Math.min(viewportRect.right, wrapperRect.right);
|
|
153
|
+
const minTop = Math.max(viewportRect.top, wrapperRect.top);
|
|
154
|
+
const maxBottom = Math.min(viewportRect.bottom, wrapperRect.bottom);
|
|
155
|
+
|
|
156
|
+
dropToSlide =
|
|
157
|
+
e.pageX > minLeft && e.pageX < maxRight && e.pageY > minTop && e.pageY < maxBottom;
|
|
158
|
+
}
|
|
159
|
+
|
|
221
160
|
const item = e.dataTransfer.items[0];
|
|
222
161
|
console.log('item', item, item.kind, item.type);
|
|
223
162
|
if (['image/png', 'image/jpeg', 'image/gif'].includes(item.type)) {
|
|
@@ -242,18 +181,12 @@
|
|
|
242
181
|
}
|
|
243
182
|
presentationEditor.images.push(image);
|
|
244
183
|
if (dropToSlide) {
|
|
245
|
-
presentationEditor.
|
|
246
|
-
x: (presentationEditor.width - image.width) / 2,
|
|
247
|
-
y: (presentationEditor.height - image.height) / 2,
|
|
184
|
+
const layer = presentationEditor.buildImageLayer({
|
|
248
185
|
width: image.width,
|
|
249
186
|
height: image.height,
|
|
250
|
-
image
|
|
251
|
-
id: image.id,
|
|
252
|
-
src: image.src,
|
|
253
|
-
width: image.width,
|
|
254
|
-
height: image.height,
|
|
255
|
-
},
|
|
187
|
+
image,
|
|
256
188
|
});
|
|
189
|
+
presentationEditor.addLayers(presentationEditor.activeSlide.id, layer);
|
|
257
190
|
}
|
|
258
191
|
} catch (err) {
|
|
259
192
|
console.log('err', err);
|
|
@@ -268,69 +201,80 @@
|
|
|
268
201
|
fitToScreen();
|
|
269
202
|
});
|
|
270
203
|
});
|
|
271
|
-
</script>
|
|
272
|
-
|
|
273
|
-
<svelte:window onkeydown={onKeyDown} onresize={onResize} ondragover={onDragOver} />
|
|
274
|
-
|
|
275
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
276
|
-
<div
|
|
277
|
-
class="flex h-full select-none flex-col"
|
|
278
|
-
ondragover={(e) => e.preventDefault()}
|
|
279
|
-
ondrop={onDrop}
|
|
280
|
-
>
|
|
281
|
-
<Dragged />
|
|
282
|
-
<CursorTooltip />
|
|
283
|
-
<Header {activeSidebarTab} onChange={toggleActiveSidebarTab} />
|
|
284
204
|
|
|
285
|
-
|
|
286
|
-
|
|
205
|
+
onDestroy(() => {
|
|
206
|
+
console.log('editor main component destroy');
|
|
207
|
+
get(presentationEditor.htmlEditor).destroy();
|
|
208
|
+
});
|
|
209
|
+
</script>
|
|
287
210
|
|
|
288
|
-
|
|
289
|
-
<main class="flex min-h-0 flex-1 flex-col bg-gray-200">
|
|
290
|
-
<SlideEditor bind:wrapperRef bind:viewportRef />
|
|
291
|
-
</main>
|
|
211
|
+
<svelte:window onresize={onResize} />
|
|
292
212
|
|
|
293
|
-
|
|
294
|
-
{#if presentationEditor.mode === 'multiple'}
|
|
295
|
-
<SlidesNavigation />
|
|
296
|
-
{/if}
|
|
297
|
-
<div class="flex items-center justify-end gap-2 px-4">
|
|
298
|
-
<div class="w-48">
|
|
299
|
-
<Slider
|
|
300
|
-
type="single"
|
|
301
|
-
bind:value={sliderValue}
|
|
302
|
-
min={sliderMin}
|
|
303
|
-
max={sliderMax}
|
|
304
|
-
step={0.001}
|
|
305
|
-
/>
|
|
306
|
-
</div>
|
|
307
|
-
<DropdownMenu.Root>
|
|
308
|
-
<DropdownMenu.Trigger
|
|
309
|
-
class={buttonVariants({ variant: 'ghost', size: 'icon-xs', class: 'w-16' })}
|
|
310
|
-
>
|
|
311
|
-
{Math.round(presentationEditor.zoom * 100)}%
|
|
312
|
-
</DropdownMenu.Trigger>
|
|
213
|
+
<Hotkeys />
|
|
313
214
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
215
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
216
|
+
<div class="flex h-full w-full select-none" ondragover={onDragOver} ondrop={onDrop}>
|
|
217
|
+
<Sidebar />
|
|
218
|
+
<div class="flex h-full flex-1 select-none flex-col overflow-auto">
|
|
219
|
+
<Dragged />
|
|
220
|
+
<CursorTooltip />
|
|
221
|
+
<Header />
|
|
222
|
+
|
|
223
|
+
<div class="flex min-h-0 flex-1">
|
|
224
|
+
<div class="relative flex grow flex-col overflow-hidden bg-gray-100">
|
|
225
|
+
<main class="flex min-h-0 flex-1 flex-col bg-gray-200">
|
|
226
|
+
<SlideEditor bind:wrapperRef bind:viewportRef />
|
|
227
|
+
</main>
|
|
228
|
+
|
|
229
|
+
<footer class="relative">
|
|
230
|
+
{#if presentationEditor.mode === 'multiple'}
|
|
231
|
+
<SlidesNavigation />
|
|
232
|
+
{/if}
|
|
233
|
+
<div class="flex items-center justify-end gap-2 px-4">
|
|
234
|
+
<div class="w-48">
|
|
235
|
+
<Slider
|
|
236
|
+
type="single"
|
|
237
|
+
value={sliderValue}
|
|
238
|
+
onValueChange={(v) => setZoom(convertSliderToZoom(v))}
|
|
239
|
+
min={sliderMin}
|
|
240
|
+
max={sliderMax}
|
|
241
|
+
step={sliderStep}
|
|
242
|
+
/>
|
|
243
|
+
</div>
|
|
244
|
+
<DropdownMenu.Root>
|
|
245
|
+
<DropdownMenu.Trigger
|
|
246
|
+
class={buttonVariants({ variant: 'ghost', size: 'icon-xs', class: 'w-16' })}
|
|
247
|
+
>
|
|
248
|
+
{Math.round(presentationEditor.zoom * 100)}%
|
|
249
|
+
</DropdownMenu.Trigger>
|
|
250
|
+
|
|
251
|
+
<DropdownMenu.Content align="end" class="w-48">
|
|
252
|
+
{#each [3, 2, 1.25, 1, 0.75, 0.5, 0.25, 0.1] as zoomLevel}
|
|
253
|
+
<DropdownMenu.Item onclick={() => setZoom(zoomLevel)}>
|
|
254
|
+
{(zoomLevel * 100).toFixed(0)}%
|
|
255
|
+
{#if presentationEditor.zoom === zoomLevel}
|
|
256
|
+
<CheckIcon class="h-4 w-4" />
|
|
257
|
+
{/if}
|
|
258
|
+
</DropdownMenu.Item>
|
|
259
|
+
{/each}
|
|
260
|
+
<DropdownMenu.Separator />
|
|
261
|
+
<DropdownMenu.Item onclick={fitToScreen}>
|
|
262
|
+
Fit
|
|
263
|
+
{#if presentationEditor.zoomSnapping === 'fit'}
|
|
264
|
+
<CheckIcon class="h-4 w-4" />
|
|
265
|
+
{/if}
|
|
266
|
+
</DropdownMenu.Item>
|
|
267
|
+
<DropdownMenu.Item onclick={fillScreen}>
|
|
268
|
+
Fill
|
|
269
|
+
{#if presentationEditor.zoomSnapping === 'fill'}
|
|
270
|
+
<CheckIcon class="h-4 w-4" />
|
|
271
|
+
{/if}
|
|
319
272
|
</DropdownMenu.Item>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
</DropdownMenu.Item>
|
|
326
|
-
<DropdownMenu.Item onclick={fillScreen}>
|
|
327
|
-
Fill
|
|
328
|
-
{#if filledToScreen}<CheckIcon class="h-4 w-4" />{/if}
|
|
329
|
-
</DropdownMenu.Item>
|
|
330
|
-
</DropdownMenu.Content>
|
|
331
|
-
</DropdownMenu.Root>
|
|
332
|
-
</div>
|
|
333
|
-
</footer>
|
|
273
|
+
</DropdownMenu.Content>
|
|
274
|
+
</DropdownMenu.Root>
|
|
275
|
+
</div>
|
|
276
|
+
</footer>
|
|
277
|
+
</div>
|
|
334
278
|
</div>
|
|
335
279
|
</div>
|
|
336
280
|
</div>
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { PresentationEditor } from './presentation-editor.svelte.js';
|
|
2
|
-
declare const PresentationEditor:
|
|
3
|
-
fillScreen: () => Promise<void>;
|
|
4
|
-
fitToScreen: () => void;
|
|
5
|
-
}, "">;
|
|
2
|
+
declare const PresentationEditor: any;
|
|
6
3
|
type PresentationEditor = ReturnType<typeof PresentationEditor>;
|
|
7
4
|
export default PresentationEditor;
|