@pushwoosh/dumb-components 1.1.214 → 1.1.215
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.
|
@@ -6,4 +6,4 @@ import { type CodeEditorProps } from './types';
|
|
|
6
6
|
* @example
|
|
7
7
|
* <CodeEditor value={code} extensions={json} onChange={setCode} height="200px" />
|
|
8
8
|
*/
|
|
9
|
-
export declare const CodeEditor: ({ value, onChange, readOnly, width, height, onBlur, extensions, themeOptions, hasError, placeholder, }: CodeEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const CodeEditor: ({ value, onChange, readOnly, width, height, onBlur, extensions, themeOptions, hasError, placeholder, wrapText, }: CodeEditorProps) => import("react/jsx-runtime").JSX.Element;
|
package/CodeEditor/CodeEditor.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import createTheme from '@uiw/codemirror-themes';
|
|
3
|
+
import { EditorView } from '@uiw/react-codemirror';
|
|
4
|
+
import { useMemo } from 'react';
|
|
3
5
|
import { defaultTheme } from './constants';
|
|
4
6
|
import { CodeMirrorStyled } from './styles';
|
|
5
7
|
/**
|
|
@@ -19,8 +21,10 @@ export const CodeEditor = ({
|
|
|
19
21
|
extensions,
|
|
20
22
|
themeOptions,
|
|
21
23
|
hasError,
|
|
22
|
-
placeholder
|
|
24
|
+
placeholder,
|
|
25
|
+
wrapText
|
|
23
26
|
}) => {
|
|
27
|
+
const resolvedExtensions = useMemo(() => wrapText ? [extensions, EditorView.lineWrapping] : extensions, [extensions, wrapText]);
|
|
24
28
|
return _jsx(CodeMirrorStyled, {
|
|
25
29
|
value: value,
|
|
26
30
|
theme: themeOptions ? createTheme(themeOptions) : defaultTheme,
|
|
@@ -29,7 +33,7 @@ export const CodeEditor = ({
|
|
|
29
33
|
onBlur: onBlur,
|
|
30
34
|
width: width,
|
|
31
35
|
height: height,
|
|
32
|
-
extensions:
|
|
36
|
+
extensions: resolvedExtensions,
|
|
33
37
|
placeholder: placeholder,
|
|
34
38
|
"$danger": hasError
|
|
35
39
|
});
|
package/CodeEditor/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type CodeEditorProps = {
|
|
|
16
16
|
extensions: Extension[];
|
|
17
17
|
/** Placeholder shown when empty. */
|
|
18
18
|
placeholder?: string;
|
|
19
|
+
/** Soft-wrap long lines instead of scrolling horizontally. */
|
|
20
|
+
wrapText?: boolean;
|
|
19
21
|
/** Theme overrides; defaults to the built-in theme when omitted. */
|
|
20
22
|
themeOptions?: CreateThemeOptions;
|
|
21
23
|
/** Fires with the new content and the CodeMirror `ViewUpdate` on every edit. */
|