mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
fix: Comment gutter mark default enabled (#12977)
This commit is contained in:
1 parent
f800c399b3
commit
69fdebd573
2 files changed
+14
-2
No files matched your search
@@ -6,6 +6,7 @@ import Extension from "@shared/editor/lib/Extension";
|
||||
import { changedDescendants } from "@shared/editor/lib/changedDescendants";
|
||||
import { isRemoteTransaction } from "@shared/editor/lib/multiplayer";
|
||||
import { EditorStyleHelper } from "@shared/editor/styles/EditorStyleHelper";
|
||||
import { UserPreferenceDefaults } from "@shared/constants";
|
||||
import { UserPreference } from "@shared/types";
|
||||
import { CommentGutter as CommentGutterComponent } from "../components/CommentGutter";
|
||||
|
||||
@@ -25,7 +26,8 @@ export default class CommentGutter extends Extension {
|
||||
|
||||
get plugins() {
|
||||
const isEnabled = () =>
|
||||
!!this.editor.props.userPreferences?.[UserPreference.CommentsInGutter];
|
||||
this.editor.props.userPreferences?.[UserPreference.CommentsInGutter] ??
|
||||
UserPreferenceDefaults[UserPreference.CommentsInGutter];
|
||||
|
||||
const handleClickCommentMark = (commentId: string) =>
|
||||
this.editor.props.onClickCommentMark?.(commentId);
|
||||
|
||||
@@ -156,6 +156,16 @@ function DocumentEditor(props: Props, ref: React.ForwardedRef<SharedEditor>) {
|
||||
[comments, user?.id, props.id, setFocusedCommentId]
|
||||
);
|
||||
|
||||
// Focus a comment and open the sidebar when its mark or gutter marker is
|
||||
// clicked.
|
||||
const handleClickCommentMark = React.useCallback(
|
||||
(commentId: string) => {
|
||||
setFocusedCommentId(commentId);
|
||||
ui.set({ rightSidebar: "comments" });
|
||||
},
|
||||
[setFocusedCommentId, ui]
|
||||
);
|
||||
|
||||
// Soft delete the Comment model when associated mark is totally removed.
|
||||
const handleRemoveComment = React.useCallback(
|
||||
async (commentId: string) => {
|
||||
@@ -245,7 +255,7 @@ function DocumentEditor(props: Props, ref: React.ForwardedRef<SharedEditor>) {
|
||||
userId={user?.id}
|
||||
focusedCommentId={focusedComment?.id}
|
||||
onClickCommentMark={
|
||||
commentingEnabled && can.comment ? setFocusedCommentId : undefined
|
||||
commentingEnabled && can.comment ? handleClickCommentMark : undefined
|
||||
}
|
||||
onCreateCommentMark={
|
||||
commentingEnabled && can.comment ? handleDraftComment : undefined
|
||||
|
||||
Reference in new issue
Block a user