mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
@@ -119,6 +119,8 @@ export type Props = {
|
||||
onCreateCommentMark?: (commentId: string, userId: string) => void;
|
||||
/** Callback when a comment mark is removed */
|
||||
onDeleteCommentMark?: (commentId: string) => void;
|
||||
/** Callback when comments sidebar should be opened */
|
||||
onOpenCommentsSidebar?: () => void;
|
||||
/** Callback when a file upload begins */
|
||||
onFileUploadStart?: () => void;
|
||||
/** Callback when a file upload ends */
|
||||
|
||||
@@ -248,6 +248,9 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
||||
onDeleteCommentMark={
|
||||
commentingEnabled && can.comment ? handleRemoveComment : undefined
|
||||
}
|
||||
onOpenCommentsSidebar={
|
||||
commentingEnabled ? ui.toggleComments : undefined
|
||||
}
|
||||
onInit={handleInit}
|
||||
onDestroy={handleDestroy}
|
||||
onChange={updateDocState}
|
||||
|
||||
@@ -41,6 +41,9 @@ const addCommentTextSelection =
|
||||
if (!(state.selection instanceof TextSelection)) {
|
||||
return false;
|
||||
}
|
||||
if (state.selection.empty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
isMarkActive(
|
||||
|
||||
@@ -70,30 +70,37 @@ export default class Comment extends Mark {
|
||||
}
|
||||
|
||||
keys({ type }: { type: MarkType }): Record<string, Command> {
|
||||
return this.options.onCreateCommentMark
|
||||
? {
|
||||
"Mod-Alt-m": (state, dispatch) => {
|
||||
if (
|
||||
isMarkActive(state.schema.marks.comment, {
|
||||
resolved: false,
|
||||
})(state)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
chainTransactions(
|
||||
toggleMark(type, {
|
||||
id: uuidv4(),
|
||||
userId: this.options.userId,
|
||||
draft: true,
|
||||
}),
|
||||
collapseSelection()
|
||||
)(state, dispatch);
|
||||
|
||||
return true;
|
||||
},
|
||||
return {
|
||||
"Mod-Alt-m": (state, dispatch) => {
|
||||
if (state.selection.empty && this.options.onOpenCommentsSidebar) {
|
||||
this.options.onOpenCommentsSidebar();
|
||||
return true;
|
||||
}
|
||||
: {};
|
||||
|
||||
if (!this.options.onCreateCommentMark) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
isMarkActive(state.schema.marks.comment, {
|
||||
resolved: false,
|
||||
})(state)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
chainTransactions(
|
||||
toggleMark(type, {
|
||||
id: uuidv4(),
|
||||
userId: this.options.userId,
|
||||
draft: true,
|
||||
}),
|
||||
collapseSelection()
|
||||
)(state, dispatch);
|
||||
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
commands() {
|
||||
|
||||
Reference in New Issue
Block a user