@easy-editor/react-renderer 0.0.12 → 0.0.14

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,12 @@ function baseRendererFactory() {
1757
1757
  * execute method in schema.lifeCycles
1758
1758
  */
1759
1759
  __executeLifeCycleMethod = (method, args) => {
1760
+ const {
1761
+ engine
1762
+ } = this.context;
1763
+ if (!engine.props.enableStrictNotFoundMode) {
1764
+ return;
1765
+ }
1760
1766
  executeLifeCycleMethod(this, this.props.__schema, method, args);
1761
1767
  };
1762
1768
 
@@ -1910,7 +1916,7 @@ function baseRendererFactory() {
1910
1916
  engine
1911
1917
  } = this.context;
1912
1918
  if (engine) {
1913
- engine.props.onCompGetCtx(schema, this);
1919
+ engine.props?.onCompGetCtx?.(schema, this);
1914
1920
  // 画布场景才需要每次渲染bind自定义方法
1915
1921
  if (this.__designModeIsDesign) {
1916
1922
  this.__bindCustomMethods(this.props);
@@ -1927,7 +1933,7 @@ function baseRendererFactory() {
1927
1933
  } = this.props;
1928
1934
  // ref && engine?.props?.onCompGetRef(__schema, ref)
1929
1935
  // TODO: 只在 ref 存在执行,会影响 documentInstance 的卸载
1930
- engine?.props?.onCompGetRef(__schema, ref);
1936
+ engine.props?.onCompGetRef?.(__schema, ref);
1931
1937
  this.__ref = ref;
1932
1938
  };
1933
1939
  __createDom = () => {
@@ -2024,7 +2030,7 @@ function baseRendererFactory() {
2024
2030
  componentId: schema.id,
2025
2031
  enableStrictNotFoundMode: engine.props.enableStrictNotFoundMode,
2026
2032
  ref: ref => {
2027
- ref && engine.props?.onCompGetRef(schema, ref);
2033
+ ref && engine.props?.onCompGetRef?.(schema, ref);
2028
2034
  }
2029
2035
  }, this.__getSchemaChildrenVirtualDom(schema, scope, Comp));
2030
2036
  }
@@ -2099,7 +2105,7 @@ function baseRendererFactory() {
2099
2105
  if (refProps && typeof refProps === 'string') {
2100
2106
  this[refProps] = ref;
2101
2107
  }
2102
- ref && engine.props?.onCompGetRef(schema, ref);
2108
+ ref && engine.props?.onCompGetRef?.(schema, ref);
2103
2109
  };
2104
2110
 
2105
2111
  // scope需要传入到组件上
@@ -2108,7 +2114,7 @@ function baseRendererFactory() {
2108
2114
  // }
2109
2115
  if (schema?.__ctx?.lceKey) {
2110
2116
  if (!isSchema(schema)) {
2111
- engine.props?.onCompGetCtx(schema, scope);
2117
+ engine.props?.onCompGetCtx?.(schema, scope);
2112
2118
  }
2113
2119
  props.key = props.key || `${schema.__ctx.lceKey}_${schema.__ctx.idx || 0}_${idx !== undefined ? idx : ''}`;
2114
2120
  } else if ((typeof idx === 'number' || typeof idx === 'string') && !props.key) {
@@ -2593,7 +2599,8 @@ function rendererFactory() {
2593
2599
  suspended: false,
2594
2600
  schema: {},
2595
2601
  onCompGetRef: () => {},
2596
- onCompGetCtx: () => {}
2602
+ onCompGetCtx: () => {},
2603
+ excuteLifeCycleInDesignMode: false
2597
2604
  };
2598
2605
  constructor(props) {
2599
2606
  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.12",
3
+ "version": "0.0.14",
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.12",
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.12"
59
+ "@easy-editor/core": "0.0.14"
60
60
  },
61
61
  "scripts": {
62
62
  "dev": "deno run --watch ./src/index.ts",