@particle-academy/fancy-code 0.9.0 → 0.9.1

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/index.js CHANGED
@@ -42,26 +42,12 @@ function CodeEditorPanel({ className }) {
42
42
  _maxHeight,
43
43
  _minHeight
44
44
  } = useCodeEditor();
45
- if (!engine) return null;
46
- const {
47
- textareaRef,
48
- highlightedHtml,
49
- lineCount,
50
- activeLine,
51
- themeColors,
52
- handleKeyDown,
53
- handleInput,
54
- handleScroll,
55
- handleSelect,
56
- scrollTop,
57
- scrollLeft
58
- } = engine;
59
- const gutterWidth = lineNumbers ? `${Math.max(String(lineCount).length, 2) * 0.75 + 1.5}em` : "0";
60
45
  const lineNumberElements = useMemo(() => {
61
- if (!lineNumbers) return null;
62
- const removed = diffRemovedColor(themeColors);
46
+ if (!engine || !lineNumbers) return null;
47
+ const { themeColors: themeColors2, lineCount: lineCount2, activeLine: activeLine2 } = engine;
48
+ const removed = diffRemovedColor(themeColors2);
63
49
  const lines = [];
64
- for (let i = 1; i <= lineCount; i++) {
50
+ for (let i = 1; i <= lineCount2; i++) {
65
51
  const mark = gutterDiffMark(diffAnnotations, i);
66
52
  lines.push(
67
53
  /* @__PURE__ */ jsxs(
@@ -71,8 +57,8 @@ function CodeEditorPanel({ className }) {
71
57
  "data-diff-deleted-above": mark?.deletedAbove ? "" : void 0,
72
58
  style: {
73
59
  position: "relative",
74
- color: i === activeLine ? themeColors.foreground : themeColors.gutterForeground,
75
- backgroundColor: i === activeLine ? themeColors.activeLineBackground : void 0
60
+ color: i === activeLine2 ? themeColors2.foreground : themeColors2.gutterForeground,
61
+ backgroundColor: i === activeLine2 ? themeColors2.activeLineBackground : void 0
76
62
  },
77
63
  className: "pr-3 text-right text-[13px] leading-[1.5] select-none",
78
64
  children: [
@@ -87,7 +73,7 @@ function CodeEditorPanel({ className }) {
87
73
  bottom: 0,
88
74
  width: 3,
89
75
  borderRadius: 2,
90
- backgroundColor: diffMarkColor(mark.type, themeColors)
76
+ backgroundColor: diffMarkColor(mark.type, themeColors2)
91
77
  }
92
78
  }
93
79
  ),
@@ -108,7 +94,7 @@ function CodeEditorPanel({ className }) {
108
94
  }
109
95
  ),
110
96
  i,
111
- i === lineCount && hasDeletedAtEnd(diffAnnotations) && /* @__PURE__ */ jsx(
97
+ i === lineCount2 && hasDeletedAtEnd(diffAnnotations) && /* @__PURE__ */ jsx(
112
98
  "span",
113
99
  {
114
100
  "aria-hidden": "true",
@@ -132,7 +118,22 @@ function CodeEditorPanel({ className }) {
132
118
  );
133
119
  }
134
120
  return lines;
135
- }, [lineNumbers, lineCount, activeLine, themeColors, diffAnnotations]);
121
+ }, [engine, lineNumbers, diffAnnotations]);
122
+ if (!engine) return null;
123
+ const {
124
+ textareaRef,
125
+ highlightedHtml,
126
+ lineCount,
127
+ activeLine,
128
+ themeColors,
129
+ handleKeyDown,
130
+ handleInput,
131
+ handleScroll,
132
+ handleSelect,
133
+ scrollTop,
134
+ scrollLeft
135
+ } = engine;
136
+ const gutterWidth = lineNumbers ? `${Math.max(String(lineCount).length, 2) * 0.75 + 1.5}em` : "0";
136
137
  const containerStyle = {
137
138
  backgroundColor: themeColors.background,
138
139
  color: themeColors.foreground,