@almadar/ui 2.52.0 → 2.54.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/avl/index.cjs +869 -611
- package/dist/avl/index.js +869 -611
- package/dist/components/index.cjs +114 -21
- package/dist/components/index.js +114 -21
- package/dist/components/molecules/markdown/CodeBlock.d.ts +9 -4
- package/dist/providers/index.cjs +114 -21
- package/dist/providers/index.js +114 -21
- package/dist/runtime/index.cjs +114 -21
- package/dist/runtime/index.js +114 -21
- package/package.json +1 -1
|
@@ -9223,6 +9223,26 @@ var CodeBlock = React90__namespace.default.memo(
|
|
|
9223
9223
|
const codeRef = React90.useRef(null);
|
|
9224
9224
|
const savedScrollLeftRef = React90.useRef(0);
|
|
9225
9225
|
const [copied, setCopied] = React90.useState(false);
|
|
9226
|
+
const [editableValue, setEditableValue] = React90.useState(code);
|
|
9227
|
+
const [editableTextareaKey, setEditableTextareaKey] = React90.useState(0);
|
|
9228
|
+
const lastPropCodeRef = React90.useRef(code);
|
|
9229
|
+
const editableTextareaRef = React90.useRef(null);
|
|
9230
|
+
const editableOverlayRef = React90.useRef(null);
|
|
9231
|
+
React90.useEffect(() => {
|
|
9232
|
+
if (code !== lastPropCodeRef.current) {
|
|
9233
|
+
lastPropCodeRef.current = code;
|
|
9234
|
+
setEditableValue(code);
|
|
9235
|
+
setEditableTextareaKey((k) => k + 1);
|
|
9236
|
+
}
|
|
9237
|
+
}, [code]);
|
|
9238
|
+
const handleEditableScroll = React90.useCallback(() => {
|
|
9239
|
+
const ta = editableTextareaRef.current;
|
|
9240
|
+
const ov = editableOverlayRef.current;
|
|
9241
|
+
if (ta && ov) {
|
|
9242
|
+
ov.scrollTop = ta.scrollTop;
|
|
9243
|
+
ov.scrollLeft = ta.scrollLeft;
|
|
9244
|
+
}
|
|
9245
|
+
}, []);
|
|
9226
9246
|
const isFoldable = foldableProp ?? (language === "orb" || language === "json");
|
|
9227
9247
|
const [collapsed, setCollapsed] = React90.useState(() => /* @__PURE__ */ new Set());
|
|
9228
9248
|
const foldRegions = React90.useMemo(
|
|
@@ -9383,33 +9403,106 @@ var CodeBlock = React90__namespace.default.memo(
|
|
|
9383
9403
|
}
|
|
9384
9404
|
),
|
|
9385
9405
|
editable ? (
|
|
9386
|
-
/* GAP-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9406
|
+
/* GAP-77: editable mode = transparent Textarea on top + Prism-highlighted
|
|
9407
|
+
overlay underneath. The textarea is uncontrolled (defaultValue + key)
|
|
9408
|
+
to avoid cursor jumps; the overlay reads `editableValue` which is
|
|
9409
|
+
mirrored from the textarea via onChange. Both elements share IDENTICAL
|
|
9410
|
+
font / line-height / padding so the highlighted text aligns with the
|
|
9411
|
+
textarea's invisible glyphs.
|
|
9412
|
+
|
|
9413
|
+
Scroll sync: the overlay has `pointer-events: none` and the textarea
|
|
9414
|
+
scrolls; `handleEditableScroll` keeps the overlay's scroll matched. */
|
|
9415
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9416
|
+
Box,
|
|
9394
9417
|
{
|
|
9395
|
-
defaultValue: code,
|
|
9396
|
-
onChange: (e) => onChange?.(e.target.value),
|
|
9397
|
-
spellCheck: false,
|
|
9398
9418
|
style: {
|
|
9399
|
-
|
|
9400
|
-
fontSize: "13px",
|
|
9401
|
-
lineHeight: "1.5",
|
|
9419
|
+
position: "relative",
|
|
9402
9420
|
backgroundColor: "#1e1e1e",
|
|
9403
|
-
color: "#e6e6e6",
|
|
9404
9421
|
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
9405
|
-
border: "none",
|
|
9406
|
-
padding: "1rem",
|
|
9407
|
-
resize: "none",
|
|
9408
9422
|
minHeight: "160px",
|
|
9409
9423
|
maxHeight,
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9424
|
+
overflow: "hidden"
|
|
9425
|
+
},
|
|
9426
|
+
children: [
|
|
9427
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9428
|
+
"div",
|
|
9429
|
+
{
|
|
9430
|
+
ref: editableOverlayRef,
|
|
9431
|
+
"aria-hidden": true,
|
|
9432
|
+
style: {
|
|
9433
|
+
position: "absolute",
|
|
9434
|
+
inset: 0,
|
|
9435
|
+
overflow: "hidden",
|
|
9436
|
+
pointerEvents: "none",
|
|
9437
|
+
maxHeight
|
|
9438
|
+
},
|
|
9439
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9440
|
+
SyntaxHighlighter__default.default,
|
|
9441
|
+
{
|
|
9442
|
+
PreTag: "div",
|
|
9443
|
+
language,
|
|
9444
|
+
style: activeStyle,
|
|
9445
|
+
customStyle: {
|
|
9446
|
+
backgroundColor: "transparent",
|
|
9447
|
+
borderRadius: 0,
|
|
9448
|
+
padding: "1rem",
|
|
9449
|
+
margin: 0,
|
|
9450
|
+
whiteSpace: "pre",
|
|
9451
|
+
minWidth: "100%",
|
|
9452
|
+
minHeight: "160px",
|
|
9453
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
9454
|
+
fontSize: "13px",
|
|
9455
|
+
lineHeight: "1.5"
|
|
9456
|
+
},
|
|
9457
|
+
codeTagProps: {
|
|
9458
|
+
style: {
|
|
9459
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
9460
|
+
fontSize: "13px",
|
|
9461
|
+
lineHeight: "1.5"
|
|
9462
|
+
}
|
|
9463
|
+
},
|
|
9464
|
+
children: editableValue || " "
|
|
9465
|
+
}
|
|
9466
|
+
)
|
|
9467
|
+
}
|
|
9468
|
+
),
|
|
9469
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9470
|
+
Textarea,
|
|
9471
|
+
{
|
|
9472
|
+
ref: editableTextareaRef,
|
|
9473
|
+
defaultValue: code,
|
|
9474
|
+
onChange: (e) => {
|
|
9475
|
+
setEditableValue(e.target.value);
|
|
9476
|
+
onChange?.(e.target.value);
|
|
9477
|
+
},
|
|
9478
|
+
onScroll: handleEditableScroll,
|
|
9479
|
+
spellCheck: false,
|
|
9480
|
+
style: {
|
|
9481
|
+
position: "relative",
|
|
9482
|
+
zIndex: 1,
|
|
9483
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
9484
|
+
fontSize: "13px",
|
|
9485
|
+
lineHeight: "1.5",
|
|
9486
|
+
backgroundColor: "transparent",
|
|
9487
|
+
color: "transparent",
|
|
9488
|
+
caretColor: "#e6e6e6",
|
|
9489
|
+
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
9490
|
+
border: "none",
|
|
9491
|
+
padding: "1rem",
|
|
9492
|
+
resize: "none",
|
|
9493
|
+
minHeight: "160px",
|
|
9494
|
+
maxHeight,
|
|
9495
|
+
width: "100%",
|
|
9496
|
+
height: "100%",
|
|
9497
|
+
outline: "none",
|
|
9498
|
+
whiteSpace: "pre",
|
|
9499
|
+
overflowWrap: "normal",
|
|
9500
|
+
overflow: "auto"
|
|
9501
|
+
}
|
|
9502
|
+
},
|
|
9503
|
+
editableTextareaKey
|
|
9504
|
+
)
|
|
9505
|
+
]
|
|
9413
9506
|
}
|
|
9414
9507
|
)
|
|
9415
9508
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
package/dist/components/index.js
CHANGED
|
@@ -9178,6 +9178,26 @@ var CodeBlock = React90__default.memo(
|
|
|
9178
9178
|
const codeRef = useRef(null);
|
|
9179
9179
|
const savedScrollLeftRef = useRef(0);
|
|
9180
9180
|
const [copied, setCopied] = useState(false);
|
|
9181
|
+
const [editableValue, setEditableValue] = useState(code);
|
|
9182
|
+
const [editableTextareaKey, setEditableTextareaKey] = useState(0);
|
|
9183
|
+
const lastPropCodeRef = useRef(code);
|
|
9184
|
+
const editableTextareaRef = useRef(null);
|
|
9185
|
+
const editableOverlayRef = useRef(null);
|
|
9186
|
+
useEffect(() => {
|
|
9187
|
+
if (code !== lastPropCodeRef.current) {
|
|
9188
|
+
lastPropCodeRef.current = code;
|
|
9189
|
+
setEditableValue(code);
|
|
9190
|
+
setEditableTextareaKey((k) => k + 1);
|
|
9191
|
+
}
|
|
9192
|
+
}, [code]);
|
|
9193
|
+
const handleEditableScroll = useCallback(() => {
|
|
9194
|
+
const ta = editableTextareaRef.current;
|
|
9195
|
+
const ov = editableOverlayRef.current;
|
|
9196
|
+
if (ta && ov) {
|
|
9197
|
+
ov.scrollTop = ta.scrollTop;
|
|
9198
|
+
ov.scrollLeft = ta.scrollLeft;
|
|
9199
|
+
}
|
|
9200
|
+
}, []);
|
|
9181
9201
|
const isFoldable = foldableProp ?? (language === "orb" || language === "json");
|
|
9182
9202
|
const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
|
|
9183
9203
|
const foldRegions = useMemo(
|
|
@@ -9338,33 +9358,106 @@ var CodeBlock = React90__default.memo(
|
|
|
9338
9358
|
}
|
|
9339
9359
|
),
|
|
9340
9360
|
editable ? (
|
|
9341
|
-
/* GAP-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9361
|
+
/* GAP-77: editable mode = transparent Textarea on top + Prism-highlighted
|
|
9362
|
+
overlay underneath. The textarea is uncontrolled (defaultValue + key)
|
|
9363
|
+
to avoid cursor jumps; the overlay reads `editableValue` which is
|
|
9364
|
+
mirrored from the textarea via onChange. Both elements share IDENTICAL
|
|
9365
|
+
font / line-height / padding so the highlighted text aligns with the
|
|
9366
|
+
textarea's invisible glyphs.
|
|
9367
|
+
|
|
9368
|
+
Scroll sync: the overlay has `pointer-events: none` and the textarea
|
|
9369
|
+
scrolls; `handleEditableScroll` keeps the overlay's scroll matched. */
|
|
9370
|
+
/* @__PURE__ */ jsxs(
|
|
9371
|
+
Box,
|
|
9349
9372
|
{
|
|
9350
|
-
defaultValue: code,
|
|
9351
|
-
onChange: (e) => onChange?.(e.target.value),
|
|
9352
|
-
spellCheck: false,
|
|
9353
9373
|
style: {
|
|
9354
|
-
|
|
9355
|
-
fontSize: "13px",
|
|
9356
|
-
lineHeight: "1.5",
|
|
9374
|
+
position: "relative",
|
|
9357
9375
|
backgroundColor: "#1e1e1e",
|
|
9358
|
-
color: "#e6e6e6",
|
|
9359
9376
|
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
9360
|
-
border: "none",
|
|
9361
|
-
padding: "1rem",
|
|
9362
|
-
resize: "none",
|
|
9363
9377
|
minHeight: "160px",
|
|
9364
9378
|
maxHeight,
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9379
|
+
overflow: "hidden"
|
|
9380
|
+
},
|
|
9381
|
+
children: [
|
|
9382
|
+
/* @__PURE__ */ jsx(
|
|
9383
|
+
"div",
|
|
9384
|
+
{
|
|
9385
|
+
ref: editableOverlayRef,
|
|
9386
|
+
"aria-hidden": true,
|
|
9387
|
+
style: {
|
|
9388
|
+
position: "absolute",
|
|
9389
|
+
inset: 0,
|
|
9390
|
+
overflow: "hidden",
|
|
9391
|
+
pointerEvents: "none",
|
|
9392
|
+
maxHeight
|
|
9393
|
+
},
|
|
9394
|
+
children: /* @__PURE__ */ jsx(
|
|
9395
|
+
SyntaxHighlighter,
|
|
9396
|
+
{
|
|
9397
|
+
PreTag: "div",
|
|
9398
|
+
language,
|
|
9399
|
+
style: activeStyle,
|
|
9400
|
+
customStyle: {
|
|
9401
|
+
backgroundColor: "transparent",
|
|
9402
|
+
borderRadius: 0,
|
|
9403
|
+
padding: "1rem",
|
|
9404
|
+
margin: 0,
|
|
9405
|
+
whiteSpace: "pre",
|
|
9406
|
+
minWidth: "100%",
|
|
9407
|
+
minHeight: "160px",
|
|
9408
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
9409
|
+
fontSize: "13px",
|
|
9410
|
+
lineHeight: "1.5"
|
|
9411
|
+
},
|
|
9412
|
+
codeTagProps: {
|
|
9413
|
+
style: {
|
|
9414
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
9415
|
+
fontSize: "13px",
|
|
9416
|
+
lineHeight: "1.5"
|
|
9417
|
+
}
|
|
9418
|
+
},
|
|
9419
|
+
children: editableValue || " "
|
|
9420
|
+
}
|
|
9421
|
+
)
|
|
9422
|
+
}
|
|
9423
|
+
),
|
|
9424
|
+
/* @__PURE__ */ jsx(
|
|
9425
|
+
Textarea,
|
|
9426
|
+
{
|
|
9427
|
+
ref: editableTextareaRef,
|
|
9428
|
+
defaultValue: code,
|
|
9429
|
+
onChange: (e) => {
|
|
9430
|
+
setEditableValue(e.target.value);
|
|
9431
|
+
onChange?.(e.target.value);
|
|
9432
|
+
},
|
|
9433
|
+
onScroll: handleEditableScroll,
|
|
9434
|
+
spellCheck: false,
|
|
9435
|
+
style: {
|
|
9436
|
+
position: "relative",
|
|
9437
|
+
zIndex: 1,
|
|
9438
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
9439
|
+
fontSize: "13px",
|
|
9440
|
+
lineHeight: "1.5",
|
|
9441
|
+
backgroundColor: "transparent",
|
|
9442
|
+
color: "transparent",
|
|
9443
|
+
caretColor: "#e6e6e6",
|
|
9444
|
+
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
9445
|
+
border: "none",
|
|
9446
|
+
padding: "1rem",
|
|
9447
|
+
resize: "none",
|
|
9448
|
+
minHeight: "160px",
|
|
9449
|
+
maxHeight,
|
|
9450
|
+
width: "100%",
|
|
9451
|
+
height: "100%",
|
|
9452
|
+
outline: "none",
|
|
9453
|
+
whiteSpace: "pre",
|
|
9454
|
+
overflowWrap: "normal",
|
|
9455
|
+
overflow: "auto"
|
|
9456
|
+
}
|
|
9457
|
+
},
|
|
9458
|
+
editableTextareaKey
|
|
9459
|
+
)
|
|
9460
|
+
]
|
|
9368
9461
|
}
|
|
9369
9462
|
)
|
|
9370
9463
|
) : /* @__PURE__ */ jsx(
|
|
@@ -24,10 +24,15 @@ export interface CodeBlockProps {
|
|
|
24
24
|
/** Additional CSS classes */
|
|
25
25
|
className?: string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* When true, render an editable surface that composes a transparent `Textarea`
|
|
28
|
+
* over a Prism-highlighted overlay. The overlay re-tokenizes on each keystroke
|
|
29
|
+
* (driven from a local mirror of the textarea value), so users see syntax-highlighted
|
|
30
|
+
* code while still being able to type. Folding is skipped in editable mode.
|
|
31
|
+
*
|
|
32
|
+
* History: GAP-51 first-cut shipped plain (no-highlighting) editable text;
|
|
33
|
+
* GAP-77 (2026-04-12) added the Prism overlay layer.
|
|
34
|
+
*
|
|
35
|
+
* Default: false (existing read-only behavior unchanged).
|
|
31
36
|
*/
|
|
32
37
|
editable?: boolean;
|
|
33
38
|
/**
|
package/dist/providers/index.cjs
CHANGED
|
@@ -4108,6 +4108,26 @@ var CodeBlock = React114__namespace.default.memo(
|
|
|
4108
4108
|
const codeRef = React114.useRef(null);
|
|
4109
4109
|
const savedScrollLeftRef = React114.useRef(0);
|
|
4110
4110
|
const [copied, setCopied] = React114.useState(false);
|
|
4111
|
+
const [editableValue, setEditableValue] = React114.useState(code);
|
|
4112
|
+
const [editableTextareaKey, setEditableTextareaKey] = React114.useState(0);
|
|
4113
|
+
const lastPropCodeRef = React114.useRef(code);
|
|
4114
|
+
const editableTextareaRef = React114.useRef(null);
|
|
4115
|
+
const editableOverlayRef = React114.useRef(null);
|
|
4116
|
+
React114.useEffect(() => {
|
|
4117
|
+
if (code !== lastPropCodeRef.current) {
|
|
4118
|
+
lastPropCodeRef.current = code;
|
|
4119
|
+
setEditableValue(code);
|
|
4120
|
+
setEditableTextareaKey((k) => k + 1);
|
|
4121
|
+
}
|
|
4122
|
+
}, [code]);
|
|
4123
|
+
const handleEditableScroll = React114.useCallback(() => {
|
|
4124
|
+
const ta = editableTextareaRef.current;
|
|
4125
|
+
const ov = editableOverlayRef.current;
|
|
4126
|
+
if (ta && ov) {
|
|
4127
|
+
ov.scrollTop = ta.scrollTop;
|
|
4128
|
+
ov.scrollLeft = ta.scrollLeft;
|
|
4129
|
+
}
|
|
4130
|
+
}, []);
|
|
4111
4131
|
const isFoldable = foldableProp ?? (language === "orb" || language === "json");
|
|
4112
4132
|
const [collapsed, setCollapsed] = React114.useState(() => /* @__PURE__ */ new Set());
|
|
4113
4133
|
const foldRegions = React114.useMemo(
|
|
@@ -4268,33 +4288,106 @@ var CodeBlock = React114__namespace.default.memo(
|
|
|
4268
4288
|
}
|
|
4269
4289
|
),
|
|
4270
4290
|
editable ? (
|
|
4271
|
-
/* GAP-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4291
|
+
/* GAP-77: editable mode = transparent Textarea on top + Prism-highlighted
|
|
4292
|
+
overlay underneath. The textarea is uncontrolled (defaultValue + key)
|
|
4293
|
+
to avoid cursor jumps; the overlay reads `editableValue` which is
|
|
4294
|
+
mirrored from the textarea via onChange. Both elements share IDENTICAL
|
|
4295
|
+
font / line-height / padding so the highlighted text aligns with the
|
|
4296
|
+
textarea's invisible glyphs.
|
|
4297
|
+
|
|
4298
|
+
Scroll sync: the overlay has `pointer-events: none` and the textarea
|
|
4299
|
+
scrolls; `handleEditableScroll` keeps the overlay's scroll matched. */
|
|
4300
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4301
|
+
Box,
|
|
4279
4302
|
{
|
|
4280
|
-
defaultValue: code,
|
|
4281
|
-
onChange: (e) => onChange?.(e.target.value),
|
|
4282
|
-
spellCheck: false,
|
|
4283
4303
|
style: {
|
|
4284
|
-
|
|
4285
|
-
fontSize: "13px",
|
|
4286
|
-
lineHeight: "1.5",
|
|
4304
|
+
position: "relative",
|
|
4287
4305
|
backgroundColor: "#1e1e1e",
|
|
4288
|
-
color: "#e6e6e6",
|
|
4289
4306
|
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
4290
|
-
border: "none",
|
|
4291
|
-
padding: "1rem",
|
|
4292
|
-
resize: "none",
|
|
4293
4307
|
minHeight: "160px",
|
|
4294
4308
|
maxHeight,
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4309
|
+
overflow: "hidden"
|
|
4310
|
+
},
|
|
4311
|
+
children: [
|
|
4312
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4313
|
+
"div",
|
|
4314
|
+
{
|
|
4315
|
+
ref: editableOverlayRef,
|
|
4316
|
+
"aria-hidden": true,
|
|
4317
|
+
style: {
|
|
4318
|
+
position: "absolute",
|
|
4319
|
+
inset: 0,
|
|
4320
|
+
overflow: "hidden",
|
|
4321
|
+
pointerEvents: "none",
|
|
4322
|
+
maxHeight
|
|
4323
|
+
},
|
|
4324
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4325
|
+
SyntaxHighlighter__default.default,
|
|
4326
|
+
{
|
|
4327
|
+
PreTag: "div",
|
|
4328
|
+
language,
|
|
4329
|
+
style: activeStyle,
|
|
4330
|
+
customStyle: {
|
|
4331
|
+
backgroundColor: "transparent",
|
|
4332
|
+
borderRadius: 0,
|
|
4333
|
+
padding: "1rem",
|
|
4334
|
+
margin: 0,
|
|
4335
|
+
whiteSpace: "pre",
|
|
4336
|
+
minWidth: "100%",
|
|
4337
|
+
minHeight: "160px",
|
|
4338
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
4339
|
+
fontSize: "13px",
|
|
4340
|
+
lineHeight: "1.5"
|
|
4341
|
+
},
|
|
4342
|
+
codeTagProps: {
|
|
4343
|
+
style: {
|
|
4344
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
4345
|
+
fontSize: "13px",
|
|
4346
|
+
lineHeight: "1.5"
|
|
4347
|
+
}
|
|
4348
|
+
},
|
|
4349
|
+
children: editableValue || " "
|
|
4350
|
+
}
|
|
4351
|
+
)
|
|
4352
|
+
}
|
|
4353
|
+
),
|
|
4354
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4355
|
+
Textarea,
|
|
4356
|
+
{
|
|
4357
|
+
ref: editableTextareaRef,
|
|
4358
|
+
defaultValue: code,
|
|
4359
|
+
onChange: (e) => {
|
|
4360
|
+
setEditableValue(e.target.value);
|
|
4361
|
+
onChange?.(e.target.value);
|
|
4362
|
+
},
|
|
4363
|
+
onScroll: handleEditableScroll,
|
|
4364
|
+
spellCheck: false,
|
|
4365
|
+
style: {
|
|
4366
|
+
position: "relative",
|
|
4367
|
+
zIndex: 1,
|
|
4368
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
4369
|
+
fontSize: "13px",
|
|
4370
|
+
lineHeight: "1.5",
|
|
4371
|
+
backgroundColor: "transparent",
|
|
4372
|
+
color: "transparent",
|
|
4373
|
+
caretColor: "#e6e6e6",
|
|
4374
|
+
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
4375
|
+
border: "none",
|
|
4376
|
+
padding: "1rem",
|
|
4377
|
+
resize: "none",
|
|
4378
|
+
minHeight: "160px",
|
|
4379
|
+
maxHeight,
|
|
4380
|
+
width: "100%",
|
|
4381
|
+
height: "100%",
|
|
4382
|
+
outline: "none",
|
|
4383
|
+
whiteSpace: "pre",
|
|
4384
|
+
overflowWrap: "normal",
|
|
4385
|
+
overflow: "auto"
|
|
4386
|
+
}
|
|
4387
|
+
},
|
|
4388
|
+
editableTextareaKey
|
|
4389
|
+
)
|
|
4390
|
+
]
|
|
4298
4391
|
}
|
|
4299
4392
|
)
|
|
4300
4393
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
package/dist/providers/index.js
CHANGED
|
@@ -4063,6 +4063,26 @@ var CodeBlock = React114__default.memo(
|
|
|
4063
4063
|
const codeRef = useRef(null);
|
|
4064
4064
|
const savedScrollLeftRef = useRef(0);
|
|
4065
4065
|
const [copied, setCopied] = useState(false);
|
|
4066
|
+
const [editableValue, setEditableValue] = useState(code);
|
|
4067
|
+
const [editableTextareaKey, setEditableTextareaKey] = useState(0);
|
|
4068
|
+
const lastPropCodeRef = useRef(code);
|
|
4069
|
+
const editableTextareaRef = useRef(null);
|
|
4070
|
+
const editableOverlayRef = useRef(null);
|
|
4071
|
+
useEffect(() => {
|
|
4072
|
+
if (code !== lastPropCodeRef.current) {
|
|
4073
|
+
lastPropCodeRef.current = code;
|
|
4074
|
+
setEditableValue(code);
|
|
4075
|
+
setEditableTextareaKey((k) => k + 1);
|
|
4076
|
+
}
|
|
4077
|
+
}, [code]);
|
|
4078
|
+
const handleEditableScroll = useCallback(() => {
|
|
4079
|
+
const ta = editableTextareaRef.current;
|
|
4080
|
+
const ov = editableOverlayRef.current;
|
|
4081
|
+
if (ta && ov) {
|
|
4082
|
+
ov.scrollTop = ta.scrollTop;
|
|
4083
|
+
ov.scrollLeft = ta.scrollLeft;
|
|
4084
|
+
}
|
|
4085
|
+
}, []);
|
|
4066
4086
|
const isFoldable = foldableProp ?? (language === "orb" || language === "json");
|
|
4067
4087
|
const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
|
|
4068
4088
|
const foldRegions = useMemo(
|
|
@@ -4223,33 +4243,106 @@ var CodeBlock = React114__default.memo(
|
|
|
4223
4243
|
}
|
|
4224
4244
|
),
|
|
4225
4245
|
editable ? (
|
|
4226
|
-
/* GAP-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4246
|
+
/* GAP-77: editable mode = transparent Textarea on top + Prism-highlighted
|
|
4247
|
+
overlay underneath. The textarea is uncontrolled (defaultValue + key)
|
|
4248
|
+
to avoid cursor jumps; the overlay reads `editableValue` which is
|
|
4249
|
+
mirrored from the textarea via onChange. Both elements share IDENTICAL
|
|
4250
|
+
font / line-height / padding so the highlighted text aligns with the
|
|
4251
|
+
textarea's invisible glyphs.
|
|
4252
|
+
|
|
4253
|
+
Scroll sync: the overlay has `pointer-events: none` and the textarea
|
|
4254
|
+
scrolls; `handleEditableScroll` keeps the overlay's scroll matched. */
|
|
4255
|
+
/* @__PURE__ */ jsxs(
|
|
4256
|
+
Box,
|
|
4234
4257
|
{
|
|
4235
|
-
defaultValue: code,
|
|
4236
|
-
onChange: (e) => onChange?.(e.target.value),
|
|
4237
|
-
spellCheck: false,
|
|
4238
4258
|
style: {
|
|
4239
|
-
|
|
4240
|
-
fontSize: "13px",
|
|
4241
|
-
lineHeight: "1.5",
|
|
4259
|
+
position: "relative",
|
|
4242
4260
|
backgroundColor: "#1e1e1e",
|
|
4243
|
-
color: "#e6e6e6",
|
|
4244
4261
|
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
4245
|
-
border: "none",
|
|
4246
|
-
padding: "1rem",
|
|
4247
|
-
resize: "none",
|
|
4248
4262
|
minHeight: "160px",
|
|
4249
4263
|
maxHeight,
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4264
|
+
overflow: "hidden"
|
|
4265
|
+
},
|
|
4266
|
+
children: [
|
|
4267
|
+
/* @__PURE__ */ jsx(
|
|
4268
|
+
"div",
|
|
4269
|
+
{
|
|
4270
|
+
ref: editableOverlayRef,
|
|
4271
|
+
"aria-hidden": true,
|
|
4272
|
+
style: {
|
|
4273
|
+
position: "absolute",
|
|
4274
|
+
inset: 0,
|
|
4275
|
+
overflow: "hidden",
|
|
4276
|
+
pointerEvents: "none",
|
|
4277
|
+
maxHeight
|
|
4278
|
+
},
|
|
4279
|
+
children: /* @__PURE__ */ jsx(
|
|
4280
|
+
SyntaxHighlighter,
|
|
4281
|
+
{
|
|
4282
|
+
PreTag: "div",
|
|
4283
|
+
language,
|
|
4284
|
+
style: activeStyle,
|
|
4285
|
+
customStyle: {
|
|
4286
|
+
backgroundColor: "transparent",
|
|
4287
|
+
borderRadius: 0,
|
|
4288
|
+
padding: "1rem",
|
|
4289
|
+
margin: 0,
|
|
4290
|
+
whiteSpace: "pre",
|
|
4291
|
+
minWidth: "100%",
|
|
4292
|
+
minHeight: "160px",
|
|
4293
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
4294
|
+
fontSize: "13px",
|
|
4295
|
+
lineHeight: "1.5"
|
|
4296
|
+
},
|
|
4297
|
+
codeTagProps: {
|
|
4298
|
+
style: {
|
|
4299
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
4300
|
+
fontSize: "13px",
|
|
4301
|
+
lineHeight: "1.5"
|
|
4302
|
+
}
|
|
4303
|
+
},
|
|
4304
|
+
children: editableValue || " "
|
|
4305
|
+
}
|
|
4306
|
+
)
|
|
4307
|
+
}
|
|
4308
|
+
),
|
|
4309
|
+
/* @__PURE__ */ jsx(
|
|
4310
|
+
Textarea,
|
|
4311
|
+
{
|
|
4312
|
+
ref: editableTextareaRef,
|
|
4313
|
+
defaultValue: code,
|
|
4314
|
+
onChange: (e) => {
|
|
4315
|
+
setEditableValue(e.target.value);
|
|
4316
|
+
onChange?.(e.target.value);
|
|
4317
|
+
},
|
|
4318
|
+
onScroll: handleEditableScroll,
|
|
4319
|
+
spellCheck: false,
|
|
4320
|
+
style: {
|
|
4321
|
+
position: "relative",
|
|
4322
|
+
zIndex: 1,
|
|
4323
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Courier New", monospace',
|
|
4324
|
+
fontSize: "13px",
|
|
4325
|
+
lineHeight: "1.5",
|
|
4326
|
+
backgroundColor: "transparent",
|
|
4327
|
+
color: "transparent",
|
|
4328
|
+
caretColor: "#e6e6e6",
|
|
4329
|
+
borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem",
|
|
4330
|
+
border: "none",
|
|
4331
|
+
padding: "1rem",
|
|
4332
|
+
resize: "none",
|
|
4333
|
+
minHeight: "160px",
|
|
4334
|
+
maxHeight,
|
|
4335
|
+
width: "100%",
|
|
4336
|
+
height: "100%",
|
|
4337
|
+
outline: "none",
|
|
4338
|
+
whiteSpace: "pre",
|
|
4339
|
+
overflowWrap: "normal",
|
|
4340
|
+
overflow: "auto"
|
|
4341
|
+
}
|
|
4342
|
+
},
|
|
4343
|
+
editableTextareaKey
|
|
4344
|
+
)
|
|
4345
|
+
]
|
|
4253
4346
|
}
|
|
4254
4347
|
)
|
|
4255
4348
|
) : /* @__PURE__ */ jsx(
|