@okam/directus-flexible-content 1.2.25 → 1.3.2

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,4 +1,11 @@
1
- ## 1.2.25 (2026-01-14)
1
+ ## 1.3.2 (2026-01-16)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated stack-ui to 1.44.1
6
+ - Updated directus-block to 1.7.2
7
+
8
+ ## 1.3.0 (2026-01-16)
2
9
 
3
10
  ### 🚀 Features
4
11
 
@@ -7,6 +14,8 @@
7
14
 
8
15
  ### 🩹 Fixes
9
16
 
17
+ - **directus-flexible-content:** remove breaking changes tag ([37954b3](https://github.com/OKAMca/stack/commit/37954b3))
18
+ - **directus-flexible-content:** stop bundling okam libs ([cc8cfed](https://github.com/OKAMca/stack/commit/cc8cfed))
10
19
  - **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
11
20
  - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
12
21
  - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
@@ -18,6 +27,58 @@
18
27
 
19
28
  - Consumers must now have react and react-dom in their own
20
29
 
30
+ ### ❤️ Thank You
31
+
32
+ - Marie-Maxime Tanguay @marie-maxime
33
+ - Pierre-Olivier Clerson @poclerson
34
+ - poclerson
35
+
36
+ ## 1.2.26 (2026-01-16)
37
+
38
+ ### 🚀 Features
39
+
40
+ - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
41
+ - bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
42
+ - Consumers must now have react and react-dom in their own
43
+
44
+ ### 🩹 Fixes
45
+
46
+ - **directus-flexible-content:** remove breaking changes tag ([37954b3](https://github.com/OKAMca/stack/commit/37954b3))
47
+ - **directus-flexible-content:** stop bundling okam libs ([cc8cfed](https://github.com/OKAMca/stack/commit/cc8cfed))
48
+ - **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
49
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
50
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
51
+ - search field type export ([5ab6070](https://github.com/OKAMca/stack/commit/5ab6070))
52
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
53
+ - select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
54
+
55
+ ### 🧱 Updated Dependencies
56
+
57
+ - Updated directus-block to 1.7.0
58
+
59
+ ### ❤️ Thank You
60
+
61
+ - Marie-Maxime Tanguay @marie-maxime
62
+ - Pierre-Olivier Clerson @poclerson
63
+ - poclerson
64
+
65
+ ## 1.2.25 (2026-01-14)
66
+
67
+ ### 🚀 Features
68
+
69
+ - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
70
+ - Consumers must now have react and react-dom in their own
71
+ - bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
72
+
73
+ ### 🩹 Fixes
74
+
75
+ - **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
76
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
77
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
78
+ - search field type export ([5ab6070](https://github.com/OKAMca/stack/commit/5ab6070))
79
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
80
+ - select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
81
+
21
82
  ### 🧱 Updated Dependencies
22
83
 
23
84
  - Updated stack-ui to 1.44.0
@@ -652,4 +713,4 @@
652
713
 
653
714
  # 1.0.0 (2024-07-08)
654
715
 
655
- This was a version bump only for directus-flexible-content to align it with other projects, there were no code changes.
716
+ This was a version bump only for directus-flexible-content to align it with other projects, there were no code changes.
package/index.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),A=require("@okam/directus-block/server"),x=require("@tiptap/core"),E=require("@okam/stack-ui"),J=require("@tiptap/extension-blockquote"),D=require("@tiptap/extension-bold"),_=require("@tiptap/extension-bullet-list"),j=require("@tiptap/extension-code"),F=require("@tiptap/extension-code-block"),K=require("@tiptap/extension-document"),P=require("@tiptap/extension-hard-break"),U=require("@tiptap/extension-heading"),V=require("@tiptap/extension-horizontal-rule"),W=require("@tiptap/extension-italic"),$=require("@tiptap/extension-link"),G=require("@tiptap/extension-list-item"),Q=require("@tiptap/extension-ordered-list"),X=require("@tiptap/extension-paragraph"),Y=require("@tiptap/extension-strike"),Z=require("@tiptap/extension-subscript"),C=require("@tiptap/extension-superscript"),ee=require("@tiptap/extension-table"),re=require("@tiptap/extension-table-cell"),te=require("@tiptap/extension-table-header"),ne=require("@tiptap/extension-table-row"),oe=require("@tiptap/extension-text"),ie=require("@tiptap/extension-text-align"),ce=(e,n,o="id",t="item")=>{const i=r=>{var a,s,l,f,m,d;if(!e&&r)return r;if(!r||!e)return null;if(r.type==="relation-mark"&&((a=r.attrs)!=null&&a.id)||r.type==="relation-block"&&((s=r.attrs)!=null&&s.id)||r.type==="relation-inline-block"&&((l=r.attrs)!=null&&l.id)){const b=(f=e.find(u=>{var k;return(u==null?void 0:u[o])===((k=r.attrs)==null?void 0:k.id)}))==null?void 0:f[t];r.attrs.data=b}return(m=r.content)==null||m.map(i),(d=r.marks)==null||d.map(i),r};return i(n)},se=(e,n)=>{const o=n.map(r=>(r.type==="mark"?x.Mark:x.Node).create({name:r.name,renderHTML({HTMLAttributes:s}){return r.render?[...r.render(s),0]:[r.component??(r.type==="mark"?"span":"div"),s,0]}})),t=o.map(({name:r})=>r);return[...e.filter(r=>t.indexOf(r.name)<0),...o]},v=(e,n,o)=>{const t=o.find(i=>i.type===n&&i.name===e);if(t)return{...t.config,options:t.options}},ae=(e,n)=>{var t;const o=(t=n.addAttributes)==null?void 0:t.call(n);return!o||!e?e:Object.fromEntries(Object.entries(e).filter(([i])=>{var r;return((r=o[i])==null?void 0:r.rendered)!==!1}))},N=(e,n,o="node")=>{const t=v(e.type,o,n);if(!(t!=null&&t.renderHTML))return[];const i=ae(e.attrs,t);return t.render?t.render(e):t.renderHTML({node:e,HTMLAttributes:i})},h=(e,n,o)=>{if(e!=null&&e.content&&(e.content=e.content.map(a=>h(a,n,o))),e.type==="text"){if(e.marks){let a;return e.marks.reverse().forEach(s=>{var f;const l=N({...s,attrs:{...s.attrs,data:{...(f=s==null?void 0:s.attrs)==null?void 0:f.data,markText:e.text}}},n,"mark");if(Array.isArray(l)){const[m="span",d=s.attrs]=l,b={...d,data:void 0};a=o(m,b,a||e.text)}else a={...l,text:e.text}}),a}return e.text??""}const t=v(e.type,"node",n);if(t!=null&&t.render)return N(e,n);const[i="div",r=e.attrs]=N(e,n);return o(i,r,e.content)},le=(e,n,o)=>h(e,n,o),B={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},ue=(e,n)=>({...Object.fromEntries(Object.entries(n).map(([o,t])=>[(e==null?void 0:e[o])??(B==null?void 0:B[o])??o,t]))}),H={},I=e=>{const{content:n,serializers:o=[],componentSerializers:t=[],renderingNodes:i,remappedAttributes:r,themeName:a,tokens:s,customTheme:l}=e,f=JSON.parse(JSON.stringify(n)),m=se(o,t);return le(f,m,(d,b,u)=>{const k={...b,style:void 0},S=ue(r,k),T=d,p=(i==null?void 0:i[T])??(H==null?void 0:H[T]);return p?p({children:u,attrs:S,themeName:a,tokens:s,customTheme:l}):y.jsx(E.Box,{as:d,...S,themeName:a,tokens:s,customTheme:l,children:u},JSON.stringify(u))})},de=[K,oe,X,P,U,F,_,Q,G,J,V,$,D,W,Y,j,ee.Table,te.TableHeader,ne.TableRow,re.TableCell,ie,Z,C],pe=e=>{const{jsonContent:n,editorNodes:o,serializers:t,nodes:i,config:r,relationMarksConfig:a,themeName:s,tokens:l,customTheme:f,remappedAttributes:m}=e,d=ce(o,n),b=t??[...de]??[],u=(p,M)=>{var O,L,z;const{attrs:c}=p,R=`${(O=c==null?void 0:c.collection)==null?void 0:O.replace("related_","")}_id`;if(c!=null&&c.data){if(!((L=c==null?void 0:c.data)!=null&&L.blocks)){const q={collection:c.collection,item:{...c==null?void 0:c.data}};return y.jsx(A.BlockDispatcher,{block:q,config:M},JSON.stringify(q))}const g=(z=c==null?void 0:c.data)==null?void 0:z.blocks,w=g==null?void 0:g.map(q=>({item:q==null?void 0:q[R],collection:c==null?void 0:c.collection}));return y.jsx(A.BlockDispatcher,{blocks:w,config:M},JSON.stringify(g))}return null},k=x.Node.create({name:"relation-block",renderHTML:()=>["relation-block"],render:p=>u(p,r)}),S=x.Node.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:p=>u(p,r)}),T=x.Mark.create({name:"relation-mark",type:"relation-mark",renderHTML:()=>["relation-mark"],render:p=>u(p,a)});return b.push(k,S,T),d?y.jsx(I,{content:d,serializers:b,renderingNodes:i,themeName:s,tokens:l,customTheme:f,remappedAttributes:m}):null};exports.FlexibleEditorContent=pe;exports.RenderNodes=I;
package/index.mjs CHANGED
@@ -1,373 +1,219 @@
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
- import re from "@tiptap/extension-document";
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
- import de from "@tiptap/extension-superscript";
25
- import { Table as ge } from "@tiptap/extension-table";
26
- import { TableCell as ke } from "@tiptap/extension-table-cell";
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
- }
34
- class T {
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
- }
38
- internalLogger(n, r, t) {
39
- this.env !== "production" && console[r || "log"](`${this.nameSpace} ${n}`.trimStart(), t ?? "");
40
- }
41
- setLogger(n) {
42
- this.logger = (r, t, i) => {
43
- this.suppressConsole && this.internalLogger(r, t, i), n(r, t, i);
44
- };
45
- }
46
- static getInstance() {
47
- return T.instance || (T.instance = new T()), T.instance;
48
- }
49
- log(n, r, t) {
50
- this.logger(n, r, t);
51
- }
52
- }
53
- T.getInstance();
54
- const he = (e, n, r = !1) => {
55
- const t = new T(e, n, r);
56
- return t.log("Logger initialized", "info"), t;
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
- credentials: "include",
59
- mode: "cors",
60
- fetch,
61
- headers: {
62
- Authorization: `Bearer ${Le}`
63
- }
64
- });
65
- new P(ve, {
66
- credentials: "include",
67
- mode: "cors",
68
- fetch,
69
- headers: {
70
- Authorization: `Bearer ${Ee}`
71
- }
72
- });
73
- new X({
74
- queryCache: new J({
75
- onError: (e) => {
76
- Be.log("QueryClient Error", "error", { error: e });
77
- }
78
- }),
79
- defaultOptions: {
80
- queries: {
81
- staleTime: 5 * 1e3
1
+ import { jsx as x } from "react/jsx-runtime";
2
+ import { BlockDispatcher as h } from "@okam/directus-block/server";
3
+ import { Mark as v, Node as L } from "@tiptap/core";
4
+ import { Box as R } from "@okam/stack-ui";
5
+ import D from "@tiptap/extension-blockquote";
6
+ import _ from "@tiptap/extension-bold";
7
+ import K from "@tiptap/extension-bullet-list";
8
+ import q from "@tiptap/extension-code";
9
+ import F from "@tiptap/extension-code-block";
10
+ import P from "@tiptap/extension-document";
11
+ import V from "@tiptap/extension-hard-break";
12
+ import W from "@tiptap/extension-heading";
13
+ import $ from "@tiptap/extension-horizontal-rule";
14
+ import G from "@tiptap/extension-italic";
15
+ import Q from "@tiptap/extension-link";
16
+ import U from "@tiptap/extension-list-item";
17
+ import X from "@tiptap/extension-ordered-list";
18
+ import Y from "@tiptap/extension-paragraph";
19
+ import Z from "@tiptap/extension-strike";
20
+ import j from "@tiptap/extension-subscript";
21
+ import C from "@tiptap/extension-superscript";
22
+ import { Table as rr } from "@tiptap/extension-table";
23
+ import { TableCell as tr } from "@tiptap/extension-table-cell";
24
+ import { TableHeader as er } from "@tiptap/extension-table-header";
25
+ import { TableRow as or } from "@tiptap/extension-table-row";
26
+ import nr from "@tiptap/extension-text";
27
+ import ir from "@tiptap/extension-text-align";
28
+ const cr = (r, o, n = "id", e = "item") => {
29
+ const i = (t) => {
30
+ var s, a, m, u, d, p;
31
+ if (!r && t) return t;
32
+ if (!t || !r) return null;
33
+ if (t.type === "relation-mark" && ((s = t.attrs) != null && s.id) || t.type === "relation-block" && ((a = t.attrs) != null && a.id) || t.type === "relation-inline-block" && ((m = t.attrs) != null && m.id)) {
34
+ const k = (u = r.find((l) => {
35
+ var b;
36
+ return (l == null ? void 0 : l[n]) === ((b = t.attrs) == null ? void 0 : b.id);
37
+ })) == null ? void 0 : u[e];
38
+ t.attrs.data = k;
82
39
  }
83
- }
84
- });
85
- function D(e, n, r = _) {
86
- return r.request(e, {
87
- ...n
88
- });
89
- }
90
- process.env.NEXT_PUBLIC_GRAPHQL_URL;
91
- process.env.NEXT_PUBLIC_API_TOKEN;
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) {
94
- return !!e;
95
- }
96
- function Ae(e) {
97
- const { id: n, settings: r, ...t } = e ?? {};
98
- return W(t);
99
- }
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];
105
- }
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({
113
- ...e,
114
- variables: a
115
- }) : null;
116
- }
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;
123
- }
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);
138
- }
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];
144
- if (!s) return null;
145
- const { settings: a } = n ?? {}, m = (n == null ? void 0 : n.id) ?? (i == null ? void 0 : i.id);
146
- if (!m) return null;
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(
149
- N,
150
- {
151
- document: u,
152
- config: t,
153
- collection: r,
154
- item: n,
155
- ...m ? { variables: { ...i, id: m } } : { variables: i },
156
- ...c
157
- },
158
- m
159
- ) : null;
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 })
165
- ] });
166
- }, xe = {
167
- block_wysiwygs: {
168
- default: (e) => /* @__PURE__ */ k(Ce, { ...e })
169
- }
170
- }, qe = {
171
- components: {
172
- ...xe
173
- }
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 });
176
- if ("blocks" in e) {
177
- const { blocks: s } = e;
178
- return s.map(o);
179
- }
180
- const { block: c } = e;
181
- return o(c);
182
- }, ze = (e, n, r = "id", t = "item") => {
183
- const i = (o) => {
184
- var c, s, a, m, d, p;
185
- if (!e && o) return o;
186
- if (!o || !e) return null;
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) => {
189
- var y;
190
- return (u == null ? void 0 : u[r]) === ((y = o.attrs) == null ? void 0 : y.id);
191
- })) == null ? void 0 : m[t];
192
- o.attrs.data = g;
193
- }
194
- return (d = o.content) == null || d.map(i), (p = o.marks) == null || p.map(i), o;
40
+ return (d = t.content) == null || d.map(i), (p = t.marks) == null || p.map(i), t;
195
41
  };
196
- return i(n);
197
- }, De = (e, n) => {
198
- const r = n.map((o) => (o.type === "mark" ? q : I).create({
199
- name: o.name,
42
+ return i(o);
43
+ }, ar = (r, o) => {
44
+ const n = o.map((t) => (t.type === "mark" ? v : L).create({
45
+ name: t.name,
200
46
  // eslint-disable-next-line
201
- renderHTML({ HTMLAttributes: s }) {
202
- return o.render ? [...o.render(s), 0] : [o.component ?? (o.type === "mark" ? "span" : "div"), s, 0];
47
+ renderHTML({ HTMLAttributes: a }) {
48
+ return t.render ? [...t.render(a), 0] : [t.component ?? (t.type === "mark" ? "span" : "div"), a, 0];
203
49
  }
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);
208
- if (t)
50
+ })), e = n.map(({ name: t }) => t);
51
+ return [...r.filter((t) => e.indexOf(t.name) < 0), ...n];
52
+ }, I = (r, o, n) => {
53
+ const e = n.find((i) => i.type === o && i.name === r);
54
+ if (e)
209
55
  return {
210
- ...t.config,
211
- options: t.options
56
+ ...e.config,
57
+ options: e.options
212
58
  };
213
- }, Fe = (e, n) => {
214
- var t;
215
- const r = (t = n.addAttributes) == null ? void 0 : t.call(n);
216
- return !r || !e ? e : Object.fromEntries(Object.entries(e).filter(([i]) => {
217
- var o;
218
- return ((o = r[i]) == null ? void 0 : o.rendered) !== !1;
59
+ }, sr = (r, o) => {
60
+ var e;
61
+ const n = (e = o.addAttributes) == null ? void 0 : e.call(o);
62
+ return !n || !r ? r : Object.fromEntries(Object.entries(r).filter(([i]) => {
63
+ var t;
64
+ return ((t = n[i]) == null ? void 0 : t.rendered) !== !1;
219
65
  }));
220
- }, L = (e, n, r = "node") => {
221
- const t = M(e.type, r, n);
222
- if (!(t != null && t.renderHTML)) return [];
223
- const i = Fe(e.attrs, t);
224
- return t.render ? t.render(e) : t.renderHTML({
225
- node: e,
66
+ }, N = (r, o, n = "node") => {
67
+ const e = I(r.type, n, o);
68
+ if (!(e != null && e.renderHTML)) return [];
69
+ const i = sr(r.attrs, e);
70
+ return e.render ? e.render(r) : e.renderHTML({
71
+ node: r,
226
72
  HTMLAttributes: i
227
73
  });
228
- }, Q = (e, n, r) => {
229
- if (e != null && e.content && (e.content = e.content.map((c) => Q(c, n, r))), e.type === "text") {
230
- if (e.marks) {
231
- let c;
232
- return e.marks.reverse().forEach((s) => {
233
- var m;
234
- const a = L(
235
- { ...s, attrs: { ...s.attrs, data: { ...(m = s == null ? void 0 : s.attrs) == null ? void 0 : m.data, markText: e.text } } },
236
- n,
74
+ }, J = (r, o, n) => {
75
+ if (r != null && r.content && (r.content = r.content.map((s) => J(s, o, n))), r.type === "text") {
76
+ if (r.marks) {
77
+ let s;
78
+ return r.marks.reverse().forEach((a) => {
79
+ var u;
80
+ const m = N(
81
+ { ...a, attrs: { ...a.attrs, data: { ...(u = a == null ? void 0 : a.attrs) == null ? void 0 : u.data, markText: r.text } } },
82
+ o,
237
83
  "mark"
238
84
  );
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);
85
+ if (Array.isArray(m)) {
86
+ const [d = "span", p = a.attrs] = m, k = { ...p, data: void 0 };
87
+ s = n(d, k, s || r.text);
242
88
  } else
243
- c = { ...a, text: e.text };
244
- }), c;
89
+ s = { ...m, text: r.text };
90
+ }), s;
245
91
  }
246
- return e.text ?? "";
92
+ return r.text ?? "";
247
93
  }
248
- const t = M(e.type, "node", n);
249
- if (t != null && t.render)
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 = {
94
+ const e = I(r.type, "node", o);
95
+ if (e != null && e.render)
96
+ return N(r, o);
97
+ const [i = "div", t = r.attrs] = N(r, o);
98
+ return n(i, t, r.content);
99
+ }, mr = (r, o, n) => J(r, o, n), B = {
254
100
  colspan: "colSpan",
255
101
  rowspan: "rowSpan",
256
102
  textAlign: "textalign"
257
- }, Qe = (e, n) => ({
103
+ }, lr = (r, o) => ({
258
104
  ...Object.fromEntries(
259
- Object.entries(n).map(([r, t]) => [(e == null ? void 0 : e[r]) ?? (E == null ? void 0 : E[r]) ?? r, t])
105
+ Object.entries(o).map(([n, e]) => [(r == null ? void 0 : r[n]) ?? (B == null ? void 0 : B[n]) ?? n, e])
260
106
  )
261
- }), A = {}, Ue = (e) => {
107
+ }), H = {}, pr = (r) => {
262
108
  const {
263
- content: n,
264
- serializers: r = [],
265
- componentSerializers: t = [],
109
+ content: o,
110
+ serializers: n = [],
111
+ componentSerializers: e = [],
266
112
  renderingNodes: i,
267
- remappedAttributes: o,
268
- themeName: c,
269
- tokens: s,
270
- customTheme: a
271
- } = e, m = JSON.parse(JSON.stringify(n)), d = De(r, t);
272
- return Me(
273
- m,
113
+ remappedAttributes: t,
114
+ themeName: s,
115
+ tokens: a,
116
+ customTheme: m
117
+ } = r, u = JSON.parse(JSON.stringify(o)), d = ar(n, e);
118
+ return mr(
119
+ u,
274
120
  d,
275
121
  // @ts-expect-error Expects ReactNode
276
- (p, g, u) => {
277
- const y = {
278
- ...g,
122
+ (p, k, l) => {
123
+ const b = {
124
+ ...k,
279
125
  style: void 0
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,
126
+ }, g = lr(t, b), y = p, f = (i == null ? void 0 : i[y]) ?? (H == null ? void 0 : H[y]);
127
+ return f ? f({ children: l, attrs: g, themeName: s, tokens: a, customTheme: m }) : /* @__PURE__ */ x(
128
+ R,
283
129
  {
284
130
  as: p,
285
- ...N,
286
- themeName: c,
287
- tokens: s,
288
- customTheme: a,
289
- children: u
131
+ ...g,
132
+ themeName: s,
133
+ tokens: a,
134
+ customTheme: m,
135
+ children: l
290
136
  },
291
- JSON.stringify(u)
137
+ JSON.stringify(l)
292
138
  );
293
139
  }
294
140
  );
295
- }, Ke = [
296
- re,
297
- be,
298
- ue,
299
- oe,
300
- ie,
301
- ne,
302
- ee,
303
- me,
304
- le,
141
+ }, fr = [
142
+ P,
143
+ nr,
305
144
  Y,
306
- se,
307
- ae,
145
+ V,
146
+ W,
147
+ F,
148
+ K,
149
+ X,
150
+ U,
151
+ D,
152
+ $,
153
+ Q,
154
+ _,
155
+ G,
308
156
  Z,
309
- ce,
310
- fe,
311
- te,
312
- ge,
313
- ye,
314
- Ne,
315
- ke,
316
- Te,
317
- pe,
318
- de
319
- ], Bt = (e) => {
157
+ q,
158
+ rr,
159
+ er,
160
+ or,
161
+ tr,
162
+ ir,
163
+ j,
164
+ C
165
+ ], Fr = (r) => {
320
166
  const {
321
- jsonContent: n,
322
- editorNodes: r,
323
- serializers: t,
167
+ jsonContent: o,
168
+ editorNodes: n,
169
+ serializers: e,
324
170
  nodes: i,
325
- config: o,
326
- relationMarksConfig: c,
327
- themeName: s,
328
- tokens: a,
329
- customTheme: m,
171
+ config: t,
172
+ relationMarksConfig: s,
173
+ themeName: a,
174
+ tokens: m,
175
+ customTheme: u,
330
176
  remappedAttributes: d
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));
177
+ } = r, p = cr(n, o), k = e ?? [...fr] ?? [], l = (f, O) => {
178
+ var z, A, M;
179
+ const { attrs: c } = f, w = `${(z = c == null ? void 0 : c.collection) == null ? void 0 : z.replace("related_", "")}_id`;
180
+ if (c != null && c.data) {
181
+ if (!((A = c == null ? void 0 : c.data) != null && A.blocks)) {
182
+ const S = { collection: c.collection, item: { ...c == null ? void 0 : c.data } };
183
+ return /* @__PURE__ */ x(h, { block: S, config: O }, JSON.stringify(S));
338
184
  }
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));
185
+ const T = (M = c == null ? void 0 : c.data) == null ? void 0 : M.blocks, E = T == null ? void 0 : T.map((S) => ({ item: S == null ? void 0 : S[w], collection: c == null ? void 0 : c.collection }));
186
+ return /* @__PURE__ */ x(h, { blocks: E, config: O }, JSON.stringify(T));
341
187
  }
342
188
  return null;
343
- }, y = I.create({
189
+ }, b = L.create({
344
190
  name: "relation-block",
345
191
  renderHTML: () => ["relation-block"],
346
- render: (f) => u(f, o)
347
- }), N = I.create({
192
+ render: (f) => l(f, t)
193
+ }), g = L.create({
348
194
  name: "relation-inline-block",
349
195
  renderHTML: () => ["relation-inline-block"],
350
- render: (f) => u(f, o)
351
- }), b = q.create({
196
+ render: (f) => l(f, t)
197
+ }), y = v.create({
352
198
  name: "relation-mark",
353
199
  type: "relation-mark",
354
200
  renderHTML: () => ["relation-mark"],
355
- render: (f) => u(f, c)
201
+ render: (f) => l(f, s)
356
202
  });
357
- return g.push(y, N, b), p ? /* @__PURE__ */ k(
358
- Ue,
203
+ return k.push(b, g, y), p ? /* @__PURE__ */ x(
204
+ pr,
359
205
  {
360
206
  content: p,
361
- serializers: g,
207
+ serializers: k,
362
208
  renderingNodes: i,
363
- themeName: s,
364
- tokens: a,
365
- customTheme: m,
209
+ themeName: a,
210
+ tokens: m,
211
+ customTheme: u,
366
212
  remappedAttributes: d
367
213
  }
368
214
  ) : null;
369
215
  };
370
216
  export {
371
- Bt as FlexibleEditorContent,
372
- Ue as RenderNodes
217
+ Fr as FlexibleEditorContent,
218
+ pr as RenderNodes
373
219
  };
@@ -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').Mark<import('@tiptap/extension-bold').BoldOptions, any> | import('@tiptap/core').Extension<import('@tiptap/extension-text-align').TextAlignOptions, any>)[];
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/directus-flexible-content",
3
- "version": "1.2.25",
3
+ "version": "1.3.2",
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.3",
27
- "@okam/stack-ui": "1.44.0",
26
+ "@okam/directus-block": "1.7.2",
27
+ "@okam/stack-ui": "1.44.1",
28
28
  "@vitejs/plugin-react": "4.3.4",
29
29
  "vite": "^5.0.13",
30
30
  "vite-plugin-dts": "~2.3.0",