@easy-editor/react-renderer 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1757,6 +1757,15 @@ function baseRendererFactory() {
1757
1757
  * execute method in schema.lifeCycles
1758
1758
  */
1759
1759
  __executeLifeCycleMethod = (method, args) => {
1760
+ // construct 场景下,跳过判断
1761
+ if (this.context) {
1762
+ const {
1763
+ engine
1764
+ } = this.context;
1765
+ if (!engine.props.excuteLifeCycleInDesignMode) {
1766
+ return;
1767
+ }
1768
+ }
1760
1769
  executeLifeCycleMethod(this, this.props.__schema, method, args);
1761
1770
  };
1762
1771
 
@@ -1910,7 +1919,7 @@ function baseRendererFactory() {
1910
1919
  engine
1911
1920
  } = this.context;
1912
1921
  if (engine) {
1913
- engine.props.onCompGetCtx(schema, this);
1922
+ engine.props?.onCompGetCtx?.(schema, this);
1914
1923
  // 画布场景才需要每次渲染bind自定义方法
1915
1924
  if (this.__designModeIsDesign) {
1916
1925
  this.__bindCustomMethods(this.props);
@@ -1927,7 +1936,7 @@ function baseRendererFactory() {
1927
1936
  } = this.props;
1928
1937
  // ref && engine?.props?.onCompGetRef(__schema, ref)
1929
1938
  // TODO: 只在 ref 存在执行,会影响 documentInstance 的卸载
1930
- engine?.props?.onCompGetRef(__schema, ref);
1939
+ engine.props?.onCompGetRef?.(__schema, ref);
1931
1940
  this.__ref = ref;
1932
1941
  };
1933
1942
  __createDom = () => {
@@ -2024,7 +2033,7 @@ function baseRendererFactory() {
2024
2033
  componentId: schema.id,
2025
2034
  enableStrictNotFoundMode: engine.props.enableStrictNotFoundMode,
2026
2035
  ref: ref => {
2027
- ref && engine.props?.onCompGetRef(schema, ref);
2036
+ ref && engine.props?.onCompGetRef?.(schema, ref);
2028
2037
  }
2029
2038
  }, this.__getSchemaChildrenVirtualDom(schema, scope, Comp));
2030
2039
  }
@@ -2099,7 +2108,7 @@ function baseRendererFactory() {
2099
2108
  if (refProps && typeof refProps === 'string') {
2100
2109
  this[refProps] = ref;
2101
2110
  }
2102
- ref && engine.props?.onCompGetRef(schema, ref);
2111
+ ref && engine.props?.onCompGetRef?.(schema, ref);
2103
2112
  };
2104
2113
 
2105
2114
  // scope需要传入到组件上
@@ -2108,7 +2117,7 @@ function baseRendererFactory() {
2108
2117
  // }
2109
2118
  if (schema?.__ctx?.lceKey) {
2110
2119
  if (!isSchema(schema)) {
2111
- engine.props?.onCompGetCtx(schema, scope);
2120
+ engine.props?.onCompGetCtx?.(schema, scope);
2112
2121
  }
2113
2122
  props.key = props.key || `${schema.__ctx.lceKey}_${schema.__ctx.idx || 0}_${idx !== undefined ? idx : ''}`;
2114
2123
  } else if ((typeof idx === 'number' || typeof idx === 'string') && !props.key) {
@@ -2593,7 +2602,8 @@ function rendererFactory() {
2593
2602
  suspended: false,
2594
2603
  schema: {},
2595
2604
  onCompGetRef: () => {},
2596
- onCompGetCtx: () => {}
2605
+ onCompGetCtx: () => {},
2606
+ excuteLifeCycleInDesignMode: false
2597
2607
  };
2598
2608
  constructor(props) {
2599
2609
  super(props);
@@ -52,8 +52,8 @@ export interface RendererProps {
52
52
  /** 设备信息 */
53
53
  device?: 'default' | 'pc' | 'mobile' | string;
54
54
  /**
55
- * @default false
56
55
  * 当开启组件未找到严格模式时,渲染模块不会默认给一个容器组件
56
+ * @default false
57
57
  */
58
58
  enableStrictNotFoundMode?: boolean;
59
59
  /** 获取节点的方法 */
@@ -62,23 +62,29 @@ export interface RendererProps {
62
62
  __host?: Simulator;
63
63
  /** 渲染模块的 container */
64
64
  __container?: SimulatorRenderer;
65
+ /**
66
+ * 是否在设计模式下执行生命周期方法
67
+ * @default false
68
+ */
69
+ excuteLifeCycleInDesignMode?: boolean;
65
70
  }
66
71
  export interface RenderComponent {
67
72
  displayName: string;
68
73
  defaultProps: RendererProps;
69
- new (props: RendererProps): Component<RendererProps, RendererState> & {
70
- [x: string]: any;
71
- __getRef: (ref: any) => void;
72
- componentDidMount(): Promise<void> | void;
73
- componentDidUpdate(): Promise<void> | void;
74
- componentWillUnmount(): Promise<void> | void;
75
- componentDidCatch(e: any): Promise<void> | void;
76
- shouldComponentUpdate(nextProps: RendererProps): boolean;
77
- isValidComponent(SetComponent: any): any;
78
- createElement(SetComponent: any, props: any, children?: any): any;
79
- getNotFoundComponent(): any;
80
- getFaultComponent(): any;
81
- };
74
+ new (props: RendererProps): RendererComponentInstance;
75
+ }
76
+ export interface RendererComponentInstance extends Component<RendererProps, RendererState> {
77
+ [x: string]: any;
78
+ __getRef: (ref: any) => void;
79
+ componentDidMount(): Promise<void> | void;
80
+ componentDidUpdate(): Promise<void> | void;
81
+ componentWillUnmount(): Promise<void> | void;
82
+ componentDidCatch(e: any): Promise<void> | void;
83
+ shouldComponentUpdate(nextProps: RendererProps): boolean;
84
+ isValidComponent(SetComponent: any): any;
85
+ createElement(SetComponent: any, props: any, children?: any): any;
86
+ getNotFoundComponent(): any;
87
+ getFaultComponent(): any;
82
88
  }
83
89
  export interface RendererAppHelper {
84
90
  /** 全局公共函数 */
@@ -117,7 +123,7 @@ export interface DataSource {
117
123
  list?: DataSourceItem[];
118
124
  dataHandler?: JSExpression;
119
125
  }
120
- export interface BaseRendererProps {
126
+ export interface BaseRendererProps extends RendererProps {
121
127
  __appHelper?: RendererAppHelper;
122
128
  __components: Record<string, React.ComponentType>;
123
129
  __ctx?: Record<string, any>;
@@ -143,7 +149,7 @@ export interface BaseRendererProps {
143
149
  export interface BaseRendererContext {
144
150
  appHelper: RendererAppHelper;
145
151
  components: Record<string, React.ComponentType>;
146
- engine: Record<string, any>;
152
+ engine: RendererComponentInstance;
147
153
  pageContext?: BaseRenderComponent;
148
154
  compContext?: BaseRenderComponent;
149
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-editor/react-renderer",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "React Renderer package for EasyEditor.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "url": "https://github.com/Easy-Editor/EasyEditor/issues"
41
41
  },
42
42
  "peerDependencies": {
43
- "@easy-editor/core": "^0.0.13",
43
+ "@easy-editor/core": "^0.0.14",
44
44
  "mobx-react": "^9.2.0",
45
45
  "react": "^18 || ^19",
46
46
  "react-dom": "^18 || ^19",
@@ -56,7 +56,7 @@
56
56
  "@types/lodash-es": "^4.17.12",
57
57
  "@types/prop-types": "^15.7.14",
58
58
  "@types/react-is": "^18.3.0",
59
- "@easy-editor/core": "0.0.13"
59
+ "@easy-editor/core": "0.0.14"
60
60
  },
61
61
  "scripts": {
62
62
  "dev": "deno run --watch ./src/index.ts",