Skip to content

Commit

Permalink
fix(deps): bump @sanity/visual-editing
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 21, 2024
1 parent 807fd93 commit f2b8b00
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 61 deletions.
2 changes: 2 additions & 0 deletions apps/mvp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vercel
.env*.local
2 changes: 1 addition & 1 deletion apps/mvp/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
7 changes: 3 additions & 4 deletions packages/next-sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@
"dependencies": {
"@portabletext/react": "^3.2.0",
"@sanity/client": "^6.24.1",
"@sanity/next-loader": "1.2.7",
"@sanity/preview-kit": "5.1.25",
"@sanity/next-loader": "1.2.8",
"@sanity/preview-kit": "5.1.26",
"@sanity/preview-url-secret": "2.0.5",
"@sanity/visual-editing": "2.11.0",
"@sanity/visual-editing": "2.11.2",
"groq": "^3.68.2",
"history": "^5.3.0"
},
Expand Down Expand Up @@ -188,7 +188,6 @@
"@sanity/ui": "^2.10.12",
"next": "^14.2 || ^15.0.0-0",
"react": "^18.3 || ^19.0.0-0",
"react-dom": "^18.3 || ^19.0.0-0",
"sanity": "^3.68.2",
"styled-components": "^6.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import {usePathname, useRouter, useSearchParams} from 'next/navigation.js'
import {revalidateRootLayout} from 'next-sanity/visual-editing/server-actions'
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
import {createPortal} from 'react-dom'

import {addPathPrefix, normalizePathTrailingSlash, removePathPrefix} from './utils'

Expand Down Expand Up @@ -131,34 +130,13 @@ export default function VisualEditing(props: VisualEditingProps): React.JSX.Elem
[refresh],
)

const [node, setNode] = useState<HTMLDivElement | null>(null)
useEffect(() => {
// eslint-disable-next-line no-warning-comments
// @TODO use 'sanity-visual-editing' instead of 'div'
// eslint-disable-next-line no-shadow
const node = document.createElement('div')
// eslint-disable-next-line no-warning-comments
// @TODO after the element is `sanity-visual-editing` instead of `div`, stop setting this ID
node.id = 'sanity-visual-editing'
document.documentElement.appendChild(node)
setNode(node)
return () => {
setNode(null)
if (document.documentElement.contains(node)) {
document.documentElement.removeChild(node)
}
}
}, [])

if (!node) return null

return createPortal(
return (
<VisualEditingComponent
components={components}
history={history}
portal
refresh={handleRefresh}
zIndex={zIndex}
/>,
node,
/>
)
}
72 changes: 41 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f2b8b00

Please sign in to comment.