@turnix-co/konva-editor 2.0.27 → 2.0.30

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
@@ -1,5 +1,7 @@
1
- import React$1 from 'react';
2
1
  import Konva from 'konva';
2
+ export { default as Konva } from 'konva';
3
+ export { Stage as KonvaStage } from 'konva/lib/Stage';
4
+ import React$1 from 'react';
3
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
6
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
5
7
  import * as redux_thunk from 'redux-thunk';
@@ -120,17 +122,7 @@ type ToolbarProps = {
120
122
  };
121
123
  declare const Toolbar: ({ isOpen: isOpenProp, onClose, onScreenRecord, stageRef, onTextAdded, showToggleButton, config, }?: ToolbarProps) => react_jsx_runtime.JSX.Element;
122
124
 
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 = {
125
+ type Line$1 = {
134
126
  id?: string;
135
127
  tool: string;
136
128
  points: number[];
@@ -192,7 +184,7 @@ type ImageElement = {
192
184
  zIndex?: number;
193
185
  timestamp?: number;
194
186
  audioData?: string;
195
- annotations?: Line[];
187
+ annotations?: Line$1[];
196
188
  isDrawingMode?: boolean;
197
189
  };
198
190
  type VideoElement = {
@@ -251,7 +243,7 @@ type PhotoFrameElement = {
251
243
  timestamp?: number;
252
244
  audioData?: string;
253
245
  isCapturing: boolean;
254
- annotations?: Line[];
246
+ annotations?: Line$1[];
255
247
  isDrawingMode?: boolean;
256
248
  };
257
249
  type TextElement = {
@@ -402,7 +394,7 @@ type Slide = {
402
394
  name: string;
403
395
  thumbnail?: string;
404
396
  backgroundColor?: string;
405
- lines: Line[];
397
+ lines: Line$1[];
406
398
  shapes: Shape[];
407
399
  images: ImageElement[];
408
400
  videos: VideoElement[];
@@ -450,7 +442,7 @@ declare const loadSlides: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
450
442
  slides: Slide[];
451
443
  currentSlideId: string;
452
444
  }, "canvas/loadSlides">;
453
- declare const addLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line, "canvas/addLine">;
445
+ declare const addLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line$1, "canvas/addLine">;
454
446
  declare const removeLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<number, "canvas/removeLine">;
455
447
  declare const addImage: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<ImageElement, "canvas/addImage">;
456
448
  declare const updateImage: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Partial<ImageElement> & {
@@ -495,7 +487,7 @@ declare const duplicatePhotoFrame: _reduxjs_toolkit.ActionCreatorWithOptionalPay
495
487
  declare const toggleImageDrawingMode: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<string, "canvas/toggleImageDrawingMode">;
496
488
  declare const addImageAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
497
489
  imageId: string;
498
- line: Line;
490
+ line: Line$1;
499
491
  }, "canvas/addImageAnnotation">;
500
492
  declare const updateImageAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
501
493
  imageId: string;
@@ -505,7 +497,7 @@ declare const clearImageAnnotations: _reduxjs_toolkit.ActionCreatorWithOptionalP
505
497
  declare const togglePhotoFrameDrawingMode: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<string, "canvas/togglePhotoFrameDrawingMode">;
506
498
  declare const addPhotoFrameAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
507
499
  frameId: string;
508
- line: Line;
500
+ line: Line$1;
509
501
  }, "canvas/addPhotoFrameAnnotation">;
510
502
  declare const updatePhotoFrameAnnotation: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
511
503
  frameId: string;
@@ -578,7 +570,7 @@ declare const setAudioData: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
578
570
  }, "canvas/setAudioData">;
579
571
  declare const updateLastLine: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<number[], "canvas/updateLastLine">;
580
572
  declare const finalizeDrawing: _reduxjs_toolkit.ActionCreatorWithoutPayload<"canvas/finalizeDrawing">;
581
- declare const setLines: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line[], "canvas/setLines">;
573
+ declare const setLines: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<Line$1[], "canvas/setLines">;
582
574
  declare const updateLinePosition: _reduxjs_toolkit.ActionCreatorWithOptionalPayload<{
583
575
  id: string;
584
576
  x: number;
@@ -640,6 +632,77 @@ interface PublishButtonProps {
640
632
  }
641
633
  declare const PublishButton: React$1.FC<PublishButtonProps>;
642
634
 
635
+ type TopNavBarProps = {
636
+ /** Title displayed in the header */
637
+ title?: string;
638
+ /** Auto-save status message */
639
+ autoSaveMessage?: string;
640
+ /** Callback when back button is clicked */
641
+ onBack?: () => void;
642
+ /** Callback when settings button is clicked */
643
+ onSettings?: () => void;
644
+ /** Callback when user/profile button is clicked */
645
+ onProfile?: () => void;
646
+ /** Function to publish slides (passed to PublishButton) */
647
+ onPublish?: PublishButtonProps['onPublish'];
648
+ /** Whether to show the publish button */
649
+ showPublishButton?: boolean;
650
+ /** Whether to show the settings button */
651
+ showSettingsButton?: boolean;
652
+ /** Whether to show the profile button */
653
+ showProfileButton?: boolean;
654
+ /** Whether to show the back button */
655
+ showBackButton?: boolean;
656
+ /** Custom class name for the container */
657
+ className?: string;
658
+ /** Custom content to render on the right side (replaces default buttons) */
659
+ rightContent?: React$1.ReactNode;
660
+ /** Custom content to render on the left side (replaces default content) */
661
+ leftContent?: React$1.ReactNode;
662
+ };
663
+ declare const TopNavBar: React$1.FC<TopNavBarProps>;
664
+
665
+ type BottomToolbarProps = {
666
+ /** Custom colors array to override defaults */
667
+ colors?: Array<{
668
+ name: string;
669
+ value: string;
670
+ }>;
671
+ /** Whether to show the size slider */
672
+ showSizeSlider?: boolean;
673
+ /** Whether to show the color picker */
674
+ showColorPicker?: boolean;
675
+ /** Whether to show the background color picker */
676
+ showBackgroundPicker?: boolean;
677
+ /** Custom class name for the container */
678
+ className?: string;
679
+ };
680
+ declare const BottomToolbar: React$1.FC<BottomToolbarProps>;
681
+
682
+ interface EditorRootProps {
683
+ children: React$1.ReactNode;
684
+ className?: string;
685
+ style?: React$1.CSSProperties;
686
+ }
687
+ /**
688
+ * EditorRoot wraps the konva editor components and scopes all Tailwind styles
689
+ * to prevent conflicts with host application styles.
690
+ *
691
+ * All konva-editor Tailwind utilities are scoped to the .konva-editor-root class
692
+ * via the `important` setting in tailwind.config.js
693
+ */
694
+ declare function EditorRoot({ children, className, style }: EditorRootProps): react_jsx_runtime.JSX.Element;
695
+
696
+ declare const SlideNavigation: React$1.FC;
697
+
698
+ type ScreenRecorderProps = {
699
+ onClose: () => void;
700
+ stageRef?: React$1.RefObject<Konva.Stage | null>;
701
+ onRecordingComplete?: (videoBlob: Blob, thumbnailDataUrl: string) => void;
702
+ directDrawingCanvasRef?: React$1.RefObject<HTMLCanvasElement | null>;
703
+ };
704
+ declare const ScreenRecorder: React$1.FC<ScreenRecorderProps>;
705
+
643
706
  type ToolbarState = {
644
707
  selectedTool: string;
645
708
  penColor: string;
@@ -695,6 +758,60 @@ declare const exportSlideAsImage: (stage: Konva.Stage, options?: ExportOptions)
695
758
  declare const exportSlideAsBlob: (stage: Konva.Stage, options?: Omit<ExportOptions, "fileName">) => Promise<Blob>;
696
759
  declare const getSlideDataURL: (stage: Konva.Stage, options?: Omit<ExportOptions, "fileName">) => string;
697
760
 
761
+ /**
762
+ * Line simplification utilities using Douglas-Peucker algorithm
763
+ * Reduces the number of points in a line while preserving its shape
764
+ */
765
+ /**
766
+ * Simplify a flat points array using Douglas-Peucker algorithm
767
+ *
768
+ * @param flatPoints Array of points [x1, y1, x2, y2, ...]
769
+ * @param epsilon Tolerance for simplification (default: 1.5 pixels)
770
+ * @returns Simplified flat points array
771
+ */
772
+ declare const simplifyFlatPoints: (flatPoints: number[], epsilon?: number) => number[];
773
+ /**
774
+ * Line type matching the canvasSlice Line type
775
+ */
776
+ type Line = {
777
+ id?: string;
778
+ tool: string;
779
+ points: number[];
780
+ color: string;
781
+ strokeWidth: number;
782
+ isSketch?: boolean;
783
+ timestamp?: number;
784
+ x?: number;
785
+ y?: number;
786
+ scaleX?: number;
787
+ scaleY?: number;
788
+ rotation?: number;
789
+ };
790
+ /**
791
+ * Simplify a single line's points using Douglas-Peucker algorithm
792
+ *
793
+ * @param line The line object to simplify
794
+ * @param epsilon Tolerance for simplification
795
+ * @returns New line object with simplified points
796
+ */
797
+ declare const simplifyLine: (line: Line, epsilon?: number) => Line;
798
+ /**
799
+ * Simplify an array of lines
800
+ *
801
+ * @param lines Array of line objects
802
+ * @param epsilon Tolerance for simplification
803
+ * @returns Array of lines with simplified points
804
+ */
805
+ declare const simplifyLines: (lines: Line[], epsilon?: number) => Line[];
806
+ /**
807
+ * Calculate compression ratio for debugging/logging
808
+ */
809
+ declare const getCompressionStats: (original: number[], simplified: number[]) => {
810
+ originalPoints: number;
811
+ simplifiedPoints: number;
812
+ reduction: string;
813
+ };
814
+
698
815
  declare const useDispatch: () => redux_thunk.ThunkDispatch<{
699
816
  toolbar: ToolbarState;
700
817
  canvas: {
@@ -712,4 +829,4 @@ declare const useSelector: <T>(selector: (state: RootState) => T) => T;
712
829
 
713
830
  declare const useSlidesPersistence: () => void;
714
831
 
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 };
832
+ 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, EditorRoot, type EditorRootProps, 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 };