@turnix-co/konva-editor 2.0.25 → 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/README.md +409 -265
- package/dist/index.d.ts +106 -41
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,110 @@
|
|
|
1
|
-
import Konva from 'konva';
|
|
2
|
-
export { default as Konva } from 'konva';
|
|
3
|
-
export { Stage as KonvaStage } from 'konva/lib/Stage';
|
|
4
1
|
import React$1 from 'react';
|
|
2
|
+
import Konva from 'konva';
|
|
5
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
4
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
7
5
|
import * as redux_thunk from 'redux-thunk';
|
|
8
6
|
import * as redux from 'redux';
|
|
9
7
|
export { Provider as ReduxProvider } from 'react-redux';
|
|
10
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Tool identifiers for the main toolbar
|
|
11
|
+
*/
|
|
12
|
+
type ToolType = 'select' | 'pen' | 'eraser' | 'text' | 'shapes' | 'activities' | 'media';
|
|
13
|
+
/**
|
|
14
|
+
* Shape identifiers available in shapes submenu
|
|
15
|
+
*/
|
|
16
|
+
type ShapeType = 'rectangle' | 'circle' | 'ellipse' | 'triangle' | 'polygon' | 'star' | 'ring' | 'wedge' | 'arrow' | 'line' | 'arc';
|
|
17
|
+
/**
|
|
18
|
+
* Activity identifiers available in activities submenu
|
|
19
|
+
*/
|
|
20
|
+
type ActivityType = 'flashcard' | 'multiple-choice' | 'true-false' | 'short-answer' | 'fill-in-the-blank';
|
|
21
|
+
/**
|
|
22
|
+
* Media identifiers available in media submenu
|
|
23
|
+
*/
|
|
24
|
+
type MediaType = 'photo-frame' | 'image' | 'video';
|
|
25
|
+
/**
|
|
26
|
+
* Action identifiers for the toolbar action buttons
|
|
27
|
+
*/
|
|
28
|
+
type ActionType = 'undo' | 'redo' | 'screen-record' | 'camera-record' | 'clear';
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for which tools to show in the toolbar
|
|
31
|
+
*/
|
|
32
|
+
interface ToolbarToolsConfig {
|
|
33
|
+
/** Show select/cursor tool */
|
|
34
|
+
select?: boolean;
|
|
35
|
+
/** Show pen drawing tool */
|
|
36
|
+
pen?: boolean;
|
|
37
|
+
/** Show eraser tool */
|
|
38
|
+
eraser?: boolean;
|
|
39
|
+
/** Show text tool */
|
|
40
|
+
text?: boolean;
|
|
41
|
+
/** Show shapes menu (or provide specific shapes) */
|
|
42
|
+
shapes?: boolean | ShapeType[];
|
|
43
|
+
/** Show activities menu (or provide specific activities) */
|
|
44
|
+
activities?: boolean | ActivityType[];
|
|
45
|
+
/** Show media menu (or provide specific media types) */
|
|
46
|
+
media?: boolean | MediaType[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration for which action buttons to show
|
|
50
|
+
*/
|
|
51
|
+
interface ToolbarActionsConfig {
|
|
52
|
+
/** Show undo button */
|
|
53
|
+
undo?: boolean;
|
|
54
|
+
/** Show redo button */
|
|
55
|
+
redo?: boolean;
|
|
56
|
+
/** Show screen recording button */
|
|
57
|
+
screenRecord?: boolean;
|
|
58
|
+
/** Show camera recording button */
|
|
59
|
+
cameraRecord?: boolean;
|
|
60
|
+
/** Show clear canvas button */
|
|
61
|
+
clear?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Complete toolbar configuration
|
|
65
|
+
*/
|
|
66
|
+
interface ToolbarConfig {
|
|
67
|
+
/** Configure which tools to show */
|
|
68
|
+
tools?: ToolbarToolsConfig;
|
|
69
|
+
/** Configure which action buttons to show */
|
|
70
|
+
actions?: ToolbarActionsConfig;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Default toolbar configuration - all tools and actions enabled
|
|
74
|
+
*/
|
|
75
|
+
declare const DEFAULT_TOOLBAR_CONFIG: Required<ToolbarConfig>;
|
|
76
|
+
/**
|
|
77
|
+
* Context menu configuration
|
|
78
|
+
* Simple boolean to enable/disable context menu on right-click of canvas elements
|
|
79
|
+
*/
|
|
80
|
+
interface ContextMenuConfig {
|
|
81
|
+
/** Enable/disable context menu entirely (default: true) */
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Default context menu configuration - enabled by default
|
|
86
|
+
*/
|
|
87
|
+
declare const DEFAULT_CONTEXT_MENU_CONFIG: ContextMenuConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Merge user's toolbar config with defaults
|
|
90
|
+
*/
|
|
91
|
+
declare function mergeToolbarConfig(userConfig?: ToolbarConfig): Required<ToolbarConfig>;
|
|
92
|
+
/**
|
|
93
|
+
* Preset: Viewer-only mode (no editing capabilities)
|
|
94
|
+
*/
|
|
95
|
+
declare const VIEWER_TOOLBAR_CONFIG: ToolbarConfig;
|
|
96
|
+
/**
|
|
97
|
+
* Preset: Basic editor (no activities)
|
|
98
|
+
*/
|
|
99
|
+
declare const BASIC_EDITOR_TOOLBAR_CONFIG: ToolbarConfig;
|
|
100
|
+
|
|
11
101
|
type CanvasProps = {
|
|
12
102
|
onStageReady?: (stageRef: React$1.RefObject<Konva.Stage | null>) => void;
|
|
13
103
|
onSelectionChange?: (selectedId: string | null) => void;
|
|
14
104
|
onTextEditingReady?: (startEditingFn: (textId: string) => void) => void;
|
|
15
105
|
onDirectDrawingCanvasReady?: (canvasRef: React$1.RefObject<HTMLCanvasElement | null>) => void;
|
|
106
|
+
/** Configuration for context menu permissions and visibility */
|
|
107
|
+
contextMenuConfig?: ContextMenuConfig;
|
|
16
108
|
};
|
|
17
109
|
declare const Canvas: React$1.FC<CanvasProps>;
|
|
18
110
|
|
|
@@ -23,18 +115,10 @@ type ToolbarProps = {
|
|
|
23
115
|
stageRef?: React.RefObject<Konva.Stage | null>;
|
|
24
116
|
onTextAdded?: (textId: string) => void;
|
|
25
117
|
showToggleButton?: boolean;
|
|
118
|
+
/** Configuration for which tools and actions to show */
|
|
119
|
+
config?: ToolbarConfig;
|
|
26
120
|
};
|
|
27
|
-
declare const Toolbar: ({ isOpen: isOpenProp, onClose, onScreenRecord, stageRef, onTextAdded, showToggleButton, }?: ToolbarProps) => react_jsx_runtime.JSX.Element;
|
|
28
|
-
|
|
29
|
-
declare const SlideNavigation: React$1.FC;
|
|
30
|
-
|
|
31
|
-
type ScreenRecorderProps = {
|
|
32
|
-
onClose: () => void;
|
|
33
|
-
stageRef?: React$1.RefObject<Konva.Stage | null>;
|
|
34
|
-
onRecordingComplete?: (videoBlob: Blob, thumbnailDataUrl: string) => void;
|
|
35
|
-
directDrawingCanvasRef?: React$1.RefObject<HTMLCanvasElement | null>;
|
|
36
|
-
};
|
|
37
|
-
declare const ScreenRecorder: React$1.FC<ScreenRecorderProps>;
|
|
121
|
+
declare const Toolbar: ({ isOpen: isOpenProp, onClose, onScreenRecord, stageRef, onTextAdded, showToggleButton, config, }?: ToolbarProps) => react_jsx_runtime.JSX.Element;
|
|
38
122
|
|
|
39
123
|
type Line$1 = {
|
|
40
124
|
id?: string;
|
|
@@ -546,22 +630,6 @@ interface PublishButtonProps {
|
|
|
546
630
|
}
|
|
547
631
|
declare const PublishButton: React$1.FC<PublishButtonProps>;
|
|
548
632
|
|
|
549
|
-
interface EditorRootProps {
|
|
550
|
-
children: React$1.ReactNode;
|
|
551
|
-
className?: string;
|
|
552
|
-
style?: React$1.CSSProperties;
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* EditorRoot wraps the konva editor components and scopes all Tailwind styles
|
|
556
|
-
* to prevent conflicts with host application styles.
|
|
557
|
-
*
|
|
558
|
-
* All konva-editor Tailwind utilities are scoped to the .konva-editor-root class
|
|
559
|
-
* via the `important` setting in tailwind.config.js
|
|
560
|
-
*
|
|
561
|
-
* Default styles are applied for full-screen layout. Override with the style prop if needed.
|
|
562
|
-
*/
|
|
563
|
-
declare function EditorRoot({ children, className, style }: EditorRootProps): react_jsx_runtime.JSX.Element;
|
|
564
|
-
|
|
565
633
|
type TopNavBarProps = {
|
|
566
634
|
/** Title displayed in the header */
|
|
567
635
|
title?: string;
|
|
@@ -609,18 +677,15 @@ type BottomToolbarProps = {
|
|
|
609
677
|
};
|
|
610
678
|
declare const BottomToolbar: React$1.FC<BottomToolbarProps>;
|
|
611
679
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
name: string;
|
|
616
|
-
timestamp: number;
|
|
617
|
-
};
|
|
618
|
-
type LayersPanelProps = {
|
|
619
|
-
selectedElementId?: string;
|
|
680
|
+
declare const SlideNavigation: React$1.FC;
|
|
681
|
+
|
|
682
|
+
type ScreenRecorderProps = {
|
|
620
683
|
onClose: () => void;
|
|
621
|
-
|
|
684
|
+
stageRef?: React$1.RefObject<Konva.Stage | null>;
|
|
685
|
+
onRecordingComplete?: (videoBlob: Blob, thumbnailDataUrl: string) => void;
|
|
686
|
+
directDrawingCanvasRef?: React$1.RefObject<HTMLCanvasElement | null>;
|
|
622
687
|
};
|
|
623
|
-
declare const
|
|
688
|
+
declare const ScreenRecorder: React$1.FC<ScreenRecorderProps>;
|
|
624
689
|
|
|
625
690
|
type ToolbarState = {
|
|
626
691
|
selectedTool: string;
|
|
@@ -748,4 +813,4 @@ declare const useSelector: <T>(selector: (state: RootState) => T) => T;
|
|
|
748
813
|
|
|
749
814
|
declare const useSlidesPersistence: () => void;
|
|
750
815
|
|
|
751
|
-
export { type AppDispatch, BottomToolbar, type BottomToolbarProps, Canvas, type CanvasProps,
|
|
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 };
|