Skip to content

Commit

Permalink
fix: parse template code & update maxRow of TextAreaSetter (#192)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wwsun authored Aug 5, 2024
1 parent 0d0479e commit a1eea02
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/playground/src/helpers/mock-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/workspace-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
});
2 changes: 1 addition & 1 deletion packages/helpers/src/helpers/code-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function isValidFunctionCode(str: string) {
}
}

const templatePattern = /^{{(.+)}}$/;
const templatePattern = /^{{([\s\S]+)}}$/;

/**
* 判断给定代码是否被双花括号包裹
Expand Down
13 changes: 13 additions & 0 deletions packages/helpers/tests/code-helper.test.ts
Original file line number Diff line number Diff line change
@@ -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
});
});
2 changes: 1 addition & 1 deletion packages/setting-form/src/setters/text-setter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function TextSetter({

const autoSize = {
minRows: 2,
maxRows: 5,
maxRows: 6,
};

export function TextAreaSetter({
Expand Down

0 comments on commit a1eea02

Please sign in to comment.