Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ next-env.d.ts
.env*.local

# Ngrok
ngrok.yml
ngrok.yml

/.vscode/
9 changes: 8 additions & 1 deletion src/features/editor/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { EmbedBubbleInput } from '@extensions/Embed.ext/EmbedBubbleInput'
import extensions from '@extensions/extensions'
import { FileHandlerExt } from '@extensions/FileHandler.ext'
import { ImageExt } from '@extensions/Image.ext'
import { SettingsContext } from '@settings/providers/settings.provider'
import { EditorContent, useEditor } from '@tiptap/react'
import { useEffect } from 'react'
import { useContext, useEffect } from 'react'
import { useShallow } from 'zustand/shallow'

interface EditorProps {
Expand All @@ -18,6 +19,7 @@ interface EditorProps {
}

export const Editor = ({ token, content, backgroundColor }: EditorProps) => {
const settingsStoreApi = useContext(SettingsContext)
const { setEditor, destroyEditor, showEmbedInput, setShowEmbedInput } = useEditorStore(
useShallow((s) => ({
setEditor: s.setEditor,
Expand All @@ -36,6 +38,11 @@ export const Editor = ({ token, content, backgroundColor }: EditorProps) => {
onCreate({ editor }) {
editor.storage.token.token = token
},
onUpdate: ({ editor }) => {
settingsStoreApi?.getState().setSettings({
content: editor.getHTML(),
})
},
Comment on lines +41 to +45
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing this but sometimes the editor got jittery / too laggy... can you stress test this fix with a lot of content + media to confirm

})

useEffect(() => {
Expand Down
11 changes: 7 additions & 4 deletions src/features/editor/hooks/useAppControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ import { useShallow } from 'zustand/shallow'
import { areObjKeysEqual } from '@/utils/objects'

export const useAppControls = () => {
const editor = useEditorStore((s) => s.editor)

const updateSettingsMutation = useSettingsMutation()

const subheading = useSettingsStore((s) => s.subheading)
const bannerImageId = useSettingsStore((s) => s.bannerImageId)
const backgroundColor = useSettingsStore((s) => s.backgroundColor)
const setSettings = useSettingsStore((s) => s.setSettings)

const content = editor?.getHTML()
const settings: SettingsUpdateDto = { content, subheading, bannerImageId, backgroundColor }
const content = useSettingsStore((s) => s.content)
const settings: SettingsUpdateDto = {
content,
subheading,
bannerImageId,
backgroundColor,
}

const actions: SettingsUpdateDto['actions'] = useSettingsStore(
useShallow((s) => ({
Expand Down