fix: mentions enter error (#2646)

* fix: fixed readonly lite text editor not rendering highlights

* fix: removed enter extension in lite text editor
This commit is contained in:
Henit Chobisa 2023-11-04 01:57:57 +05:30 committed by GitHub
parent 52395d0563
commit f0335751b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 5 deletions

View File

@ -27,8 +27,6 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
const selectItem = (index: number) => { const selectItem = (index: number) => {
const item = props.items[index]; const item = props.items[index];
console.log(props.command);
if (item) { if (item) {
props.command({ props.command({
id: item.id, id: item.id,
@ -71,7 +69,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
if (event.key === "Enter") { if (event.key === "Enter") {
enterHandler(); enterHandler();
return false; return true;
} }
return false; return false;
@ -79,7 +77,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
})); }));
return props.items && props.items.length !== 0 ? ( return props.items && props.items.length !== 0 ? (
<div className="absolute max-h-40 bg-custom-background-100 rounded-md shadow-custom-shadow-sm text-custom-text-300 text-sm overflow-y-auto w-48 p-1 space-y-0.5"> <div className="mentions absolute max-h-40 bg-custom-background-100 rounded-md shadow-custom-shadow-sm text-custom-text-300 text-sm overflow-y-auto w-48 p-1 space-y-0.5">
{props.items.length ? ( {props.items.length ? (
props.items.map((item, index) => ( props.items.map((item, index) => (
<div <div

View File

@ -1,5 +1,5 @@
import { EnterKeyExtension } from "./enter-key-extension"; import { EnterKeyExtension } from "./enter-key-extension";
export const LiteTextEditorExtensions = (onEnterKeyPress?: () => void) => [ export const LiteTextEditorExtensions = (onEnterKeyPress?: () => void) => [
EnterKeyExtension(onEnterKeyPress), // EnterKeyExtension(onEnterKeyPress),
]; ];

View File

@ -8,6 +8,7 @@ interface ICoreReadOnlyEditor {
noBorder?: boolean; noBorder?: boolean;
borderOnFocus?: boolean; borderOnFocus?: boolean;
customClassName?: string; customClassName?: string;
mentionHighlights: string[]
} }
interface EditorCoreProps extends ICoreReadOnlyEditor { interface EditorCoreProps extends ICoreReadOnlyEditor {
@ -26,10 +27,12 @@ const LiteReadOnlyEditor = ({
customClassName, customClassName,
value, value,
forwardedRef, forwardedRef,
mentionHighlights
}: EditorCoreProps) => { }: EditorCoreProps) => {
const editor = useReadOnlyEditor({ const editor = useReadOnlyEditor({
value, value,
forwardedRef, forwardedRef,
mentionHighlights
}); });
const editorClassNames = getEditorClassNames({ noBorder, borderOnFocus, customClassName }); const editorClassNames = getEditorClassNames({ noBorder, borderOnFocus, customClassName });

View File

@ -147,6 +147,7 @@ export const CommentCard: React.FC<Props> = ({
ref={showEditorRef} ref={showEditorRef}
value={comment.comment_html} value={comment.comment_html}
customClassName="text-xs border border-custom-border-200 bg-custom-background-100" customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
mentionHighlights={editorSuggestions.mentionHighlights}
/> />
<CommentReaction projectId={comment.project} commentId={comment.id} /> <CommentReaction projectId={comment.project} commentId={comment.id} />
</div> </div>

View File

@ -158,6 +158,7 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
ref={showEditorRef} ref={showEditorRef}
value={comment.comment_html} value={comment.comment_html}
customClassName="text-xs border border-custom-border-200 bg-custom-background-100" customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
mentionHighlights={editorSuggestions.mentionHighlights}
/> />
<div className="mt-1"> <div className="mt-1">