camox 0.31.5 → 0.32.0
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/dist/core/components/lexical/InlineLexicalEditor.js +79 -11
- package/dist/core/components/lexical/SelectionBroadcaster.js +106 -20
- package/dist/core/components/lexical/SidebarLexicalEditor.js +442 -8
- package/dist/core/components/lexical/TextLinkPopover.js +327 -0
- package/dist/core/components/lexical/editorConfig.js +11 -5
- package/dist/core/createApp.d.ts +9 -0
- package/dist/core/createBlock.d.ts +6 -1
- package/dist/core/createBlock.js +31 -20
- package/dist/core/lib/lexicalReact.d.ts +26 -0
- package/dist/core/lib/lexicalReact.js +50 -15
- package/dist/core/lib/lexicalState.js +34 -0
- package/dist/core/lib/textLinks.js +28 -0
- package/dist/features/preview/components/FieldToolbar.js +141 -71
- package/dist/features/vite/vite.js +2 -0
- package/dist/studio.css +1 -1
- package/package.json +5 -4
- package/skills/camox-block/SKILL.md +23 -1
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { useProjectSlug } from "../../../lib/auth.js";
|
|
2
|
+
import { pageQueries, projectQueries } from "../../../lib/queries.js";
|
|
3
|
+
import { createPageTextLinkTarget, getPageIdFromTextLinkTarget } from "../../lib/textLinks.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { Input } from "@camox/ui/input";
|
|
6
|
+
import { Label } from "@camox/ui/label";
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@camox/ui/popover";
|
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Button } from "@camox/ui/button";
|
|
12
|
+
import { Link2 } from "lucide-react";
|
|
13
|
+
import { Tabs, TabsList, TabsTrigger } from "@camox/ui/tabs";
|
|
14
|
+
|
|
15
|
+
//#region src/core/components/lexical/TextLinkPopover.tsx
|
|
16
|
+
function TextLinkPopover(t0) {
|
|
17
|
+
const $ = c(67);
|
|
18
|
+
if ($[0] !== "7c8db8e526690648d7ded9c61109093d7db1e840e5fd768c697120d428d94f0f") {
|
|
19
|
+
for (let $i = 0; $i < 67; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
20
|
+
$[0] = "7c8db8e526690648d7ded9c61109093d7db1e840e5fd768c697120d428d94f0f";
|
|
21
|
+
}
|
|
22
|
+
const { open, onOpenChange, trigger, text, target, onSave, onUnlink } = t0;
|
|
23
|
+
const [textValue, setTextValue] = React.useState(text);
|
|
24
|
+
const [mode, setMode] = React.useState("page");
|
|
25
|
+
const [pageValue, setPageValue] = React.useState("");
|
|
26
|
+
const [urlValue, setUrlValue] = React.useState("");
|
|
27
|
+
const projectSlug = useProjectSlug();
|
|
28
|
+
let t1;
|
|
29
|
+
if ($[1] !== projectSlug) {
|
|
30
|
+
t1 = projectQueries.getBySlug(projectSlug);
|
|
31
|
+
$[1] = projectSlug;
|
|
32
|
+
$[2] = t1;
|
|
33
|
+
} else t1 = $[2];
|
|
34
|
+
const { data: project } = useQuery(t1);
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[3] !== project?.id) {
|
|
37
|
+
t2 = pageQueries.list(project?.id ?? 0);
|
|
38
|
+
$[3] = project?.id;
|
|
39
|
+
$[4] = t2;
|
|
40
|
+
} else t2 = $[4];
|
|
41
|
+
const t3 = !!project;
|
|
42
|
+
let t4;
|
|
43
|
+
if ($[5] !== t2 || $[6] !== t3) {
|
|
44
|
+
t4 = {
|
|
45
|
+
...t2,
|
|
46
|
+
enabled: t3
|
|
47
|
+
};
|
|
48
|
+
$[5] = t2;
|
|
49
|
+
$[6] = t3;
|
|
50
|
+
$[7] = t4;
|
|
51
|
+
} else t4 = $[7];
|
|
52
|
+
const { data: pages } = useQuery(t4);
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[8] !== target || $[9] !== text) {
|
|
55
|
+
t5 = () => {
|
|
56
|
+
setTextValue(text);
|
|
57
|
+
const pageId = target ? getPageIdFromTextLinkTarget(target) : null;
|
|
58
|
+
if (pageId != null) {
|
|
59
|
+
setMode("page");
|
|
60
|
+
setPageValue(pageId);
|
|
61
|
+
setUrlValue("");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setMode("external");
|
|
65
|
+
setUrlValue(target ?? "");
|
|
66
|
+
setPageValue("");
|
|
67
|
+
};
|
|
68
|
+
$[8] = target;
|
|
69
|
+
$[9] = text;
|
|
70
|
+
$[10] = t5;
|
|
71
|
+
} else t5 = $[10];
|
|
72
|
+
const prepare = t5;
|
|
73
|
+
let t6;
|
|
74
|
+
let t7;
|
|
75
|
+
if ($[11] !== open || $[12] !== prepare) {
|
|
76
|
+
t6 = () => {
|
|
77
|
+
if (!open) return;
|
|
78
|
+
prepare();
|
|
79
|
+
};
|
|
80
|
+
t7 = [open, prepare];
|
|
81
|
+
$[11] = open;
|
|
82
|
+
$[12] = prepare;
|
|
83
|
+
$[13] = t6;
|
|
84
|
+
$[14] = t7;
|
|
85
|
+
} else {
|
|
86
|
+
t6 = $[13];
|
|
87
|
+
t7 = $[14];
|
|
88
|
+
}
|
|
89
|
+
React.useEffect(t6, t7);
|
|
90
|
+
let t8;
|
|
91
|
+
if ($[15] !== onOpenChange || $[16] !== prepare) {
|
|
92
|
+
t8 = (nextOpen) => {
|
|
93
|
+
onOpenChange(nextOpen);
|
|
94
|
+
if (nextOpen) prepare();
|
|
95
|
+
};
|
|
96
|
+
$[15] = onOpenChange;
|
|
97
|
+
$[16] = prepare;
|
|
98
|
+
$[17] = t8;
|
|
99
|
+
} else t8 = $[17];
|
|
100
|
+
const handleOpenChange = t8;
|
|
101
|
+
let t9;
|
|
102
|
+
if ($[18] !== mode || $[19] !== onSave || $[20] !== pageValue || $[21] !== textValue || $[22] !== urlValue) {
|
|
103
|
+
t9 = (event) => {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const nextText = textValue.trim();
|
|
106
|
+
if (!nextText) return;
|
|
107
|
+
if (mode === "page") {
|
|
108
|
+
if (!pageValue) return;
|
|
109
|
+
onSave(createPageTextLinkTarget(pageValue), nextText);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const nextTarget = urlValue.trim();
|
|
113
|
+
if (!/^https?:\/\//i.test(nextTarget)) return;
|
|
114
|
+
onSave(nextTarget, nextText);
|
|
115
|
+
};
|
|
116
|
+
$[18] = mode;
|
|
117
|
+
$[19] = onSave;
|
|
118
|
+
$[20] = pageValue;
|
|
119
|
+
$[21] = textValue;
|
|
120
|
+
$[22] = urlValue;
|
|
121
|
+
$[23] = t9;
|
|
122
|
+
} else t9 = $[23];
|
|
123
|
+
const handleSubmit = t9;
|
|
124
|
+
let t10;
|
|
125
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
126
|
+
t10 = /* @__PURE__ */ jsx(Link2, {});
|
|
127
|
+
$[24] = t10;
|
|
128
|
+
} else t10 = $[24];
|
|
129
|
+
let t11;
|
|
130
|
+
if ($[25] !== trigger) {
|
|
131
|
+
t11 = /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
132
|
+
render: trigger,
|
|
133
|
+
children: t10
|
|
134
|
+
});
|
|
135
|
+
$[25] = trigger;
|
|
136
|
+
$[26] = t11;
|
|
137
|
+
} else t11 = $[26];
|
|
138
|
+
let t12;
|
|
139
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
140
|
+
t12 = /* @__PURE__ */ jsx(Label, {
|
|
141
|
+
htmlFor: "text-link-text",
|
|
142
|
+
children: "Text"
|
|
143
|
+
});
|
|
144
|
+
$[27] = t12;
|
|
145
|
+
} else t12 = $[27];
|
|
146
|
+
let t13;
|
|
147
|
+
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
148
|
+
t13 = (event_0) => setTextValue(event_0.target.value);
|
|
149
|
+
$[28] = t13;
|
|
150
|
+
} else t13 = $[28];
|
|
151
|
+
let t14;
|
|
152
|
+
if ($[29] !== textValue) {
|
|
153
|
+
t14 = /* @__PURE__ */ jsxs("div", {
|
|
154
|
+
className: "grid gap-1.5",
|
|
155
|
+
children: [t12, /* @__PURE__ */ jsx(Input, {
|
|
156
|
+
id: "text-link-text",
|
|
157
|
+
value: textValue,
|
|
158
|
+
onChange: t13,
|
|
159
|
+
autoFocus: true
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
$[29] = textValue;
|
|
163
|
+
$[30] = t14;
|
|
164
|
+
} else t14 = $[30];
|
|
165
|
+
let t15;
|
|
166
|
+
if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
|
|
167
|
+
t15 = /* @__PURE__ */ jsx(Label, { children: "Destination" });
|
|
168
|
+
$[31] = t15;
|
|
169
|
+
} else t15 = $[31];
|
|
170
|
+
let t16;
|
|
171
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
172
|
+
t16 = (nextMode) => setMode(nextMode);
|
|
173
|
+
$[32] = t16;
|
|
174
|
+
} else t16 = $[32];
|
|
175
|
+
let t17;
|
|
176
|
+
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
|
177
|
+
t17 = /* @__PURE__ */ jsxs(TabsList, {
|
|
178
|
+
className: "w-full",
|
|
179
|
+
children: [/* @__PURE__ */ jsx(TabsTrigger, {
|
|
180
|
+
value: "page",
|
|
181
|
+
children: "Page"
|
|
182
|
+
}), /* @__PURE__ */ jsx(TabsTrigger, {
|
|
183
|
+
value: "external",
|
|
184
|
+
children: "URL"
|
|
185
|
+
})]
|
|
186
|
+
});
|
|
187
|
+
$[33] = t17;
|
|
188
|
+
} else t17 = $[33];
|
|
189
|
+
let t18;
|
|
190
|
+
if ($[34] !== mode) {
|
|
191
|
+
t18 = /* @__PURE__ */ jsx(Tabs, {
|
|
192
|
+
value: mode,
|
|
193
|
+
onValueChange: t16,
|
|
194
|
+
children: t17
|
|
195
|
+
});
|
|
196
|
+
$[34] = mode;
|
|
197
|
+
$[35] = t18;
|
|
198
|
+
} else t18 = $[35];
|
|
199
|
+
let t19;
|
|
200
|
+
if ($[36] !== mode || $[37] !== pageValue || $[38] !== pages || $[39] !== urlValue) {
|
|
201
|
+
t19 = mode === "page" ? /* @__PURE__ */ jsxs("select", {
|
|
202
|
+
className: "border-input bg-background text-foreground h-9 rounded-md border px-2 text-sm",
|
|
203
|
+
value: pageValue,
|
|
204
|
+
onChange: (event_1) => setPageValue(event_1.target.value),
|
|
205
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
206
|
+
value: "",
|
|
207
|
+
children: pages && pages.length > 0 ? "Select a page" : "No pages found"
|
|
208
|
+
}), pages?.map(_temp)]
|
|
209
|
+
}) : /* @__PURE__ */ jsx(Input, {
|
|
210
|
+
type: "url",
|
|
211
|
+
placeholder: "https://",
|
|
212
|
+
value: urlValue,
|
|
213
|
+
onChange: (event_2) => setUrlValue(event_2.target.value)
|
|
214
|
+
});
|
|
215
|
+
$[36] = mode;
|
|
216
|
+
$[37] = pageValue;
|
|
217
|
+
$[38] = pages;
|
|
218
|
+
$[39] = urlValue;
|
|
219
|
+
$[40] = t19;
|
|
220
|
+
} else t19 = $[40];
|
|
221
|
+
let t20;
|
|
222
|
+
if ($[41] !== t18 || $[42] !== t19) {
|
|
223
|
+
t20 = /* @__PURE__ */ jsxs("div", {
|
|
224
|
+
className: "grid gap-1.5",
|
|
225
|
+
children: [
|
|
226
|
+
t15,
|
|
227
|
+
t18,
|
|
228
|
+
t19
|
|
229
|
+
]
|
|
230
|
+
});
|
|
231
|
+
$[41] = t18;
|
|
232
|
+
$[42] = t19;
|
|
233
|
+
$[43] = t20;
|
|
234
|
+
} else t20 = $[43];
|
|
235
|
+
let t21;
|
|
236
|
+
if ($[44] !== mode || $[45] !== pageValue || $[46] !== textValue || $[47] !== urlValue) {
|
|
237
|
+
t21 = !textValue.trim() || (mode === "page" ? !pageValue : !/^https?:\/\//i.test(urlValue.trim()));
|
|
238
|
+
$[44] = mode;
|
|
239
|
+
$[45] = pageValue;
|
|
240
|
+
$[46] = textValue;
|
|
241
|
+
$[47] = urlValue;
|
|
242
|
+
$[48] = t21;
|
|
243
|
+
} else t21 = $[48];
|
|
244
|
+
let t22;
|
|
245
|
+
if ($[49] !== t21) {
|
|
246
|
+
t22 = /* @__PURE__ */ jsx(Button, {
|
|
247
|
+
type: "submit",
|
|
248
|
+
size: "sm",
|
|
249
|
+
disabled: t21,
|
|
250
|
+
children: "Save"
|
|
251
|
+
});
|
|
252
|
+
$[49] = t21;
|
|
253
|
+
$[50] = t22;
|
|
254
|
+
} else t22 = $[50];
|
|
255
|
+
let t23;
|
|
256
|
+
if ($[51] !== onUnlink || $[52] !== target) {
|
|
257
|
+
t23 = target && /* @__PURE__ */ jsx(Button, {
|
|
258
|
+
type: "button",
|
|
259
|
+
variant: "outline",
|
|
260
|
+
size: "sm",
|
|
261
|
+
onClick: onUnlink,
|
|
262
|
+
children: "Unlink"
|
|
263
|
+
});
|
|
264
|
+
$[51] = onUnlink;
|
|
265
|
+
$[52] = target;
|
|
266
|
+
$[53] = t23;
|
|
267
|
+
} else t23 = $[53];
|
|
268
|
+
let t24;
|
|
269
|
+
if ($[54] !== t22 || $[55] !== t23) {
|
|
270
|
+
t24 = /* @__PURE__ */ jsxs("div", {
|
|
271
|
+
className: "grid gap-2",
|
|
272
|
+
children: [t22, t23]
|
|
273
|
+
});
|
|
274
|
+
$[54] = t22;
|
|
275
|
+
$[55] = t23;
|
|
276
|
+
$[56] = t24;
|
|
277
|
+
} else t24 = $[56];
|
|
278
|
+
let t25;
|
|
279
|
+
if ($[57] !== handleSubmit || $[58] !== t14 || $[59] !== t20 || $[60] !== t24) {
|
|
280
|
+
t25 = /* @__PURE__ */ jsx(PopoverContent, {
|
|
281
|
+
align: "center",
|
|
282
|
+
className: "w-72 p-3",
|
|
283
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
284
|
+
className: "grid gap-3",
|
|
285
|
+
onSubmit: handleSubmit,
|
|
286
|
+
children: [
|
|
287
|
+
t14,
|
|
288
|
+
t20,
|
|
289
|
+
t24
|
|
290
|
+
]
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
$[57] = handleSubmit;
|
|
294
|
+
$[58] = t14;
|
|
295
|
+
$[59] = t20;
|
|
296
|
+
$[60] = t24;
|
|
297
|
+
$[61] = t25;
|
|
298
|
+
} else t25 = $[61];
|
|
299
|
+
let t26;
|
|
300
|
+
if ($[62] !== handleOpenChange || $[63] !== open || $[64] !== t11 || $[65] !== t25) {
|
|
301
|
+
t26 = /* @__PURE__ */ jsxs(Popover, {
|
|
302
|
+
open,
|
|
303
|
+
onOpenChange: handleOpenChange,
|
|
304
|
+
children: [t11, t25]
|
|
305
|
+
});
|
|
306
|
+
$[62] = handleOpenChange;
|
|
307
|
+
$[63] = open;
|
|
308
|
+
$[64] = t11;
|
|
309
|
+
$[65] = t25;
|
|
310
|
+
$[66] = t26;
|
|
311
|
+
} else t26 = $[66];
|
|
312
|
+
return t26;
|
|
313
|
+
}
|
|
314
|
+
function _temp(page) {
|
|
315
|
+
return /* @__PURE__ */ jsxs("option", {
|
|
316
|
+
value: page.id,
|
|
317
|
+
children: [
|
|
318
|
+
page.nickname,
|
|
319
|
+
" (",
|
|
320
|
+
page.fullPath,
|
|
321
|
+
")"
|
|
322
|
+
]
|
|
323
|
+
}, page.id);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
//#endregion
|
|
327
|
+
export { TextLinkPopover };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isLexicalState, markdownToLexicalState } from "../../lib/lexicalState.js";
|
|
2
2
|
import { InlineParagraphNode } from "./InlineParagraphNode.js";
|
|
3
|
+
import { LinkNode } from "@lexical/link";
|
|
3
4
|
import { ParagraphNode } from "lexical";
|
|
4
5
|
|
|
5
6
|
//#region src/core/components/lexical/editorConfig.ts
|
|
@@ -18,11 +19,16 @@ function createEditorConfig(initialState) {
|
|
|
18
19
|
onError: (error) => {
|
|
19
20
|
console.error("Lexical error:", error);
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
theme: { link: "camox-text-link" },
|
|
23
|
+
nodes: [
|
|
24
|
+
LinkNode,
|
|
25
|
+
InlineParagraphNode,
|
|
26
|
+
{
|
|
27
|
+
replace: ParagraphNode,
|
|
28
|
+
with: () => new InlineParagraphNode(),
|
|
29
|
+
withKlass: InlineParagraphNode
|
|
30
|
+
}
|
|
31
|
+
]
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
34
|
|
package/dist/core/createApp.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EmbedURL, FileValue, ImageValue, LinkValue } from "./lib/contentType.js";
|
|
2
|
+
import { MarkdownInlineComponents } from "./lib/lexicalReact.js";
|
|
2
3
|
import { Block, BlockComponentProps, PeekItem, RepeatableItemSeed } from "./createBlock.js";
|
|
3
4
|
import { Layout, LayoutBlockData, OgImageParams } from "./createLayout.js";
|
|
4
5
|
import * as _$_sinclair_typebox0 from "@sinclair/typebox";
|
|
@@ -28,9 +29,11 @@ declare function createApp({
|
|
|
28
29
|
}) => React.JSX.Element;
|
|
29
30
|
Field: <K extends never>({
|
|
30
31
|
name,
|
|
32
|
+
components,
|
|
31
33
|
children
|
|
32
34
|
}: {
|
|
33
35
|
name: K;
|
|
36
|
+
components?: MarkdownInlineComponents;
|
|
34
37
|
children: (props: {
|
|
35
38
|
children: React.ReactNode;
|
|
36
39
|
} & {
|
|
@@ -134,6 +137,7 @@ declare function createApp({
|
|
|
134
137
|
children: (item: {
|
|
135
138
|
Field: <F extends keyof { [F_1 in keyof ({}[K] extends (infer U)[] ? U : never) as ({}[K] extends (infer U)[] ? U : never)[F_1] extends string ? F_1 : never]: ({}[K] extends (infer U)[] ? U : never)[F_1] }>(props: {
|
|
136
139
|
name: F;
|
|
140
|
+
components?: MarkdownInlineComponents;
|
|
137
141
|
children: (props: {
|
|
138
142
|
children: React.ReactNode;
|
|
139
143
|
} & {
|
|
@@ -258,6 +262,7 @@ declare function createApp({
|
|
|
258
262
|
children: (item: {
|
|
259
263
|
Field: (props: {
|
|
260
264
|
name: string;
|
|
265
|
+
components?: MarkdownInlineComponents;
|
|
261
266
|
children: (props: {
|
|
262
267
|
children: React.ReactNode;
|
|
263
268
|
} & {
|
|
@@ -426,9 +431,11 @@ declare function createApp({
|
|
|
426
431
|
}) => React.JSX.Element;
|
|
427
432
|
Field: <K extends never>({
|
|
428
433
|
name,
|
|
434
|
+
components,
|
|
429
435
|
children
|
|
430
436
|
}: {
|
|
431
437
|
name: K;
|
|
438
|
+
components?: MarkdownInlineComponents;
|
|
432
439
|
children: (props: {
|
|
433
440
|
children: React.ReactNode;
|
|
434
441
|
} & {
|
|
@@ -532,6 +539,7 @@ declare function createApp({
|
|
|
532
539
|
children: (item: {
|
|
533
540
|
Field: <F extends keyof { [F_1 in keyof ({}[K] extends (infer U)[] ? U : never) as ({}[K] extends (infer U)[] ? U : never)[F_1] extends string ? F_1 : never]: ({}[K] extends (infer U)[] ? U : never)[F_1] }>(props: {
|
|
534
541
|
name: F;
|
|
542
|
+
components?: MarkdownInlineComponents;
|
|
535
543
|
children: (props: {
|
|
536
544
|
children: React.ReactNode;
|
|
537
545
|
} & {
|
|
@@ -656,6 +664,7 @@ declare function createApp({
|
|
|
656
664
|
children: (item: {
|
|
657
665
|
Field: (props: {
|
|
658
666
|
name: string;
|
|
667
|
+
components?: MarkdownInlineComponents;
|
|
659
668
|
children: (props: {
|
|
660
669
|
children: React.ReactNode;
|
|
661
670
|
} & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EmbedURL, FileValue, ImageValue, ItemSettingsBrand, LinkValue, ToMarkdownBuilder, Type } from "./lib/contentType.js";
|
|
2
|
+
import { MarkdownInlineComponents, MarkdownLinkRenderData, MarkdownLinkRenderProps } from "./lib/lexicalReact.js";
|
|
2
3
|
import * as _$_sinclair_typebox0 from "@sinclair/typebox";
|
|
3
4
|
import { Static, TSchema, Type as Type$1 } from "@sinclair/typebox";
|
|
4
5
|
import * as React from "react";
|
|
@@ -153,9 +154,11 @@ declare function createBlock<TSchemaShape extends Record<string, TSchema>, TSett
|
|
|
153
154
|
params: unknown[] & [];
|
|
154
155
|
})["static"] }, Exclude<keyof TSchemaShape, { [K_2 in keyof TSchemaShape]: TSchemaShape[K_2] extends _$_sinclair_typebox0.TReadonly<TSchema> ? TSchemaShape[K_2] extends _$_sinclair_typebox0.TOptional<TSchemaShape[K_2]> ? K_2 : never : never }[keyof TSchemaShape] | { [K_3 in keyof TSchemaShape]: TSchemaShape[K_3] extends _$_sinclair_typebox0.TReadonly<TSchema> ? TSchemaShape[K_3] extends _$_sinclair_typebox0.TOptional<TSchemaShape[K_3]> ? never : K_3 : never }[keyof TSchemaShape] | { [K_4 in keyof TSchemaShape]: TSchemaShape[K_4] extends _$_sinclair_typebox0.TOptional<TSchema> ? TSchemaShape[K_4] extends _$_sinclair_typebox0.TReadonly<TSchemaShape[K_4]> ? never : K_4 : never }[keyof TSchemaShape]>>>>[K_5] }>({
|
|
155
156
|
name,
|
|
157
|
+
components,
|
|
156
158
|
children
|
|
157
159
|
}: {
|
|
158
160
|
name: K;
|
|
161
|
+
components?: MarkdownInlineComponents;
|
|
159
162
|
children: (props: {
|
|
160
163
|
children: React.ReactNode;
|
|
161
164
|
} & {
|
|
@@ -515,6 +518,7 @@ declare function createBlock<TSchemaShape extends Record<string, TSchema>, TSett
|
|
|
515
518
|
params: unknown[] & [];
|
|
516
519
|
})["static"] }, Exclude<keyof TSchemaShape, { [K_2 in keyof TSchemaShape]: TSchemaShape[K_2] extends _$_sinclair_typebox0.TReadonly<TSchema> ? TSchemaShape[K_2] extends _$_sinclair_typebox0.TOptional<TSchemaShape[K_2]> ? K_2 : never : never }[keyof TSchemaShape] | { [K_3 in keyof TSchemaShape]: TSchemaShape[K_3] extends _$_sinclair_typebox0.TReadonly<TSchema> ? TSchemaShape[K_3] extends _$_sinclair_typebox0.TOptional<TSchemaShape[K_3]> ? never : K_3 : never }[keyof TSchemaShape] | { [K_4 in keyof TSchemaShape]: TSchemaShape[K_4] extends _$_sinclair_typebox0.TOptional<TSchema> ? TSchemaShape[K_4] extends _$_sinclair_typebox0.TReadonly<TSchemaShape[K_4]> ? never : K_4 : never }[keyof TSchemaShape]>>>>[K_5] }[K] extends (infer U)[] ? U : never)[F_1] }>(props: {
|
|
517
520
|
name: F;
|
|
521
|
+
components?: MarkdownInlineComponents;
|
|
518
522
|
children: (props: {
|
|
519
523
|
children: React.ReactNode;
|
|
520
524
|
} & {
|
|
@@ -1239,6 +1243,7 @@ declare function createBlock<TSchemaShape extends Record<string, TSchema>, TSett
|
|
|
1239
1243
|
children: (item: {
|
|
1240
1244
|
Field: (props: {
|
|
1241
1245
|
name: string;
|
|
1246
|
+
components?: MarkdownInlineComponents;
|
|
1242
1247
|
children: (props: {
|
|
1243
1248
|
children: React.ReactNode;
|
|
1244
1249
|
} & {
|
|
@@ -1448,4 +1453,4 @@ declare function createBlock<TSchemaShape extends Record<string, TSchema>, TSett
|
|
|
1448
1453
|
};
|
|
1449
1454
|
type Block = ReturnType<typeof createBlock>;
|
|
1450
1455
|
//#endregion
|
|
1451
|
-
export { Block, BlockComponentProps, PeekItem, RepeatableItemSeed, Type, createBlock };
|
|
1456
|
+
export { Block, BlockComponentProps, type MarkdownInlineComponents, type MarkdownLinkRenderData, type MarkdownLinkRenderProps, PeekItem, RepeatableItemSeed, Type, createBlock };
|
package/dist/core/createBlock.js
CHANGED
|
@@ -189,13 +189,20 @@ function createBlock(options) {
|
|
|
189
189
|
if (repeaterContext?.itemId != null) return `${blockId}__${repeaterContext.itemId}__${fieldName}`;
|
|
190
190
|
return `${blockId}__${fieldName}`;
|
|
191
191
|
};
|
|
192
|
-
const Field = ({ name, children }) => {
|
|
192
|
+
const Field = ({ name, components, children }) => {
|
|
193
193
|
const blockContext = React.use(Context);
|
|
194
194
|
if (!blockContext) throw new Error("Field must be used within a Block Component");
|
|
195
195
|
const { blockId, content, mode } = blockContext;
|
|
196
196
|
const isContentEditable = useIsEditable(mode);
|
|
197
197
|
const elementRef = React.useRef(null);
|
|
198
198
|
const { window: iframeWindow } = useFrame();
|
|
199
|
+
const projectSlug = useProjectSlug();
|
|
200
|
+
const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
|
|
201
|
+
const { data: pages } = useQuery({
|
|
202
|
+
...pageQueries.list(project?.id ?? 0),
|
|
203
|
+
enabled: !!project
|
|
204
|
+
});
|
|
205
|
+
const currentPathname = useLocation({ select: (l) => l.pathname });
|
|
199
206
|
const repeaterContext = React.use(RepeaterItemContext);
|
|
200
207
|
const fieldId = getOverlayFieldId(blockId, repeaterContext, String(name));
|
|
201
208
|
const fieldValue = repeaterContext ? repeaterContext.itemContent[name] : content[name];
|
|
@@ -262,7 +269,11 @@ function createBlock(options) {
|
|
|
262
269
|
if (isContentEditable) setIsHovered(false);
|
|
263
270
|
};
|
|
264
271
|
const fieldData = { text: fieldValue };
|
|
265
|
-
if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: markdownToReactNodes(fieldValue
|
|
272
|
+
if (!isContentEditable) return /* @__PURE__ */ jsx(Fragment, { children: children({ children: markdownToReactNodes(fieldValue, {
|
|
273
|
+
pages,
|
|
274
|
+
fallbackHref: currentPathname,
|
|
275
|
+
components
|
|
276
|
+
}) }, fieldData) });
|
|
266
277
|
return /* @__PURE__ */ jsx(Fragment, { children: children({
|
|
267
278
|
ref: elementRef,
|
|
268
279
|
"data-camox-field-id": fieldId,
|
|
@@ -282,9 +293,9 @@ function createBlock(options) {
|
|
|
282
293
|
};
|
|
283
294
|
const Embed = (t0) => {
|
|
284
295
|
const $ = c(59);
|
|
285
|
-
if ($[0] !== "
|
|
296
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
286
297
|
for (let $i = 0; $i < 59; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
287
|
-
$[0] = "
|
|
298
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
288
299
|
}
|
|
289
300
|
const { name, children } = t0;
|
|
290
301
|
const blockContext = React.use(Context);
|
|
@@ -532,9 +543,9 @@ function createBlock(options) {
|
|
|
532
543
|
};
|
|
533
544
|
const Link = (t0) => {
|
|
534
545
|
const $ = c(38);
|
|
535
|
-
if ($[0] !== "
|
|
546
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
536
547
|
for (let $i = 0; $i < 38; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
537
|
-
$[0] = "
|
|
548
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
538
549
|
}
|
|
539
550
|
const { name, children } = t0;
|
|
540
551
|
const blockContext = React.use(Context);
|
|
@@ -773,9 +784,9 @@ function createBlock(options) {
|
|
|
773
784
|
};
|
|
774
785
|
const Image = (t0) => {
|
|
775
786
|
const $ = c(22);
|
|
776
|
-
if ($[0] !== "
|
|
787
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
777
788
|
for (let $i = 0; $i < 22; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
778
|
-
$[0] = "
|
|
789
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
779
790
|
}
|
|
780
791
|
const { name, children } = t0;
|
|
781
792
|
const blockContext = React.use(Context);
|
|
@@ -897,9 +908,9 @@ function createBlock(options) {
|
|
|
897
908
|
};
|
|
898
909
|
const File = (t0) => {
|
|
899
910
|
const $ = c(9);
|
|
900
|
-
if ($[0] !== "
|
|
911
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
901
912
|
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
902
|
-
$[0] = "
|
|
913
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
903
914
|
}
|
|
904
915
|
const { name, children } = t0;
|
|
905
916
|
const blockContext = React.use(Context);
|
|
@@ -974,9 +985,9 @@ function createBlock(options) {
|
|
|
974
985
|
const FileList = _AssetList;
|
|
975
986
|
const RepeaterItemWrapper = (t0) => {
|
|
976
987
|
const $ = c(9);
|
|
977
|
-
if ($[0] !== "
|
|
988
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
978
989
|
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
979
|
-
$[0] = "
|
|
990
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
980
991
|
}
|
|
981
992
|
const { itemId, blockId, mode, children } = t0;
|
|
982
993
|
const isContentEditable = useIsEditable(mode);
|
|
@@ -1017,9 +1028,9 @@ function createBlock(options) {
|
|
|
1017
1028
|
};
|
|
1018
1029
|
const RepeaterHoverProvider = (t0) => {
|
|
1019
1030
|
const $ = c(7);
|
|
1020
|
-
if ($[0] !== "
|
|
1031
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
1021
1032
|
for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
1022
|
-
$[0] = "
|
|
1033
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
1023
1034
|
}
|
|
1024
1035
|
const { blockId, fieldName, children } = t0;
|
|
1025
1036
|
const isContentEditable = useIsEditable("site");
|
|
@@ -1050,9 +1061,9 @@ function createBlock(options) {
|
|
|
1050
1061
|
};
|
|
1051
1062
|
const Repeater = (t0) => {
|
|
1052
1063
|
const $ = c(27);
|
|
1053
|
-
if ($[0] !== "
|
|
1064
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
1054
1065
|
for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
1055
|
-
$[0] = "
|
|
1066
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
1056
1067
|
}
|
|
1057
1068
|
const { name, children } = t0;
|
|
1058
1069
|
const blockContext = React.use(Context);
|
|
@@ -1177,9 +1188,9 @@ function createBlock(options) {
|
|
|
1177
1188
|
};
|
|
1178
1189
|
const BlockComponent = (t0) => {
|
|
1179
1190
|
const $ = c(78);
|
|
1180
|
-
if ($[0] !== "
|
|
1191
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
1181
1192
|
for (let $i = 0; $i < 78; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
1182
|
-
$[0] = "
|
|
1193
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
1183
1194
|
}
|
|
1184
1195
|
const { blockData, mode, isFirstBlock, showAddBlockTop, showAddBlockBottom, addBlockAfterPosition } = t0;
|
|
1185
1196
|
const isContentEditable = useIsEditable(mode);
|
|
@@ -1513,9 +1524,9 @@ function createBlock(options) {
|
|
|
1513
1524
|
*/
|
|
1514
1525
|
const Detached = (t0) => {
|
|
1515
1526
|
const $ = c(31);
|
|
1516
|
-
if ($[0] !== "
|
|
1527
|
+
if ($[0] !== "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87") {
|
|
1517
1528
|
for (let $i = 0; $i < 31; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
1518
|
-
$[0] = "
|
|
1529
|
+
$[0] = "2de3817ad13c2f077917d526d0922e6872092cefc060bd582d58642907e6ee87";
|
|
1519
1530
|
}
|
|
1520
1531
|
const { children } = t0;
|
|
1521
1532
|
const ctx = React.use(Context);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/core/lib/lexicalReact.d.ts
|
|
4
|
+
interface MarkdownLinkRenderProps {
|
|
5
|
+
href: string;
|
|
6
|
+
target?: string;
|
|
7
|
+
rel?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
interface MarkdownLinkRenderData {
|
|
11
|
+
target: string;
|
|
12
|
+
href: string;
|
|
13
|
+
external: boolean;
|
|
14
|
+
pageId?: string;
|
|
15
|
+
}
|
|
16
|
+
interface MarkdownInlineComponents {
|
|
17
|
+
link?: (props: MarkdownLinkRenderProps, data: MarkdownLinkRenderData) => React.ReactNode;
|
|
18
|
+
strong?: (props: {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}) => React.ReactNode;
|
|
21
|
+
emphasis?: (props: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}) => React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { MarkdownInlineComponents, MarkdownLinkRenderData, MarkdownLinkRenderProps };
|