Merge remote-tracking branch 'origin/release/1.0.0' into feat/rax-miniapp

This commit is contained in:
wanying.jwy 2020-09-10 10:27:44 +08:00
commit 7fe13d15e3
1026 changed files with 184248 additions and 38263 deletions

View File

@ -13,9 +13,10 @@
"build": "./scripts/build.sh", "build": "./scripts/build.sh",
"clean": "rm -rf ./packages/*/lib ./packages/*/es ./packages/*/dist ./packages/*/build", "clean": "rm -rf ./packages/*/lib ./packages/*/es ./packages/*/dist ./packages/*/build",
"commit": "git-cz", "commit": "git-cz",
"pub": "lerna publish --cd-version patch", "pub": "lerna publish --force-publish --cd-version prepatch",
"setup": "./scripts/setup.sh", "setup": "./scripts/setup.sh",
"start": "./scripts/start.sh", "start": "./scripts/start.sh",
"start:server": "./scripts/start-server.sh",
"test": "lerna run test --stream", "test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot" "test:snapshot": "lerna run test:snapshot"
}, },

View File

@ -3,6 +3,134 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.0.8-0"></a>
## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.7-0...@ali/lowcode-code-generator@1.0.8-0) (2020-09-09)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.6-0...@ali/lowcode-code-generator@1.0.7-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.5-0...@ali/lowcode-code-generator@1.0.6-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.4-0...@ali/lowcode-code-generator@1.0.5-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.4-0"></a>
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.3-0...@ali/lowcode-code-generator@1.0.4-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.2-0...@ali/lowcode-code-generator@1.0.3-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.2-0"></a>
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.1-0...@ali/lowcode-code-generator@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.1-0"></a>
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.0...@ali/lowcode-code-generator@1.0.1-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.13.0...@ali/lowcode-code-generator@1.0.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.12.0...@ali/lowcode-code-generator@0.13.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.10.0...@ali/lowcode-code-generator@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.10.0...@ali/lowcode-code-generator@0.11.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.9.0...@ali/lowcode-code-generator@0.10.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-code-generator
<a name="0.9.0"></a>
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.8.10...@ali/lowcode-code-generator@0.9.0) (2020-08-14)
### Bug Fixes
* 🐛 bugs about deps ([1eabd50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1eabd50))
* 🐛 children in props ([fe0ace8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fe0ace8))
* 🐛 get deps info from slot ([6c3ae36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6c3ae36))
* 🐛 group chunks by filetype family ([db144a9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/db144a9))
* 🐛 loop bug ([8f53910](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8f53910))
* 🐛 repair children before deps analyze ([737d06e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/737d06e))
* 🐛 support JSFunction type ([9061e4b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9061e4b))
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
### Features
* 🎸 add node type mapping config for jsx plugin ([19a51b8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/19a51b8))
* 🎸 code generator fix slot support ([e51b9cb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e51b9cb))
<a name="0.8.10"></a> <a name="0.8.10"></a>
## [0.8.10](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.8.9...@ali/lowcode-code-generator@0.8.10) (2020-07-21) ## [0.8.10](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.8.9...@ali/lowcode-code-generator@0.8.10) (2020-07-21)
@ -118,14 +246,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Features ### Features
<<<<<<< HEAD
* code generator main process ([021d6e0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/021d6e0)) * code generator main process ([021d6e0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/021d6e0))
* demo schema & complex children type ([a5ee6bd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5ee6bd)) * demo schema & complex children type ([a5ee6bd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5ee6bd))
* fix gaps ([32af3d3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/32af3d3)) * fix gaps ([32af3d3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/32af3d3))
* project builder fix & publish demo to disk ([26983b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/26983b3)) * project builder fix & publish demo to disk ([26983b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/26983b3))
=======
* code generator main process ([021d6e0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/021d6e0fe9fb29a8b6c1c5d5f4d06ec71896faa5)) * code generator main process ([021d6e0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/021d6e0fe9fb29a8b6c1c5d5f4d06ec71896faa5))
* demo schema & complex children type ([a5ee6bd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5ee6bd55806fc9aea695096ccd4c7f50b8e31c4)) * demo schema & complex children type ([a5ee6bd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5ee6bd55806fc9aea695096ccd4c7f50b8e31c4))
* fix gaps ([32af3d3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/32af3d3a3ca4d5aca15be25e05c840c8ea0cb6ae)) * fix gaps ([32af3d3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/32af3d3a3ca4d5aca15be25e05c840c8ea0cb6ae))
* project builder fix & publish demo to disk ([26983b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/26983b38c2b0f1d39d79964eb54d8ce60250dd82)) * project builder fix & publish demo to disk ([26983b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/26983b38c2b0f1d39d79964eb54d8ce60250dd82))
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc

View File

@ -59,9 +59,7 @@ function main() {
builder.generateProject(schemaJson).then((result) => { builder.generateProject(schemaJson).then((result) => {
displayResultInConsole(result); displayResultInConsole(result);
writeResultToDisk(result, 'output/lowcodeDemo').then((response) => writeResultToDisk(result, 'output/lowcodeDemo').then((response) => console.log('Write to disk: ', JSON.stringify(response)),);
console.log('Write to disk: ', JSON.stringify(response)),
);
return result; return result;
}); });
} }
@ -162,111 +160,12 @@ function exportProject() {
builder.generateProject(schemaJson).then((result) => { builder.generateProject(schemaJson).then((result) => {
displayResultInConsole(result); displayResultInConsole(result);
writeResultToDisk(result, 'output/lowcodeDemo').then((response) => writeResultToDisk(result, 'output/lowcodeDemo').then((response) => console.log('Write to disk: ', JSON.stringify(response)),);
console.log('Write to disk: ', JSON.stringify(response)),
);
return result;
});
}
function exportModule() {
const schemaJson = fs.readFileSync('./demo/shenmaSample.json', { encoding: 'utf8' });
const moduleBuilder = CodeGenerator.createModuleBuilder({
plugins: [
CodeGenerator.plugins.react.reactCommonDeps(),
CodeGenerator.plugins.common.esmodule({
fileType: 'jsx',
}),
CodeGenerator.plugins.react.containerClass(),
CodeGenerator.plugins.react.containerInitState(),
CodeGenerator.plugins.react.containerLifeCycle(),
CodeGenerator.plugins.react.containerMethod(),
CodeGenerator.plugins.react.jsx(),
CodeGenerator.plugins.style.css(),
],
postProcessors: [
CodeGenerator.postprocessor.prettier(),
],
mainFileName: 'index',
});
moduleBuilder.generateModuleCode(schemaJson).then(result => {
displayResultInConsole(result);
return result;
});
}
function exportProject() {
const schemaJson = fs.readFileSync('./demo/sampleSchema.json', { encoding: 'utf8' });
const builder = CodeGenerator.createProjectBuilder({
template: CodeGenerator.solutionParts.icejs.template,
plugins: {
components: [
CodeGenerator.plugins.react.reactCommonDeps(),
CodeGenerator.plugins.common.esmodule({
fileType: 'jsx',
}),
CodeGenerator.plugins.react.containerClass(),
CodeGenerator.plugins.react.containerInitState(),
CodeGenerator.plugins.react.containerLifeCycle(),
CodeGenerator.plugins.react.containerMethod(),
CodeGenerator.plugins.react.jsx(),
CodeGenerator.plugins.style.css(),
],
pages: [
CodeGenerator.plugins.react.reactCommonDeps(),
CodeGenerator.plugins.common.esmodule({
fileType: 'jsx',
}),
CodeGenerator.plugins.react.containerClass(),
CodeGenerator.plugins.react.containerInitState(),
CodeGenerator.plugins.react.containerLifeCycle(),
CodeGenerator.plugins.react.containerMethod(),
CodeGenerator.plugins.react.jsx(),
CodeGenerator.plugins.style.css(),
],
router: [
CodeGenerator.plugins.common.esmodule(),
CodeGenerator.solutionParts.icejs.plugins.router(),
],
entry: [
CodeGenerator.solutionParts.icejs.plugins.entry(),
],
constants: [
CodeGenerator.plugins.project.constants(),
],
utils: [
CodeGenerator.plugins.common.esmodule(),
CodeGenerator.plugins.project.utils(),
],
i18n: [
CodeGenerator.plugins.project.i18n(),
],
globalStyle: [
CodeGenerator.solutionParts.icejs.plugins.globalStyle(),
],
htmlEntry: [
CodeGenerator.solutionParts.icejs.plugins.entryHtml(),
],
packageJSON: [
CodeGenerator.solutionParts.icejs.plugins.packageJSON(),
],
},
postProcessors: [
CodeGenerator.postprocessor.prettier(),
],
});
builder.generateProject(schemaJson).then(result => {
displayResultInConsole(result);
writeResultToDisk(result, 'output/lowcodeDemo').then(response =>
console.log('Write to disk: ', JSON.stringify(response)),
);
return result; return result;
}); });
} }
// main(); // main();
// exportModule(); // exportModule();
exportProject(); // exportProject();
demo();

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-code-generator", "name": "@ali/lowcode-code-generator",
"version": "0.8.10", "version": "1.0.8-0",
"description": "出码引擎 for LowCode Engine", "description": "出码引擎 for LowCode Engine",
"main": "lib/index.js", "main": "lib/index.js",
"files": [ "files": [

View File

@ -0,0 +1,3 @@
import { FileType } from '../types/core';
export const FILE_TYPE_FAMILY = [[FileType.TSX, FileType.TS, FileType.JSX, FileType.JS]];

View File

@ -1,28 +1,72 @@
import { import { BuilderComponentPlugin, IChunkBuilder, ICodeChunk, ICodeStruct, FileType } from '../types';
BuilderComponentPlugin,
IChunkBuilder,
ICodeChunk,
ICodeStruct,
} from '../types';
import { COMMON_SUB_MODULE_NAME } from '../const/generator'; import { COMMON_SUB_MODULE_NAME } from '../const/generator';
import { FILE_TYPE_FAMILY } from '../const/file';
type ChunkGroupInfo = {
chunk: ICodeChunk;
familyIdx?: number;
};
function whichFamily(type: FileType): [number, FileType[]] | undefined {
const idx = FILE_TYPE_FAMILY.findIndex((family) => family.indexOf(type) >= 0);
if (idx < 0) {
return undefined;
}
return [idx, FILE_TYPE_FAMILY[idx]];
}
export const groupChunks = (chunks: ICodeChunk[]): ICodeChunk[][] => { export const groupChunks = (chunks: ICodeChunk[]): ICodeChunk[][] => {
const col = chunks.reduce( const tmp: Record<string, Record<number, number>> = {};
(chunksSet: Record<string, ICodeChunk[]>, chunk) => { const col = chunks.reduce((chunksSet: Record<string, ChunkGroupInfo[]>, chunk) => {
const fileKey = `${chunk.subModule || COMMON_SUB_MODULE_NAME}.${ const fileKey = chunk.subModule || COMMON_SUB_MODULE_NAME;
chunk.fileType if (!chunksSet[fileKey]) {
}`; chunksSet[fileKey] = [];
if (!chunksSet[fileKey]) { }
chunksSet[fileKey] = []; const res = whichFamily(chunk.fileType as FileType);
const info: ChunkGroupInfo = {
chunk,
};
if (res) {
const [familyIdx, family] = res;
const rank = family.indexOf(chunk.fileType as FileType);
if (tmp[fileKey]) {
if (tmp[fileKey][familyIdx] !== undefined) {
if (tmp[fileKey][familyIdx] > rank) {
tmp[fileKey][familyIdx] = rank;
}
} else {
tmp[fileKey][familyIdx] = rank;
}
} else {
tmp[fileKey] = {};
tmp[fileKey][familyIdx] = rank;
} }
chunksSet[fileKey].push(chunk); info.familyIdx = familyIdx;
return chunksSet; }
},
{},
);
return Object.keys(col).map(key => col[key]); chunksSet[fileKey].push(info);
return chunksSet;
}, {});
const result: ICodeChunk[][] = [];
Object.keys(col).forEach((key) => {
const byType: Record<string, ICodeChunk[]> = {};
col[key].forEach((info) => {
let t: string = info.chunk.fileType;
if (info.familyIdx !== undefined) {
t = FILE_TYPE_FAMILY[info.familyIdx][tmp[key][info.familyIdx]];
info.chunk.fileType = t;
}
if (!byType[t]) {
byType[t] = [];
}
byType[t].push(info.chunk);
});
result.push(...Object.keys(byType).map((t) => byType[t]));
});
return result;
}; };
/** /**
@ -39,7 +83,7 @@ export default class ChunkBuilder implements IChunkBuilder {
this.plugins = plugins; this.plugins = plugins;
} }
public async run( async run(
ir: unknown, ir: unknown,
initialStructure: ICodeStruct = { initialStructure: ICodeStruct = {
ir, ir,
@ -64,11 +108,11 @@ export default class ChunkBuilder implements IChunkBuilder {
}; };
} }
public getPlugins() { getPlugins() {
return this.plugins; return this.plugins;
} }
public addPlugin(plugin: BuilderComponentPlugin) { addPlugin(plugin: BuilderComponentPlugin) {
this.plugins.push(plugin); this.plugins.push(plugin);
} }
} }

View File

@ -37,29 +37,23 @@ export function createModuleBuilder(
const generateModule = async (input: unknown): Promise<ICompiledModule> => { const generateModule = async (input: unknown): Promise<ICompiledModule> => {
const moduleMainName = options.mainFileName || COMMON_SUB_MODULE_NAME; const moduleMainName = options.mainFileName || COMMON_SUB_MODULE_NAME;
if (chunkGenerator.getPlugins().length <= 0) { if (chunkGenerator.getPlugins().length <= 0) {
throw new CodeGeneratorError( throw new CodeGeneratorError('No plugins found. Component generation cannot work without any plugins!');
'No plugins found. Component generation cannot work without any plugins!',
);
} }
let files: IResultFile[] = []; let files: IResultFile[] = [];
const { chunks } = await chunkGenerator.run(input); const { chunks } = await chunkGenerator.run(input);
chunks.forEach(fileChunkList => { chunks.forEach((fileChunkList) => {
const content = linker.link(fileChunkList); const content = linker.link(fileChunkList);
const file = new ResultFile( const file = new ResultFile(fileChunkList[0].subModule || moduleMainName, fileChunkList[0].fileType, content);
fileChunkList[0].subModule || moduleMainName,
fileChunkList[0].fileType,
content,
);
files.push(file); files.push(file);
}); });
if (options.postProcessors.length > 0) { if (options.postProcessors.length > 0) {
files = files.map(file => { files = files.map((file) => {
let content = file.content; let content = file.content;
const type = file.ext; const type = file.ext;
options.postProcessors.forEach(processer => { options.postProcessors.forEach((processer) => {
content = processer(content, type); content = processer(content, type);
}); });
@ -81,25 +75,18 @@ export function createModuleBuilder(
const { files } = await generateModule(containerInfo); const { files } = await generateModule(containerInfo);
const dir = new ResultDir(containerInfo.moduleName); const dir = new ResultDir(containerInfo.moduleName);
files.forEach(file => dir.addFile(file)); files.forEach((file) => dir.addFile(file));
return dir; return dir;
} };
const linkCodeChunks = ( const linkCodeChunks = (chunks: Record<string, ICodeChunk[]>, fileName: string) => {
chunks: Record<string, ICodeChunk[]>,
fileName: string,
) => {
const files: IResultFile[] = []; const files: IResultFile[] = [];
Object.keys(chunks).forEach(fileKey => { Object.keys(chunks).forEach((fileKey) => {
const fileChunkList = chunks[fileKey]; const fileChunkList = chunks[fileKey];
const content = linker.link(fileChunkList); const content = linker.link(fileChunkList);
const file = new ResultFile( const file = new ResultFile(fileChunkList[0].subModule || fileName, fileChunkList[0].fileType, content);
fileChunkList[0].subModule || fileName,
fileChunkList[0].fileType,
content,
);
files.push(file); files.push(file);
}); });

View File

@ -124,17 +124,6 @@ class SchemaParser implements ISchemaParser {
internalDeps[dep.moduleName] = dep; internalDeps[dep.moduleName] = dep;
}); });
// 分析容器内部组件依赖
containers.forEach((container) => {
if (container.children) {
const depNames = this.getComponentNames(container.children);
container.deps = uniqueArray<string>(depNames, (i: string) => i)
.map((depName) => internalDeps[depName] || compDeps[depName])
.filter((dep) => !!dep);
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
}
});
// TODO: 不应该在出码部分解决? // TODO: 不应该在出码部分解决?
// 处理 children 写在了 props 里的情况 // 处理 children 写在了 props 里的情况
containers.forEach((container) => { containers.forEach((container) => {
@ -156,6 +145,17 @@ class SchemaParser implements ISchemaParser {
} }
}); });
// 分析容器内部组件依赖
containers.forEach((container) => {
if (container.children) {
const depNames = this.getComponentNames(container.children);
container.deps = uniqueArray<string>(depNames, (i: string) => i)
.map((depName) => internalDeps[depName] || compDeps[depName])
.filter((dep) => !!dep);
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
}
});
// 分析路由配置 // 分析路由配置
const routes = containers const routes = containers
.filter((container) => container.containerType === 'Page') .filter((container) => container.containerType === 'Page')

View File

@ -13,7 +13,7 @@ import {
type PluginConfig = { type PluginConfig = {
fileType: string; fileType: string;
} };
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => { const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
const cfg: PluginConfig = { const cfg: PluginConfig = {
@ -30,9 +30,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
if (ir.state) { if (ir.state) {
const state = ir.state; const state = ir.state;
const fields = Object.keys(state).map<string>(stateName => { const fields = Object.keys(state).map<string>((stateName) => {
const [isString, value] = generateCompositeType(state[stateName]); const value = generateCompositeType(state[stateName]);
return `${stateName}: ${isString ? `'${value}'` : value},`; return `${stateName}: ${value},`;
}); });
next.chunks.push({ next.chunks.push({

View File

@ -14,7 +14,7 @@ import {
type PluginConfig = { type PluginConfig = {
fileType: string; fileType: string;
implementType: 'inConstructor' | 'insMember' | 'hooks'; implementType: 'inConstructor' | 'insMember' | 'hooks';
} };
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => { const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
const cfg: PluginConfig = { const cfg: PluginConfig = {
@ -32,9 +32,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
if (ir.state) { if (ir.state) {
const state = ir.state; const state = ir.state;
const fields = Object.keys(state).map<string>(stateName => { const fields = Object.keys(state).map<string>((stateName) => {
const [isString, value] = generateCompositeType(state[stateName]); const value = generateCompositeType(state[stateName]);
return `${stateName}: ${isString ? `'${value}'` : value},`; return `${stateName}: ${value},`;
}); });
if (cfg.implementType === 'inConstructor') { if (cfg.implementType === 'inConstructor') {

View File

@ -11,7 +11,7 @@ import {
CompositeValue, CompositeValue,
} from '../../../types'; } from '../../../types';
import { generateCompositeType, handleStringValueDefault } from '../../../utils/compositeType'; import { generateCompositeType } from '../../../utils/compositeType';
import { generateExpression } from '../../../utils/jsExpression'; import { generateExpression } from '../../../utils/jsExpression';
function packJsExpression(exp: unknown): string { function packJsExpression(exp: unknown): string {
@ -35,19 +35,17 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
const extConfigs = Object.keys(rest).map((extConfigName) => { const extConfigs = Object.keys(rest).map((extConfigName) => {
const value = (rest as Record<string, CompositeValue>)[extConfigName]; const value = (rest as Record<string, CompositeValue>)[extConfigName];
const [isString, valueStr] = generateCompositeType(value); const valueStr = generateCompositeType(value);
return `${extConfigName}: ${isString ? `'${valueStr}'` : valueStr}`; return `${extConfigName}: ${valueStr}`;
}); });
attrs = [...attrs, ...extConfigs]; attrs = [...attrs, ...extConfigs];
const listProp = handleStringValueDefault( const listProp = generateCompositeType((list as unknown) as CompositeValue, {
generateCompositeType((list as unknown) as CompositeValue, { handlers: {
handlers: { expression: packJsExpression,
expression: packJsExpression, },
}, });
}),
);
attrs.push(`list: ${listProp}`); attrs.push(`list: ${listProp}`);

View File

@ -13,7 +13,7 @@ import { COMMON_CHUNK_NAME } from '../../../const/generator';
import { createNodeGenerator, generateString } from '../../../utils/nodeToJSX'; import { createNodeGenerator, generateString } from '../../../utils/nodeToJSX';
import { generateExpression } from '../../../utils/jsExpression'; import { generateExpression } from '../../../utils/jsExpression';
import { generateCompositeType, handleStringValueDefault } from '../../../utils/compositeType'; import { generateCompositeType } from '../../../utils/compositeType';
const generateGlobalProps = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] => { const generateGlobalProps = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] => {
return [ return [
@ -28,7 +28,7 @@ const generateCtrlLine = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeIt
const pieces: CodePiece[] = []; const pieces: CodePiece[] = [];
if (nodeItem.loop && nodeItem.loopArgs) { if (nodeItem.loop && nodeItem.loopArgs) {
const loopDataExp = handleStringValueDefault(generateCompositeType(nodeItem.loop)); const loopDataExp = generateCompositeType(nodeItem.loop);
pieces.push({ pieces.push({
type: PIECE_TYPE.ATTR, type: PIECE_TYPE.ATTR,
value: `x-for={${loopDataExp}}`, value: `x-for={${loopDataExp}}`,
@ -41,7 +41,7 @@ const generateCtrlLine = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeIt
} }
if (nodeItem.condition) { if (nodeItem.condition) {
const conditionExp = handleStringValueDefault(generateCompositeType(nodeItem.condition)); const conditionExp = generateCompositeType(nodeItem.condition);
pieces.push({ pieces.push({
type: PIECE_TYPE.ATTR, type: PIECE_TYPE.ATTR,
value: `x-if={${conditionExp}}`, value: `x-if={${conditionExp}}`,

View File

@ -17,7 +17,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
const ir = next.ir as IProjectInfo; const ir = next.ir as IProjectInfo;
if (ir.constants) { if (ir.constants) {
const [, constantStr] = generateCompositeType(ir.constants); const constantStr = generateCompositeType(ir.constants);
next.chunks.push({ next.chunks.push({
type: ChunkType.STRING, type: ChunkType.STRING,

View File

@ -17,7 +17,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
const ir = next.ir as IProjectInfo; const ir = next.ir as IProjectInfo;
if (ir.i18n) { if (ir.i18n) {
const [, i18nStr] = generateCompositeType(ir.i18n); const i18nStr = generateCompositeType(ir.i18n);
next.chunks.push({ next.chunks.push({
type: ChunkType.STRING, type: ChunkType.STRING,

View File

@ -179,6 +179,7 @@ export interface INodeGeneratorContext {
// } // }
export type CompositeValueCustomHandler = (data: unknown) => string; export type CompositeValueCustomHandler = (data: unknown) => string;
export type CompositeTypeContainerHandler = (value: string) => string;
export interface CompositeValueCustomHandlerSet { export interface CompositeValueCustomHandlerSet {
boolean?: CompositeValueCustomHandler; boolean?: CompositeValueCustomHandler;
number?: CompositeValueCustomHandler; number?: CompositeValueCustomHandler;
@ -188,7 +189,13 @@ export interface CompositeValueCustomHandlerSet {
expression?: CompositeValueCustomHandler; expression?: CompositeValueCustomHandler;
} }
export interface CompositeTypeContainerHandlerSet {
default?: CompositeTypeContainerHandler;
string?: CompositeValueCustomHandler;
}
export interface CompositeValueGeneratorOptions { export interface CompositeValueGeneratorOptions {
handlers?: CompositeValueCustomHandlerSet; handlers?: CompositeValueCustomHandlerSet;
containerHandlers?: CompositeTypeContainerHandlerSet;
nodeGenerator?: NodeGenerator; nodeGenerator?: NodeGenerator;
} }

View File

@ -3,10 +3,18 @@ import {
CompositeValue, CompositeValue,
ICompositeObject, ICompositeObject,
CompositeValueGeneratorOptions, CompositeValueGeneratorOptions,
CompositeTypeContainerHandlerSet,
CodeGeneratorError, CodeGeneratorError,
} from '../types'; } from '../types';
import { generateExpression, generateFunction, isJsExpression, isJsFunction } from './jsExpression'; import { generateExpression, generateFunction, isJsExpression, isJsFunction } from './jsExpression';
import { isJsSlot, generateJsSlot } from './jsSlot'; import { isJsSlot, generateJsSlot } from './jsSlot';
import { isValidIdentifier } from './validate';
import { camelize } from './common';
const defaultContainerHandlers: CompositeTypeContainerHandlerSet = {
default: (v) => v,
string: (v) => `'${v}'`,
};
function generateArray(value: CompositeArray, options: CompositeValueGeneratorOptions = {}): string { function generateArray(value: CompositeArray, options: CompositeValueGeneratorOptions = {}): string {
const body = value.map((v) => generateUnknownType(v, options)).join(','); const body = value.map((v) => generateUnknownType(v, options)).join(',');
@ -34,8 +42,25 @@ function generateObject(value: ICompositeObject, options: CompositeValueGenerato
const body = Object.keys(value) const body = Object.keys(value)
.map((key) => { .map((key) => {
let propName = key;
// TODO: 可以增加更多智能修复的方法
const fixMethods: Array<(v: string) => string> = [camelize];
// Try to fix propName
while (!isValidIdentifier(propName)) {
const fixMethod = fixMethods.pop();
if (fixMethod) {
try {
propName = fixMethod(propName);
} catch (error) {
throw new CodeGeneratorError(error.message);
}
} else {
throw new CodeGeneratorError(`Propname: ${key} is not a valid identifier.`);
}
}
const v = generateUnknownType(value[key], options); const v = generateUnknownType(value[key], options);
return `${key}: ${v}`; return `${propName}: ${v}`;
}) })
.join(',\n'); .join(',\n');
@ -66,22 +91,16 @@ export function generateUnknownType(value: CompositeValue, options: CompositeVal
return `${value}`; return `${value}`;
} }
export function generateCompositeType( export function generateCompositeType(value: CompositeValue, options: CompositeValueGeneratorOptions = {}): string {
value: CompositeValue,
options: CompositeValueGeneratorOptions = {},
): [boolean, string] {
const result = generateUnknownType(value, options); const result = generateUnknownType(value, options);
const containerHandlers = {
...defaultContainerHandlers,
...(options.containerHandlers || {}),
};
if (result.substr(0, 1) === "'" && result.substr(-1, 1) === "'") { const isStringType = result.substr(0, 1) === "'" && result.substr(-1, 1) === "'";
return [true, result.substring(1, result.length - 1)]; if (isStringType) {
return (containerHandlers.string && containerHandlers.string(result.substring(1, result.length - 1))) || '';
} }
return (containerHandlers.default && containerHandlers.default(result)) || '';
return [false, result];
}
export function handleStringValueDefault([isString, result]: [boolean, string]) {
if (isString) {
return `'${result}'`;
}
return result;
} }

View File

@ -104,12 +104,16 @@ export function generateAttr(ctx: INodeGeneratorContext, attrName: string, attrV
if (attrName === 'initValue') { if (attrName === 'initValue') {
return []; return [];
} }
const [isString, valueStr] = generateCompositeType(attrValue, { const valueStr = generateCompositeType(attrValue, {
containerHandlers: {
default: (v) => `{${v}}`,
string: (v) => `"${v}"`,
},
nodeGenerator: ctx.generator, nodeGenerator: ctx.generator,
}); });
return [ return [
{ {
value: `${attrName}=${isString ? `"${valueStr}"` : `{${valueStr}}`}`, value: `${attrName}=${valueStr}`,
type: PIECE_TYPE.ATTR, type: PIECE_TYPE.ATTR,
}, },
]; ];
@ -162,15 +166,13 @@ export function generateBasicNode(
export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] { export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] {
const pieces: CodePiece[] = []; const pieces: CodePiece[] = [];
if (nodeItem.loop && nodeItem.loopArgs) { if (nodeItem.loop) {
let loopDataExp; const args: [string, string] = nodeItem.loopArgs || ['item', 'index'];
if (isJsExpression(nodeItem.loop)) { const loopData = generateCompositeType(nodeItem.loop, {
loopDataExp = `(${generateExpression(nodeItem.loop)})`; nodeGenerator: ctx.generator,
} else { });
loopDataExp = JSON.stringify(nodeItem.loop);
}
pieces.unshift({ pieces.unshift({
value: `${loopDataExp}.map((${nodeItem.loopArgs[0]}, ${nodeItem.loopArgs[1]}) => (`, value: `(${loopData}).map((${args[0]}, ${args[1]}) => (`,
type: PIECE_TYPE.BEFORE, type: PIECE_TYPE.BEFORE,
}); });
pieces.push({ pieces.push({
@ -180,12 +182,12 @@ export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: ICom
} }
if (nodeItem.condition) { if (nodeItem.condition) {
const [isString, value] = generateCompositeType(nodeItem.condition, { const value = generateCompositeType(nodeItem.condition, {
nodeGenerator: ctx.generator, nodeGenerator: ctx.generator,
}); });
pieces.unshift({ pieces.unshift({
value: `(${isString ? `'${value}'` : value}) && (`, value: `(${value}) && (`,
type: PIECE_TYPE.BEFORE, type: PIECE_TYPE.BEFORE,
}); });
pieces.push({ pieces.push({
@ -194,7 +196,7 @@ export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: ICom
}); });
} }
if (nodeItem.condition || (nodeItem.loop && nodeItem.loopArgs)) { if (nodeItem.condition || nodeItem.loop) {
pieces.unshift({ pieces.unshift({
value: '{', value: '{',
type: PIECE_TYPE.BEFORE, type: PIECE_TYPE.BEFORE,

View File

@ -0,0 +1,24 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -0,0 +1,124 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.0.8-0"></a>
## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.7-0...@ali/lowcode-demo-server@1.0.8-0) (2020-09-09)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.6-0...@ali/lowcode-demo-server@1.0.7-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.5-0...@ali/lowcode-demo-server@1.0.6-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.4-0...@ali/lowcode-demo-server@1.0.5-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.4-0"></a>
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.3-0...@ali/lowcode-demo-server@1.0.4-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.2-0...@ali/lowcode-demo-server@1.0.3-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.2-0"></a>
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.1-0...@ali/lowcode-demo-server@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.1-0"></a>
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.0...@ali/lowcode-demo-server@1.0.1-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.14.0...@ali/lowcode-demo-server@1.0.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="0.14.0"></a>
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.13.0...@ali/lowcode-demo-server@0.14.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.11.0...@ali/lowcode-demo-server@0.13.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.11.0...@ali/lowcode-demo-server@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.10.0...@ali/lowcode-demo-server@0.11.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.9.0...@ali/lowcode-demo-server@0.10.0) (2020-08-14)
**Note:** Version bump only for package @ali/lowcode-demo-server
<a name="0.9.0"></a>
# 0.9.0 (2020-08-14)
### Features
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))

View File

@ -0,0 +1,75 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Installation
```bash
$ npm install
```
## Running the app
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
```
## Test
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
```
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

View File

@ -0,0 +1,4 @@
{
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}

View File

@ -0,0 +1,66 @@
{
"name": "@ali/lowcode-demo-server",
"version": "1.0.8-0",
"private": true,
"description": "低代码引擎 DEMO Server 端",
"scripts": {
"prebuild": "rimraf dist",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"start": "nest start",
"start:debug": "nest start --debug --watch",
"start:dev": "nest start --watch",
"start:prod": "node dist/main",
"test": "jest",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"test:watch": "jest --watch"
},
"jest": {
"coverageDirectory": "../coverage",
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testEnvironment": "node",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
},
"dependencies": {
"@ali/lowcode-code-generator": "0.8.8",
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/platform-express": "^7.0.0",
"jszip": "^3.5.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.5.4"
},
"devDependencies": {
"@nestjs/cli": "^7.0.0",
"@nestjs/schematics": "^7.0.0",
"@nestjs/testing": "^7.0.0",
"@types/express": "^4.17.3",
"@types/jest": "25.2.3",
"@types/node": "^13.9.1",
"@types/supertest": "^2.0.8",
"@typescript-eslint/eslint-plugin": "3.0.2",
"@typescript-eslint/parser": "3.0.2",
"eslint": "7.1.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"jest": "26.0.1",
"prettier": "^1.19.1",
"supertest": "^4.0.2",
"ts-jest": "26.1.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.6.2",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.4"
}
}

View File

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ApiController } from './api.controller';
describe('Api Controller', () => {
let controller: ApiController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ApiController],
}).compile();
controller = module.get<ApiController>(ApiController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@ -0,0 +1,21 @@
import { Controller, Res, Get, Post, Body, Header } from '@nestjs/common';
import { Response } from 'express';
import { ApiService } from './api.service';
import { GenerateProjectDto } from '../dto/generate-project.dto';
@Controller('api')
export class ApiController {
constructor(private readonly apiService: ApiService) {}
@Get('generate/test')
generateTest() {
return 'generate test';
}
@Post('generate/project')
@Header('Content-Type', 'application/zip')
async generateProject(@Res() res: Response, @Body() dto: GenerateProjectDto) {
const file = await this.apiService.generateProject(dto.schema);
file.pipe(res);
}
}

View File

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ApiService } from './api.service';
describe('ApiService', () => {
let service: ApiService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ApiService],
}).compile();
service = module.get<ApiService>(ApiService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@ -0,0 +1,30 @@
import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
import { Injectable } from '@nestjs/common';
import CodeGenerator from '@ali/lowcode-code-generator';
import { createZipPublisher } from '../publisher';
@Injectable()
export class ApiService {
async generateProject(schema: string) {
const tmpDir = os.tmpdir();
const createIceJsProjectBuilder = CodeGenerator.solutions.icejs;
const builder = createIceJsProjectBuilder();
const publisher = createZipPublisher({
outputPath: tmpDir,
projectSlug: 'demo-project',
});
const filePath = path.join(tmpDir, 'demo-project.zip');
const result = await builder.generateProject(schema);
publisher.setProject(result);
const response = await publisher.publish();
if (!response.success) {
throw new Error('generateProject failed');
}
return fs.createReadStream(filePath);
// return filePath;
}
}

View File

@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});

View File

@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}

View File

@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ApiController } from './api/api.controller';
import { ApiService } from './api/api.service';
@Module({
imports: [],
controllers: [AppController, ApiController],
providers: [AppService, ApiService],
})
export class AppModule {}

View File

@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@ -0,0 +1,7 @@
import { GenerateProjectDto } from './generate-project.dto';
describe('GenerateProjectDto', () => {
it('should be defined', () => {
expect(new GenerateProjectDto()).toBeDefined();
});
});

View File

@ -0,0 +1,3 @@
export class GenerateProjectDto {
schema: string;
}

View File

@ -0,0 +1,9 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
await app.listen(7002);
}
bootstrap();

View File

@ -0,0 +1,76 @@
import { IResultDir } from '@ali/lowcode-code-generator';
import { isNodeProcess, writeZipToDisk, generateProjectZip } from './utils'
export type PublisherFactory<T, U> = (configuration?: Partial<T>) => U;
export interface IPublisher<T, U> {
publish: (options?: T) => Promise<IPublisherResponse<U>>;
getProject: () => IResultDir | void;
setProject: (project: IResultDir) => void;
}
export interface IPublisherFactoryParams {
project?: IResultDir;
}
export interface IPublisherResponse<T> {
success: boolean;
payload?: T;
}
declare type ZipPublisherResponse = string | Buffer | Blob
export interface ZipFactoryParams extends IPublisherFactoryParams {
outputPath?: string
projectSlug?: string
}
export interface ZipPublisher extends IPublisher<ZipFactoryParams, ZipPublisherResponse> {
getOutputPath: () => string
setOutputPath: (path: string) => void
}
export const createZipPublisher: PublisherFactory<ZipFactoryParams, ZipPublisher> = (
params: ZipFactoryParams = {}
): ZipPublisher => {
let { project, outputPath } = params
const getProject = () => project
const setProject = (projectToSet: IResultDir) => {
project = projectToSet
}
const getOutputPath = () => outputPath
const setOutputPath = (path: string) => {
outputPath = path
}
const publish = async (options: ZipFactoryParams = {}) => {
const projectToPublish = options.project || project
if (!projectToPublish) {
throw new Error('MissingProject');
}
const zipName = options.projectSlug || params.projectSlug || projectToPublish.name
try {
const zipContent = await generateProjectZip(projectToPublish)
// If not output path is provided, zip is not written to disk
const projectOutputPath = options.outputPath || outputPath
if (projectOutputPath && isNodeProcess()) {
await writeZipToDisk(projectOutputPath, zipContent, zipName)
}
return { success: true, payload: zipContent }
} catch (error) {
throw new Error('ZipUnexpected');
}
}
return {
publish,
getProject,
setProject,
getOutputPath,
setOutputPath,
}
}

View File

@ -0,0 +1,57 @@
import * as JSZip from 'jszip';
import { IResultFile, IResultDir } from '@ali/lowcode-code-generator';
export const isNodeProcess = (): boolean => {
return (
typeof process === 'object' &&
typeof process.versions === 'object' &&
typeof process.versions.node !== 'undefined'
)
}
export const writeZipToDisk = (
zipFolderPath: string,
content: Buffer | Blob,
zipName: string
): void => {
const fs = require('fs')
const path = require('path')
if (!fs.existsSync(zipFolderPath)) {
fs.mkdirSync(zipFolderPath, { recursive: true })
}
const zipPath = path.join(zipFolderPath, `${zipName}.zip`)
const writeStream = fs.createWriteStream(zipPath)
writeStream.write(content)
writeStream.end()
}
export const generateProjectZip = async (project: IResultDir): Promise<Buffer | Blob> => {
let zip = new JSZip()
zip = writeFolderToZip(project, zip, true)
const zipType = isNodeProcess() ? 'nodebuffer' : 'blob'
return zip.generateAsync({ type: zipType })
}
const writeFolderToZip = (
folder: IResultDir,
parentFolder: JSZip,
ignoreFolder: boolean = false
) => {
const zipFolder = ignoreFolder ? parentFolder : parentFolder.folder(folder.name)
folder.files.forEach((file: IResultFile) => {
// const options = file.contentEncoding === 'base64' ? { base64: true } : {}
const options = {};
const fileName = file.ext ? `${file.name}.${file.ext}` : file.name
zipFolder.file(fileName, file.content, options)
})
folder.dirs.forEach((subFolder: IResultDir) => {
writeFolderToZip(subFolder, zipFolder)
})
return parentFolder
}

View File

@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
}
}

View File

@ -3,46 +3,289 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="0.8.52"></a> <a name="1.0.8-0"></a>
## [0.8.52](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.51...@ali/lowcode-demo@0.8.52) (2020-08-14) ## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.65...@ali/lowcode-demo@1.0.8-0) (2020-09-09)
### Bug Fixes
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
* 🐛 after event name & TabItem parent limitation ([76fb0b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/76fb0b3))
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
* 🐛 fix Menu & MenuButton assets cfg ([3d40aa2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3d40aa2))
* 🐛 Menu Items ([5ecacef](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5ecacef))
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
* 🐛 Timeline asset config ([436dadd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/436dadd))
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f))
* 修改插件面板配置 ([f9ceda5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9ceda5))
* 修改js面板的保存schema问题 ([0ee8892](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0ee8892))
* demo 中引入locode-editor-general ([1f03857](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f03857))
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
* fix mixsetter style ([0ecce83](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0ecce83))
* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375))
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
### Features
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
* 🎸 Collapse component update ([c682cc5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c682cc5))
* 🎸 Collapse.panel has drop in Collapse ([d4d41e4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d4d41e4))
* 🎸 pagination update ([f13b3ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f13b3ab))
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
* 🎸 update upload component ([10abef5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/10abef5))
* 🎸 upload update ([f81932b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f81932b))
* 适配TreeNode节点 ([8c36928](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8c36928))
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
* 新增simulatorurl可以设置cdn使用simulator ([1f45b05](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f45b05))
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f))
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.6-0...@ali/lowcode-demo@1.0.7-0) (2020-09-02)
<a name="0.8.65"></a>
## [0.8.65](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.64...@ali/lowcode-demo@0.8.65) (2020-09-08)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="0.8.64"></a>
## [0.8.64](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.63...@ali/lowcode-demo@0.8.64) (2020-09-03)
**Note:** Version bump only for package @ali/lowcode-demo **Note:** Version bump only for package @ali/lowcode-demo
<a name="0.8.51"></a> <a name="0.8.63"></a>
## [0.8.51](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.50...@ali/lowcode-demo@0.8.51) (2020-08-07) ## [0.8.63](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.62...@ali/lowcode-demo@0.8.63) (2020-09-03)
**Note:** Version bump only for package @ali/lowcode-demo **Note:** Version bump only for package @ali/lowcode-demo
<a name="0.8.50"></a> <a name="0.8.62"></a>
## [0.8.50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.49...@ali/lowcode-demo@0.8.50) (2020-08-06) ## [0.8.62](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.61...@ali/lowcode-demo@0.8.62) (2020-08-27)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.62...@ali/lowcode-demo@1.0.6-0) (2020-09-02)
### Bug Fixes
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
* 🐛 after event name & TabItem parent limitation ([76fb0b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/76fb0b3))
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
* 🐛 fix Menu & MenuButton assets cfg ([3d40aa2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3d40aa2))
* 🐛 Menu Items ([5ecacef](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5ecacef))
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
* 🐛 Timeline asset config ([436dadd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/436dadd))
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f))
* 修改插件面板配置 ([f9ceda5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9ceda5))
* 修改js面板的保存schema问题 ([0ee8892](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0ee8892))
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
* fix mixsetter style ([0ecce83](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0ecce83))
* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375))
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
### Features
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
* 🎸 Collapse component update ([c682cc5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c682cc5))
* 🎸 Collapse.panel has drop in Collapse ([d4d41e4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d4d41e4))
* 🎸 pagination update ([f13b3ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f13b3ab))
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
* 🎸 update upload component ([10abef5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/10abef5))
* 🎸 upload update ([f81932b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f81932b))
* 适配TreeNode节点 ([8c36928](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8c36928))
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
* 新增simulatorurl可以设置cdn使用simulator ([1f45b05](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f45b05))
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f))
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.2-0...@ali/lowcode-demo@1.0.3-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo **Note:** Version bump only for package @ali/lowcode-demo
<a name="0.8.49"></a> <a name="1.0.2-0"></a>
## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.48...@ali/lowcode-demo@0.8.49) (2020-08-06) ## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.1-0...@ali/lowcode-demo@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-demo **Note:** Version bump only for package @ali/lowcode-demo
<a name="0.8.48"></a> <a name="1.0.1-0"></a>
## [0.8.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.47...@ali/lowcode-demo@0.8.48) (2020-08-06) ## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.57...@ali/lowcode-demo@1.0.1-0) (2020-08-20)
### Bug Fixes
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
### Features
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
* 🎸 Collapse component update ([c682cc5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c682cc5))
* 🎸 Collapse.panel has drop in Collapse ([d4d41e4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d4d41e4))
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.15.0...@ali/lowcode-demo@1.0.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo **Note:** Version bump only for package @ali/lowcode-demo
<a name="0.15.0"></a>
# [0.15.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.14.0...@ali/lowcode-demo@0.15.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="0.14.0"></a>
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.12.0...@ali/lowcode-demo@0.14.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.12.0...@ali/lowcode-demo@0.13.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.11.0...@ali/lowcode-demo@0.12.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.10.0...@ali/lowcode-demo@0.11.0) (2020-08-14)
### Bug Fixes
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.9.0...@ali/lowcode-demo@0.10.0) (2020-08-14)
**Note:** Version bump only for package @ali/lowcode-demo
<a name="0.9.0"></a>
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.47...@ali/lowcode-demo@0.9.0) (2020-08-14)
### Bug Fixes
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
### Features
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
<a name="0.8.47"></a> <a name="0.8.47"></a>
## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.46...@ali/lowcode-demo@0.8.47) (2020-08-04) ## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.46...@ali/lowcode-demo@0.8.47) (2020-08-04)
@ -440,10 +683,5 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Features ### Features
<<<<<<< HEAD
* complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ff)) * complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ff))
* double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7)) * double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7))
=======
* complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ffa5c39c2d01abd9cfa90fea49a4539da1d))
* double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7c0c488ef24f825760750a13d3fa083c96))
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-demo", "name": "@ali/lowcode-demo",
"version": "0.8.52", "version": "1.0.8-0",
"private": true, "private": true,
"description": "低代码引擎 DEMO", "description": "低代码引擎 DEMO",
"scripts": { "scripts": {
@ -9,21 +9,21 @@
}, },
"config": {}, "config": {},
"dependencies": { "dependencies": {
"@ali/lowcode-editor-core": "^0.8.28", "@ali/lowcode-editor-core": "^1.0.8-0",
"@ali/lowcode-editor-skeleton": "^0.8.48", "@ali/lowcode-editor-skeleton": "^1.0.8-0",
"@ali/lowcode-plugin-components-pane": "^0.8.44", "@ali/lowcode-plugin-components-pane": "^1.0.8-0",
"@ali/lowcode-plugin-designer": "^0.9.42", "@ali/lowcode-plugin-designer": "^1.0.8-0",
"@ali/lowcode-plugin-event-bind-dialog": "^0.8.27", "@ali/lowcode-plugin-event-bind-dialog": "^1.0.8-0",
"@ali/lowcode-plugin-outline-pane": "^0.8.48", "@ali/lowcode-plugin-outline-pane": "^1.0.8-0",
"@ali/lowcode-plugin-sample-logo": "^0.8.26", "@ali/lowcode-plugin-sample-logo": "^1.0.8-0",
"@ali/lowcode-plugin-sample-preview": "^0.8.46", "@ali/lowcode-plugin-sample-preview": "^1.0.8-0",
"@ali/lowcode-plugin-settings-pane": "^0.8.8", "@ali/lowcode-plugin-settings-pane": "^0.8.8",
"@ali/lowcode-plugin-undo-redo": "^0.8.46", "@ali/lowcode-plugin-undo-redo": "^1.0.8-0",
"@ali/lowcode-plugin-variable-bind-dialog": "^0.8.25", "@ali/lowcode-plugin-variable-bind-dialog": "^1.0.8-0",
"@ali/lowcode-plugin-zh-en": "^0.8.29", "@ali/lowcode-plugin-zh-en": "^1.0.8-0",
"@ali/lowcode-react-renderer": "^0.8.18", "@ali/lowcode-react-renderer": "^1.0.8-0",
"@ali/lowcode-runtime": "^0.8.16", "@ali/lowcode-runtime": "^1.0.8-0",
"@ali/lowcode-utils": "^0.8.16", "@ali/lowcode-utils": "^1.0.8-0",
"@ali/ve-action-pane": "^4.7.0-beta.0", "@ali/ve-action-pane": "^4.7.0-beta.0",
"@ali/ve-datapool-pane": "^6.4.3", "@ali/ve-datapool-pane": "^6.4.3",
"@ali/ve-history-pane": "4.0.0", "@ali/ve-history-pane": "4.0.0",

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@
</script> </script>
<script src="https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"></script> <script src="https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"></script>
<script src="https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js"></script> <script src="https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js"></script>
<link rel="stylesheet" href="https://alifd.alicdn.com/npm/@alifd/next/1.11.6/next.min.css" /> <link rel="stylesheet" href="https://unpkg.alibaba-inc.com/@alifd/next@1.20.25/dist/next.min.css" />
<script src="https://unpkg.alibaba-inc.com/@alifd/next@1.18.17/dist/next.min.js"></script> <script src="https://unpkg.alibaba-inc.com/@alifd/next@1.20.25/dist/next.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rax@1.1.3/dist/rax.js"></script> <script src="https://cdn.jsdelivr.net/npm/rax@1.1.3/dist/rax.js"></script>
<link rel="stylesheet" href="/css/editor-preset-vision.css" /> <link rel="stylesheet" href="/css/editor-preset-vision.css" />
<script> <script>
@ -70,6 +70,9 @@
<body> <body>
<!-- lowcode engine globals --> <!-- lowcode engine globals -->
<div id="lce-container"></div> <div id="lce-container"></div>
<!-- vision 测试使用
-->
<script src="/js/editor-preset-vision.js"></script> <script src="/js/editor-preset-vision.js"></script>
<script src="https://dev.g.alicdn.com/vision/visualengine-utils/5.0.0/engine-utils.js"></script> <script src="https://dev.g.alicdn.com/vision/visualengine-utils/5.0.0/engine-utils.js"></script>
</body> </body>

View File

@ -57,7 +57,7 @@
{ "library": "VisualEngineUtils.NumberSetter", "name": "@ali/vs-number" }, { "library": "VisualEngineUtils.NumberSetter", "name": "@ali/vs-number" },
{ "library": "VisualEngineUtils.OptionsSetter", "name": "@ali/vs-options" }, { "library": "VisualEngineUtils.OptionsSetter", "name": "@ali/vs-options" },
{ "library": "VisualEngineUtils.SelectSetter", "name": "@ali/vs-select" }, { "library": "VisualEngineUtils.SelectSetter", "name": "@ali/vs-select" },
{ "library": "VisualEngineUtils.TextSetter", "name": "@ali/vs-text" }, { "library": "VisualEngineUtils.TextSetter", "name": "@ali/vs-text"},
{ "library": "VisualEngineUtils.ValidationSetter", "name": "@ali/vs-validation" }, { "library": "VisualEngineUtils.ValidationSetter", "name": "@ali/vs-validation" },
{ "library": "VisualEngineUtils.ImageSetter", "name": "@ali/vs-image" }, { "library": "VisualEngineUtils.ImageSetter", "name": "@ali/vs-image" },
{ "library": "VisualEngineUtils.StyleSetter", "name": "@ali/vs-style" }, { "library": "VisualEngineUtils.StyleSetter", "name": "@ali/vs-style" },
@ -84,6 +84,23 @@
"appKey": "template_deep_mobile", "appKey": "template_deep_mobile",
"systemType": "", "systemType": "",
"componentDependencies": [ "componentDependencies": [
{
"packageName": "@alife/service-hall-base-space",
"library": "alifeServiceHallBaseSpace",
"version": "0.1.0",
"components": null,
"prototypeViewsUrl": null,
"prototypeUrls": {
"default": [
"https://dev.g.alicdn.com/service-hall-components/base-space/0.1.0/designer.js"
]
},
"alias": "",
"prototypeConfigsUrl": [
"https://dev.g.alicdn.com/service-hall-components/base-space/0.1.0/designer.js"
],
"urls": ["https://dev.g.alicdn.com/service-hall-components/base-space/0.1.0/view.js"]
},
{ {
"prototypeViewsUrl": null, "prototypeViewsUrl": null,
"prototypeUrls": { "prototypeUrls": {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
{
{
"packageName": "@alife/knowledge-detail",
"version": "0.1.0",
"library": "ServiceHallKnowledgeDetail",
"ext": {
"project": "knowledge-detail",
"group": "service-hall-components"
},
"urls": ["https://dev.g.alicdn.com/service-hall-components/knowledge-detail/0.1.0/designer.js"]
},
{
"packageName": "@alife/benefits-list",
"version": "0.1.1",
"library": "ServiceHallBenefitsList",
"ext": {
"project": "benefits-list",
"group": "service-hall-components"
},
"urls": ["https://dev.g.alicdn.com/service-hall-components/benefits-list/0.1.1/designer.js"]
},
{
"packageName": "@alife/todo-list",
"version": "0.1.1",
"library": "ServiceHallTodoList",
"ext": {
"project": "todo-list",
"group": "service-hall-components"
},
"urls": ["https://dev.g.alicdn.com/service-hall-components/todo-list/0.1.1/designer.js"]
},
{
"packageName": "@alife/todo-list-detail",
"version": "0.1.1",
"library": "ServiceHallTodoListDetail",
"ext": {
"project": "todo-list-detail",
"group": "service-hall-components"
},
"urls": ["https://dev.g.alicdn.com/service-hall-components/todo-list-detail/0.1.1/designer.js"]
},
{
"packageName": "@alife/service-hall-tabs",
"library": "ServiceHallTabs",
"version": "0.1.0",
"ext": {
"project": "tabs",
"group": "service-hall-components"
},
"urls": ["https://dev.g.alicdn.com/service-hall-components/tabs/0.1.0/designer.js"]
}
}

View File

@ -0,0 +1,887 @@
{
"componentName": "Page",
"id": "node_1",
"props": {
"ref": "outterView",
"autoLoading": true,
"style": {
"padding": 20
}
},
"fileName": "test",
"dataSource": {
"list": []
},
"state": {
"text": "outter",
"abc": [1, 2, 3]
},
"children": [
{
"componentName": "Steps",
"id": "node_1i",
"props": {
"dataSource": [
{
"title": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": "报名"
},
"status": "",
"content": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": "Open the refrigerator door"
},
"customSwitcher": false
},
{
"title": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": "信息收集"
},
"status": "",
"content": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": "Put the elephant in the refrigerator"
},
"customSwitcher": false
},
{
"title": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": "审核"
},
"status": "",
"content": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": "Close the refrigerator door"
},
"customSwitcher": false
}
],
"current": 1,
"shape": "circle",
"direction": "horizontal",
"labelPlacement": "vertical",
"readOnly": false,
"animation": true,
"__style__": {},
"fieldId": "steps_kadcb0ov"
}
},
{
"componentName": "Title",
"id": "node_b",
"props": {
"text": "请填写以下人员信息表单",
"type": "primary",
"noDecoration": false,
"__style__": {},
"fieldId": "title_kadcb0nw"
}
},
{
"componentName": "Paragraph",
"id": "node_e",
"props": {
"content": "人最宝贵的是生命。它给予我们只有一次。人的一生应当这样度过:当他回首往事时不因虚度年华而悔恨,也不因碌碌无为而羞耻。这样在他临死的时侯就能够说:我已把我整个的生命和全部精力都献给最壮丽的事业——为人类的解放而斗争。",
"size": "medium",
"type": "long",
"__style__": {},
"fieldId": "paragraph_kadcb0nz"
}
},
{
"componentName": "ColumnsLayout",
"id": "node_r",
"props": {
"layout": "6:6",
"columnGap": "16px",
"rowGap": "16px",
"__style__": {
"marginTop": "24px"
},
"fieldId": "columnsLayout_kadcb0ob"
},
"children": [
{
"componentName": "Column",
"id": "node_s",
"props": {
"fieldId": "column_kadcb0o9",
"__style__": {}
},
"children": [
{
"componentName": "Card",
"id": "node_n",
"props": {
"title": "基本信息",
"subTitle": {
"type": "i18n",
"zh_CN": "",
"en_US": ""
},
"extra": {
"type": "JSSlot",
"params": null,
"value": [
{
"componentName": "Icon",
"id": "node_q",
"props": {
"type": {
"useType": true,
"baseType": "smile",
"otherType": "smile"
},
"size": "medium",
"__style__": {},
"fieldId": "icon_kadcb0o8"
}
}
]
},
"showTitleBullet": true,
"showHeadDivider": true,
"dividerNoInset": false,
"contentHeight": "",
"__style__": {},
"fieldId": "card_kadcb0o7"
},
"children": [
{
"componentName": "CardContent",
"id": "node_o",
"props": {},
"children": [
{
"componentName": "Form",
"id": "node_f",
"props": {
"labelAlign": "top",
"size": "medium",
"behavior": "NORMAL",
"autoValidate": true,
"scrollToFirstError": true,
"autoUnmount": true,
"fieldOptions": {},
"__style__": {
"marginTop": "24px"
},
"fieldId": "form_kadcb0o5"
},
"children": [
{
"componentName": "TextField",
"id": "node_g",
"props": {
"__category__": "form",
"__useMediator": "value",
"label": "姓名",
"value": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"labelAlign": "top",
"labelColSpan": 4,
"labelColOffset": 0,
"wrapperColSpan": 0,
"wrapperColOffset": 0,
"labelTextAlign": "right",
"placeholder": {
"type": "i18n",
"use": "zh_CN",
"en_US": "Please enter",
"zh_CN": "请输入"
},
"tips": {
"zh_CN": "",
"en_US": "",
"type": "i18n"
},
"size": "medium",
"behavior": "NORMAL",
"labelTipsTypes": "none",
"labelTipsIcon": "",
"labelTipsText": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"htmlType": "input",
"state": "",
"rows": 4,
"autoHeight": false,
"hasClear": false,
"trim": false,
"autoFocus": false,
"addonBefore": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"addonAfter": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"validation": [],
"hasLimitHint": false,
"cutString": false,
"__style__": {},
"fieldId": "textField_kadcb0o0"
}
},
{
"componentName": "RadioField",
"id": "node_14",
"props": {
"__category__": "form",
"__useMediator": "value",
"label": "性别",
"value": "",
"labelAlign": "top",
"labelColSpan": 4,
"labelColOffset": 0,
"wrapperColSpan": 0,
"wrapperColOffset": 0,
"labelTextAlign": "right",
"tips": {
"zh_CN": "",
"en_US": "",
"type": "i18n"
},
"size": "medium",
"behavior": "NORMAL",
"labelTipsTypes": "none",
"labelTipsIcon": "",
"labelTipsText": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"shape": "default",
"itemDirection": "hoz",
"dataSource": [
{
"text": {
"zh_CN": "选项一",
"en_US": "Option 1",
"type": "i18n",
"use": "zh_CN"
},
"value": "1",
"disable": false
},
{
"text": {
"zh_CN": "选项二",
"en_US": "Option 2",
"type": "i18n",
"use": "zh_CN"
},
"value": "2",
"disable": false
},
{
"text": {
"zh_CN": "选项三",
"en_US": "Option 3",
"type": "i18n",
"use": "zh_CN"
},
"value": "3",
"disable": true
}
],
"validation": [],
"__style__": {},
"fieldId": "radioField_kadcb0ok"
}
},
{
"componentName": "SelectField",
"id": "node_h",
"props": {
"__category__": "form",
"__useMediator": "value",
"label": "学校",
"value": "",
"labelAlign": "top",
"labelColSpan": 4,
"labelColOffset": 0,
"wrapperColSpan": 0,
"wrapperColOffset": 0,
"labelTextAlign": "right",
"placeholder": {
"type": "i18n",
"use": "zh_CN",
"en_US": "please select",
"zh_CN": "请选择"
},
"tips": {
"zh_CN": "",
"en_US": "",
"type": "i18n"
},
"size": "medium",
"behavior": "NORMAL",
"labelTipsTypes": "none",
"labelTipsIcon": "",
"labelTipsText": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"mode": "single",
"hasClear": false,
"hasSelectAll": false,
"showSearch": false,
"filterLocal": true,
"dataSource": [
{
"text": {
"zh_CN": "选项一",
"en_US": "Option 1",
"type": "i18n"
},
"value": "1"
},
{
"text": {
"zh_CN": "选项二",
"en_US": "Option 2",
"type": "i18n"
},
"value": "2"
},
{
"text": {
"zh_CN": "选项三",
"en_US": "Option 3",
"type": "i18n"
},
"value": "3"
}
],
"validation": [],
"notFoundContent": {
"type": "i18n",
"use": "zh_CN",
"en_US": null
},
"hasArrow": true,
"hasBorder": true,
"autoWidth": true,
"searchDelay": 300,
"__style__": {},
"fieldId": "select_kadcb0o1"
}
},
{
"componentName": "Div",
"id": "node_i",
"props": {
"behavior": "NORMAL",
"__style__": {},
"fieldId": "div_kadcb0o4"
},
"children": [
{
"componentName": "Button",
"id": "node_j",
"props": {
"content": {
"type": "i18n",
"en_US": "Ok",
"zh_CN": "提交"
},
"type": "primary",
"size": "medium",
"behavior": "NORMAL",
"baseIcon": "",
"otherIcon": "",
"loading": false,
"triggerEventsWhenLoading": false,
"__style__": ":root {\n margin-right: 15px;\n}",
"fieldId": "button_kadcb0o2",
"onClick": {
"type": "JSExpression",
"value": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
"extType": "function",
"events": [
{
"name": "onClick",
"params": {},
"func": {
"type": "js",
"source": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
"compiled": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}"
}
}
]
}
}
},
{
"componentName": "Button",
"id": "node_k",
"props": {
"content": {
"type": "i18n",
"en_US": "Reset",
"zh_CN": "重置"
},
"type": "secondary",
"size": "medium",
"behavior": "NORMAL",
"baseIcon": "",
"otherIcon": "",
"loading": false,
"triggerEventsWhenLoading": false,
"__style__": {},
"fieldId": "button_kadcb0o3",
"onClick": {
"type": "JSExpression",
"value": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
"extType": "function",
"events": [
{
"name": "onClick",
"params": {},
"func": {
"type": "js",
"source": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
"compiled": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}"
}
}
]
}
}
}
]
}
]
}
]
}
]
}
]
},
{
"componentName": "Column",
"id": "node_t",
"props": {
"fieldId": "column_kadcb0oa",
"__style__": {}
},
"children": [
{
"componentName": "Card",
"id": "node_u",
"props": {
"title": {
"type": "JSSlot",
"params": null,
"value": [
{
"componentName": "Icon",
"id": "node_18",
"props": {
"type": {
"useType": true,
"baseType": "smile",
"otherType": "smile"
},
"size": "medium",
"__style__": {},
"fieldId": "icon_kadcb0on"
}
},
{
"componentName": "Link",
"id": "node_19",
"props": {
"content": {
"type": "i18n",
"use": "zh_CN",
"en_US": "link text",
"zh_CN": "扩展信息"
},
"textOverflow": false,
"link": {
"type": "page",
"page": null,
"router": {
"type": "JSExpression",
"value": "this.utils.router"
}
},
"__style__": {},
"fieldId": "link_kadcb0oo"
}
}
]
},
"subTitle": {
"type": "i18n",
"zh_CN": "",
"en_US": ""
},
"extra": {
"type": "JSSlot",
"params": null,
"value": [
{
"componentName": "Icon",
"id": "node_1a",
"props": {
"type": {
"useType": true,
"baseType": "smile",
"otherType": "smile"
},
"size": "xl",
"__style__": {},
"fieldId": "icon_kadcb0op"
}
}
]
},
"showTitleBullet": true,
"showHeadDivider": true,
"dividerNoInset": false,
"contentHeight": "",
"__style__": {},
"fieldId": "card_kadcb0oc"
},
"children": [
{
"componentName": "CardContent",
"id": "node_v",
"props": {},
"children": [
{
"componentName": "Form",
"id": "node_x",
"props": {
"labelAlign": "top",
"size": "medium",
"behavior": "NORMAL",
"autoValidate": true,
"scrollToFirstError": true,
"autoUnmount": true,
"fieldOptions": {},
"__style__": {
"marginTop": "24px"
},
"fieldId": "form_kadcb0oi"
},
"children": [
{
"componentName": "TextField",
"id": "node_y",
"props": {
"__category__": "form",
"__useMediator": "value",
"label": "职位",
"value": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"labelAlign": "top",
"labelColSpan": 4,
"labelColOffset": 0,
"wrapperColSpan": 0,
"wrapperColOffset": 0,
"labelTextAlign": "right",
"placeholder": {
"type": "i18n",
"use": "zh_CN",
"en_US": "Please enter",
"zh_CN": "请输入"
},
"tips": {
"zh_CN": "",
"en_US": "",
"type": "i18n"
},
"size": "medium",
"behavior": "NORMAL",
"labelTipsTypes": "none",
"labelTipsIcon": "",
"labelTipsText": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"htmlType": "input",
"state": "",
"rows": 4,
"autoHeight": false,
"hasClear": false,
"trim": false,
"autoFocus": false,
"addonBefore": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"addonAfter": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"validation": [],
"hasLimitHint": false,
"cutString": false,
"__style__": {},
"fieldId": "textField_kadcb0od"
}
},
{
"componentName": "DateField",
"id": "node_15",
"props": {
"__category__": "form",
"__useMediator": "value",
"label": "入职时间",
"value": "",
"labelAlign": "top",
"labelColSpan": 4,
"labelColOffset": 0,
"wrapperColSpan": 0,
"wrapperColOffset": 0,
"labelTextAlign": "right",
"placeholder": {
"type": "i18n",
"use": "zh_CN",
"en_US": "please select",
"zh_CN": "请选择"
},
"tips": {
"zh_CN": "",
"en_US": "",
"type": "i18n"
},
"size": "medium",
"behavior": "NORMAL",
"format": "YYYY-MM-DD",
"returnType": "timestamp",
"labelTipsTypes": "none",
"labelTipsIcon": "",
"labelTipsText": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"hasClear": true,
"resetTime": false,
"disabledDate": false,
"validation": [],
"__style__": {},
"fieldId": "dateField_kadcb0ol"
}
},
{
"componentName": "SelectField",
"id": "node_z",
"props": {
"__category__": "form",
"__useMediator": "value",
"label": "下拉选择",
"value": "",
"labelAlign": "top",
"labelColSpan": 4,
"labelColOffset": 0,
"wrapperColSpan": 0,
"wrapperColOffset": 0,
"labelTextAlign": "right",
"placeholder": {
"type": "i18n",
"use": "zh_CN",
"en_US": "please select",
"zh_CN": "请选择"
},
"tips": {
"zh_CN": "",
"en_US": "",
"type": "i18n"
},
"size": "medium",
"behavior": "NORMAL",
"labelTipsTypes": "none",
"labelTipsIcon": "",
"labelTipsText": {
"type": "i18n",
"use": "zh_CN",
"en_US": null,
"zh_CN": ""
},
"mode": "single",
"hasClear": false,
"hasSelectAll": false,
"showSearch": false,
"filterLocal": true,
"dataSource": [
{
"text": {
"zh_CN": "选项一",
"en_US": "Option 1",
"type": "i18n"
},
"value": "1"
},
{
"text": {
"zh_CN": "选项二",
"en_US": "Option 2",
"type": "i18n"
},
"value": "2"
},
{
"text": {
"zh_CN": "选项三",
"en_US": "Option 3",
"type": "i18n"
},
"value": "3"
}
],
"validation": [],
"notFoundContent": {
"type": "i18n",
"use": "zh_CN",
"en_US": null
},
"hasArrow": true,
"hasBorder": true,
"autoWidth": true,
"searchDelay": 300,
"__style__": {},
"fieldId": "select_kadcb0oe"
}
},
{
"componentName": "Div",
"id": "node_10",
"props": {
"behavior": "NORMAL",
"__style__": {},
"fieldId": "div_kadcb0oh"
},
"children": [
{
"componentName": "Button",
"id": "node_11",
"props": {
"content": {
"type": "i18n",
"en_US": "Ok",
"zh_CN": "提交"
},
"type": "primary",
"size": "medium",
"behavior": "NORMAL",
"baseIcon": "",
"otherIcon": "",
"loading": false,
"triggerEventsWhenLoading": false,
"__style__": ":root {\n margin-right: 15px;\n}",
"fieldId": "button_kadcb0of",
"onClick": {
"type": "JSExpression",
"value": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
"extType": "function",
"events": [
{
"name": "onClick",
"params": {},
"func": {
"type": "js",
"source": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
"compiled": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}"
}
}
]
}
}
},
{
"componentName": "Button",
"id": "node_12",
"props": {
"content": {
"type": "i18n",
"en_US": "Reset",
"zh_CN": "重置"
},
"type": "secondary",
"size": "medium",
"behavior": "NORMAL",
"baseIcon": "",
"otherIcon": "",
"loading": false,
"triggerEventsWhenLoading": false,
"__style__": {},
"fieldId": "button_kadcb0og",
"onClick": {
"type": "JSExpression",
"value": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
"extType": "function",
"events": [
{
"name": "onClick",
"params": {},
"func": {
"type": "js",
"source": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
"compiled": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}"
}
}
]
}
}
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}

View File

@ -1,4 +1,5 @@
import { ReactProvider, Utils } from '@ali/lowcode-runtime'; import { ReactProvider } from '@ali/lowcode-runtime';
import { buildComponents } from '@ali/lowcode-utils';
import appConfig from '../config/app'; import appConfig from '../config/app';
import builtInComps from '../config/components'; import builtInComps from '../config/components';
import componentsMap from '../config/componentsMap'; import componentsMap from '../config/componentsMap';
@ -31,7 +32,7 @@ export default class Preview extends ReactProvider {
layout, layout,
routes, routes,
containerId, containerId,
components: { ...builtInComps, ...Utils.buildComponents({ '@alifd/next': 'Next' }, componentsMap) }, components: { ...builtInComps, ...buildComponents({ '@alifd/next': 'Next' }, componentsMap) },
componentsMap, componentsMap,
utils: utils, utils: utils,
constants, constants,

View File

@ -1,6 +1,6 @@
import logo from '@ali/lowcode-plugin-sample-logo'; import logo from '@ali/lowcode-plugin-sample-logo';
import samplePreview from '@ali/lowcode-plugin-sample-preview'; import samplePreview from '@ali/lowcode-plugin-sample-preview';
//import undoRedo from '@ali/lowcode-plugin-undo-redo'; import undoRedo from '@ali/lowcode-plugin-undo-redo';
import componentsPane from '@ali/lowcode-plugin-components-pane'; import componentsPane from '@ali/lowcode-plugin-components-pane';
import outline, { OutlinePane } from '@ali/lowcode-plugin-outline-pane'; import outline, { OutlinePane } from '@ali/lowcode-plugin-outline-pane';
import zhEn from '@ali/lowcode-plugin-zh-en'; import zhEn from '@ali/lowcode-plugin-zh-en';
@ -14,7 +14,7 @@ import saveload from './plugins/saveload';
export default { export default {
logo, logo,
samplePreview, samplePreview,
//undoRedo, undoRedo,
componentsPane, componentsPane,
outline, outline,
zhEn, zhEn,

View File

@ -13,7 +13,6 @@ export default {
href: '/', href: '/',
}, },
}, },
/*
{ {
pluginKey: 'undoRedo', pluginKey: 'undoRedo',
type: 'Custom', type: 'Custom',
@ -22,6 +21,7 @@ export default {
width: 88, width: 88,
}, },
}, },
/*
{ {
pluginKey: 'divider', pluginKey: 'divider',
type: 'Divider', type: 'Divider',
@ -84,15 +84,15 @@ export default {
props: { props: {
align: 'top', align: 'top',
icon: 'wenjian', icon: 'wenjian',
description: '资源面板', description: 'JS面板',
panelProps: { panelProps: {
floatable: true, floatable: true,
height: 300, height: 300,
help: undefined, help: undefined,
hideTitleBar: true, hideTitleBar: false,
maxHeight: 800, maxHeight: 800,
maxWidth: 1200, maxWidth: 1200,
title: '动作面板', title: 'JS面板',
width: 600, width: 600,
}, },
}, },
@ -120,6 +120,15 @@ export default {
init: async function init(editor) { init: async function init(editor) {
const assets = await editor.utils.get('./assets.json'); const assets = await editor.utils.get('./assets.json');
editor.set('assets', assets); editor.set('assets', assets);
const simulatorUrl = [
'https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-engine/0.9.50/react-simulator-renderer.css',
'https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-engine/0.9.50/react-simulator-renderer.js',
// for debug simulator
// 'http://localhost:3333/js/react-simulator-renderer.js',
];
editor.set('simulatorUrl', simulatorUrl);
// editor.set('renderEnv', 'rax');
const schema = await editor.utils.get('./schema.json'); const schema = await editor.utils.get('./schema.json');
editor.set('schema', schema); editor.set('schema', schema);

View File

@ -1,5 +1,5 @@
import { render } from 'react-dom'; import { render } from 'react-dom';
import GeneralWorkbench, { editor } from '../../../editor-preset-general/src'; import GeneralWorkbench, { editor } from '@ali/lowcode-editor-preset-general';
import config from './config'; import config from './config';
import components from './components'; import components from './components';
import './global.scss'; import './global.scss';

View File

@ -21,7 +21,7 @@ interface BasicSection {
[k: string]: any; [k: string]: any;
} }
const CODEOUT_SERVICE_HOST = '30.13.90.55:3000'; const CODEOUT_SERVICE_HOST = 'localhost:7002';
const Codeout = ({ editor }: PluginProps) => { const Codeout = ({ editor }: PluginProps) => {
const handleClick = () => { const handleClick = () => {

View File

@ -22,14 +22,21 @@ interface BasicSection {
const Codeout = ({ editor }: PluginProps) => { const Codeout = ({ editor }: PluginProps) => {
const handleSaveClick = () => { const handleSaveClick = () => {
const designer = editor.get(Designer);
if (designer) { debugger;
const schema = designer.schema.componentsTree[designer.schema.componentsTree.length - 1]; // editor.get('schema');
const schemaStr = JSON.stringify(schema); let schema = editor.get('designer').project.getSchema();
window.localStorage.setItem('schema_data', schemaStr); console.log(schema);
console.info('save schema:', schemaStr);
alert('保存成功');
} // const designer = editor.get(Designer);
// if (designer) {
// const schema = designer.schema.componentsTree[designer.schema.componentsTree.length - 1]; // editor.get('schema');
// const schemaStr = JSON.stringify(schema);
// window.localStorage.setItem('schema_data', schemaStr);
// console.info('save schema:', schemaStr);
// alert('保存成功');
// }
}; };
const handleLoadClick = () => { const handleLoadClick = () => {

View File

@ -1,2 +1,2 @@
import './vision'; // import './vision';
// import './editor'; import './editor';

View File

@ -14,14 +14,13 @@ import ActionPane from '@ali/ve-action-pane';
import SourceEditor from '@ali/lowcode-plugin-source-editor'; import SourceEditor from '@ali/lowcode-plugin-source-editor';
import fetchContext from '@ali/vu-legao-design-fetch-context'; import fetchContext from '@ali/vu-legao-design-fetch-context';
import EventBindDialog from '@ali/lowcode-plugin-event-bind-dialog'; import EventBindDialog from '@ali/lowcode-plugin-event-bind-dialog';
import loadUrls from './loader';
import { upgradeAssetsBundle } from './upgrade-assets';
import { isCSSUrl } from '@ali/lowcode-utils'; import { isCSSUrl } from '@ali/lowcode-utils';
import VariableSetter from '@ali/vs-variable-setter'; import VariableSetter from '@ali/vs-variable-setter';
import _isArray from "lodash/isArray"; import _isArray from "lodash/isArray";
import _isObject from "lodash/isObject"; import _isObject from "lodash/isObject";
import _get from 'lodash/get'; import _get from 'lodash/get';
import funcParser from '@ali/vu-function-parser'; import funcParser from '@ali/vu-function-parser';
import { import {
NumberSetter, NumberSetter,
BoolSetter, BoolSetter,
@ -39,6 +38,13 @@ import {
ActionSetter, ActionSetter,
} from '@ali/visualengine-utils'; } from '@ali/visualengine-utils';
import PropType from 'prop-types';
import loadUrls from './loader';
import { upgradeAssetsBundle } from './upgrade-assets';
console.log(PropType);
const { editor, skeleton, context, HOOKS, Trunk } = Engine; const { editor, skeleton, context, HOOKS, Trunk } = Engine;
Trunk.registerSetter('Input', TextSetter); Trunk.registerSetter('Input', TextSetter);
@ -102,8 +108,8 @@ context.use(HOOKS.VE_SETTING_FIELD_VARIABLE_SETTER, VariableSetter);
const externals = ['react', 'react-dom', 'prop-types', 'react-router', 'react-router-dom', '@ali/recore']; const externals = ['react', 'react-dom', 'prop-types', 'react-router', 'react-router-dom', '@ali/recore'];
async function loadAssets() { async function loadAssets() {
const legaoAssets = await editor.utils.get('./raxAssets.json'); // const legaoAssets = await editor.utils.get('./raxAssets.json');
// const legaoAssets = await editor.utils.get('./legao-assets.json'); const legaoAssets = await editor.utils.get('./legao-assets.json');
const assets = upgradeAssetsBundle(legaoAssets); const assets = upgradeAssetsBundle(legaoAssets);
@ -145,11 +151,12 @@ async function loadAssets() {
} }
async function loadSchema() { async function loadSchema() {
const schema = await editor.utils.get('./rax.json'); // const schema = await editor.utils.get('./rax.json');
// const schema = await editor.utils.get('./schema.json'); const schema = await editor.utils.get('./vision-schema.json');
editor.set('schema', schema); editor.set('schema', schema);
editor.set('renderEnv', 'rax'); // editor.set('renderEnv', 'rax');
editor.set('clientTypes', ['mobile']); // editor.set('clientTypes', ['mobile']);
} }
// demo // demo

View File

@ -3,6 +3,184 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.0.8-0"></a>
## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.55...@ali/lowcode-designer@1.0.8-0) (2020-09-09)
### Bug Fixes
* 不应该限定 parent 才做解绑操作 ([2e616e3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2e616e3))
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 兼容modal模式 ([1092ee9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1092ee9))
* 解决 set('schema') 后 componentsTree 越来越多的 bug ([a171d3e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a171d3e))
* 优化树子节点删除逻辑 ([47e814f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/47e814f))
### Features
* 🎸 支持设置模拟器的 viewport 的宽高和缩放级别 ([3a54241](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3a54241))
* 新增simulatorurl可以设置cdn使用simulator ([1f45b05](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f45b05))
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@1.0.6-0...@ali/lowcode-designer@1.0.7-0) (2020-09-02)
<a name="0.9.55"></a>
## [0.9.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.54...@ali/lowcode-designer@0.9.55) (2020-09-08)
### Bug Fixes
* 拖拽时要解除与原来节点的关系 ([7a6bf2c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7a6bf2c))
<a name="0.9.54"></a>
## [0.9.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.53...@ali/lowcode-designer@0.9.54) (2020-09-03)
**Note:** Version bump only for package @ali/lowcode-designer
<a name="0.9.53"></a>
## [0.9.53](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.52...@ali/lowcode-designer@0.9.53) (2020-09-03)
**Note:** Version bump only for package @ali/lowcode-designer
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.52...@ali/lowcode-designer@1.0.6-0) (2020-09-02)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 兼容modal模式 ([1092ee9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1092ee9))
### Features
* 🎸 支持设置模拟器的 viewport 的宽高和缩放级别 ([3a54241](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3a54241))
* 新增simulatorurl可以设置cdn使用simulator ([1f45b05](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f45b05))
**Note:** Version bump only for package @ali/lowcode-designer
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@1.0.4-0...@ali/lowcode-designer@1.0.5-0) (2020-08-20)
<a name="0.9.52"></a>
## [0.9.52](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.51...@ali/lowcode-designer@0.9.52) (2020-08-27)
### Bug Fixes
* 在 renderer 层面做 function component 包装,避免影响 rax 等其他场景 ([1f920dd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f920dd))
<a name="0.9.51"></a>
## [0.9.51](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.50...@ali/lowcode-designer@0.9.51) (2020-08-26)
### Bug Fixes
* 处理 function component 无法选中的问题,本质上是没有 ref ([fa94aab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fa94aab))
<a name="0.9.50"></a>
## [0.9.50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.49...@ali/lowcode-designer@0.9.50) (2020-08-24)
### Bug Fixes
* 修复在切换页面时没有销毁相应节点导致的一系列bug ([59fac25](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/59fac25))
* 在设计器里,所有组件都需要展示,不管 condition 为何值 ([0e7e038](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0e7e038))
* 实现 removeDocument ([c07b447](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c07b447))
<a name="0.9.49"></a>
## [0.9.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.48...@ali/lowcode-designer@0.9.49) (2020-08-23)
### Bug Fixes
* nextId() 逻辑调整 ([488a5d8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/488a5d8))
<a name="0.9.48"></a>
## [0.9.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.47...@ali/lowcode-designer@0.9.48) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-designer
<a name="0.9.47"></a>
## [0.9.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.46...@ali/lowcode-designer@0.9.47) (2020-08-19)
### Bug Fixes
* 修复获取 currentPage 的逻辑 ([d8221db](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d8221db))
<a name="0.9.46"></a>
## [0.9.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.45...@ali/lowcode-designer@0.9.46) (2020-08-19)
### Bug Fixes
* support dropObject is data ([809fda7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/809fda7))
**Note:** Version bump only for package @ali/lowcode-designer
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.11.0...@ali/lowcode-designer@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-designer
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.10.0...@ali/lowcode-designer@0.11.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-designer
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.37...@ali/lowcode-designer@0.10.0) (2020-08-14)
<a name="0.9.43"></a>
## [0.9.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.42...@ali/lowcode-designer@0.9.43) (2020-08-14)
### Bug Fixes
* 修改移动端设备宽度 ([cd7b1e6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/cd7b1e6))
<a name="0.9.42"></a> <a name="0.9.42"></a>
## [0.9.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.41...@ali/lowcode-designer@0.9.42) (2020-08-14) ## [0.9.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.41...@ali/lowcode-designer@0.9.42) (2020-08-14)
@ -65,7 +243,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Bug Fixes ### Bug Fixes
* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24)) * 兼容modal模式 ([1092ee9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1092ee9))
@ -554,12 +732,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Features ### Features
<<<<<<< HEAD
* 🎸 merge material-parser ([b40c286](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b40c286)) * 🎸 merge material-parser ([b40c286](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b40c286))
* history log ([fbb3577](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fbb3577)) * history log ([fbb3577](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fbb3577))
* import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e66168)) * import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e66168))
=======
* 🎸 merge material-parser ([b40c286](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b40c2869a0bc901d855279735fe86b84dabaa04d))
* history log ([fbb3577](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fbb3577bd434c0ac77cc907abc36e3efe110fe8c))
* import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e661686e4693e69279c496f3be1dd173703c55e))
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-designer", "name": "@ali/lowcode-designer",
"version": "0.9.42", "version": "1.0.8-0",
"description": "Designer for Ali LowCode Engine", "description": "Designer for Ali LowCode Engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,9 +15,9 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@ali/lowcode-editor-core": "^0.8.28", "@ali/lowcode-editor-core": "^1.0.8-0",
"@ali/lowcode-types": "^0.8.14", "@ali/lowcode-types": "^1.0.8-0",
"@ali/lowcode-utils": "^0.8.16", "@ali/lowcode-utils": "^1.0.8-0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"event": "^1.0.0", "event": "^1.0.0",
"react": "^16", "react": "^16",

View File

@ -75,7 +75,7 @@ export function createSimulator(
.join(''); .join('');
doc.open(); doc.open();
doc.write(`<!doctype html><html><head><meta charset="utf-8"/> doc.write(`<!doctype html><html class="engine-design-mode"><head><meta charset="utf-8"/>
${styleFrags} ${styleFrags}
</head><body>${scriptFrags}</body></html>`); </head><body>${scriptFrags}</body></html>`);
doc.close(); doc.close();

View File

@ -58,7 +58,7 @@ class Canvas extends Component<{ host: BuiltinSimulatorHost }> {
return ( return (
<div className={className}> <div className={className}>
<div ref={elmt => sim.mountViewport(elmt)} className="lc-simulator-canvas-viewport"> <div ref={(elmt) => sim.mountViewport(elmt)} className="lc-simulator-canvas-viewport">
<BemTools host={sim} /> <BemTools host={sim} />
<Content host={sim} /> <Content host={sim} />
</div> </div>
@ -72,18 +72,19 @@ class Content extends Component<{ host: BuiltinSimulatorHost }> {
render() { render() {
const sim = this.props.host; const sim = this.props.host;
const viewport = sim.viewport; const viewport = sim.viewport;
let frameStyle = {}; const frameStyle = {
if (viewport.scale < 1) { transform: `scale(${viewport.scale})`,
frameStyle = { height: viewport.contentHeight,
transform: `scale(${viewport.scale})`, width: viewport.contentWidth,
height: viewport.contentHeight, };
width: viewport.contentWidth,
};
}
return ( return (
<div className="lc-simulator-content"> <div className="lc-simulator-content">
<iframe className="lc-simulator-content-frame" style={frameStyle} ref={frame => sim.mountContentFrame(frame)} /> <iframe
className="lc-simulator-content-frame"
style={frameStyle}
ref={(frame) => sim.mountContentFrame(frame)}
/>
</div> </div>
); );
} }

View File

@ -89,7 +89,7 @@ const defaultRaxSimulatorUrl = (() => {
const defaultEnvironment = [ const defaultEnvironment = [
// https://g.alicdn.com/mylib/??react/16.11.0/umd/react.production.min.js,react-dom/16.8.6/umd/react-dom.production.min.js,prop-types/15.7.2/prop-types.min.js // https://g.alicdn.com/mylib/??react/16.11.0/umd/react.production.min.js,react-dom/16.8.6/umd/react-dom.production.min.js,prop-types/15.7.2/prop-types.min.js
assetItem(AssetType.JSText, 'window.React=parent.React;window.ReactDOM=parent.ReactDOM;', undefined, 'react'), assetItem(AssetType.JSText, 'window.React=parent.React;window.ReactDOM=parent.ReactDOM;window.__is_simulator_env__=true;', undefined, 'react'),
assetItem( assetItem(
AssetType.JSText, AssetType.JSText,
'window.PropTypes=parent.PropTypes;React.PropTypes=parent.PropTypes; window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;', 'window.PropTypes=parent.PropTypes;React.PropTypes=parent.PropTypes; window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;',
@ -235,7 +235,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
const vendors = [ const vendors = [
// required & use once // required & use once
assetBundle( assetBundle(
this.get('environment') || this.renderEnv === 'rax' ? defaultRaxEnvironment : defaultEnvironment, this.get('environment') || (this.renderEnv === 'rax' ? defaultRaxEnvironment : defaultEnvironment),
AssetLevel.Environment, AssetLevel.Environment,
), ),
// required & use once // required & use once
@ -246,7 +246,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
assetBundle(this.theme, AssetLevel.Theme), assetBundle(this.theme, AssetLevel.Theme),
// required & use once // required & use once
assetBundle( assetBundle(
this.get('simulatorUrl') || this.renderEnv === 'rax' ? defaultRaxSimulatorUrl : defaultSimulatorUrl, this.get('simulatorUrl') || (this.renderEnv === 'rax' ? defaultRaxSimulatorUrl : defaultSimulatorUrl),
AssetLevel.Runtime, AssetLevel.Runtime,
), ),
]; ];
@ -401,12 +401,31 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
x.initEvent('click', true); x.initEvent('click', true);
this._iframe?.dispatchEvent(x); this._iframe?.dispatchEvent(x);
const target = e.target as HTMLElement; const target = e.target as HTMLElement;
if (
isFormEvent(e) || // TODO: need more elegant solution to ignore click events of compoents in designer
target?.closest( const ignoreSelectors: any = [
'.next-input-group,.next-checkbox-group,.next-date-picker,.next-input,.next-month-picker,.next-number-picker,.next-radio-group,.next-range,.next-range-picker,.next-rating,.next-select,.next-switch,.next-time-picker,.next-upload,.next-year-picker,.next-breadcrumb-item,.next-calendar-header,.next-calendar-table', '.next-input-group',
) '.next-checkbox-group',
) { '.next-date-picker',
'.next-input',
'.next-month-picker',
'.next-number-picker',
'.next-radio-group',
'.next-range',
'.next-range-picker',
'.next-rating',
'.next-select',
'.next-switch',
'.next-time-picker',
'.next-upload',
'.next-year-picker',
'.next-breadcrumb-item',
'.next-calendar-header',
'.next-calendar-table',
'.editor-container', // 富文本组件
];
const ignoreSelectorsString = ignoreSelectors.join(',');
if (isFormEvent(e) || target?.closest(ignoreSelectorsString)) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
} }
@ -475,9 +494,10 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
return; return;
} }
const rootElement = this.findDOMNodes(nodeInst.instance, node.componentMeta.rootSelector)?.find((item) => const rootElement = this.findDOMNodes(nodeInst.instance, node.componentMeta.rootSelector)?.find(
// 可能是 [null]; (item) =>
item && item.contains(targetElement), // 可能是 [null];
item && item.contains(targetElement),
) as HTMLElement; ) as HTMLElement;
if (!rootElement) { if (!rootElement) {
return; return;
@ -857,7 +877,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
// fix target : 浏览器事件响应目标 // fix target : 浏览器事件响应目标
if (!e.target || notMyEvent) { if (!e.target || notMyEvent) {
e.target = this.contentDocument!.elementFromPoint(e.canvasX!, e.canvasY!); e.target = this.contentDocument?.elementFromPoint(e.canvasX!, e.canvasY!);
} }
// 事件已订正 // 事件已订正
@ -898,9 +918,10 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
return canMove; return canMove;
}); });
if (!operationalNodes || operationalNodes.length === 0) { if (nodes && (!operationalNodes || operationalNodes.length === 0)) {
return; return;
} }
this.sensing = true; this.sensing = true;
this.scroller.scrolling(e); this.scroller.scrolling(e);
const document = this.project.currentDocument; const document = this.project.currentDocument;
@ -914,7 +935,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
!dropContainer || !dropContainer ||
canDropIn === false || canDropIn === false ||
// too dirty // too dirty
(typeof canDropIn === 'function' && !canDropIn(operationalNodes[0])) (nodes && typeof canDropIn === 'function' && !canDropIn(operationalNodes[0]))
) { ) {
return null; return null;
} }
@ -946,7 +967,13 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
event: e, event: e,
}; };
if (dragObject.type === 'node' && operationalNodes[0]?.getPrototype()?.isModal()) { // if (e.dragObject.type === 'node' && e.dragObject.nodes[0]?.getPrototype()?.isModal()) {
if (
e.dragObject &&
e.dragObject.nodes &&
e.dragObject.nodes.length &&
e.dragObject.nodes[0].getPrototype()?.isModal()
) {
return this.designer.createLocation({ return this.designer.createLocation({
target: document.rootNode, target: document.rootNode,
detail, detail,

View File

@ -22,8 +22,8 @@ export default class Viewport implements IViewport {
return new DOMRect(0, 0, bounds.width / scale, bounds.height / scale); return new DOMRect(0, 0, bounds.width / scale, bounds.height / scale);
} }
private viewportElement?: Element; private viewportElement?: HTMLElement;
mount(viewportElement: Element | null) { mount(viewportElement: HTMLElement | null) {
if (!viewportElement || this.viewportElement === viewportElement) { if (!viewportElement || this.viewportElement === viewportElement) {
return; return;
} }
@ -43,6 +43,15 @@ export default class Viewport implements IViewport {
} }
return this.rect.height; return this.rect.height;
} }
set height(newHeight: number) {
this._contentHeight = newHeight / this.scale;
if (this.viewportElement) {
this.viewportElement.style.height = `${newHeight}px`;
this.touch();
}
}
@computed get width(): number { @computed get width(): number {
if (!this.rect) { if (!this.rect) {
return 1000; return 1000;
@ -50,29 +59,45 @@ export default class Viewport implements IViewport {
return this.rect.width; return this.rect.width;
} }
set width(newWidth: number) {
this._contentWidth = newWidth / this.scale;
if (this.viewportElement) {
this.viewportElement.style.width = `${newWidth}px`;
this.touch();
}
}
@obx.ref private _scale: number = 1;
/** /**
* *
*/ */
@computed get scale(): number { @computed get scale(): number {
if (!this.rect || this.contentWidth === AutoFit) { return this._scale;
return 1; }
set scale(newScale: number) {
if (isNaN(newScale) || newScale <= 0) {
throw new Error(`invalid new scale "${newScale}"`);
} }
return this.width / this.contentWidth;
this._scale = newScale;
this._contentWidth = this.width / this.scale;
this._contentHeight = this.height / this.scale;
} }
@obx.ref private _contentWidth: number | AutoFit = AutoFit; @obx.ref private _contentWidth: number | AutoFit = AutoFit;
@obx.ref private _contentHeight: number | AutoFit = AutoFit;
@computed get contentHeight(): number | AutoFit { @computed get contentHeight(): number | AutoFit {
if (!this.rect || this.scale === 1) { return this._contentHeight;
return AutoFit; }
}
return this.height / this.scale; set contentHeight(newContentHeight: number | AutoFit) {
this._contentHeight = newContentHeight;
} }
@computed get contentWidth(): number | AutoFit { @computed get contentWidth(): number | AutoFit {
if (!this.rect || (this._contentWidth !== AutoFit && this._contentWidth <= this.width)) {
return AutoFit;
}
return this._contentWidth; return this._contentWidth;
} }

View File

@ -160,8 +160,8 @@ export class ComponentMeta {
const liveTextEditing = this._transformedMetadata.experimental?.liveTextEditing || []; const liveTextEditing = this._transformedMetadata.experimental?.liveTextEditing || [];
function collectLiveTextEditing(items: FieldConfig[]) { function collectLiveTextEditing(items: FieldConfig[]) {
items.forEach(config => { items.forEach((config) => {
if (config.items) { if (config?.items) {
collectLiveTextEditing(config.items); collectLiveTextEditing(config.items);
} else { } else {
const liveConfig = config.liveTextEditing || config.extraProps?.liveTextEditing; const liveConfig = config.liveTextEditing || config.extraProps?.liveTextEditing;
@ -208,13 +208,13 @@ export class ComponentMeta {
return result as any; return result as any;
} }
isRootComponent() { isRootComponent(includeBlock: boolean = true) {
return this.componentName === 'Page' || this.componentName === 'Block' || this.componentName === 'Component'; return this.componentName === 'Page' || this.componentName === 'Component' || (includeBlock && this.componentName === 'Block');
} }
@computed get availableActions() { @computed get availableActions() {
let { disableBehaviors, actions } = this._transformedMetadata?.configure.component || {}; let { disableBehaviors, actions } = this._transformedMetadata?.configure.component || {};
const disabled = ensureAList(disableBehaviors) || (this.isRootComponent() ? ['copy', 'remove'] : null); const disabled = ensureAList(disableBehaviors) || (this.isRootComponent(false) ? ['copy', 'remove'] : null);
actions = builtinComponentActions.concat(this.designer.getGlobalComponentActions() || [], actions || []); actions = builtinComponentActions.concat(this.designer.getGlobalComponentActions() || [], actions || []);
if (disabled) { if (disabled) {
@ -277,7 +277,6 @@ function preprocessMetadata(metadata: ComponentMetadata): TransformedComponentMe
}; };
} }
export interface MetadataTransducer { export interface MetadataTransducer {
(prev: TransformedComponentMetadata): TransformedComponentMetadata; (prev: TransformedComponentMetadata): TransformedComponentMetadata;
/** /**
@ -293,7 +292,7 @@ export interface MetadataTransducer {
} }
const metadataTransducers: MetadataTransducer[] = []; const metadataTransducers: MetadataTransducer[] = [];
export function registerMetadataTransducer(transducer: MetadataTransducer, level: number = 100, id?: string) { export function registerMetadataTransducer(transducer: MetadataTransducer, level = 100, id?: string) {
transducer.level = level; transducer.level = level;
transducer.id = id; transducer.id = id;
const i = metadataTransducers.findIndex((item) => item.level != null && item.level > level); const i = metadataTransducers.findIndex((item) => item.level != null && item.level > level);
@ -308,7 +307,6 @@ export function getRegisteredMetadataTransducers(): MetadataTransducer[] {
return metadataTransducers; return metadataTransducers;
} }
registerMetadataTransducer((metadata) => { registerMetadataTransducer((metadata) => {
const { configure, componentName } = metadata; const { configure, componentName } = metadata;
const { component = {} } = configure; const { component = {} } = configure;
@ -337,9 +335,9 @@ registerMetadataTransducer((metadata) => {
}; };
} }
} }
if (component.isModal == null && /Dialog/.test(componentName)) { // if (component.isModal == null && /Dialog/.test(componentName)) {
component.isModal = true; // component.isModal = true;
} // }
return { return {
...metadata, ...metadata,
configure: { configure: {

View File

@ -8,6 +8,7 @@ import {
IEditor, IEditor,
CompositeObject, CompositeObject,
PropsList, PropsList,
isNodeSchema,
} from '@ali/lowcode-types'; } from '@ali/lowcode-types';
import { Project } from '../project'; import { Project } from '../project';
import { Node, DocumentModel, insertChildren, isRootNode, ParentalNode, TransformStage } from '../document'; import { Node, DocumentModel, insertChildren, isRootNode, ParentalNode, TransformStage } from '../document';
@ -111,10 +112,14 @@ export class Designer {
if (isLocationChildrenDetail(loc.detail) && loc.detail.valid !== false) { if (isLocationChildrenDetail(loc.detail) && loc.detail.valid !== false) {
let nodes: Node[] | undefined; let nodes: Node[] | undefined;
if (isDragNodeObject(dragObject)) { if (isDragNodeObject(dragObject)) {
nodes = insertChildren(loc.target, dragObject.nodes, loc.detail.index, copy); nodes = insertChildren(loc.target, [...dragObject.nodes], loc.detail.index, copy);
} else if (isDragNodeDataObject(dragObject)) { } else if (isDragNodeDataObject(dragObject)) {
// process nodeData // process nodeData
const nodeData = Array.isArray(dragObject.data) ? dragObject.data : [dragObject.data]; const nodeData = Array.isArray(dragObject.data) ? dragObject.data : [dragObject.data];
const isNotNodeSchema = nodeData.find(item => !isNodeSchema(item));
if (isNotNodeSchema) {
return;
}
nodes = insertChildren(loc.target, nodeData, loc.detail.index); nodes = insertChildren(loc.target, nodeData, loc.detail.index);
} }
if (nodes) { if (nodes) {
@ -440,7 +445,7 @@ export class Designer {
designer._componentMetasMap.forEach((config, key) => { designer._componentMetasMap.forEach((config, key) => {
const metaData = config.getMetadata(); const metaData = config.getMetadata();
if (metaData.devMode === 'lowcode') { if (metaData.devMode === 'lowcode') {
maps[key] = metaData.schema; maps[key] = this.currentDocument?.simulator?.createComponent(metaData.schema!);
} else { } else {
const view = metaData.experimental?.view; const view = metaData.experimental?.view;
if (view) { if (view) {

View File

@ -149,4 +149,29 @@ export class DropLocation {
event, event,
}); });
} }
/**
* @deprecated
* vision
*/
getContainer() {
return this.target;
}
/**
* @deprecated
* vision
*/
getInsertion() {
if (!this.detail) {
return null;
}
if (this.detail.type === 'Children') {
if (this.detail.index <= 0) {
return null;
}
return this.target.children.get(this.detail.index - 1);
}
return (this.detail as any)?.near?.node;
}
} }

View File

@ -228,6 +228,9 @@ export class SettingTopEntry implements SettingEntry {
/** /**
* @deprecated * @deprecated
*/ */
get node() {
return this.getNode();
}
getNode() { getNode() {
return this.nodes[0]; return this.nodes[0];
} }

View File

@ -9,10 +9,13 @@ function getHotterFromSetter(setter) {
} }
function getTransducerFromSetter(setter) { function getTransducerFromSetter(setter) {
return setter && ( return (
setter.transducer || setter.Transducer (setter &&
|| (setter.type && (setter.type.transducer || setter.type.Transducer)) (setter.transducer ||
) || null; // eslint-disable-line setter.Transducer ||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
null
); // eslint-disable-line
} }
function combineTransducer(transducer, arr, context) { function combineTransducer(transducer, arr, context) {
@ -49,11 +52,7 @@ export class Transducer {
setter = getSetter(setter)?.component; setter = getSetter(setter)?.component;
} }
this.setterTransducer = combineTransducer( this.setterTransducer = combineTransducer(getTransducerFromSetter(setter), getHotterFromSetter(setter), context);
getTransducerFromSetter(setter),
getHotterFromSetter(setter),
context,
);
this.context = context; this.context = context;
} }

View File

@ -1,5 +1,5 @@
import { computed, obx } from '@ali/lowcode-editor-core'; import { computed, obx } from '@ali/lowcode-editor-core';
import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema } from '@ali/lowcode-types'; import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema, PageSchema } from '@ali/lowcode-types';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { Project } from '../project'; import { Project } from '../project';
import { ISimulatorHost } from '../simulator'; import { ISimulatorHost } from '../simulator';
@ -11,6 +11,7 @@ import { History } from './history';
import { TransformStage } from './node'; import { TransformStage } from './node';
import { uniqueId } from '@ali/lowcode-utils'; import { uniqueId } from '@ali/lowcode-utils';
import { ModalNodesManager } from './node'; import { ModalNodesManager } from './node';
import { foreachReverse } from '../utils/tree';
export type GetDataType<T, NodeType> = T extends undefined export type GetDataType<T, NodeType> = T extends undefined
? NodeType extends { ? NodeType extends {
@ -20,20 +21,20 @@ export type GetDataType<T, NodeType> = T extends undefined
: any : any
: T; : T;
export interface ComponentMap { export interface ComponentMap {
componentName: string; componentName: string;
package: string; package: string;
version?: string; version?: string;
destructuring?: boolean; destructuring?: boolean;
exportName?: string; exportName?: string;
subName?: string; subName?: string;
} }
export class DocumentModel { export class DocumentModel {
/** /**
* Page/Component/Block * Page/Component/Block
*/ */
readonly rootNode: RootNode; rootNode: RootNode | null;
/** /**
* *
*/ */
@ -51,7 +52,7 @@ export class DocumentModel {
*/ */
readonly modalNodesManager: ModalNodesManager; readonly modalNodesManager: ModalNodesManager;
private nodesMap = new Map<string, Node>(); private _nodesMap = new Map<string, Node>();
@obx.val private nodes = new Set<Node>(); @obx.val private nodes = new Set<Node>();
private seqId = 0; private seqId = 0;
private emitter: EventEmitter; private emitter: EventEmitter;
@ -69,6 +70,10 @@ export class DocumentModel {
return this.project.simulator; return this.project.simulator;
} }
get nodesMap(): Map<string, Node> {
return this._nodesMap;
}
get fileName(): string { get fileName(): string {
return this.rootNode.getExtraProp('fileName')?.getAsString() || this.id; return this.rootNode.getExtraProp('fileName')?.getAsString() || this.id;
} }
@ -102,6 +107,9 @@ export class DocumentModel {
this._blank = true; this._blank = true;
} }
// 兼容 vision
this.id = project.getSchema()?.id || this.id;
this.rootNode = this.createNode<RootNode>( this.rootNode = this.createNode<RootNode>(
schema || { schema || {
componentName: 'Page', componentName: 'Page',
@ -140,14 +148,19 @@ export class DocumentModel {
* id * id
*/ */
nextId() { nextId() {
return this.id + (++this.seqId).toString(36).toLocaleLowerCase(); let id;
do {
id = 'node_' + (this.id.slice(-10) + (++this.seqId).toString(36)).toLocaleLowerCase();
} while (this.nodesMap.get(id))
return id;
} }
/** /**
* id * id
*/ */
getNode(id: string): Node | null { getNode(id: string): Node | null {
return this.nodesMap.get(id) || null; return this._nodesMap.get(id) || null;
} }
/** /**
@ -201,13 +214,13 @@ export class DocumentModel {
// todo: this.activeNodes?.push(node); // todo: this.activeNodes?.push(node);
} }
const origin = this.nodesMap.get(node.id); const origin = this._nodesMap.get(node.id);
if (origin && origin !== node) { if (origin && origin !== node) {
// almost will not go here, ensure the id is unique // almost will not go here, ensure the id is unique
origin.internalSetWillPurge(); origin.internalSetWillPurge();
} }
this.nodesMap.set(node.id, node); this._nodesMap.set(node.id, node);
this.nodes.add(node); this.nodes.add(node);
this.emitter.emit('nodecreate', node); this.emitter.emit('nodecreate', node);
@ -254,14 +267,16 @@ export class DocumentModel {
/** /**
* *
*/ */
internalRemoveAndPurgeNode(node: Node) { internalRemoveAndPurgeNode(node: Node, useMutator = false) {
if (!this.nodes.has(node)) { if (!this.nodes.has(node)) {
return; return;
} }
this.nodesMap.delete(node.id); node.remove(useMutator);
}
unlinkNode(node: Node) {
this.nodes.delete(node); this.nodes.delete(node);
this.selection.remove(node.id); this._nodesMap.delete(node.id);
node.remove();
} }
@obx.ref private _dropLocation: DropLocation | null = null; @obx.ref private _dropLocation: DropLocation | null = null;
@ -305,20 +320,23 @@ export class DocumentModel {
* schema * schema
*/ */
get schema(): RootSchema { get schema(): RootSchema {
return this.rootNode.schema as any; return this.rootNode?.schema as any;
} }
import(schema: RootSchema, checkId = false) { import(schema: RootSchema, checkId = false) {
// TODO: do purge // TODO: 暂时用饱和式删除,原因是 Slot 节点并不是树节点,无法正常递归删除
this.nodes.forEach(node => { this.nodes.forEach(node => {
this.destroyNode(node); this.internalRemoveAndPurgeNode(node, true);
}); });
this.rootNode.import(schema as any, checkId); // foreachReverse(this.rootNode?.children, (node: Node) => {
// this.internalRemoveAndPurgeNode(node, true);
// });
this.rootNode?.import(schema as any, checkId);
// todo: select added and active track added // todo: select added and active track added
} }
export(stage: TransformStage = TransformStage.Serilize) { export(stage: TransformStage = TransformStage.Serilize) {
return this.rootNode.export(stage); return this.rootNode?.export(stage);
} }
/** /**
@ -427,12 +445,16 @@ export class DocumentModel {
* *
*/ */
remove() { remove() {
// this.project.removeDocument(this); this.designer.postEvent('document.remove', { id: this.id });
// todo: ... this.purge();
this.project.removeDocument(this);
} }
purge() { purge() {
// todo: this.rootNode?.purge();
this.nodes.clear();
this._nodesMap.clear();
this.rootNode = null;
} }
checkNesting(dropTarget: ParentalNode, dragObject: DragNodeObject | DragNodeDataObject): boolean { checkNesting(dropTarget: ParentalNode, dragObject: DragNodeObject | DragNodeDataObject): boolean {
@ -551,7 +573,7 @@ export class DocumentModel {
const componentsMap: ComponentMap[] = []; const componentsMap: ComponentMap[] = [];
// 组件去重 // 组件去重
const map: any = {}; const map: any = {};
for (let node of this.nodesMap.values()) { for (let node of this._nodesMap.values()) {
const { componentName } = node || {}; const { componentName } = node || {};
if (!map[componentName] && node?.componentMeta?.npm?.package) { if (!map[componentName] && node?.componentMeta?.npm?.package) {
map[componentName] = true; map[componentName] = true;
@ -610,3 +632,7 @@ export class DocumentModel {
export function isDocumentModel(obj: any): obj is DocumentModel { export function isDocumentModel(obj: any): obj is DocumentModel {
return obj && obj.rootNode; return obj && obj.rootNode;
} }
export function isPageSchema(obj: any): obj is PageSchema {
return obj?.componentName === 'Page';
}

View File

@ -36,8 +36,6 @@ export class History {
this.obx = autorun(() => { this.obx = autorun(() => {
const data = logger(); const data = logger();
// TODO: remove this line
console.info('log');
if (this.justWokeup) { if (this.justWokeup) {
this.justWokeup = false; this.justWokeup = false;
return; return;

View File

@ -4,6 +4,7 @@ import { TransformStage } from './transform-stage';
import { NodeData, isNodeSchema } from '@ali/lowcode-types'; import { NodeData, isNodeSchema } from '@ali/lowcode-types';
import { shallowEqual } from '@ali/lowcode-utils'; import { shallowEqual } from '@ali/lowcode-utils';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { foreachReverse } from '../../utils/tree';
export class NodeChildren { export class NodeChildren {
@obx.val private children: Node[]; @obx.val private children: Node[];
@ -13,9 +14,10 @@ export class NodeChildren {
this.children = (Array.isArray(data) ? data : [data]).map(child => { this.children = (Array.isArray(data) ? data : [data]).map(child => {
return this.owner.document.createNode(child); return this.owner.document.createNode(child);
}); });
} }
interalInitParent() { internalInitParent() {
this.children.forEach(child => child.internalSetParent(this.owner)); this.children.forEach(child => child.internalSetParent(this.owner));
} }
@ -55,7 +57,7 @@ export class NodeChildren {
} }
this.children = children; this.children = children;
this.interalInitParent(); this.internalInitParent();
if (!shallowEqual(children, originChildren)) { if (!shallowEqual(children, originChildren)) {
this.emitter.emit('change'); this.emitter.emit('change');
} }
@ -63,7 +65,7 @@ export class NodeChildren {
/** /**
* @deprecated * @deprecated
* @param nodes * @param nodes
*/ */
concat(nodes: Node[]) { concat(nodes: Node[]) {
return this.children.concat(nodes); return this.children.concat(nodes);
@ -91,24 +93,58 @@ export class NodeChildren {
return this.children.length; return this.children.length;
} }
private purged = false;
/** /**
* *
*/ */
delete(node: Node, purge = false, useMutator = true): boolean { purge(useMutator = true) {
if (this.purged) {
return;
}
this.purged = true;
this.children.forEach((child) => {
child.purge(useMutator);
});
}
unlinkChild(node: Node) {
const i = this.children.indexOf(node); const i = this.children.indexOf(node);
if (i < 0) { if (i < 0) {
return false; return false;
} }
const deleted = this.children.splice(i, 1)[0]; this.children.splice(i, 1);
}
/**
*
*/
delete(node: Node, purge = false, useMutator = true): boolean {
if (node.isParental()) {
foreachReverse(node.children, (subNode: Node) => {
subNode.remove(useMutator, purge);
});
}
if (purge) { if (purge) {
// should set parent null // should set parent null
deleted.internalSetParent(null, useMutator); node.internalSetParent(null, useMutator);
deleted.purge(useMutator); try {
node.purge(useMutator);
} catch(err) {
console.error(err);
}
} }
const document = node.document;
document.unlinkNode(node);
document.selection.remove(node.id);
document.destroyNode(node);
this.emitter.emit('change'); this.emitter.emit('change');
const i = this.children.indexOf(node);
if (useMutator) { if (useMutator) {
this.reportModified(node, this.owner, {type: 'remove', removeIndex: i, removeNode: node}); this.reportModified(node, this.owner, {type: 'remove', removeIndex: i, removeNode: node});
} }
if (i < 0) {
return false;
}
this.children.splice(i, 1);
return false; return false;
} }
@ -235,7 +271,6 @@ export class NodeChildren {
return fn(child, index); return fn(child, index);
}); });
} }
every(fn: (item: Node, index: number) => any): boolean { every(fn: (item: Node, index: number) => any): boolean {
return this.children.every((child, index) => fn(child, index)); return this.children.every((child, index) => fn(child, index));
} }
@ -248,6 +283,10 @@ export class NodeChildren {
return this.children.filter(fn); return this.children.filter(fn);
} }
find(fn: (item: Node, index: number) => Node) {
return this.children.find(fn);
}
mergeChildren(remover: () => any, adder: (children: Node[]) => NodeData[] | null, sorter: () => any) { mergeChildren(remover: () => any, adder: (children: Node[]) => NodeData[] | null, sorter: () => any) {
let changed = false; let changed = false;
if (remover) { if (remover) {
@ -290,18 +329,6 @@ export class NodeChildren {
}; };
} }
private purged = false;
/**
*
*/
purge(useMutator = true) {
if (this.purged) {
return;
}
this.purged = true;
this.children.forEach((child) => child.purge(useMutator));
}
get [Symbol.toStringTag]() { get [Symbol.toStringTag]() {
// 保证向前兼容性 // 保证向前兼容性
return 'Array'; return 'Array';
@ -327,7 +354,7 @@ export class NodeChildren {
try { try {
callbacks?.onSubtreeModified.call(node, owner, options); callbacks?.onSubtreeModified.call(node, owner, options);
} catch (e) { } catch (e) {
console.error('error when excute experimental.callbacks.onNodeAdd', e); console.error('error when excute experimental.callbacks.onSubtreeModified', e);
} }
} }

View File

@ -6,7 +6,6 @@ import {
PropsMap, PropsMap,
PropsList, PropsList,
NodeData, NodeData,
TitleContent,
I18nData, I18nData,
SlotSchema, SlotSchema,
PageSchema, PageSchema,
@ -149,16 +148,19 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
constructor(readonly document: DocumentModel, nodeSchema: Schema) { constructor(readonly document: DocumentModel, nodeSchema: Schema) {
const { componentName, id, children, props, ...extras } = nodeSchema; const { componentName, id, children, props, ...extras } = nodeSchema;
this.id = id || `node_${document.nextId()}`; this.id = id || document.nextId();
this.componentName = componentName; this.componentName = componentName;
if (this.componentName === 'Leaf') { if (this.componentName === 'Leaf') {
this.props = new Props(this, { this.props = new Props(this, {
children: isDOMText(children) || isJSExpression(children) ? children : '', children: isDOMText(children) || isJSExpression(children) ? children : '',
}); });
} else { } else {
// 这里 props 被初始化两次,一次 new一次 importnew 的实例需要给 propsReducer 的钩子去使用,
// import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug
// 所以在 props 里会对 new / import 做一些区别化的解析
this.props = new Props(this, props, extras); this.props = new Props(this, props, extras);
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children)); this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
this._children.interalInitParent(); this._children.internalInitParent();
this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {})); this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {}));
this.setupAutoruns(); this.setupAutoruns();
} }
@ -259,14 +261,15 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return; return;
} }
// 解除老的父子关系,但不需要真的删除节点
if (this._parent) { if (this._parent) {
if (this.isSlot()) { if (this.isSlot()) {
this._parent.removeSlot(this, false); this._parent.unlinkSlot(this);
} else { } else {
this._parent.children.delete(this, false, useMutator); this._parent.children.unlinkChild(this);
} }
} }
// 建立新的父子关系
this._parent = parent; this._parent = parent;
if (parent) { if (parent) {
this.document.removeWillPurge(this); this.document.removeWillPurge(this);
@ -299,12 +302,12 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
/** /**
* *
*/ */
remove(useMutator = true) { remove(useMutator = true, purge = true) {
if (this.parent) { if (this.parent) {
if (this.isSlot()) { if (this.isSlot()) {
this.parent.removeSlot(this, true); this.parent.removeSlot(this, purge);
} else { } else {
this.parent.children.delete(this, true, useMutator); this.parent.children.delete(this, purge, useMutator);
} }
} }
} }
@ -396,9 +399,23 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return v != null && v !== '' && v !== true; return v != null && v !== '' && v !== true;
} }
/**
* has loop when 1. loop is validArray with length > 1 ; OR 2. loop is variable object
* @return boolean, has loop config or not
*/
@computed hasLoop() { @computed hasLoop() {
const v = this.getExtraProp('loop', false)?.getValue(); const value = this.getExtraProp('loop', false)?.getValue();
return v != null && v !== ''; if (value === undefined || value === null) {
return false;
}
if (Array.isArray(value) && value.length > 0) {
return true;
}
if (isJSExpression(value)) {
return true;
}
return false;
} }
wrapWith(schema: Schema) { wrapWith(schema: Schema) {
@ -635,20 +652,30 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return comparePosition(this, otherNode); return comparePosition(this, otherNode);
} }
/** unlinkSlot(slotNode: Node) {
* Slot节点
*/
removeSlot(slotNode: Node, purge = false): boolean {
const i = this._slots.indexOf(slotNode); const i = this._slots.indexOf(slotNode);
if (i < 0) { if (i < 0) {
return false; return false;
} }
const deleted = this._slots.splice(i, 1)[0]; this._slots.splice(i, 1);
}
/**
* Slot节点
*/
removeSlot(slotNode: Node, purge = false): boolean {
if (purge) { if (purge) {
// should set parent null // should set parent null
deleted.internalSetParent(null); slotNode?.internalSetParent(null, false);
deleted.purge(); slotNode?.purge();
} }
this.document.unlinkNode(slotNode);
this.document.selection.remove(slotNode.id);
const i = this._slots.indexOf(slotNode);
if (i < 0) {
return false;
}
this._slots.splice(i, 1);
return false; return false;
} }
@ -669,7 +696,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
/** /**
* *
* @param node * @param node
*/ */
removeChild(node: Node) { removeChild(node: Node) {
this.children?.delete(node); this.children?.delete(node);
@ -689,19 +716,9 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
if (this.purged) { if (this.purged) {
return; return;
} }
if (this._parent) {
// should remove thisNode before purge
this.remove(useMutator);
return;
}
this.purged = true; this.purged = true;
if (this.isParental()) {
this.children.purge(useMutator);
}
this.autoruns?.forEach((dispose) => dispose()); this.autoruns?.forEach((dispose) => dispose());
this.props.purge(); this.props.purge();
this.document.internalRemoveAndPurgeNode(this);
this.document.destroyNode(this); this.document.destroyNode(this);
} }
@ -724,6 +741,12 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return this.componentName; return this.componentName;
} }
/**
* @deprecated
*/
insert(node: Node, ref?: Node, useMutator = true) {
this.insertAfter(node, ref, useMutator);
}
insertBefore(node: Node, ref?: Node, useMutator = true) { insertBefore(node: Node, ref?: Node, useMutator = true) {
this.children?.insert(node, ref ? ref.index : null, useMutator); this.children?.insert(node, ref ? ref.index : null, useMutator);
} }
@ -846,7 +869,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
if (this.parent) { if (this.parent) {
return this.parent.getSuitablePlace(node, ref); return this.parent.getSuitablePlace(node, ref);
} }
return null; return null;
} }
/** /**

View File

@ -22,6 +22,37 @@ export class Prop implements IPropParent {
readonly isProp = true; readonly isProp = true;
readonly owner: Node; readonly owner: Node;
private stash: PropStash | undefined;
/**
*
*/
@obx key: string | number | undefined;
/**
*
*/
@obx spread: boolean;
readonly props: Props;
readonly options: any;
constructor(
public parent: IPropParent,
value: CompositeValue | UNSET = UNSET,
key?: string | number,
spread = false,
options = {},
) {
this.owner = parent.owner;
this.props = parent.props;
this.key = key;
this.spread = spread;
this.options = options;
if (value !== UNSET) {
this.setValue(value);
}
}
/** /**
* @see SettingTarget * @see SettingTarget
*/ */
@ -65,6 +96,11 @@ export class Prop implements IPropParent {
export(stage: TransformStage = TransformStage.Save): CompositeValue | UNSET { export(stage: TransformStage = TransformStage.Save): CompositeValue | UNSET {
const type = this._type; const type = this._type;
// 在设计器里,所有组件都需要展示
if (stage === TransformStage.Render && this.key === '___condition___') {
return true;
}
if (type === 'unset') { if (type === 'unset') {
// return UNSET; @康为 之后 review 下这块改造 // return UNSET; @康为 之后 review 下这块改造
return undefined; return undefined;
@ -192,7 +228,7 @@ export class Prop implements IPropParent {
} else if (Array.isArray(val)) { } else if (Array.isArray(val)) {
this._type = 'list'; this._type = 'list';
} else if (isPlainObject(val)) { } else if (isPlainObject(val)) {
if (isJSSlot(val)) { if (isJSSlot(val) && this.options.propsMode !== 'init') {
this.setAsSlot(val); this.setAsSlot(val);
return; return;
} }
@ -342,34 +378,6 @@ export class Prop implements IPropParent {
return this._maps; return this._maps;
} }
private stash: PropStash | undefined;
/**
*
*/
@obx key: string | number | undefined;
/**
*
*/
@obx spread: boolean;
readonly props: Props;
constructor(
public parent: IPropParent,
value: CompositeValue | UNSET = UNSET,
key?: string | number,
spread = false,
) {
this.owner = parent.owner;
this.props = parent.props;
if (value !== UNSET) {
this.setValue(value);
}
this.key = key;
this.spread = spread;
}
/** /**
* *
* @param stash * @param stash

View File

@ -57,9 +57,9 @@ export class Props implements IPropParent {
constructor(readonly owner: Node, value?: PropsMap | PropsList | null, extras?: object) { constructor(readonly owner: Node, value?: PropsMap | PropsList | null, extras?: object) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
this.type = 'list'; this.type = 'list';
this.items = value.map(item => new Prop(this, item.value, item.name, item.spread)); this.items = value.map(item => new Prop(this, item.value, item.name, item.spread, { propsMode: 'init' }));
} else if (value != null) { } else if (value != null) {
this.items = Object.keys(value).map(key => new Prop(this, value[key], key)); this.items = Object.keys(value).map(key => new Prop(this, value[key], key, false, { propsMode: 'init' }));
} }
if (extras) { if (extras) {
Object.keys(extras).forEach(key => { Object.keys(extras).forEach(key => {

View File

@ -1,7 +1,7 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { obx, computed } from '@ali/lowcode-editor-core'; import { obx, computed } from '@ali/lowcode-editor-core';
import { Designer } from '../designer'; import { Designer } from '../designer';
import { DocumentModel, isDocumentModel } from '../document'; import { DocumentModel, isDocumentModel, isPageSchema } from '../document';
import { ProjectSchema, RootSchema } from '@ali/lowcode-types'; import { ProjectSchema, RootSchema } from '@ali/lowcode-types';
import { ISimulatorHost } from '../simulator'; import { ISimulatorHost } from '../simulator';
@ -50,6 +50,15 @@ export class Project {
}; };
} }
/**
* document的schema,render
* @param schema
*/
setSchema(schema?: ProjectSchema){
let doc = this.documents.find((doc) => doc.actived);
doc && doc.import(schema?.componentsTree[0]);
}
/** /**
* schema * schema
* *
@ -65,6 +74,7 @@ export class Project {
...schema, ...schema,
}; };
this.config = schema?.config; this.config = schema?.config;
debugger;
if (autoOpen) { if (autoOpen) {
if (autoOpen === true) { if (autoOpen === true) {
@ -94,6 +104,14 @@ export class Project {
this.documents.forEach((doc) => doc.remove()); this.documents.forEach((doc) => doc.remove());
} }
removeDocument(doc: DocumentModel) {
const index = this.documents.indexOf(doc);
if (index < 0) {
return;
}
this.documents.splice(index, 1);
}
/** /**
* *
*/ */
@ -176,6 +194,11 @@ export class Project {
if (isDocumentModel(doc)) { if (isDocumentModel(doc)) {
return doc.open(); return doc.open();
} else if (isPageSchema(doc)) {
const foundDoc = this.documents.find(curDoc => curDoc?.rootNode?.id && curDoc?.rootNode?.id === doc?.id);
if (foundDoc) {
foundDoc.remove();
}
} }
doc = this.createDocument(doc); doc = this.createDocument(doc);

View File

@ -0,0 +1,7 @@
import { NodeChildren } from '../document/node/node-children';
export function foreachReverse(arr: NodeChildren, fn: Function, context: any = {}) {
for (let i = arr.length - 1; i >= 0; i--) {
fn.call(context, arr.get(i));
}
}

View File

@ -3,6 +3,156 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.0.8-0"></a>
## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.36...@ali/lowcode-editor-core@1.0.8-0) (2020-09-09)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30))
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.6-0...@ali/lowcode-editor-core@1.0.7-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.34...@ali/lowcode-editor-core@1.0.6-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.8.36"></a>
## [0.8.36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.35...@ali/lowcode-editor-core@0.8.36) (2020-09-03)
<a name="0.8.35"></a>
## [0.8.35](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.34...@ali/lowcode-editor-core@0.8.35) (2020-09-03)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30))
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.4-0...@ali/lowcode-editor-core@1.0.5-0) (2020-08-20)
<a name="0.8.34"></a>
## [0.8.34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.33...@ali/lowcode-editor-core@0.8.34) (2020-08-27)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.8.33"></a>
## [0.8.33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.32...@ali/lowcode-editor-core@0.8.33) (2020-08-24)
### Features
* 编辑器 hooks 能力实现 ([f3ac23b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f3ac23b))
<a name="0.8.32"></a>
## [0.8.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.30...@ali/lowcode-editor-core@0.8.32) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="1.0.4-0"></a>
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.3-0...@ali/lowcode-editor-core@1.0.4-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.2-0...@ali/lowcode-editor-core@1.0.3-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="1.0.2-0"></a>
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.1-0...@ali/lowcode-editor-core@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="1.0.1-0"></a>
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.30...@ali/lowcode-editor-core@1.0.1-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.13.0...@ali/lowcode-editor-core@1.0.0) (2020-08-17)
<a name="0.8.30"></a>
## [0.8.30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.29...@ali/lowcode-editor-core@0.8.30) (2020-08-19)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.12.0...@ali/lowcode-editor-core@0.13.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.10.0...@ali/lowcode-editor-core@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.10.0...@ali/lowcode-editor-core@0.11.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.9.0...@ali/lowcode-editor-core@0.10.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.9.0"></a>
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.28...@ali/lowcode-editor-core@0.9.0) (2020-08-14)
**Note:** Version bump only for package @ali/lowcode-editor-core
<a name="0.8.28"></a> <a name="0.8.28"></a>
## [0.8.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.27...@ali/lowcode-editor-core@0.8.28) (2020-08-04) ## [0.8.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.27...@ali/lowcode-editor-core@0.8.28) (2020-08-04)

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-editor-core", "name": "@ali/lowcode-editor-core",
"version": "0.8.28", "version": "1.0.8-0",
"description": "Core Api for Ali lowCode engine", "description": "Core Api for Ali lowCode engine",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@ -15,14 +15,14 @@
"cloud-build": "build-scripts build --skip-demo" "cloud-build": "build-scripts build --skip-demo"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-types": "^0.8.14", "@ali/lowcode-types": "^1.0.8-0",
"@ali/lowcode-utils": "^0.8.16", "@ali/lowcode-utils": "^1.0.8-0",
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@recore/obx": "^1.0.9", "@recore/obx": "^1.0.9",
"@recore/obx-react": "^1.0.8", "@recore/obx-react": "^1.0.8",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"debug": "^4.1.1", "debug": "^4.1.1",
"intl-messageformat": "^8.3.1", "intl-messageformat": "^9.3.1",
"power-di": "^2.2.4", "power-di": "^2.2.4",
"react": "^16", "react": "^16",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",

View File

@ -1,13 +1,22 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { IEditor, EditorConfig, PluginClassSet, KeyType, GetOptions, GetReturnType } from '@ali/lowcode-types'; import {
IEditor,
EditorConfig,
PluginClassSet,
KeyType,
GetOptions,
GetReturnType,
HookConfig,
} from '@ali/lowcode-types';
import { IocContext, RegisterOptions } from './di'; import { IocContext, RegisterOptions } from './di';
import { globalLocale } from './intl'; import { globalLocale } from './intl';
import * as utils from './utils';
import { tipHandler } from './widgets/tip/tip-handler';
EventEmitter.defaultMaxListeners = 100; EventEmitter.defaultMaxListeners = 100;
const NOT_FOUND = Symbol.for('not_found'); const NOT_FOUND = Symbol.for('not_found');
import * as utils from './utils';
export class Editor extends EventEmitter implements IEditor { export class Editor extends EventEmitter implements IEditor {
/** /**
* Ioc Container * Ioc Container
@ -22,6 +31,8 @@ export class Editor extends EventEmitter implements IEditor {
readonly utils = utils; readonly utils = utils;
private hooks: HookConfig[] = [];
get<T = undefined, KeyOrType = any>(keyOrType: KeyOrType, opt?: GetOptions): GetReturnType<T, KeyOrType> | undefined { get<T = undefined, KeyOrType = any>(keyOrType: KeyOrType, opt?: GetOptions): GetReturnType<T, KeyOrType> | undefined {
const x = this.context.get<T, KeyOrType>(keyOrType, opt); const x = this.context.get<T, KeyOrType>(keyOrType, opt);
if (x === NOT_FOUND) { if (x === NOT_FOUND) {
@ -79,15 +90,19 @@ export class Editor extends EventEmitter implements IEditor {
async init(config?: EditorConfig, components?: PluginClassSet): Promise<any> { async init(config?: EditorConfig, components?: PluginClassSet): Promise<any> {
this.config = config || {}; this.config = config || {};
this.components = components || {}; this.components = components || {};
const { shortCuts = [], lifeCycles } = this.config; const { shortCuts = [], hooks = [], lifeCycles } = this.config;
this.emit('editor.beforeInit'); this.emit('editor.beforeInit');
const init = (lifeCycles && lifeCycles.init) || ((): void => {}); const init = (lifeCycles && lifeCycles.init) || ((): void => {});
try { try {
await init(this); await init(this);
// 注册快捷键 // 注册快捷键
// registShortCuts(shortCuts, this); // registShortCuts(shortCuts, this);
// 注册 hooks
this.registerHooks(hooks);
this.emit('editor.afterInit'); this.emit('editor.afterInit');
return true; return true;
} catch (err) { } catch (err) {
console.error(err); console.error(err);
@ -101,6 +116,9 @@ export class Editor extends EventEmitter implements IEditor {
try { try {
const { shortCuts = [], lifeCycles = {} } = this.config; const { shortCuts = [], lifeCycles = {} } = this.config;
// unRegistShortCuts(shortCuts); // unRegistShortCuts(shortCuts);
this.unregisterHooks();
if (lifeCycles.destroy) { if (lifeCycles.destroy) {
lifeCycles.destroy(this); lifeCycles.destroy(this);
} }
@ -109,6 +127,30 @@ export class Editor extends EventEmitter implements IEditor {
} }
} }
initHooks = (hooks: HookConfig[]) => {
this.hooks = hooks.map((hook) => ({
...hook,
// 指定第一个参数为 editor
handler: hook.handler.bind(this, this),
}));
return this.hooks;
};
registerHooks = (hooks: HookConfig[]) => {
this.initHooks(hooks).forEach(({ message, type, handler }) => {
if (['on', 'once'].indexOf(type) !== -1) {
this[type](message, handler);
}
});
};
unregisterHooks = () => {
this.hooks.forEach(({ message, handler }) => {
this.removeListener(message, handler);
});
};
private waits = new Map< private waits = new Map<
KeyType, KeyType,
Array<{ Array<{

View File

@ -1,5 +1,5 @@
const publicPath = (document.currentScript as HTMLScriptElement).src.replace(/^(.*\/)[^/]+$/, '$1'); const publicPath = (document.currentScript as HTMLScriptElement)?.src.replace(/^(.*\/)[^/]+$/, '$1');
export function getPublicPath(): string { export function getPublicPath(): string {
return publicPath; return publicPath || '';
} }

View File

@ -6,6 +6,11 @@
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 4px; margin-right: 4px;
img {
width: 16px;
height: 16px;
filter: brightness(0) invert(1)
}
} }
&.only-icon { &.only-icon {
.lc-title-icon { .lc-title-icon {

View File

@ -3,40 +3,206 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="0.9.27"></a> <a name="1.0.8-0"></a>
## [0.9.27](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.26...@ali/lowcode-editor-preset-general@0.9.27) (2020-08-14) ## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.40...@ali/lowcode-editor-preset-general@1.0.8-0) (2020-09-09)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.6-0...@ali/lowcode-editor-preset-general@1.0.7-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.37...@ali/lowcode-editor-preset-general@1.0.6-0) (2020-09-02)
<a name="0.9.40"></a>
## [0.9.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.39...@ali/lowcode-editor-preset-general@0.9.40) (2020-09-08)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.39"></a>
## [0.9.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.38...@ali/lowcode-editor-preset-general@0.9.39) (2020-09-03)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.38"></a>
## [0.9.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.37...@ali/lowcode-editor-preset-general@0.9.38) (2020-09-03)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.4-0...@ali/lowcode-editor-preset-general@1.0.5-0) (2020-08-20)
<a name="0.9.37"></a>
## [0.9.37](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.36...@ali/lowcode-editor-preset-general@0.9.37) (2020-08-27)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general **Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.26"></a> <a name="0.9.36"></a>
## [0.9.26](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.25...@ali/lowcode-editor-preset-general@0.9.26) (2020-08-07) ## [0.9.36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.35...@ali/lowcode-editor-preset-general@0.9.36) (2020-08-26)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general **Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.25"></a> <a name="0.9.35"></a>
## [0.9.25](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.24...@ali/lowcode-editor-preset-general@0.9.25) (2020-08-06) ## [0.9.35](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.34...@ali/lowcode-editor-preset-general@0.9.35) (2020-08-24)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general **Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.24"></a> <a name="0.9.34"></a>
## [0.9.24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.23...@ali/lowcode-editor-preset-general@0.9.24) (2020-08-06) ## [0.9.34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.33...@ali/lowcode-editor-preset-general@0.9.34) (2020-08-23)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general **Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.23"></a> <a name="0.9.33"></a>
## [0.9.23](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.22...@ali/lowcode-editor-preset-general@0.9.23) (2020-08-06) ## [0.9.33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.32...@ali/lowcode-editor-preset-general@0.9.33) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="1.0.4-0"></a>
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.3-0...@ali/lowcode-editor-preset-general@1.0.4-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.2-0...@ali/lowcode-editor-preset-general@1.0.3-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="1.0.2-0"></a>
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.1-0...@ali/lowcode-editor-preset-general@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="1.0.1-0"></a>
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.32...@ali/lowcode-editor-preset-general@1.0.1-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.14.0...@ali/lowcode-editor-preset-general-beta@1.0.0) (2020-08-17)
<a name="0.9.32"></a>
## [0.9.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.31...@ali/lowcode-editor-preset-general@0.9.32) (2020-08-19)
### Features
* register-defaults 改为可选项 ([2195797](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2195797))
<a name="0.9.31"></a>
## [0.9.31](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.30...@ali/lowcode-editor-preset-general@0.9.31) (2020-08-19)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.30"></a>
## [0.9.30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.29...@ali/lowcode-editor-preset-general@0.9.30) (2020-08-19)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.29"></a>
## [0.9.29](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.28...@ali/lowcode-editor-preset-general@0.9.29) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
<a name="0.9.28"></a>
## [0.9.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.27...@ali/lowcode-editor-preset-general@0.9.28) (2020-08-14)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
<a name="0.14.0"></a>
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.13.0...@ali/lowcode-editor-preset-general-beta@0.14.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.11.0...@ali/lowcode-editor-preset-general-beta@0.13.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.11.0...@ali/lowcode-editor-preset-general-beta@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
<a name="0.11.0"></a>
# 0.11.0 (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.22...@ali/lowcode-editor-preset-general@0.10.0) (2020-08-14)

View File

@ -1,7 +1,6 @@
{ {
"name": "@ali/lowcode-editor-preset-general", "name": "@ali/lowcode-editor-preset-general",
"version": "0.9.27", "version": "1.0.8-0",
"private": true,
"description": "Ali General Editor Preset", "description": "Ali General Editor Preset",
"main": "lib/index.js", "main": "lib/index.js",
"files": [ "files": [
@ -15,12 +14,12 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@ali/lowcode-editor-core": "^0.8.28", "@ali/lowcode-editor-core": "^1.0.8-0",
"@ali/lowcode-editor-skeleton": "^0.8.48", "@ali/lowcode-editor-skeleton": "^1.0.8-0",
"@ali/lowcode-plugin-designer": "^0.9.42", "@ali/lowcode-plugin-designer": "^1.0.8-0",
"@ali/lowcode-plugin-outline-pane": "^0.8.48", "@ali/lowcode-plugin-outline-pane": "^1.0.8-0",
"@ali/lowcode-types": "^0.8.14", "@ali/lowcode-types": "^1.0.8-0",
"@ali/lowcode-utils": "^0.8.16", "@ali/lowcode-utils": "^1.0.8-0",
"@alifd/next": "^1.19.12", "@alifd/next": "^1.19.12",
"@alife/theme-lowcode-dark": "^0.1.0", "@alife/theme-lowcode-dark": "^0.1.0",
"@alife/theme-lowcode-light": "^0.1.0", "@alife/theme-lowcode-light": "^0.1.0",
@ -28,7 +27,7 @@
"react-dom": "^16.8.1" "react-dom": "^16.8.1"
}, },
"devDependencies": { "devDependencies": {
"@ali/lowcode-editor-setters": "^0.9.14", "@ali/lowcode-editor-setters": "^1.0.8-0",
"@alib/build-scripts": "^0.1.18", "@alib/build-scripts": "^0.1.18",
"@types/events": "^3.0.0", "@types/events": "^3.0.0",
"@types/react": "^16.8.3", "@types/react": "^16.8.3",

View File

@ -1,6 +1,6 @@
import { render } from 'react-dom'; import { render } from 'react-dom';
import { createElement } from 'react'; import { createElement } from 'react';
import { Workbench, Skeleton, SettingsPrimaryPane } from '@ali/lowcode-editor-skeleton'; import { Workbench, Skeleton, SettingsPrimaryPane, registerDefaults } from '@ali/lowcode-editor-skeleton';
import { globalContext, Editor } from '@ali/lowcode-editor-core'; import { globalContext, Editor } from '@ali/lowcode-editor-core';
import { Designer, LiveEditing, TransformStage, Node } from '@ali/lowcode-designer'; import { Designer, LiveEditing, TransformStage, Node } from '@ali/lowcode-designer';
import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane'; import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane';
@ -20,6 +20,7 @@ globalContext.register(editor, Editor);
export const skeleton = new Skeleton(editor); export const skeleton = new Skeleton(editor);
editor.set(Skeleton, skeleton); editor.set(Skeleton, skeleton);
editor.set('skeleton', skeleton); editor.set('skeleton', skeleton);
registerDefaults();
export const designer = new Designer({ editor: editor }); export const designer = new Designer({ editor: editor });
editor.set(Designer, designer); editor.set(Designer, designer);

View File

@ -30,7 +30,7 @@ export function liveEditingRule(target: EditingTarget) {
} }
const innerText = targetElement.innerText; const innerText = targetElement.innerText;
const propTarget = ['title', 'label', 'text', 'content'].find(prop => { const propTarget = ['title', 'label', 'text', 'content', 'children'].find(prop => {
return equalText(getText(node, prop), innerText); return equalText(getText(node, prop), innerText);
}); });

View File

@ -3,67 +3,233 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="0.8.43"></a> <a name="1.0.8-0"></a>
## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.42...@ali/lowcode-editor-preset-vision@0.8.43) (2020-08-14) ## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.57...@ali/lowcode-editor-preset-vision@1.0.8-0) (2020-09-09)
### Bug Fixes ### Bug Fixes
* createComponent 支持所有 schema ([7f946f5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7f946f5)) * 不应该限定 parent 才做解绑操作 ([2e616e3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2e616e3))
* upgradePropsReducer ([e68977f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e68977f)) * 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* vision 大包 window 指向问题 ([aa1b526](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aa1b526))
* 不对外暴露 Node ([05957ce](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/05957ce))
* 支持 AC 组件 ([c287bad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c287bad))
<a name="0.8.42"></a> <a name="1.0.7-0"></a>
## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.41...@ali/lowcode-editor-preset-vision@0.8.42) (2020-08-07) ## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.6-0...@ali/lowcode-editor-preset-vision@1.0.7-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.54...@ali/lowcode-editor-preset-vision@1.0.6-0) (2020-09-02)
<a name="0.8.57"></a>
## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.56...@ali/lowcode-editor-preset-vision@0.8.57) (2020-09-08)
### Bug Fixes ### Bug Fixes
* vision API 兼容 DockPane.getDocks() ([f72fb66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f72fb66)) * 移除 isInSimulator 函数 ([6370889](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6370889))
* 补全 packageName, 否则在组件面板会被隐藏 ([88e5008](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/88e5008))
<a name="0.8.56"></a>
## [0.8.56](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.55...@ali/lowcode-editor-preset-vision@0.8.56) (2020-09-03)
<a name="0.8.41"></a>
## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.40...@ali/lowcode-editor-preset-vision@0.8.41) (2020-08-06)
### Bug Fixes ### Bug Fixes
* fieldId 重复问题 ([e761b1a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e761b1a)) * 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 用户在动态修改 prototype 时也需要重新计算 meta ([66c21c0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/66c21c0))
<a name="0.8.40"></a> <a name="0.8.55"></a>
## [0.8.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.39...@ali/lowcode-editor-preset-vision@0.8.40) (2020-08-06) ## [0.8.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.54...@ali/lowcode-editor-preset-vision@0.8.55) (2020-09-03)
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.4-0...@ali/lowcode-editor-preset-vision@1.0.5-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="1.0.4-0"></a>
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.3-0...@ali/lowcode-editor-preset-vision@1.0.4-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.2-0...@ali/lowcode-editor-preset-vision@1.0.3-0) (2020-08-20)
<a name="0.8.54"></a>
## [0.8.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.53...@ali/lowcode-editor-preset-vision@0.8.54) (2020-08-27)
### Bug Fixes ### Bug Fixes
* 保存区块按钮渲染异常 ([33a7227](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/33a7227)) * 在 renderer 层面做 function component 包装,避免影响 rax 等其他场景 ([1f920dd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f920dd))
* 增加兼容 API ([2960446](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2960446)) * **editor-skeleton:** add canSetFixed prop to panel config ([1b57d5c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1b57d5c))
<a name="0.8.39"></a> <a name="0.8.53"></a>
## [0.8.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.38...@ali/lowcode-editor-preset-vision@0.8.39) (2020-08-06) ## [0.8.53](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.52...@ali/lowcode-editor-preset-vision@0.8.53) (2020-08-26)
### Bug Fixes ### Bug Fixes
* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24)) * 处理 function component 无法选中的问题,本质上是没有 ref ([fa94aab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fa94aab))
* 框架样式调整 ([58790c5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/58790c5))
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="1.0.2-0"></a>
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.1-0...@ali/lowcode-editor-preset-vision@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="1.0.1-0"></a>
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.49...@ali/lowcode-editor-preset-vision@1.0.1-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.13.0...@ali/lowcode-editor-preset-vision@1.0.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.12.0...@ali/lowcode-editor-preset-vision@0.13.0) (2020-08-17)
<a name="0.8.50"></a>
## [0.8.50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.49...@ali/lowcode-editor-preset-vision@0.8.50) (2020-08-20)
### Bug Fixes
* 兼容原来 prototype 的 componentName/view ([d542a40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d542a40))
<a name="0.8.49"></a>
## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.48...@ali/lowcode-editor-preset-vision@0.8.49) (2020-08-19)
### Bug Fixes
* 修复获取 currentPage 的逻辑 ([d8221db](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d8221db))
### Features
* register-defaults 改为可选项 ([2195797](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2195797))
<a name="0.8.48"></a>
## [0.8.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.47...@ali/lowcode-editor-preset-vision@0.8.48) (2020-08-19)
### Bug Fixes
* compatiableReducer 递归 ([e905928](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e905928))
<a name="0.8.47"></a>
## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.46...@ali/lowcode-editor-preset-vision@0.8.47) (2020-08-19)
### Bug Fixes
* currentPage.id 返回 formUuid ([775725d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/775725d))
* formUuid 可能不在 url 中 ([8657ab8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8657ab8))
* 区块组件无法删除 ([d936d2b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d936d2b))
<a name="0.8.46"></a>
## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.45...@ali/lowcode-editor-preset-vision@0.8.46) (2020-08-17)
### Bug Fixes
* fieldId 重复 ([5d64312](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5d64312))
* 页面加载之后就被标记位 isModified ([2840d27](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2840d27))
<a name="0.8.45"></a>
## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.44...@ali/lowcode-editor-preset-vision@0.8.45) (2020-08-14)
### Bug Fixes
* 兼容 rpx ([5050af7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5050af7))
<a name="0.8.44"></a>
## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.43...@ali/lowcode-editor-preset-vision@0.8.44) (2020-08-14)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.10.0...@ali/lowcode-editor-preset-vision@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.10.0...@ali/lowcode-editor-preset-vision@0.11.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.9.0...@ali/lowcode-editor-preset-vision@0.10.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="0.9.0"></a>
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.38...@ali/lowcode-editor-preset-vision@0.9.0) (2020-08-14)
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
<a name="0.8.38"></a> <a name="0.8.38"></a>
## [0.8.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.37...@ali/lowcode-editor-preset-vision@0.8.38) (2020-08-04) ## [0.8.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.37...@ali/lowcode-editor-preset-vision@0.8.38) (2020-08-04)

View File

@ -1,9 +1,9 @@
{ {
"name": "@ali/lowcode-editor-preset-vision", "name": "@ali/lowcode-editor-preset-vision",
"version": "0.8.43", "version": "1.0.8-0",
"private": true,
"description": "Vision Polyfill for Ali lowCode engine", "description": "Vision Polyfill for Ali lowCode engine",
"main": "lib/index.js", "main": "lib/index.js",
"private": true,
"files": [ "files": [
"dist", "dist",
"es", "es",
@ -15,11 +15,11 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@ali/lowcode-designer": "^0.9.42", "@ali/lowcode-designer": "^1.0.8-0",
"@ali/lowcode-editor-core": "^0.8.28", "@ali/lowcode-editor-core": "^1.0.8-0",
"@ali/lowcode-editor-skeleton": "^0.8.48", "@ali/lowcode-editor-skeleton": "^1.0.8-0",
"@ali/lowcode-plugin-designer": "^0.9.42", "@ali/lowcode-plugin-designer": "^1.0.8-0",
"@ali/lowcode-plugin-outline-pane": "^0.8.48", "@ali/lowcode-plugin-outline-pane": "^1.0.8-0",
"@ali/ve-i18n-util": "^2.0.0", "@ali/ve-i18n-util": "^2.0.0",
"@ali/ve-icons": "^4.1.9", "@ali/ve-icons": "^4.1.9",
"@ali/ve-less-variables": "2.0.3", "@ali/ve-less-variables": "2.0.3",

View File

@ -2,6 +2,7 @@ import lg from '@ali/vu-logger';
import { ComponentClass, ComponentType } from 'react'; import { ComponentClass, ComponentType } from 'react';
import Prototype, { isPrototype } from './prototype'; import Prototype, { isPrototype } from './prototype';
import { designer } from '../editor'; import { designer } from '../editor';
import { upgradeMetadata } from './upgrade-metadata';
import trunk from './trunk'; import trunk from './trunk';
function basename(name: string) { function basename(name: string) {
@ -69,8 +70,6 @@ export default class Bundle {
// invoke prototype mocker while the prototype does not exist // invoke prototype mocker while the prototype does not exist
Object.keys(this.viewsMap).forEach((viewName) => { Object.keys(this.viewsMap).forEach((viewName) => {
const test = this;
// console.log(test, viewName);
if (!this.prototypeList.find((proto) => proto.getComponentName() === viewName)) { if (!this.prototypeList.find((proto) => proto.getComponentName() === viewName)) {
const mockedPrototype = trunk.mockComponentPrototype(this.viewsMap[viewName]); const mockedPrototype = trunk.mockComponentPrototype(this.viewsMap[viewName]);
if (mockedPrototype) { if (mockedPrototype) {
@ -127,6 +126,8 @@ export default class Bundle {
*/ */
if (bundles.length >= 2) { if (bundles.length >= 2) {
const prototype = bundles[0]; const prototype = bundles[0];
const metadata = upgradeMetadata({ ...prototype.options, packageName: prototype.packageName });
prototype.meta = designer.createComponentMeta(metadata);
const prototypeView = bundles[1]; const prototypeView = bundles[1];
prototype.setView(prototypeView); prototype.setView(prototypeView);
this.registerPrototype(prototype); this.registerPrototype(prototype);

View File

@ -1,5 +1,5 @@
import { ComponentType, ReactElement } from 'react'; import { ComponentType, ReactElement, Component, FunctionComponent } from 'react';
import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem, isI18nData } from '@ali/lowcode-types'; import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem } from '@ali/lowcode-types';
import { import {
ComponentMeta, ComponentMeta,
addBuiltinComponentAction, addBuiltinComponentAction,
@ -7,6 +7,7 @@ import {
registerMetadataTransducer, registerMetadataTransducer,
TransformStage, TransformStage,
} from '@ali/lowcode-designer'; } from '@ali/lowcode-designer';
import { intl } from '@ali/lowcode-editor-core';
import { import {
OldPropConfig, OldPropConfig,
OldPrototypeConfig, OldPrototypeConfig,
@ -15,9 +16,8 @@ import {
upgradePropConfig, upgradePropConfig,
upgradeConfigure, upgradeConfigure,
} from './upgrade-metadata'; } from './upgrade-metadata';
import { intl } from '@ali/lowcode-editor-core';
import { designer } from '../editor'; import { designer } from '../editor';
import { uniqueId } from '@ali/lowcode-utils';
const GlobalPropsConfigure: Array<{ const GlobalPropsConfigure: Array<{
position: string; position: string;
@ -220,9 +220,14 @@ class Prototype {
readonly isPrototype = true; readonly isPrototype = true;
readonly meta: ComponentMeta; readonly meta: ComponentMeta;
readonly options: OldPrototypeConfig | ComponentMetadata; readonly options: OldPrototypeConfig | ComponentMetadata;
get componentName() {
return this.getId();
}
get packageName() { get packageName() {
return this.meta.npm?.package; return this.meta.npm?.package;
} }
// 兼容原 vision 用法
view: ComponentType | undefined;
constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) { constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) {
if (lookup) { if (lookup) {
@ -322,6 +327,7 @@ class Prototype {
} }
setView(view: ComponentType<any>) { setView(view: ComponentType<any>) {
this.view = view;
const metadata = this.meta.getMetadata(); const metadata = this.meta.getMetadata();
if (!metadata.experimental) { if (!metadata.experimental) {
metadata.experimental = { metadata.experimental = {
@ -334,6 +340,7 @@ class Prototype {
getView() { getView() {
return ( return (
this.view ||
this.meta.getMetadata().experimental?.view || this.meta.getMetadata().experimental?.view ||
designer.currentDocument?.simulator?.getComponent(this.getComponentName()) designer.currentDocument?.simulator?.getComponent(this.getComponentName())
); );

View File

@ -1,8 +1,9 @@
import { ReactElement, ComponentType } from 'react'; import { ReactElement, ComponentType } from 'react';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { registerSetter, RegisteredSetter, getSetter } from '@ali/lowcode-editor-core'; import { registerSetter, RegisteredSetter, getSetter } from '@ali/lowcode-editor-core';
import Bundle from './bundle'; import lg from '@ali/vu-logger';
import { CustomView } from '@ali/lowcode-types'; import { CustomView } from '@ali/lowcode-types';
import Bundle from './bundle';
import Prototype from './prototype'; import Prototype from './prototype';
export class Trunk { export class Trunk {

View File

@ -9,7 +9,8 @@ import bus from './bus';
import { VE_EVENTS } from './base/const'; import { VE_EVENTS } from './base/const';
import DesignerPlugin from '@ali/lowcode-plugin-designer'; import DesignerPlugin from '@ali/lowcode-plugin-designer';
import { Skeleton, SettingsPrimaryPane } from '@ali/lowcode-editor-skeleton'; import { Skeleton, SettingsPrimaryPane, registerDefaults } from '@ali/lowcode-editor-skeleton';
import { deepValueParser } from './deep-value-parser'; import { deepValueParser } from './deep-value-parser';
import { liveEditingRule, liveEditingSaveHander } from './vc-live-editing'; import { liveEditingRule, liveEditingSaveHander } from './vc-live-editing';
import { Item } from '@alifd/next/types/breadcrumb'; import { Item } from '@alifd/next/types/breadcrumb';
@ -20,22 +21,14 @@ globalContext.register(editor, Editor);
export const skeleton = new Skeleton(editor); export const skeleton = new Skeleton(editor);
editor.set(Skeleton, skeleton); editor.set(Skeleton, skeleton);
editor.set('skeleton', skeleton); editor.set('skeleton', skeleton);
registerDefaults();
export const designer = new Designer({ editor: editor }); export const designer = new Designer({ editor: editor });
editor.set(Designer, designer); editor.set(Designer, designer);
editor.set('designer', designer); editor.set('designer', designer);
designer.project.onRendererReady(() => {
bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY);
});
const nodeCache: any = {};
designer.project.onCurrentDocumentChange((doc) => { designer.project.onCurrentDocumentChange((doc) => {
doc.onNodeCreate((node) => { bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY);
nodeCache[node.id] = node;
});
doc.onNodeDestroy((node) => {
delete nodeCache[node.id];
});
}); });
interface Variable { interface Variable {
@ -84,6 +77,18 @@ function upgradePropsReducer(props: any) {
// 升级 Props // 升级 Props
designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade); designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade);
function getCurrentFieldIds() {
const fieldIds: any = [];
const nodesMap = designer?.currentDocument?.nodesMap || new Map();
nodesMap.forEach((curNode: any) => {
const fieldId = nodesMap?.get(curNode.id)?.getPropValue('fieldId');
if (fieldId) {
fieldIds.push(fieldId);
}
});
return fieldIds;
}
// 节点 props 初始化 // 节点 props 初始化
designer.addPropsReducer((props, node) => { designer.addPropsReducer((props, node) => {
// debugger; // debugger;
@ -92,14 +97,10 @@ designer.addPropsReducer((props, node) => {
...props, ...props,
}; };
if (newProps.fieldId) { if (newProps.fieldId) {
const fieldIds: any = []; const fieldIds = getCurrentFieldIds();
Object.keys(nodeCache).forEach((nodeId) => {
const fieldId = nodeCache[nodeId].getPropValue('fieldId'); // 全局的关闭 uniqueIdChecker 信号,在 ve-utils 中实现
if (fieldId) { if (fieldIds.indexOf(props.fieldId) >= 0 && !(window as any).__disable_unique_id_checker__) {
fieldIds.push(fieldId);
}
});
if (fieldIds.indexOf(props.fieldId) >= 0) {
newProps.fieldId = undefined; newProps.fieldId = undefined;
} }
} }
@ -186,33 +187,33 @@ designer.addPropsReducer(filterReducer, TransformStage.Save);
designer.addPropsReducer(filterReducer, TransformStage.Render); designer.addPropsReducer(filterReducer, TransformStage.Render);
function compatiableReducer(props: any) { function compatiableReducer(props: any) {
if (!isPlainObject(props)) { if (!props || !isPlainObject(props)) {
return props; return props;
} }
if (isJSSlot(props)) {
return {
type: 'JSBlock',
value: {
componentName: 'Slot',
children: props.value,
props: {
slotTitle: props.title,
slotName: props.name,
},
},
};
}
// 为了能降级到老版本,建议在后期版本去掉以下代码
// if (isJSExpression(props) && !props.events) {
// return {
// type: 'variable',
// value: props.mock,
// variable: props.value,
// }
// }
const newProps: any = {}; const newProps: any = {};
Object.entries<any>(props).forEach(([key, val]) => { Object.entries<any>(props).forEach(([key, val]) => {
if (isJSSlot(val)) { newProps[key] = compatiableReducer(val);
val = {
type: 'JSBlock',
value: {
componentName: 'Slot',
children: val.value,
props: {
slotTitle: val.title,
slotName: val.name,
},
},
};
}
// 为了能降级到老版本,建议在后期版本去掉以下代码
if (isJSExpression(val) && !val.events) {
val = {
type: 'variable',
value: val.mock,
variable: val.value,
};
}
newProps[key] = val;
}); });
return newProps; return newProps;
} }
@ -298,7 +299,9 @@ function appendStyleNode(props: any, styleProp: any, cssClass: string, cssId: st
s.setAttribute('id', cssId); s.setAttribute('id', cssId);
doc.getElementsByTagName('head')[0].appendChild(s); doc.getElementsByTagName('head')[0].appendChild(s);
s.appendChild(doc.createTextNode(styleProp.replace(/:root/g, '.' + cssClass))); s.appendChild(doc.createTextNode(styleProp.replace(/(\d+)rpx/g, (a, b) => {
return `${b / 2}px`;
}).replace(/:root/g, '.' + cssClass)));
} }
} }
designer.addPropsReducer(stylePropsReducer, TransformStage.Render); designer.addPropsReducer(stylePropsReducer, TransformStage.Render);

View File

@ -16,7 +16,7 @@ export class Flags {
constructor() { constructor() {
this.emitter = new EventEmitter(); this.emitter = new EventEmitter();
this.flags = ['design-mode']; this.flags = [];
domReady(() => { domReady(() => {
this.ready = true; this.ready = true;

View File

@ -30,11 +30,6 @@ import Symbols from './symbols';
import './vision.less'; import './vision.less';
function init(container?: Element) { function init(container?: Element) {
//TODO: dirty fix
// 之前的组件库依赖了这个样式临时fix一下。
// 取决于预览模式是否保留。
document.documentElement.classList.add('engine-design-mode');
if (!container) { if (!container) {
container = document.createElement('div'); container = document.createElement('div');
document.body.appendChild(container); document.body.appendChild(container);

View File

@ -1,6 +1,6 @@
import { designer } from './editor';
import { RootSchema } from '@ali/lowcode-types'; import { RootSchema } from '@ali/lowcode-types';
import { DocumentModel } from '@ali/lowcode-designer'; import { DocumentModel } from '@ali/lowcode-designer';
import { designer } from './editor';
import NodeCacheVisitor from './rootNodeVisitor'; import NodeCacheVisitor from './rootNodeVisitor';
const { project } = designer; const { project } = designer;
@ -33,14 +33,31 @@ const pages = Object.assign(project, {
throw new Error('pages schema 不合法'); throw new Error('pages schema 不合法');
} }
// todo: miniapp // todo: miniapp
const componentsTree: any = []; let componentsTree: any = [];
pages.forEach((item: any) => { if (window.pageConfig?.isNoCodeMiniApp) {
if (isPageDataV1(item)) { // 小程序多页面
componentsTree.push(item.layout); pages.forEach((item: any) => {
if (isPageDataV1(item)) {
componentsTree.push(item.layout);
} else {
componentsTree.push(item.componentsTree[0]);
}
});
} else {
if (isPageDataV1(pages[0])) {
componentsTree = [pages[0].layout];
} else { } else {
componentsTree.push(item.componentsTree[0]); componentsTree = pages[0].componentsTree;
if (componentsTree[0]) {
componentsTree[0].componentName = componentsTree[0].componentName || 'Page';
// FIXME
if (componentsTree[0].componentName === 'Page' || componentsTree[0].componentName === 'Component') {
componentsTree[0].methods = {};
}
}
} }
}); }
componentsTree.forEach((item: any) => { componentsTree.forEach((item: any) => {
item.componentName = item.componentName || 'Page'; item.componentName = item.componentName || 'Page';
if (item.componentName === 'Page' || item.componentName === 'Component') { if (item.componentName === 'Page' || item.componentName === 'Component') {
@ -48,16 +65,21 @@ const pages = Object.assign(project, {
} }
}); });
console.log(pages, componentsTree); console.log(pages, componentsTree);
project.load( project.load(
{ {
version: '1.0.0', version: '1.0.0',
componentsMap: [], componentsMap: [],
componentsTree, componentsTree,
id: pages[0].id,
config: project.config, config: project.config,
}, },
true, true,
); );
// FIXME: 根本原因应该是 propStash 导致的,这样可以避免页面加载之后就被标记为 isModified
setTimeout(() => {
project.currentDocument?.history.savePoint();
}, 0);
}, },
addPage(data: OldPageData | RootSchema) { addPage(data: OldPageData | RootSchema) {
if (isPageDataV1(data)) { if (isPageDataV1(data)) {
@ -94,18 +116,20 @@ const pages = Object.assign(project, {
return project.onCurrentDocumentChange(fn); return project.onCurrentDocumentChange(fn);
}, },
toData() { toData() {
return project.documents.map(doc => doc.toData()); return project.documents.map((doc) => doc.toData());
} },
}); });
Object.defineProperty(pages, 'currentPage', { Object.defineProperty(pages, 'currentPage', {
get() { get() {
return project.currentDocument; return project.currentDocument;
} },
}) });
pages.onCurrentPageChange((page: DocumentModel) => { pages.onCurrentPageChange((page: DocumentModel) => {
if (!page) { return; } if (!page) {
return;
}
page.acceptRootNodeVisitor('NodeCache', (rootNode) => { page.acceptRootNodeVisitor('NodeCache', (rootNode) => {
const visitor: NodeCacheVisitor = page.getRootNodeVisitor('NodeCache'); const visitor: NodeCacheVisitor = page.getRootNodeVisitor('NodeCache');
if (visitor) { if (visitor) {

View File

@ -68,7 +68,7 @@ function upgradeConfig(config: OldPaneConfig): IWidgetBaseConfig & { area: strin
newConfig.type = 'PanelDock'; newConfig.type = 'PanelDock';
newConfig.area = 'left'; newConfig.area = 'left';
newConfig.props.description = description || title; newConfig.props.description = description || title;
const { contents, hideTitleBar, tip, width, maxWidth, height, maxHeight, menu, isAction } = config; const { contents, hideTitleBar, tip, width, maxWidth, height, maxHeight, menu, isAction, canSetFixed } = config;
if (menu) { if (menu) {
newConfig.props.title = menu; newConfig.props.title = menu;
} }
@ -83,6 +83,7 @@ function upgradeConfig(config: OldPaneConfig): IWidgetBaseConfig & { area: strin
maxWidth, maxWidth,
height, height,
maxHeight, maxHeight,
canSetFixed,
onInit: init, onInit: init,
onDestroy: destroy, onDestroy: destroy,
}; };

View File

@ -122,3 +122,7 @@ html.engine-preview-mode {
line-height: 22px; line-height: 22px;
} }
} }
.lc-setter-mixed {
flex: 1
}

View File

@ -3,6 +3,194 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.0.8-0"></a>
## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.21...@ali/lowcode-editor-setters@1.0.8-0) (2020-09-09)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30))
* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f))
* fix function-setter bug ([dced647](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dced647))
* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df))
* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375))
### Features
* 新增事件入参功能 ([0614fa7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0614fa7))
* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6))
* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0))
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807))
* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f))
<a name="1.0.7-0"></a>
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.6-0...@ali/lowcode-editor-setters@1.0.7-0) (2020-09-02)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="1.0.6-0"></a>
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@1.0.6-0) (2020-09-02)
<a name="0.9.21"></a>
## [0.9.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.20...@ali/lowcode-editor-setters@0.9.21) (2020-09-03)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.9.20"></a>
## [0.9.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@0.9.20) (2020-09-03)
### Bug Fixes
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30))
* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f))
* fix function-setter bug ([dced647](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dced647))
* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df))
* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375))
### Features
* 新增事件入参功能 ([0614fa7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0614fa7))
* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6))
* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0))
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807))
* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f))
<a name="1.0.5-0"></a>
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.4-0...@ali/lowcode-editor-setters@1.0.5-0) (2020-08-20)
<a name="0.9.19"></a>
## [0.9.19](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.18...@ali/lowcode-editor-setters@0.9.19) (2020-08-27)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.9.18"></a>
## [0.9.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.17...@ali/lowcode-editor-setters@0.9.18) (2020-08-24)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.9.17"></a>
## [0.9.17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.16...@ali/lowcode-editor-setters@0.9.17) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="1.0.4-0"></a>
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.3-0...@ali/lowcode-editor-setters@1.0.4-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="1.0.3-0"></a>
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.2-0...@ali/lowcode-editor-setters@1.0.3-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="1.0.2-0"></a>
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.1-0...@ali/lowcode-editor-setters@1.0.2-0) (2020-08-20)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="1.0.1-0"></a>
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.16...@ali/lowcode-editor-setters@1.0.1-0) (2020-08-20)
### Bug Fixes
* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df))
### Features
* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0))
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807))
* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6))
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.14.0...@ali/lowcode-editor-setters@1.0.0) (2020-08-17)
<a name="0.9.16"></a>
## [0.9.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.15...@ali/lowcode-editor-setters@0.9.16) (2020-08-19)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.14.0"></a>
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.13.0...@ali/lowcode-editor-setters@0.14.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.13.0"></a>
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.11.0...@ali/lowcode-editor-setters@0.13.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.12.0"></a>
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.11.0...@ali/lowcode-editor-setters@0.12.0) (2020-08-17)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.11.0"></a>
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.10.0...@ali/lowcode-editor-setters@0.11.0) (2020-08-16)
**Note:** Version bump only for package @ali/lowcode-editor-setters
<a name="0.10.0"></a>
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.14...@ali/lowcode-editor-setters@0.10.0) (2020-08-14)
### Features
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
<a name="0.9.14"></a> <a name="0.9.14"></a>
## [0.9.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.13...@ali/lowcode-editor-setters@0.9.14) (2020-08-04) ## [0.9.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.13...@ali/lowcode-editor-setters@0.9.14) (2020-08-04)
@ -243,8 +431,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Bug Fixes ### Bug Fixes
<<<<<<< HEAD
* ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7d)) * ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7d))
=======
* ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7db5fccb6e185cfa12e197ae698932fe127))
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-editor-setters", "name": "@ali/lowcode-editor-setters",
"version": "0.9.14", "version": "1.0.8-0",
"description": "Builtin setters for Ali lowCode engine", "description": "Builtin setters for Ali lowCode engine",
"files": [ "files": [
"es", "es",
@ -22,11 +22,11 @@
"@ali/iceluna-comp-react-node": "^1.0.5", "@ali/iceluna-comp-react-node": "^1.0.5",
"@ali/iceluna-sdk": "^1.0.5-beta.24", "@ali/iceluna-sdk": "^1.0.5-beta.24",
"@ali/lc-style-setter": "^0.0.1", "@ali/lc-style-setter": "^0.0.1",
"@ali/lowcode-editor-core": "^0.8.28", "@ali/lowcode-editor-core": "^1.0.8-0",
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"acorn": "^6.4.1", "acorn": "^6.4.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"intl-messageformat": "^8.2.1", "intl-messageformat": "^9.3.1",
"monaco-editor": "^0.20.0", "monaco-editor": "^0.20.0",
"qs": "^6.9.1", "qs": "^6.9.1",
"react": "^16", "react": "^16",

View File

@ -18,23 +18,23 @@ export default class ColorPickerView extends PureComponent<PluginProps> {
static display = 'ColorPicker'; static display = 'ColorPicker';
static propTypes = { static propTypes = {
onChange: PropTypes.func, onChange: PropTypes.func,
value: PropTypes.string value: PropTypes.string,
}; };
static defaultProps = { static defaultProps = {
onChange: () => {}, onChange: () => {},
value: '' value: '',
}; };
constructor(props: Readonly<{value: string; defaultValue: string}>) { constructor(props: Readonly<{ value: string; defaultValue: string }>) {
super(props); super(props);
this.state = { this.state = {
value: props.value || props.defaultValue value: props.value || props.defaultValue,
}; };
} }
static getDerivedStateFromProps(props: { value: string; }, state: { preValue: string; }) { static getDerivedStateFromProps(props: { value: string }, state: { preValue: string }) {
if (props.value != state.preValue) { if (props.value != state.preValue) {
return { return {
preValue: props.value, preValue: props.value,
value: props.value value: props.value,
}; };
} }
return null; return null;
@ -42,35 +42,35 @@ export default class ColorPickerView extends PureComponent<PluginProps> {
onChangeComplete = (color: Color): void => { onChangeComplete = (color: Color): void => {
let value; let value;
if (color.rgb.a < 1) { if (color.rgb.a < 1) {
let rgb = color.rgb; const rgb = color.rgb;
let rgba = [rgb.r, rgb.g, rgb.b, rgb.a]; const rgba = [rgb.r, rgb.g, rgb.b, rgb.a];
value = `rgba(${rgba.join(',')})`; value = `rgba(${rgba.join(',')})`;
} else { } else {
value = color.hex; value = color.hex;
} }
this.setState({ this.setState({
value value,
}); });
this.props.onChange && this.props.onChange(value); this.props.onChange && this.props.onChange(value);
} };
onInputChange = (value: string): void => { onInputChange = (value: string): void => {
if (/^[0-9a-zA-Z]{6}$/.test(value)) value = '#' + value; if (/^[0-9a-zA-Z]{6}$/.test(value)) value = '#' + value;
this.setState({ this.setState({
value value,
}); });
this.props.onChange && this.props.onChange(value); this.props.onChange && this.props.onChange(value);
} };
render(): React.ReactNode { render(): React.ReactNode {
const { value, onChange, ...restProps } = this.props; const { value, onChange, ...restProps } = this.props;
let boxStyle = { const boxStyle = {
backgroundColor: this.state.value backgroundColor: this.state.value,
}; };
let triggerNode = ( const triggerNode = (
<div className="lowcode-color-box"> <div className="lowcode-color-box">
<div style={boxStyle} /> <div style={boxStyle} />
</div> </div>
); );
let InnerBeforeNode = ( const InnerBeforeNode = (
<Balloon <Balloon
className={'lowcode-color-content'} className={'lowcode-color-content'}
trigger={triggerNode} trigger={triggerNode}
@ -80,20 +80,11 @@ export default class ColorPickerView extends PureComponent<PluginProps> {
alignEdge="edge" alignEdge="edge"
offset={[-3, -6]} offset={[-3, -6]}
> >
<SketchPicker <SketchPicker onChangeComplete={this.onChangeComplete} color={this.state.value} arrowPointAtCenter={true} />
onChangeComplete={this.onChangeComplete}
color={this.state.value}
arrowPointAtCenter={true}
/>
</Balloon> </Balloon>
); );
return ( return (
<Input <Input {...restProps} innerBefore={InnerBeforeNode} onChange={this.onInputChange} value={this.state.value} />
{...restProps}
innerBefore={InnerBeforeNode}
onChange={this.onInputChange}
value={this.state.value}
/>
); );
} }
} }

View File

@ -67,7 +67,7 @@
.event-menu { .event-menu {
max-height: 300px; max-height: 300px;
width: 230px; width: 256px;
overflow-x: hidden; overflow-x: hidden;
position: absolute; position: absolute;
top: 67px; top: 67px;

View File

@ -18,6 +18,8 @@ const DEFINITION_EVENT_TYPE = {
LIFE_CYCLE_EVENT: 'lifeCycleEvent', LIFE_CYCLE_EVENT: 'lifeCycleEvent',
}; };
const SETTER_NAME = 'event-setter'
export default class EventsSetter extends Component<{ export default class EventsSetter extends Component<{
value: any[]; value: any[];
onChange: (eventList: any[]) => void; onChange: (eventList: any[]) => void;
@ -29,39 +31,43 @@ export default class EventsSetter extends Component<{
selectType: null, selectType: null,
nativeEventList: [], nativeEventList: [],
lifeCycleEventList: [], lifeCycleEventList: [],
eventDataList: this.props.value || [], eventDataList: (this.props?.value?.eventDataList ? this.props.value.eventDataList : this.props?.value) || [],
relatedEventName: '', relatedEventName: '',
}; };
// constructor (){ // constructor (){
// super(); // super();
// debugger; // debugger;
// if (!this.props || !this.props.value){ // // if (!this.props || !this.props.value){
// this.setState({ // // this.setState({
// eventDataList:[] // // eventDataList:[]
// }) // // })
// } // // }
// } // }
static getDerivedStateFromProps(nextProps, prevState) { // static getDerivedStateFromProps(nextProps, prevState) {
// const { value } = nextProps; // debugger;
// debugger; // // const { value } = nextProps;
// if (value !== prevState.eventDataList) { // // debugger;
// return { // // if (value !== prevState.eventDataList) {
// value, // // return {
// }; // // value,
// } // // };
return null; // // }
} // return null;
// }
private bindEventName:String; private bindEventName:String;
componentDidMount() { componentDidMount() {
console.log(this.state.eventDataList);
const {editor} = this.props.field; const {editor} = this.props.field;
this.initEventBtns(); this.initEventBtns();
this.initEventList(); this.initEventList();
editor.on('event-setter.bindEvent',(relatedEventName)=>{ editor.on(`${SETTER_NAME}.bindEvent`,(relatedEventName,paramStr)=>{
this.bindEvent(relatedEventName); this.bindEvent(relatedEventName,paramStr);
}) })
} }
@ -310,7 +316,7 @@ export default class EventsSetter extends Component<{
}; };
deleteEvent = (eventName: String) => { deleteEvent = (eventName: String) => {
const { eventDataList } = this.state; const { eventDataList,eventList} = this.state;
eventDataList.map((item, index) => { eventDataList.map((item, index) => {
if (item.name === eventName) { if (item.name === eventName) {
eventDataList.splice(index, 1); eventDataList.splice(index, 1);
@ -320,22 +326,32 @@ export default class EventsSetter extends Component<{
this.setState({ this.setState({
eventDataList, eventDataList,
}); });
this.props.onChange({eventDataList,eventList});
this.updateEventListStatus(eventName, true); this.updateEventListStatus(eventName, true);
}; };
openDialog = (bindEventName: String) => { openDialog = (bindEventName: String) => {
const {editor} = this.props.field; const {editor} = this.props.field;
const {eventDataList} = this.state;
let paramStr;
eventDataList.map((item)=>{
if (item.name == bindEventName){
paramStr = item.paramStr;
}
})
this.bindEventName = bindEventName; this.bindEventName = bindEventName;
editor.emit('eventBindDialog.openDialog',bindEventName); editor.emit('eventBindDialog.openDialog',bindEventName,SETTER_NAME,paramStr);
}; };
bindEvent = (relatedEventName: String) => { bindEvent = (relatedEventName: String,paramStr:String) => {
const {eventDataList} = this.state; const {eventDataList,eventList} = this.state;
eventDataList.map(item => { eventDataList.map(item => {
if (item.name === this.bindEventName) { if (item.name === this.bindEventName) {
item.relatedEventName = relatedEventName; item.relatedEventName = relatedEventName;
if (paramStr){
item.paramStr = paramStr
}
} }
}); });
@ -344,7 +360,7 @@ export default class EventsSetter extends Component<{
}) })
this.props.onChange(eventDataList); this.props.onChange({eventDataList,eventList});
//this.closeDialog(); //this.closeDialog();
}; };

Some files were not shown because too many files have changed in this diff Show More