New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sanity-plugin-iframe-pane

Package Overview
Dependencies
Maintainers
0
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanity-plugin-iframe-pane - npm Package Compare versions

Comparing version 3.1.6 to 3.1.7-canary.0

lib/index.d.cts

3

lib/index.d.ts
import type {HTMLAttributeReferrerPolicy} from 'react'
import {JSX as JSX_2} from 'react/jsx-runtime'
import {SanityDocument} from 'sanity'
export declare function Iframe(props: IframeProps): JSX_2.Element
export declare function Iframe(props: IframeProps): React.JSX.Element

@@ -7,0 +6,0 @@ export declare interface IframeOptions {

@@ -7,6 +7,5 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";

import { motion, MotionConfig, AnimatePresence } from "framer-motion";
import { useMemo, useRef, memo, useState, useCallback, forwardRef, useEffect, useTransition, Suspense } from "react";
import { useCurrentUser, useClient } from "sanity";
import { useMemo, useRef, useState, useCallback, memo, forwardRef, useEffect, useTransition, Suspense } from "react";
import { useActiveWorkspace, useCurrentUser, useClient } from "sanity";
import { suspend } from "suspend-react";
import { useCopyToClipboard } from "usehooks-ts";
import { getRedirectTo } from "@sanity/preview-url-secret/get-redirect-to";

@@ -103,4 +102,3 @@ function DisplayUrl(props) {

onClick: () => {
var _a;
(_a = input == null ? void 0 : input.current) != null && _a.value && copy(input.current.value).then((copied) => {
input?.current?.value && copy(input.current.value).then((copied) => {
pushToast(copied ? {

@@ -147,5 +145,17 @@ closable: !0,

}
const MotionFlex = motion(Flex);
function useCopyToClipboard() {
const [copiedText, setCopiedText] = useState(null), copy = useCallback(async (text) => {
if (!navigator?.clipboard)
return console.warn("Clipboard not supported"), !1;
try {
return await navigator.clipboard.writeText(text), setCopiedText(text), !0;
} catch (error) {
return console.warn("Copy failed", error), setCopiedText(null), !1;
}
}, []);
return [copiedText, copy];
}
const MotionFlex = motion.create(Flex);
function Iframe(props) {
const { document, options } = props, draft = document.draft || document.published || document.displayed, { defaultSize = DEFAULT_SIZE, reload, attributes, showDisplayUrl = !0, key } = options, urlRef = useRef(options.url), [draftSnapshot, setDraftSnapshot] = useState(() => ({ key, draft }));
const { document, options } = props, draft = document.draft || document.published || document.displayed, { defaultSize = DEFAULT_SIZE, reload, attributes, showDisplayUrl = !0, key } = options, basePath = useActiveWorkspace()?.activeWorkspace?.basePath || "/", urlRef = useRef(options.url), [draftSnapshot, setDraftSnapshot] = useState(() => ({ key, draft }));
useEffect(() => {

@@ -156,3 +166,3 @@ urlRef.current = options.url;

}, [draft, draftSnapshot, key]);
const currentUser = useCurrentUser(), client = useClient({ apiVersion: "2023-10-16" }), [expiresAt, setExpiresAt] = useState(), previewSecretRef = useRef(), [isResolvingUrl, startTransition] = useTransition(), url = useCallback(
const currentUser = useCurrentUser(), client = useClient({ apiVersion: "2023-10-16" }), [expiresAt, setExpiresAt] = useState(), previewSecretRef = useRef(void 0), [isResolvingUrl, startTransition] = useTransition(), url = useCallback(
// eslint-disable-next-line @typescript-eslint/no-shadow

@@ -178,3 +188,3 @@ async (draft2) => {

location.href,
currentUser == null ? void 0 : currentUser.id
currentUser?.id
);

@@ -192,3 +202,5 @@ previewSecretRef.current = secret, startTransition(() => setExpiresAt(expiresAt2.getTime()));

previewUrlSecret: previewSecretRef.current,
previewSearchParam: null
previewSearchParam: null,
studioBasePath: basePath,
studioPreviewPerspective: "previewDrafts"
});

@@ -198,3 +210,3 @@ return new URL(url2, location.origin);

},
[client, currentUser == null ? void 0 : currentUser.id]
[client, currentUser?.id, basePath]
);

@@ -222,3 +234,3 @@ return useEffect(() => {

showDisplayUrl,
userId: currentUser == null ? void 0 : currentUser.id
userId: currentUser?.id
},

@@ -229,3 +241,2 @@ draftSnapshot.key

const IframeInner = memo(function(props) {
var _a;
const {

@@ -241,3 +252,3 @@ isResolvingUrl,

_key
} = props, [iframeSize, setIframeSize] = useState((_a = sizes) != null && _a[defaultSize] ? defaultSize : DEFAULT_SIZE), prefersReducedMotion = usePrefersReducedMotion(), url = suspend(
} = props, [iframeSize, setIframeSize] = useState(sizes?.[defaultSize] ? defaultSize : DEFAULT_SIZE), prefersReducedMotion = usePrefersReducedMotion(), url = suspend(
() => props.url(draftSnapshot),

@@ -254,3 +265,3 @@ [

), [loading, setLoading] = useState(!0), [_reloading, setReloading] = useState(!1), reloading = _reloading || isResolvingUrl, iframe = useRef(null), handleReload = useCallback(() => {
iframe != null && iframe.current && (iframe.current.src = iframe.current.src, setReloading(!0));
iframe?.current && (iframe.current.src = iframe.current.src, setReloading(!0));
}, []);

@@ -266,3 +277,3 @@ return /* @__PURE__ */ jsx(MotionConfig, { transition: prefersReducedMotion ? { duration: 0 } : void 0, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", style: { height: "100%" }, children: [

showUrl: showDisplayUrl,
reloadButton: !!(reload != null && reload.button),
reloadButton: !!reload?.button,
handleReload

@@ -269,0 +280,0 @@ }

{
"name": "sanity-plugin-iframe-pane",
"version": "3.1.6",
"version": "3.1.7-canary.0",
"description": "Display any URL in a View Pane, along with helpful buttons to Copy the URL or open in a new tab",

@@ -19,3 +19,2 @@ "homepage": "https://github.com/sanity-io/sanity-plugin-iframe-pane#readme",

".": {
"types": "./lib/index.d.ts",
"source": "./src/index.ts",

@@ -30,3 +29,2 @@ "import": "./lib/index.js",

"module": "./lib/index.js",
"source": "./src/index.ts",
"types": "./lib/index.d.ts",

@@ -40,3 +38,3 @@ "files": [

"scripts": {
"build": "run-s clean && plugin-kit verify-package --silent && pkg-utils build --strict && pkg-utils --strict",
"build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
"clean": "rimraf lib",

@@ -47,3 +45,3 @@ "format": "prettier --write --cache --ignore-unknown .",

"prepare": "husky install || true",
"prepublishOnly": "run-s build",
"prepublishOnly": "npm run build",
"test": "npm run lint && npm run type-check && npm run build",

@@ -54,10 +52,10 @@ "type-check": "tsc --noEmit",

"browserslist": "extends @sanity/browserslist-config",
"prettier": "@sanity/prettier-config",
"dependencies": {
"@sanity/icons": "^2.7.0",
"@sanity/incompatible-plugin": "^1.0.4",
"@sanity/preview-url-secret": "^1.6.4",
"@sanity/ui": "^2.0.10",
"framer-motion": "11.0.8",
"suspend-react": "0.1.3",
"usehooks-ts": "3.0.1"
"@sanity/icons": "^3.5.7",
"@sanity/incompatible-plugin": "^1.0.5",
"@sanity/preview-url-secret": "^2.1.3",
"@sanity/ui": "^2.11.6",
"framer-motion": "^12.0.6",
"suspend-react": "0.1.3"
},

@@ -67,7 +65,10 @@ "devDependencies": {

"@commitlint/config-conventional": "^19.1.0",
"@sanity/pkg-utils": "^5.0.4",
"@sanity/plugin-kit": "^3.1.10",
"@sanity/pkg-utils": "^7.0.3",
"@sanity/plugin-kit": "^4.0.19",
"@sanity/prettier-config": "^1.0.3",
"@sanity/semantic-release-preset": "^4.1.7",
"@types/react": "^19.0.8",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",

@@ -78,31 +79,28 @@ "eslint-config-react-app": "^7.0.1",

"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.34.1",
"eslint": "^8.57.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"husky": "^8.0.3",
"lint-staged": "^15.0.1",
"npm-run-all2": "^5.0.0",
"prettier": "^3.2.5",
"prettier-plugin-packagejson": "^2.4.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"prettier": "^3.4.2",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"react-is": "^18.3.0",
"rimraf": "^5.0.1",
"sanity": "^3.34.0",
"styled-components": "^6.1.8",
"typescript": "5.3.3"
"sanity": "^3.71.2",
"styled-components": "^6.1.14",
"typescript": "5.7.3"
},
"peerDependencies": {
"react": "^18.2.0",
"sanity": "^3.20.0",
"styled-components": "^5.2 || ^6.0.0"
"react": "^18.3 || ^19",
"sanity": "^3.71",
"styled-components": "^5.2 || ^6"
},
"engines": {
"node": ">=14"
"node": ">=18"
},
"publishConfig": {
"access": "public",
"provenance": true
"provenance": false
}
}

@@ -28,3 +28,3 @@ # sanity-plugin-iframe-pane

The simplest way to configure views is by customizing the `defaultDocumentNode` setting in the `deskTool()` plugin.
The simplest way to configure views is by customizing the `defaultDocumentNode` setting in the `structureTool()` plugin.

@@ -37,3 +37,3 @@ ```ts

plugins: [
deskTool({
structureTool({
defaultDocumentNode,

@@ -52,5 +52,5 @@ structure, // not required

import {DefaultDocumentNodeResolver} from 'sanity/desk'
import {type DefaultDocumentNodeResolver} from 'sanity/structure'
import {Iframe} from 'sanity-plugin-iframe-pane'
import {SanityDocument} from 'sanity'
import {type SanityDocument} from 'sanity'

@@ -57,0 +57,0 @@ // Customise this function to show the correct URL based on the current document

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

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