@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 +63 -2
- package/index.js +1 -1
- package/index.mjs +164 -318
- package/lib/components/FlexibleEditorContent/extensions.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
## 1.2
|
|
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
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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(
|
|
197
|
-
},
|
|
198
|
-
const
|
|
199
|
-
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:
|
|
202
|
-
return
|
|
47
|
+
renderHTML({ HTMLAttributes: a }) {
|
|
48
|
+
return t.render ? [...t.render(a), 0] : [t.component ?? (t.type === "mark" ? "span" : "div"), a, 0];
|
|
203
49
|
}
|
|
204
|
-
})),
|
|
205
|
-
return [...
|
|
206
|
-
},
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
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
|
-
...
|
|
211
|
-
options:
|
|
56
|
+
...e.config,
|
|
57
|
+
options: e.options
|
|
212
58
|
};
|
|
213
|
-
},
|
|
214
|
-
var
|
|
215
|
-
const
|
|
216
|
-
return !
|
|
217
|
-
var
|
|
218
|
-
return ((
|
|
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
|
-
},
|
|
221
|
-
const
|
|
222
|
-
if (!(
|
|
223
|
-
const i =
|
|
224
|
-
return
|
|
225
|
-
node:
|
|
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
|
-
},
|
|
229
|
-
if (
|
|
230
|
-
if (
|
|
231
|
-
let
|
|
232
|
-
return
|
|
233
|
-
var
|
|
234
|
-
const
|
|
235
|
-
{ ...
|
|
236
|
-
|
|
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(
|
|
240
|
-
const [d = "span", p =
|
|
241
|
-
|
|
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
|
-
|
|
244
|
-
}),
|
|
89
|
+
s = { ...m, text: r.text };
|
|
90
|
+
}), s;
|
|
245
91
|
}
|
|
246
|
-
return
|
|
92
|
+
return r.text ?? "";
|
|
247
93
|
}
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
return
|
|
251
|
-
const [i = "div",
|
|
252
|
-
return
|
|
253
|
-
},
|
|
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
|
-
},
|
|
103
|
+
}, lr = (r, o) => ({
|
|
258
104
|
...Object.fromEntries(
|
|
259
|
-
Object.entries(
|
|
105
|
+
Object.entries(o).map(([n, e]) => [(r == null ? void 0 : r[n]) ?? (B == null ? void 0 : B[n]) ?? n, e])
|
|
260
106
|
)
|
|
261
|
-
}),
|
|
107
|
+
}), H = {}, pr = (r) => {
|
|
262
108
|
const {
|
|
263
|
-
content:
|
|
264
|
-
serializers:
|
|
265
|
-
componentSerializers:
|
|
109
|
+
content: o,
|
|
110
|
+
serializers: n = [],
|
|
111
|
+
componentSerializers: e = [],
|
|
266
112
|
renderingNodes: i,
|
|
267
|
-
remappedAttributes:
|
|
268
|
-
themeName:
|
|
269
|
-
tokens:
|
|
270
|
-
customTheme:
|
|
271
|
-
} =
|
|
272
|
-
return
|
|
273
|
-
|
|
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,
|
|
277
|
-
const
|
|
278
|
-
...
|
|
122
|
+
(p, k, l) => {
|
|
123
|
+
const b = {
|
|
124
|
+
...k,
|
|
279
125
|
style: void 0
|
|
280
|
-
},
|
|
281
|
-
return f ? f({ children:
|
|
282
|
-
|
|
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
|
-
...
|
|
286
|
-
themeName:
|
|
287
|
-
tokens:
|
|
288
|
-
customTheme:
|
|
289
|
-
children:
|
|
131
|
+
...g,
|
|
132
|
+
themeName: s,
|
|
133
|
+
tokens: a,
|
|
134
|
+
customTheme: m,
|
|
135
|
+
children: l
|
|
290
136
|
},
|
|
291
|
-
JSON.stringify(
|
|
137
|
+
JSON.stringify(l)
|
|
292
138
|
);
|
|
293
139
|
}
|
|
294
140
|
);
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
ue,
|
|
299
|
-
oe,
|
|
300
|
-
ie,
|
|
301
|
-
ne,
|
|
302
|
-
ee,
|
|
303
|
-
me,
|
|
304
|
-
le,
|
|
141
|
+
}, fr = [
|
|
142
|
+
P,
|
|
143
|
+
nr,
|
|
305
144
|
Y,
|
|
306
|
-
|
|
307
|
-
|
|
145
|
+
V,
|
|
146
|
+
W,
|
|
147
|
+
F,
|
|
148
|
+
K,
|
|
149
|
+
X,
|
|
150
|
+
U,
|
|
151
|
+
D,
|
|
152
|
+
$,
|
|
153
|
+
Q,
|
|
154
|
+
_,
|
|
155
|
+
G,
|
|
308
156
|
Z,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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:
|
|
322
|
-
editorNodes:
|
|
323
|
-
serializers:
|
|
167
|
+
jsonContent: o,
|
|
168
|
+
editorNodes: n,
|
|
169
|
+
serializers: e,
|
|
324
170
|
nodes: i,
|
|
325
|
-
config:
|
|
326
|
-
relationMarksConfig:
|
|
327
|
-
themeName:
|
|
328
|
-
tokens:
|
|
329
|
-
customTheme:
|
|
171
|
+
config: t,
|
|
172
|
+
relationMarksConfig: s,
|
|
173
|
+
themeName: a,
|
|
174
|
+
tokens: m,
|
|
175
|
+
customTheme: u,
|
|
330
176
|
remappedAttributes: d
|
|
331
|
-
} =
|
|
332
|
-
var
|
|
333
|
-
const { attrs:
|
|
334
|
-
if (
|
|
335
|
-
if (!((
|
|
336
|
-
const
|
|
337
|
-
return /* @__PURE__ */
|
|
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
|
|
340
|
-
return /* @__PURE__ */
|
|
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
|
-
},
|
|
189
|
+
}, b = L.create({
|
|
344
190
|
name: "relation-block",
|
|
345
191
|
renderHTML: () => ["relation-block"],
|
|
346
|
-
render: (f) =>
|
|
347
|
-
}),
|
|
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) =>
|
|
351
|
-
}),
|
|
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) =>
|
|
201
|
+
render: (f) => l(f, s)
|
|
356
202
|
});
|
|
357
|
-
return
|
|
358
|
-
|
|
203
|
+
return k.push(b, g, y), p ? /* @__PURE__ */ x(
|
|
204
|
+
pr,
|
|
359
205
|
{
|
|
360
206
|
content: p,
|
|
361
|
-
serializers:
|
|
207
|
+
serializers: k,
|
|
362
208
|
renderingNodes: i,
|
|
363
|
-
themeName:
|
|
364
|
-
tokens:
|
|
365
|
-
customTheme:
|
|
209
|
+
themeName: a,
|
|
210
|
+
tokens: m,
|
|
211
|
+
customTheme: u,
|
|
366
212
|
remappedAttributes: d
|
|
367
213
|
}
|
|
368
214
|
) : null;
|
|
369
215
|
};
|
|
370
216
|
export {
|
|
371
|
-
|
|
372
|
-
|
|
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').
|
|
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
|
|
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.
|
|
27
|
-
"@okam/stack-ui": "1.44.
|
|
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",
|