@turnix-co/konva-editor 2.0.27 → 2.0.28

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/dist/index.d.ts CHANGED
@@ -120,17 +120,7 @@ type ToolbarProps = {
120
120
  };
121
121
  declare const Toolbar: ({ isOpen: isOpenProp, onClose, onScreenRecord, stageRef, onTextAdded, showToggleButton, config, }?: ToolbarProps) => react_jsx_runtime.JSX.Element;
122
122
 
123
- declare const SlideNavigation: React$1.FC;
124
-
125
- type ScreenRecorderProps = {
126
- onClose: () => void;
127
- stageRef?: React$1.RefObject<Konva.Stage | null>;
128
- onRecordingComplete?: (videoBlob: Blob, thumbnailDataUrl: string) => void;
129
- directDrawingCanvasRef?: React$1.RefObject<HTMLCanvasElement | null>;
130
- };
131
- declare const ScreenRecorder: React$1.FC<ScreenRecorderProps>;
132
-
133
- type Line = {
123
+ type Line$1 = {
134
124
  id?: string;
135
125
  tool: string;
136
126
  points: number[];
@@ -192,7 +182,7 @@ type ImageElement = {
192
182
  zIndex?: number;
193
183
  timestamp?: number;
194
184
  audioData?: string;
195
- annotations?: Line[];
185
+ annotations?: Line$1[];
196
186
  isDrawingMode?: boolean;
197
187
  };
198
188
  type VideoElement = {
@@ -251,7 +241,7 @@ type PhotoFrameElement = {
251
241
  timestamp?: number;
252
242
  audioData?: string;
253
243
  isCapturing: boolean;
254
- annotations?: Line[];
244
+ annotations?: Line$1[];
255
245
  isDrawingMode?: boolean;
256
246
  };
257
247
  type TextElement = {
@@ -402,7 +392,7 @@ type Slide = {
402
392
  name: string;
403
393
  thumbnail?: string;
404
394
  backgroundColor?: string;
405
- lines: Line[];
395
+ lines: Line$1[];
406
396
  shapes: Shape[];
407
397
  images: ImageElement[];
408
398
  videos: VideoElement[];
@@ -450,7 +440,7 @@ declare const loadSlides: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
450
440
  slides: Slide[];
451
441
  currentSlideId: string;
452
442
  }, "canvas/loadSlides">;
453
- declare const addLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line, "canvas/addLine">;
443
+ declare const addLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line$1, "canvas/addLine">;
454
444
  declare const removeLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<number, "canvas/removeLine">;
455
445
  declare const addImage: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<ImageElement, "canvas/addImage">;
456
446
  declare const updateImage: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Partial<ImageElement> & {
@@ -495,7 +485,7 @@ declare const duplicatePhotoFrame: _reduxjs_toolkit.ActionCreatorWithOptionalPay
495
485
  declare const toggleImageDrawingMode: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<string, "canvas/toggleImageDrawingMode">;
496
486
  declare const addImageAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
497
487
  imageId: string;
498
- line: Line;
488
+ line: Line$1;
499
489
  }, "canvas/addImageAnnotation">;
500
490
  declare const updateImageAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
501
491
  imageId: string;
@@ -505,7 +495,7 @@ declare const clearImageAnnotations: _reduxjs_toolkit.ActionCreatorWithOptionalP
505
495
  declare const togglePhotoFrameDrawingMode: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<string, "canvas/togglePhotoFrameDrawingMode">;
506
496
  declare const addPhotoFrameAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
507
497
  frameId: string;
508
- line: Line;
498
+ line: Line$1;
509
499
  }, "canvas/addPhotoFrameAnnotation">;
510
500
  declare const updatePhotoFrameAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
511
501
  frameId: string;
@@ -578,7 +568,7 @@ declare const setAudioData: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
578
568
  }, "canvas/setAudioData">;
579
569
  declare const updateLastLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<number[], "canvas/updateLastLine">;
580
570
  declare const finalizeDrawing: _reduxjs_toolkit.ActionCreatorWithoutPayload<"canvas/finalizeDrawing">;
581
- declare const setLines: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line[], "canvas/setLines">;
571
+ declare const setLines: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line$1[], "canvas/setLines">;
582
572
  declare const updateLinePosition: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
583
573
  id: string;
584
574
  x: number;
@@ -640,6 +630,63 @@ interface PublishButtonProps {
640
630
  }
641
631
  declare const PublishButton: React$1.FC<PublishButtonProps>;
642
632
 
633
+ type TopNavBarProps = {
634
+ /** Title displayed in the header */
635
+ title?: string;
636
+ /** Auto-save status message */
637
+ autoSaveMessage?: string;
638
+ /** Callback when back button is clicked */
639
+ onBack?: () => void;
640
+ /** Callback when settings button is clicked */
641
+ onSettings?: () => void;
642
+ /** Callback when user/profile button is clicked */
643
+ onProfile?: () => void;
644
+ /** Function to publish slides (passed to PublishButton) */
645
+ onPublish?: PublishButtonProps['onPublish'];
646
+ /** Whether to show the publish button */
647
+ showPublishButton?: boolean;
648
+ /** Whether to show the settings button */
649
+ showSettingsButton?: boolean;
650
+ /** Whether to show the profile button */
651
+ showProfileButton?: boolean;
652
+ /** Whether to show the back button */
653
+ showBackButton?: boolean;
654
+ /** Custom class name for the container */
655
+ className?: string;
656
+ /** Custom content to render on the right side (replaces default buttons) */
657
+ rightContent?: React$1.ReactNode;
658
+ /** Custom content to render on the left side (replaces default content) */
659
+ leftContent?: React$1.ReactNode;
660
+ };
661
+ declare const TopNavBar: React$1.FC<TopNavBarProps>;
662
+
663
+ type BottomToolbarProps = {
664
+ /** Custom colors array to override defaults */
665
+ colors?: Array<{
666
+ name: string;
667
+ value: string;
668
+ }>;
669
+ /** Whether to show the size slider */
670
+ showSizeSlider?: boolean;
671
+ /** Whether to show the color picker */
672
+ showColorPicker?: boolean;
673
+ /** Whether to show the background color picker */
674
+ showBackgroundPicker?: boolean;
675
+ /** Custom class name for the container */
676
+ className?: string;
677
+ };
678
+ declare const BottomToolbar: React$1.FC<BottomToolbarProps>;
679
+
680
+ declare const SlideNavigation: React$1.FC;
681
+
682
+ type ScreenRecorderProps = {
683
+ onClose: () => void;
684
+ stageRef?: React$1.RefObject<Konva.Stage | null>;
685
+ onRecordingComplete?: (videoBlob: Blob, thumbnailDataUrl: string) => void;
686
+ directDrawingCanvasRef?: React$1.RefObject<HTMLCanvasElement | null>;
687
+ };
688
+ declare const ScreenRecorder: React$1.FC<ScreenRecorderProps>;
689
+
643
690
  type ToolbarState = {
644
691
  selectedTool: string;
645
692
  penColor: string;
@@ -695,6 +742,60 @@ declare const exportSlideAsImage: (stage: Konva.Stage, options?: ExportOptions)
695
742
  declare const exportSlideAsBlob: (stage: Konva.Stage, options?: Omit<ExportOptions, "fileName">) => Promise<Blob>;
696
743
  declare const getSlideDataURL: (stage: Konva.Stage, options?: Omit<ExportOptions, "fileName">) => string;
697
744
 
745
+ /**
746
+ * Line simplification utilities using Douglas-Peucker algorithm
747
+ * Reduces the number of points in a line while preserving its shape
748
+ */
749
+ /**
750
+ * Simplify a flat points array using Douglas-Peucker algorithm
751
+ *
752
+ * @param flatPoints Array of points [x1, y1, x2, y2, ...]
753
+ * @param epsilon Tolerance for simplification (default: 1.5 pixels)
754
+ * @returns Simplified flat points array
755
+ */
756
+ declare const simplifyFlatPoints: (flatPoints: number[], epsilon?: number) => number[];
757
+ /**
758
+ * Line type matching the canvasSlice Line type
759
+ */
760
+ type Line = {
761
+ id?: string;
762
+ tool: string;
763
+ points: number[];
764
+ color: string;
765
+ strokeWidth: number;
766
+ isSketch?: boolean;
767
+ timestamp?: number;
768
+ x?: number;
769
+ y?: number;
770
+ scaleX?: number;
771
+ scaleY?: number;
772
+ rotation?: number;
773
+ };
774
+ /**
775
+ * Simplify a single line's points using Douglas-Peucker algorithm
776
+ *
777
+ * @param line The line object to simplify
778
+ * @param epsilon Tolerance for simplification
779
+ * @returns New line object with simplified points
780
+ */
781
+ declare const simplifyLine: (line: Line, epsilon?: number) => Line;
782
+ /**
783
+ * Simplify an array of lines
784
+ *
785
+ * @param lines Array of line objects
786
+ * @param epsilon Tolerance for simplification
787
+ * @returns Array of lines with simplified points
788
+ */
789
+ declare const simplifyLines: (lines: Line[], epsilon?: number) => Line[];
790
+ /**
791
+ * Calculate compression ratio for debugging/logging
792
+ */
793
+ declare const getCompressionStats: (original: number[], simplified: number[]) => {
794
+ originalPoints: number;
795
+ simplifiedPoints: number;
796
+ reduction: string;
797
+ };
798
+
698
799
  declare const useDispatch: () => redux_thunk.ThunkDispatch<{
699
800
  toolbar: ToolbarState;
700
801
  canvas: {
@@ -712,4 +813,4 @@ declare const useSelector: <T>(selector: (state: RootState) => T) => T;
712
813
 
713
814
  declare const useSlidesPersistence: () => void;
714
815
 
715
- export { type ActionType, type ActivityType, type AppDispatch, BASIC_EDITOR_TOOLBAR_CONFIG, Canvas, type CanvasProps, type ContextMenuConfig, DEFAULT_CONTEXT_MENU_CONFIG, DEFAULT_TOOLBAR_CONFIG, type ExportOptions, type FillInTheBlanks, type FlashcardElement, type ImageElement, type Line, type LongAnswer, type MediaType, type MultipleChoice, type PhotoFrameElement, PublishButton, type PublishButtonProps, type PublishProgress, type PublishResponse, type RootState, ScreenRecorder, type Shape, type ShapeType, type ShortAnswer, type Slide, SlideNavigation, type TextElement, type ToolType, Toolbar, type ToolbarActionsConfig, type ToolbarConfig, type ToolbarProps, type ToolbarToolsConfig, type TrueFalse, VIEWER_TOOLBAR_CONFIG, 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, getSlideDataURL, loadSlides, mergeToolbarConfig, 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, 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 };
816
+ export { type ActionType, type ActivityType, type AppDispatch, BASIC_EDITOR_TOOLBAR_CONFIG, BottomToolbar, type BottomToolbarProps, Canvas, type CanvasProps, type ContextMenuConfig, DEFAULT_CONTEXT_MENU_CONFIG, DEFAULT_TOOLBAR_CONFIG, type ExportOptions, type FillInTheBlanks, type FlashcardElement, type ImageElement, type Line$1 as Line, type LongAnswer, type MediaType, type MultipleChoice, type PhotoFrameElement, PublishButton, type PublishButtonProps, type PublishProgress, type PublishResponse, type RootState, ScreenRecorder, type Shape, type ShapeType, type ShortAnswer, type Slide, SlideNavigation, type TextElement, type ToolType, Toolbar, type ToolbarActionsConfig, type ToolbarConfig, type ToolbarProps, type ToolbarToolsConfig, TopNavBar, type TopNavBarProps, type TrueFalse, VIEWER_TOOLBAR_CONFIG, 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, mergeToolbarConfig, 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 };