fix: parse template code & update maxRow of TextAreaSetter (#192)

* fix: update templatePattern regex to allow for multiline code wrapping

* fix: update error overlay display to use designer.activeView instead of mode

* fix: update maxRows to 6 in TextAreaSetter
This commit is contained in:
Wells
2024-08-05 11:20:41 +08:00
committed by GitHub
parent 0d0479e3e5
commit a1eea02f94
5 changed files with 17 additions and 4 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ import { OutButton } from "../components";
class App extends React.Component {
render() {
return (
<Page title={tango.stores.app.title} subTitle={111}>
<Page title={tango.stores.app.title} subTitle={<><Button>hello</Button></>}>
<Section tid="section0" />
<Section tid="section1" title="Section Title">
your input: <Input tid="input1" defaultValue="hello" />
+1 -1
View File
@@ -31,7 +31,7 @@ export const WorkspaceView = observer((props: WorkspaceViewProps) => {
{children}
{/* 添加组件弹层 */}
{display === 'block' && <ComponentsPopover type="inner" isControlled />}
{mode === 'design' && <FileErrorsOverlay />}
{designer.activeView === 'design' && <FileErrorsOverlay />}
</Box>
);
});
+1 -1
View File
@@ -32,7 +32,7 @@ export function isValidFunctionCode(str: string) {
}
}
const templatePattern = /^{{(.+)}}$/;
const templatePattern = /^{{([\s\S]+)}}$/;
/**
* 判断给定代码是否被双花括号包裹
@@ -0,0 +1,13 @@
import { isWrappedCode } from '../src/helpers';
describe('helpers/codeHelper', () => {
it('isWrappedCode', () => {
expect(isWrappedCode('{{[]}}')).toBeTruthy(); // true
expect(isWrappedCode('{{{}}}')).toBeTruthy(); // true
expect(isWrappedCode('{{this.foo}}')).toBeTruthy(); // true
expect(isWrappedCode('{{123}}')).toBeTruthy(); // true
expect(isWrappedCode('{{() => {}}}')).toBeTruthy(); // true
expect(isWrappedCode('{{<Button>button</Button>}}')).toBeTruthy(); // true
expect(isWrappedCode('{{<>\n<Button>hello</Button>\n</>}}')).toBeTruthy(); // true
});
});
@@ -34,7 +34,7 @@ export function TextSetter({
const autoSize = {
minRows: 2,
maxRows: 5,
maxRows: 6,
};
export function TextAreaSetter({