mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 12:50:38 +00:00
fix: 修复设置迭代参数异常的 bug
This commit is contained in:
parent
46dce7a1f1
commit
c26da97885
@ -455,8 +455,9 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
wrapWith(/* schema: Schema */) {
|
||||
// todo
|
||||
wrapWith(schema: Schema) {
|
||||
// this.replaceWith({ ...schema, children: [this.export()] });
|
||||
// this.children!.get(0)!.select();
|
||||
}
|
||||
|
||||
replaceWith(schema: Schema, migrate = false): any {
|
||||
|
||||
@ -15,16 +15,11 @@ export function getConvertedExtraKey(key: string): string {
|
||||
if (key.indexOf('.') > 0) {
|
||||
_key = key.split('.')[0];
|
||||
}
|
||||
return EXTRA_KEY_PREFIX + _key + EXTRA_KEY_PREFIX + key.substr(_key.length + 1);
|
||||
return EXTRA_KEY_PREFIX + _key + EXTRA_KEY_PREFIX + key.substr(_key.length);
|
||||
}
|
||||
export function getOriginalExtraKey(key: string): string {
|
||||
// 移除串首、串尾的 EXTRA_KEY_PREFIX,将剩下的转成 .
|
||||
return key
|
||||
.replace(new RegExp(`^${EXTRA_KEY_PREFIX}`), '')
|
||||
.replace(new RegExp(`${EXTRA_KEY_PREFIX}$`), '')
|
||||
.replace(new RegExp(`${EXTRA_KEY_PREFIX}`, 'g'), '.');
|
||||
return key.replace(new RegExp(`${EXTRA_KEY_PREFIX}`, 'g'), '');
|
||||
}
|
||||
|
||||
export class Props implements IPropParent {
|
||||
readonly id = uniqueId('props');
|
||||
|
||||
|
||||
@ -234,11 +234,12 @@ describe('其他函数', () => {
|
||||
it('getConvertedExtraKey', () => {
|
||||
expect(getConvertedExtraKey()).toBe('');
|
||||
expect(getConvertedExtraKey('a')).toBe('___a___');
|
||||
expect(getConvertedExtraKey('a.b')).toBe('___a___b');
|
||||
expect(getConvertedExtraKey('a.b')).toBe('___a___.b');
|
||||
expect(getConvertedExtraKey('a.0')).toBe('___a___.0');
|
||||
});
|
||||
|
||||
it('getOriginalExtraKey', () => {
|
||||
expect(getOriginalExtraKey('___a___')).toBe('a');
|
||||
expect(getOriginalExtraKey('___a___b')).toBe('a.b');
|
||||
expect(getOriginalExtraKey('___a___.b')).toBe('a.b');
|
||||
});
|
||||
});
|
||||
34
packages/engine/build.cloud.json
Normal file
34
packages/engine/build.cloud.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"entry": {
|
||||
"engine": "src/index",
|
||||
"engine-core": "src/index-core"
|
||||
},
|
||||
"library": "___AliLowCodeEngine___",
|
||||
"libraryTarget": "umd",
|
||||
"externals": {
|
||||
"react": "var window.React",
|
||||
"react-dom": "var window.ReactDOM",
|
||||
"prop-types": "var window.PropTypes",
|
||||
"@ali/visualengine": "var window.VisualEngine",
|
||||
"@ali/visualengine-utils": "var window.VisualEngineUtils",
|
||||
"rax": "var window.Rax",
|
||||
"monaco-editor/esm/vs/editor/editor.api": "var window.monaco",
|
||||
"monaco-editor/esm/vs/editor/editor.main.js": "var window.monaco",
|
||||
"@ali/lowcode-engine-ext": "var window.AliLowCodeEngineExt"
|
||||
},
|
||||
"browserslist": {
|
||||
"chrome": 80
|
||||
},
|
||||
"outputDir": "dist",
|
||||
"vendor": false,
|
||||
"ignoreHtmlTemplate": false,
|
||||
"sourceMap": true,
|
||||
"plugins": [
|
||||
"build-plugin-react-app",
|
||||
"build-plugin-fusion",
|
||||
["build-plugin-moment-locales", {
|
||||
"locales": ["zh-cn"]
|
||||
}],
|
||||
"./build.plugin.js"
|
||||
]
|
||||
}
|
||||
@ -13,7 +13,7 @@
|
||||
"start": "build-scripts start",
|
||||
"version:update": "node ./scripts/version.js",
|
||||
"build": "build-scripts build --skip-demo",
|
||||
"cloud-build": "build-scripts build --skip-demo && tnpm run version:update",
|
||||
"cloud-build": "build-scripts build --skip-demo",
|
||||
"test": "build-scripts test --config build.test.json"
|
||||
},
|
||||
"license": "MIT",
|
||||
@ -50,7 +50,7 @@
|
||||
"@types/react-dom": "^16.8.2",
|
||||
"build-plugin-fusion": "^0.1.0",
|
||||
"build-plugin-moment-locales": "^0.1.0",
|
||||
"build-plugin-react-app": "^1.1.2",
|
||||
"build-plugin-react-app": "^1.8.0",
|
||||
"fs-extra": "^9.0.1",
|
||||
"prop-types": "^15.7.2",
|
||||
"tsconfig-paths-webpack-plugin": "^3.2.0"
|
||||
|
||||
154
packages/engine/src/engine-core.ts
Normal file
154
packages/engine/src/engine-core.ts
Normal file
@ -0,0 +1,154 @@
|
||||
import { createElement } from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { globalContext, Editor } from '@ali/lowcode-editor-core';
|
||||
import * as editorCabin from '@ali/lowcode-editor-core';
|
||||
import {
|
||||
Designer,
|
||||
LowCodePluginManager,
|
||||
} from '@ali/lowcode-designer';
|
||||
import * as designerCabin from '@ali/lowcode-designer';
|
||||
import { Skeleton, SettingsPrimaryPane, registerDefaults } from '@ali/lowcode-editor-skeleton';
|
||||
import * as skeletonCabin from '@ali/lowcode-editor-skeleton';
|
||||
import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane';
|
||||
import DesignerPlugin from '@ali/lowcode-plugin-designer';
|
||||
import './modules/live-editing';
|
||||
|
||||
export * from './modules/editor-types';
|
||||
export * from './modules/skeleton-types';
|
||||
export * from './modules/designer-types';
|
||||
// export * from './modules/lowcode-types';
|
||||
|
||||
const { hotkey, monitor, getSetter, registerSetter, getSettersMap } = editorCabin;
|
||||
registerDefaults();
|
||||
|
||||
const editor = new Editor();
|
||||
globalContext.register(editor, Editor);
|
||||
|
||||
const skeleton = new Skeleton(editor);
|
||||
editor.set(Skeleton, skeleton);
|
||||
editor.set('skeleton' as any, skeleton);
|
||||
|
||||
const designer = new Designer({ editor });
|
||||
editor.set(Designer, designer);
|
||||
editor.set('designer' as any, designer);
|
||||
|
||||
const plugins = new LowCodePluginManager(editor).toProxy();
|
||||
editor.set('plugins' as any, plugins);
|
||||
|
||||
skeleton.add({
|
||||
area: 'mainArea',
|
||||
name: 'designer',
|
||||
type: 'Widget',
|
||||
content: DesignerPlugin,
|
||||
});
|
||||
skeleton.add({
|
||||
area: 'rightArea',
|
||||
name: 'settingsPane',
|
||||
type: 'Panel',
|
||||
content: SettingsPrimaryPane,
|
||||
props: {
|
||||
ignoreRoot: true,
|
||||
},
|
||||
});
|
||||
skeleton.add({
|
||||
area: 'leftArea',
|
||||
name: 'outlinePane',
|
||||
type: 'PanelDock',
|
||||
content: Outline,
|
||||
panelProps: {
|
||||
area: 'leftFixedArea',
|
||||
},
|
||||
});
|
||||
skeleton.add({
|
||||
area: 'rightArea',
|
||||
name: 'backupOutline',
|
||||
type: 'Panel',
|
||||
props: {
|
||||
condition: () => {
|
||||
return designer.dragon.dragging && !getTreeMaster(designer).hasVisibleTreeBoard();
|
||||
},
|
||||
},
|
||||
content: OutlineBackupPane,
|
||||
});
|
||||
|
||||
const { project, currentSelection: selection } = designer;
|
||||
const { Workbench } = skeletonCabin;
|
||||
const setters = {
|
||||
getSetter,
|
||||
registerSetter,
|
||||
getSettersMap,
|
||||
};
|
||||
|
||||
export {
|
||||
editor,
|
||||
editorCabin,
|
||||
skeleton,
|
||||
skeletonCabin,
|
||||
designer,
|
||||
designerCabin,
|
||||
plugins,
|
||||
setters,
|
||||
project,
|
||||
selection,
|
||||
/**
|
||||
* 注册一些全局的切面
|
||||
*/
|
||||
// hooks,
|
||||
/**
|
||||
* 全局的一些数据存储
|
||||
*/
|
||||
// store,
|
||||
hotkey,
|
||||
monitor,
|
||||
};
|
||||
|
||||
const getSelection = () => designer.currentDocument?.selection;
|
||||
// TODO: build-plugin-component 的 umd 开发态没有导出 AliLowCodeEngine,这里先简单绕过
|
||||
(window as any).AliLowCodeEngine = {
|
||||
editor,
|
||||
editorCabin,
|
||||
skeleton,
|
||||
skeletonCabin,
|
||||
designer,
|
||||
designerCabin,
|
||||
plugins,
|
||||
setters,
|
||||
project,
|
||||
get selection() {
|
||||
return getSelection();
|
||||
},
|
||||
/**
|
||||
* 注册一些全局的切面
|
||||
*/
|
||||
// hooks,
|
||||
/**
|
||||
* 全局的一些数据存储
|
||||
*/
|
||||
// store,
|
||||
hotkey,
|
||||
monitor,
|
||||
init,
|
||||
};
|
||||
|
||||
export async function init(container?: Element) {
|
||||
const builtinSetters = require('@ali/lowcode-engine-ext').setters;
|
||||
if (builtinSetters) {
|
||||
registerSetter(builtinSetters as any);
|
||||
}
|
||||
let engineContainer = container;
|
||||
if (!engineContainer) {
|
||||
engineContainer = document.createElement('div');
|
||||
document.body.appendChild(engineContainer);
|
||||
}
|
||||
engineContainer.id = 'engine';
|
||||
|
||||
await plugins.init();
|
||||
render(
|
||||
createElement(Workbench, {
|
||||
skeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
}),
|
||||
engineContainer,
|
||||
);
|
||||
}
|
||||
11
packages/engine/src/index-core.ts
Normal file
11
packages/engine/src/index-core.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export * from './engine';
|
||||
|
||||
const version = '{{VERSION_PLACEHOLDER}}';
|
||||
|
||||
(window as any).AliLowCodeEngine.version = version;
|
||||
|
||||
console.log(
|
||||
`%c AliLowCodeEngine %c v${version} `,
|
||||
'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;',
|
||||
'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;',
|
||||
);
|
||||
Loading…
x
Reference in New Issue
Block a user