MCP takes markdown input for document version content
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -18,11 +18,14 @@ package mcp_v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/prosemirror"
|
||||
"go.probo.inc/probo/pkg/server/api/authn"
|
||||
)
|
||||
|
||||
@@ -32,6 +35,20 @@ type Resolver struct {
|
||||
logger *log.Logger
|
||||
}
|
||||
|
||||
func markdownToProseMirrorJSON(markdown string) (string, error) {
|
||||
node, err := prosemirror.ParseMarkdown(markdown)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot parse markdown: %w", err)
|
||||
}
|
||||
|
||||
out, err := json.Marshal(node)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot marshal prosemirror node: %w", err)
|
||||
}
|
||||
|
||||
return string(out), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) MustAuthorize(ctx context.Context, entityID gid.GID, action iam.Action) {
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user