Class

CommentThread (comments/comments)

@ckeditor/ckeditor5-comments/src/comments/commentsrepository

class

Comment thread representation. Stores a list of Comments.

Filtering

Properties

  • channelId : String | undefined

    The channel where the comment thread was created.

  • comments : Collection

    readonly

    A collection of Comments belonging to this thread.

  • id : String

    The comment thread ID.

  • isAttached : Boolean

    Informs if the comment thread is attached to any target at the moment.

  • isReadOnly : Boolean

    observable

    Informs if the comment thread is in read-only state (true) or not (false).

  • isRemovable : Boolean

    observable

    Informs if the comment thread can be removed by the local user.

  • length : Number

    The number of comments in the comment thread.

  • weight : Number

    Sum of weights of all comments in this thread.

Methods

  • constructor( commentsRepository, data = { [data.channelId], data.id } )

    Parameters

    commentsRepository : CommentsRepository
    data : Object
    Properties
    [ data.channelId ] : String
    data.id : String
  • addComment( data = { data.commentId, data.content, data.authorId, [data.createdAt], [data.attributes], [data.isFromAdapter] } )

    Creates a new comment inside the comment thread.

    Note This method is event-driven. It means it fires an event then a normal priority listener catches it and executes an action. It makes it possible to add some actions before and after method will be executed.

    Parameters

    data : Object

    Data object.

    Properties
    data.commentId : String

    Comment id.

    data.content : String

    Comment content.

    data.authorId : String

    Author id.

    [ data.createdAt ] : Date

    Creation date. If not set, current date (new Date()) will be used.

    [ data.attributes ] : Object

    Custom comment attributes. See also setAttribute and removeAttribute.

    [ data.isFromAdapter ] : Boolean

    Defaults to false

    Fires

  • attachTo( target )

    Creates comment annotations and displays it attached to the given target.

    Parameters

    target : HTMLElement | Rect | function
  • getComment( commentId ) → Comment

    Returns comment of given id.

    Parameters

    commentId : String

    Returns

    Comment
  • remove( [ data ] = { [data.isFromAdapter] } )

    Removes comment thread.

    Note This method is event-driven. It means it fires an event then a normal priority listener catches it and executes an action. It makes it possible to add some actions before and after method will be executed.

    Parameters

    [ data ] : Object
    Properties
    [ data.isFromAdapter ] : Boolean

    Defaults to false

    Defaults to {}

    Fires

  • toJSON() → Object

    Returns

    Object

Events

  • change:isReadOnly( eventInfo, name, value, oldValue )

    Fired when the isReadOnly property changed value.

    Parameters

    eventInfo : EventInfo

    An object containing information about the fired event.

    name : String

    Name of the changed property (isReadOnly).

    value : Boolean

    New value of the isReadOnly property with given key or null, if operation should remove property.

    oldValue : Boolean

    Old value of the isReadOnly property with given key or null, if property was not set before.

  • change:isRemovable( eventInfo, name, value, oldValue )

    Fired when the isRemovable property changed value.

    Parameters

    eventInfo : EventInfo

    An object containing information about the fired event.

    name : String

    Name of the changed property (isRemovable).

    value : Boolean

    New value of the isRemovable property with given key or null, if operation should remove property.

    oldValue : Boolean

    Old value of the isRemovable property with given key or null, if property was not set before.