camox 0.3.0 → 0.4.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/components/AuthGate.js +2 -1
- package/dist/core/components/AddBlockControlBar.js +117 -44
- package/dist/core/components/lexical/InlineContentEditable.js +37 -17
- package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
- package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
- package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
- package/dist/core/createBlock.js +1172 -414
- package/dist/core/createLayout.js +48 -16
- package/dist/core/hooks/useFieldSelection.js +24 -13
- package/dist/core/hooks/useIsEditable.js +8 -2
- package/dist/core/hooks/useOverlayMessage.js +51 -20
- package/dist/features/content/CamoxContent.js +239 -107
- package/dist/features/content/components/AssetCard.js +78 -16
- package/dist/features/content/components/AssetCardSkeleton.js +11 -4
- package/dist/features/content/components/ContentSidebar.js +15 -8
- package/dist/features/content/components/UploadDropZone.js +77 -34
- package/dist/features/content/components/UploadProgressDrawer.js +201 -58
- package/dist/features/metadata/sitemap.js +15 -0
- package/dist/features/preview/CamoxPreview.js +447 -179
- package/dist/features/preview/components/AddBlockSheet.js +344 -167
- package/dist/features/preview/components/AgentChatSheet.js +32 -10
- package/dist/features/preview/components/AssetFieldEditor.js +185 -50
- package/dist/features/preview/components/AssetLightbox.js +60 -33
- package/dist/features/preview/components/AssetPickerGrid.js +203 -71
- package/dist/features/preview/components/BlockActionsPopover.js +295 -218
- package/dist/features/preview/components/CreatePageSheet.js +3 -3
- package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
- package/dist/features/preview/components/EditPageSheet.js +241 -86
- package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
- package/dist/features/preview/components/LinkFieldEditor.js +351 -153
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
- package/dist/features/preview/components/OverlayTracker.js +58 -23
- package/dist/features/preview/components/Overlays.js +85 -43
- package/dist/features/preview/components/PageContentSheet.js +18 -18
- package/dist/features/preview/components/PageLocationFieldset.js +229 -63
- package/dist/features/preview/components/PagePicker.js +27 -27
- package/dist/features/preview/components/PageTree.js +921 -319
- package/dist/features/preview/components/PeekedBlock.js +173 -63
- package/dist/features/preview/components/PreviewPanel.js +271 -148
- package/dist/features/preview/components/PreviewSideSheet.js +44 -11
- package/dist/features/preview/components/PreviewToolbar.js +262 -59
- package/dist/features/preview/components/RepeatableItemsList.js +187 -78
- package/dist/features/preview/components/ShikiMarkdown.js +46 -20
- package/dist/features/preview/components/TextFormatToolbar.js +81 -23
- package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
- package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
- package/dist/features/preview/previewStore.d.ts +2 -2
- package/dist/features/provider/CamoxProvider.js +69 -21
- package/dist/features/provider/actionsStore.d.ts +2 -2
- package/dist/features/provider/components/CamoxAppContext.js +15 -5
- package/dist/features/provider/components/CommandPalette.js +199 -92
- package/dist/features/provider/useAdminShortcuts.js +80 -64
- package/dist/features/routes/pageRoute.js +8 -1
- package/dist/features/studio/CamoxStudio.js +45 -9
- package/dist/features/studio/components/EnvironmentMenu.js +47 -12
- package/dist/features/studio/components/Navbar.js +163 -65
- package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -1
- package/dist/features/studio/components/ProjectMenu.js +284 -83
- package/dist/features/studio/components/UserButton.js +21 -6
- package/dist/features/studio/studioStore.d.ts +2 -2
- package/dist/features/studio/useTheme.js +128 -74
- package/dist/features/vite/definitionsSync.d.ts +7 -12
- package/dist/features/vite/definitionsSync.d.ts.map +1 -1
- package/dist/features/vite/definitionsSync.js +5 -16
- package/dist/features/vite/vite.d.ts +0 -3
- package/dist/features/vite/vite.d.ts.map +1 -1
- package/dist/features/vite/vite.js +1 -2
- package/dist/hooks/use-file-upload.js +11 -11
- package/dist/hooks/use-marquee-selection.js +121 -74
- package/dist/lib/auth.js +95 -51
- package/dist/lib/normalized-data.js +103 -30
- package/dist/lib/use-project-room.js +55 -22
- package/dist/studio.css +2 -2
- package/package.json +29 -26
- package/dist/lib/auth.d.ts +0 -2130
- package/dist/lib/auth.d.ts.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useAuthState } from "../lib/auth.js";
|
|
2
2
|
//#region src/components/AuthGate.tsx
|
|
3
|
-
function AuthGate(
|
|
3
|
+
function AuthGate(t0) {
|
|
4
|
+
const { authenticated, unauthenticated } = t0;
|
|
4
5
|
const { isAuthenticated, isLoading } = useAuthState();
|
|
5
6
|
if (isLoading) return unauthenticated;
|
|
6
7
|
return isAuthenticated ? authenticated : unauthenticated;
|
|
@@ -1,65 +1,138 @@
|
|
|
1
1
|
import { OVERLAY_COLORS } from "../../features/preview/overlayConstants.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
//#region src/core/components/AddBlockControlBar.tsx
|
|
5
|
-
var AddBlockControlBar = (
|
|
6
|
+
var AddBlockControlBar = (t0) => {
|
|
7
|
+
const $ = c(25);
|
|
8
|
+
const { position, hidden, onClick, onMouseLeave } = t0;
|
|
6
9
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
const t1 = position === "top" ? 0 : void 0;
|
|
11
|
+
const t2 = position === "bottom" ? 0 : void 0;
|
|
12
|
+
const t3 = position === "top" ? "translateX(-50%) translateY(-50%)" : "translateX(-50%) translateY(50%)";
|
|
13
|
+
const t4 = hidden ? 0 : 1;
|
|
14
|
+
const t5 = hidden ? "none" : "auto";
|
|
15
|
+
let t6;
|
|
16
|
+
if ($[0] !== t1 || $[1] !== t2 || $[2] !== t3 || $[3] !== t4 || $[4] !== t5) {
|
|
17
|
+
t6 = {
|
|
9
18
|
position: "absolute",
|
|
10
|
-
top:
|
|
11
|
-
bottom:
|
|
19
|
+
top: t1,
|
|
20
|
+
bottom: t2,
|
|
12
21
|
left: "50%",
|
|
13
22
|
right: 0,
|
|
14
23
|
height: "36px",
|
|
15
|
-
transform:
|
|
24
|
+
transform: t3,
|
|
16
25
|
width: "fit-content",
|
|
17
26
|
display: "flex",
|
|
18
27
|
alignItems: "center",
|
|
19
28
|
justifyContent: "center",
|
|
20
29
|
zIndex: 11,
|
|
21
|
-
opacity:
|
|
22
|
-
pointerEvents:
|
|
30
|
+
opacity: t4,
|
|
31
|
+
pointerEvents: t5,
|
|
23
32
|
transition: "opacity 150ms ease"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
};
|
|
34
|
+
$[0] = t1;
|
|
35
|
+
$[1] = t2;
|
|
36
|
+
$[2] = t3;
|
|
37
|
+
$[3] = t4;
|
|
38
|
+
$[4] = t5;
|
|
39
|
+
$[5] = t6;
|
|
40
|
+
} else t6 = $[5];
|
|
41
|
+
let t7;
|
|
42
|
+
let t8;
|
|
43
|
+
let t9;
|
|
44
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
45
|
+
t7 = {
|
|
46
|
+
width: "120px",
|
|
47
|
+
height: "36px",
|
|
48
|
+
display: "flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
justifyContent: "center"
|
|
51
|
+
};
|
|
52
|
+
t8 = () => setIsExpanded(true);
|
|
53
|
+
t9 = () => setIsExpanded(false);
|
|
54
|
+
$[6] = t7;
|
|
55
|
+
$[7] = t8;
|
|
56
|
+
$[8] = t9;
|
|
57
|
+
} else {
|
|
58
|
+
t7 = $[6];
|
|
59
|
+
t8 = $[7];
|
|
60
|
+
t9 = $[8];
|
|
61
|
+
}
|
|
62
|
+
const t10 = isExpanded ? "4px" : "0px";
|
|
63
|
+
const t11 = isExpanded ? "4px 8px" : "0px";
|
|
64
|
+
const t12 = isExpanded ? "auto" : "20px";
|
|
65
|
+
const t13 = isExpanded ? "auto" : "20px";
|
|
66
|
+
let t14;
|
|
67
|
+
if ($[9] !== t10 || $[10] !== t11 || $[11] !== t12 || $[12] !== t13) {
|
|
68
|
+
t14 = {
|
|
69
|
+
display: "flex",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
gap: t10,
|
|
72
|
+
padding: t11,
|
|
73
|
+
width: t12,
|
|
74
|
+
height: t13,
|
|
75
|
+
justifyContent: "center",
|
|
76
|
+
backgroundColor: OVERLAY_COLORS.selected,
|
|
77
|
+
color: "white",
|
|
78
|
+
border: "none",
|
|
79
|
+
borderRadius: "9999px",
|
|
80
|
+
fontSize: "12px",
|
|
81
|
+
fontWeight: 500,
|
|
82
|
+
cursor: "pointer",
|
|
83
|
+
whiteSpace: "nowrap",
|
|
84
|
+
transition: "all 150ms ease"
|
|
85
|
+
};
|
|
86
|
+
$[9] = t10;
|
|
87
|
+
$[10] = t11;
|
|
88
|
+
$[11] = t12;
|
|
89
|
+
$[12] = t13;
|
|
90
|
+
$[13] = t14;
|
|
91
|
+
} else t14 = $[13];
|
|
92
|
+
let t15;
|
|
93
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
94
|
+
t15 = /* @__PURE__ */ jsx("span", {
|
|
95
|
+
style: { lineHeight: 1 },
|
|
96
|
+
children: "+"
|
|
97
|
+
});
|
|
98
|
+
$[14] = t15;
|
|
99
|
+
} else t15 = $[14];
|
|
100
|
+
let t16;
|
|
101
|
+
if ($[15] !== isExpanded) {
|
|
102
|
+
t16 = isExpanded && /* @__PURE__ */ jsx("span", { children: "Add block" });
|
|
103
|
+
$[15] = isExpanded;
|
|
104
|
+
$[16] = t16;
|
|
105
|
+
} else t16 = $[16];
|
|
106
|
+
let t17;
|
|
107
|
+
if ($[17] !== onClick || $[18] !== t14 || $[19] !== t16) {
|
|
108
|
+
t17 = /* @__PURE__ */ jsx("div", {
|
|
109
|
+
style: t7,
|
|
110
|
+
onMouseEnter: t8,
|
|
111
|
+
onMouseLeave: t9,
|
|
36
112
|
children: /* @__PURE__ */ jsxs("button", {
|
|
37
|
-
style:
|
|
38
|
-
display: "flex",
|
|
39
|
-
alignItems: "center",
|
|
40
|
-
gap: isExpanded ? "4px" : "0px",
|
|
41
|
-
padding: isExpanded ? "4px 8px" : "0px",
|
|
42
|
-
width: isExpanded ? "auto" : "20px",
|
|
43
|
-
height: isExpanded ? "auto" : "20px",
|
|
44
|
-
justifyContent: "center",
|
|
45
|
-
backgroundColor: OVERLAY_COLORS.selected,
|
|
46
|
-
color: "white",
|
|
47
|
-
border: "none",
|
|
48
|
-
borderRadius: "9999px",
|
|
49
|
-
fontSize: "12px",
|
|
50
|
-
fontWeight: 500,
|
|
51
|
-
cursor: "pointer",
|
|
52
|
-
whiteSpace: "nowrap",
|
|
53
|
-
transition: "all 150ms ease"
|
|
54
|
-
},
|
|
113
|
+
style: t14,
|
|
55
114
|
onClick,
|
|
56
|
-
children: [
|
|
57
|
-
style: { lineHeight: 1 },
|
|
58
|
-
children: "+"
|
|
59
|
-
}), isExpanded && /* @__PURE__ */ jsx("span", { children: "Add block" })]
|
|
115
|
+
children: [t15, t16]
|
|
60
116
|
})
|
|
61
|
-
})
|
|
62
|
-
|
|
117
|
+
});
|
|
118
|
+
$[17] = onClick;
|
|
119
|
+
$[18] = t14;
|
|
120
|
+
$[19] = t16;
|
|
121
|
+
$[20] = t17;
|
|
122
|
+
} else t17 = $[20];
|
|
123
|
+
let t18;
|
|
124
|
+
if ($[21] !== onMouseLeave || $[22] !== t17 || $[23] !== t6) {
|
|
125
|
+
t18 = /* @__PURE__ */ jsx("div", {
|
|
126
|
+
style: t6,
|
|
127
|
+
onMouseLeave,
|
|
128
|
+
children: t17
|
|
129
|
+
});
|
|
130
|
+
$[21] = onMouseLeave;
|
|
131
|
+
$[22] = t17;
|
|
132
|
+
$[23] = t6;
|
|
133
|
+
$[24] = t18;
|
|
134
|
+
} else t18 = $[24];
|
|
135
|
+
return t18;
|
|
63
136
|
};
|
|
64
137
|
//#endregion
|
|
65
138
|
export { AddBlockControlBar };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
@@ -7,25 +8,44 @@ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext
|
|
|
7
8
|
* so it can be nested inside phrasing elements like <h1>, <p>, etc.
|
|
8
9
|
*/
|
|
9
10
|
var InlineContentEditable = React.forwardRef(function InlineContentEditable(props, ref) {
|
|
11
|
+
const $ = c(8);
|
|
10
12
|
const [editor] = useLexicalComposerContext();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return (el) => {
|
|
17
|
-
handleRef(el);
|
|
18
|
-
if (typeof ref === "function") ref(el);
|
|
19
|
-
else if (ref) ref.current = el;
|
|
13
|
+
let t0;
|
|
14
|
+
if ($[0] !== editor) {
|
|
15
|
+
t0 = (el) => {
|
|
16
|
+
if (el?.ownerDocument?.defaultView) editor.setRootElement(el);
|
|
17
|
+
else editor.setRootElement(null);
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
$[0] = editor;
|
|
20
|
+
$[1] = t0;
|
|
21
|
+
} else t0 = $[1];
|
|
22
|
+
const handleRef = t0;
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[2] !== handleRef || $[3] !== ref) {
|
|
25
|
+
t1 = (el_0) => {
|
|
26
|
+
handleRef(el_0);
|
|
27
|
+
if (typeof ref === "function") ref(el_0);
|
|
28
|
+
else if (ref) ref.current = el_0;
|
|
29
|
+
};
|
|
30
|
+
$[2] = handleRef;
|
|
31
|
+
$[3] = ref;
|
|
32
|
+
$[4] = t1;
|
|
33
|
+
} else t1 = $[4];
|
|
34
|
+
const mergedRef = t1;
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[5] !== mergedRef || $[6] !== props) {
|
|
37
|
+
t2 = /* @__PURE__ */ jsx("span", {
|
|
38
|
+
...props,
|
|
39
|
+
contentEditable: true,
|
|
40
|
+
ref: mergedRef,
|
|
41
|
+
role: "textbox",
|
|
42
|
+
spellCheck: true
|
|
43
|
+
});
|
|
44
|
+
$[5] = mergedRef;
|
|
45
|
+
$[6] = props;
|
|
46
|
+
$[7] = t2;
|
|
47
|
+
} else t2 = $[7];
|
|
48
|
+
return t2;
|
|
29
49
|
});
|
|
30
50
|
//#endregion
|
|
31
51
|
export { InlineContentEditable };
|
|
@@ -2,6 +2,7 @@ import { lexicalStateToMarkdown } from "../../lib/lexicalState.js";
|
|
|
2
2
|
import { createEditorConfig, normalizeLexicalState } from "./editorConfig.js";
|
|
3
3
|
import { InlineContentEditable } from "./InlineContentEditable.js";
|
|
4
4
|
import { SelectionBroadcaster } from "./SelectionBroadcaster.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
5
6
|
import { useFrame } from "@camox/ui/frame";
|
|
6
7
|
import * as React from "react";
|
|
7
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -11,11 +12,15 @@ import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
|
11
12
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
12
13
|
import { COMMAND_PRIORITY_LOW, KEY_ESCAPE_COMMAND } from "lexical";
|
|
13
14
|
//#region src/core/components/lexical/InlineLexicalEditor.tsx
|
|
14
|
-
function ExternalStateSync(
|
|
15
|
+
function ExternalStateSync(t0) {
|
|
16
|
+
const $ = c(7);
|
|
17
|
+
const { externalState } = t0;
|
|
15
18
|
const [editor] = useLexicalComposerContext();
|
|
16
19
|
const isFocusedRef = React.useRef(false);
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
let t1;
|
|
21
|
+
let t2;
|
|
22
|
+
if ($[0] !== editor) {
|
|
23
|
+
t1 = () => editor.registerRootListener((root) => {
|
|
19
24
|
if (!root) return;
|
|
20
25
|
const handleFocus = () => {
|
|
21
26
|
isFocusedRef.current = true;
|
|
@@ -30,31 +35,67 @@ function ExternalStateSync({ externalState }) {
|
|
|
30
35
|
root.removeEventListener("blur", handleBlur);
|
|
31
36
|
};
|
|
32
37
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
t2 = [editor];
|
|
39
|
+
$[0] = editor;
|
|
40
|
+
$[1] = t1;
|
|
41
|
+
$[2] = t2;
|
|
42
|
+
} else {
|
|
43
|
+
t1 = $[1];
|
|
44
|
+
t2 = $[2];
|
|
45
|
+
}
|
|
46
|
+
React.useEffect(t1, t2);
|
|
47
|
+
let t3;
|
|
48
|
+
let t4;
|
|
49
|
+
if ($[3] !== editor || $[4] !== externalState) {
|
|
50
|
+
t3 = () => {
|
|
51
|
+
if (isFocusedRef.current) return;
|
|
52
|
+
try {
|
|
53
|
+
const normalized = normalizeLexicalState(externalState);
|
|
54
|
+
const newState = editor.parseEditorState(normalized);
|
|
55
|
+
editor.setEditorState(newState);
|
|
56
|
+
} catch {}
|
|
57
|
+
};
|
|
58
|
+
t4 = [editor, externalState];
|
|
59
|
+
$[3] = editor;
|
|
60
|
+
$[4] = externalState;
|
|
61
|
+
$[5] = t3;
|
|
62
|
+
$[6] = t4;
|
|
63
|
+
} else {
|
|
64
|
+
t3 = $[5];
|
|
65
|
+
t4 = $[6];
|
|
66
|
+
}
|
|
67
|
+
React.useEffect(t3, t4);
|
|
42
68
|
return null;
|
|
43
69
|
}
|
|
44
70
|
function EscapeHandler() {
|
|
71
|
+
const $ = c(3);
|
|
45
72
|
const [editor] = useLexicalComposerContext();
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
let t0;
|
|
74
|
+
let t1;
|
|
75
|
+
if ($[0] !== editor) {
|
|
76
|
+
t0 = () => editor.registerCommand(KEY_ESCAPE_COMMAND, () => {
|
|
48
77
|
editor.getRootElement()?.blur();
|
|
49
78
|
return true;
|
|
50
79
|
}, COMMAND_PRIORITY_LOW);
|
|
51
|
-
|
|
80
|
+
t1 = [editor];
|
|
81
|
+
$[0] = editor;
|
|
82
|
+
$[1] = t0;
|
|
83
|
+
$[2] = t1;
|
|
84
|
+
} else {
|
|
85
|
+
t0 = $[1];
|
|
86
|
+
t1 = $[2];
|
|
87
|
+
}
|
|
88
|
+
React.useEffect(t0, t1);
|
|
52
89
|
return null;
|
|
53
90
|
}
|
|
54
|
-
function FocusBlurHandler(
|
|
91
|
+
function FocusBlurHandler(t0) {
|
|
92
|
+
const $ = c(5);
|
|
93
|
+
const { onFocus, onBlur } = t0;
|
|
55
94
|
const [editor] = useLexicalComposerContext();
|
|
56
|
-
|
|
57
|
-
|
|
95
|
+
let t1;
|
|
96
|
+
let t2;
|
|
97
|
+
if ($[0] !== editor || $[1] !== onBlur || $[2] !== onFocus) {
|
|
98
|
+
t1 = () => editor.registerRootListener((root) => {
|
|
58
99
|
if (!root) return;
|
|
59
100
|
root.addEventListener("focus", onFocus);
|
|
60
101
|
root.addEventListener("blur", onBlur);
|
|
@@ -63,11 +104,21 @@ function FocusBlurHandler({ onFocus, onBlur }) {
|
|
|
63
104
|
root.removeEventListener("blur", onBlur);
|
|
64
105
|
};
|
|
65
106
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
107
|
+
t2 = [
|
|
108
|
+
editor,
|
|
109
|
+
onFocus,
|
|
110
|
+
onBlur
|
|
111
|
+
];
|
|
112
|
+
$[0] = editor;
|
|
113
|
+
$[1] = onBlur;
|
|
114
|
+
$[2] = onFocus;
|
|
115
|
+
$[3] = t1;
|
|
116
|
+
$[4] = t2;
|
|
117
|
+
} else {
|
|
118
|
+
t1 = $[3];
|
|
119
|
+
t2 = $[4];
|
|
120
|
+
}
|
|
121
|
+
React.useEffect(t1, t2);
|
|
71
122
|
return null;
|
|
72
123
|
}
|
|
73
124
|
function InlineLexicalEditor({ initialState, externalState, onChange, onFocus, onBlur }) {
|
|
@@ -113,8 +164,16 @@ function InlineLexicalEditor({ initialState, externalState, onChange, onFocus, o
|
|
|
113
164
|
]
|
|
114
165
|
});
|
|
115
166
|
}
|
|
116
|
-
function LexicalErrorBoundary(
|
|
117
|
-
|
|
167
|
+
function LexicalErrorBoundary(t0) {
|
|
168
|
+
const $ = c(2);
|
|
169
|
+
const { children } = t0;
|
|
170
|
+
let t1;
|
|
171
|
+
if ($[0] !== children) {
|
|
172
|
+
t1 = /* @__PURE__ */ jsx(Fragment, { children });
|
|
173
|
+
$[0] = children;
|
|
174
|
+
$[1] = t1;
|
|
175
|
+
} else t1 = $[1];
|
|
176
|
+
return t1;
|
|
118
177
|
}
|
|
119
178
|
//#endregion
|
|
120
179
|
export { InlineLexicalEditor };
|
|
@@ -1,61 +1,98 @@
|
|
|
1
1
|
import { isOverlayMessage, postOverlayMessage } from "../../../features/preview/overlayMessages.js";
|
|
2
2
|
import { TEXT_MODIFIERS } from "../../lib/modifiers.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
5
6
|
import { $getSelection, $isRangeSelection, FORMAT_TEXT_COMMAND } from "lexical";
|
|
6
7
|
//#region src/core/components/lexical/SelectionBroadcaster.tsx
|
|
7
|
-
function SelectionBroadcaster(
|
|
8
|
+
function SelectionBroadcaster(t0) {
|
|
9
|
+
const $ = c(12);
|
|
10
|
+
const { targetWindow } = t0;
|
|
8
11
|
const [editor] = useLexicalComposerContext();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== editor || $[1] !== targetWindow) {
|
|
14
|
+
t1 = () => {
|
|
15
|
+
const nativeSelection = targetWindow.getSelection();
|
|
16
|
+
if (!(nativeSelection != null && nativeSelection.rangeCount > 0 && !nativeSelection.isCollapsed)) {
|
|
17
|
+
postOverlayMessage({
|
|
18
|
+
type: "CAMOX_TEXT_SELECTION_STATE",
|
|
19
|
+
hasSelection: false,
|
|
20
|
+
activeFormats: 0
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let format = 0;
|
|
25
|
+
editor.getEditorState().read(() => {
|
|
26
|
+
const selection = $getSelection();
|
|
27
|
+
if (!$isRangeSelection(selection)) return;
|
|
28
|
+
for (const modifier of Object.values(TEXT_MODIFIERS)) {
|
|
29
|
+
const key = modifier === TEXT_MODIFIERS.bold ? "bold" : "italic";
|
|
30
|
+
if (selection.hasFormat(key)) format = format | modifier.formatFlag;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
12
33
|
postOverlayMessage({
|
|
13
34
|
type: "CAMOX_TEXT_SELECTION_STATE",
|
|
14
|
-
hasSelection:
|
|
15
|
-
activeFormats:
|
|
35
|
+
hasSelection: true,
|
|
36
|
+
activeFormats: format
|
|
16
37
|
});
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let format = 0;
|
|
20
|
-
editor.getEditorState().read(() => {
|
|
21
|
-
const selection = $getSelection();
|
|
22
|
-
if (!$isRangeSelection(selection)) return;
|
|
23
|
-
for (const modifier of Object.values(TEXT_MODIFIERS)) {
|
|
24
|
-
const key = modifier === TEXT_MODIFIERS.bold ? "bold" : "italic";
|
|
25
|
-
if (selection.hasFormat(key)) format |= modifier.formatFlag;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
postOverlayMessage({
|
|
29
|
-
type: "CAMOX_TEXT_SELECTION_STATE",
|
|
30
|
-
hasSelection: true,
|
|
31
|
-
activeFormats: format
|
|
32
|
-
});
|
|
33
|
-
}, [editor, targetWindow]);
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
const doc = targetWindow.document;
|
|
36
|
-
const handleSelectionChange = () => broadcastSelection();
|
|
37
|
-
doc.addEventListener("selectionchange", handleSelectionChange);
|
|
38
|
-
return () => doc.removeEventListener("selectionchange", handleSelectionChange);
|
|
39
|
-
}, [targetWindow, broadcastSelection]);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
const handleMessage = (event) => {
|
|
42
|
-
const data = event.data;
|
|
43
|
-
if (!isOverlayMessage(data) || data.type !== "CAMOX_FORMAT_TEXT") return;
|
|
44
|
-
const root = editor.getRootElement();
|
|
45
|
-
const nativeSelection = targetWindow.getSelection();
|
|
46
|
-
if (!root || !nativeSelection || nativeSelection.rangeCount === 0) return;
|
|
47
|
-
if (!root.contains(nativeSelection.anchorNode)) return;
|
|
48
|
-
root.focus();
|
|
49
|
-
editor.dispatchCommand(FORMAT_TEXT_COMMAND, data.formatKey);
|
|
50
|
-
setTimeout(broadcastSelection, 10);
|
|
51
38
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
$[0] = editor;
|
|
40
|
+
$[1] = targetWindow;
|
|
41
|
+
$[2] = t1;
|
|
42
|
+
} else t1 = $[2];
|
|
43
|
+
const broadcastSelection = t1;
|
|
44
|
+
let t2;
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[3] !== broadcastSelection || $[4] !== targetWindow) {
|
|
47
|
+
t2 = () => {
|
|
48
|
+
const doc = targetWindow.document;
|
|
49
|
+
const handleSelectionChange = () => broadcastSelection();
|
|
50
|
+
doc.addEventListener("selectionchange", handleSelectionChange);
|
|
51
|
+
return () => doc.removeEventListener("selectionchange", handleSelectionChange);
|
|
52
|
+
};
|
|
53
|
+
t3 = [targetWindow, broadcastSelection];
|
|
54
|
+
$[3] = broadcastSelection;
|
|
55
|
+
$[4] = targetWindow;
|
|
56
|
+
$[5] = t2;
|
|
57
|
+
$[6] = t3;
|
|
58
|
+
} else {
|
|
59
|
+
t2 = $[5];
|
|
60
|
+
t3 = $[6];
|
|
61
|
+
}
|
|
62
|
+
React.useEffect(t2, t3);
|
|
63
|
+
let t4;
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[7] !== broadcastSelection || $[8] !== editor || $[9] !== targetWindow) {
|
|
66
|
+
t4 = () => {
|
|
67
|
+
const handleMessage = (event) => {
|
|
68
|
+
const data = event.data;
|
|
69
|
+
if (!isOverlayMessage(data) || data.type !== "CAMOX_FORMAT_TEXT") return;
|
|
70
|
+
const root = editor.getRootElement();
|
|
71
|
+
const nativeSelection_0 = targetWindow.getSelection();
|
|
72
|
+
if (!root || !nativeSelection_0 || nativeSelection_0.rangeCount === 0) return;
|
|
73
|
+
if (!root.contains(nativeSelection_0.anchorNode)) return;
|
|
74
|
+
root.focus();
|
|
75
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, data.formatKey);
|
|
76
|
+
setTimeout(broadcastSelection, 10);
|
|
77
|
+
};
|
|
78
|
+
targetWindow.addEventListener("message", handleMessage);
|
|
79
|
+
return () => targetWindow.removeEventListener("message", handleMessage);
|
|
80
|
+
};
|
|
81
|
+
t5 = [
|
|
82
|
+
editor,
|
|
83
|
+
targetWindow,
|
|
84
|
+
broadcastSelection
|
|
85
|
+
];
|
|
86
|
+
$[7] = broadcastSelection;
|
|
87
|
+
$[8] = editor;
|
|
88
|
+
$[9] = targetWindow;
|
|
89
|
+
$[10] = t4;
|
|
90
|
+
$[11] = t5;
|
|
91
|
+
} else {
|
|
92
|
+
t4 = $[10];
|
|
93
|
+
t5 = $[11];
|
|
94
|
+
}
|
|
95
|
+
React.useEffect(t4, t5);
|
|
59
96
|
return null;
|
|
60
97
|
}
|
|
61
98
|
//#endregion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lexicalStateToMarkdown } from "../../lib/lexicalState.js";
|
|
2
2
|
import { createEditorConfig, normalizeLexicalState } from "./editorConfig.js";
|
|
3
3
|
import { INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, cn } from "../../../lib/utils.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
@@ -9,11 +10,15 @@ import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
|
9
10
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
10
11
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
11
12
|
//#region src/core/components/lexical/SidebarLexicalEditor.tsx
|
|
12
|
-
function ExternalStateSync(
|
|
13
|
+
function ExternalStateSync(t0) {
|
|
14
|
+
const $ = c(8);
|
|
15
|
+
const { value, isSyncingRef } = t0;
|
|
13
16
|
const [editor] = useLexicalComposerContext();
|
|
14
17
|
const isFocusedRef = React.useRef(false);
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
let t1;
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[0] !== editor) {
|
|
21
|
+
t1 = () => editor.registerRootListener((root) => {
|
|
17
22
|
if (!root) return;
|
|
18
23
|
const handleFocus = () => {
|
|
19
24
|
isFocusedRef.current = true;
|
|
@@ -28,20 +33,42 @@ function ExternalStateSync({ value, isSyncingRef }) {
|
|
|
28
33
|
root.removeEventListener("blur", handleBlur);
|
|
29
34
|
};
|
|
30
35
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
t2 = [editor];
|
|
37
|
+
$[0] = editor;
|
|
38
|
+
$[1] = t1;
|
|
39
|
+
$[2] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t1 = $[1];
|
|
42
|
+
t2 = $[2];
|
|
43
|
+
}
|
|
44
|
+
React.useEffect(t1, t2);
|
|
45
|
+
let t3;
|
|
46
|
+
let t4;
|
|
47
|
+
if ($[3] !== editor || $[4] !== isSyncingRef || $[5] !== value) {
|
|
48
|
+
t3 = () => {
|
|
49
|
+
if (isFocusedRef.current) return;
|
|
50
|
+
try {
|
|
51
|
+
const normalized = normalizeLexicalState(value);
|
|
52
|
+
const newState = editor.parseEditorState(normalized);
|
|
53
|
+
isSyncingRef.current = true;
|
|
54
|
+
editor.setEditorState(newState);
|
|
55
|
+
} catch {}
|
|
56
|
+
};
|
|
57
|
+
t4 = [
|
|
58
|
+
editor,
|
|
59
|
+
value,
|
|
60
|
+
isSyncingRef
|
|
61
|
+
];
|
|
62
|
+
$[3] = editor;
|
|
63
|
+
$[4] = isSyncingRef;
|
|
64
|
+
$[5] = value;
|
|
65
|
+
$[6] = t3;
|
|
66
|
+
$[7] = t4;
|
|
67
|
+
} else {
|
|
68
|
+
t3 = $[6];
|
|
69
|
+
t4 = $[7];
|
|
70
|
+
}
|
|
71
|
+
React.useEffect(t3, t4);
|
|
45
72
|
return null;
|
|
46
73
|
}
|
|
47
74
|
function SidebarLexicalEditor({ value, onChange, onFocus, onBlur }) {
|
|
@@ -84,8 +111,16 @@ function SidebarLexicalEditor({ value, onChange, onFocus, onBlur }) {
|
|
|
84
111
|
]
|
|
85
112
|
});
|
|
86
113
|
}
|
|
87
|
-
function LexicalErrorBoundary(
|
|
88
|
-
|
|
114
|
+
function LexicalErrorBoundary(t0) {
|
|
115
|
+
const $ = c(2);
|
|
116
|
+
const { children } = t0;
|
|
117
|
+
let t1;
|
|
118
|
+
if ($[0] !== children) {
|
|
119
|
+
t1 = /* @__PURE__ */ jsx(Fragment, { children });
|
|
120
|
+
$[0] = children;
|
|
121
|
+
$[1] = t1;
|
|
122
|
+
} else t1 = $[1];
|
|
123
|
+
return t1;
|
|
89
124
|
}
|
|
90
125
|
//#endregion
|
|
91
126
|
export { SidebarLexicalEditor };
|