Repository includes React plugin
Learn more about Filerobot
Filerobot Image Annotator
Usage:
Install the package
npm install filerobot-image-annotator
Import the plugin
import { ImageAnnotatorContext, CommentsList, Canvas, NewCommentArea } from "filerobot-image-annotator";
Create plugin's config
Minimal config (uses Scaleflex servers)
check defaultConfig's object docs
const imageAnnotatorConfig: ImageAnnotatorConfig = {
imageUrl: 'https://images2.alphacoders.com/439/thumb-1920-439779.jpg',
userConfig: {
userId: 139,
},
commentsConfig: {
commentsConnector: {
defaultConfig: {
fileUUID: "someuuid-a5656-aa-50f7-bcd2-de0741850000",
projectSlug: "wazaaarghd",
apiKey: "very_long_token"
}
}
}
};
<ImageAnnotatorContext config={imageAnnotatorConfig}>
<div>
<Canvas />
</div>
<div>
<span>Comments list will reside here!</span>
<CommentsList />
</div>
<div>
<p>Hello there, we are having your comment here down below, write down ur comment please in the next box</p>
<NewCommentArea />
</div>
</ImageAnnotatorContext>
Done !
Config types:
UserConfig ,
CommentsConfig ,
DatesConfig ,
TranslationsConfig
EventsHandlersConfig
DrawerViewConfig
interface ImageAnnotatorConfig {
imageUrl?: string,
userConfig: UserConfig,
commentsConfig: CommentsConfig,
datesConfig?: DatesConfig,
translationsConfig?: TranslationsConfig,
Loader?: (() => JSX.Element),
eventHandlersConfig?: EventsHandlersConfig,
drawerViewConfig?: DrawerViewConfig,
}
CommentsEventHandlersConfig
export interface EventsHandlersConfig {
comments?: CommentsEventHandlersConfig,
}
export interface CommentsEventHandlersConfig {
onSentClick?: (commentText: CommentText) => void;
onReplyClick?: () => void;
onEditClick?: () => void;
onLikeClick?: (comment: DrawerComment) => void;
onSubscribeClick?: (comment: DrawerComment) => void;
onCommentSelect?: (comment: DrawerComment) => void;
deleteComments?: (comments_uuids: [string | number] | 'all') => void
}
CanvasConfig
export interface DrawerViewConfig {
selectRenderNode?: () => HTMLElement,
classes?: string,
canvasOnly?: boolean,
canvasConfig?: CanvasConfig,
}
export interface CanvasConfig {
backgroundStyle?: CSSProperties;
}
Translations:
interface TranslationsConfig {
messageInput_sendButtonText?: string
messageInput_placeholder?: string
messageInput_back?: string
comment_replyButtonText?: string
comment_popupEditLabel?: string
comment_popupDeleteLabel?: string
comment_showReplies?: string
comment_hideReplies?: string
comments_commentsEmptyPlaceholderLabel?: string
comments_commentsEmptyPlaceholderHint?: string
comments_commentsFilteredEmptyPlaceholderLabel: string
comments_commentsFilteredEmptyPlaceholderHint: string
comments_commentHeaderResolveLabel?: string
comments_commentHeaderReopenLabel?: string
commentsHeader_commentsCounterText?: string
commentsHeader_commentsSortText?: string
commentsHeader_commentsSortAscendingText?: string
commentsHeader_commentsSortDescendingText?: string
commentsHeader_commentsFilterText?: string
commentsHeader_commentsFilterAllComments?: string
commentsHeader_commentsFilterResolved?: string
commentsHeader_commentsFilterUnResolved?: string
messageInput_editPlaceholder?: string
}
interface UserConfig {
userId: string | number,
}
CommentsSelectors
CommentsConnector
interface CommentsConfig {
commentsSelectors?: CommentsSelectors;
commentsConnector: CommentsConnector;
}
interface DatesConfig {
formatDate?: (date: string) => string
difference?: (date: string) => string
}
interface CommentText {
text: string;
shapes: BaseShape[];
parent?: string | number
}
interface CommentsSelectors {
selectComments: (data: any) => Object[];
selectCommentId: (data: any) => string | number;
selectCommentText: (data: any) => string;
selectCommentDate: (data: any) => string;
selectCommentUpdatedAt: (data: any) => string;
selectCommentOwnerUserName: (data: any) => string;
selectCommentOwnerName: (data: any) => string;
selectCommentUserPhotoUri: (data: any) => string;
selectCommentLikes: (data: any) => string[] | number[];
selectCommentSubscribes: (data: any) => string[] | number[];
}
CommentText
interface CommentsConnector {
fetchCommentsRequest?: () => Promise<Record<string, unknown>[]>
createCommentRequest?: (text: string) => Promise<any>
deleteComments?: (comments_uuids: [string | number] | 'all') => Promise<any>
editCommentTextRequest?: (commentId: string | number, text: CommentText) => Promise<any>
likeCommentRequest?: (commentId: string | number) => Promise<any>
dislikeCommentRequest?: (commentId: string | number) => Promise<any>
subscribeToCommentRequest?: (commentId: string | number) => Promise<any>
unsubscribeToCommentRequest?: (commentId: string | number) => Promise<any>
defaultConfig?: CommentsConnectorDefaultConfigType
}
interface CommentsConnectorDefaultConfig {
api?: string;
apiKey: string;
projectSlug: string;
fileUUID: string;
requestsErrorHandler?: (error: CommentRequestError) => void;
}