mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-01 13:40:41 +00:00
Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3681622 * chore: remove unnecessary code * refactor: react-render using TypeScript * chore: build-script * refactor: editor-skeleton * refactor: designer * refactor: material-parser * refactor: editor-setters * refactor: js to ts for rax-provider Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3678180 * refactor: rax-provider * feat: add build command * chore: compilerOptions for rax-provider * refactor: JS to TS for Rax Renderer Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3678935 * refactor: rax-renderer * Merge remote-tracking branch 'origin/refactor/js-to-ts' into refactor/js2ts-rax-renderer * Merge remote-tracking branch 'origin/refactor/js-to-ts' into refactor/js2ts-rax-renderer * refactor: ts-nocheck * chore: ts compile error * fix: ts rootDir * fix: compile error * chore: using same tsconfig for rax component * refactor: ts compile rax-renderer && rax-provider * Merge remote-tracking branch 'origin/release/1.0.0' into refactor/js-to-ts # Conflicts: # packages/rax-render/src/utils/appHelper.js # packages/rax-render/src/utils/appHelper.ts # packages/utils/src/appHelper.ts * refactor: no JS file * refactor: remove lint * feat: add xima * feat: add eslint ignore * style: fix by lint * feat: lint command * fix: using the same eslint config * style: eslint settings * Merge remote-tracking branch 'origin/release/1.0.0' into refactor/code-style # Conflicts: # packages/plugin-event-bind-dialog/src/index.tsx # packages/plugin-source-editor/src/index.tsx # packages/runtime/src/core/container.ts # packages/runtime/src/core/provider.ts * Merge remote-tracking branch 'origin/release/1.0.0' into refactor/code-style # Conflicts: # packages/designer/src/document/document-model.ts # packages/designer/src/document/node/node-children.ts # packages/designer/src/document/node/props/prop.ts # packages/plugin-source-editor/src/index.tsx * fix: 修改dataSource items -> list * Merge remote-tracking branch 'origin/relase/1.0.0' into refactor/code-style # Conflicts: # packages/react-renderer/package.json * refactor: component-panel plugin-component-pane 代码规范化 Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3703771 * feat: support bizcomps * refactor: component-panel * style: eslint * Merge branch 'refactor/code-style' into fix/ducheng-source-style * style: code style * Merge branch 'fix/ducheng-source-style' into 'refactor/code-style' Code review title: Fix/ducheng source style Code review Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3705972 * style: for demo * style: for demo-server * style: for plugin-event-bind-dialog * style: for plugin-sample-preview * style: for plugin-undo-redo * style: plugin-variable-bind-dialog * style: types * style: for utils * Merge remote-tracking branch 'origin/release/1.0.0' into refactor/code-style # Conflicts: # packages/editor-setters/src/expression-setter/locale/snippets.ts # packages/editor-setters/src/json-setter/locale/snippets.ts # packages/editor-setters/src/locale/snippets.ts # packages/plugin-components-pane/package.json # packages/rax-render/src/hoc/compWrapper.tsx # packages/rax-render/src/utils/index.ts # packages/react-renderer/src/context/appContext.ts * style: editor-preset-general editor-preset-general 代码规范化 Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3707974 * style: editor-preset-general * fix: should set field * fix: should set field - demo-server * refactor(style): fix code style for designer refactor(style): fix code style for editor-core refactor(style): fix code style for editor-skeleton refactor(style): fix code style for react-simulator-renderer refactor(style): fix code style for rax-simulator-renderer * Merge branch 'refactor/lihao-code-style' into 'refactor/code-style' Code review title: refactor(style): fix code style for designer Code review description: refactor(style): fix code style for editor-core refactor(style): fix code style for editor-skeleton refactor(style): fix code style for react-simulator-renderer refactor(style): fix code style for rax-simulator-renderer Code review Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3709472 * style: react/no-multi-comp set to 0 for designer * style: ignore editor-prset-vision * style: fix for plugin-outline-pane * style: fix for rax-provider * style: react-provider * style: runtime * style: rax-render * Merge remote-tracking branch 'origin/release/1.0.0' into refactor/code-style # Conflicts: # packages/editor-setters/src/expression-setter/index.tsx # packages/plugin-source-editor/src/index.tsx # packages/plugin-source-editor/src/transform.ts * refactor: material parser code style 1. 修复eslint问题 2. instanceOf => any 3. 修复node类型解析失败问题 Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3716330 * refactor: material parser code style * refactor: code-generator code style 1. rax 出码合并 2. code style 修复 注:合并的代码中带了 datasource 的 Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3717159 * Merge branch 'feat/rax-code-generator' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into feat/rax-code-generator # Conflicts: # packages/code-generator/src/generator/ProjectBuilder.ts # packages/code-generator/src/parser/SchemaParser.ts # packages/code-generator/src/plugins/component/rax/jsx.ts # packages/code-generator/src/plugins/project/constants.ts # packages/code-generator/src/plugins/project/framework/rax/plugins/packageJSON.ts # packages/code-generator/src/plugins/project/i18n.ts # packages/code-generator/src/publisher/disk/index.ts # packages/code-generator/src/publisher/disk/utils.ts # packages/code-generator/src/types/core.ts # packages/code-generator/src/types/schema.ts # packages/code-generator/src/utils/compositeType.ts # packages/code-generator/src/utils/nodeToJSX.ts * refactor: code-generator * Merge remote-tracking branch 'origin/refactor/code-style' into refactor/code-style-code-generator # Conflicts: # .vscode/launch.json * Revert "refactor: code-generator code style " This reverts commit ebc78e8788f83e8fda0e146758af43b878125c10. * chore: eslintrc && eslintignore * style: for plugin-source-editor * style: fix by eslint --fix * style: scripts/ * style: datasource-engine * feat: pre-commit * Merge branch 'refactor/code-style' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into refactor/code-style # Conflicts: # .eslintignore # packages/code-generator/src/parser/SchemaParser.ts # packages/code-generator/src/plugins/component/rax/containerInitState.ts # packages/code-generator/src/plugins/component/rax/containerInjectDataSourceEngine.ts # packages/code-generator/src/plugins/component/rax/containerLifeCycle.ts # packages/code-generator/src/plugins/project/framework/rax/plugins/buildConfig.ts # packages/code-generator/src/utils/OrderedSet.ts # packages/code-generator/src/utils/ScopeBindings.ts # packages/code-generator/src/utils/expressionParser.ts # packages/code-generator/src/utils/schema.ts # packages/datasource-engine/src/core/DataSourceEngine.ts # packages/datasource-engine/src/core/RuntimeDataSource.ts # packages/datasource-engine/src/types/IRuntimeContext.ts # packages/datasource-engine/src/types/index.ts * refactor: code style code-generator 对 code style 分支上次合并的 code-generator 修改做了 revert 重新在 code style 分支基础上对代码样式做了修复 rax 合并分支会另行 fix 后向 release 分支提 MR Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3719702 * refactor: code style fix * style: for code-generator * Merge remote-tracking branch 'origin/release/1.0.0' into refactor/code-style # Conflicts: # packages/editor-skeleton/src/transducers/addon-combine.ts # packages/plugin-components-pane/package.json # packages/plugin-components-pane/src/components/base/index.tsx # packages/plugin-components-pane/src/components/component-list/index.tsx # packages/plugin-components-pane/src/i18n/index.ts # packages/plugin-components-pane/src/i18n/strings/index.ts # packages/plugin-components-pane/src/index.tsx # packages/plugin-event-bind-dialog/src/index.tsx # packages/plugin-source-editor/src/index.tsx # packages/plugin-source-editor/src/transform.ts * style: auto fix
414 lines
6.9 KiB
TypeScript
414 lines
6.9 KiB
TypeScript
import { ReactElement, createElement, ReactType } from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
const supportedEvents = [
|
|
// MouseEvents
|
|
{
|
|
name: 'onClick',
|
|
description: '点击时',
|
|
},
|
|
{
|
|
name: 'onDoubleClick',
|
|
description: '双击时',
|
|
},
|
|
{
|
|
name: 'onMouseDown',
|
|
description: '鼠标按下',
|
|
},
|
|
{
|
|
name: 'onMouseEnter',
|
|
description: '鼠标进入',
|
|
},
|
|
{
|
|
name: 'onMouseMove',
|
|
description: '鼠标移动',
|
|
},
|
|
{
|
|
name: 'onMouseOut',
|
|
description: '鼠标移出',
|
|
},
|
|
{
|
|
name: 'onMouseOver',
|
|
description: '鼠标悬停',
|
|
},
|
|
{
|
|
name: 'onMouseUp',
|
|
description: '鼠标松开',
|
|
},
|
|
// Focus Events
|
|
{
|
|
name: 'onFocus',
|
|
description: '获得焦点',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onBlur',
|
|
description: '失去焦点',
|
|
snippet: '',
|
|
},
|
|
// Form Events
|
|
{
|
|
name: 'onChange',
|
|
description: '值改变时',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onSelect',
|
|
description: '选择',
|
|
},
|
|
{
|
|
name: 'onInput',
|
|
description: '输入',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onReset',
|
|
description: '重置',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onSubmit',
|
|
description: '提交',
|
|
snippet: '',
|
|
},
|
|
// Clipboard Events
|
|
{
|
|
name: 'onCopy',
|
|
description: '复制',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onCut',
|
|
description: '剪切',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onPaste',
|
|
description: '粘贴',
|
|
snippet: '',
|
|
},
|
|
|
|
// Keyboard Events
|
|
{
|
|
name: 'onKeyDown',
|
|
description: '键盘按下',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onKeyPress',
|
|
description: '键盘按下并释放',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onKeyUp',
|
|
description: '键盘松开',
|
|
snippet: '',
|
|
},
|
|
// Touch Events
|
|
{
|
|
name: 'onTouchCancel',
|
|
description: '触摸退出',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onTouchEnd',
|
|
description: '触摸结束',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onTouchMove',
|
|
description: '触摸移动',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onTouchStart',
|
|
description: '触摸开始',
|
|
snippet: '',
|
|
},
|
|
// UI Events
|
|
{
|
|
name: 'onScroll',
|
|
description: '滚动',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onLoad',
|
|
description: '加载完毕',
|
|
snippet: '',
|
|
},
|
|
{
|
|
name: 'onWheel',
|
|
description: '滚轮事件',
|
|
snippet: '',
|
|
},
|
|
// Animation Events
|
|
{
|
|
name: 'onAnimationStart',
|
|
description: '动画开始',
|
|
},
|
|
{
|
|
name: 'onAnimationEnd',
|
|
description: '动画结束',
|
|
},
|
|
];
|
|
|
|
// eslint-disable-next-line func-call-spacing
|
|
const builtinComponents = new Map<string, (props: any) => ReactElement>();
|
|
function getBlockElement(tag: string): (props: any) => ReactElement {
|
|
if (builtinComponents.has(tag)) {
|
|
return builtinComponents.get(tag)!;
|
|
}
|
|
const mock = ({ className, children, ...rest }: any = {}) => {
|
|
const props = {
|
|
...rest,
|
|
className: classNames('lc-block-container', className),
|
|
};
|
|
return createElement(tag, props, children);
|
|
};
|
|
|
|
mock.metadata = {
|
|
componentName: tag,
|
|
// selfControlled: true,
|
|
configure: {
|
|
props: [],
|
|
events: {
|
|
supportedEvents,
|
|
},
|
|
styles: {
|
|
supportClassName: true,
|
|
supportInlineStyle: true,
|
|
},
|
|
component: {
|
|
...metasMap[tag],
|
|
},
|
|
},
|
|
};
|
|
|
|
builtinComponents.set(tag, mock);
|
|
return mock;
|
|
}
|
|
|
|
const HTMLBlock = [
|
|
'div',
|
|
'p',
|
|
'article',
|
|
'h1',
|
|
'h2',
|
|
'h3',
|
|
'h4',
|
|
'h5',
|
|
'h6',
|
|
'aside',
|
|
'blockquote',
|
|
'footer',
|
|
'form',
|
|
'header',
|
|
'table',
|
|
'tbody',
|
|
'section',
|
|
'ul',
|
|
'li',
|
|
];
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
const HTMLInlineBlock = ['a', 'b', 'span', 'em'];
|
|
export function getIntrinsicMock(tag: string): ReactType {
|
|
if (HTMLBlock.indexOf(tag) > -1) {
|
|
return getBlockElement(tag);
|
|
}
|
|
|
|
return tag as any;
|
|
}
|
|
|
|
const metasMap: any = {
|
|
div: {
|
|
isContainer: true,
|
|
nesting: {
|
|
ancestorBlacklist: 'p',
|
|
},
|
|
},
|
|
ul: {
|
|
isContainer: true,
|
|
nesting: {
|
|
childWhitelist: 'li',
|
|
},
|
|
},
|
|
p: {
|
|
isContainer: true,
|
|
nesting: {
|
|
ancestorBlacklist: 'button,p',
|
|
},
|
|
},
|
|
li: {
|
|
isContainer: true,
|
|
nesting: {
|
|
parentWhitelist: 'ui,ol',
|
|
},
|
|
},
|
|
span: {
|
|
isContainer: true,
|
|
selfControlled: true,
|
|
},
|
|
a: {
|
|
isContainer: true,
|
|
nesting: {
|
|
ancestorBlacklist: 'a',
|
|
},
|
|
},
|
|
b: {
|
|
isContainer: true,
|
|
},
|
|
strong: {
|
|
isContainer: true,
|
|
},
|
|
em: {
|
|
isContainer: true,
|
|
},
|
|
i: {
|
|
isContainer: true,
|
|
},
|
|
form: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'form,button',
|
|
},
|
|
},
|
|
table: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
caption: {
|
|
isContainer: true,
|
|
selfControlled: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
select: {
|
|
isContainer: true,
|
|
selfControlled: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
button: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
input: {
|
|
isContainer: false,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button,h1,h2,h3,h4,h5,h6',
|
|
},
|
|
},
|
|
textarea: {
|
|
isContainer: false,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
image: {
|
|
isContainer: false,
|
|
},
|
|
canvas: {
|
|
isContainer: false,
|
|
},
|
|
br: {
|
|
isContainer: false,
|
|
},
|
|
h1: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
h2: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
h3: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
h4: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
h5: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
h6: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
article: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
aside: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
footer: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
header: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
blockquote: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
address: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
section: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'p,h1,h2,h3,h4,h5,h6,button',
|
|
},
|
|
},
|
|
summary: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
nav: {
|
|
isContainer: true,
|
|
nestingRule: {
|
|
ancestorBlacklist: 'button',
|
|
},
|
|
},
|
|
};
|