chore: 保存成功弹框位置适配新引擎

feat: 支持属性变更事件
This commit is contained in:
力皓 2020-11-20 11:34:58 +08:00
parent e07fd69141
commit 447ed9b8f9
12 changed files with 80 additions and 10 deletions

View File

@ -6,7 +6,8 @@ module.exports = {
// // '^.+\\.(ts|tsx)$': 'ts-jest',
// // '^.+\\.(js|jsx)$': 'babel-jest',
// },
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
// testMatch: ['**/project.test.ts'],
testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
transformIgnorePatterns: [
`/node_modules/(?!${esModules})/`,
],

View File

@ -23,6 +23,7 @@
"react-dom": "^16.7.0"
},
"devDependencies": {
"@ali/lowcode-test-mate": "^1.0.1",
"@alib/build-scripts": "^0.1.18",
"@types/classnames": "^2.2.7",
"@types/medium-editor": "^5.0.3",
@ -34,7 +35,6 @@
"build-scripts-config": "^0.1.8",
"jest": "^26.5.2",
"lodash": "^4.17.20",
"ts-jest": "^26.4.1",
"typescript": "^4.0.3"
},
"publishConfig": {

View File

@ -1,4 +1,4 @@
import { Component, Fragment } from 'react';
import React, { Component, Fragment } from 'react';
import DragResizeEngine from './drag-resize-engine';
import { observer, computed, globalContext, Editor } from '@ali/lowcode-editor-core';
import classNames from 'classnames';

View File

@ -1,4 +1,4 @@
import { Component } from 'react';
import React, { Component } from 'react';
import { observer } from '@ali/lowcode-editor-core';
import { BorderDetecting } from './border-detecting';
import { BuiltinSimulatorHost } from '../host';

View File

@ -1,4 +1,4 @@
import { Component } from 'react';
import React, { Component } from 'react';
import { observer } from '@ali/lowcode-editor-core';
import { BuiltinSimulatorHost, BuiltinSimulatorProps } from './host';
import { BemTools } from './bem-tools';

View File

@ -1,4 +1,4 @@
import { untracked, computed, obx } from '@ali/lowcode-editor-core';
import { untracked, computed, obx, globalContext, Editor } from '@ali/lowcode-editor-core';
import { CompositeValue, isJSExpression, isJSSlot, JSSlot, SlotSchema } from '@ali/lowcode-types';
import { uniqueId, isPlainObject, hasOwnProperty } from '@ali/lowcode-utils';
import { PropStash } from './prop-stash';
@ -247,6 +247,8 @@ export class Prop implements IPropParent {
value: valueToSource(val),
};
}
const editor = globalContext.get(Editor);
editor.emit('node.prop.change', { prop: this, node: this.owner });
this.dispose();
}

View File

@ -0,0 +1,34 @@
import React from 'react';
import set from 'lodash/set';
import cloneDeep from 'lodash/clonedeep';
import '../fixtures/window';
import { Editor } from '@ali/lowcode-editor-core';
import { Project } from '../../src/project/project';
import { Node } from '../../src/document/node/node';
import TestRenderer from 'react-test-renderer';
import { configure, render } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { Designer } from '../../src/designer/designer';
import formSchema from '../fixtures/schema/form';
import { getIdsFromSchema, getNodeFromSchemaById } from '../utils';
import { BuiltinSimulatorHostView } from '../../src/builtin-simulator/host-view';
configure({ adapter: new Adapter() });
const editor = new Editor();
describe('setting-prop-entry 测试', () => {
let designer: Designer;
beforeEach(() => {
designer = new Designer({ editor });
});
afterEach(() => {
designer._componentMetasMap.clear();
designer = null;
});
it('xxx', () => {
// console.log(JSON.stringify(TestRenderer.create(<BuiltinSimulatorHostView project={designer.project} />).toJSON()));
console.log(render(<BuiltinSimulatorHostView project={designer.project} ref={(xxx) => { console.log('xxx', xxx)}}/>))
})
});

View File

@ -0,0 +1,29 @@
import React from 'react';
import set from 'lodash/set';
import cloneDeep from 'lodash/clonedeep';
import '../fixtures/window';
import { Editor } from '@ali/lowcode-editor-core';
import { Project } from '../../src/project/project';
import { Node } from '../../src/document/node/node';
import { Designer } from '../../src/designer/designer';
import formSchema from '../fixtures/schema/form';
import { getIdsFromSchema, getNodeFromSchemaById } from '../utils';
import { BuiltinSimulatorHost } from '../../src/builtin-simulator/host';
const editor = new Editor();
describe('setting-prop-entry 测试', () => {
let designer: Designer;
beforeEach(() => {
designer = new Designer({ editor });
});
afterEach(() => {
designer._componentMetasMap.clear();
designer = null;
});
it('dummy test', () => {
console.log(new BuiltinSimulatorHost(designer.project));
})
});

View File

@ -23,7 +23,7 @@ describe('setting-prop-entry 测试', () => {
});
describe('node 构造函数生成 settingEntry', () => {
it.only('常规方法测试', () => {
it('常规方法测试', () => {
designer.createComponentMeta(divMeta);
designer.project.open(settingSchema);
const { currentDocument } = designer.project;

View File

@ -76,4 +76,8 @@ editor?.on('history.forward', (data) => {
bus.emit('ve.history.forward', data);
});
editor?.on('node.prop.change', (data) => {
bus.emit('node.prop.change', data);
});
export default bus;

View File

@ -114,7 +114,7 @@ html.engine-preview-mode {
}
.ve-popups .ve-message {
right: 290px;
right: calc(var(--right-area-width, 300px) + 10px);
.ve-message-content {
display: flex;

View File

@ -11,7 +11,7 @@
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"start": "build-scripts start",
"build": "build-scripts build",
"build": "build-scripts build --skip-demo",
"prepublishOnly": "npm run build"
},
"repository": {
@ -54,5 +54,5 @@
"publishConfig": {
"registry": "http://registry.npm.alibaba-inc.com"
},
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-11/build/index.html"
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-13/build/index.html"
}