mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-13 04:03:07 +00:00
feat: add common.utils.executeTransaction API to change multi nodes
This commit is contained in:
parent
55365194e9
commit
7bf7ca428d
@ -36,6 +36,7 @@ import {
|
|||||||
hasOwnProperty,
|
hasOwnProperty,
|
||||||
UtilsMetadata,
|
UtilsMetadata,
|
||||||
getClosestNode,
|
getClosestNode,
|
||||||
|
transactionManager,
|
||||||
} from '@alilc/lowcode-utils';
|
} from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
DragObjectType,
|
DragObjectType,
|
||||||
@ -59,9 +60,8 @@ import { getClosestClickableNode } from './utils/clickable';
|
|||||||
import {
|
import {
|
||||||
ComponentMetadata,
|
ComponentMetadata,
|
||||||
ComponentSchema,
|
ComponentSchema,
|
||||||
TransformStage,
|
|
||||||
ActivityData,
|
|
||||||
Package,
|
Package,
|
||||||
|
TransitionType,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { BuiltinSimulatorRenderer } from './renderer';
|
import { BuiltinSimulatorRenderer } from './renderer';
|
||||||
import clipboard from '../designer/clipboard';
|
import clipboard from '../designer/clipboard';
|
||||||
@ -181,6 +181,14 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
*/
|
*/
|
||||||
autoRender = true;
|
autoRender = true;
|
||||||
|
|
||||||
|
stopAutoRepaintNode() {
|
||||||
|
this.renderer?.stopAutoRepaintNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
enableAutoRepaintNode() {
|
||||||
|
this.renderer?.enableAutoRepaintNode();
|
||||||
|
}
|
||||||
|
|
||||||
constructor(project: Project) {
|
constructor(project: Project) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
this.project = project;
|
this.project = project;
|
||||||
@ -194,6 +202,13 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
i18n: this.project.i18n,
|
i18n: this.project.i18n,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
transactionManager.onStartTransaction(() => {
|
||||||
|
this.stopAutoRepaintNode();
|
||||||
|
}, TransitionType.REPAINT);
|
||||||
|
transactionManager.onEndTransaction(() => {
|
||||||
|
this.rerender();
|
||||||
|
this.enableAutoRepaintNode();
|
||||||
|
}, TransitionType.REPAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentDocument() {
|
get currentDocument() {
|
||||||
|
|||||||
@ -13,6 +13,8 @@ export interface BuiltinSimulatorRenderer {
|
|||||||
setCopyState(state: boolean): void;
|
setCopyState(state: boolean): void;
|
||||||
loadAsyncLibrary(asyncMap: { [index: string]: any }): void;
|
loadAsyncLibrary(asyncMap: { [index: string]: any }): void;
|
||||||
clearState(): void;
|
clearState(): void;
|
||||||
|
stopAutoRepaintNode(): void;
|
||||||
|
enableAutoRepaintNode(): void;
|
||||||
run(): void;
|
run(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { autorun, reaction, mobx, untracked, globalContext, Editor } from '@alilc/lowcode-editor-core';
|
import { reaction, untracked, globalContext, Editor } from '@alilc/lowcode-editor-core';
|
||||||
import { NodeSchema } from '@alilc/lowcode-types';
|
import { NodeSchema } from '@alilc/lowcode-types';
|
||||||
import { History as ShellHistory } from '@alilc/lowcode-shell';
|
import { History as ShellHistory } from '@alilc/lowcode-shell';
|
||||||
|
|
||||||
@ -32,31 +32,30 @@ export class History<T = NodeSchema> {
|
|||||||
this.currentSerialization = serialization;
|
this.currentSerialization = serialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(dataFn: () => T, private redoer: (data: T) => void, private timeGap: number = 1000) {
|
constructor(dataFn: () => T | null, private redoer: (data: T) => void, private timeGap: number = 1000) {
|
||||||
this.session = new Session(0, null, this.timeGap);
|
this.session = new Session(0, null, this.timeGap);
|
||||||
this.records = [this.session];
|
this.records = [this.session];
|
||||||
|
|
||||||
reaction(() => {
|
reaction((): any => {
|
||||||
return dataFn();
|
return dataFn();
|
||||||
}, (data: T) => {
|
}, (data: T) => {
|
||||||
if (this.asleep) return;
|
if (this.asleep) return;
|
||||||
untracked(() => {
|
untracked(() => {
|
||||||
const log = this.currentSerialization.serialize(data);
|
const log = this.currentSerialization.serialize(data);
|
||||||
if (this.session.isActive()) {
|
if (this.session.isActive()) {
|
||||||
this.session.log(log);
|
this.session.log(log);
|
||||||
} else {
|
} else {
|
||||||
this.session.end();
|
this.session.end();
|
||||||
const lastState = this.getState();
|
const lastState = this.getState();
|
||||||
const cursor = this.session.cursor + 1;
|
const cursor = this.session.cursor + 1;
|
||||||
const session = new Session(cursor, log, this.timeGap);
|
const session = new Session(cursor, log, this.timeGap);
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.records.splice(cursor, this.records.length - cursor, session);
|
this.records.splice(cursor, this.records.length - cursor, session);
|
||||||
const currentState = this.getState();
|
const currentState = this.getState();
|
||||||
if (currentState !== lastState) {
|
if (currentState !== lastState) {
|
||||||
this.emitter.emit('statechange', currentState);
|
this.emitter.emit('statechange', currentState);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
}, { fireImmediately: true });
|
}, { fireImmediately: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById } from '@alilc/lowcode-utils';
|
import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById, transactionManager } from '@alilc/lowcode-utils';
|
||||||
import { isNodeSchema } from '@alilc/lowcode-types';
|
import { isNodeSchema } from '@alilc/lowcode-types';
|
||||||
import { getConvertedExtraKey, getOriginalExtraKey, isNode, isSettingField } from '@alilc/lowcode-designer';
|
import { getConvertedExtraKey, getOriginalExtraKey } from '@alilc/lowcode-designer';
|
||||||
|
|
||||||
const utils = {
|
const utils = {
|
||||||
isNodeSchema,
|
isNodeSchema,
|
||||||
@ -9,6 +9,7 @@ const utils = {
|
|||||||
getNodeSchemaById,
|
getNodeSchemaById,
|
||||||
getConvertedExtraKey,
|
getConvertedExtraKey,
|
||||||
getOriginalExtraKey,
|
getOriginalExtraKey,
|
||||||
|
executeTransaction: transactionManager.executeTransaction.bind(transactionManager),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default utils;
|
export default utils;
|
||||||
@ -349,6 +349,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
* 是否为画布自动渲染
|
* 是否为画布自动渲染
|
||||||
*/
|
*/
|
||||||
autoRender = true;
|
autoRender = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 画布是否自动监听事件来重绘节点
|
||||||
|
*/
|
||||||
|
autoRepaintNode = true;
|
||||||
/**
|
/**
|
||||||
* 加载资源
|
* 加载资源
|
||||||
*/
|
*/
|
||||||
@ -491,6 +496,14 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
this._appContext = { ...this._appContext };
|
this._appContext = { ...this._appContext };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopAutoRepaintNode() {
|
||||||
|
this.autoRepaintNode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
enableAutoRepaintNode() {
|
||||||
|
this.autoRepaintNode = true;
|
||||||
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this.disposeFunctions.forEach(fn => fn());
|
this.disposeFunctions.forEach(fn => fn());
|
||||||
this.documentInstances.forEach(docInst => docInst.dispose());
|
this.documentInstances.forEach(docInst => docInst.dispose());
|
||||||
|
|||||||
@ -102,14 +102,23 @@ function initRerenderEvent({
|
|||||||
leaf,
|
leaf,
|
||||||
dispose: [
|
dispose: [
|
||||||
leaf?.onPropChange?.(() => {
|
leaf?.onPropChange?.(() => {
|
||||||
|
if (!container.autoRepaintNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onPropsChange make rerender`);
|
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onPropsChange make rerender`);
|
||||||
container.rerender();
|
container.rerender();
|
||||||
}),
|
}),
|
||||||
leaf?.onChildrenChange?.(() => {
|
leaf?.onChildrenChange?.(() => {
|
||||||
|
if (!container.autoRepaintNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onChildrenChange make rerender`);
|
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onChildrenChange make rerender`);
|
||||||
container.rerender();
|
container.rerender();
|
||||||
}) as Function,
|
}) as Function,
|
||||||
leaf?.onVisibleChange?.(() => {
|
leaf?.onVisibleChange?.(() => {
|
||||||
|
if (!container.autoRepaintNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onVisibleChange make rerender`);
|
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onVisibleChange make rerender`);
|
||||||
container.rerender();
|
container.rerender();
|
||||||
}),
|
}),
|
||||||
@ -213,14 +222,18 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
const _leaf = this.leaf;
|
||||||
|
this.initOnPropsChangeEvent(_leaf);
|
||||||
|
this.initOnChildrenChangeEvent(_leaf);
|
||||||
|
this.initOnVisibleChangeEvent(_leaf);
|
||||||
this.recordTime();
|
this.recordTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
get defaultState() {
|
getDefaultState(nextProps: any) {
|
||||||
const {
|
const {
|
||||||
hidden = false,
|
hidden = false,
|
||||||
condition = true,
|
condition = true,
|
||||||
} = this.leaf?.export?.(TransformStage.Render) || {};
|
} = nextProps.__inner__ || this.leaf?.export?.(TransformStage.Render) || {};
|
||||||
return {
|
return {
|
||||||
nodeChildren: null,
|
nodeChildren: null,
|
||||||
childrenInState: false,
|
childrenInState: false,
|
||||||
@ -236,11 +249,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
// 监听以下事件,当变化时更新自己
|
// 监听以下事件,当变化时更新自己
|
||||||
__debug(`${schema.componentName}[${this.props.componentId}] leaf render in SimulatorRendererView`);
|
__debug(`${schema.componentName}[${this.props.componentId}] leaf render in SimulatorRendererView`);
|
||||||
clearRerenderEvent(componentCacheId);
|
clearRerenderEvent(componentCacheId);
|
||||||
const _leaf = this.leaf;
|
this.curEventLeaf = this.leaf;
|
||||||
this.initOnPropsChangeEvent(_leaf);
|
|
||||||
this.initOnChildrenChangeEvent(_leaf);
|
|
||||||
this.initOnVisibleChangeEvent(_leaf);
|
|
||||||
this.curEventLeaf = _leaf;
|
|
||||||
|
|
||||||
cache.ref.set(componentCacheId, {
|
cache.ref.set(componentCacheId, {
|
||||||
makeUnitRender: this.makeUnitRender,
|
makeUnitRender: this.makeUnitRender,
|
||||||
@ -248,7 +257,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
|
|
||||||
let cacheState = cache.state.get(componentCacheId);
|
let cacheState = cache.state.get(componentCacheId);
|
||||||
if (!cacheState || cacheState.__tag !== props.__tag) {
|
if (!cacheState || cacheState.__tag !== props.__tag) {
|
||||||
cacheState = this.defaultState;
|
cacheState = this.getDefaultState(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = cacheState;
|
this.state = cacheState;
|
||||||
@ -279,6 +288,10 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
singleRender?: boolean;
|
singleRender?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get autoRepaintNode() {
|
||||||
|
return container.autoRepaintNode;
|
||||||
|
}
|
||||||
|
|
||||||
judgeMiniUnitRender() {
|
judgeMiniUnitRender() {
|
||||||
if (!this.renderUnitInfo) {
|
if (!this.renderUnitInfo) {
|
||||||
this.getRenderUnitInfo();
|
this.getRenderUnitInfo();
|
||||||
@ -380,13 +393,16 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
const {
|
const {
|
||||||
visible,
|
visible,
|
||||||
...resetState
|
...resetState
|
||||||
} = this.defaultState;
|
} = this.getDefaultState(nextProps);
|
||||||
this.setState(resetState);
|
this.setState(resetState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 监听参数变化 */
|
/** 监听参数变化 */
|
||||||
initOnPropsChangeEvent(leaf = this.leaf): void {
|
initOnPropsChangeEvent(leaf = this.leaf): void {
|
||||||
const dispose = leaf?.onPropChange?.(debounce((propChangeInfo: PropChangeOptions) => {
|
const dispose = leaf?.onPropChange?.((propChangeInfo: PropChangeOptions) => {
|
||||||
|
if (!this.autoRepaintNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
key,
|
key,
|
||||||
newValue = null,
|
newValue = null,
|
||||||
@ -433,7 +449,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.judgeMiniUnitRender();
|
this.judgeMiniUnitRender();
|
||||||
}, 30));
|
});
|
||||||
|
|
||||||
dispose && this.disposeFunctions.push(dispose);
|
dispose && this.disposeFunctions.push(dispose);
|
||||||
}
|
}
|
||||||
@ -443,6 +459,9 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
*/
|
*/
|
||||||
initOnVisibleChangeEvent(leaf = this.leaf) {
|
initOnVisibleChangeEvent(leaf = this.leaf) {
|
||||||
const dispose = leaf?.onVisibleChange?.((flag: boolean) => {
|
const dispose = leaf?.onVisibleChange?.((flag: boolean) => {
|
||||||
|
if (!this.autoRepaintNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.state.visible === flag) {
|
if (this.state.visible === flag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -463,6 +482,9 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
*/
|
*/
|
||||||
initOnChildrenChangeEvent(leaf = this.leaf) {
|
initOnChildrenChangeEvent(leaf = this.leaf) {
|
||||||
const dispose = leaf?.onChildrenChange?.((param): void => {
|
const dispose = leaf?.onChildrenChange?.((param): void => {
|
||||||
|
if (!this.autoRepaintNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
node,
|
node,
|
||||||
@ -540,6 +562,8 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
ref: forwardedRef,
|
ref: forwardedRef,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
delete compProps.__inner__;
|
||||||
|
|
||||||
return engine.createElement(Comp, compProps, this.hasChildren ? this.children : null);
|
return engine.createElement(Comp, compProps, this.hasChildren ? this.children : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -670,7 +670,14 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return renderComp({ ...props, ...otherProps });
|
return renderComp({
|
||||||
|
...props,
|
||||||
|
...otherProps,
|
||||||
|
__inner__: {
|
||||||
|
hidden: schema.hidden,
|
||||||
|
condition,
|
||||||
|
},
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return engine.createElement(engine.getFaultComponent(), {
|
return engine.createElement(engine.getFaultComponent(), {
|
||||||
error: e,
|
error: e,
|
||||||
|
|||||||
@ -35,7 +35,8 @@ const baseRenderer: any = {
|
|||||||
__container: {
|
__container: {
|
||||||
rerender: () => {
|
rerender: () => {
|
||||||
rerenderCount = 1 + rerenderCount;
|
rerenderCount = 1 + rerenderCount;
|
||||||
}
|
},
|
||||||
|
autoRepaintNode: true,
|
||||||
},
|
},
|
||||||
documentId: '01'
|
documentId: '01'
|
||||||
},
|
},
|
||||||
|
|||||||
@ -11,6 +11,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xed"
|
__id="node_dockcy8n9xed"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-box"
|
className="next-box"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -25,6 +31,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xee"
|
__id="node_dockcy8n9xee"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-box"
|
className="next-box"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -39,6 +51,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<nav
|
<nav
|
||||||
__id="node_dockcy8n9xef"
|
__id="node_dockcy8n9xef"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
aria-label="Breadcrumb"
|
aria-label="Breadcrumb"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -55,6 +73,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
__id="node_dockcy8n9xeg"
|
__id="node_dockcy8n9xeg"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-breadcrumb-text"
|
className="next-breadcrumb-text"
|
||||||
>
|
>
|
||||||
首页
|
首页
|
||||||
@ -74,6 +98,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
__id="node_dockcy8n9xei"
|
__id="node_dockcy8n9xei"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-breadcrumb-text"
|
className="next-breadcrumb-text"
|
||||||
>
|
>
|
||||||
品质中台
|
品质中台
|
||||||
@ -93,6 +123,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
__id="node_dockcy8n9xek"
|
__id="node_dockcy8n9xek"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-breadcrumb-text"
|
className="next-breadcrumb-text"
|
||||||
>
|
>
|
||||||
商家品质页面管理
|
商家品质页面管理
|
||||||
@ -112,6 +148,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
__id="node_dockcy8n9xem"
|
__id="node_dockcy8n9xem"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
aria-current="page"
|
aria-current="page"
|
||||||
className="next-breadcrumb-text activated"
|
className="next-breadcrumb-text activated"
|
||||||
>
|
>
|
||||||
@ -123,6 +165,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xeo"
|
__id="node_dockcy8n9xeo"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-box"
|
className="next-box"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -138,6 +186,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
<form
|
<form
|
||||||
__events={Array []}
|
__events={Array []}
|
||||||
__id="node_dockcy8n9xep"
|
__id="node_dockcy8n9xep"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-form next-inline next-medium"
|
className="next-form next-inline next-medium"
|
||||||
onSubmit={[Function]}
|
onSubmit={[Function]}
|
||||||
role="grid"
|
role="grid"
|
||||||
@ -151,6 +205,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xeq"
|
__id="node_dockcy8n9xeq"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-form-item next-left next-medium"
|
className="next-form-item next-left next-medium"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -193,6 +253,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
__id="node_dockcy8n9xer"
|
__id="node_dockcy8n9xer"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
height="100%"
|
height="100%"
|
||||||
@ -258,6 +324,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xes"
|
__id="node_dockcy8n9xes"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-form-item next-left next-medium"
|
className="next-form-item next-left next-medium"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -300,6 +372,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
__id="node_dockcy8n9xet"
|
__id="node_dockcy8n9xet"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
height="100%"
|
height="100%"
|
||||||
@ -365,6 +443,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xeu"
|
__id="node_dockcy8n9xeu"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-form-item next-left next-medium"
|
className="next-form-item next-left next-medium"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -392,6 +476,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
__id="node_dockcy8n9xev"
|
__id="node_dockcy8n9xev"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
height="100%"
|
height="100%"
|
||||||
@ -412,10 +502,22 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xew"
|
__id="node_dockcy8n9xew"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-btn-group"
|
className="next-btn-group"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
__id="node_dockcy8n9xex"
|
__id="node_dockcy8n9xex"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-btn next-medium next-btn-primary"
|
className="next-btn next-medium next-btn-primary"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
@ -435,6 +537,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
__id="node_dockcy8n9xe10"
|
__id="node_dockcy8n9xe10"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-btn next-medium next-btn-normal"
|
className="next-btn next-medium next-btn-normal"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
@ -457,6 +565,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockcy8n9xe1f"
|
__id="node_dockcy8n9xe1f"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-box"
|
className="next-box"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -482,6 +596,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
__id="node_dockd5nrh9p4"
|
__id="node_dockd5nrh9p4"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-btn next-medium next-btn-primary"
|
className="next-btn next-medium next-btn-primary"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
@ -498,6 +618,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockd5nrh9p5"
|
__id="node_dockd5nrh9p5"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-box"
|
className="next-box"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -510,6 +636,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_dockjielosj1"
|
__id="node_dockjielosj1"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
actionBar={
|
actionBar={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
@ -688,6 +820,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_dockd5nrh9pg"
|
__id="node_dockd5nrh9pg"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-box"
|
className="next-box"
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
@ -702,6 +840,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_dockd5nrh9pf"
|
__id="node_dockd5nrh9pf"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="next-pagination next-medium next-normal"
|
className="next-pagination next-medium next-normal"
|
||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
@ -898,6 +1042,12 @@ exports[`Base Render renderComp 1`] = `
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
__id="node_dockd5nrh9pr"
|
__id="node_dockd5nrh9pr"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
height="100%"
|
height="100%"
|
||||||
@ -967,6 +1117,12 @@ exports[`JSExpression JSExpression props 1`] = `
|
|||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
visible={true}
|
visible={true}
|
||||||
@ -980,12 +1136,24 @@ exports[`JSExpression JSExpression props with loop 1`] = `
|
|||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
name1="1"
|
name1="1"
|
||||||
name2="1"
|
name2="1"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
name1="2"
|
name1="2"
|
||||||
@ -1000,11 +1168,23 @@ exports[`JSExpression JSExpression props with loop, and thisRequiredInJSE is tru
|
|||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
name1="1"
|
name1="1"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
name1="2"
|
name1="2"
|
||||||
@ -1018,6 +1198,12 @@ exports[`JSExpression JSFunction props 1`] = `
|
|||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
@ -1032,6 +1218,12 @@ exports[`JSExpression JSSlot has loop 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_ocl1ao1o7w3"
|
__id="node_ocl1ao1o7w3"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
__style__=":root {
|
__style__=":root {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
@ -1046,6 +1238,12 @@ exports[`JSExpression JSSlot has loop 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_ocl1ao1o7w4"
|
__id="node_ocl1ao1o7w4"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
__style__=":root {
|
__style__=":root {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #666;
|
color: #666;
|
||||||
@ -1063,6 +1261,12 @@ exports[`JSExpression JSSlot has loop 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_ocl1ao1o7w3"
|
__id="node_ocl1ao1o7w3"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
__style__=":root {
|
__style__=":root {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
@ -1077,6 +1281,12 @@ exports[`JSExpression JSSlot has loop 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_ocl1ao1o7w4"
|
__id="node_ocl1ao1o7w4"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
__style__=":root {
|
__style__=":root {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #666;
|
color: #666;
|
||||||
@ -1094,6 +1304,12 @@ exports[`JSExpression JSSlot has loop 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
__id="node_ocl1ao1o7w3"
|
__id="node_ocl1ao1o7w3"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
__style__=":root {
|
__style__=":root {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
@ -1108,6 +1324,12 @@ exports[`JSExpression JSSlot has loop 1`] = `
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
__id="node_ocl1ao1o7w4"
|
__id="node_ocl1ao1o7w4"
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
__style__=":root {
|
__style__=":root {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #666;
|
color: #666;
|
||||||
@ -1132,6 +1354,12 @@ exports[`JSExpression base props 1`] = `
|
|||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
text="123"
|
text="123"
|
||||||
@ -1146,10 +1374,22 @@ exports[`designMode designMode:default 1`] = `
|
|||||||
style={Object {}}
|
style={Object {}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut"
|
className="div-ut"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
__inner__={
|
||||||
|
Object {
|
||||||
|
"condition": true,
|
||||||
|
"hidden": undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
className="div-ut-children"
|
className="div-ut-children"
|
||||||
forwardRef={[Function]}
|
forwardRef={[Function]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -21,3 +21,4 @@ export * from './code-result';
|
|||||||
export * from './assets';
|
export * from './assets';
|
||||||
export * as GlobalEvent from './event';
|
export * as GlobalEvent from './event';
|
||||||
export * from './disposable';
|
export * from './disposable';
|
||||||
|
export * from './start-transaction';
|
||||||
|
|||||||
4
packages/types/src/start-transaction.ts
Normal file
4
packages/types/src/start-transaction.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export enum TransitionType {
|
||||||
|
/** 节点更新后重绘处理 */
|
||||||
|
REPAINT
|
||||||
|
}
|
||||||
@ -17,6 +17,7 @@
|
|||||||
"@alilc/lowcode-types": "1.0.15",
|
"@alilc/lowcode-types": "1.0.15",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"react": "^16",
|
"react": "^16",
|
||||||
|
"mobx": "^6.3.0",
|
||||||
"zen-logger": "^1.1.0"
|
"zen-logger": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -26,3 +26,4 @@ export * from './node-helper';
|
|||||||
export * from './clone-enumerable-property';
|
export * from './clone-enumerable-property';
|
||||||
export * from './logger';
|
export * from './logger';
|
||||||
export * as css from './css-helper';
|
export * as css from './css-helper';
|
||||||
|
export { transactionManager } from './start-transaction';
|
||||||
|
|||||||
29
packages/utils/src/start-transaction.ts
Normal file
29
packages/utils/src/start-transaction.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { TransitionType } from '@alilc/lowcode-types';
|
||||||
|
import { runInAction } from 'mobx';
|
||||||
|
import EventEmitter from 'events';
|
||||||
|
|
||||||
|
class TransactionManager {
|
||||||
|
emitter = new EventEmitter();
|
||||||
|
|
||||||
|
executeTransaction = (fn: () => void, type: TransitionType = TransitionType.REPAINT): void => {
|
||||||
|
this.emitter.emit(`[${type}]startTransaction`);
|
||||||
|
runInAction(fn);
|
||||||
|
this.emitter.emit(`[${type}]endTransaction`);
|
||||||
|
};
|
||||||
|
|
||||||
|
onStartTransaction = (fn: () => void, type: TransitionType = TransitionType.REPAINT): () => void => {
|
||||||
|
this.emitter.on(`[${type}]startTransaction`, fn);
|
||||||
|
return () => {
|
||||||
|
this.emitter.off(`[${type}]startTransaction`, fn);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
onEndTransaction = (fn: () => void, type: TransitionType = TransitionType.REPAINT): () => void => {
|
||||||
|
this.emitter.on(`[${type}]endTransaction`, fn);
|
||||||
|
return () => {
|
||||||
|
this.emitter.off(`[${type}]endTransaction`, fn);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const transactionManager = new TransactionManager();
|
||||||
Loading…
x
Reference in New Issue
Block a user