camox 0.40.0 → 0.41.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.
Files changed (97) hide show
  1. package/dist/components/PlatformLabel.js +62 -0
  2. package/dist/core/components/lexical/GradientNode.js +126 -0
  3. package/dist/core/components/lexical/InlineLexicalEditor.js +37 -56
  4. package/dist/core/components/lexical/InlineStylesPlugin.js +183 -0
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +49 -46
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +197 -151
  7. package/dist/core/components/lexical/editorConfig.js +25 -7
  8. package/dist/core/components/lexical/selectTextLink.js +21 -0
  9. package/dist/core/createApp.d.ts +30 -17
  10. package/dist/core/createApp.js +14 -3
  11. package/dist/core/createBlock.d.ts +2 -2
  12. package/dist/core/createBlock.js +18 -15
  13. package/dist/core/createLayout.d.ts +48 -4
  14. package/dist/core/createLayout.js +51 -23
  15. package/dist/core/derivedRoutes.js +36 -0
  16. package/dist/core/editing/createEditableBlock.d.ts +9 -8
  17. package/dist/core/editing/createEditableBlock.js +167 -168
  18. package/dist/core/lib/lexicalReact.d.ts +1 -26
  19. package/dist/core/lib/lexicalReact.js +46 -60
  20. package/dist/core/lib/lexicalState.js +164 -81
  21. package/dist/core/lib/modifierFormats.js +4 -15
  22. package/dist/core/lib/textStyles.d.ts +27 -0
  23. package/dist/core/lib/textStyles.js +47 -0
  24. package/dist/features/navigation/navigation.d.ts +2 -0
  25. package/dist/features/navigation/navigation.js +51 -46
  26. package/dist/features/page/DerivedPageContent.js +61 -0
  27. package/dist/features/page/PublishedPageContent.js +52 -83
  28. package/dist/features/page/SharedLayoutContent.js +66 -0
  29. package/dist/features/preview/CamoxPreview.d.ts +16 -1
  30. package/dist/features/preview/CamoxPreview.js +242 -265
  31. package/dist/features/preview/DerivedPreview.js +137 -0
  32. package/dist/features/preview/EditablePageExperience.js +25 -8
  33. package/dist/features/preview/components/AddBlockSidebar.js +43 -33
  34. package/dist/features/preview/components/AssetLightbox.js +1 -1
  35. package/dist/features/preview/components/BlockThumbnail.js +192 -0
  36. package/dist/features/preview/components/CreatePageModal.js +123 -115
  37. package/dist/features/preview/components/DerivedLayoutDialog.js +100 -0
  38. package/dist/features/preview/components/DerivedLayoutSidebar.d.ts +5 -0
  39. package/dist/features/preview/components/DerivedLayoutSidebar.js +163 -0
  40. package/dist/features/preview/components/DerivedPageInfoSidebar.js +57 -0
  41. package/dist/features/preview/components/FieldToolbar.js +42 -20
  42. package/dist/features/preview/components/Frame.js +133 -140
  43. package/dist/features/preview/components/LeftSidebar.js +42 -38
  44. package/dist/features/preview/components/MobilePreviewDrawer.js +4 -4
  45. package/dist/features/preview/components/Overlays.js +57 -42
  46. package/dist/features/preview/components/PageInfoSidebar.js +63 -55
  47. package/dist/features/preview/components/PageNavigatorSidebar.js +34 -483
  48. package/dist/features/preview/components/PagePicker.js +205 -153
  49. package/dist/features/preview/components/PageTree.js +298 -206
  50. package/dist/features/preview/components/PreviewActivation.js +78 -0
  51. package/dist/features/preview/components/PreviewPanel.js +67 -35
  52. package/dist/features/preview/components/PreviewToolbar.js +218 -232
  53. package/dist/features/preview/components/PublicationRow.js +431 -0
  54. package/dist/features/preview/components/PublishDialog.js +180 -97
  55. package/dist/features/preview/components/RightSidebar.js +19 -34
  56. package/dist/features/preview/components/previewStyles.js +8 -0
  57. package/dist/features/preview/components/useUpdateBlockPosition.js +7 -13
  58. package/dist/features/preview/previewConstants.js +8 -0
  59. package/dist/features/preview/previewStore.js +0 -10
  60. package/dist/features/preview/publication.js +71 -0
  61. package/dist/features/provider/AuthenticatedCamoxProvider.js +2 -1
  62. package/dist/features/provider/CoreCamoxProvider.js +11 -2
  63. package/dist/features/provider/LocalhostPreviewProvider.js +6 -7
  64. package/dist/features/routes/pageRuntime.d.ts +10 -0
  65. package/dist/features/routes/pageRuntime.js +7 -9
  66. package/dist/features/runtime/PreviewDocumentContext.js +7 -0
  67. package/dist/features/runtime/RuntimeChrome.js +137 -0
  68. package/dist/features/runtime/SharedChromeContext.js +7 -0
  69. package/dist/features/runtime/navigationRequest.js +21 -0
  70. package/dist/features/runtime/navigationTarget.js +23 -0
  71. package/dist/features/runtime/pageApp.js +196 -121
  72. package/dist/features/runtime/pageNavigation.js +79 -130
  73. package/dist/features/runtime/runtime.d.ts +11 -0
  74. package/dist/features/runtime/runtime.js +183 -47
  75. package/dist/features/runtime/studioApp.d.ts +2 -11
  76. package/dist/features/runtime/studioApp.js +14 -177
  77. package/dist/features/studio/CamoxStudio.js +27 -13
  78. package/dist/features/studio/components/Navbar.js +80 -74
  79. package/dist/features/studio/studioTheme.js +25 -0
  80. package/dist/features/studio/useTheme.js +94 -109
  81. package/dist/features/vite/appGeneration.js +12 -3
  82. package/dist/features/vite/definitionsSync.js +4 -2
  83. package/dist/features/vite/layoutGeneration.js +38 -0
  84. package/dist/features/vite/runtimeDev.js +3 -1
  85. package/dist/lib/auth.js +15 -13
  86. package/dist/lib/normalized-data.js +4 -4
  87. package/dist/lib/platform.js +13 -0
  88. package/dist/lib/utils.js +90 -38
  89. package/dist/studio-overlays.css +5 -40
  90. package/dist/studio.css +1 -1
  91. package/package.json +8 -4
  92. package/skills/camox/SKILL.md +2 -0
  93. package/skills/camox/references/block-definitions.md +31 -12
  94. package/skills/camox/references/layout-definitions.md +2 -0
  95. package/dist/core/lib/modifiers.js +0 -24
  96. package/dist/features/preview/previewQueryFns.js +0 -23
  97. package/dist/features/runtime/studioNavigation.js +0 -120
@@ -1,5 +1,7 @@
1
+ import { FORMAT_FLAGS } from "../../lib/modifierFormats.js";
1
2
  import { isOverlayMessage, postOverlayMessage } from "../../../features/preview/overlayMessages.js";
2
- import { TEXT_MODIFIERS } from "../../lib/modifiers.js";
3
+ import { $selectionHasGradient, $toggleGradient } from "./GradientNode.js";
4
+ import { selectTextLink } from "./selectTextLink.js";
3
5
  import { c } from "react/compiler-runtime";
4
6
  import * as React from "react";
5
7
  import { $createLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
@@ -21,10 +23,10 @@ function getLinkTargetFromSelection() {
21
23
  return null;
22
24
  }
23
25
  function SelectionBroadcaster(t0) {
24
- const $ = c(18);
25
- if ($[0] !== "e89fc1c958f4e83679744b18d31c960a1ed541e1ba675eee3f5a0ecee772b5f2") {
26
- for (let $i = 0; $i < 18; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
27
- $[0] = "e89fc1c958f4e83679744b18d31c960a1ed541e1ba675eee3f5a0ecee772b5f2";
26
+ const $ = c(20);
27
+ if ($[0] !== "9b38f39cf15304b288c351ba69b5c7891a3521400640cd47c3395c47e67ae59c") {
28
+ for (let $i = 0; $i < 20; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
29
+ $[0] = "9b38f39cf15304b288c351ba69b5c7891a3521400640cd47c3395c47e67ae59c";
28
30
  }
29
31
  const { targetWindow } = t0;
30
32
  const [editor] = useLexicalComposerContext();
@@ -49,10 +51,12 @@ function SelectionBroadcaster(t0) {
49
51
  const selection = $getSelection();
50
52
  if (!$isRangeSelection(selection)) return;
51
53
  lastTextSelectionRef.current = selection.clone();
52
- for (const modifier of Object.values(TEXT_MODIFIERS)) {
53
- const key = modifier === TEXT_MODIFIERS.bold ? "bold" : "italic";
54
- if (selection.hasFormat(key)) format = format | modifier.formatFlag;
55
- }
54
+ for (const key of [
55
+ "bold",
56
+ "italic",
57
+ "underline"
58
+ ]) if (selection.hasFormat(key)) format = format | FORMAT_FLAGS[key];
59
+ if ($selectionHasGradient()) format = format | FORMAT_FLAGS.gradient;
56
60
  linkTarget = getLinkTargetFromSelection();
57
61
  });
58
62
  postOverlayMessage({
@@ -88,8 +92,7 @@ function SelectionBroadcaster(t0) {
88
92
  }
89
93
  React.useEffect(t2, t3);
90
94
  let t4;
91
- let t5;
92
- if ($[8] !== broadcastSelection || $[9] !== editor || $[10] !== targetWindow) {
95
+ if ($[8] !== broadcastSelection || $[9] !== editor) {
93
96
  t4 = () => editor.registerRootListener((root) => {
94
97
  if (!root) return;
95
98
  const handleLinkClick = (event) => {
@@ -97,44 +100,42 @@ function SelectionBroadcaster(t0) {
97
100
  if (!(target instanceof HTMLElement)) return;
98
101
  const anchor = target.closest("a");
99
102
  if (!anchor || !root.contains(anchor)) return;
100
- const href = anchor.getAttribute("href");
101
- if (!href) return;
103
+ if (!(anchor.dataset.camoxLinkTarget ?? anchor.getAttribute("href"))) return;
102
104
  event.preventDefault();
103
105
  event.stopPropagation();
104
- const range = targetWindow.document.createRange();
105
- range.selectNodeContents(anchor);
106
- const selection_0 = targetWindow.getSelection();
107
- selection_0?.removeAllRanges();
108
- selection_0?.addRange(range);
109
- root.focus();
106
+ const link = selectTextLink(editor, anchor);
107
+ if (!link) return;
108
+ lastTextSelectionRef.current = link.selection;
110
109
  broadcastSelection();
111
110
  postOverlayMessage({
112
111
  type: "CAMOX_OPEN_TEXT_LINK_POPOVER",
113
- target: href,
114
- text: selection_0?.toString() ?? ""
112
+ target: link.target,
113
+ text: link.text
115
114
  });
116
115
  };
117
116
  root.addEventListener("click", handleLinkClick);
118
117
  return () => root.removeEventListener("click", handleLinkClick);
119
118
  });
119
+ $[8] = broadcastSelection;
120
+ $[9] = editor;
121
+ $[10] = t4;
122
+ } else t4 = $[10];
123
+ let t5;
124
+ if ($[11] !== broadcastSelection || $[12] !== editor || $[13] !== targetWindow) {
120
125
  t5 = [
121
126
  editor,
122
127
  targetWindow,
123
128
  broadcastSelection
124
129
  ];
125
- $[8] = broadcastSelection;
126
- $[9] = editor;
127
- $[10] = targetWindow;
128
- $[11] = t4;
129
- $[12] = t5;
130
- } else {
131
- t4 = $[11];
132
- t5 = $[12];
133
- }
130
+ $[11] = broadcastSelection;
131
+ $[12] = editor;
132
+ $[13] = targetWindow;
133
+ $[14] = t5;
134
+ } else t5 = $[14];
134
135
  React.useEffect(t4, t5);
135
136
  let t6;
136
137
  let t7;
137
- if ($[13] !== broadcastSelection || $[14] !== editor || $[15] !== targetWindow) {
138
+ if ($[15] !== broadcastSelection || $[16] !== editor || $[17] !== targetWindow) {
138
139
  t6 = () => {
139
140
  const handleMessage = (event_0) => {
140
141
  const data = event_0.data;
@@ -145,23 +146,25 @@ function SelectionBroadcaster(t0) {
145
146
  if (!root_0.contains(nativeSelection_0.anchorNode)) return;
146
147
  root_0.focus();
147
148
  editor.update(() => {
148
- const selection_1 = $getSelection();
149
- if ($isRangeSelection(selection_1) && !selection_1.isCollapsed()) {
150
- lastTextSelectionRef.current = selection_1.clone();
149
+ const selection_0 = $getSelection();
150
+ if ($isRangeSelection(selection_0) && !selection_0.isCollapsed()) {
151
+ lastTextSelectionRef.current = selection_0.clone();
151
152
  return;
152
153
  }
153
154
  if (lastTextSelectionRef.current) $setSelection(lastTextSelectionRef.current.clone());
154
155
  });
155
- if (data.type === "CAMOX_FORMAT_TEXT") editor.dispatchCommand(FORMAT_TEXT_COMMAND, data.formatKey);
156
- else if (data.target === null) editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
156
+ if (data.type === "CAMOX_FORMAT_TEXT") {
157
+ if (data.formatKey === "gradient") editor.update($toggleGradient);
158
+ else if (data.formatKey === "bold" || data.formatKey === "italic" || data.formatKey === "underline") editor.dispatchCommand(FORMAT_TEXT_COMMAND, data.formatKey);
159
+ } else if (data.target === null) editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
157
160
  else if (typeof data.text === "string") {
158
161
  const target_0 = data.target;
159
162
  editor.update(() => {
160
- const selection_2 = $getSelection();
161
- if (!$isRangeSelection(selection_2)) return;
163
+ const selection_1 = $getSelection();
164
+ if (!$isRangeSelection(selection_1)) return;
162
165
  const linkNode = $createLinkNode(target_0);
163
166
  linkNode.append($createTextNode(data.text));
164
- selection_2.insertNodes([linkNode]);
167
+ selection_1.insertNodes([linkNode]);
165
168
  });
166
169
  } else editor.dispatchCommand(TOGGLE_LINK_COMMAND, data.target);
167
170
  setTimeout(broadcastSelection, 10);
@@ -174,14 +177,14 @@ function SelectionBroadcaster(t0) {
174
177
  targetWindow,
175
178
  broadcastSelection
176
179
  ];
177
- $[13] = broadcastSelection;
178
- $[14] = editor;
179
- $[15] = targetWindow;
180
- $[16] = t6;
181
- $[17] = t7;
180
+ $[15] = broadcastSelection;
181
+ $[16] = editor;
182
+ $[17] = targetWindow;
183
+ $[18] = t6;
184
+ $[19] = t7;
182
185
  } else {
183
- t6 = $[16];
184
- t7 = $[17];
186
+ t6 = $[18];
187
+ t7 = $[19];
185
188
  }
186
189
  React.useEffect(t6, t7);
187
190
  return null;