mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
feat: add comment button to mermaid diagram toolbar
Allow users to comment on mermaid diagrams via the selection toolbar, matching the existing comment-on-image pattern. https://claude.ai/code/session_01E7BvJCgSpXJZdQEqj9mHgs
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { CopyIcon, EditIcon, ExpandedIcon, TextWrapIcon } from "outline-icons";
|
||||
import {
|
||||
CommentIcon,
|
||||
CopyIcon,
|
||||
EditIcon,
|
||||
ExpandedIcon,
|
||||
TextWrapIcon,
|
||||
} from "outline-icons";
|
||||
import type { Node as ProseMirrorNode } from "prosemirror-model";
|
||||
import { NodeSelection } from "prosemirror-state";
|
||||
import type { EditorState } from "prosemirror-state";
|
||||
@@ -71,6 +77,13 @@ export default function codeMenuItems(
|
||||
shortcut: `${metaDisplay} Enter`,
|
||||
visible: isMermaid(node) && !isEditingMermaid && !readOnly,
|
||||
},
|
||||
{
|
||||
name: "commentOnMermaid",
|
||||
icon: <CommentIcon />,
|
||||
tooltip: t("Comment"),
|
||||
shortcut: `${metaDisplay}+⌥+M`,
|
||||
visible: isMermaid(node) && !isEditingMermaid && !readOnly,
|
||||
},
|
||||
{
|
||||
name: "separator",
|
||||
},
|
||||
|
||||
@@ -20,6 +20,7 @@ import { toast } from "sonner";
|
||||
import type { Primitive } from "utility-types";
|
||||
import type { UserPreferences } from "../../types";
|
||||
import { isBrowser, isMac } from "../../utils/browser";
|
||||
import { addComment } from "../commands/comment";
|
||||
import backspaceToParagraph from "../commands/backspaceToParagraph";
|
||||
import {
|
||||
newlineInCode,
|
||||
@@ -151,6 +152,8 @@ function buildCollapseState(
|
||||
type CodeFenceOptions = {
|
||||
/** Display preferences for the logged in user, if any. */
|
||||
userPreferences?: UserPreferences | null;
|
||||
/** The id of the current user, used for comment attribution. */
|
||||
userId?: string;
|
||||
};
|
||||
|
||||
export default class CodeFence extends Node<CodeFenceOptions> {
|
||||
@@ -178,6 +181,9 @@ export default class CodeFence extends Node<CodeFenceOptions> {
|
||||
default: false,
|
||||
validate: "boolean",
|
||||
},
|
||||
marks: {
|
||||
default: undefined,
|
||||
},
|
||||
},
|
||||
content: "text*",
|
||||
marks: "comment",
|
||||
@@ -333,6 +339,8 @@ export default class CodeFence extends Node<CodeFenceOptions> {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
commentOnMermaid: (): Command =>
|
||||
addComment({ userId: this.options.userId }),
|
||||
copyToClipboard: (): Command => (state, dispatch) => {
|
||||
const codeBlock = findParentNode(isCode)(state.selection);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user