camox 0.42.0 → 0.43.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/{GradientNode.js → HighlightNode.js} +34 -34
- package/dist/core/components/lexical/InlineLexicalEditor.js +14 -14
- package/dist/core/components/lexical/InlineStylesPlugin.js +6 -6
- package/dist/core/components/lexical/SelectionBroadcaster.js +5 -5
- package/dist/core/components/lexical/SidebarLexicalEditor.js +20 -20
- package/dist/core/components/lexical/TextLinkPopover.js +191 -208
- package/dist/core/components/lexical/editorConfig.js +2 -2
- package/dist/core/createApp.d.ts +3 -2
- package/dist/core/createApp.js +2 -1
- package/dist/core/createLayout.d.ts +16 -3
- package/dist/core/createLayout.js +15 -15
- package/dist/core/derivedRoutes.js +1 -1
- package/dist/core/dom.d.ts +17 -0
- package/dist/core/dom.js +22 -0
- package/dist/core/lib/lexicalReact.js +4 -4
- package/dist/core/lib/lexicalState.js +3 -3
- package/dist/core/lib/modifierFormats.js +1 -1
- package/dist/core/lib/textLinks.js +5 -2
- package/dist/core/lib/textStyles.d.ts +2 -2
- package/dist/core/lib/textStyles.js +6 -11
- package/dist/core/pageDestinations.js +37 -0
- package/dist/features/og/imageResponse.node.js +11 -9
- package/dist/features/preview/CamoxPreview.js +42 -65
- package/dist/features/preview/components/AddBlockSidebar.js +1 -1
- package/dist/features/preview/components/BlockActionsPopover.js +1 -1
- package/dist/features/preview/components/CreatePageModal.js +4 -4
- package/dist/features/preview/components/DerivedLayoutSidebar.js +45 -26
- package/dist/features/preview/components/DerivedPageInfoSidebar.js +38 -26
- package/dist/features/preview/components/FieldToolbar.js +7 -7
- package/dist/features/preview/components/LinkFieldEditor.js +212 -209
- package/dist/features/preview/components/PageEditorSidebar.js +1 -1
- package/dist/features/preview/components/PageInfoSidebar.js +28 -28
- package/dist/features/preview/components/PagePicker.js +16 -16
- package/dist/features/preview/components/PageTree.js +1 -1
- package/dist/features/preview/components/PublicationRow.js +8 -4
- package/dist/features/preview/components/useRepeatableItemActions.js +1 -1
- package/dist/features/preview/publication.js +10 -0
- package/dist/features/provider/CoreCamoxProvider.js +1 -1
- package/dist/features/runtime/runtime.js +20 -21
- package/dist/features/studio/components/EnvironmentMenu.js +3 -2
- package/dist/features/studio/components/Navbar.js +53 -80
- package/dist/features/vite/layoutGeneration.js +7 -3
- package/dist/features/vite/vite.js +5 -1
- package/dist/hooks/use-page-destinations.js +53 -0
- package/dist/lib/auth.js +11 -14
- package/dist/lib/server-auth-cookie.js +21 -0
- package/dist/studio.css +1 -1
- package/package.json +8 -4
- package/skills/camox/SKILL.md +32 -9
- package/skills/camox/references/block-definitions.md +84 -290
- package/skills/camox/references/cli-common.md +2 -4
- package/skills/camox/references/cli-content.md +147 -0
- package/skills/camox/references/cli-environments.md +1 -1
- package/skills/camox/references/dom-integrations.md +93 -0
- package/skills/camox/references/field-styling.md +50 -0
- package/skills/camox/references/layout-definitions.md +33 -147
- package/skills/camox/references/routed-layouts.md +71 -0
- package/skills/camoxify/SKILL.md +52 -0
- package/skills/camox/references/cli-blocks.md +0 -78
- package/skills/camox/references/cli-pages.md +0 -53
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { $applyNodeReplacement, $copyNode, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, ElementNode } from "lexical";
|
|
2
2
|
|
|
3
|
-
//#region src/core/components/lexical/
|
|
4
|
-
var
|
|
3
|
+
//#region src/core/components/lexical/HighlightNode.ts
|
|
4
|
+
var HighlightNode = class HighlightNode extends ElementNode {
|
|
5
5
|
static getType() {
|
|
6
|
-
return "
|
|
6
|
+
return "highlight";
|
|
7
7
|
}
|
|
8
8
|
static clone(node) {
|
|
9
|
-
return new
|
|
9
|
+
return new HighlightNode(node.__key);
|
|
10
10
|
}
|
|
11
11
|
static importJSON(value) {
|
|
12
|
-
return $
|
|
12
|
+
return $createHighlightNode().updateFromJSON(value);
|
|
13
13
|
}
|
|
14
14
|
static importDOM() {
|
|
15
|
-
return { span: (element) => element.hasAttribute("data-camox-
|
|
16
|
-
conversion: () => ({ node: $
|
|
15
|
+
return { span: (element) => element.hasAttribute("data-camox-highlight") ? {
|
|
16
|
+
conversion: () => ({ node: $createHighlightNode() }),
|
|
17
17
|
priority: 1
|
|
18
18
|
} : null };
|
|
19
19
|
}
|
|
20
20
|
createDOM() {
|
|
21
21
|
const span = document.createElement("span");
|
|
22
|
-
span.dataset.
|
|
22
|
+
span.dataset.camoxHighlight = "";
|
|
23
23
|
return span;
|
|
24
24
|
}
|
|
25
25
|
updateDOM() {
|
|
@@ -38,30 +38,30 @@ var GradientNode = class GradientNode extends ElementNode {
|
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
function $
|
|
42
|
-
return $applyNodeReplacement(new
|
|
41
|
+
function $createHighlightNode() {
|
|
42
|
+
return $applyNodeReplacement(new HighlightNode());
|
|
43
43
|
}
|
|
44
|
-
function $
|
|
44
|
+
function $getHighlight(node) {
|
|
45
45
|
let current = node;
|
|
46
46
|
while (current) {
|
|
47
|
-
if (current instanceof
|
|
47
|
+
if (current instanceof HighlightNode) return current;
|
|
48
48
|
current = current.getParent();
|
|
49
49
|
}
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
|
-
function $
|
|
52
|
+
function $selectionHasHighlight() {
|
|
53
53
|
const selection = $getSelection();
|
|
54
54
|
if (!$isRangeSelection(selection)) return false;
|
|
55
|
-
if (selection.isCollapsed()) return !!$
|
|
55
|
+
if (selection.isCollapsed()) return !!$getHighlight(selection.anchor.getNode());
|
|
56
56
|
const texts = selection.getNodes().filter($isTextNode);
|
|
57
|
-
return texts.length > 0 && texts.every((node) => !!$
|
|
57
|
+
return texts.length > 0 && texts.every((node) => !!$getHighlight(node));
|
|
58
58
|
}
|
|
59
|
-
/** Isolate a selected leaf without removing
|
|
60
|
-
function $
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
59
|
+
/** Isolate a selected leaf without removing highlight from its unselected siblings. */
|
|
60
|
+
function $removeHighlightFrom(node) {
|
|
61
|
+
const highlight = $getHighlight(node);
|
|
62
|
+
if (!highlight) return;
|
|
63
63
|
let branch = node;
|
|
64
|
-
while (branch.getKey() !==
|
|
64
|
+
while (branch.getKey() !== highlight.getKey()) {
|
|
65
65
|
const parent = branch.getParentOrThrow();
|
|
66
66
|
const before = branch.getPreviousSiblings();
|
|
67
67
|
const after = branch.getNextSiblings();
|
|
@@ -77,40 +77,40 @@ function $removeGradientFrom(node) {
|
|
|
77
77
|
}
|
|
78
78
|
branch = parent;
|
|
79
79
|
}
|
|
80
|
-
for (const child of
|
|
81
|
-
|
|
80
|
+
for (const child of highlight.getChildren()) highlight.insertBefore(child);
|
|
81
|
+
highlight.remove();
|
|
82
82
|
}
|
|
83
|
-
function $
|
|
83
|
+
function $toggleHighlight() {
|
|
84
84
|
const selection = $getSelection();
|
|
85
85
|
if (!$isRangeSelection(selection) || selection.isCollapsed()) return;
|
|
86
|
-
const remove = $
|
|
86
|
+
const remove = $selectionHasHighlight();
|
|
87
87
|
const nodes = selection.extract().filter((node) => $isTextNode(node) || node.getType() === "linebreak");
|
|
88
88
|
for (const node of nodes) {
|
|
89
89
|
if (remove) {
|
|
90
|
-
$
|
|
90
|
+
$removeHighlightFrom(node);
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
if ($
|
|
93
|
+
if ($getHighlight(node)) continue;
|
|
94
94
|
const previous = node.getPreviousSibling();
|
|
95
|
-
if (previous instanceof
|
|
95
|
+
if (previous instanceof HighlightNode) {
|
|
96
96
|
previous.append(node);
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
node.insertBefore(
|
|
101
|
-
|
|
99
|
+
const highlight = $createHighlightNode();
|
|
100
|
+
node.insertBefore(highlight);
|
|
101
|
+
highlight.append(node);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
/** Keep one background across adjacent runs, including after formatting changes. */
|
|
105
|
-
function $
|
|
105
|
+
function $normalizeHighlight(node) {
|
|
106
106
|
const parent = node.getParent();
|
|
107
|
-
if (parent instanceof
|
|
107
|
+
if (parent instanceof HighlightNode) {
|
|
108
108
|
for (const child of node.getChildren()) node.insertBefore(child);
|
|
109
109
|
node.remove();
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
const next = node.getNextSibling();
|
|
113
|
-
if (next instanceof
|
|
113
|
+
if (next instanceof HighlightNode) {
|
|
114
114
|
node.append(...next.getChildren());
|
|
115
115
|
next.remove();
|
|
116
116
|
}
|
|
@@ -123,4 +123,4 @@ function $normalizeGradient(node) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
//#endregion
|
|
126
|
-
export { $
|
|
126
|
+
export { $normalizeHighlight, $selectionHasHighlight, $toggleHighlight, HighlightNode };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isValidTextLinkTarget } from "../../lib/textLinks.js";
|
|
2
2
|
import { lexicalStateToMarkdown } from "../../lib/lexicalState.js";
|
|
3
3
|
import { useFrame } from "../../../features/preview/components/Frame.js";
|
|
4
4
|
import { createEditorConfig, normalizeLexicalState } from "./editorConfig.js";
|
|
@@ -20,9 +20,9 @@ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, INSERT_LINE_BRE
|
|
|
20
20
|
//#region src/core/components/lexical/InlineLexicalEditor.tsx
|
|
21
21
|
function ExternalStateSync(t0) {
|
|
22
22
|
const $ = c(8);
|
|
23
|
-
if ($[0] !== "
|
|
23
|
+
if ($[0] !== "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc") {
|
|
24
24
|
for (let $i = 0; $i < 8; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
25
|
-
$[0] = "
|
|
25
|
+
$[0] = "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc";
|
|
26
26
|
}
|
|
27
27
|
const { externalState } = t0;
|
|
28
28
|
const [editor] = useLexicalComposerContext();
|
|
@@ -79,9 +79,9 @@ function ExternalStateSync(t0) {
|
|
|
79
79
|
}
|
|
80
80
|
function EscapeHandler() {
|
|
81
81
|
const $ = c(4);
|
|
82
|
-
if ($[0] !== "
|
|
82
|
+
if ($[0] !== "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc") {
|
|
83
83
|
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
84
|
-
$[0] = "
|
|
84
|
+
$[0] = "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc";
|
|
85
85
|
}
|
|
86
86
|
const [editor] = useLexicalComposerContext();
|
|
87
87
|
let t0;
|
|
@@ -104,9 +104,9 @@ function EscapeHandler() {
|
|
|
104
104
|
}
|
|
105
105
|
function EnterAsLineBreakHandler() {
|
|
106
106
|
const $ = c(4);
|
|
107
|
-
if ($[0] !== "
|
|
107
|
+
if ($[0] !== "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc") {
|
|
108
108
|
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
109
|
-
$[0] = "
|
|
109
|
+
$[0] = "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc";
|
|
110
110
|
}
|
|
111
111
|
const [editor] = useLexicalComposerContext();
|
|
112
112
|
let t0;
|
|
@@ -130,9 +130,9 @@ function EnterAsLineBreakHandler() {
|
|
|
130
130
|
}
|
|
131
131
|
function PasteUrlAsLinkHandler() {
|
|
132
132
|
const $ = c(4);
|
|
133
|
-
if ($[0] !== "
|
|
133
|
+
if ($[0] !== "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc") {
|
|
134
134
|
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
135
|
-
$[0] = "
|
|
135
|
+
$[0] = "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc";
|
|
136
136
|
}
|
|
137
137
|
const [editor] = useLexicalComposerContext();
|
|
138
138
|
let t0;
|
|
@@ -143,7 +143,7 @@ function PasteUrlAsLinkHandler() {
|
|
|
143
143
|
if (!$isRangeSelection(selection) || selection.isCollapsed()) return false;
|
|
144
144
|
if (!("clipboardData" in event) || !event.clipboardData) return false;
|
|
145
145
|
const url = event.clipboardData.getData("text/plain").trim();
|
|
146
|
-
if (!url || !
|
|
146
|
+
if (!url || !isValidTextLinkTarget(url)) return false;
|
|
147
147
|
event.preventDefault();
|
|
148
148
|
editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
|
|
149
149
|
return true;
|
|
@@ -161,9 +161,9 @@ function PasteUrlAsLinkHandler() {
|
|
|
161
161
|
}
|
|
162
162
|
function FocusBlurHandler(t0) {
|
|
163
163
|
const $ = c(6);
|
|
164
|
-
if ($[0] !== "
|
|
164
|
+
if ($[0] !== "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc") {
|
|
165
165
|
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
166
|
-
$[0] = "
|
|
166
|
+
$[0] = "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc";
|
|
167
167
|
}
|
|
168
168
|
const { onFocus, onBlur } = t0;
|
|
169
169
|
const [editor] = useLexicalComposerContext();
|
|
@@ -265,9 +265,9 @@ function InlineLexicalEditor({ initialState, externalState, onChange, onFocus, o
|
|
|
265
265
|
}
|
|
266
266
|
function LexicalErrorBoundary(t0) {
|
|
267
267
|
const $ = c(3);
|
|
268
|
-
if ($[0] !== "
|
|
268
|
+
if ($[0] !== "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc") {
|
|
269
269
|
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
270
|
-
$[0] = "
|
|
270
|
+
$[0] = "ce0aab2d8f6174c436b3fa78439a44b23b8d509cc6b49c38f4129c459abdf4cc";
|
|
271
271
|
}
|
|
272
272
|
const { children } = t0;
|
|
273
273
|
let t1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getPageIdFromTextLinkTarget, isHttpTextLinkTarget, resolveTextLinkHref, shouldOpenTextLinkInNewTab } from "../../lib/textLinks.js";
|
|
2
|
-
import {
|
|
3
|
-
import { $
|
|
2
|
+
import { getHighlightStyle, getTextAppearance } from "../../lib/textStyles.js";
|
|
3
|
+
import { $normalizeHighlight, HighlightNode } from "./HighlightNode.js";
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { $isLinkNode } from "@lexical/link";
|
|
@@ -57,9 +57,9 @@ const unitless = new Set([
|
|
|
57
57
|
/** Only manages appearance attributes; Lexical retains ownership of the editable tree. */
|
|
58
58
|
function InlineStylesPlugin(options) {
|
|
59
59
|
const $ = c(13);
|
|
60
|
-
if ($[0] !== "
|
|
60
|
+
if ($[0] !== "2ac672d1b6a8ab06af1a7ad709040f99688a70d9b3bd2a117fe818c6dc8986e3") {
|
|
61
61
|
for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
62
|
-
$[0] = "
|
|
62
|
+
$[0] = "2ac672d1b6a8ab06af1a7ad709040f99688a70d9b3bd2a117fe818c6dc8986e3";
|
|
63
63
|
}
|
|
64
64
|
const [editor] = useLexicalComposerContext();
|
|
65
65
|
let t0;
|
|
@@ -91,7 +91,7 @@ function InlineStylesPlugin(options) {
|
|
|
91
91
|
function visit(node) {
|
|
92
92
|
const dom_0 = editor.getElementByKey(node.getKey());
|
|
93
93
|
if (dom_0 && $isTextNode(node)) apply(dom_0, getTextAppearance(node.getFormat(), options));
|
|
94
|
-
if (dom_0 && node instanceof
|
|
94
|
+
if (dom_0 && node instanceof HighlightNode) apply(dom_0, getHighlightStyle(options));
|
|
95
95
|
if (dom_0 && $isLinkNode(node)) {
|
|
96
96
|
const target = node.getURL();
|
|
97
97
|
const href = resolveTextLinkHref(target, options.pages, options.fallbackHref ?? "#") ?? "#";
|
|
@@ -160,7 +160,7 @@ function InlineStylesPlugin(options) {
|
|
|
160
160
|
let t2;
|
|
161
161
|
let t3;
|
|
162
162
|
if ($[10] !== editor) {
|
|
163
|
-
t2 = () => editor.registerNodeTransform(
|
|
163
|
+
t2 = () => editor.registerNodeTransform(HighlightNode, $normalizeHighlight);
|
|
164
164
|
t3 = [editor];
|
|
165
165
|
$[10] = editor;
|
|
166
166
|
$[11] = t2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FORMAT_FLAGS } from "../../lib/modifierFormats.js";
|
|
2
2
|
import { isOverlayMessage, postOverlayMessage } from "../../../features/preview/overlayMessages.js";
|
|
3
|
-
import { $
|
|
3
|
+
import { $selectionHasHighlight, $toggleHighlight } from "./HighlightNode.js";
|
|
4
4
|
import { selectTextLink } from "./selectTextLink.js";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import * as React from "react";
|
|
@@ -24,9 +24,9 @@ function getLinkTargetFromSelection() {
|
|
|
24
24
|
}
|
|
25
25
|
function SelectionBroadcaster(t0) {
|
|
26
26
|
const $ = c(20);
|
|
27
|
-
if ($[0] !== "
|
|
27
|
+
if ($[0] !== "b88c574c21c23f501029bacae0b122b78516d4a0df4269eae25d68662efb6a32") {
|
|
28
28
|
for (let $i = 0; $i < 20; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
29
|
-
$[0] = "
|
|
29
|
+
$[0] = "b88c574c21c23f501029bacae0b122b78516d4a0df4269eae25d68662efb6a32";
|
|
30
30
|
}
|
|
31
31
|
const { targetWindow } = t0;
|
|
32
32
|
const [editor] = useLexicalComposerContext();
|
|
@@ -56,7 +56,7 @@ function SelectionBroadcaster(t0) {
|
|
|
56
56
|
"italic",
|
|
57
57
|
"underline"
|
|
58
58
|
]) if (selection.hasFormat(key)) format = format | FORMAT_FLAGS[key];
|
|
59
|
-
if ($
|
|
59
|
+
if ($selectionHasHighlight()) format = format | FORMAT_FLAGS.highlight;
|
|
60
60
|
linkTarget = getLinkTargetFromSelection();
|
|
61
61
|
});
|
|
62
62
|
postOverlayMessage({
|
|
@@ -154,7 +154,7 @@ function SelectionBroadcaster(t0) {
|
|
|
154
154
|
if (lastTextSelectionRef.current) $setSelection(lastTextSelectionRef.current.clone());
|
|
155
155
|
});
|
|
156
156
|
if (data.type === "CAMOX_FORMAT_TEXT") {
|
|
157
|
-
if (data.formatKey === "
|
|
157
|
+
if (data.formatKey === "highlight") editor.update($toggleHighlight);
|
|
158
158
|
else if (data.formatKey === "bold" || data.formatKey === "italic" || data.formatKey === "underline") editor.dispatchCommand(FORMAT_TEXT_COMMAND, data.formatKey);
|
|
159
159
|
} else if (data.target === null) editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
160
160
|
else if (typeof data.text === "string") {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FORMAT_FLAGS } from "../../lib/modifierFormats.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isValidTextLinkTarget } from "../../lib/textLinks.js";
|
|
3
3
|
import { lexicalStateToMarkdown } from "../../lib/lexicalState.js";
|
|
4
4
|
import { INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, cn } from "../../../lib/utils.js";
|
|
5
5
|
import { TextLinkPopover } from "./TextLinkPopover.js";
|
|
6
|
-
import { $
|
|
6
|
+
import { $selectionHasHighlight, $toggleHighlight } from "./HighlightNode.js";
|
|
7
7
|
import { createEditorConfig, normalizeLexicalState } from "./editorConfig.js";
|
|
8
8
|
import { InlineStylesPlugin } from "./InlineStylesPlugin.js";
|
|
9
9
|
import { selectTextLink } from "./selectTextLink.js";
|
|
@@ -11,7 +11,7 @@ import { c } from "react/compiler-runtime";
|
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Button } from "@camox/ui/button";
|
|
14
|
-
import {
|
|
14
|
+
import { Bold, Highlighter, Italic, Underline } from "lucide-react";
|
|
15
15
|
import { FloatingToolbar } from "@camox/ui/floating-toolbar";
|
|
16
16
|
import { Toggle } from "@camox/ui/toggle";
|
|
17
17
|
import { $createLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
|
|
@@ -27,9 +27,9 @@ import { $createTextNode, $getSelection, $isRangeSelection, $setSelection, COMMA
|
|
|
27
27
|
//#region src/core/components/lexical/SidebarLexicalEditor.tsx
|
|
28
28
|
function EnterAsLineBreakHandler() {
|
|
29
29
|
const $ = c(4);
|
|
30
|
-
if ($[0] !== "
|
|
30
|
+
if ($[0] !== "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372") {
|
|
31
31
|
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
32
|
-
$[0] = "
|
|
32
|
+
$[0] = "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372";
|
|
33
33
|
}
|
|
34
34
|
const [editor] = useLexicalComposerContext();
|
|
35
35
|
let t0;
|
|
@@ -53,9 +53,9 @@ function EnterAsLineBreakHandler() {
|
|
|
53
53
|
}
|
|
54
54
|
function ExternalStateSync(t0) {
|
|
55
55
|
const $ = c(6);
|
|
56
|
-
if ($[0] !== "
|
|
56
|
+
if ($[0] !== "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372") {
|
|
57
57
|
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
58
|
-
$[0] = "
|
|
58
|
+
$[0] = "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372";
|
|
59
59
|
}
|
|
60
60
|
const { value, isSyncingRef } = t0;
|
|
61
61
|
const [editor] = useLexicalComposerContext();
|
|
@@ -91,9 +91,9 @@ function ExternalStateSync(t0) {
|
|
|
91
91
|
}
|
|
92
92
|
function SidebarFloatingTextToolbar() {
|
|
93
93
|
const $ = c(72);
|
|
94
|
-
if ($[0] !== "
|
|
94
|
+
if ($[0] !== "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372") {
|
|
95
95
|
for (let $i = 0; $i < 72; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
96
|
-
$[0] = "
|
|
96
|
+
$[0] = "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372";
|
|
97
97
|
}
|
|
98
98
|
const [editor] = useLexicalComposerContext();
|
|
99
99
|
const [open, setOpen] = React.useState(false);
|
|
@@ -144,7 +144,7 @@ function SidebarFloatingTextToolbar() {
|
|
|
144
144
|
if (selection.hasFormat("bold")) activeFormats = activeFormats | FORMAT_FLAGS.bold;
|
|
145
145
|
if (selection.hasFormat("italic")) activeFormats = activeFormats | FORMAT_FLAGS.italic;
|
|
146
146
|
if (selection.hasFormat("underline")) activeFormats = activeFormats | FORMAT_FLAGS.underline;
|
|
147
|
-
if ($
|
|
147
|
+
if ($selectionHasHighlight()) activeFormats = activeFormats | FORMAT_FLAGS.highlight;
|
|
148
148
|
let node = selection.anchor.getNode();
|
|
149
149
|
while (node) {
|
|
150
150
|
if (node.getType?.() === "link") {
|
|
@@ -260,8 +260,8 @@ function SidebarFloatingTextToolbar() {
|
|
|
260
260
|
t9 = (formatKey) => {
|
|
261
261
|
editor.update(() => {
|
|
262
262
|
restoreSelection();
|
|
263
|
-
if (formatKey === "
|
|
264
|
-
$
|
|
263
|
+
if (formatKey === "highlight") {
|
|
264
|
+
$toggleHighlight();
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
editor.dispatchCommand(FORMAT_TEXT_COMMAND, formatKey);
|
|
@@ -431,9 +431,9 @@ function SidebarFloatingTextToolbar() {
|
|
|
431
431
|
label: "Underline",
|
|
432
432
|
icon: Underline
|
|
433
433
|
}, {
|
|
434
|
-
key: "
|
|
435
|
-
label: "
|
|
436
|
-
icon:
|
|
434
|
+
key: "highlight",
|
|
435
|
+
label: "Highlight",
|
|
436
|
+
icon: Highlighter
|
|
437
437
|
}];
|
|
438
438
|
$[53] = t23;
|
|
439
439
|
} else t23 = $[53];
|
|
@@ -518,9 +518,9 @@ function _temp(event_0) {
|
|
|
518
518
|
}
|
|
519
519
|
function PasteUrlAsLinkHandler() {
|
|
520
520
|
const $ = c(4);
|
|
521
|
-
if ($[0] !== "
|
|
521
|
+
if ($[0] !== "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372") {
|
|
522
522
|
for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
523
|
-
$[0] = "
|
|
523
|
+
$[0] = "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372";
|
|
524
524
|
}
|
|
525
525
|
const [editor] = useLexicalComposerContext();
|
|
526
526
|
let t0;
|
|
@@ -531,7 +531,7 @@ function PasteUrlAsLinkHandler() {
|
|
|
531
531
|
if (!$isRangeSelection(selection) || selection.isCollapsed()) return false;
|
|
532
532
|
if (!("clipboardData" in event) || !event.clipboardData) return false;
|
|
533
533
|
const url = event.clipboardData.getData("text/plain").trim();
|
|
534
|
-
if (!
|
|
534
|
+
if (!isValidTextLinkTarget(url)) return false;
|
|
535
535
|
event.preventDefault();
|
|
536
536
|
editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
|
|
537
537
|
return true;
|
|
@@ -608,9 +608,9 @@ function SidebarLexicalEditor({ id, value, onChange, onFocus, onBlur }) {
|
|
|
608
608
|
}
|
|
609
609
|
function LexicalErrorBoundary(t0) {
|
|
610
610
|
const $ = c(3);
|
|
611
|
-
if ($[0] !== "
|
|
611
|
+
if ($[0] !== "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372") {
|
|
612
612
|
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
613
|
-
$[0] = "
|
|
613
|
+
$[0] = "b2abd53d41bcf7845fda084f34768059ff9a381fdb75359c9fd3fc0de4052372";
|
|
614
614
|
}
|
|
615
615
|
const { children } = t0;
|
|
616
616
|
let t1;
|