Socket
Socket
Sign inDemoInstall

@sanity/overlays

Package Overview
Dependencies
Maintainers
44
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/overlays - npm Package Compare versions

Comparing version 1.0.6 to 2.1.2

dist/_chunks/index-JtjVptJR.js

304

CHANGELOG.md

@@ -8,2 +8,306 @@ <!-- markdownlint-disable --><!-- textlint-disable -->

### Dependencies
* The following workspace dependencies were updated
* devDependencies
* @sanity/channels bumped to 0.1.0
* @sanity/visual-editing-helpers bumped to 0.1.0
### Dependencies
* The following workspace dependencies were updated
* devDependencies
* @sanity/visual-editing-helpers bumped from 0.1.0 to 0.1.1
## [2.1.0](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.4...overlays-v2.1.0) (2023-12-05)
### Features
* add new `same-origin` option ([#471](https://github.com/sanity-io/visual-editing/issues/471)) ([09621ad](https://github.com/sanity-io/visual-editing/commit/09621ad85897d4c600cbf7a011f8ddcfed75841e))
### Bug Fixes
* **types:** add missing exports ([fd52637](https://github.com/sanity-io/visual-editing/commit/fd52637f1ca932965260a00132f31148533ce913))
## [2.0.4](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.3...overlays-v2.0.4) (2023-11-29)
### Bug Fixes
* **deps:** update dependency @sanity/client to ^6.9.0 ([#434](https://github.com/sanity-io/visual-editing/issues/434)) ([c7c8ec5](https://github.com/sanity-io/visual-editing/commit/c7c8ec59e6503060eb60800bac4a494e39c1595c))
* **deps:** update dependency @sanity/client to ^6.9.1 ([#437](https://github.com/sanity-io/visual-editing/issues/437)) ([6974b0d](https://github.com/sanity-io/visual-editing/commit/6974b0d6fabd9911af40f6a1de645473b47df19d))
## [2.0.3](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.2...overlays-v2.0.3) (2023-11-27)
### Bug Fixes
* **overlays:** only render overlays in iframe if channel is connected ([#411](https://github.com/sanity-io/visual-editing/issues/411)) ([1aa40fc](https://github.com/sanity-io/visual-editing/commit/1aa40fc412d575cffd84a2427072ddade849a3a1))
## [2.0.2](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.1...overlays-v2.0.2) (2023-11-21)
### Bug Fixes
* **overlays:** use getComputedStyle over computedStyleMap ([#412](https://github.com/sanity-io/visual-editing/issues/412)) ([63398e4](https://github.com/sanity-io/visual-editing/commit/63398e4fa1d4a1e8830964200f15b88e8c0d387a))
## [2.0.1](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.0...overlays-v2.0.1) (2023-11-16)
### Bug Fixes
* **deps:** update dependency @sanity/client to ^6.8.6 ([#374](https://github.com/sanity-io/visual-editing/issues/374)) ([f62967a](https://github.com/sanity-io/visual-editing/commit/f62967a2068844b358357c7c2254cd1d9228ba6d))
## [2.0.0](https://github.com/sanity-io/visual-editing/compare/overlays-v2.3.4-pink-lizard...overlays-v2.0.0) (2023-11-15)
### Features
* production ready release ([#246](https://github.com/sanity-io/visual-editing/issues/246)) ([993c3cc](https://github.com/sanity-io/visual-editing/commit/993c3cc621921971087053950a1dc88fd9e34762))
## [2.3.4-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.3.3-pink-lizard...overlays-v2.3.4-pink-lizard) (2023-11-15)
### Bug Fixes
* **overlays:** add `mode=presentation` to intent links ([a838cd8](https://github.com/sanity-io/visual-editing/commit/a838cd8b392f8f74d18463709d7f24a3aac28ed6))
## [2.3.3-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.3.2-pink-lizard...overlays-v2.3.3-pink-lizard) (2023-11-13)
### Bug Fixes
* click-to-edit links in overlays pass in `preview` params of the current page ([d90ec9e](https://github.com/sanity-io/visual-editing/commit/d90ec9efe79d11f7f5c880c0439090d25dfc42d7))
* **deps:** Update dependency @sanity/client to ^6.8.4 ([5dbbe06](https://github.com/sanity-io/visual-editing/commit/5dbbe062ac1dd71a251e70d15caa1c5d53a505f6))
* **deps:** Update dependency @sanity/client to ^6.8.5 ([#361](https://github.com/sanity-io/visual-editing/issues/361)) ([e8e61c1](https://github.com/sanity-io/visual-editing/commit/e8e61c1a377b2737db60a1c3e42160794b26ad9b))
* **deps:** Update dependency @sanity/ui to ^1.9.3 ([#355](https://github.com/sanity-io/visual-editing/issues/355)) ([e10f6a7](https://github.com/sanity-io/visual-editing/commit/e10f6a79243b040aaba73c94146348f509164064))
* make `allowStudioOrigin` required ([700e140](https://github.com/sanity-io/visual-editing/commit/700e14025d327514152528138501353961034999))
* use `createEditUrl ` from `@sanity/client` ([e83bb2b](https://github.com/sanity-io/visual-editing/commit/e83bb2bf28794477300d914e053d77b6ad1c07e4))
## [2.3.2-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.3.1-pink-lizard...overlays-v2.3.2-pink-lizard) (2023-11-11)
### Bug Fixes
* **deps:** Update dependency @sanity/ui to ^1.9.2 ([#335](https://github.com/sanity-io/visual-editing/issues/335)) ([5b17c77](https://github.com/sanity-io/visual-editing/commit/5b17c7785f748eea4d0dae57e0c906e8bc3f3918))
## [2.3.1-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.3.0-pink-lizard...overlays-v2.3.1-pink-lizard) (2023-11-10)
### Bug Fixes
* **presentation:** prevent iframe from taking focus ([fbd02fd](https://github.com/sanity-io/visual-editing/commit/fbd02fd3b83774546c017a84cf8c444eff5dfe4f))
* **presentation:** prevent scrolling when array items close ([da2ad22](https://github.com/sanity-io/visual-editing/commit/da2ad22c7e825cebdff0dbfa374b65ca3a50e04c))
* remove initial url sender ([badda86](https://github.com/sanity-io/visual-editing/commit/badda8677af485467f469ef39f710566ba2908b4))
* send initial URL on load ([3caf2e3](https://github.com/sanity-io/visual-editing/commit/3caf2e35511e4bfd7275131f2301b1f32742e70b))
* **types:** add `HistoryAdapterNavigate` exported type ([7e8340f](https://github.com/sanity-io/visual-editing/commit/7e8340f0b5313885b4205bad60f3b2db62f79309))
## [2.3.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.2.1-pink-lizard...overlays-v2.3.0-pink-lizard) (2023-11-09)
### Features
* **overlays:** toggle overlay using mod key ([#228](https://github.com/sanity-io/visual-editing/issues/228)) ([60484e1](https://github.com/sanity-io/visual-editing/commit/60484e1458fdc9f85071cdbca2afc0978fae8041))
### Bug Fixes
* **presentation:** complete keyboard implementation ([a931b1b](https://github.com/sanity-io/visual-editing/commit/a931b1b68cf85a17dd1ab8010445313c4d75539a))
## [2.2.1-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.2.0-pink-lizard...overlays-v2.2.1-pink-lizard) (2023-11-08)
### Bug Fixes
* use `studioPath` utils from `@sanity/client/csm` ([a804364](https://github.com/sanity-io/visual-editing/commit/a80436410083ae88f6dc46a259ae3a08a7f4b59f))
## [2.2.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.1.2-pink-lizard...overlays-v2.2.0-pink-lizard) (2023-11-08)
### ⚠ BREAKING CHANGES
* lazy load live mode ([#281](https://github.com/sanity-io/visual-editing/issues/281))
* renamed `studioUrl` to `allowStudioOrigin`to clarify it's CORS related
### Bug Fixes
* lazy load live mode ([#281](https://github.com/sanity-io/visual-editing/issues/281)) ([e52991c](https://github.com/sanity-io/visual-editing/commit/e52991cc974df76647c4ede51de16527c14e6c10))
* renamed `studioUrl` to `allowStudioOrigin`to clarify it's CORS related ([589a7c2](https://github.com/sanity-io/visual-editing/commit/589a7c29ef61bb53f249847b4d5b9ae78ad252f2))
## [2.1.2-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.1.1-pink-lizard...overlays-v2.1.2-pink-lizard) (2023-11-07)
### Bug Fixes
* **deps:** Update dependency @sanity/ui to ^1.9.0 ([#274](https://github.com/sanity-io/visual-editing/issues/274)) ([4b971e3](https://github.com/sanity-io/visual-editing/commit/4b971e38c480322b4041206b5fd6378b01797ca4))
## [2.1.1-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.1.0-pink-lizard...overlays-v2.1.1-pink-lizard) (2023-11-04)
### Bug Fixes
* scroll into view if needed ([dfbbdbb](https://github.com/sanity-io/visual-editing/commit/dfbbdbb38ea9220cc820441c5e8f7296c44922fb))
## [2.1.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.2-pink-lizard...overlays-v2.1.0-pink-lizard) (2023-11-04)
### Features
* use the new `@sanity/client/stega` features ([#252](https://github.com/sanity-io/visual-editing/issues/252)) ([fa08bb2](https://github.com/sanity-io/visual-editing/commit/fa08bb24e6413bfa49adb79df256217e06ed0844))
### Bug Fixes
* handle stega nodes in a way that supports focus ([#254](https://github.com/sanity-io/visual-editing/issues/254)) ([dce801f](https://github.com/sanity-io/visual-editing/commit/dce801f3b76e6e2bb0597345b5deacc2038e6fec))
## [2.0.2-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.1-pink-lizard...overlays-v2.0.2-pink-lizard) (2023-11-03)
### Bug Fixes
* **overlays:** flash overlays when mounting ([6a9a86d](https://github.com/sanity-io/visual-editing/commit/6a9a86d9eca784dff1ff55686b9b91ca9203f6a9))
## [2.0.1-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v2.0.0-pink-lizard...overlays-v2.0.1-pink-lizard) (2023-11-02)
### Bug Fixes
* attempt bundling `@sanity/ui` and `styled-components` for hydrogen compat ([b39f58a](https://github.com/sanity-io/visual-editing/commit/b39f58a33e6114be37d69d852b40ff35397d8591))
* **CHANGELOG:** restore continuity ([c9f19cd](https://github.com/sanity-io/visual-editing/commit/c9f19cd7d8be297b99f7feb9c678b34822d10c8b))
* don't bundle `uuid` ([6e11ca5](https://github.com/sanity-io/visual-editing/commit/6e11ca552cc05dc37295900c5aab511ab7b6eef9))
## [2.0.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.16-pink-lizard...overlays-v2.0.0-pink-lizard) (2023-11-02)
### Bug Fixes
* **README:** add badges and links ([0fcf516](https://github.com/sanity-io/visual-editing/commit/0fcf516fb0a920c01cb4a153863d256e39395024))
## [0.1.16-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.15-pink-lizard...overlays-v0.1.16-pink-lizard) (2023-11-02)
### Bug Fixes
* bundle `valibot` ([6b07f06](https://github.com/sanity-io/visual-editing/commit/6b07f0629d1e70fcce86b22f1a3f8258f1f833c7))
* move peer deps to regular deps ([91489dc](https://github.com/sanity-io/visual-editing/commit/91489dc486f209cdaf618cffb2f0e331b2d9753a))
* remove unused `@sanity/icons` package ([09c1954](https://github.com/sanity-io/visual-editing/commit/09c195409525fff03563ce973b36b14055d49fb9))
* remove unused dep `history` ([9fb2447](https://github.com/sanity-io/visual-editing/commit/9fb24478abb0bddacd0fbe369ec4956cfa1aaa09))
## [0.1.15-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.14-pink-lizard...overlays-v0.1.15-pink-lizard) (2023-11-02)
### Bug Fixes
* remove `sanity` peer dep ([30ff225](https://github.com/sanity-io/visual-editing/commit/30ff225255b587e92e020bca5cfda03f5577852b))
* remove unused `nanoid` dependency ([142b3dd](https://github.com/sanity-io/visual-editing/commit/142b3ddf9f30b0a7ab89471144a9bf091c31863f))
## [0.1.14-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.13-pink-lizard...overlays-v0.1.14-pink-lizard) (2023-11-02)
### Bug Fixes
* **deps:** pin dependencies ([#239](https://github.com/sanity-io/visual-editing/issues/239)) ([e1583b9](https://github.com/sanity-io/visual-editing/commit/e1583b99eb45342ffbddb68c1af66b33bc9a25d1))
* use the same path utils everywhere ([a437719](https://github.com/sanity-io/visual-editing/commit/a4377194fdcaefddb3f199650aeb87a6989b0694))
## [0.1.13-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.12-pink-lizard...overlays-v0.1.13-pink-lizard) (2023-11-02)
### Bug Fixes
* always bundle private packages ([6be3f74](https://github.com/sanity-io/visual-editing/commit/6be3f7409216c699667d6ac400b4ce3b3a426679))
* **deps:** Update sanity monorepo to v3.18.2-pink-lizard.172 ([#233](https://github.com/sanity-io/visual-editing/issues/233)) ([c5e6c5d](https://github.com/sanity-io/visual-editing/commit/c5e6c5d48f6d1c6b17d97e3845e3da751aef9918))
* load src directly ([94308f0](https://github.com/sanity-io/visual-editing/commit/94308f0ba815d89347c7201eb759cc0ba6e2bbf7))
* move `@sanity/csm` into `visual-editing-helpers` ([257a4ad](https://github.com/sanity-io/visual-editing/commit/257a4adf64dcd74cbf435b883995c6f5b8730c25))
* **overlays:** improve element detection in mutation handler ([eda5fbd](https://github.com/sanity-io/visual-editing/commit/eda5fbdcfb0d510569aab42a1233679a5ef60b07))
* prepare release ([f2ce9cb](https://github.com/sanity-io/visual-editing/commit/f2ce9cb4046df2cb7581e66fcad3a5c0631778ae))
## [0.1.12-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.11-pink-lizard...overlays-v0.1.12-pink-lizard) (2023-10-31)
### Bug Fixes
* **deps:** Update dependency valibot to ^0.20.0 ([#211](https://github.com/sanity-io/visual-editing/issues/211)) ([8fe3fc1](https://github.com/sanity-io/visual-editing/commit/8fe3fc170533bac3e223c0a4885aa0656c454c2f))
## [0.1.11-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.10-pink-lizard...overlays-v0.1.11-pink-lizard) (2023-10-27)
### Bug Fixes
* **deps:** Update sanity monorepo to v3.18.2-pink-lizard.162 ([#197](https://github.com/sanity-io/visual-editing/issues/197)) ([6d962b1](https://github.com/sanity-io/visual-editing/commit/6d962b15f5f876c91cfd8df1856d4ffd8f05d83c))
* **refactor:** composer to pages ([#202](https://github.com/sanity-io/visual-editing/issues/202)) ([e46f475](https://github.com/sanity-io/visual-editing/commit/e46f475c50438339f5c95ccf3930f9d16c43dc4b))
## [0.1.10-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.9-pink-lizard...overlays-v0.1.10-pink-lizard) (2023-10-25)
### Bug Fixes
* **deps:** upgrade `@sanity/pkg-utils` ([9236c86](https://github.com/sanity-io/visual-editing/commit/9236c86fd37a2e4dff4d5a8142846fc2a96bc538))
## [0.1.9-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.8-pink-lizard...overlays-v0.1.9-pink-lizard) (2023-10-24)
### Bug Fixes
* temp disable minify for debugging ([93265ae](https://github.com/sanity-io/visual-editing/commit/93265ae870ec204a2753665a3e435a573ab5d862))
## [0.1.8-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.7-pink-lizard...overlays-v0.1.8-pink-lizard) (2023-10-24)
### Bug Fixes
* channels improvements ([#180](https://github.com/sanity-io/visual-editing/issues/180)) ([182cb48](https://github.com/sanity-io/visual-editing/commit/182cb489efb6e5413303fa60d33e8b6c012a0cd3))
## [0.1.7-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.6-pink-lizard...overlays-v0.1.7-pink-lizard) (2023-10-24)
### Bug Fixes
* **overlays:** initialise observers on activate method ([475b4bf](https://github.com/sanity-io/visual-editing/commit/475b4bf22c6dcd3b8c00263c1978aa1af3edf7f0))
## [0.1.6-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.5-pink-lizard...overlays-v0.1.6-pink-lizard) (2023-10-23)
### Bug Fixes
* disable minification to ease debugging ([666f8e0](https://github.com/sanity-io/visual-editing/commit/666f8e07565a566291c7a19b7dfe65a12aed49a5))
## [0.1.5-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.4-pink-lizard...overlays-v0.1.5-pink-lizard) (2023-10-23)
### Bug Fixes
* generate typings from bundled packages ([8201fa7](https://github.com/sanity-io/visual-editing/commit/8201fa7895c8511b44c7a7344d29a183ef2cf87b))
## [0.1.4-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.3-pink-lizard...overlays-v0.1.4-pink-lizard) (2023-10-23)
### Bug Fixes
* **deps:** Update dependency @sanity/ui to ^1.8.3 ([#171](https://github.com/sanity-io/visual-editing/issues/171)) ([7612ac4](https://github.com/sanity-io/visual-editing/commit/7612ac4799468f3f15f0ea66e6f09902b11dfb80))
* remove debug console loggers ([84f4b1d](https://github.com/sanity-io/visual-editing/commit/84f4b1d06196161e94aa2333fbf5f9cbef0cc51c))
## [0.1.3-pink-lizard](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.2-pink-lizard...overlays-v0.1.3-pink-lizard) (2023-10-23)
### Bug Fixes
* **deps:** update sanity monorepo ([#166](https://github.com/sanity-io/visual-editing/issues/166)) ([2f6232f](https://github.com/sanity-io/visual-editing/commit/2f6232fb3384bb1ad29273434e54659b344d6e49))
* **pink-lizard:** remove unnecessary suffix ([c7409aa](https://github.com/sanity-io/visual-editing/commit/c7409aa698a5f6e332b05537441efd0df8d33b95))
## [0.1.2-pink-lizard.0](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.1-pink-lizard.0...overlays-v0.1.2-pink-lizard.0) (2023-10-19)
### Bug Fixes
* **overlays:** calculate rect on element scroll ([70101f8](https://github.com/sanity-io/visual-editing/commit/70101f8aec06f75a9730b3308c27c927ad4fde35))
## [0.1.1-pink-lizard.0](https://github.com/sanity-io/visual-editing/compare/overlays-v0.1.0-pink-lizard.0...overlays-v0.1.1-pink-lizard.0) (2023-10-19)
### Bug Fixes
* include `CHANGELOG.md` files in private packages ([9967f1c](https://github.com/sanity-io/visual-editing/commit/9967f1c8edca69737842e1807cf8f9e725fbcd07))
## [1.0.6](https://github.com/sanity-io/overlays/compare/v1.0.5...v1.0.6) (2023-09-12)

@@ -10,0 +314,0 @@

3

dist/index.cjs.js
import cjs from './index.cjs';
export const enableVisualEditing = cjs.enableVisualEditing;
export const createOverlayController = cjs.createOverlayController;
export const enableOverlays = cjs.enableOverlays;

@@ -1,12 +0,282 @@

export declare type DisableVisualEditing = () => void
/**
* The origin that are allowed to connect to the overlay.
* @example 'https://my.sanity.studio'
* @example location.origin
* @example 'same-origin'
* @public
*/
export declare type AllowStudioOrigin =
| 'same-origin'
| `https://${string}`
| `http://${string}`
| string
/**
* Creates a controller which dispatches overlay related events
*
* @param handler - Dispatched event handler
* @param overlayElement - Parent element containing rendered overlay elements
* @public
*/
export declare function createOverlayController({
handler,
overlayElement,
preventDefault,
}: OverlayOptions): OverlayController
/**
* Cleanup function used when e.g. unmounting
* @public
*/
export declare type DisableOverlays = () => void
/**
* Element focus state
* @public
*/
export declare type ElementFocusedState = 'clicked' | 'duplicate' | boolean
/**
* Element state for consuming applications
* @public
*/
export declare interface ElementState {
id: string
activated: boolean
focused: ElementFocusedState
hovered: boolean
rect: OverlayRect
sanity: SanityNode | SanityNodeLegacy
}
/**
* Enables Visual Editing overlay in a page with sourcemap encoding.
*
* This will overlay UI on hovered elements that deep-links to Sanity Studio.
* @public
*/
export declare function enableOverlays(options?: {
/**
* The origin that are allowed to connect to the overlay.
* @example 'https://my.sanity.studio'
* @example location.origin
* @example 'same-origin'
* @defaultValue 'same-origin'
*/
allowStudioOrigin?: AllowStudioOrigin
history?: HistoryAdapter
zIndex?: string | number
}): DisableOverlays
/**
* 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
}
/**
*
* @public
*/
export declare function enableVisualEditing(): DisableVisualEditing
export declare interface HistoryAdapter {
subscribe: (navigate: HistoryAdapterNavigate) => () => void
update: (update: HistoryUpdate) => void
}
/**
*
* @public
*/
export declare type HistoryAdapterNavigate = (update: HistoryUpdate) => void
/**
* Preview frame history update
* @public
*/
export declare type HistoryUpdate = {
type: 'push' | 'pop' | 'replace'
url: string
}
/**
* Base controller dispatched message
* @typeParam T - Type of message
* @public
*/
export declare interface Msg<T extends string> {
type: T
}
/**
* Object returned by a controller instantiation
* @public
*/
export declare interface OverlayController {
activate: () => void
deactivate: () => void
}
/**
* 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
* @public
*/
export declare type OverlayEventHandler = (message: OverlayMsg) => void
/**
* Controller dispatched messages
* @public
*/
export declare type OverlayMsg =
| OverlayMsgBlur
| OverlayMsgActivate
| OverlayMsgDeactivate
| OverlayMsgElementActivate
| OverlayMsgElementClick
| OverlayMsgElementDeactivate
| OverlayMsgElementMouseEnter
| OverlayMsgElementMouseLeave
| OverlayMsgElementRegister
| OverlayMsgElementUnregister
| OverlayMsgElementUpdateRect
/** @public */
export declare type OverlayMsgActivate = Msg<'overlay/activate'>
/** @public */
export declare type OverlayMsgBlur = Msg<'overlay/blur'>
/** @public */
export declare type OverlayMsgDeactivate = Msg<'overlay/deactivate'>
/** @public */
export declare interface OverlayMsgElement<T extends string>
extends Msg<`element/${T}`> {
id: string
}
/** @public */
export declare type OverlayMsgElementActivate =
OverlayMsgElement<'activate'> & {
sanity: SanityNode | SanityNodeLegacy
rect: OverlayRect
}
/** @public */
export declare type OverlayMsgElementClick = OverlayMsgElement<'click'> & {
sanity: SanityNode | SanityNodeLegacy
}
/** @public */
export declare type OverlayMsgElementDeactivate =
OverlayMsgElement<'deactivate'>
/** @public */
export declare type OverlayMsgElementMouseEnter =
OverlayMsgElement<'mouseenter'> & {
rect: OverlayRect
}
/** @public */
export declare type OverlayMsgElementMouseLeave =
OverlayMsgElement<'mouseleave'>
/** @public */
export declare type OverlayMsgElementRegister =
OverlayMsgElement<'register'> & {
sanity: SanityNode | SanityNodeLegacy
rect: OverlayRect
}
/** @public */
export declare type OverlayMsgElementUnregister =
OverlayMsgElement<'unregister'>
/** @public */
export declare type OverlayMsgElementUpdateRect =
OverlayMsgElement<'updateRect'> & {
rect: OverlayRect
}
/**
* Options passed when instantiating an overlay controller
* @public
*/
export declare interface OverlayOptions {
handler: OverlayEventHandler
overlayElement: HTMLElement
preventDefault: boolean
}
/**
* @public
*/
export declare interface OverlayRect {
x: number
y: number
w: number
h: number
}
/**
* Object returned by node traversal
* @internal
*/
export declare interface _ResolvedElement {
elements: _SanityNodeElements
sanity: SanityNode | SanityNodeLegacy
}
/**
* Data resolved from a Sanity node
* @public
*/
export declare type SanityNode = {
/** @deprecated */
projectId?: string
/** @deprecated */
dataset?: string
id: string
path: string
type?: string
baseUrl: string
tool?: string
workspace?: string
}
/**
* Object returned by node traversal
* @internal
*/
export declare interface _SanityNodeElements {
element: HTMLElement
measureElement: HTMLElement
}
/**
* Data resolved from a (legacy) Sanity node
* @public
*/
export declare type SanityNodeLegacy = {
origin: string
href: string
data?: string
}
export {}

@@ -1,1 +0,1 @@

import{jsx as e}from"react/jsx-runtime";let t=null,n=null;function i(){n&&(n.unmount(),n=null),t&&(document.body.removeChild(t),t=null)}function l(){if(n||t)return i;let l=!1;return Promise.all([import("react-dom/client"),import("./_chunks/VisualEditingOverlay-17042a2c.js")]).then((([i,{VisualEditingOverlay:r}])=>{if(l)return;t=document.createElement("div"),t.id="sanity-visual-editing",t.style.position="relative",t.style.zIndex="2147483647",document.body.appendChild(t);const{createRoot:o}="default"in i?i.default:i;n=o(t),n.render(e(r,{}))})),()=>{l=!0,i()}}export{l as enableVisualEditing};//# sourceMappingURL=index.js.map
export{c as createOverlayController,e as enableOverlays}from"./_chunks/index-JtjVptJR.js";//# sourceMappingURL=index.js.map
{
"name": "@sanity/overlays",
"version": "1.0.6",
"homepage": "https://github.com/sanity-io/overlays#readme",
"version": "2.1.2",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/overlays#readme",
"bugs": {
"url": "https://github.com/sanity-io/overlays/issues"
"url": "https://github.com/sanity-io/visual-editing/issues"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/sanity-io/overlays.git",
"url": "git+ssh://git@github.com/sanity-io/visual-editing.git",
"directory": "packages/overlays"

@@ -37,13 +37,5 @@ },

"dist",
"src",
"CHANGELOG.md"
],
"scripts": {
"prebuild": "rimraf dist",
"build": "pkg build --strict && pkg --strict",
"lint": "eslint --max-warnings 0 .",
"prepublishOnly": "npm run build",
"release": "semantic-release || semantic-release --dry-run --debug",
"test": "tsc --noEmit",
"watch": "pkg watch --strict"
},
"browserslist": [

@@ -54,2 +46,5 @@ "> 0.2% and last 2 versions and supports es6-module and supports es6-module-dynamic-import and not dead and not IE 11",

"prettier": {
"plugins": [
"prettier-plugin-packagejson"
],
"semi": false,

@@ -114,39 +109,31 @@ "singleQuote": true

"dependencies": {
"@floating-ui/react-dom": "^2.0.2",
"@sanity/icons": "^2.4.1",
"@sanity/ui": "^1.8.2",
"@sanity/client": "^6.9.1",
"@sanity/ui": "^1.9.3",
"@vercel/stega": "0.1.0",
"nanoid": "^4.0.2",
"react-intersection-observer": "^9.5.2",
"scroll-into-view-if-needed": "^3.0.10"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"scroll-into-view-if-needed": "^3.1.0",
"styled-components": "6.1.1",
"uuid": "^9.0.1"
},
"devDependencies": {
"@sanity/pkg-utils": "^2.4.8",
"@sanity/semantic-release-preset": "^4.1.4",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"@sanity/channels": "0.1.0",
"@sanity/pkg-utils": "^3.3.2",
"@sanity/visual-editing-helpers": "0.1.1",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"ls-engines": "^0.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"rimraf": "^5.0.1",
"semantic-release": "^21.1.1",
"styled-components": "^5.3.11",
"typescript": "^5.2.2"
"happy-dom": "^12.10.3",
"ls-engines": "^0.9.1",
"rimraf": "^5.0.5",
"typescript": "^5.3.2",
"vitest": "^1.0.1"
},
"peerDependencies": {
"react": "^18",
"react-dom": "^18",
"react-is": "^18",
"styled-components": "^5.3.11"
},
"engines": {

@@ -156,5 +143,11 @@ "node": ">=16.14"

"publishConfig": {
"access": "public",
"provenance": true
"access": "public"
},
"scripts": {
"prebuild": "rimraf dist",
"build": "pkg build --strict && pkg --strict",
"lint": "eslint .",
"test": "vitest --pass-with-no-tests --typecheck",
"watch": "pkg watch --strict"
}
}
}
# @sanity/overlays — Visual Editing
Sanity Visual Editing highlights elements on your website that are editable in Sanity Studio.
[![npm stat](https://img.shields.io/npm/dm/@sanity/overlays.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@sanity/overlays)
[![npm version](https://img.shields.io/npm/v/@sanity/overlays.svg?style=flat-square)](https://www.npmjs.com/package/@sanity/overlays)
[![gzip size][gzip-badge]][bundlephobia]
[![size][size-badge]][bundlephobia]
Learn more about this feature, and how to use it, in our [Visual Editing documentation](http://sanity.io/docs/vercel-visual-editing).
This package is used with the [Presentation](https://www.sanity.io/docs/presentation) tool in the Sanity Studio to create clickable elements to take editors right from previews to the document and field they want to edit.
> **Note**
> Visual Editing requires [Content Source Maps](https://www.sanity.io/blog/content-source-maps-announce), a feature available on a Sanity Enterprise plan. If you are an existing enterprise customer, [contact our sales team](https://www.sanity.io/contact/sales?ref=vercel-visual-editing-docs) to have Content Source Maps enabled on your project. [Learn more about Sanity for Enterprise organizations here](https://www.sanity.io/enterprise?ref=vercel-visual-editing-docs).
> **Note**
> This package is **not required** for Vercel Visual Editing. It is only required if you want to enable visual editing on alternative hosting providers.
## Prerequisites
- Sanity Enterprise project with Content Source Maps enabled
- An **enhanced** Sanity Client using `createClient` from [`@sanity/preview-kit`](https://github.com/sanity-io/preview-kit) or [`next-sanity`](https://github.com/sanity-io/next-sanity) with `encodeSourceMap` and `studioUrl` enabled
## Getting started

@@ -22,3 +14,3 @@

Install the package along with either `next-sanity` or `@sanity/preview-kit` depending on your project.
Install the package along with either `@sanity/react-loader`, `@sanity/nuxt-loader`, `@sanity/svelte-loader` or `@sanity/core-loader` depending on your project.

@@ -28,4 +20,4 @@ The other peer dependencies are required and will be loaded asynchronously when Visual Editing is enabled.

```sh
# For Next.js applications
npm install @sanity/overlays next-sanity react react-dom react-is styled-components
# For React.js applications
npm install @sanity/overlays @sanity/react-loader
```

@@ -35,36 +27,21 @@

# Framework agnostic JavaScript libraries
npm install @sanity/overlays @sanity/preview-kit react react-dom react-is styled-components
npm install @sanity/overlays @sanity/core-loader
```
### 2. Configure an enhanced Sanity client
### 2. Fetch data with a Sanity loader
Visual Editing relies on encoded metadata being present in values returned from your queries. This metadata is only present when using an enhanced Sanity client on a project on which Content Source Maps is enabled.
TODO, link to the docs for each loader
Ensure `encodeSourceMap` is only `true` in non-production environments.
### 3. Set data attributes
```ts
import { createClient } from 'next-sanity'
// or
import { createClient } from '@sanity/preview-kit/client'
TODO, how to set the `data-sanity` attributes
const client = createClient({
// ...all other config
studioUrl: '/studio', // Or: 'https://my-cool-project.sanity.studio'
encodeSourceMap: true,
})
```
### 4. Dynamically enable Visual Editing
For more configuration options when working with Content Source Maps and the enhanced Sanity Client, see the README's of either package:
- [next-sanity](https://github.com/sanity-io/next-sanity)
- [@sanity/preview-kit](https://github.com/sanity-io/preview-kit)
### 3. Dynamically enable Visual Editing
Ensure the overlay is only enabled in non-production environments.
```ts
import { enableVisualEditing } from '@sanity/overlays'
import { enableOverlays } from '@sanity/overlays'
const disable = enableVisualEditing() // Enables Visual Editing overlay
const disable = enableOverlays() // Enables Visual Editing overlay
disable() // Disables Visual Editing overlay

@@ -76,5 +53,5 @@ ```

```ts
import { enableVisualEditing } from '@sanity/overlays'
import { enableOverlays } from '@sanity/overlays'
useEffect(enableVisualEditing, [])
useEffect(enableOverlays, [])
```

@@ -110,19 +87,12 @@

### `data-sanity-edit-info`
## Using stega
You can manually add custom "Edit in Sanity Studio" elements by adding a `data-sanity-edit-info` attribute to the element you want to be editable.
Docs on how to use the new stega enhanced client in `@sanity/client/stega` which replaces `@sanity/preview-kit/client`.
```tsx
export function MyComponent() {
return (
<div
data-sanity-edit-info={JSON.stringify({
origin: 'sanity.io',
href: '/studio',
})}
>
...
</div>
)
}
```
## Vercel Visual Editing compatibility
A note on usage that's compatible with Vercel.
[gzip-badge]: https://img.shields.io/bundlephobia/minzip/@sanity/overlays?label=gzip%20size&style=flat-square
[size-badge]: https://img.shields.io/bundlephobia/min/@sanity/overlays?label=size&style=flat-square
[bundlephobia]: https://bundlephobia.com/package/@sanity/overlays

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