mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: (wip) fix editor when creating new note
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -335,6 +335,11 @@ function EditorView({
|
||||
}, [editor]);
|
||||
|
||||
const getContent = useCallback(() => {
|
||||
console.log(
|
||||
"rerender session.content.data",
|
||||
session.id,
|
||||
session.content?.data
|
||||
);
|
||||
return session.content?.data;
|
||||
}, [session.content?.data]);
|
||||
|
||||
@@ -378,6 +383,10 @@ function EditorView({
|
||||
|
||||
const currentSessionId = session.id;
|
||||
const data = content();
|
||||
console.log("session.content.data before", {
|
||||
content: data,
|
||||
session: session.content?.data
|
||||
});
|
||||
for (const session of sessions) {
|
||||
if (
|
||||
session?.type !== "default" &&
|
||||
@@ -387,7 +396,10 @@ function EditorView({
|
||||
continue;
|
||||
if (!session.content) session.content = { type: "tiptap", data };
|
||||
else session.content.data = data;
|
||||
|
||||
console.log("session.content.data after", {
|
||||
content: data,
|
||||
session: session.content?.data
|
||||
});
|
||||
// update content in other tabs
|
||||
if (session.id !== currentSessionId) {
|
||||
const editor = useEditorManager.getState().getEditor(session.id);
|
||||
|
||||
@@ -227,6 +227,7 @@ function TipTap(props: TipTapProps) {
|
||||
const oldNonce = useRef<number>();
|
||||
|
||||
const tiptapOptions = useMemo<Partial<TiptapOptions>>(() => {
|
||||
console.log("rerender tiptap: content", content, content?.());
|
||||
return {
|
||||
editorProps: {
|
||||
handleKeyDown(_, event) {
|
||||
|
||||
@@ -836,6 +836,12 @@ class EditorStore extends BaseStore<EditorStore> {
|
||||
options
|
||||
);
|
||||
} else {
|
||||
const currentSession = getSession(sessionId, ["default", "new"]);
|
||||
console.log("session.content.data in openSession", {
|
||||
rawContent: options.rawContent,
|
||||
contentDb: content,
|
||||
sessionContent: currentSession?.content?.data
|
||||
});
|
||||
this.addSession(
|
||||
{
|
||||
type: "default",
|
||||
@@ -849,7 +855,8 @@ class EditorStore extends BaseStore<EditorStore> {
|
||||
content:
|
||||
options.rawContent && content
|
||||
? { ...content, data: options.rawContent }
|
||||
: content,
|
||||
: // : content,
|
||||
currentSession?.content || content,
|
||||
activeBlockId: options.activeBlockId,
|
||||
activeSearchResultId: options.activeSearchResultId,
|
||||
tabId
|
||||
|
||||
Reference in New Issue
Block a user