Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/visual-editing

Package Overview
Dependencies
Maintainers
44
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/visual-editing - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

7

CHANGELOG.md
# Changelog
## [1.0.1](https://github.com/sanity-io/visual-editing/compare/visual-editing-v1.0.0...visual-editing-v1.0.1) (2024-02-05)
### Bug Fixes
* rename `@sanity/overlays` to `@sanity/visual-editing` ([#834](https://github.com/sanity-io/visual-editing/issues/834)) ([1d28908](https://github.com/sanity-io/visual-editing/commit/1d289084dd2d631230141fbdc5043c709ecebdea))
## 1.0.0 (2024-02-05)

@@ -4,0 +11,0 @@

62

dist/index.d.ts

@@ -45,20 +45,7 @@ /**

*/
export declare function enableVisualEditing(options?: {
history?: HistoryAdapter
zIndex?: string | number
}): DisableVisualEditing
export declare function enableVisualEditing(
options?: VisualEditingOptions,
): DisableVisualEditing
/**
* Event handlers attached to each element
* @internal
*/
export declare interface _EventHandlers {
click: (event: MouseEvent) => void
mousedown: (event: MouseEvent) => void
mouseenter: (event: MouseEvent) => void
mouseleave: (event: MouseEvent) => void
mousemove: (event: MouseEvent) => void
}
/**
*

@@ -106,13 +93,2 @@ * @public

/**
* Element data stored in controller state
* @internal
*/
export declare interface _OverlayElement {
id: string
elements: _SanityNodeElements
handlers: _EventHandlers
sanity: SanityNode | SanityNodeLegacy
}
/**
* Callback function used for handling dispatched controller messages

@@ -219,11 +195,2 @@ * @public

/**
* Object returned by node traversal
* @internal
*/
export declare interface _ResolvedElement {
elements: _SanityNodeElements
sanity: SanityNode | SanityNodeLegacy
}
/**
* Data resolved from a Sanity node

@@ -246,11 +213,2 @@ * @public

/**
* Object returned by node traversal
* @internal
*/
export declare interface _SanityNodeElements {
element: HTMLElement
measureElement: HTMLElement
}
/**
* Data resolved from a (legacy) Sanity node

@@ -265,2 +223,16 @@ * @public

/**
* @public
*/
export declare interface VisualEditingOptions {
/**
* The history adapter is used for Sanity Presentation to navigate URLs in the preview frame.
*/
history?: HistoryAdapter
/**
* The CSS z-index on the root node that renders overlays, tweak it accordingly to what layout you have.
*/
zIndex?: string | number
}
export {}
{
"name": "@sanity/visual-editing",
"version": "1.0.0",
"version": "1.0.1",
"keywords": [

@@ -5,0 +5,0 @@ "sanity.io",

@@ -18,2 +18,39 @@ # @sanity/visual-editing

### Plain JS
```ts
import { enableVisualEditing } from '@sanity/vision-editing'
// Enables visual editing overlays
enableVisualEditing()
// Integrate with a router that uses the History API
enableVisualEditing({
history: {
subscribe: (navigate) => {
const handler = (event: PopStateEvent) => {
navigate({
type: 'push',
url: `${location.pathname}${location.search}`,
})
}
window.addEventListener('popstate', handler)
return () => window.removeEventListener('popstate', handler)
},
update: (update) => {
switch (update.type) {
case 'push':
return window.history.pushState(null, '', update.url)
case 'pop':
return window.history.back()
case 'replace':
return window.history.replaceState(null, '', update.url)
default:
throw new Error(`Unknown update type: ${update.type}`)
}
},
},
})
```
### In React.js

@@ -27,3 +64,3 @@

useEffect(() => {
const disable = enableVisualEditing({)
const disable = enableVisualEditing()
return () => disable()

@@ -62,4 +99,12 @@ }, [])

## Change the z-index of overlay elements
```ts
enableVisualEditing({
zIndex: 1000,
})
```
[gzip-badge]: https://img.shields.io/bundlephobia/minzip/@sanity/visual-editing?label=gzip%20size&style=flat-square
[size-badge]: https://img.shields.io/bundlephobia/min/@sanity/visual-editing?label=size&style=flat-square
[bundlephobia]: https://bundlephobia.com/package/@sanity/visual-editing
export { createOverlayController } from './controller'
export type * from './types'
export type {
ElementFocusedState,
ElementState,
HistoryAdapter,
HistoryAdapterNavigate,
HistoryUpdate,
Msg,
OverlayController,
OverlayEventHandler,
OverlayMsg,
OverlayMsgActivate,
OverlayMsgBlur,
OverlayMsgDeactivate,
OverlayMsgElement,
OverlayMsgElementActivate,
OverlayMsgElementClick,
OverlayMsgElementDeactivate,
OverlayMsgElementMouseEnter,
OverlayMsgElementMouseLeave,
OverlayMsgElementRegister,
OverlayMsgElementUnregister,
OverlayMsgElementUpdateRect,
OverlayOptions,
OverlayRect,
SanityNode,
SanityNodeLegacy,
} from './types'
export {
type DisableVisualEditing,
enableVisualEditing,
type VisualEditingOptions,
} from './ui/enableVisualEditing'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc