@turnix-co/konva-editor 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -36,7 +36,7 @@ type ScreenRecorderProps = {
36
36
  };
37
37
  declare const ScreenRecorder: React$1.FC<ScreenRecorderProps>;
38
38
 
39
- type Line = {
39
+ type Line$1 = {
40
40
  id?: string;
41
41
  tool: string;
42
42
  points: number[];
@@ -98,7 +98,7 @@ type ImageElement = {
98
98
  zIndex?: number;
99
99
  timestamp?: number;
100
100
  audioData?: string;
101
- annotations?: Line[];
101
+ annotations?: Line$1[];
102
102
  isDrawingMode?: boolean;
103
103
  };
104
104
  type VideoElement = {
@@ -157,7 +157,7 @@ type PhotoFrameElement = {
157
157
  timestamp?: number;
158
158
  audioData?: string;
159
159
  isCapturing: boolean;
160
- annotations?: Line[];
160
+ annotations?: Line$1[];
161
161
  isDrawingMode?: boolean;
162
162
  };
163
163
  type TextElement = {
@@ -308,7 +308,7 @@ type Slide = {
308
308
  name: string;
309
309
  thumbnail?: string;
310
310
  backgroundColor?: string;
311
- lines: Line[];
311
+ lines: Line$1[];
312
312
  shapes: Shape[];
313
313
  images: ImageElement[];
314
314
  videos: VideoElement[];
@@ -356,7 +356,7 @@ declare const loadSlides: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
356
356
  slides: Slide[];
357
357
  currentSlideId: string;
358
358
  }, "canvas/loadSlides">;
359
- declare const addLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line, "canvas/addLine">;
359
+ declare const addLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line$1, "canvas/addLine">;
360
360
  declare const removeLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<number, "canvas/removeLine">;
361
361
  declare const addImage: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<ImageElement, "canvas/addImage">;
362
362
  declare const updateImage: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Partial<ImageElement> & {
@@ -401,7 +401,7 @@ declare const duplicatePhotoFrame: _reduxjs_toolkit.ActionCreatorWithOptionalPay
401
401
  declare const toggleImageDrawingMode: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<string, "canvas/toggleImageDrawingMode">;
402
402
  declare const addImageAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
403
403
  imageId: string;
404
- line: Line;
404
+ line: Line$1;
405
405
  }, "canvas/addImageAnnotation">;
406
406
  declare const updateImageAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
407
407
  imageId: string;
@@ -411,7 +411,7 @@ declare const clearImageAnnotations: _reduxjs_toolkit.ActionCreatorWithOptionalP
411
411
  declare const togglePhotoFrameDrawingMode: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<string, "canvas/togglePhotoFrameDrawingMode">;
412
412
  declare const addPhotoFrameAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
413
413
  frameId: string;
414
- line: Line;
414
+ line: Line$1;
415
415
  }, "canvas/addPhotoFrameAnnotation">;
416
416
  declare const updatePhotoFrameAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
417
417
  frameId: string;
@@ -484,7 +484,7 @@ declare const setAudioData: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
484
484
  }, "canvas/setAudioData">;
485
485
  declare const updateLastLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<number[], "canvas/updateLastLine">;
486
486
  declare const finalizeDrawing: _reduxjs_toolkit.ActionCreatorWithoutPayload<"canvas/finalizeDrawing">;
487
- declare const setLines: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line[], "canvas/setLines">;
487
+ declare const setLines: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line$1[], "canvas/setLines">;
488
488
  declare const updateLinePosition: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
489
489
  id: string;
490
490
  x: number;
@@ -615,6 +615,60 @@ declare const exportSlideAsImage: (stage: Konva.Stage, options?: ExportOptions)
615
615
  declare const exportSlideAsBlob: (stage: Konva.Stage, options?: Omit<ExportOptions, "fileName">) => Promise<Blob>;
616
616
  declare const getSlideDataURL: (stage: Konva.Stage, options?: Omit<ExportOptions, "fileName">) => string;
617
617
 
618
+ /**
619
+ * Line simplification utilities using Douglas-Peucker algorithm
620
+ * Reduces the number of points in a line while preserving its shape
621
+ */
622
+ /**
623
+ * Simplify a flat points array using Douglas-Peucker algorithm
624
+ *
625
+ * @param flatPoints Array of points [x1, y1, x2, y2, ...]
626
+ * @param epsilon Tolerance for simplification (default: 1.5 pixels)
627
+ * @returns Simplified flat points array
628
+ */
629
+ declare const simplifyFlatPoints: (flatPoints: number[], epsilon?: number) => number[];
630
+ /**
631
+ * Line type matching the canvasSlice Line type
632
+ */
633
+ type Line = {
634
+ id?: string;
635
+ tool: string;
636
+ points: number[];
637
+ color: string;
638
+ strokeWidth: number;
639
+ isSketch?: boolean;
640
+ timestamp?: number;
641
+ x?: number;
642
+ y?: number;
643
+ scaleX?: number;
644
+ scaleY?: number;
645
+ rotation?: number;
646
+ };
647
+ /**
648
+ * Simplify a single line's points using Douglas-Peucker algorithm
649
+ *
650
+ * @param line The line object to simplify
651
+ * @param epsilon Tolerance for simplification
652
+ * @returns New line object with simplified points
653
+ */
654
+ declare const simplifyLine: (line: Line, epsilon?: number) => Line;
655
+ /**
656
+ * Simplify an array of lines
657
+ *
658
+ * @param lines Array of line objects
659
+ * @param epsilon Tolerance for simplification
660
+ * @returns Array of lines with simplified points
661
+ */
662
+ declare const simplifyLines: (lines: Line[], epsilon?: number) => Line[];
663
+ /**
664
+ * Calculate compression ratio for debugging/logging
665
+ */
666
+ declare const getCompressionStats: (original: number[], simplified: number[]) => {
667
+ originalPoints: number;
668
+ simplifiedPoints: number;
669
+ reduction: string;
670
+ };
671
+
618
672
  declare const useDispatch: () => redux_thunk.ThunkDispatch<{
619
673
  toolbar: ToolbarState;
620
674
  canvas: {
@@ -632,4 +686,4 @@ declare const useSelector: <T>(selector: (state: RootState) => T) => T;
632
686
 
633
687
  declare const useSlidesPersistence: () => void;
634
688
 
635
- export { type AppDispatch, Canvas, type CanvasProps, EditorRoot, type EditorRootProps, type ExportOptions, type FillInTheBlanks, type FlashcardElement, type ImageElement, type 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, 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, 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 };
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 };