ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.44k stars 3.69k forks source link

Docs issue report from "features/collaboration/comments/comments-outside-editor.html" #16548

Open ryanj-openquire opened 3 months ago

ryanj-openquire commented 3 months ago

Origin URL

https://ckeditor.com/docs/ckeditor5/41.3.0/features/collaboration/comments/comments-outside-editor.html

Project version

41.3.0

Is the information outdated? How?

The code samples show devs how to reach into components to manually update views. This seems a bit hacky, and likely prone to breakage in the future. I discovered that by simply calling attachTo on the thread returned via addCommentThread worked great.

Is there something missing in the guide? What is it?

No response

Is there anything else you would like to add?

No response

User agent

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:126.0) Gecko/20100101 Firefox/126.0

scofalik commented 3 months ago

Hi @ryanj-openquire 

Could you please more preciesly specify which part of the documentation looks hacky, and how did you approach it?

ryanj-openquire commented 3 months ago

Sure - this block of code from the handleNewCommentThread function:

    // When an annotation is created or reopened we need to bound its focus manager with the field.
    // Thanks to that, the annotation will be focused whenever the field is focused as well.
    // However, this can be done only for one annotation, so we do it only if there are no open
    // annotations for given field.
    if ( !openThreads.length ) {
        const threadView = commentsRepository._threadToController.get( thread ).view;
        const annotation = annotations.collection.getByInnerView( threadView );

        annotation.focusableElements.add( field );
    }

I would prefer to not write code that is peering into internal properties in order to make this scenario perform well. If the above code is required by all integrations that use comments outside of the editor, then there should be supported API methods to implement the above.