@particle-academy/fancy-code 0.4.1 → 0.4.2
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/README.md +11 -17
- package/dist/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -83,7 +83,7 @@ function CodeEditorPanel({ className }) {
|
|
|
83
83
|
children: lineNumberElements
|
|
84
84
|
}
|
|
85
85
|
),
|
|
86
|
-
/* @__PURE__ */ jsxs("div", { className: "relative min-w-0
|
|
86
|
+
/* @__PURE__ */ jsxs("div", { className: cn("relative flex-1", wordWrap && "min-w-0"), children: [
|
|
87
87
|
/* @__PURE__ */ jsx(
|
|
88
88
|
"pre",
|
|
89
89
|
{
|
|
@@ -108,7 +108,10 @@ function CodeEditorPanel({ className }) {
|
|
|
108
108
|
"textarea",
|
|
109
109
|
{
|
|
110
110
|
ref: textareaRef,
|
|
111
|
-
className:
|
|
111
|
+
className: cn(
|
|
112
|
+
"relative m-0 block resize-none border-none bg-transparent p-2.5 text-[13px] leading-[1.5] text-transparent outline-none",
|
|
113
|
+
wordWrap ? "w-full" : "min-w-full"
|
|
114
|
+
),
|
|
112
115
|
style: {
|
|
113
116
|
caretColor: themeColors.cursorColor,
|
|
114
117
|
minHeight: _minHeight ? _minHeight - 40 : 80,
|
|
@@ -1293,6 +1296,7 @@ function useEditorEngine({
|
|
|
1293
1296
|
language,
|
|
1294
1297
|
theme,
|
|
1295
1298
|
readOnly,
|
|
1299
|
+
wordWrap,
|
|
1296
1300
|
tabSize,
|
|
1297
1301
|
onCursorChange
|
|
1298
1302
|
}) {
|
|
@@ -1331,7 +1335,13 @@ function useEditorEngine({
|
|
|
1331
1335
|
if (!ta) return;
|
|
1332
1336
|
ta.style.height = "auto";
|
|
1333
1337
|
ta.style.height = ta.scrollHeight + "px";
|
|
1334
|
-
|
|
1338
|
+
if (!wordWrap) {
|
|
1339
|
+
ta.style.width = "0";
|
|
1340
|
+
ta.style.width = ta.scrollWidth + "px";
|
|
1341
|
+
} else {
|
|
1342
|
+
ta.style.width = "";
|
|
1343
|
+
}
|
|
1344
|
+
}, [wordWrap]);
|
|
1335
1345
|
useEffect(() => {
|
|
1336
1346
|
const ta = textareaRef.current;
|
|
1337
1347
|
if (!ta) return;
|
|
@@ -1519,6 +1529,7 @@ function CodeEditorRoot({
|
|
|
1519
1529
|
language: currentLanguage,
|
|
1520
1530
|
theme: resolvedTheme,
|
|
1521
1531
|
readOnly,
|
|
1532
|
+
wordWrap: isWordWrap,
|
|
1522
1533
|
tabSize: tabSizeProp,
|
|
1523
1534
|
onCursorChange: ({ line, col, selectionLength: sel }) => {
|
|
1524
1535
|
setCursorPosition({ line, col });
|