notjs-react 0.3.3 → 0.3.6

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 CHANGED
@@ -58,6 +58,7 @@ function App() {
58
58
  | `initialDarkMode` | `boolean` | `true` | Enable dark mode by default |
59
59
  | `initialCode` | `string` | (language default) | Custom starting code |
60
60
  | `hideHeader` | `boolean` | `false` | Hide header for embedding |
61
+ | `editorWidthPercent` | `number` | `50` | Initial editor width as percentage (20-80) |
61
62
 
62
63
  ## Features
63
64
 
@@ -144,6 +145,53 @@ int main() {
144
145
  />
145
146
  ```
146
147
 
148
+ ## Troubleshooting
149
+
150
+ ### CSS Styling Issues in Frameworks (Astro, Next.js, etc.)
151
+
152
+ Although NotJS includes self-contained CSS, some frameworks may experience styling issues due to **CSS purging/tree-shaking**. The terminal styles (xterm.js) are added dynamically at runtime, so build tools may incorrectly remove them as "unused."
153
+
154
+ #### Symptoms
155
+ - Terminal appears with white/blank background
156
+ - Terminal resizing doesn't work
157
+ - Missing terminal UI elements
158
+
159
+ #### Solution: Wrapper Component (Recommended)
160
+
161
+ Create a wrapper component with explicit dimensions and **always import the CSS in the wrapper**:
162
+
163
+ ```tsx
164
+ // components/NotJSWrapper.tsx
165
+ import { NotJS } from 'notjs-react'
166
+ import 'notjs-react/styles.css' // Critical: Import styles here
167
+
168
+ export function NotJSWrapper({ width = '100%', height = '600px', ...props }) {
169
+ return (
170
+ <div style={{ width, height }}>
171
+ <NotJS {...props} />
172
+ </div>
173
+ )
174
+ }
175
+ ```
176
+
177
+ Then use the wrapper in your MDX/pages:
178
+
179
+ ```mdx
180
+ import { NotJSWrapper } from '@/components/NotJSWrapper'
181
+
182
+ # My Blog Post
183
+
184
+ <NotJSWrapper
185
+ width="100%"
186
+ height="500px"
187
+ apiBaseUrl="https://your-api.com/api"
188
+ websocketUrl="wss://your-api.com/terminal"
189
+ initialLanguage="java"
190
+ />
191
+ ```
192
+
193
+ **Important**: The CSS import (`import 'notjs-react/styles.css'`) must be in the wrapper component file, not just in your page/MDX file. This ensures the styles are properly bundled and not purged by the build process.
194
+
147
195
  ## Development
148
196
 
149
197
  To develop the library locally:
@@ -215,6 +263,11 @@ The `NotJS` component accepts the following props:
215
263
  - Default: `false`
216
264
  - Description: Hide the header (language selector, version, theme toggle) for embedded views
217
265
 
266
+ #### `editorWidthPercent` (optional)
267
+ - Type: `number`
268
+ - Default: `50`
269
+ - Description: Initial width of the editor panel as a percentage (constrained between 20-80). The console panel takes the remaining space. Users can still manually resize using the drag handle.
270
+
218
271
  ## Architecture
219
272
 
220
273
  The NotJS component architecture:
package/dist/NotJS.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface NotJSProps {
12
12
  initialVersion?: string;
13
13
  initialDarkMode?: boolean;
14
14
  hideHeader?: boolean;
15
+ editorWidthPercent?: number;
15
16
  }
16
- export default function NotJS({ websocketUrl, apiBaseUrl, initialCode, initialLanguage, initialVersion, initialDarkMode, hideHeader }: NotJSProps): import("react/jsx-runtime").JSX.Element;
17
+ export default function NotJS({ websocketUrl, apiBaseUrl, initialCode, initialLanguage, initialVersion, initialDarkMode, hideHeader, editorWidthPercent }: NotJSProps): import("react/jsx-runtime").JSX.Element;
17
18
  //# sourceMappingURL=NotJS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotJS.d.ts","sourceRoot":"","sources":["../src/NotJS.tsx"],"names":[],"mappings":"AAGA,OAAO,4BAA4B,CAAA;AAgGnC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,E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