@okam/directus-flexible-content 1.2.23 → 1.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,61 @@
1
+ ## 1.2.25 (2026-01-14)
2
+
3
+ ### 🚀 Features
4
+
5
+ - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
6
+ - bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
11
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
12
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
13
+ - search field type export ([5ab6070](https://github.com/OKAMca/stack/commit/5ab6070))
14
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
15
+ - select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
16
+
17
+ ### ⚠️ Breaking Changes
18
+
19
+ - Consumers must now have react and react-dom in their own
20
+
21
+ ### 🧱 Updated Dependencies
22
+
23
+ - Updated stack-ui to 1.44.0
24
+ - Updated directus-block to 1.6.3
25
+
26
+ ### ❤️ Thank You
27
+
28
+ - Marie-Maxime Tanguay @marie-maxime
29
+ - Pierre-Olivier Clerson @poclerson
30
+ - poclerson
31
+
32
+ ## 1.2.24 (2026-01-13)
33
+
34
+ ### 🚀 Features
35
+
36
+ - React 19 + Next.js 15 support ([#369](https://github.com/OKAMca/stack/pull/369))
37
+ - bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
38
+
39
+ ### 🩹 Fixes
40
+
41
+ - **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
42
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
43
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
44
+ - search field type export ([5ab6070](https://github.com/OKAMca/stack/commit/5ab6070))
45
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
46
+ - select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
47
+
48
+ ### 🧱 Updated Dependencies
49
+
50
+ - Updated stack-ui to 1.43.0
51
+ - Updated directus-block to 1.6.2
52
+
53
+ ### ❤️ Thank You
54
+
55
+ - Marie-Maxime Tanguay @marie-maxime
56
+ - Pierre-Olivier Clerson @poclerson
57
+ - poclerson
58
+
1
59
  ## 1.2.23 (2025-11-27)
2
60
 
3
61
  ### 🚀 Features
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),O=require("@tanstack/react-query"),_=require("radashi"),C=require("graphql-request"),E=require("@okam/stack-ui"),G=require("react"),B=require("@tiptap/core"),K=require("@tiptap/extension-blockquote"),V=require("@tiptap/extension-bold"),X=require("@tiptap/extension-bullet-list"),J=require("@tiptap/extension-code"),W=require("@tiptap/extension-code-block"),$=require("@tiptap/extension-document"),Y=require("@tiptap/extension-hard-break"),Z=require("@tiptap/extension-heading"),ee=require("@tiptap/extension-horizontal-rule"),te=require("@tiptap/extension-italic"),ne=require("@tiptap/extension-link"),re=require("@tiptap/extension-list-item"),oe=require("@tiptap/extension-ordered-list"),ie=require("@tiptap/extension-paragraph"),se=require("@tiptap/extension-strike"),ce=require("@tiptap/extension-subscript"),ae=require("@tiptap/extension-superscript"),le=require("@tiptap/extension-table"),ue=require("@tiptap/extension-table-cell"),de=require("@tiptap/extension-table-header"),me=require("@tiptap/extension-table-row"),fe=require("@tiptap/extension-text"),pe=require("@tiptap/extension-text-align");function H(e,n){return n}class q{constructor(n,r,t){this.nameSpace="[STACK]",this.suppressConsole=!1,this.env=process.env.NODE_ENV,this.nameSpace=n??this.nameSpace,this.suppressConsole=t??this.suppressConsole,this.logger=r??this.internalLogger}internalLogger(n,r,t){this.env!=="production"&&console[r||"log"](`${this.nameSpace} ${n}`.trimStart(),t??"")}setLogger(n){this.logger=(r,t,i)=>{this.suppressConsole&&this.internalLogger(r,t,i),n(r,t,i)}}static getInstance(){return q.instance||(q.instance=new q),q.instance}log(n,r,t){this.logger(n,r,t)}}q.getInstance();const ge=(e,n,r=!1)=>{const t=new q(e,n,r);return t.log("Logger initialized","info"),t},ke=ge("[DirectusQuery]"),ye=process.env.NEXT_PUBLIC_GRAPHQL_URL,be=process.env.NEXT_SERVER_GRAPHQL_URL,Ne=process.env.NEXT_GRAPHQL_URL_ADMIN,qe=process.env.NEXT_PUBLIC_API_TOKEN??"",Te=process.env.NEXT_PUBLIC_API_TOKEN,he=new C.GraphQLClient(be||ye,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${qe}`}});new C.GraphQLClient(Ne,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Te}`}});new O.QueryClient({queryCache:new O.QueryCache({onError:e=>{ke.log("QueryClient Error","error",{error:e})}}),defaultOptions:{queries:{staleTime:5*1e3}}});function M(e,n,r=he){return r.request(e,{...n})}process.env.NEXT_PUBLIC_GRAPHQL_URL;process.env.NEXT_PUBLIC_API_TOKEN;function A(e){return!!e}function Be(e){const{id:n,settings:r,...t}=e??{};return _.isEmpty(t)}async function Se(e){const{document:n,blockKey:r,variables:t}=e;if(!n||!A(t))return null;const i=await M(n,t);return!i||typeof i!="object"||!r?null:i[r]}async function _e(e){const{document:n,item:r,blockKey:t,variables:i}=e;if(r){if(!Be(r))return r;const s={id:r.id,...i};return A(s)?Se({...e,variables:s}):null}if(!n||!A(i))return null;const o=await M(n,i);return!o||typeof o!="object"||!t?null:o[t]}function ve(e,...n){return n.reduce((t,i)=>i?{components:{...t.components,...i.components}}:t,e)}const z={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"BlockSettings"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"block_settings"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tokens"}},{kind:"Field",name:{kind:"Name",value:"variant"}}]}}]},Le=e=>{var N,k,h;const{item:n,collection:r,config:t,variables:i,defaultVariant:o,...c}=e;if(!r||!t)return null;const s=(N=t==null?void 0:t.components)==null?void 0:N[r];if(!s)return null;const{settings:l}=n??{},u=(n==null?void 0:n.id)??(i==null?void 0:i.id);if(!u)return null;const{variant:f}=H(z,l)??{},d=((k=s.getVariant)==null?void 0:k.call(s,e))??f??o,{default:g,document:m}=s,b=((h=s.variants)==null?void 0:h[d??""])??g;return b?p.jsx(b,{document:m,config:t,collection:r,item:n,...u?{variables:{...i,id:u}}:{variables:i},...c},u):null};async function xe(e,n,r){const t=_.get(e,"item"),i=_.get(e,"document"),o=_.get(e,"variables"),c=await _e({item:t,blockKey:n,document:i,variables:o}),{tokens:s}=H(z,c==null?void 0:c.settings)??{};return{...c,cmsTokens:s}}const Ee=async e=>{const n="block_wysiwyg_by_id",{themeName:r="wysiwyg",tokens:t}=e,{content:i,title:o,level:c,cmsTokens:s}=await xe(e,n);return!i&&!(o&&c)?null:p.jsxs(p.Fragment,{children:[o&&c&&p.jsx(E.Box,{as:"span",themeName:r,tokens:{...t,...s},children:G.createElement(c,{},o)}),i&&p.jsx(E.WysiwygBlock,{themeName:r,tokens:{...t,...s},content:i})]})},Ae={block_wysiwyg:{default:e=>p.jsx(Ee,{...e})}},Ie={components:{...Ae}},P=e=>{const{children:n,config:r,...t}=e,i=ve(Ie,r),o=s=>n?n({...t,...s,config:i}):p.jsx(Le,{...t,...s,config:i});if("blocks"in e){const{blocks:s}=e;return s.map(o)}const{block:c}=e;return o(c)},Re=(e,n,r="id",t="item")=>{const i=o=>{var c,s,l,u,f,d;if(!e&&o)return o;if(!o||!e)return null;if(o.type==="relation-mark"&&((c=o.attrs)!=null&&c.id)||o.type==="relation-block"&&((s=o.attrs)!=null&&s.id)||o.type==="relation-inline-block"&&((l=o.attrs)!=null&&l.id)){const g=(u=e.find(m=>{var y;return(m==null?void 0:m[r])===((y=o.attrs)==null?void 0:y.id)}))==null?void 0:u[t];o.attrs.data=g}return(f=o.content)==null||f.map(i),(d=o.marks)==null||d.map(i),o};return i(n)},we=(e,n)=>{const r=n.map(o=>(o.type==="mark"?B.Mark:B.Node).create({name:o.name,renderHTML({HTMLAttributes:s}){return o.render?[...o.render(s),0]:[o.component??(o.type==="mark"?"span":"div"),s,0]}})),t=r.map(({name:o})=>o);return[...e.filter(o=>t.indexOf(o.name)<0),...r]},D=(e,n,r)=>{const t=r.find(i=>i.type===n&&i.name===e);if(t)return{...t.config,options:t.options}},Oe=(e,n)=>{var t;const r=(t=n.addAttributes)==null?void 0:t.call(n);return!r||!e?e:Object.fromEntries(Object.entries(e).filter(([i])=>{var o;return((o=r[i])==null?void 0:o.rendered)!==!1}))},v=(e,n,r="node")=>{const t=D(e.type,r,n);if(!(t!=null&&t.renderHTML))return[];const i=Oe(e.attrs,t);return t.render?t.render(e):t.renderHTML({node:e,HTMLAttributes:i})},F=(e,n,r)=>{if(e!=null&&e.content&&(e.content=e.content.map(c=>F(c,n,r))),e.type==="text"){if(e.marks){let c;return e.marks.reverse().forEach(s=>{var u;const l=v({...s,attrs:{...s.attrs,data:{...(u=s==null?void 0:s.attrs)==null?void 0:u.data,markText:e.text}}},n,"mark");if(Array.isArray(l)){const[f="span",d=s.attrs]=l,g={...d,data:void 0};c=r(f,g,c||e.text)}else c={...l,text:e.text}}),c}return e.text??""}const t=D(e.type,"node",n);if(t!=null&&t.render)return v(e,n);const[i="div",o=e.attrs]=v(e,n);return r(i,o,e.content)},Pe=(e,n,r)=>F(e,n,r),L={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Ce=(e,n)=>({...Object.fromEntries(Object.entries(n).map(([r,t])=>[(e==null?void 0:e[r])??(L==null?void 0:L[r])??r,t]))}),x={},Q=e=>{const{content:n,serializers:r=[],componentSerializers:t=[],renderingNodes:i,remappedAttributes:o,themeName:c,tokens:s,customTheme:l}=e,u=JSON.parse(JSON.stringify(n)),f=we(r,t);return Pe(u,f,(d,g,m)=>{const y={...g,style:void 0},b=Ce(o,y),N=(i==null?void 0:i[d])??(x==null?void 0:x[d]);return N?N({children:m,attrs:b,themeName:c,tokens:s,customTheme:l}):p.jsx(E.Box,{as:d,...b,themeName:c,tokens:s,customTheme:l,children:m},JSON.stringify(m))})},He=[$,fe,ie,Y,Z,W,X,oe,re,K,ee,ne,V,te,se,J,le.Table,de.TableHeader,me.TableRow,ue.TableCell,pe,ce,ae],Me=e=>{const{jsonContent:n,editorNodes:r,serializers:t,nodes:i,config:o,relationMarksConfig:c,themeName:s,tokens:l,customTheme:u,remappedAttributes:f}=e,d=Re(r,n),g=t??[...He]??[],m=(k,h)=>{var I,R,w;const{attrs:a}=k,U=`${(I=a==null?void 0:a.collection)==null?void 0:I.replace("related_","")}_id`;if(a!=null&&a.data){if(!((R=a==null?void 0:a.data)!=null&&R.blocks)){const T={collection:a.collection,item:{...a==null?void 0:a.data}};return p.jsx(P,{block:T,config:h},JSON.stringify(T))}const S=(w=a==null?void 0:a.data)==null?void 0:w.blocks,j=S==null?void 0:S.map(T=>({item:T==null?void 0:T[U],collection:a==null?void 0:a.collection}));return p.jsx(P,{blocks:j,config:h},JSON.stringify(S))}return null},y=B.Node.create({name:"relation-block",renderHTML:()=>["relation-block"],render:k=>m(k,o)}),b=B.Node.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:k=>m(k,o)}),N=B.Mark.create({name:"relation-mark",type:"relation-mark",renderHTML:()=>["relation-mark"],render:k=>m(k,c)});return g.push(y,b,N),d?p.jsx(Q,{content:d,serializers:g,renderingNodes:i,themeName:s,tokens:l,customTheme:u,remappedAttributes:f}):null};exports.FlexibleEditorContent=Me;exports.RenderNodes=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),H=require("@tanstack/react-query"),v=require("radashi"),R=require("graphql-request"),A=require("@okam/stack-ui"),K=require("react"),B=require("@tiptap/core"),V=require("@tiptap/extension-blockquote"),X=require("@tiptap/extension-bold"),J=require("@tiptap/extension-bullet-list"),W=require("@tiptap/extension-code"),$=require("@tiptap/extension-code-block"),Y=require("@tiptap/extension-document"),Z=require("@tiptap/extension-hard-break"),ee=require("@tiptap/extension-heading"),te=require("@tiptap/extension-horizontal-rule"),ne=require("@tiptap/extension-italic"),re=require("@tiptap/extension-link"),oe=require("@tiptap/extension-list-item"),ie=require("@tiptap/extension-ordered-list"),se=require("@tiptap/extension-paragraph"),ce=require("@tiptap/extension-strike"),ae=require("@tiptap/extension-subscript"),le=require("@tiptap/extension-superscript"),ue=require("@tiptap/extension-table"),de=require("@tiptap/extension-table-cell"),me=require("@tiptap/extension-table-header"),fe=require("@tiptap/extension-table-row"),pe=require("@tiptap/extension-text"),ge=require("@tiptap/extension-text-align");function M(e,n){return n}class q{constructor(n,r,t){this.nameSpace="[STACK]",this.suppressConsole=!1,this.env=process.env.NODE_ENV,this.nameSpace=n??this.nameSpace,this.suppressConsole=t??this.suppressConsole,this.logger=r??this.internalLogger}internalLogger(n,r,t){this.env!=="production"&&console[r||"log"](`${this.nameSpace} ${n}`.trimStart(),t??"")}setLogger(n){this.logger=(r,t,i)=>{this.suppressConsole&&this.internalLogger(r,t,i),n(r,t,i)}}static getInstance(){return q.instance||(q.instance=new q),q.instance}log(n,r,t){this.logger(n,r,t)}}q.getInstance();const ke=(e,n,r=!1)=>{const t=new q(e,n,r);return t.log("Logger initialized","info"),t},ye=ke("[DirectusQuery]"),be=process.env.NEXT_PUBLIC_GRAPHQL_URL,Ne=process.env.NEXT_SERVER_GRAPHQL_URL,qe=process.env.NEXT_GRAPHQL_URL_ADMIN,Te=process.env.NEXT_PUBLIC_API_TOKEN??"",he=process.env.NEXT_PUBLIC_API_TOKEN,_=new R.GraphQLClient(Ne||be,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Te}`}});new R.GraphQLClient(qe,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${he}`}});new H.QueryClient({queryCache:new H.QueryCache({onError:e=>{ye.log("QueryClient Error","error",{error:e})}}),defaultOptions:{queries:{staleTime:5*1e3}}});function Q(e,n,r=_){return r.request(e,{...n})}process.env.NEXT_PUBLIC_GRAPHQL_URL;process.env.NEXT_PUBLIC_API_TOKEN;const z={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"BlockSettings"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"block_settings"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tokens"}},{kind:"Field",name:{kind:"Name",value:"variant"}}]}}]};function I(e){return!!e}function Be(e){const{id:n,settings:r,...t}=e??{};return v.isEmpty(t)}async function Se(e,n=_){const{document:r,blockKey:t,variables:i}=e;if(!r||!I(i))return null;const o=await Q(r,i,n);return!o||typeof o!="object"||!t?null:o[t]}async function ve(e,n=_){const{document:r,item:t,blockKey:i,variables:o}=e;if(t){if(!Be(t))return t;const a={id:t.id,...o};return I(a)?Se({...e,variables:a}):null}if(!r||!I(o))return null;const c=await Q(r,o,n);return!c||typeof c!="object"||!i?null:c[i]}function _e(e){return e instanceof R.GraphQLClient}async function Le(e,n,r=_){const t=v.get(e,"item"),i=_e(r),o=v.get(e,"document"),c=v.get(e,"variables"),s=await ve({item:t,blockKey:n,document:o??(i?void 0:r),variables:c},i?r:void 0),{tokens:a}=M(z,s==null?void 0:s.settings)??{};return{...s,cmsTokens:a}}function xe(e,...n){return n.reduce((t,i)=>i?{components:{...t.components,...i.components}}:t,e)}const Ee=e=>{var N,m,h;const{item:n,collection:r,config:t,variables:i,defaultVariant:o,...c}=e;if(!r||!t)return null;const s=(N=t==null?void 0:t.components)==null?void 0:N[r];if(!s)return null;const{settings:a}=n??{},u=(n==null?void 0:n.id)??(i==null?void 0:i.id);if(!u)return null;const{variant:p}=M(z,a)??{},f=((m=s.getVariant)==null?void 0:m.call(s,e))??p??o,{default:k,document:d}=s,b=((h=s.variants)==null?void 0:h[f??""])??k;return b?g.jsx(b,{document:d,config:t,collection:r,item:n,...u?{variables:{...i,id:u}}:{variables:i},...c},u):null},Ae=async e=>{const n="block_wysiwygs_by_id",{themeName:r="wysiwyg",tokens:t}=e,{content:i,title:o,level:c,cmsTokens:s}=await Le(e,n);return!i&&!(o&&c)?null:g.jsxs(g.Fragment,{children:[o&&c&&g.jsx(A.Box,{as:"span",themeName:r,tokens:{...t,...s},children:K.createElement(c,{},o)}),i&&g.jsx(A.WysiwygBlock,{themeName:r,tokens:{...t,...s},content:i})]})},Ie={block_wysiwygs:{default:e=>g.jsx(Ae,{...e})}},Re={components:{...Ie}},O=e=>{const{children:n,config:r,...t}=e,i=xe(Re,r),o=s=>n?n({...t,...s,config:i}):g.jsx(Ee,{...t,...s,config:i});if("blocks"in e){const{blocks:s}=e;return s.map(o)}const{block:c}=e;return o(c)},we=(e,n,r="id",t="item")=>{const i=o=>{var c,s,a,u,p,f;if(!e&&o)return o;if(!o||!e)return null;if(o.type==="relation-mark"&&((c=o.attrs)!=null&&c.id)||o.type==="relation-block"&&((s=o.attrs)!=null&&s.id)||o.type==="relation-inline-block"&&((a=o.attrs)!=null&&a.id)){const k=(u=e.find(d=>{var y;return(d==null?void 0:d[r])===((y=o.attrs)==null?void 0:y.id)}))==null?void 0:u[t];o.attrs.data=k}return(p=o.content)==null||p.map(i),(f=o.marks)==null||f.map(i),o};return i(n)},Pe=(e,n)=>{const r=n.map(o=>(o.type==="mark"?B.Mark:B.Node).create({name:o.name,renderHTML({HTMLAttributes:s}){return o.render?[...o.render(s),0]:[o.component??(o.type==="mark"?"span":"div"),s,0]}})),t=r.map(({name:o})=>o);return[...e.filter(o=>t.indexOf(o.name)<0),...r]},D=(e,n,r)=>{const t=r.find(i=>i.type===n&&i.name===e);if(t)return{...t.config,options:t.options}},Ce=(e,n)=>{var t;const r=(t=n.addAttributes)==null?void 0:t.call(n);return!r||!e?e:Object.fromEntries(Object.entries(e).filter(([i])=>{var o;return((o=r[i])==null?void 0:o.rendered)!==!1}))},L=(e,n,r="node")=>{const t=D(e.type,r,n);if(!(t!=null&&t.renderHTML))return[];const i=Ce(e.attrs,t);return t.render?t.render(e):t.renderHTML({node:e,HTMLAttributes:i})},F=(e,n,r)=>{if(e!=null&&e.content&&(e.content=e.content.map(c=>F(c,n,r))),e.type==="text"){if(e.marks){let c;return e.marks.reverse().forEach(s=>{var u;const a=L({...s,attrs:{...s.attrs,data:{...(u=s==null?void 0:s.attrs)==null?void 0:u.data,markText:e.text}}},n,"mark");if(Array.isArray(a)){const[p="span",f=s.attrs]=a,k={...f,data:void 0};c=r(p,k,c||e.text)}else c={...a,text:e.text}}),c}return e.text??""}const t=D(e.type,"node",n);if(t!=null&&t.render)return L(e,n);const[i="div",o=e.attrs]=L(e,n);return r(i,o,e.content)},He=(e,n,r)=>F(e,n,r),x={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Oe=(e,n)=>({...Object.fromEntries(Object.entries(n).map(([r,t])=>[(e==null?void 0:e[r])??(x==null?void 0:x[r])??r,t]))}),E={},U=e=>{const{content:n,serializers:r=[],componentSerializers:t=[],renderingNodes:i,remappedAttributes:o,themeName:c,tokens:s,customTheme:a}=e,u=JSON.parse(JSON.stringify(n)),p=Pe(r,t);return He(u,p,(f,k,d)=>{const y={...k,style:void 0},b=Oe(o,y),N=f,m=(i==null?void 0:i[N])??(E==null?void 0:E[N]);return m?m({children:d,attrs:b,themeName:c,tokens:s,customTheme:a}):g.jsx(A.Box,{as:f,...b,themeName:c,tokens:s,customTheme:a,children:d},JSON.stringify(d))})},Me=[Y,pe,se,Z,ee,$,J,ie,oe,V,te,re,X,ne,ce,W,ue.Table,me.TableHeader,fe.TableRow,de.TableCell,ge,ae,le],Qe=e=>{const{jsonContent:n,editorNodes:r,serializers:t,nodes:i,config:o,relationMarksConfig:c,themeName:s,tokens:a,customTheme:u,remappedAttributes:p}=e,f=we(r,n),k=t??[...Me]??[],d=(m,h)=>{var w,P,C;const{attrs:l}=m,G=`${(w=l==null?void 0:l.collection)==null?void 0:w.replace("related_","")}_id`;if(l!=null&&l.data){if(!((P=l==null?void 0:l.data)!=null&&P.blocks)){const T={collection:l.collection,item:{...l==null?void 0:l.data}};return g.jsx(O,{block:T,config:h},JSON.stringify(T))}const S=(C=l==null?void 0:l.data)==null?void 0:C.blocks,j=S==null?void 0:S.map(T=>({item:T==null?void 0:T[G],collection:l==null?void 0:l.collection}));return g.jsx(O,{blocks:j,config:h},JSON.stringify(S))}return null},y=B.Node.create({name:"relation-block",renderHTML:()=>["relation-block"],render:m=>d(m,o)}),b=B.Node.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:m=>d(m,o)}),N=B.Mark.create({name:"relation-mark",type:"relation-mark",renderHTML:()=>["relation-mark"],render:m=>d(m,c)});return k.push(y,b,N),f?g.jsx(U,{content:f,serializers:k,renderingNodes:i,themeName:s,tokens:a,customTheme:u,remappedAttributes:p}):null};exports.FlexibleEditorContent=Qe;exports.RenderNodes=U;
package/index.mjs CHANGED
@@ -1,79 +1,79 @@
1
- import { jsx as g, jsxs as G, Fragment as K } from "react/jsx-runtime";
2
- import { QueryClient as V, QueryCache as X } from "@tanstack/react-query";
3
- import { isEmpty as J, get as _ } from "radashi";
4
- import { GraphQLClient as H } from "graphql-request";
5
- import { Box as C, WysiwygBlock as W } from "@okam/stack-ui";
6
- import $ from "react";
7
- import { Mark as x, Node as A } from "@tiptap/core";
8
- import j from "@tiptap/extension-blockquote";
9
- import Y from "@tiptap/extension-bold";
10
- import Z from "@tiptap/extension-bullet-list";
11
- import ee from "@tiptap/extension-code";
12
- import te from "@tiptap/extension-code-block";
1
+ import { jsx as k, jsxs as G, Fragment as V } from "react/jsx-runtime";
2
+ import { QueryClient as X, QueryCache as J } from "@tanstack/react-query";
3
+ import { isEmpty as W, get as v } from "radashi";
4
+ import { GraphQLClient as P } from "graphql-request";
5
+ import { Box as x, WysiwygBlock as $ } from "@okam/stack-ui";
6
+ import j from "react";
7
+ import { Mark as q, Node as I } from "@tiptap/core";
8
+ import Y from "@tiptap/extension-blockquote";
9
+ import Z from "@tiptap/extension-bold";
10
+ import ee from "@tiptap/extension-bullet-list";
11
+ import te from "@tiptap/extension-code";
12
+ import ne from "@tiptap/extension-code-block";
13
13
  import re from "@tiptap/extension-document";
14
- import ne from "@tiptap/extension-hard-break";
15
- import oe from "@tiptap/extension-heading";
16
- import ie from "@tiptap/extension-horizontal-rule";
17
- import se from "@tiptap/extension-italic";
18
- import ce from "@tiptap/extension-link";
19
- import ae from "@tiptap/extension-list-item";
20
- import le from "@tiptap/extension-ordered-list";
21
- import me from "@tiptap/extension-paragraph";
22
- import ue from "@tiptap/extension-strike";
23
- import fe from "@tiptap/extension-subscript";
14
+ import oe from "@tiptap/extension-hard-break";
15
+ import ie from "@tiptap/extension-heading";
16
+ import se from "@tiptap/extension-horizontal-rule";
17
+ import ce from "@tiptap/extension-italic";
18
+ import ae from "@tiptap/extension-link";
19
+ import le from "@tiptap/extension-list-item";
20
+ import me from "@tiptap/extension-ordered-list";
21
+ import ue from "@tiptap/extension-paragraph";
22
+ import fe from "@tiptap/extension-strike";
23
+ import pe from "@tiptap/extension-subscript";
24
24
  import de from "@tiptap/extension-superscript";
25
- import { Table as pe } from "@tiptap/extension-table";
25
+ import { Table as ge } from "@tiptap/extension-table";
26
26
  import { TableCell as ke } from "@tiptap/extension-table-cell";
27
- import { TableHeader as ge } from "@tiptap/extension-table-header";
28
- import { TableRow as ye } from "@tiptap/extension-table-row";
29
- import Ne from "@tiptap/extension-text";
30
- import be from "@tiptap/extension-text-align";
31
- function q(e, r) {
32
- return r;
27
+ import { TableHeader as ye } from "@tiptap/extension-table-header";
28
+ import { TableRow as Ne } from "@tiptap/extension-table-row";
29
+ import be from "@tiptap/extension-text";
30
+ import Te from "@tiptap/extension-text-align";
31
+ function z(e, n) {
32
+ return n;
33
33
  }
34
34
  class T {
35
- constructor(r, n, t) {
36
- this.nameSpace = "[STACK]", this.suppressConsole = !1, this.env = process.env.NODE_ENV, this.nameSpace = r ?? this.nameSpace, this.suppressConsole = t ?? this.suppressConsole, this.logger = n ?? this.internalLogger;
35
+ constructor(n, r, t) {
36
+ this.nameSpace = "[STACK]", this.suppressConsole = !1, this.env = process.env.NODE_ENV, this.nameSpace = n ?? this.nameSpace, this.suppressConsole = t ?? this.suppressConsole, this.logger = r ?? this.internalLogger;
37
37
  }
38
- internalLogger(r, n, t) {
39
- this.env !== "production" && console[n || "log"](`${this.nameSpace} ${r}`.trimStart(), t ?? "");
38
+ internalLogger(n, r, t) {
39
+ this.env !== "production" && console[r || "log"](`${this.nameSpace} ${n}`.trimStart(), t ?? "");
40
40
  }
41
- setLogger(r) {
42
- this.logger = (n, t, i) => {
43
- this.suppressConsole && this.internalLogger(n, t, i), r(n, t, i);
41
+ setLogger(n) {
42
+ this.logger = (r, t, i) => {
43
+ this.suppressConsole && this.internalLogger(r, t, i), n(r, t, i);
44
44
  };
45
45
  }
46
46
  static getInstance() {
47
47
  return T.instance || (T.instance = new T()), T.instance;
48
48
  }
49
- log(r, n, t) {
50
- this.logger(r, n, t);
49
+ log(n, r, t) {
50
+ this.logger(n, r, t);
51
51
  }
52
52
  }
53
53
  T.getInstance();
54
- const Te = (e, r, n = !1) => {
55
- const t = new T(e, r, n);
54
+ const he = (e, n, r = !1) => {
55
+ const t = new T(e, n, r);
56
56
  return t.log("Logger initialized", "info"), t;
57
- }, he = Te("[DirectusQuery]"), Be = process.env.NEXT_PUBLIC_GRAPHQL_URL, Se = process.env.NEXT_SERVER_GRAPHQL_URL, _e = process.env.NEXT_GRAPHQL_URL_ADMIN, ve = process.env.NEXT_PUBLIC_API_TOKEN ?? "", Le = process.env.NEXT_PUBLIC_API_TOKEN, Ee = new H(Se || Be, {
57
+ }, Be = he("[DirectusQuery]"), Se = process.env.NEXT_PUBLIC_GRAPHQL_URL, _e = process.env.NEXT_SERVER_GRAPHQL_URL, ve = process.env.NEXT_GRAPHQL_URL_ADMIN, Le = process.env.NEXT_PUBLIC_API_TOKEN ?? "", Ee = process.env.NEXT_PUBLIC_API_TOKEN, _ = new P(_e || Se, {
58
58
  credentials: "include",
59
59
  mode: "cors",
60
60
  fetch,
61
61
  headers: {
62
- Authorization: `Bearer ${ve}`
62
+ Authorization: `Bearer ${Le}`
63
63
  }
64
64
  });
65
- new H(_e, {
65
+ new P(ve, {
66
66
  credentials: "include",
67
67
  mode: "cors",
68
68
  fetch,
69
69
  headers: {
70
- Authorization: `Bearer ${Le}`
70
+ Authorization: `Bearer ${Ee}`
71
71
  }
72
72
  });
73
- new V({
74
- queryCache: new X({
73
+ new X({
74
+ queryCache: new J({
75
75
  onError: (e) => {
76
- he.log("QueryClient Error", "error", { error: e });
76
+ Be.log("QueryClient Error", "error", { error: e });
77
77
  }
78
78
  }),
79
79
  defaultOptions: {
@@ -82,286 +82,292 @@ new V({
82
82
  }
83
83
  }
84
84
  });
85
- function z(e, r, n = Ee) {
86
- return n.request(e, {
87
- ...r
85
+ function D(e, n, r = _) {
86
+ return r.request(e, {
87
+ ...n
88
88
  });
89
89
  }
90
90
  process.env.NEXT_PUBLIC_GRAPHQL_URL;
91
91
  process.env.NEXT_PUBLIC_API_TOKEN;
92
- function I(e) {
92
+ const F = { kind: "Document", definitions: [{ kind: "FragmentDefinition", name: { kind: "Name", value: "BlockSettings" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "block_settings" } }, selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "tokens" } }, { kind: "Field", name: { kind: "Name", value: "variant" } }] } }] };
93
+ function w(e) {
93
94
  return !!e;
94
95
  }
95
96
  function Ae(e) {
96
- const { id: r, settings: n, ...t } = e ?? {};
97
- return J(t);
97
+ const { id: n, settings: r, ...t } = e ?? {};
98
+ return W(t);
98
99
  }
99
- async function Ie(e) {
100
- const { document: r, blockKey: n, variables: t } = e;
101
- if (!r || !I(t)) return null;
102
- const i = await z(r, t);
103
- return !i || typeof i != "object" || !n ? null : i[n];
100
+ async function Ie(e, n = _) {
101
+ const { document: r, blockKey: t, variables: i } = e;
102
+ if (!r || !w(i)) return null;
103
+ const o = await D(r, i, n);
104
+ return !o || typeof o != "object" || !t ? null : o[t];
104
105
  }
105
- async function we(e) {
106
- const { document: r, item: n, blockKey: t, variables: i } = e;
107
- if (n) {
108
- if (!Ae(n))
109
- return n;
110
- const s = { id: n.id, ...i };
111
- return I(s) ? Ie({
106
+ async function we(e, n = _) {
107
+ const { document: r, item: t, blockKey: i, variables: o } = e;
108
+ if (t) {
109
+ if (!Ae(t))
110
+ return t;
111
+ const a = { id: t.id, ...o };
112
+ return w(a) ? Ie({
112
113
  ...e,
113
- variables: s
114
+ variables: a
114
115
  }) : null;
115
116
  }
116
- if (!r || !I(i)) return null;
117
- const o = await z(r, i);
118
- return !o || typeof o != "object" || !t ? null : o[t];
117
+ if (!r || !w(o)) return null;
118
+ const c = await D(r, o, n);
119
+ return !c || typeof c != "object" || !i ? null : c[i];
120
+ }
121
+ function Pe(e) {
122
+ return e instanceof P;
119
123
  }
120
- function Oe(e, ...r) {
121
- return r.reduce((t, i) => i ? { components: { ...t.components, ...i.components } } : t, e);
124
+ async function Re(e, n, r = _) {
125
+ const t = v(e, "item"), i = Pe(r), o = v(e, "document"), c = v(e, "variables"), s = await we(
126
+ {
127
+ item: t,
128
+ blockKey: n,
129
+ document: o ?? (i ? void 0 : r),
130
+ variables: c
131
+ },
132
+ i ? r : void 0
133
+ ), { tokens: a } = z(F, s == null ? void 0 : s.settings) ?? {};
134
+ return { ...s, cmsTokens: a };
135
+ }
136
+ function He(e, ...n) {
137
+ return n.reduce((t, i) => i ? { components: { ...t.components, ...i.components } } : t, e);
122
138
  }
123
- const D = { kind: "Document", definitions: [{ kind: "FragmentDefinition", name: { kind: "Name", value: "BlockSettings" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "block_settings" } }, selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "tokens" } }, { kind: "Field", name: { kind: "Name", value: "variant" } }] } }] }, Pe = (e) => {
124
- var b, k, B;
125
- const { item: r, collection: n, config: t, variables: i, defaultVariant: o, ...c } = e;
126
- if (!n || !t) return null;
127
- const s = (b = t == null ? void 0 : t.components) == null ? void 0 : b[n];
139
+ const Oe = (e) => {
140
+ var b, f, B;
141
+ const { item: n, collection: r, config: t, variables: i, defaultVariant: o, ...c } = e;
142
+ if (!r || !t) return null;
143
+ const s = (b = t == null ? void 0 : t.components) == null ? void 0 : b[r];
128
144
  if (!s) return null;
129
- const { settings: l } = r ?? {}, m = (r == null ? void 0 : r.id) ?? (i == null ? void 0 : i.id);
145
+ const { settings: a } = n ?? {}, m = (n == null ? void 0 : n.id) ?? (i == null ? void 0 : i.id);
130
146
  if (!m) return null;
131
- const { variant: d } = q(D, l) ?? {}, u = ((k = s.getVariant) == null ? void 0 : k.call(s, e)) ?? d ?? o, { default: p, document: f } = s, N = ((B = s.variants) == null ? void 0 : B[u ?? ""]) ?? p;
132
- return N ? /* @__PURE__ */ g(
147
+ const { variant: d } = z(F, a) ?? {}, p = ((f = s.getVariant) == null ? void 0 : f.call(s, e)) ?? d ?? o, { default: g, document: u } = s, N = ((B = s.variants) == null ? void 0 : B[p ?? ""]) ?? g;
148
+ return N ? /* @__PURE__ */ k(
133
149
  N,
134
150
  {
135
- document: f,
151
+ document: u,
136
152
  config: t,
137
- collection: n,
138
- item: r,
153
+ collection: r,
154
+ item: n,
139
155
  ...m ? { variables: { ...i, id: m } } : { variables: i },
140
156
  ...c
141
157
  },
142
158
  m
143
159
  ) : null;
144
- };
145
- async function Re(e, r, n) {
146
- const t = _(e, "item"), i = _(e, "document"), o = _(e, "variables"), c = await we({
147
- item: t,
148
- blockKey: r,
149
- document: i,
150
- variables: o
151
- }), { tokens: s } = q(D, c == null ? void 0 : c.settings) ?? {};
152
- return { ...c, cmsTokens: s };
153
- }
154
- const He = async (e) => {
155
- const r = "block_wysiwyg_by_id", { themeName: n = "wysiwyg", tokens: t } = e, { content: i, title: o, level: c, cmsTokens: s } = await Re(e, r);
156
- return !i && !(o && c) ? null : /* @__PURE__ */ G(K, { children: [
157
- o && c && /* @__PURE__ */ g(C, { as: "span", themeName: n, tokens: { ...t, ...s }, children: $.createElement(c, {}, o) }),
158
- i && /* @__PURE__ */ g(W, { themeName: n, tokens: { ...t, ...s }, content: i })
160
+ }, Ce = async (e) => {
161
+ const n = "block_wysiwygs_by_id", { themeName: r = "wysiwyg", tokens: t } = e, { content: i, title: o, level: c, cmsTokens: s } = await Re(e, n);
162
+ return !i && !(o && c) ? null : /* @__PURE__ */ G(V, { children: [
163
+ o && c && /* @__PURE__ */ k(x, { as: "span", themeName: r, tokens: { ...t, ...s }, children: j.createElement(c, {}, o) }),
164
+ i && /* @__PURE__ */ k($, { themeName: r, tokens: { ...t, ...s }, content: i })
159
165
  ] });
160
- }, Ce = {
161
- block_wysiwyg: {
162
- default: (e) => /* @__PURE__ */ g(He, { ...e })
163
- }
164
166
  }, xe = {
167
+ block_wysiwygs: {
168
+ default: (e) => /* @__PURE__ */ k(Ce, { ...e })
169
+ }
170
+ }, qe = {
165
171
  components: {
166
- ...Ce
172
+ ...xe
167
173
  }
168
- }, R = (e) => {
169
- const { children: r, config: n, ...t } = e, i = Oe(xe, n), o = (s) => r ? r({ ...t, ...s, config: i }) : /* @__PURE__ */ g(Pe, { ...t, ...s, config: i });
174
+ }, C = (e) => {
175
+ const { children: n, config: r, ...t } = e, i = He(qe, r), o = (s) => n ? n({ ...t, ...s, config: i }) : /* @__PURE__ */ k(Oe, { ...t, ...s, config: i });
170
176
  if ("blocks" in e) {
171
177
  const { blocks: s } = e;
172
178
  return s.map(o);
173
179
  }
174
180
  const { block: c } = e;
175
181
  return o(c);
176
- }, qe = (e, r, n = "id", t = "item") => {
182
+ }, ze = (e, n, r = "id", t = "item") => {
177
183
  const i = (o) => {
178
- var c, s, l, m, d, u;
184
+ var c, s, a, m, d, p;
179
185
  if (!e && o) return o;
180
186
  if (!o || !e) return null;
181
- if (o.type === "relation-mark" && ((c = o.attrs) != null && c.id) || o.type === "relation-block" && ((s = o.attrs) != null && s.id) || o.type === "relation-inline-block" && ((l = o.attrs) != null && l.id)) {
182
- const p = (m = e.find((f) => {
187
+ if (o.type === "relation-mark" && ((c = o.attrs) != null && c.id) || o.type === "relation-block" && ((s = o.attrs) != null && s.id) || o.type === "relation-inline-block" && ((a = o.attrs) != null && a.id)) {
188
+ const g = (m = e.find((u) => {
183
189
  var y;
184
- return (f == null ? void 0 : f[n]) === ((y = o.attrs) == null ? void 0 : y.id);
190
+ return (u == null ? void 0 : u[r]) === ((y = o.attrs) == null ? void 0 : y.id);
185
191
  })) == null ? void 0 : m[t];
186
- o.attrs.data = p;
192
+ o.attrs.data = g;
187
193
  }
188
- return (d = o.content) == null || d.map(i), (u = o.marks) == null || u.map(i), o;
194
+ return (d = o.content) == null || d.map(i), (p = o.marks) == null || p.map(i), o;
189
195
  };
190
- return i(r);
191
- }, ze = (e, r) => {
192
- const n = r.map((o) => (o.type === "mark" ? x : A).create({
196
+ return i(n);
197
+ }, De = (e, n) => {
198
+ const r = n.map((o) => (o.type === "mark" ? q : I).create({
193
199
  name: o.name,
194
200
  // eslint-disable-next-line
195
201
  renderHTML({ HTMLAttributes: s }) {
196
202
  return o.render ? [...o.render(s), 0] : [o.component ?? (o.type === "mark" ? "span" : "div"), s, 0];
197
203
  }
198
- })), t = n.map(({ name: o }) => o);
199
- return [...e.filter((o) => t.indexOf(o.name) < 0), ...n];
200
- }, F = (e, r, n) => {
201
- const t = n.find((i) => i.type === r && i.name === e);
204
+ })), t = r.map(({ name: o }) => o);
205
+ return [...e.filter((o) => t.indexOf(o.name) < 0), ...r];
206
+ }, M = (e, n, r) => {
207
+ const t = r.find((i) => i.type === n && i.name === e);
202
208
  if (t)
203
209
  return {
204
210
  ...t.config,
205
211
  options: t.options
206
212
  };
207
- }, De = (e, r) => {
213
+ }, Fe = (e, n) => {
208
214
  var t;
209
- const n = (t = r.addAttributes) == null ? void 0 : t.call(r);
210
- return !n || !e ? e : Object.fromEntries(Object.entries(e).filter(([i]) => {
215
+ const r = (t = n.addAttributes) == null ? void 0 : t.call(n);
216
+ return !r || !e ? e : Object.fromEntries(Object.entries(e).filter(([i]) => {
211
217
  var o;
212
- return ((o = n[i]) == null ? void 0 : o.rendered) !== !1;
218
+ return ((o = r[i]) == null ? void 0 : o.rendered) !== !1;
213
219
  }));
214
- }, v = (e, r, n = "node") => {
215
- const t = F(e.type, n, r);
220
+ }, L = (e, n, r = "node") => {
221
+ const t = M(e.type, r, n);
216
222
  if (!(t != null && t.renderHTML)) return [];
217
- const i = De(e.attrs, t);
223
+ const i = Fe(e.attrs, t);
218
224
  return t.render ? t.render(e) : t.renderHTML({
219
225
  node: e,
220
226
  HTMLAttributes: i
221
227
  });
222
- }, M = (e, r, n) => {
223
- if (e != null && e.content && (e.content = e.content.map((c) => M(c, r, n))), e.type === "text") {
228
+ }, Q = (e, n, r) => {
229
+ if (e != null && e.content && (e.content = e.content.map((c) => Q(c, n, r))), e.type === "text") {
224
230
  if (e.marks) {
225
231
  let c;
226
232
  return e.marks.reverse().forEach((s) => {
227
233
  var m;
228
- const l = v(
234
+ const a = L(
229
235
  { ...s, attrs: { ...s.attrs, data: { ...(m = s == null ? void 0 : s.attrs) == null ? void 0 : m.data, markText: e.text } } },
230
- r,
236
+ n,
231
237
  "mark"
232
238
  );
233
- if (Array.isArray(l)) {
234
- const [d = "span", u = s.attrs] = l, p = { ...u, data: void 0 };
235
- c = n(d, p, c || e.text);
239
+ if (Array.isArray(a)) {
240
+ const [d = "span", p = s.attrs] = a, g = { ...p, data: void 0 };
241
+ c = r(d, g, c || e.text);
236
242
  } else
237
- c = { ...l, text: e.text };
243
+ c = { ...a, text: e.text };
238
244
  }), c;
239
245
  }
240
246
  return e.text ?? "";
241
247
  }
242
- const t = F(e.type, "node", r);
248
+ const t = M(e.type, "node", n);
243
249
  if (t != null && t.render)
244
- return v(e, r);
245
- const [i = "div", o = e.attrs] = v(e, r);
246
- return n(i, o, e.content);
247
- }, Fe = (e, r, n) => M(e, r, n), L = {
250
+ return L(e, n);
251
+ const [i = "div", o = e.attrs] = L(e, n);
252
+ return r(i, o, e.content);
253
+ }, Me = (e, n, r) => Q(e, n, r), E = {
248
254
  colspan: "colSpan",
249
255
  rowspan: "rowSpan",
250
256
  textAlign: "textalign"
251
- }, Me = (e, r) => ({
257
+ }, Qe = (e, n) => ({
252
258
  ...Object.fromEntries(
253
- Object.entries(r).map(([n, t]) => [(e == null ? void 0 : e[n]) ?? (L == null ? void 0 : L[n]) ?? n, t])
259
+ Object.entries(n).map(([r, t]) => [(e == null ? void 0 : e[r]) ?? (E == null ? void 0 : E[r]) ?? r, t])
254
260
  )
255
- }), E = {}, Qe = (e) => {
261
+ }), A = {}, Ue = (e) => {
256
262
  const {
257
- content: r,
258
- serializers: n = [],
263
+ content: n,
264
+ serializers: r = [],
259
265
  componentSerializers: t = [],
260
266
  renderingNodes: i,
261
267
  remappedAttributes: o,
262
268
  themeName: c,
263
269
  tokens: s,
264
- customTheme: l
265
- } = e, m = JSON.parse(JSON.stringify(r)), d = ze(n, t);
266
- return Fe(
270
+ customTheme: a
271
+ } = e, m = JSON.parse(JSON.stringify(n)), d = De(r, t);
272
+ return Me(
267
273
  m,
268
274
  d,
269
275
  // @ts-expect-error Expects ReactNode
270
- (u, p, f) => {
276
+ (p, g, u) => {
271
277
  const y = {
272
- ...p,
278
+ ...g,
273
279
  style: void 0
274
- }, N = Me(o, y), b = (i == null ? void 0 : i[u]) ?? (E == null ? void 0 : E[u]);
275
- return b ? b({ children: f, attrs: N, themeName: c, tokens: s, customTheme: l }) : /* @__PURE__ */ g(
276
- C,
280
+ }, N = Qe(o, y), b = p, f = (i == null ? void 0 : i[b]) ?? (A == null ? void 0 : A[b]);
281
+ return f ? f({ children: u, attrs: N, themeName: c, tokens: s, customTheme: a }) : /* @__PURE__ */ k(
282
+ x,
277
283
  {
278
- as: u,
284
+ as: p,
279
285
  ...N,
280
286
  themeName: c,
281
287
  tokens: s,
282
- customTheme: l,
283
- children: f
288
+ customTheme: a,
289
+ children: u
284
290
  },
285
- JSON.stringify(f)
291
+ JSON.stringify(u)
286
292
  );
287
293
  }
288
294
  );
289
- }, Ue = [
295
+ }, Ke = [
290
296
  re,
291
- Ne,
292
- me,
293
- ne,
297
+ be,
298
+ ue,
294
299
  oe,
295
- te,
296
- Z,
297
- le,
298
- ae,
299
- j,
300
300
  ie,
301
- ce,
301
+ ne,
302
+ ee,
303
+ me,
304
+ le,
302
305
  Y,
303
306
  se,
304
- ue,
305
- ee,
306
- pe,
307
+ ae,
308
+ Z,
309
+ ce,
310
+ fe,
311
+ te,
307
312
  ge,
308
313
  ye,
314
+ Ne,
309
315
  ke,
310
- be,
311
- fe,
316
+ Te,
317
+ pe,
312
318
  de
313
- ], ht = (e) => {
319
+ ], Bt = (e) => {
314
320
  const {
315
- jsonContent: r,
316
- editorNodes: n,
321
+ jsonContent: n,
322
+ editorNodes: r,
317
323
  serializers: t,
318
324
  nodes: i,
319
325
  config: o,
320
326
  relationMarksConfig: c,
321
327
  themeName: s,
322
- tokens: l,
328
+ tokens: a,
323
329
  customTheme: m,
324
330
  remappedAttributes: d
325
- } = e, u = qe(n, r), p = t ?? [...Ue] ?? [], f = (k, B) => {
326
- var w, O, P;
327
- const { attrs: a } = k, Q = `${(w = a == null ? void 0 : a.collection) == null ? void 0 : w.replace("related_", "")}_id`;
328
- if (a != null && a.data) {
329
- if (!((O = a == null ? void 0 : a.data) != null && O.blocks)) {
330
- const h = { collection: a.collection, item: { ...a == null ? void 0 : a.data } };
331
- return /* @__PURE__ */ g(R, { block: h, config: B }, JSON.stringify(h));
331
+ } = e, p = ze(r, n), g = t ?? [...Ke] ?? [], u = (f, B) => {
332
+ var R, H, O;
333
+ const { attrs: l } = f, U = `${(R = l == null ? void 0 : l.collection) == null ? void 0 : R.replace("related_", "")}_id`;
334
+ if (l != null && l.data) {
335
+ if (!((H = l == null ? void 0 : l.data) != null && H.blocks)) {
336
+ const h = { collection: l.collection, item: { ...l == null ? void 0 : l.data } };
337
+ return /* @__PURE__ */ k(C, { block: h, config: B }, JSON.stringify(h));
332
338
  }
333
- const S = (P = a == null ? void 0 : a.data) == null ? void 0 : P.blocks, U = S == null ? void 0 : S.map((h) => ({ item: h == null ? void 0 : h[Q], collection: a == null ? void 0 : a.collection }));
334
- return /* @__PURE__ */ g(R, { blocks: U, config: B }, JSON.stringify(S));
339
+ const S = (O = l == null ? void 0 : l.data) == null ? void 0 : O.blocks, K = S == null ? void 0 : S.map((h) => ({ item: h == null ? void 0 : h[U], collection: l == null ? void 0 : l.collection }));
340
+ return /* @__PURE__ */ k(C, { blocks: K, config: B }, JSON.stringify(S));
335
341
  }
336
342
  return null;
337
- }, y = A.create({
343
+ }, y = I.create({
338
344
  name: "relation-block",
339
345
  renderHTML: () => ["relation-block"],
340
- render: (k) => f(k, o)
341
- }), N = A.create({
346
+ render: (f) => u(f, o)
347
+ }), N = I.create({
342
348
  name: "relation-inline-block",
343
349
  renderHTML: () => ["relation-inline-block"],
344
- render: (k) => f(k, o)
345
- }), b = x.create({
350
+ render: (f) => u(f, o)
351
+ }), b = q.create({
346
352
  name: "relation-mark",
347
353
  type: "relation-mark",
348
354
  renderHTML: () => ["relation-mark"],
349
- render: (k) => f(k, c)
355
+ render: (f) => u(f, c)
350
356
  });
351
- return p.push(y, N, b), u ? /* @__PURE__ */ g(
352
- Qe,
357
+ return g.push(y, N, b), p ? /* @__PURE__ */ k(
358
+ Ue,
353
359
  {
354
- content: u,
355
- serializers: p,
360
+ content: p,
361
+ serializers: g,
356
362
  renderingNodes: i,
357
363
  themeName: s,
358
- tokens: l,
364
+ tokens: a,
359
365
  customTheme: m,
360
366
  remappedAttributes: d
361
367
  }
362
368
  ) : null;
363
369
  };
364
370
  export {
365
- ht as FlexibleEditorContent,
366
- Qe as RenderNodes
371
+ Bt as FlexibleEditorContent,
372
+ Ue as RenderNodes
367
373
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-subscript").SubscriptExtensionOptions, any>)[];
1
+ declare const _default: (import('@tiptap/core').Node<any, any> | import('@tiptap/core').Extension<import('@tiptap/extension-text-align').TextAlignOptions, any> | import('@tiptap/core').Mark<import('@tiptap/extension-subscript').SubscriptExtensionOptions, any>)[];
2
2
  export default _default;
@@ -1,7 +1,8 @@
1
- import type { TBlockSerializerConfig } from '@okam/directus-block';
2
- import type { TDefaultComponent } from '@okam/stack-ui';
3
- import type { JSONContent, Extensions, EditorNodes } from '../../functions/types';
4
- import type { TRenderingNodes } from '../nodes/types';
1
+ import { TBlockSerializerConfig } from '../../../../../directus-block/src/index.ts';
2
+ import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
3
+ import { JSONContent, Extensions, EditorNodes } from '../../functions/types';
4
+ import { TRenderingNodes } from '../nodes/types';
5
+
5
6
  interface FlexibleEditorContentProps extends TDefaultComponent {
6
7
  jsonContent: JSONContent;
7
8
  editorNodes?: EditorNodes[] | undefined | null;
@@ -1,7 +1,8 @@
1
- import type { TDefaultComponent } from '@okam/stack-ui';
2
- import type { FunctionComponent } from 'react';
3
- import type { JSONContent, Extensions, ReactComponentSerializers } from '../../functions/types';
4
- import type { TRenderingNodes } from '../nodes/types';
1
+ import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
2
+ import { ReactNode } from 'react';
3
+ import { JSONContent, Extensions, ReactComponentSerializers } from '../../functions/types';
4
+ import { TRenderingNodes } from '../nodes/types';
5
+
5
6
  interface RenderNodesProps extends TDefaultComponent {
6
7
  content: JSONContent;
7
8
  serializers?: Extensions;
@@ -9,5 +10,5 @@ interface RenderNodesProps extends TDefaultComponent {
9
10
  renderingNodes?: TRenderingNodes;
10
11
  remappedAttributes?: Record<string, string>;
11
12
  }
12
- declare const RenderNodes: FunctionComponent<RenderNodesProps>;
13
+ declare const RenderNodes: (props: RenderNodesProps) => ReactNode;
13
14
  export default RenderNodes;
@@ -1,3 +1,4 @@
1
- import type { TRenderingNodes } from './types';
1
+ import { TRenderingNodes } from './types';
2
+
2
3
  declare const nodes: TRenderingNodes;
3
4
  export default nodes;
@@ -1,8 +1,10 @@
1
- import type { TDefaultComponent } from '@okam/stack-ui';
1
+ import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
2
+ import { default as React } from 'react';
3
+
2
4
  export interface TBaseRenderingNode extends TDefaultComponent {
3
5
  children: React.ReactNode;
4
6
  attrs?: Record<string, number | string | boolean | undefined>;
5
7
  }
6
8
  export type TRenderingNodes = {
7
- [key in keyof JSX.IntrinsicElements]?: (props: TBaseRenderingNode) => JSX.Element;
9
+ [key in keyof React.JSX.IntrinsicElements]?: (props: TBaseRenderingNode) => React.JSX.Element;
8
10
  };
@@ -1,4 +1,5 @@
1
- import type { JSONContent } from '@tiptap/core';
2
- import type { EditorNodes } from './types';
1
+ import { JSONContent } from '@tiptap/core';
2
+ import { EditorNodes } from './types';
3
+
3
4
  declare const injectDataIntoContent: (data: EditorNodes[] | undefined | null, content: JSONContent, primaryKeyField?: string, itemField?: string) => JSONContent | null;
4
5
  export default injectDataIntoContent;
@@ -1,3 +1,4 @@
1
- import type { Extensions, ComponentSerializers } from './types';
1
+ import { Extensions, ComponentSerializers } from './types';
2
+
2
3
  declare const mergeSerializers: <T>(serializers: Extensions, componentSerializers: ComponentSerializers<T>) => Extensions;
3
4
  export default mergeSerializers;
@@ -1,4 +1,5 @@
1
- import type { ReactNode } from 'react';
2
- import type { JSONContent, Extensions, RenderedNode, RenderCallback } from './types';
1
+ import { ReactNode } from 'react';
2
+ import { JSONContent, Extensions, RenderedNode, RenderCallback } from './types';
3
+
3
4
  declare const renderView: <T>(node: JSONContent, serializers: Extensions, renderCallback: RenderCallback<ReactNode | JSONContent[]>) => RenderedNode<T>;
4
5
  export default renderView;
@@ -1,6 +1,7 @@
1
- import type { TBlock } from '@okam/directus-block';
2
- import type { JSONContent, Extensions, AnyExtension } from '@tiptap/core';
3
- import type { ElementType, FunctionComponent, ReactNode } from 'react';
1
+ import { TBlock } from '../../../../directus-block/src/index.ts';
2
+ import { JSONContent, Extensions, AnyExtension } from '@tiptap/core';
3
+ import { ElementType, FunctionComponent, ReactNode } from 'react';
4
+
4
5
  export type { JSONContent, Extensions };
5
6
  export type RenderedNode<T> = T | string | (T | string)[];
6
7
  export type Tag = ElementType;
package/lib/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { TCommonBlockFragment } from '@okam/directus-block';
1
+ import { TCommonBlockFragment } from '../../../directus-block/src/index.ts';
2
+
2
3
  export type RelationBlockSerializers<T> = {
3
4
  collection: string;
4
5
  component: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/directus-flexible-content",
3
- "version": "1.2.23",
3
+ "version": "1.2.25",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@nx/vite": "20.2.2",
26
- "@okam/directus-block": "1.6.1",
27
- "@okam/stack-ui": "1.42.4",
26
+ "@okam/directus-block": "1.6.3",
27
+ "@okam/stack-ui": "1.44.0",
28
28
  "@vitejs/plugin-react": "4.3.4",
29
29
  "vite": "^5.0.13",
30
30
  "vite-plugin-dts": "~2.3.0",
@@ -51,7 +51,12 @@
51
51
  "@tiptap/extension-table-row": "^2.10.3",
52
52
  "@tiptap/extension-text": "^2.10.3",
53
53
  "@tiptap/extension-text-align": "^2.10.3",
54
- "@tiptap/core": "^2.10.3",
55
- "react": "18.3.1"
54
+ "@tiptap/core": "^2.10.3"
55
+ },
56
+ "peerDependencies": {
57
+ "react": "^18.0.0 || ^19.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "react": "^19.0.0"
56
61
  }
57
62
  }