@turnix-co/konva-editor 2.0.7 → 2.0.10
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 +76 -10
- package/dist/index.d.ts +61 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,9 +46,16 @@ import {
|
|
|
46
46
|
Canvas,
|
|
47
47
|
Toolbar,
|
|
48
48
|
SlideNavigation,
|
|
49
|
+
TopNavBar,
|
|
50
|
+
BottomToolbar,
|
|
51
|
+
PublishButton,
|
|
52
|
+
EditorRoot,
|
|
49
53
|
ReduxProvider,
|
|
50
54
|
store,
|
|
51
|
-
useSlidesPersistence
|
|
55
|
+
useSlidesPersistence,
|
|
56
|
+
type Slide,
|
|
57
|
+
type PublishProgress,
|
|
58
|
+
type PublishResponse,
|
|
52
59
|
} from '@turnix-co/konva-editor';
|
|
53
60
|
import '@turnix-co/konva-editor/styles.css';
|
|
54
61
|
import type Konva from 'konva';
|
|
@@ -62,24 +69,48 @@ function PersistenceLoader({ children }: { children: React.ReactNode }) {
|
|
|
62
69
|
export default function EditorPage() {
|
|
63
70
|
const stageRef = useRef<Konva.Stage | null>(null);
|
|
64
71
|
|
|
72
|
+
const handlePublish = async (
|
|
73
|
+
slides: Slide[],
|
|
74
|
+
onProgress?: (progress: PublishProgress) => void
|
|
75
|
+
): Promise<PublishResponse> => {
|
|
76
|
+
// Your publish logic here
|
|
77
|
+
return { success: true, message: 'Published!' };
|
|
78
|
+
};
|
|
79
|
+
|
|
65
80
|
return (
|
|
66
81
|
<ReduxProvider store={store}>
|
|
67
82
|
<PersistenceLoader>
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
<EditorRoot
|
|
84
|
+
style={{
|
|
85
|
+
width: '100vw',
|
|
86
|
+
height: '100vh',
|
|
87
|
+
display: 'flex',
|
|
88
|
+
flexDirection: 'column',
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{/* Header with title and publish button */}
|
|
93
|
+
<TopNavBar
|
|
94
|
+
title="My Lesson"
|
|
95
|
+
autoSaveMessage="Auto-saved just now"
|
|
96
|
+
onBack={() => window.history.back()}
|
|
97
|
+
onPublish={handlePublish}
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
{/* Main toolbar */}
|
|
75
101
|
<Toolbar stageRef={stageRef} />
|
|
76
102
|
|
|
103
|
+
{/* Canvas area */}
|
|
77
104
|
<div style={{ flex: 1, position: 'relative' }}>
|
|
78
105
|
<Canvas onStageReady={(ref) => { stageRef.current = ref.current; }} />
|
|
106
|
+
|
|
107
|
+
{/* Bottom toolbar for pen size and colors (shows when drawing) */}
|
|
108
|
+
<BottomToolbar />
|
|
79
109
|
</div>
|
|
80
110
|
|
|
111
|
+
{/* Slide navigation */}
|
|
81
112
|
<SlideNavigation />
|
|
82
|
-
</
|
|
113
|
+
</EditorRoot>
|
|
83
114
|
</PersistenceLoader>
|
|
84
115
|
</ReduxProvider>
|
|
85
116
|
);
|
|
@@ -112,9 +143,12 @@ export default function EditorPage() {
|
|
|
112
143
|
| `Canvas` | Main canvas component with drawing, images, videos, and text |
|
|
113
144
|
| `Toolbar` | Toolbar with drawing tools, colors, and actions |
|
|
114
145
|
| `SlideNavigation` | Multi-slide navigation and management |
|
|
146
|
+
| `TopNavBar` | Header with title, auto-save status, and action buttons |
|
|
147
|
+
| `BottomToolbar` | Pen size and color picker toolbar |
|
|
148
|
+
| `LayersPanel` | Layer management panel for reordering elements |
|
|
115
149
|
| `ScreenRecorder` | Screen recording functionality |
|
|
116
150
|
| `PublishButton` | Customizable publish button with progress tracking |
|
|
117
|
-
| `EditorRoot` | Root wrapper that scopes styles (
|
|
151
|
+
| `EditorRoot` | Root wrapper that scopes styles (required for styling) |
|
|
118
152
|
|
|
119
153
|
### Redux Setup
|
|
120
154
|
|
|
@@ -311,6 +345,8 @@ import type {
|
|
|
311
345
|
CanvasProps,
|
|
312
346
|
ToolbarProps,
|
|
313
347
|
EditorRootProps,
|
|
348
|
+
TopNavBarProps,
|
|
349
|
+
BottomToolbarProps,
|
|
314
350
|
ExportOptions,
|
|
315
351
|
PublishProgress,
|
|
316
352
|
PublishResponse,
|
|
@@ -319,6 +355,36 @@ import type {
|
|
|
319
355
|
} from '@turnix-co/konva-editor';
|
|
320
356
|
```
|
|
321
357
|
|
|
358
|
+
## Component Props
|
|
359
|
+
|
|
360
|
+
### TopNavBar
|
|
361
|
+
|
|
362
|
+
| Prop | Type | Default | Description |
|
|
363
|
+
|------|------|---------|-------------|
|
|
364
|
+
| `title` | `string` | `'Untitled'` | Title displayed in the header |
|
|
365
|
+
| `autoSaveMessage` | `string` | `'Auto-saved just now'` | Auto-save status text |
|
|
366
|
+
| `onBack` | `() => void` | - | Callback when back button clicked |
|
|
367
|
+
| `onSettings` | `() => void` | - | Callback when settings button clicked |
|
|
368
|
+
| `onProfile` | `() => void` | - | Callback when profile button clicked |
|
|
369
|
+
| `onPublish` | `PublishButtonProps['onPublish']` | - | Publish function (shows publish button if provided) |
|
|
370
|
+
| `showBackButton` | `boolean` | `true` | Show/hide back button |
|
|
371
|
+
| `showSettingsButton` | `boolean` | `true` | Show/hide settings button |
|
|
372
|
+
| `showProfileButton` | `boolean` | `true` | Show/hide profile button |
|
|
373
|
+
| `showPublishButton` | `boolean` | `true` | Show/hide publish button |
|
|
374
|
+
| `leftContent` | `React.ReactNode` | - | Custom left side content |
|
|
375
|
+
| `rightContent` | `React.ReactNode` | - | Custom right side content |
|
|
376
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
377
|
+
|
|
378
|
+
### BottomToolbar
|
|
379
|
+
|
|
380
|
+
| Prop | Type | Default | Description |
|
|
381
|
+
|------|------|---------|-------------|
|
|
382
|
+
| `colors` | `Array<{name: string, value: string}>` | Default colors | Custom color palette |
|
|
383
|
+
| `showSizeSlider` | `boolean` | `true` | Show/hide pen size slider |
|
|
384
|
+
| `showColorPicker` | `boolean` | `true` | Show/hide color picker |
|
|
385
|
+
| `showBackgroundPicker` | `boolean` | `true` | Show/hide background color picker |
|
|
386
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
387
|
+
|
|
322
388
|
## Troubleshooting
|
|
323
389
|
|
|
324
390
|
### Recorded Video Not Displaying Full Screen
|
package/dist/index.d.ts
CHANGED
|
@@ -560,6 +560,66 @@ interface EditorRootProps {
|
|
|
560
560
|
*/
|
|
561
561
|
declare function EditorRoot({ children, className, style }: EditorRootProps): react_jsx_runtime.JSX.Element;
|
|
562
562
|
|
|
563
|
+
type TopNavBarProps = {
|
|
564
|
+
/** Title displayed in the header */
|
|
565
|
+
title?: string;
|
|
566
|
+
/** Auto-save status message */
|
|
567
|
+
autoSaveMessage?: string;
|
|
568
|
+
/** Callback when back button is clicked */
|
|
569
|
+
onBack?: () => void;
|
|
570
|
+
/** Callback when settings button is clicked */
|
|
571
|
+
onSettings?: () => void;
|
|
572
|
+
/** Callback when user/profile button is clicked */
|
|
573
|
+
onProfile?: () => void;
|
|
574
|
+
/** Function to publish slides (passed to PublishButton) */
|
|
575
|
+
onPublish?: PublishButtonProps['onPublish'];
|
|
576
|
+
/** Whether to show the publish button */
|
|
577
|
+
showPublishButton?: boolean;
|
|
578
|
+
/** Whether to show the settings button */
|
|
579
|
+
showSettingsButton?: boolean;
|
|
580
|
+
/** Whether to show the profile button */
|
|
581
|
+
showProfileButton?: boolean;
|
|
582
|
+
/** Whether to show the back button */
|
|
583
|
+
showBackButton?: boolean;
|
|
584
|
+
/** Custom class name for the container */
|
|
585
|
+
className?: string;
|
|
586
|
+
/** Custom content to render on the right side (replaces default buttons) */
|
|
587
|
+
rightContent?: React$1.ReactNode;
|
|
588
|
+
/** Custom content to render on the left side (replaces default content) */
|
|
589
|
+
leftContent?: React$1.ReactNode;
|
|
590
|
+
};
|
|
591
|
+
declare const TopNavBar: React$1.FC<TopNavBarProps>;
|
|
592
|
+
|
|
593
|
+
type BottomToolbarProps = {
|
|
594
|
+
/** Custom colors array to override defaults */
|
|
595
|
+
colors?: Array<{
|
|
596
|
+
name: string;
|
|
597
|
+
value: string;
|
|
598
|
+
}>;
|
|
599
|
+
/** Whether to show the size slider */
|
|
600
|
+
showSizeSlider?: boolean;
|
|
601
|
+
/** Whether to show the color picker */
|
|
602
|
+
showColorPicker?: boolean;
|
|
603
|
+
/** Whether to show the background color picker */
|
|
604
|
+
showBackgroundPicker?: boolean;
|
|
605
|
+
/** Custom class name for the container */
|
|
606
|
+
className?: string;
|
|
607
|
+
};
|
|
608
|
+
declare const BottomToolbar: React$1.FC<BottomToolbarProps>;
|
|
609
|
+
|
|
610
|
+
type LayerItem = {
|
|
611
|
+
id: string;
|
|
612
|
+
type: 'image' | 'video' | 'shape' | 'text' | 'flashcard' | 'photoFrame' | 'mcq' | 'trueFalse' | 'shortAnswer' | 'longAnswer' | 'fillInTheBlanks' | 'line';
|
|
613
|
+
name: string;
|
|
614
|
+
timestamp: number;
|
|
615
|
+
};
|
|
616
|
+
type LayersPanelProps = {
|
|
617
|
+
selectedElementId?: string;
|
|
618
|
+
onClose: () => void;
|
|
619
|
+
onSelectElement: (id: string, type: LayerItem['type']) => void;
|
|
620
|
+
};
|
|
621
|
+
declare const LayersPanel: React$1.FC<LayersPanelProps>;
|
|
622
|
+
|
|
563
623
|
type ToolbarState = {
|
|
564
624
|
selectedTool: string;
|
|
565
625
|
penColor: string;
|
|
@@ -686,4 +746,4 @@ declare const useSelector: <T>(selector: (state: RootState) => T) => T;
|
|
|
686
746
|
|
|
687
747
|
declare const useSlidesPersistence: () => void;
|
|
688
748
|
|
|
689
|
-
export { type AppDispatch, Canvas, type CanvasProps, EditorRoot, type EditorRootProps, type ExportOptions, type FillInTheBlanks, type FlashcardElement, type ImageElement, type Line$1 as Line, type LongAnswer, type MultipleChoice, type PhotoFrameElement, PublishButton, type PublishButtonProps, type PublishProgress, type PublishResponse, type RootState, ScreenRecorder, type Shape, type ShortAnswer, type Slide, SlideNavigation, type TextElement, Toolbar, type ToolbarProps, type TrueFalse, type VideoElement, addFillInTheBlanks, addFlashcard, addImage, addImageAnnotation, addLine, addLongAnswer, addMultipleChoice, addPhotoFrame, addPhotoFrameAnnotation, addShape, addShortAnswer, addSlide, addText, addTrueFalse, addVideo, bringToFront, clearCanvas, clearImageAnnotations, clearPhotoFrameAnnotations, deleteFillInTheBlanks, deleteFlashcard, deleteImage, deleteLineById, deleteLongAnswer, deleteMultipleChoice, deletePhotoFrame, deleteShape, deleteShortAnswer, deleteSlide, deleteText, deleteTrueFalse, deleteVideo, duplicateFillInTheBlanks, duplicateFlashcard, duplicateImage, duplicateLine, duplicateLongAnswer, duplicateMultipleChoice, duplicatePhotoFrame, duplicateShape, duplicateShortAnswer, duplicateSlide, duplicateText, duplicateTrueFalse, duplicateVideo, editFlashcard, editMultipleChoice, exportSlideAsBlob, exportSlideAsImage, finalizeDrawing, getCompressionStats, getSlideDataURL, loadSlides, nextFlashcard, previousFlashcard, redo, removeLine, reorderSlides, saveToHistory, selectAllSlides, selectCanAddSlide, selectCurrentSlide, selectCurrentSlideId, selectSlideById, sendToBack, setActivityType, setAltText, setAudioData, setBackgroundColor, setCurrentSlide, setEditingActivity, setEditingTextId, setLines, setLink, setPenColor, setShowFlashcardForm, setShowMcqForm, setSketchMode, setStrokeWidth, setTool, simplifyFlatPoints, simplifyLine, simplifyLines, store, toggleImageDrawingMode, toggleLock, togglePhotoFrameDrawingMode, toggleSketchMode, toggleVideoPlaying, undo, updateElementOrder, updateFillInTheBlanks, updateFlashcard, updateImage, updateImageAnnotation, updateLastLine, updateLinePosition, updateLineTransform, updateLongAnswer, updateMultipleChoice, updatePhotoFrame, updatePhotoFrameAnnotation, updateShape, updateShortAnswer, updateSlideThumbnail, updateText, updateTrueFalse, updateVideo, useDispatch, useSelector, useSlidesPersistence };
|
|
749
|
+
export { type AppDispatch, BottomToolbar, type BottomToolbarProps, Canvas, type CanvasProps, EditorRoot, type EditorRootProps, type ExportOptions, type FillInTheBlanks, type FlashcardElement, type ImageElement, LayersPanel, type Line$1 as Line, type LongAnswer, type MultipleChoice, type PhotoFrameElement, PublishButton, type PublishButtonProps, type PublishProgress, type PublishResponse, type RootState, ScreenRecorder, type Shape, type ShortAnswer, type Slide, SlideNavigation, type TextElement, Toolbar, type ToolbarProps, TopNavBar, type TopNavBarProps, type TrueFalse, type VideoElement, addFillInTheBlanks, addFlashcard, addImage, addImageAnnotation, addLine, addLongAnswer, addMultipleChoice, addPhotoFrame, addPhotoFrameAnnotation, addShape, addShortAnswer, addSlide, addText, addTrueFalse, addVideo, bringToFront, clearCanvas, clearImageAnnotations, clearPhotoFrameAnnotations, deleteFillInTheBlanks, deleteFlashcard, deleteImage, deleteLineById, deleteLongAnswer, deleteMultipleChoice, deletePhotoFrame, deleteShape, deleteShortAnswer, deleteSlide, deleteText, deleteTrueFalse, deleteVideo, duplicateFillInTheBlanks, duplicateFlashcard, duplicateImage, duplicateLine, duplicateLongAnswer, duplicateMultipleChoice, duplicatePhotoFrame, duplicateShape, duplicateShortAnswer, duplicateSlide, duplicateText, duplicateTrueFalse, duplicateVideo, editFlashcard, editMultipleChoice, exportSlideAsBlob, exportSlideAsImage, finalizeDrawing, getCompressionStats, getSlideDataURL, loadSlides, nextFlashcard, previousFlashcard, redo, removeLine, reorderSlides, saveToHistory, selectAllSlides, selectCanAddSlide, selectCurrentSlide, selectCurrentSlideId, selectSlideById, sendToBack, setActivityType, setAltText, setAudioData, setBackgroundColor, setCurrentSlide, setEditingActivity, setEditingTextId, setLines, setLink, setPenColor, setShowFlashcardForm, setShowMcqForm, setSketchMode, setStrokeWidth, setTool, simplifyFlatPoints, simplifyLine, simplifyLines, store, toggleImageDrawingMode, toggleLock, togglePhotoFrameDrawingMode, toggleSketchMode, toggleVideoPlaying, undo, updateElementOrder, updateFillInTheBlanks, updateFlashcard, updateImage, updateImageAnnotation, updateLastLine, updateLinePosition, updateLineTransform, updateLongAnswer, updateMultipleChoice, updatePhotoFrame, updatePhotoFrameAnnotation, updateShape, updateShortAnswer, updateSlideThumbnail, updateText, updateTrueFalse, updateVideo, useDispatch, useSelector, useSlidesPersistence };
|