@okam/directus-flexible-content 1.3.2 → 1.3.8

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,41 @@
1
+ ## 1.3.8 (2026-01-21)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated stack-ui to 1.44.4
6
+ - Updated directus-block to 1.7.8
7
+
8
+ ## 1.3.6 (2026-01-19)
9
+
10
+ ### 🧱 Updated Dependencies
11
+
12
+ - Updated stack-ui to 1.44.2
13
+ - Updated directus-block to 1.7.5
14
+
15
+ ## 1.3.4 (2026-01-19)
16
+
17
+ ### 🩹 Fixes
18
+
19
+ - cross-lib type imports are always absolute ([#392](https://github.com/OKAMca/stack/pull/392))
20
+
21
+ ### ❤️ Thank You
22
+
23
+ - Pierre-Olivier Clerson @poclerson
24
+
25
+ ## 1.3.3 (2026-01-19)
26
+
27
+ ### 🩹 Fixes
28
+
29
+ - cross-lib type imports are always absolute ([#392](https://github.com/OKAMca/stack/pull/392))
30
+
31
+ ### 🧱 Updated Dependencies
32
+
33
+ - Updated directus-block to 1.7.3
34
+
35
+ ### ❤️ Thank You
36
+
37
+ - Pierre-Olivier Clerson @poclerson
38
+
1
39
  ## 1.3.2 (2026-01-16)
2
40
 
3
41
  ### 🧱 Updated Dependencies
@@ -11,6 +49,7 @@
11
49
 
12
50
  - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
13
51
  - bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
52
+ - Consumers must now have react and react-dom in their own
14
53
 
15
54
  ### 🩹 Fixes
16
55
 
@@ -23,10 +62,6 @@
23
62
  - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
24
63
  - select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
25
64
 
26
- ### ⚠️ Breaking Changes
27
-
28
- - Consumers must now have react and react-dom in their own
29
-
30
65
  ### ❤️ Thank You
31
66
 
32
67
  - Marie-Maxime Tanguay @marie-maxime
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  | nodes | TRenderingNodes \| undefined | This takes in a config object for remapping default HTML semantic tags to React Components. |
18
18
  | remappedAttributes | Record<string, string> \| undefined | This allows to remap HTML attributes to fix warnings or errors made by tiptap. |
19
19
 
20
- ### Configuring the flexible editor inside directus :
20
+ ### Configuring the flexible editor inside directus :
21
21
 
22
22
  - [Basic usage](https://github.com/formfcw/directus-extension-flexible-editor?tab=readme-ov-file#basic-usage)
23
23
  - [With relation nodes](https://github.com/formfcw/directus-extension-flexible-editor?tab=readme-ov-file#usage-with-relation-nodes)
@@ -25,20 +25,16 @@
25
25
 
26
26
  Adding blocks to the flexible editor options : the related blocks are handled in the Editor Nodes field beside the flexible editor field. You can add more collections by going in the relationship menu of the editor nodes and selecting additional collections in the associated collections section.
27
27
 
28
-
29
28
  https://github.com/user-attachments/assets/576bdb52-f9bc-4835-ab2a-4c59995ae77f
30
29
 
31
-
32
-
33
30
  Most of the time, if you want to insert blocks inside the flexible editor, you will need to follow the `With relation nodes and exisiting items` tutorial. Note that it is important to prefix related blocks for selection with `related_` so that a related block would look like `related_{block-collection}` so if you have a `block_faqs` your related collection key should be `related_block_faqs`.
34
31
 
35
32
  IMPORTANT: when configuring the many to many relation inside your `related_{block-collection}` collection. The key of the field should always be `blocks`.
36
33
  ![image](https://github.com/user-attachments/assets/716ef0e9-cf9c-4320-8d7f-6557e8946972)
37
34
 
35
+ ### Querying
38
36
 
39
- ### Querying
40
-
41
- Here is an example of what querying should look like :
37
+ Here is an example of what querying should look like :
42
38
 
43
39
  ```graphql
44
40
  flexible_editor
@@ -76,5 +72,3 @@ editor_nodes {
76
72
  }
77
73
  }
78
74
  ```
79
-
80
-
package/index.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),q=require("@okam/directus-block/server"),b=require("@tiptap/core"),B=require("@okam/stack-ui"),L=require("@tiptap/extension-subscript"),R=require("@tiptap/extension-superscript"),w=require("@tiptap/extension-table"),E=require("@tiptap/extension-table-cell"),I=require("@tiptap/extension-table-header"),J=require("@tiptap/extension-table-row"),j=require("@tiptap/extension-text-align"),D=require("@tiptap/starter-kit");function K(e,n,r="id",i="item"){const o=t=>{if(t==null)return null;if(e==null)return t;if(t.type==="relation-mark"&&t.attrs?.id||t.type==="relation-block"&&t.attrs?.id||t.type==="relation-inline-block"&&t.attrs?.id){const s=e.find(a=>a?.[r]===t.attrs?.id)?.[i];t.attrs.data=s}return t.content?.map(o),t.marks?.map(o),t};return o(n)}function _(e,n){const r=n.map(t=>(t.type==="mark"?b.Mark:b.Node).create({name:t.name,renderHTML({HTMLAttributes:a}){return t.render!=null?[...t.render(a),0]:[t.component??(t.type==="mark"?"span":"div"),a,0]}})),i=r.map(({name:t})=>t);return[...e.filter(t=>!i.includes(t.name)),...r]}function M(e,n,r){const i=r.find(o=>o.type===n&&o.name===e);if(i)return{...i.config,options:i.options}}function F(e,n){const r=n.addAttributes?.();return!r||!e?e:Object.fromEntries(Object.entries(e).filter(([i])=>r[i]?.rendered!==!1))}function y(e,n,r="node"){const i=M(e.type,r,n);if(!i?.renderHTML)return[];const o=F(e.attrs,i);return i.render?i.render(e):i.renderHTML({node:e,HTMLAttributes:o})}function O(e,n,r){if(e?.content&&(e.content=e.content.map(async s=>O(s,n,r))),e.type==="text"){if(e.marks){let s;return e.marks.reverse().forEach(a=>{const l=y({...a,attrs:{...a.attrs,data:{...a?.attrs?.data,markText:e.text}}},n,"mark");if(Array.isArray(l)){const[f="span",m=a.attrs]=l,u={...m,data:void 0};s=r(f,u,s??e.text)}else s=[{...l,text:e.text}]}),s}return e.text??""}if(M(e.type,"node",n)?.render)return y(e,n);const[o="div",t=e.attrs]=y(e,n);return r(o,t,e.content)}function P(e,n,r){return O(e,n,r)}const U={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"};function V(e,n){return{...Object.fromEntries(Object.entries(n).map(([r,i])=>[e?.[r]??U?.[r]??r,i]))}}const W={};function v(e){const{content:n,serializers:r=[],componentSerializers:i=[],renderingNodes:o,remappedAttributes:t,themeName:s,tokens:a,customTheme:l}=e,f=JSON.parse(JSON.stringify(n)),m=_(r,i);return P(f,m,(u,k,d)=>{const T={...k,style:void 0},g=V(t,T),S=u,c=o?.[S]??W?.[S];return c!=null?c({children:d,attrs:g,themeName:s,tokens:a,customTheme:l}):N.jsx(B.Box,{as:u,...g,themeName:s,tokens:a,customTheme:l,children:d},JSON.stringify(d))})}const $=[D.configure({dropcursor:!1,gapcursor:!1,undoRedo:!1,underline:!1}),w.Table,I.TableHeader,J.TableRow,E.TableCell,j,L,R];function G(e){const{jsonContent:n,editorNodes:r,serializers:i,nodes:o,config:t,relationMarksConfig:s,themeName:a,tokens:l,customTheme:f,remappedAttributes:m}=e,u=K(r,n),k=i??[...$],d=(c,z)=>{const{attrs:p}=c,H=`${p?.collection?.replace("related_","")}_id`;if(p?.data!=null){if(p.data.blocks==null){const x={collection:p.collection,item:{...p?.data}};return N.jsx(q.BlockDispatcher,{block:x,config:z},JSON.stringify(x))}const A=p?.data?.blocks,h=A?.map(x=>({item:x?.[H],collection:p?.collection}));return N.jsx(q.BlockDispatcher,{blocks:h,config:z},JSON.stringify(A))}return null},T=b.Node.create({name:"relation-block",renderHTML:()=>["relation-block"],render:c=>d(c,t)}),g=b.Node.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:c=>d(c,t)}),S=b.Mark.create({name:"relation-mark",renderHTML:()=>["relation-mark"],render:c=>d(c,s)});return k.push(T,g,S),u==null?null:N.jsx(v,{content:u,serializers:k,renderingNodes:o,themeName:a,tokens:l,customTheme:f,remappedAttributes:m})}exports.FlexibleEditorContent=G;exports.RenderNodes=v;
package/index.mjs CHANGED
@@ -1,219 +1,202 @@
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;
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import { BlockDispatcher as M } from "@okam/directus-block/server";
3
+ import { Mark as O, Node as T } from "@tiptap/core";
4
+ import { Box as B } from "@okam/stack-ui";
5
+ import I from "@tiptap/extension-subscript";
6
+ import J from "@tiptap/extension-superscript";
7
+ import { Table as w } from "@tiptap/extension-table";
8
+ import { TableCell as E } from "@tiptap/extension-table-cell";
9
+ import { TableHeader as R } from "@tiptap/extension-table-header";
10
+ import { TableRow as K } from "@tiptap/extension-table-row";
11
+ import _ from "@tiptap/extension-text-align";
12
+ import D from "@tiptap/starter-kit";
13
+ function F(e, n, r = "id", i = "item") {
14
+ const o = (t) => {
15
+ if (t == null)
16
+ return null;
17
+ if (e == null)
18
+ return t;
19
+ if (t.type === "relation-mark" && t.attrs?.id || t.type === "relation-block" && t.attrs?.id || t.type === "relation-inline-block" && t.attrs?.id) {
20
+ const a = e.find((s) => s?.[r] === t.attrs?.id)?.[i];
21
+ t.attrs.data = a;
39
22
  }
40
- return (d = t.content) == null || d.map(i), (p = t.marks) == null || p.map(i), t;
23
+ return t.content?.map(o), t.marks?.map(o), t;
41
24
  };
42
- return i(o);
43
- }, ar = (r, o) => {
44
- const n = o.map((t) => (t.type === "mark" ? v : L).create({
25
+ return o(n);
26
+ }
27
+ function V(e, n) {
28
+ const r = n.map((t) => (t.type === "mark" ? O : T).create({
45
29
  name: t.name,
46
- // eslint-disable-next-line
47
- renderHTML({ HTMLAttributes: a }) {
48
- return t.render ? [...t.render(a), 0] : [t.component ?? (t.type === "mark" ? "span" : "div"), a, 0];
30
+ renderHTML({ HTMLAttributes: s }) {
31
+ return t.render != null ? [...t.render(s), 0] : [t.component ?? (t.type === "mark" ? "span" : "div"), s, 0];
49
32
  }
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)
33
+ })), i = r.map(({ name: t }) => t);
34
+ return [...e.filter((t) => !i.includes(t.name)), ...r];
35
+ }
36
+ function H(e, n, r) {
37
+ const i = r.find((o) => o.type === n && o.name === e);
38
+ if (i)
55
39
  return {
56
- ...e.config,
57
- options: e.options
40
+ ...i.config,
41
+ options: i.options
58
42
  };
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;
65
- }));
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,
72
- HTMLAttributes: i
43
+ }
44
+ function W(e, n) {
45
+ const r = n.addAttributes?.();
46
+ return !r || !e ? e : Object.fromEntries(Object.entries(e).filter(([i]) => r[i]?.rendered !== !1));
47
+ }
48
+ function z(e, n, r = "node") {
49
+ const i = H(e.type, r, n);
50
+ if (!i?.renderHTML)
51
+ return [];
52
+ const o = W(e.attrs, i);
53
+ return i.render ? i.render(e) : i.renderHTML({
54
+ node: e,
55
+ HTMLAttributes: o
73
56
  });
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,
57
+ }
58
+ function v(e, n, r) {
59
+ if (e?.content && (e.content = e.content.map(async (a) => v(a, n, r))), e.type === "text") {
60
+ if (e.marks) {
61
+ let a;
62
+ return e.marks.reverse().forEach((s) => {
63
+ const l = z(
64
+ { ...s, attrs: { ...s.attrs, data: { ...s?.attrs?.data, markText: e.text } } },
65
+ n,
83
66
  "mark"
84
67
  );
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);
68
+ if (Array.isArray(l)) {
69
+ const [d = "span", f = s.attrs] = l, u = { ...f, data: void 0 };
70
+ a = r(d, u, a ?? e.text);
88
71
  } else
89
- s = { ...m, text: r.text };
90
- }), s;
72
+ a = [{ ...l, text: e.text }];
73
+ }), a;
91
74
  }
92
- return r.text ?? "";
75
+ return e.text ?? "";
93
76
  }
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 = {
77
+ if (H(e.type, "node", n)?.render)
78
+ return z(e, n);
79
+ const [o = "div", t = e.attrs] = z(e, n);
80
+ return r(o, t, e.content);
81
+ }
82
+ function $(e, n, r) {
83
+ return v(e, n, r);
84
+ }
85
+ const q = {
100
86
  colspan: "colSpan",
101
87
  rowspan: "rowSpan",
102
88
  textAlign: "textalign"
103
- }, lr = (r, o) => ({
104
- ...Object.fromEntries(
105
- Object.entries(o).map(([n, e]) => [(r == null ? void 0 : r[n]) ?? (B == null ? void 0 : B[n]) ?? n, e])
106
- )
107
- }), H = {}, pr = (r) => {
89
+ };
90
+ function G(e, n) {
91
+ return {
92
+ ...Object.fromEntries(
93
+ Object.entries(n).map(([r, i]) => [e?.[r] ?? q?.[r] ?? r, i])
94
+ )
95
+ };
96
+ }
97
+ const P = {};
98
+ function Q(e) {
108
99
  const {
109
- content: o,
110
- serializers: n = [],
111
- componentSerializers: e = [],
112
- renderingNodes: i,
100
+ content: n,
101
+ serializers: r = [],
102
+ componentSerializers: i = [],
103
+ renderingNodes: o,
113
104
  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,
105
+ themeName: a,
106
+ tokens: s,
107
+ customTheme: l
108
+ } = e, d = JSON.parse(JSON.stringify(n)), f = V(r, i);
109
+ return $(
120
110
  d,
111
+ f,
121
112
  // @ts-expect-error Expects ReactNode
122
- (p, k, l) => {
123
- const b = {
124
- ...k,
113
+ (u, b, m) => {
114
+ const N = {
115
+ ...b,
125
116
  style: void 0
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,
117
+ }, k = G(t, N), g = u, c = o?.[g] ?? P?.[g];
118
+ return c != null ? c({ children: m, attrs: k, themeName: a, tokens: s, customTheme: l }) : /* @__PURE__ */ y(
119
+ B,
129
120
  {
130
- as: p,
131
- ...g,
132
- themeName: s,
133
- tokens: a,
134
- customTheme: m,
135
- children: l
121
+ as: u,
122
+ ...k,
123
+ themeName: a,
124
+ tokens: s,
125
+ customTheme: l,
126
+ children: m
136
127
  },
137
- JSON.stringify(l)
128
+ JSON.stringify(m)
138
129
  );
139
130
  }
140
131
  );
141
- }, fr = [
142
- P,
143
- nr,
144
- Y,
145
- V,
146
- W,
147
- F,
132
+ }
133
+ const U = [
134
+ D.configure({
135
+ // Disable extensions we don't need for read-only rendering
136
+ dropcursor: !1,
137
+ gapcursor: !1,
138
+ undoRedo: !1,
139
+ underline: !1
140
+ }),
141
+ // Extensions not included in StarterKit
142
+ w,
143
+ R,
148
144
  K,
149
- X,
150
- U,
151
- D,
152
- $,
153
- Q,
145
+ E,
154
146
  _,
155
- G,
156
- Z,
157
- q,
158
- rr,
159
- er,
160
- or,
161
- tr,
162
- ir,
163
- j,
164
- C
165
- ], Fr = (r) => {
147
+ I,
148
+ J
149
+ ];
150
+ function ce(e) {
166
151
  const {
167
- jsonContent: o,
168
- editorNodes: n,
169
- serializers: e,
170
- nodes: i,
152
+ jsonContent: n,
153
+ editorNodes: r,
154
+ serializers: i,
155
+ nodes: o,
171
156
  config: t,
172
- relationMarksConfig: s,
173
- themeName: a,
174
- tokens: m,
175
- customTheme: u,
176
- remappedAttributes: d
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));
157
+ relationMarksConfig: a,
158
+ themeName: s,
159
+ tokens: l,
160
+ customTheme: d,
161
+ remappedAttributes: f
162
+ } = e, u = F(r, n), b = i ?? [...U], m = (c, x) => {
163
+ const { attrs: p } = c, L = `${p?.collection?.replace("related_", "")}_id`;
164
+ if (p?.data != null) {
165
+ if (p.data.blocks == null) {
166
+ const S = { collection: p.collection, item: { ...p?.data } };
167
+ return /* @__PURE__ */ y(M, { block: S, config: x }, JSON.stringify(S));
184
168
  }
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));
169
+ const A = p?.data?.blocks, h = A?.map((S) => ({ item: S?.[L], collection: p?.collection }));
170
+ return /* @__PURE__ */ y(M, { blocks: h, config: x }, JSON.stringify(A));
187
171
  }
188
172
  return null;
189
- }, b = L.create({
173
+ }, N = T.create({
190
174
  name: "relation-block",
191
175
  renderHTML: () => ["relation-block"],
192
- render: (f) => l(f, t)
193
- }), g = L.create({
176
+ render: (c) => m(c, t)
177
+ }), k = T.create({
194
178
  name: "relation-inline-block",
195
179
  renderHTML: () => ["relation-inline-block"],
196
- render: (f) => l(f, t)
197
- }), y = v.create({
180
+ render: (c) => m(c, t)
181
+ }), g = O.create({
198
182
  name: "relation-mark",
199
- type: "relation-mark",
200
183
  renderHTML: () => ["relation-mark"],
201
- render: (f) => l(f, s)
184
+ render: (c) => m(c, a)
202
185
  });
203
- return k.push(b, g, y), p ? /* @__PURE__ */ x(
204
- pr,
186
+ return b.push(N, k, g), u == null ? null : /* @__PURE__ */ y(
187
+ Q,
205
188
  {
206
- content: p,
207
- serializers: k,
208
- renderingNodes: i,
209
- themeName: a,
210
- tokens: m,
211
- customTheme: u,
212
- remappedAttributes: d
189
+ content: u,
190
+ serializers: b,
191
+ renderingNodes: o,
192
+ themeName: s,
193
+ tokens: l,
194
+ customTheme: d,
195
+ remappedAttributes: f
213
196
  }
214
- ) : null;
215
- };
197
+ );
198
+ }
216
199
  export {
217
- Fr as FlexibleEditorContent,
218
- pr as RenderNodes
200
+ ce as FlexibleEditorContent,
201
+ Q as RenderNodes
219
202
  };
@@ -1,2 +1,2 @@
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>)[];
1
+ declare const _default: (import('@tiptap/core').Extension<import('@tiptap/starter-kit').StarterKitOptions, any> | import('@tiptap/core').Node<import('@tiptap/extension-table').TableOptions, any> | import('@tiptap/core').Node<import('@tiptap/extension-table').TableHeaderOptions, 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,8 +1,7 @@
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';
1
+ import { TBlockSerializerConfig } from '@okam/directus-block';
2
+ import { TDefaultComponent } from '@okam/stack-ui';
3
+ import { EditorNodes, Extensions, JSONContent } from '../../functions/types';
4
4
  import { TRenderingNodes } from '../nodes/types';
5
-
6
5
  interface FlexibleEditorContentProps extends TDefaultComponent {
7
6
  jsonContent: JSONContent;
8
7
  editorNodes?: EditorNodes[] | undefined | null;
@@ -12,5 +11,5 @@ interface FlexibleEditorContentProps extends TDefaultComponent {
12
11
  nodes?: TRenderingNodes;
13
12
  remappedAttributes?: Record<string, string>;
14
13
  }
15
- declare const FlexibleEditorContent: (props: FlexibleEditorContentProps) => import("react/jsx-runtime").JSX.Element | null;
14
+ declare function FlexibleEditorContent(props: FlexibleEditorContentProps): import("react/jsx-runtime").JSX.Element | null;
16
15
  export default FlexibleEditorContent;
@@ -1,8 +1,7 @@
1
- import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
1
+ import { TDefaultComponent } from '@okam/stack-ui';
2
2
  import { ReactNode } from 'react';
3
- import { JSONContent, Extensions, ReactComponentSerializers } from '../../functions/types';
3
+ import { Extensions, JSONContent, ReactComponentSerializers } from '../../functions/types';
4
4
  import { TRenderingNodes } from '../nodes/types';
5
-
6
5
  interface RenderNodesProps extends TDefaultComponent {
7
6
  content: JSONContent;
8
7
  serializers?: Extensions;
@@ -10,5 +9,5 @@ interface RenderNodesProps extends TDefaultComponent {
10
9
  renderingNodes?: TRenderingNodes;
11
10
  remappedAttributes?: Record<string, string>;
12
11
  }
13
- declare const RenderNodes: (props: RenderNodesProps) => ReactNode;
12
+ declare function RenderNodes(props: RenderNodesProps): ReactNode;
14
13
  export default RenderNodes;
@@ -1,4 +1,4 @@
1
- declare const remapAttributes: (mappedAttributes: Record<string, string> | undefined, attrs: Record<string, number | string | undefined>) => {
2
- [x: string]: string | number | undefined;
1
+ declare function remapAttributes(mappedAttributes: Record<string, string> | undefined, attrs: Record<string, number | string | undefined>): {
2
+ [k: string]: string | number | undefined;
3
3
  };
4
4
  export default remapAttributes;
@@ -1,3 +1,3 @@
1
1
  export { default as FlexibleEditorContent } from './FlexibleEditorContent';
2
+ export type * from './nodes/types';
2
3
  export { default as RenderNodes } from './RenderNodes';
3
- export * from './nodes/types';
@@ -1,4 +1,3 @@
1
1
  import { TRenderingNodes } from './types';
2
-
3
2
  declare const nodes: TRenderingNodes;
4
3
  export default nodes;
@@ -1,10 +1,9 @@
1
- import { TDefaultComponent } from '../../../../../../stack/stack-ui/src/index.ts';
2
- import { default as React } from 'react';
3
-
1
+ import { TDefaultComponent } from '@okam/stack-ui';
2
+ import type * as React from 'react';
4
3
  export interface TBaseRenderingNode extends TDefaultComponent {
5
4
  children: React.ReactNode;
6
5
  attrs?: Record<string, number | string | boolean | undefined>;
7
6
  }
8
7
  export type TRenderingNodes = {
9
- [key in keyof React.JSX.IntrinsicElements]?: (props: TBaseRenderingNode) => React.JSX.Element;
8
+ [_key in keyof React.JSX.IntrinsicElements]?: (_props: TBaseRenderingNode) => React.JSX.Element;
10
9
  };
@@ -1,4 +1,4 @@
1
1
  export { default as injectDataIntoContent } from './injectDataIntoContent';
2
2
  export { default as mergeSerializers } from './mergeSerializers';
3
3
  export { default as renderView } from './renderView';
4
- export * from './types';
4
+ export type * from './types';
@@ -1,5 +1,4 @@
1
1
  import { JSONContent } from '@tiptap/core';
2
2
  import { EditorNodes } from './types';
3
-
4
- declare const injectDataIntoContent: (data: EditorNodes[] | undefined | null, content: JSONContent, primaryKeyField?: string, itemField?: string) => JSONContent | null;
3
+ declare function injectDataIntoContent(data: EditorNodes[] | undefined | null, content: JSONContent, primaryKeyField?: string, itemField?: string): JSONContent | null;
5
4
  export default injectDataIntoContent;
@@ -1,4 +1,3 @@
1
- import { Extensions, ComponentSerializers } from './types';
2
-
3
- declare const mergeSerializers: <T>(serializers: Extensions, componentSerializers: ComponentSerializers<T>) => Extensions;
1
+ import { ComponentSerializers, Extensions } from './types';
2
+ declare function mergeSerializers<T>(serializers: Extensions, componentSerializers: ComponentSerializers<T>): Extensions;
4
3
  export default mergeSerializers;
@@ -1,5 +1,4 @@
1
1
  import { ReactNode } from 'react';
2
- import { JSONContent, Extensions, RenderedNode, RenderCallback } from './types';
3
-
4
- declare const renderView: <T>(node: JSONContent, serializers: Extensions, renderCallback: RenderCallback<ReactNode | JSONContent[]>) => RenderedNode<T>;
2
+ import { Extensions, JSONContent, RenderCallback, RenderedNode } from './types';
3
+ declare function renderView<T>(node: JSONContent, serializers: Extensions, renderCallback: RenderCallback<ReactNode | JSONContent[]>): RenderedNode<T>;
5
4
  export default renderView;
@@ -1,24 +1,33 @@
1
- import { TBlock } from '../../../../directus-block/src/index.ts';
2
- import { JSONContent, Extensions, AnyExtension } from '@tiptap/core';
1
+ import { TBlock } from '@okam/directus-block';
2
+ import { AnyExtension, Extensions, JSONContent } from '@tiptap/core';
3
3
  import { ElementType, FunctionComponent, ReactNode } from 'react';
4
-
5
- export type { JSONContent, Extensions };
4
+ export type { Extensions, JSONContent };
6
5
  export type RenderedNode<T> = T | string | (T | string)[];
7
6
  export type Tag = ElementType;
8
7
  export type Attrs = JSONContent['attrs'];
9
8
  export type NodeType = 'mark' | 'node';
10
- export type RenderCallback<T> = (tag: Tag, attrs: Attrs, content?: T) => RenderedNode<T>;
9
+ export type RenderCallback<T> = (_tag: Tag, _attrs: Attrs, _content?: T) => RenderedNode<T>;
11
10
  export type SerializedNode = [tag?: Tag, attrs?: Attrs];
12
- export type Serializer = AnyExtension & {
11
+ /**
12
+ * Custom serializer config type that includes the custom `render` property
13
+ * added via module augmentation in tiptap.d.ts
14
+ */
15
+ export interface SerializerConfig {
13
16
  options?: unknown;
14
- renderHTML?: (attributes: Record<string, unknown>) => SerializedNode;
15
- render?: (props: TBlock['item']) => ReactNode;
16
- addAttributes: () => unknown;
17
+ renderHTML?: (_attributes: Record<string, unknown>) => SerializedNode;
18
+ render?: (_props: TBlock['item']) => ReactNode;
19
+ addAttributes?: () => Record<string, {
20
+ rendered?: boolean;
21
+ default?: unknown;
22
+ }>;
23
+ }
24
+ export type Serializer = AnyExtension & {
25
+ config: SerializerConfig;
17
26
  };
18
27
  export type ComponentSerializers<T> = {
19
28
  name: string;
20
29
  component?: T;
21
- render?: (attrs: Attrs) => [Tag | T, Attrs];
30
+ render?: (_attrs: Attrs) => [Tag | T, Attrs];
22
31
  type?: NodeType;
23
32
  }[];
24
33
  export type RelationBlockSerializers<T> = {
package/lib/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { TCommonBlockFragment } from '../../../directus-block/src/index.ts';
2
-
1
+ import { TCommonBlockFragment } from '@okam/directus-block';
3
2
  export type RelationBlockSerializers<T> = {
4
3
  collection: string;
5
4
  component: T;
@@ -12,8 +11,8 @@ export type RelationBlockProps = RelationBlockAttrs & {
12
11
  };
13
12
  };
14
13
  };
15
- export type RelationBlockAttrs = {
14
+ export interface RelationBlockAttrs {
16
15
  id: string | null;
17
16
  junction: string | null;
18
17
  collection: string | null;
19
- };
18
+ }
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@okam/directus-flexible-content",
3
- "version": "1.3.2",
4
- "main": "./index.js",
5
- "types": "./index.d.ts",
3
+ "version": "1.3.8",
4
+ "repository": {
5
+ "url": "https://github.com/OKAMca/stack.git"
6
+ },
7
+ "sideEffects": false,
6
8
  "exports": {
7
9
  ".": {
8
10
  "import": {
@@ -15,46 +17,33 @@
15
17
  }
16
18
  }
17
19
  },
20
+ "main": "./index.js",
21
+ "types": "./index.d.ts",
22
+ "engines": {
23
+ "node": ">=20.19.0"
24
+ },
18
25
  "publishConfig": {
19
26
  "access": "public"
20
27
  },
21
- "repository": {
22
- "url": "https://github.com/OKAMca/stack.git"
28
+ "peerDependencies": {
29
+ "react": "^18.0.0 || ^19.0.0"
23
30
  },
24
31
  "dependencies": {
25
32
  "@nx/vite": "20.2.2",
26
- "@okam/directus-block": "1.7.2",
27
- "@okam/stack-ui": "1.44.1",
33
+ "@okam/directus-block": "1.7.8",
34
+ "@okam/stack-ui": "1.44.4",
35
+ "@tiptap/core": "^3.15.3",
36
+ "@tiptap/extension-subscript": "^3.15.3",
37
+ "@tiptap/extension-superscript": "^3.15.3",
38
+ "@tiptap/extension-table": "^3.15.3",
39
+ "@tiptap/extension-table-cell": "^3.15.3",
40
+ "@tiptap/extension-table-header": "^3.15.3",
41
+ "@tiptap/extension-table-row": "^3.15.3",
42
+ "@tiptap/extension-text-align": "^3.15.3",
43
+ "@tiptap/starter-kit": "^3.15.3",
28
44
  "@vitejs/plugin-react": "4.3.4",
29
45
  "vite": "^5.0.13",
30
- "vite-plugin-dts": "~2.3.0",
31
- "@tiptap/extension-blockquote": "^2.10.3",
32
- "@tiptap/extension-bold": "^2.10.3",
33
- "@tiptap/extension-bullet-list": "^2.10.3",
34
- "@tiptap/extension-code": "^2.10.3",
35
- "@tiptap/extension-code-block": "^2.10.3",
36
- "@tiptap/extension-document": "^2.10.3",
37
- "@tiptap/extension-hard-break": "^2.10.3",
38
- "@tiptap/extension-heading": "^2.10.3",
39
- "@tiptap/extension-horizontal-rule": "^2.10.3",
40
- "@tiptap/extension-italic": "^2.10.3",
41
- "@tiptap/extension-link": "^2.10.3",
42
- "@tiptap/extension-list-item": "^2.10.3",
43
- "@tiptap/extension-ordered-list": "^2.10.3",
44
- "@tiptap/extension-paragraph": "^2.10.3",
45
- "@tiptap/extension-strike": "^2.10.3",
46
- "@tiptap/extension-subscript": "^2.10.3",
47
- "@tiptap/extension-superscript": "^2.10.3",
48
- "@tiptap/extension-table": "^2.10.3",
49
- "@tiptap/extension-table-cell": "^2.10.3",
50
- "@tiptap/extension-table-header": "^2.10.3",
51
- "@tiptap/extension-table-row": "^2.10.3",
52
- "@tiptap/extension-text": "^2.10.3",
53
- "@tiptap/extension-text-align": "^2.10.3",
54
- "@tiptap/core": "^2.10.3"
55
- },
56
- "peerDependencies": {
57
- "react": "^18.0.0 || ^19.0.0"
46
+ "vite-plugin-dts": "~2.3.0"
58
47
  },
59
48
  "devDependencies": {
60
49
  "react": "^19.0.0"