Add the slash menu, bubble menu, mentions and inline comments
Editor: - "/" opens a filterable block menu (text, headings, lists, quote, code, divider, and image or file upload when the host can store files). - Selecting text shows a formatting toolbar (bold, italic, strike, code, link) and, for anyone who may comment, a Comment button. - "@" finds people in the page's workspace; the mention node is always in the schema so documents with mentions open in every client. - The popups are plain DOM in the design system's slash-menu style, so the framework-free mobile bridge keeps building and can use them. - Menu words come from the host; the web app passes English or Polish. Inline comments (basic): commenters cannot edit the document, so a comment's anchor is a pair of Yjs relative positions stored with the comment rather than a mark in the text. Highlights follow local edits by mapping and are re-resolved when comments change or remote edits arrive. Pages get a comments panel (side column, or a bottom sheet on narrow screens). Authors and space admins can delete comments. Server: comments collection and endpoints, and a people lookup any workspace member may use for mentions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dac6d6da63
commit
92cd81fd96
32 files changed
+1992
-123
No files matched your search
@@ -151,6 +151,7 @@ func (a *api) routes(mux *routeMux) {
|
||||
a.searchRoutes(mux)
|
||||
a.transferRoutes(mux)
|
||||
a.shareRoutes(mux)
|
||||
a.commentRoutes(mux)
|
||||
}
|
||||
|
||||
func (a *api) decode(w http.ResponseWriter, r *http.Request, v any) bool {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"docwell/server/internal/access"
|
||||
"docwell/server/internal/directory"
|
||||
)
|
||||
|
||||
// CommentService is the part of directory.Service for inline comments.
|
||||
type CommentService interface {
|
||||
ListComments(ctx context.Context, c access.Caller, pageID string) ([]directory.Comment, error)
|
||||
CreateComment(ctx context.Context, c access.Caller, pageID string, in directory.CreateCommentInput) (directory.Comment, error)
|
||||
DeleteComment(ctx context.Context, c access.Caller, id string) error
|
||||
}
|
||||
|
||||
func (a *api) commentRoutes(mux *routeMux) {
|
||||
mux.HandleFunc("GET /api/v1/pages/{id}/comments", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
|
||||
list, err := a.dir.ListComments(r.Context(), caller(r), r.PathValue("id"))
|
||||
a.respond(w, list, err)
|
||||
}))
|
||||
mux.HandleFunc("POST /api/v1/pages/{id}/comments", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
|
||||
var in directory.CreateCommentInput
|
||||
if !a.decode(w, r, &in) {
|
||||
return
|
||||
}
|
||||
cm, err := a.dir.CreateComment(r.Context(), caller(r), r.PathValue("id"), in)
|
||||
a.respondStatus(w, http.StatusCreated, cm, err)
|
||||
}))
|
||||
mux.HandleFunc("DELETE /api/v1/comments/{id}", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
|
||||
a.respondNoContent(w, a.dir.DeleteComment(r.Context(), caller(r), r.PathValue("id")))
|
||||
}))
|
||||
}
|
||||
@@ -31,6 +31,7 @@ type DirectoryService interface {
|
||||
ListMembers(ctx context.Context, c access.Caller, wsID string) ([]directory.Member, error)
|
||||
SetMember(ctx context.Context, c access.Caller, wsID, email, role string) (directory.Member, error)
|
||||
RemoveMember(ctx context.Context, c access.Caller, wsID, userID string) error
|
||||
ListPeople(ctx context.Context, c access.Caller, wsID, query string, limit int) ([]directory.MemberUser, error)
|
||||
|
||||
SpaceService
|
||||
InviteService
|
||||
@@ -40,6 +41,7 @@ type DirectoryService interface {
|
||||
SearchService
|
||||
TransferService
|
||||
ShareService
|
||||
CommentService
|
||||
}
|
||||
|
||||
func caller(r *http.Request) access.Caller {
|
||||
@@ -139,6 +141,11 @@ func (a *api) directoryRoutes(mux *routeMux) {
|
||||
m, err := a.dir.SetMember(r.Context(), caller(r), r.PathValue("id"), in.Email, in.Role)
|
||||
a.respond(w, m, err)
|
||||
}))
|
||||
mux.HandleFunc("GET /api/v1/workspaces/{id}/people", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
|
||||
limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))
|
||||
people, err := a.dir.ListPeople(r.Context(), caller(r), r.PathValue("id"), r.URL.Query().Get("q"), limit)
|
||||
a.respond(w, people, err)
|
||||
}))
|
||||
mux.HandleFunc("DELETE /api/v1/workspaces/{id}/members/{userId}", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
|
||||
a.respondNoContent(w, a.dir.RemoveMember(r.Context(), caller(r), r.PathValue("id"), r.PathValue("userId")))
|
||||
}))
|
||||
|
||||
Reference in new issue
Block a user