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

@portabletext/react

Package Overview
Dependencies
Maintainers
8
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@portabletext/react - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

dist/react-portable-text.cjs.js

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

"use strict";var q=Object.defineProperty,j=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var C=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))M.call(t,n)&&C(e,n,t[n]);if(L)for(var n of L(t))$.call(t,n)&&C(e,n,t[n]);return e},P=(e,t)=>j(e,H(t));var S=(e,t)=>{var n={};for(var a in e)M.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&L)for(var a of L(e))t.indexOf(a)<0&&$.call(e,a)&&(n[a]=e[a]);return n};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var y=require("@portabletext/toolkit"),w=require("react");function R(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var l=R(w);function g(e,t){const d=t,{block:n,list:a,listItem:f,marks:h,types:I}=d,p=S(d,["block","list","listItem","marks","types"]);return E(P(E({},e),{block:x(e,t,"block"),list:x(e,t,"list"),listItem:x(e,t,"listItem"),marks:x(e,t,"marks"),types:x(e,t,"types")}),p)}function x(e,t,n){const a=t[n],f=e[n];return typeof a=="function"||a&&typeof f=="function"?a:a?E(E({},f),a):f}const A=({children:e,value:t})=>l.default.createElement("a",{href:t==null?void 0:t.href},e),z={textDecoration:"underline"},F={em:({children:e})=>l.default.createElement("em",null,e),strong:({children:e})=>l.default.createElement("strong",null,e),code:({children:e})=>l.default.createElement("code",null,e),underline:({children:e})=>l.default.createElement("span",{style:z},e),"strike-through":({children:e})=>l.default.createElement("del",null,e),link:A},K={number:({children:e})=>l.default.createElement("ol",null,e),bullet:({children:e})=>l.default.createElement("ul",null,e)},O=({children:e})=>l.default.createElement("li",null,e),_=(e,t)=>`Unknown ${e}, specify a component for it in the \`components.${t}\` prop`,N=e=>_(`block type "${e}"`,"types"),V=e=>_(`mark type "${e}"`,"marks"),G=e=>_(`block style "${e}"`,"block"),J=e=>_(`list style "${e}"`,"list"),Q=e=>_(`list item style "${e}"`,"listItem");function X(e){console.warn(e)}const U={display:"none"},Y=({value:e,isInline:t})=>{const n=N(e._type);return t?l.default.createElement("span",{style:U},n):l.default.createElement("div",{style:U},n)},Z=({markType:e,children:t})=>l.default.createElement("span",{className:`unknown__pt__mark__${e}`},t),ee=({children:e})=>l.default.createElement("p",null,e),te=({children:e})=>l.default.createElement("ul",null,e),ne=({children:e})=>l.default.createElement("li",null,e),le=()=>l.default.createElement("br",null),re={normal:({children:e})=>l.default.createElement("p",null,e),blockquote:({children:e})=>l.default.createElement("blockquote",null,e),h1:({children:e})=>l.default.createElement("h1",null,e),h2:({children:e})=>l.default.createElement("h2",null,e),h3:({children:e})=>l.default.createElement("h3",null,e),h4:({children:e})=>l.default.createElement("h4",null,e),h5:({children:e})=>l.default.createElement("h5",null,e),h6:({children:e})=>l.default.createElement("h6",null,e)},B={types:{},block:re,marks:F,list:K,listItem:O,hardBreak:le,unknownType:Y,unknownMark:Z,unknownList:te,unknownListItem:ne,unknownBlockStyle:ee},D=w.createContext(B),oe=({components:e,children:t})=>{const n=w.useMemo(()=>g(B,e),[e]);return l.default.createElement(D.Provider,{value:n},t)};function ae({value:e,components:t,listNestingMode:n,onMissingComponent:a=X}){const f=a||se,h=Array.isArray(e)?e:[e],I=y.nestLists(h,n||y.LIST_NEST_MODE_HTML),p=w.useContext(D),d=w.useMemo(()=>t?g(p,t):p,[p,t]),r=w.useMemo(()=>ue(d,f),[d,f]),o=I.map((s,c)=>r({node:s,index:c,isInline:!1,renderNode:r}));return t?l.default.createElement(D.Provider,{value:d},o):l.default.createElement(l.default.Fragment,null,o)}const ue=(e,t)=>{function n(r){const{node:o,index:s,isInline:c}=r,u=o._key||`node-${s}`;return y.isPortableTextToolkitList(o)?f(o,s,u):y.isPortableTextListItemBlock(o)?a(o,s,u):y.isPortableTextToolkitSpan(o)?h(o,s,u):y.isPortableTextBlock(o)?I(o,s,u,c):y.isPortableTextToolkitTextNode(o)?p(o,u):d(o,s,u,c)}function a(r,o,s){const c=v({node:r,index:o,isInline:!1,renderNode:n}),u=e.listItem,i=(typeof u=="function"?u:u[r.listItem])||e.unknownListItem;if(i===e.unknownListItem){const T=r.listItem||"bullet";t(Q(T),{type:T,nodeType:"listItemStyle"})}let k=c.children;if(r.style&&r.style!=="normal"){const b=r,{listItem:T}=b,W=S(b,["listItem"]);k=n({node:W,index:o,isInline:!1,renderNode:n})}return l.default.createElement(i,{key:s,value:r,index:o,isInline:!1,renderNode:n},k)}function f(r,o,s){const c=r.children.map((k,b)=>n({node:k._key?k:P(E({},k),{_key:`li-${o}-${b}`}),index:o,isInline:!1,renderNode:n})),u=e.list,i=(typeof u=="function"?u:u[r.listItem])||e.unknownList;if(i===e.unknownList){const k=r.listItem||"bullet";t(J(k),{nodeType:"listStyle",type:k})}return l.default.createElement(i,{key:s,value:r,index:o,isInline:!1,renderNode:n},c)}function h(r,o,s){const{markDef:c,markType:u,markKey:m}=r,i=e.marks[u]||e.unknownMark,k=r.children.map((b,T)=>n({node:b,index:T,isInline:!0,renderNode:n}));return i===e.unknownMark&&t(V(u),{nodeType:"mark",type:u}),l.default.createElement(i,{key:s,text:y.spanToPlainText(r),value:c,markType:u,markKey:m,renderNode:n},k)}function I(r,o,s,c){const T=v({node:r,index:o,isInline:c,renderNode:n}),{_key:u}=T,m=S(T,["_key"]),i=m.node.style||"normal",b=(typeof e.block=="function"?e.block:e.block[i])||e.unknownBlockStyle;return b===e.unknownBlockStyle&&t(G(i),{nodeType:"blockStyle",type:i}),l.default.createElement(b,P(E({key:s},m),{value:m.node,renderNode:n}))}function p(r,o){if(r.text===`
"use strict";var q=Object.defineProperty,j=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var M=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))$.call(t,n)&&M(e,n,t[n]);if(L)for(var n of L(t))C.call(t,n)&&M(e,n,t[n]);return e},P=(e,t)=>j(e,H(t));var S=(e,t)=>{var n={};for(var a in e)$.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&L)for(var a of L(e))t.indexOf(a)<0&&C.call(e,a)&&(n[a]=e[a]);return n};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var y=require("@portabletext/toolkit"),w=require("react");function R(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var l=R(w);function B(e,t){const d=t,{block:n,list:a,listItem:f,marks:h,types:I}=d,p=S(d,["block","list","listItem","marks","types"]);return E(P(E({},e),{block:_(e,t,"block"),list:_(e,t,"list"),listItem:_(e,t,"listItem"),marks:_(e,t,"marks"),types:_(e,t,"types")}),p)}function _(e,t,n){const a=t[n],f=e[n];return typeof a=="function"||a&&typeof f=="function"?a:a?E(E({},f),a):f}const A=({children:e,value:t})=>l.default.createElement("a",{href:t==null?void 0:t.href},e),z={textDecoration:"underline"},F={em:({children:e})=>l.default.createElement("em",null,e),strong:({children:e})=>l.default.createElement("strong",null,e),code:({children:e})=>l.default.createElement("code",null,e),underline:({children:e})=>l.default.createElement("span",{style:z},e),"strike-through":({children:e})=>l.default.createElement("del",null,e),link:A},K={number:({children:e})=>l.default.createElement("ol",null,e),bullet:({children:e})=>l.default.createElement("ul",null,e)},O=({children:e})=>l.default.createElement("li",null,e),x=(e,t)=>`Unknown ${e}, specify a component for it in the \`components.${t}\` prop`,v=e=>x(`block type "${e}"`,"types"),V=e=>x(`mark type "${e}"`,"marks"),G=e=>x(`block style "${e}"`,"block"),J=e=>x(`list style "${e}"`,"list"),Q=e=>x(`list item style "${e}"`,"listItem");function X(e){console.warn(e)}const N={display:"none"},Y=({value:e,isInline:t})=>{const n=v(e._type);return t?l.default.createElement("span",{style:N},n):l.default.createElement("div",{style:N},n)},Z=({markType:e,children:t})=>l.default.createElement("span",{className:`unknown__pt__mark__${e}`},t),ee=({children:e})=>l.default.createElement("p",null,e),te=({children:e})=>l.default.createElement("ul",null,e),ne=({children:e})=>l.default.createElement("li",null,e),le=()=>l.default.createElement("br",null),re={normal:({children:e})=>l.default.createElement("p",null,e),blockquote:({children:e})=>l.default.createElement("blockquote",null,e),h1:({children:e})=>l.default.createElement("h1",null,e),h2:({children:e})=>l.default.createElement("h2",null,e),h3:({children:e})=>l.default.createElement("h3",null,e),h4:({children:e})=>l.default.createElement("h4",null,e),h5:({children:e})=>l.default.createElement("h5",null,e),h6:({children:e})=>l.default.createElement("h6",null,e)},D={types:{},block:re,marks:F,list:K,listItem:O,hardBreak:le,unknownType:Y,unknownMark:Z,unknownList:te,unknownListItem:ne,unknownBlockStyle:ee},g=w.createContext(D),oe=({components:e,children:t})=>{const n=w.useMemo(()=>B(D,e),[e]);return l.default.createElement(g.Provider,{value:n},t)};function ae({value:e,components:t,listNestingMode:n,onMissingComponent:a=X}){const f=a||se,h=Array.isArray(e)?e:[e],I=y.nestLists(h,n||y.LIST_NEST_MODE_HTML),p=w.useContext(g),d=w.useMemo(()=>t?B(p,t):p,[p,t]),r=w.useMemo(()=>ue(d,f),[d,f]),o=I.map((s,c)=>r({node:s,index:c,isInline:!1,renderNode:r}));return t?l.default.createElement(g.Provider,{value:d},o):l.default.createElement(l.default.Fragment,null,o)}const ue=(e,t)=>{function n(r){const{node:o,index:s,isInline:c}=r,u=o._key||`node-${s}`;return y.isPortableTextToolkitList(o)?f(o,s,u):y.isPortableTextListItemBlock(o)?a(o,s,u):y.isPortableTextToolkitSpan(o)?h(o,s,u):y.isPortableTextBlock(o)?I(o,s,u,c):y.isPortableTextToolkitTextNode(o)?p(o,u):d(o,s,u,c)}function a(r,o,s){const c=U({node:r,index:o,isInline:!1,renderNode:n}),u=e.listItem,i=(typeof u=="function"?u:u[r.listItem])||e.unknownListItem;if(i===e.unknownListItem){const T=r.listItem||"bullet";t(Q(T),{type:T,nodeType:"listItemStyle"})}let k=c.children;if(r.style&&r.style!=="normal"){const b=r,{listItem:T}=b,W=S(b,["listItem"]);k=n({node:W,index:o,isInline:!1,renderNode:n})}return l.default.createElement(i,{key:s,value:r,index:o,isInline:!1,renderNode:n},k)}function f(r,o,s){const c=r.children.map((k,b)=>n({node:k._key?k:P(E({},k),{_key:`li-${o}-${b}`}),index:o,isInline:!1,renderNode:n})),u=e.list,i=(typeof u=="function"?u:u[r.listItem])||e.unknownList;if(i===e.unknownList){const k=r.listItem||"bullet";t(J(k),{nodeType:"listStyle",type:k})}return l.default.createElement(i,{key:s,value:r,index:o,isInline:!1,renderNode:n},c)}function h(r,o,s){const{markDef:c,markType:u,markKey:m}=r,i=e.marks[u]||e.unknownMark,k=r.children.map((b,T)=>n({node:b,index:T,isInline:!0,renderNode:n}));return i===e.unknownMark&&t(V(u),{nodeType:"mark",type:u}),l.default.createElement(i,{key:s,text:y.spanToPlainText(r),value:c,markType:u,markKey:m,renderNode:n},k)}function I(r,o,s,c){const T=U({node:r,index:o,isInline:c,renderNode:n}),{_key:u}=T,m=S(T,["_key"]),i=m.node.style||"normal",b=(typeof e.block=="function"?e.block:e.block[i])||e.unknownBlockStyle;return b===e.unknownBlockStyle&&t(G(i),{nodeType:"blockStyle",type:i}),l.default.createElement(b,P(E({key:s},m),{value:m.node,renderNode:n}))}function p(r,o){if(r.text===`
`){const s=e.hardBreak;return s?l.default.createElement(s,{key:o}):`
`}return r.text}function d(r,o,s,c){const u=e.types[r._type],m={value:r,isInline:c,index:o,renderNode:n};if(u)return l.default.createElement(u,E({key:s},m));t(N(r._type),{nodeType:"block",type:r._type});const i=e.unknownType;return l.default.createElement(i,E({key:s},m))}return n};function v(e){const{node:t,index:n,isInline:a,renderNode:f}=e,I=y.buildMarksTree(t).map((p,d)=>f({node:p,isInline:!0,index:d,renderNode:f}));return{_key:t._key||`block-${n}`,children:I,index:n,isInline:a,node:t}}function se(){}Object.defineProperty(exports,"toPlainText",{enumerable:!0,get:function(){return y.toPlainText}});exports.PortableText=ae;exports.PortableTextComponentsProvider=oe;exports.defaultComponents=B;exports.mergeComponents=g;
`}return r.text}function d(r,o,s,c){const u=e.types[r._type],m={value:r,isInline:c,index:o,renderNode:n};if(u)return l.default.createElement(u,E({key:s},m));t(v(r._type),{nodeType:"block",type:r._type});const i=e.unknownType;return l.default.createElement(i,E({key:s},m))}return n};function U(e){const{node:t,index:n,isInline:a,renderNode:f}=e,I=y.buildMarksTree(t).map((p,d)=>f({node:p,isInline:!0,index:d,renderNode:f}));return{_key:t._key||`block-${n}`,children:I,index:n,isInline:a,node:t}}function se(){}Object.defineProperty(exports,"toPlainText",{enumerable:!0,get:function(){return y.toPlainText}});exports.PortableText=ae;exports.PortableTextComponentsProvider=oe;exports.defaultComponents=D;exports.mergeComponents=B;
//# sourceMappingURL=react-portable-text.cjs.js.map

@@ -241,3 +241,3 @@ var __defProp = Object.defineProperty;

}
function renderSpan(node, index, key) {
function renderSpan(node, _index, key) {
const { markDef, markType, markKey } = node;

@@ -244,0 +244,0 @@ const Span = components.marks[markType] || components.unknownMark;

{
"name": "@portabletext/react",
"version": "1.0.2",
"version": "1.0.3",
"description": "Render Portable Text with React",

@@ -39,17 +39,21 @@ "main": "./dist/react-portable-text.cjs.js",

"license": "MIT",
"dependencies": {
"@portabletext/toolkit": "^1.0.4",
"@portabletext/types": "^1.0.3"
},
"devDependencies": {
"@sanity/ui": "^0.37.2",
"@types/leaflet": "^1.7.8",
"@types/react": "^17.0.37",
"@sanity/ui": "^0.37.5",
"@types/leaflet": "^1.7.9",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/refractor": "^3.0.2",
"@types/styled-components": "^5.1.20",
"@types/styled-components": "^5.1.22",
"@types/tap": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"esbuild-register": "^3.2.1",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"esbuild-register": "^3.3.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-sanity": "^5.1.0",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react": "^7.28.0",
"leaflet": "^1.7.1",

@@ -59,3 +63,3 @@ "prettier": "^2.5.1",

"react-dom": "^17.0.2",
"react-leaflet": "^3.2.4",
"react-leaflet": "^3.2.5",
"react-refractor": "^2.1.5",

@@ -65,5 +69,5 @@ "refractor": "^3.5.0",

"styled-components": "^5.3.3",
"tap": "^15.1.5",
"typescript": "^4.5.4",
"vite": "^2.7.4",
"tap": "^15.1.6",
"typescript": "^4.5.5",
"vite": "^2.8.1",
"vite-dts": "^1.0.4"

@@ -108,7 +112,3 @@ },

"check-coverage": false
},
"dependencies": {
"@portabletext/toolkit": "^1.0.3",
"@portabletext/types": "^1.0.2"
}
}

@@ -168,3 +168,3 @@ # @portabletext/react

// Ex. 1: custom renderer for the em / italics decorator
em: ({children}) => <em class="text-gray-600 font-semibold">{children}</em>,
em: ({children}) => <em className="text-gray-600 font-semibold">{children}</em>,

@@ -193,7 +193,7 @@ // Ex. 2: rendering a custom `link` annotation

// Ex. 1: customizing common block types
h1: ({children}) => <h1 class="text-2xl">{children}</h1>,
blockquote: ({children}) => <blockquote class="border-l-purple-500">{children}</blockquote>,
h1: ({children}) => <h1 className="text-2xl">{children}</h1>,
blockquote: ({children}) => <blockquote className="border-l-purple-500">{children}</blockquote>,
// Ex. 2: rendering custom styles
customHeading: ({children}) => <h2 class="text-lg text-primary text-purple-700">{children}</h2>,
customHeading: ({children}) => <h2 className="text-lg text-primary text-purple-700">{children}</h2>,
},

@@ -215,7 +215,7 @@ }

// Ex. 1: customizing common list types
bullet: ({children}) => <ul class="mt-xl">{children}</ul>,
number: ({children}) => <ol class="mt-lg">{children}</ol>,
bullet: ({children}) => <ul className="mt-xl">{children}</ul>,
number: ({children}) => <ol className="mt-lg">{children}</ol>,
// Ex. 2: rendering custom lists
checkmarks: ({children}) => <ol class="m-auto text-lg">{children}</ol>,
checkmarks: ({children}) => <ol className="m-auto text-lg">{children}</ol>,
},

@@ -222,0 +222,0 @@ }

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