Skip to content

Commit b8ad8a7

Browse files
committed
fix: lexical
1 parent 945a75e commit b8ad8a7

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

apps/app/components/lexical/editor.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { EditorState, LexicalEditor, $getRoot, $getSelection } from "lexical";
1+
import {
2+
EditorState,
3+
$getRoot,
4+
$getSelection,
5+
SerializedEditorState,
6+
LexicalEditor,
7+
} from "lexical";
28
import { LexicalComposer } from "@lexical/react/LexicalComposer";
39
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
410
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
@@ -21,7 +27,7 @@ import { getValidatedValue } from "./helpers/editor";
2127
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
2228

2329
export interface RichTextEditorProps {
24-
onChange: (state: string) => void;
30+
onChange: (state: SerializedEditorState) => void;
2531
id: string;
2632
value: string;
2733
placeholder?: string;
@@ -33,11 +39,17 @@ const RichTextEditor: React.FC<RichTextEditorProps> = ({
3339
value,
3440
placeholder = "Enter some text...",
3541
}) => {
36-
function handleChange(state: EditorState, editor: LexicalEditor) {
37-
state.read(() => {
38-
onChange(JSON.stringify(state.toJSON()));
42+
const handleChange = (editorState: EditorState) => {
43+
editorState.read(() => {
44+
let editorData = editorState.toJSON();
45+
if (onChange) onChange(editorData);
3946
});
40-
}
47+
};
48+
// function handleChange(state: EditorState, editor: LexicalEditor) {
49+
// state.read(() => {
50+
// onChange(state.toJSON());
51+
// });
52+
// }
4153

4254
return (
4355
<LexicalComposer

apps/app/components/lexical/helpers/editor.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ export const positionEditorElement = (editor: any, rect: any) => {
66
editor.style.left = "-1000px";
77
} else {
88
editor.style.opacity = "1";
9-
editor.style.top = `${
10-
rect.top + rect.height + window.pageYOffset + 10
11-
}px`;
9+
editor.style.top = `${rect.top + rect.height + window.pageYOffset + 10}px`;
1210
editor.style.left = `${
1311
rect.left + window.pageXOffset - editor.offsetWidth / 2 + rect.width / 2
1412
}px`;
@@ -22,9 +20,9 @@ export const getValidatedValue = (value: string) => {
2220

2321
if (value) {
2422
try {
25-
const json = JSON.parse(value);
26-
return JSON.stringify(json);
27-
} catch (error) {
23+
console.log(value);
24+
return value;
25+
} catch (e) {
2826
return defaultValue;
2927
}
3028
}

apps/app/components/project/issues/CreateUpdateIssueModal/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type Props = {
5151
const defaultValues: Partial<IIssue> = {
5252
project: "",
5353
name: "",
54-
description: "",
54+
// description: "",
5555
state: "",
5656
sprints: "",
5757
priority: "",
@@ -176,7 +176,6 @@ const CreateUpdateIssuesModal: React.FC<Props> = ({
176176
if (!activeWorkspace || !activeProject) return;
177177
const payload: Partial<IIssue> = {
178178
...formData,
179-
description: JSON.stringify(formData.description),
180179
target_date: formData.target_date ? renderDateFormat(formData.target_date ?? "") : null,
181180
};
182181
if (!data) {

apps/app/components/project/issues/ListView/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ const ListView: React.FC<Props> = ({
184184
<td className="px-3 py-4 font-medium text-gray-900 truncate text-xs max-w-[15rem]">
185185
{/* <LexicalViewer
186186
id={`descriptionViewer-${issue.id}`}
187-
value={JSON.parse(issue.description)}
187+
value={issue.description}
188188
/> */}
189-
{issue.description}
189+
{/* {issue.description} */}
190190
</td>
191191
) : (key as keyof Properties) === "priority" ? (
192192
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">

0 commit comments

Comments
 (0)