@okam/directus-flexible-content 1.2.22 → 1.2.24
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 +53 -0
- package/index.js +1 -1
- package/index.mjs +42 -42
- package/lib/components/FlexibleEditorContent/extensions.d.ts +1 -1
- package/lib/components/FlexibleEditorContent/index.d.ts +5 -4
- package/lib/components/RenderNodes/index.d.ts +6 -5
- package/lib/components/nodes/index.d.ts +2 -1
- package/lib/components/nodes/types.d.ts +4 -2
- package/lib/functions/injectDataIntoContent.d.ts +3 -2
- package/lib/functions/mergeSerializers.d.ts +2 -1
- package/lib/functions/renderView.d.ts +3 -2
- package/lib/functions/types.d.ts +4 -3
- package/lib/types.d.ts +2 -1
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
## 1.2.24 (2026-01-13)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- React 19 + Next.js 15 support ([#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
|
+
### 🧱 Updated Dependencies
|
|
18
|
+
|
|
19
|
+
- Updated stack-ui to 1.43.0
|
|
20
|
+
- Updated directus-block to 1.6.2
|
|
21
|
+
|
|
22
|
+
### ❤️ Thank You
|
|
23
|
+
|
|
24
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
25
|
+
- Pierre-Olivier Clerson @poclerson
|
|
26
|
+
- poclerson
|
|
27
|
+
|
|
28
|
+
## 1.2.23 (2025-11-27)
|
|
29
|
+
|
|
30
|
+
### 🚀 Features
|
|
31
|
+
|
|
32
|
+
- bump ([ab924b9](https://github.com/OKAMca/stack/commit/ab924b9))
|
|
33
|
+
|
|
34
|
+
### 🩹 Fixes
|
|
35
|
+
|
|
36
|
+
- **directus-flexible-content:** core-lib in external deps ([e44cb2b](https://github.com/OKAMca/stack/commit/e44cb2b))
|
|
37
|
+
- update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
|
|
38
|
+
- package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
|
|
39
|
+
- search field type export ([5ab6070](https://github.com/OKAMca/stack/commit/5ab6070))
|
|
40
|
+
- search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
|
|
41
|
+
- select controlled ([#280](https://github.com/OKAMca/stack/pull/280))
|
|
42
|
+
|
|
43
|
+
### 🧱 Updated Dependencies
|
|
44
|
+
|
|
45
|
+
- Updated stack-ui to 1.42.4
|
|
46
|
+
- Updated directus-block to 1.6.1
|
|
47
|
+
|
|
48
|
+
### ❤️ Thank You
|
|
49
|
+
|
|
50
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
51
|
+
- Pierre-Olivier Clerson @poclerson
|
|
52
|
+
- poclerson
|
|
53
|
+
|
|
1
54
|
## 1.2.22 (2025-10-17)
|
|
2
55
|
|
|
3
56
|
### 🚀 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"),
|
|
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"),ge=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 pe=(e,n,r=!1)=>{const t=new q(e,n,r);return t.log("Logger initialized","info"),t},ke=pe("[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,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:l}=n??{},u=(n==null?void 0:n.id)??(i==null?void 0:i.id);if(!u)return null;const{variant:g}=H(z,l)??{},f=((m=s.getVariant)==null?void 0:m.call(s,e))??g??o,{default:k,document:d}=s,b=((h=s.variants)==null?void 0:h[f??""])??k;return b?p.jsx(b,{document:d,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,g,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"&&((l=o.attrs)!=null&&l.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(g=o.content)==null||g.map(i),(f=o.marks)==null||f.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[g="span",f=s.attrs]=l,k={...f,data:void 0};c=r(g,k,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)),g=we(r,t);return Pe(u,g,(f,k,d)=>{const y={...k,style:void 0},b=Ce(o,y),N=f,m=(i==null?void 0:i[N])??(x==null?void 0:x[N]);return m?m({children:d,attrs:b,themeName:c,tokens:s,customTheme:l}):p.jsx(E.Box,{as:f,...b,themeName:c,tokens:s,customTheme:l,children:d},JSON.stringify(d))})},He=[$,fe,ie,Y,Z,W,X,oe,re,K,ee,ne,V,te,se,J,le.Table,de.TableHeader,me.TableRow,ue.TableCell,ge,ce,ae],Me=e=>{const{jsonContent:n,editorNodes:r,serializers:t,nodes:i,config:o,relationMarksConfig:c,themeName:s,tokens:l,customTheme:u,remappedAttributes:g}=e,f=Re(r,n),k=t??[...He]??[],d=(m,h)=>{var I,R,w;const{attrs:a}=m,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: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?p.jsx(Q,{content:f,serializers:k,renderingNodes:i,themeName:s,tokens:l,customTheme:u,remappedAttributes:g}):null};exports.FlexibleEditorContent=Me;exports.RenderNodes=Q;
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as k, jsxs as K, Fragment as G } from "react/jsx-runtime";
|
|
2
2
|
import { QueryClient as V, QueryCache as X } from "@tanstack/react-query";
|
|
3
3
|
import { isEmpty as J, get as _ } from "radashi";
|
|
4
4
|
import { GraphQLClient as H } from "graphql-request";
|
|
@@ -23,8 +23,8 @@ import ue from "@tiptap/extension-strike";
|
|
|
23
23
|
import fe from "@tiptap/extension-subscript";
|
|
24
24
|
import de from "@tiptap/extension-superscript";
|
|
25
25
|
import { Table as pe } from "@tiptap/extension-table";
|
|
26
|
-
import { TableCell as
|
|
27
|
-
import { TableHeader as
|
|
26
|
+
import { TableCell as ge } from "@tiptap/extension-table-cell";
|
|
27
|
+
import { TableHeader as ke } from "@tiptap/extension-table-header";
|
|
28
28
|
import { TableRow as ye } from "@tiptap/extension-table-row";
|
|
29
29
|
import Ne from "@tiptap/extension-text";
|
|
30
30
|
import be from "@tiptap/extension-text-align";
|
|
@@ -121,18 +121,18 @@ function Oe(e, ...r) {
|
|
|
121
121
|
return r.reduce((t, i) => i ? { components: { ...t.components, ...i.components } } : t, e);
|
|
122
122
|
}
|
|
123
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,
|
|
124
|
+
var b, f, B;
|
|
125
125
|
const { item: r, collection: n, config: t, variables: i, defaultVariant: o, ...c } = e;
|
|
126
126
|
if (!n || !t) return null;
|
|
127
127
|
const s = (b = t == null ? void 0 : t.components) == null ? void 0 : b[n];
|
|
128
128
|
if (!s) return null;
|
|
129
129
|
const { settings: l } = r ?? {}, m = (r == null ? void 0 : r.id) ?? (i == null ? void 0 : i.id);
|
|
130
130
|
if (!m) return null;
|
|
131
|
-
const { variant:
|
|
132
|
-
return N ? /* @__PURE__ */
|
|
131
|
+
const { variant: p } = q(D, l) ?? {}, d = ((f = s.getVariant) == null ? void 0 : f.call(s, e)) ?? p ?? o, { default: g, document: u } = s, N = ((B = s.variants) == null ? void 0 : B[d ?? ""]) ?? g;
|
|
132
|
+
return N ? /* @__PURE__ */ k(
|
|
133
133
|
N,
|
|
134
134
|
{
|
|
135
|
-
document:
|
|
135
|
+
document: u,
|
|
136
136
|
config: t,
|
|
137
137
|
collection: n,
|
|
138
138
|
item: r,
|
|
@@ -153,20 +153,20 @@ async function Re(e, r, n) {
|
|
|
153
153
|
}
|
|
154
154
|
const He = async (e) => {
|
|
155
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
|
|
157
|
-
o && c && /* @__PURE__ */
|
|
158
|
-
i && /* @__PURE__ */
|
|
156
|
+
return !i && !(o && c) ? null : /* @__PURE__ */ K(G, { children: [
|
|
157
|
+
o && c && /* @__PURE__ */ k(C, { as: "span", themeName: n, tokens: { ...t, ...s }, children: $.createElement(c, {}, o) }),
|
|
158
|
+
i && /* @__PURE__ */ k(W, { themeName: n, tokens: { ...t, ...s }, content: i })
|
|
159
159
|
] });
|
|
160
160
|
}, Ce = {
|
|
161
161
|
block_wysiwyg: {
|
|
162
|
-
default: (e) => /* @__PURE__ */
|
|
162
|
+
default: (e) => /* @__PURE__ */ k(He, { ...e })
|
|
163
163
|
}
|
|
164
164
|
}, xe = {
|
|
165
165
|
components: {
|
|
166
166
|
...Ce
|
|
167
167
|
}
|
|
168
168
|
}, R = (e) => {
|
|
169
|
-
const { children: r, config: n, ...t } = e, i = Oe(xe, n), o = (s) => r ? r({ ...t, ...s, config: i }) : /* @__PURE__ */
|
|
169
|
+
const { children: r, config: n, ...t } = e, i = Oe(xe, n), o = (s) => r ? r({ ...t, ...s, config: i }) : /* @__PURE__ */ k(Pe, { ...t, ...s, config: i });
|
|
170
170
|
if ("blocks" in e) {
|
|
171
171
|
const { blocks: s } = e;
|
|
172
172
|
return s.map(o);
|
|
@@ -175,17 +175,17 @@ const He = async (e) => {
|
|
|
175
175
|
return o(c);
|
|
176
176
|
}, qe = (e, r, n = "id", t = "item") => {
|
|
177
177
|
const i = (o) => {
|
|
178
|
-
var c, s, l, m,
|
|
178
|
+
var c, s, l, m, p, d;
|
|
179
179
|
if (!e && o) return o;
|
|
180
180
|
if (!o || !e) return null;
|
|
181
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
|
|
182
|
+
const g = (m = e.find((u) => {
|
|
183
183
|
var y;
|
|
184
|
-
return (
|
|
184
|
+
return (u == null ? void 0 : u[n]) === ((y = o.attrs) == null ? void 0 : y.id);
|
|
185
185
|
})) == null ? void 0 : m[t];
|
|
186
|
-
o.attrs.data =
|
|
186
|
+
o.attrs.data = g;
|
|
187
187
|
}
|
|
188
|
-
return (
|
|
188
|
+
return (p = o.content) == null || p.map(i), (d = o.marks) == null || d.map(i), o;
|
|
189
189
|
};
|
|
190
190
|
return i(r);
|
|
191
191
|
}, ze = (e, r) => {
|
|
@@ -231,8 +231,8 @@ const He = async (e) => {
|
|
|
231
231
|
"mark"
|
|
232
232
|
);
|
|
233
233
|
if (Array.isArray(l)) {
|
|
234
|
-
const [
|
|
235
|
-
c = n(
|
|
234
|
+
const [p = "span", d = s.attrs] = l, g = { ...d, data: void 0 };
|
|
235
|
+
c = n(p, g, c || e.text);
|
|
236
236
|
} else
|
|
237
237
|
c = { ...l, text: e.text };
|
|
238
238
|
}), c;
|
|
@@ -262,27 +262,27 @@ const He = async (e) => {
|
|
|
262
262
|
themeName: c,
|
|
263
263
|
tokens: s,
|
|
264
264
|
customTheme: l
|
|
265
|
-
} = e, m = JSON.parse(JSON.stringify(r)),
|
|
265
|
+
} = e, m = JSON.parse(JSON.stringify(r)), p = ze(n, t);
|
|
266
266
|
return Fe(
|
|
267
267
|
m,
|
|
268
|
-
|
|
268
|
+
p,
|
|
269
269
|
// @ts-expect-error Expects ReactNode
|
|
270
|
-
(
|
|
270
|
+
(d, g, u) => {
|
|
271
271
|
const y = {
|
|
272
|
-
...
|
|
272
|
+
...g,
|
|
273
273
|
style: void 0
|
|
274
|
-
}, N = Me(o, y), b = (i == null ? void 0 : i[
|
|
275
|
-
return
|
|
274
|
+
}, N = Me(o, y), b = d, f = (i == null ? void 0 : i[b]) ?? (E == null ? void 0 : E[b]);
|
|
275
|
+
return f ? f({ children: u, attrs: N, themeName: c, tokens: s, customTheme: l }) : /* @__PURE__ */ k(
|
|
276
276
|
C,
|
|
277
277
|
{
|
|
278
|
-
as:
|
|
278
|
+
as: d,
|
|
279
279
|
...N,
|
|
280
280
|
themeName: c,
|
|
281
281
|
tokens: s,
|
|
282
282
|
customTheme: l,
|
|
283
|
-
children:
|
|
283
|
+
children: u
|
|
284
284
|
},
|
|
285
|
-
JSON.stringify(
|
|
285
|
+
JSON.stringify(u)
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
);
|
|
@@ -304,9 +304,9 @@ const He = async (e) => {
|
|
|
304
304
|
ue,
|
|
305
305
|
ee,
|
|
306
306
|
pe,
|
|
307
|
-
ge,
|
|
308
|
-
ye,
|
|
309
307
|
ke,
|
|
308
|
+
ye,
|
|
309
|
+
ge,
|
|
310
310
|
be,
|
|
311
311
|
fe,
|
|
312
312
|
de
|
|
@@ -321,43 +321,43 @@ const He = async (e) => {
|
|
|
321
321
|
themeName: s,
|
|
322
322
|
tokens: l,
|
|
323
323
|
customTheme: m,
|
|
324
|
-
remappedAttributes:
|
|
325
|
-
} = e,
|
|
324
|
+
remappedAttributes: p
|
|
325
|
+
} = e, d = qe(n, r), g = t ?? [...Ue] ?? [], u = (f, B) => {
|
|
326
326
|
var w, O, P;
|
|
327
|
-
const { attrs: a } =
|
|
327
|
+
const { attrs: a } = f, Q = `${(w = a == null ? void 0 : a.collection) == null ? void 0 : w.replace("related_", "")}_id`;
|
|
328
328
|
if (a != null && a.data) {
|
|
329
329
|
if (!((O = a == null ? void 0 : a.data) != null && O.blocks)) {
|
|
330
330
|
const h = { collection: a.collection, item: { ...a == null ? void 0 : a.data } };
|
|
331
|
-
return /* @__PURE__ */
|
|
331
|
+
return /* @__PURE__ */ k(R, { block: h, config: B }, JSON.stringify(h));
|
|
332
332
|
}
|
|
333
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__ */
|
|
334
|
+
return /* @__PURE__ */ k(R, { blocks: U, config: B }, JSON.stringify(S));
|
|
335
335
|
}
|
|
336
336
|
return null;
|
|
337
337
|
}, y = A.create({
|
|
338
338
|
name: "relation-block",
|
|
339
339
|
renderHTML: () => ["relation-block"],
|
|
340
|
-
render: (
|
|
340
|
+
render: (f) => u(f, o)
|
|
341
341
|
}), N = A.create({
|
|
342
342
|
name: "relation-inline-block",
|
|
343
343
|
renderHTML: () => ["relation-inline-block"],
|
|
344
|
-
render: (
|
|
344
|
+
render: (f) => u(f, o)
|
|
345
345
|
}), b = x.create({
|
|
346
346
|
name: "relation-mark",
|
|
347
347
|
type: "relation-mark",
|
|
348
348
|
renderHTML: () => ["relation-mark"],
|
|
349
|
-
render: (
|
|
349
|
+
render: (f) => u(f, c)
|
|
350
350
|
});
|
|
351
|
-
return
|
|
351
|
+
return g.push(y, N, b), d ? /* @__PURE__ */ k(
|
|
352
352
|
Qe,
|
|
353
353
|
{
|
|
354
|
-
content:
|
|
355
|
-
serializers:
|
|
354
|
+
content: d,
|
|
355
|
+
serializers: g,
|
|
356
356
|
renderingNodes: i,
|
|
357
357
|
themeName: s,
|
|
358
358
|
tokens: l,
|
|
359
359
|
customTheme: m,
|
|
360
|
-
remappedAttributes:
|
|
360
|
+
remappedAttributes: p
|
|
361
361
|
}
|
|
362
362
|
) : null;
|
|
363
363
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (import(
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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:
|
|
13
|
+
declare const RenderNodes: (props: RenderNodesProps) => ReactNode;
|
|
13
14
|
export default RenderNodes;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
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
|
|
2
|
-
import
|
|
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
|
|
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
|
|
2
|
-
import
|
|
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;
|
package/lib/functions/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/directus-flexible-content",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.24",
|
|
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.
|
|
27
|
-
"@okam/stack-ui": "1.
|
|
26
|
+
"@okam/directus-block": "1.6.2",
|
|
27
|
+
"@okam/stack-ui": "1.43.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
|
-
|
|
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
|
}
|