GhostManager / Ghostwriter

The SpecterOps project management and reporting engine
https://ghostwriter.wiki
BSD 3-Clause "New" or "Revised" License
1.32k stars 181 forks source link

TinyMCE Comments Plugin #473

Open domwhewell-sage opened 3 months ago

domwhewell-sage commented 3 months ago

Draft PR for a comments plugin mentioned in #425 Added a new tinymce plugin to the folder called ghostwriter-comments

The comment thread currently appears with the commenters username avatar and then their comment.

<div class="${selfclass}">
    <div class="comment-header">
        <h1>${tinymce.DOM.encode(hex2ascii(author))}</h1>
        <img class="comment-avatar" src="/users/${tinymce.DOM.encode(hex2ascii(author))}/avatar" alt="Avatar">
    </div>
    <p>${tinymce.DOM.encode(comment)}</p>
</div>

The comments dont currently transfer over to the docx but Im not sure they should, the reportwriter is currently just adding the paragraph element into the docx correctly without the comment so we might not want to change that

domwhewell-sage commented 3 months ago

I'm trying to think of a way to notify the author which findings / fields have comments on them sort of like the "Previous" / "Next" functionality in word

image

We could potentially send an ajax request to set the finding as "Needs Editing" once a reviewer has posted a comment on a finding but I think sending a list of urls to the user that take them directly to each comment would be more useful. We might be able to use the websockets notifications for the user but I don't know how long these stay available to the user

domwhewell-sage commented 2 months ago

Thanks @ColonelThirtyTwo I have made the requested changes. And added a border around each individual comment, moved the avatar to the top left of the comment.

I am still interested in working on this however I am still trying to think of a way to solve the notification problem. After your report has been QA'd (and comments have been left) it might be time consuming for the author to go back through each individual finding and check if all comments have been addressed in the report.

domwhewell-sage commented 1 month ago

Thinking about it I don't think the notifications should be part of this plugin as I did have it sending websocket messages once a comment had been added but if the user didn't submit the form the comment wouldn't save therefore notifications should probably be done server side once the form is submitted.

Something like this: If the updated form contains any rich text fields with 1 or more <span class="comment"> tags in the source send a notification.

Marking this as ready for review now.

domwhewell-sage commented 1 month ago

Hi @ColonelThirtyTwo I think we should support nested comments too! I have made a change to support editing your comments in a thread. But I am stuck on how to create the nested comments.... I will not have too much time available to work on this for the next few weeks.