Skip to content

Commit

Permalink
feat: support non-loader based visual editing
Browse files Browse the repository at this point in the history
  • Loading branch information
rdunk committed Mar 5, 2024
1 parent 6f589a8 commit dbd3f88
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare module 'nuxt/schema' {
enable: string
disable: string
}
mode: 'global' | 'component'
mode: 'loaders' | 'basic' | 'manual'
studioUrl: string
previewModeId: string
token: string
Expand Down Expand Up @@ -48,7 +48,7 @@ declare module 'nuxt/schema' {
enable: string
disable: string
}
mode: 'global' | 'component'
mode: 'loaders' | 'basic' | 'manual'
studioUrl: string
}
| nullish
Expand Down
9 changes: 4 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export interface SanityModuleVisualEditingOptions {
}
/**
* Enable visual editing at app level or per component
* @default 'global'
* @default 'loaders'
*/
mode?: 'global' | 'component'
mode?: 'loaders' | 'basic' | 'manual'
/**
* Read token for server side queries
* @required
Expand Down Expand Up @@ -162,7 +162,7 @@ export default defineNuxtModule<SanityModuleOptions>({
disable: '/preview/disable',
})
: false) as { enable: string; disable: string } | false,
mode: options.visualEditing.mode || 'global',
mode: options.visualEditing.mode || 'loaders',
studioUrl: options.visualEditing.studioUrl || '',
}

Expand Down Expand Up @@ -289,8 +289,7 @@ export default defineNuxtModule<SanityModuleOptions>({
})

if (
options.visualEditing.mode === undefined ||
options.visualEditing.mode === 'global'
options.visualEditing.mode !== 'manual'
) {
addPlugin({
mode: 'client',
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/visual-editing/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface SanityVisualEditingConfiguration {
enable?: string
disable?: string
}
mode: 'global' | 'component'
mode: 'loaders' | 'basic' | 'manual'
token?: string
studioUrl: string
previewModeId?: string
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/visual-editing/plugins/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// @ts-ignore
import { defineNuxtPlugin, useSanityVisualEditing } from '#imports'

export default defineNuxtPlugin(() => {
export default defineNuxtPlugin((nuxtApp) => {
useSanityVisualEditing()
useSanityLiveMode()
if(nuxtApp.$config.public.sanity.visualEditing?.mode !== 'basic') {
useSanityLiveMode()

Check failure on line 7 in src/runtime/visual-editing/plugins/client.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Cannot find name 'useSanityLiveMode'.
}
})

0 comments on commit dbd3f88

Please sign in to comment.