Skip to content

[Feature/Plugin] Specification for Commenting Feature #47

Description

@zeigerpuppy

Introduction

This is a proposed feature to permit annotation of documents with comments.

The primary aims of the commenting feature are to:

  1. allow selecting a cursor position or selection in document and attaching comment
  2. showing a side-panel with comment threads
  3. responding to comments
  4. marking comments resolved
  5. (optional) allowing comments to propose changes in text - amend/delete/highlight

Various approaches were considered and previous discussed in hedgedoc/hedgedoc#657. The main technical question is whether to include the commenting within the markdown source document or to store the comments in a database. This specification chooses the database storage option because it enables commenting threads without polluting the source document with too much inline syntax.

Plan

  • In the first instance, this feature will be developed as a plugin for RefMD v1
  • Once RefMD v2 API is stabilised, it can be integrated as a core feature

Implementation

For each document (defined by document id):

  • Corresponding THREAD entities can be created.
  • Each THREAD is anchored to the document by an HTML comment, e.g. <!--CTHREAD:yTs5gh39dyagJKG-->.
  • When a document is loaded, the database is queried for matching THREAD ids and the threads are populated in the commenting panel
  • Each THREAD can have multiple COMMENTS
  • Each COMMENT includes metadata about Creator and Datetime which is used to identify comment details
  • Users can mark a comment or thread with TAGS, including a "resolved" tag

The current plan is to implement just commenting of document parts, but the functionality could be extended with attributes to mark suggested edits to the selected text. For instance, a comment metadata could mark the text for deletion or amendment. This feature would require extension of the UI with a "proposed changes" mode.

UI considerations

A similar implementation as shown in the mockup in hedgedoc/hedgedoc#657 (comment) would be a reasonable start.

Image

The main proposed differences from that mockup are:

  1. replace "delete thread" with "resolve thread" as it would be good to tag these threads resolved and filter them
  2. include tagging functionality for threads and comments
  3. include a filter and search comments bar at the top of the comment pane - search text of comments
    • filter by author or tag
    • show/hide resolved threads
  4. (Optional) include a toggle for "proposed changes" mode in which proposed editing changes are saved and shown on the document

Specification

erDiagram
    %% Main entity for the comment thread
    THREAD {
        UUID TID PK "Unique Thread ID"
        UUID DOC_ID FK "RefMD document ID"
        string Commit_ID FK "Last commit of doc"
        string Anchor_start "Start anchor (line, pos)"
        string Anchor_end "End anchor (line, pos)"
        boolean Anchored "Is anchor still present?"
        datetime Created
        datetime Updated
        UUID Creator FK
        boolean Resolved
        datetime T_resolved "Time resolved"
        UUID W_resolved FK "Who resolved?"
    }

    %% Entity for tags
    TAG {
        string name PK
        string color
        string description
    }

    %% Entity for individual comments within a thread
    COMMENT {
        UUID CID PK
        UUID Creator FK
        datetime Datetime
        boolean Resolved
        datetime T_resolved
        UUID W_resolved FK
        string Content
    }

    %% Relationships
    THREAD ||--|{ COMMENT : "contains"
    THREAD ||--|{ TAG : "categorized by"
    COMMENT ||--|{ TAG : "tagged with"
Loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions