neo-register 1.0.3 → 1.0.6
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.esm.js +125 -118
- package/dist/index.esm.min.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.LICENSE.txt +2 -2
- package/dist/{src/main.d.ts → main.d.ts} +1 -0
- package/dist/{src/utils → utils}/index.d.ts +1 -0
- package/docs/EditorItemType.md +856 -0
- package/docs/FormItemType.md +186 -19
- package/docs/NeoCmps.md +100 -0
- package/package.json +1 -1
- package/dist/demo2/entity-detail/index.d.ts +0 -40
- package/dist/demo2/entity-detail/model.d.ts +0 -77
- package/dist/demo2/entity-detail/register.d.ts +0 -1
- package/docs/NeoEntityApiType/xObjectDataApi.md +0 -35
- package/docs/NeoEntityApiType/xObjectDetailApi.md +0 -35
- package/docs/NeoEntityApiType/xObjectEntityList.md +0 -35
- /package/dist/{src/function → function}/registerNeoCmp.d.ts +0 -0
- /package/dist/{src/function → function}/registerNeoEditorModel.d.ts +0 -0
- /package/dist/{src/utils → utils}/object.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,123 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Vue from 'vue';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 将 vue2.0 自定义组件包裹成一个 react组件
|
|
6
|
+
*/
|
|
7
|
+
function createVue2Component(vueObj) {
|
|
8
|
+
if (!vueObj || (typeof vueObj !== 'function' && typeof vueObj !== 'object')) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
class VueFactory extends React.Component {
|
|
12
|
+
domRef;
|
|
13
|
+
vm;
|
|
14
|
+
isUnmount;
|
|
15
|
+
// 指定 contextType 读取当前的 scope context。
|
|
16
|
+
// React 会往上找到最近的 scope Provider,然后使用它的值。
|
|
17
|
+
// static contextType = ScopedContext; // 待支持
|
|
18
|
+
constructor(props, context) {
|
|
19
|
+
super(props);
|
|
20
|
+
this.domRef = React.createRef();
|
|
21
|
+
this.isUnmount = false;
|
|
22
|
+
/*
|
|
23
|
+
// 待支持(自定义组件支持事件动作)
|
|
24
|
+
const scoped = context;
|
|
25
|
+
scoped.registerComponent(this);
|
|
26
|
+
*/
|
|
27
|
+
this.resolveNeoProps = this.resolveNeoProps.bind(this);
|
|
28
|
+
}
|
|
29
|
+
componentDidMount() {
|
|
30
|
+
const { neoData, neoMSTData, neoFunc } = this.resolveNeoProps();
|
|
31
|
+
const { data, ...rest } = (vueObj =
|
|
32
|
+
typeof vueObj === 'function' ? new vueObj() : vueObj);
|
|
33
|
+
const vueData = typeof data === 'function' ? data() : data;
|
|
34
|
+
const curVueData = extendObject(vueData, neoData);
|
|
35
|
+
// 传入的Vue属性
|
|
36
|
+
this.vm = new Vue({
|
|
37
|
+
...rest,
|
|
38
|
+
data: () => curVueData,
|
|
39
|
+
props: extendObject(neoFunc, {
|
|
40
|
+
...(rest.props || {}),
|
|
41
|
+
...neoMSTData,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
Object.keys(neoFunc).forEach((key) => {
|
|
45
|
+
this.vm.$props[key] = neoFunc[key];
|
|
46
|
+
});
|
|
47
|
+
if (this.domRef.current) {
|
|
48
|
+
this.domRef.current.appendChild(this.vm.$mount().$el);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
componentDidUpdate() {
|
|
52
|
+
if (!this.isUnmount) {
|
|
53
|
+
const { neoData } = this.resolveNeoProps();
|
|
54
|
+
if (this.vm) {
|
|
55
|
+
Object.keys(neoData).forEach((key) => {
|
|
56
|
+
this.vm[key] = neoData[key];
|
|
57
|
+
});
|
|
58
|
+
this.vm.$forceUpdate();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
componentWillUnmount() {
|
|
63
|
+
this.isUnmount = true;
|
|
64
|
+
/*
|
|
65
|
+
// 待支持
|
|
66
|
+
const scoped = this.context;
|
|
67
|
+
scoped.unRegisterComponent(this);
|
|
68
|
+
*/
|
|
69
|
+
if (this.vm) {
|
|
70
|
+
this.vm.$destroy();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
resolveNeoProps() {
|
|
74
|
+
let neoFunc = {};
|
|
75
|
+
let neoData = {};
|
|
76
|
+
let neoMSTData = {};
|
|
77
|
+
Object.keys(this.props).forEach((key) => {
|
|
78
|
+
const value = this.props[key];
|
|
79
|
+
if (typeof value === 'function') {
|
|
80
|
+
neoFunc[key] = value;
|
|
81
|
+
}
|
|
82
|
+
else if (isProxy(value)) {
|
|
83
|
+
neoMSTData[key] = value;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
neoData[key] = value;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return { neoData, neoMSTData, neoFunc };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* reload动作处理
|
|
93
|
+
*/
|
|
94
|
+
reload() {
|
|
95
|
+
if (this.vm && this.vm.reload) {
|
|
96
|
+
this.vm.reload();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.warn('自定义组件暂不支持reload动作。');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 事件动作处理:
|
|
104
|
+
* 在这里设置自定义组件对外暴露的动作,其他组件可以通过组件动作触发自定义组件的对应动作
|
|
105
|
+
*/
|
|
106
|
+
doAction(action, args) {
|
|
107
|
+
if (this.vm && this.vm.doAction) {
|
|
108
|
+
this.vm.doAction(action, args);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.warn('自定义组件中不存在 doAction。');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
render() {
|
|
115
|
+
return React.createElement("div", { ref: this.domRef });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return VueFactory;
|
|
119
|
+
}
|
|
120
|
+
|
|
4
121
|
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
5
122
|
function cloneObject(target, persistOwnProps = true) {
|
|
6
123
|
const obj = target && target.__super
|
|
@@ -156,6 +273,13 @@ function isProxy(obj) {
|
|
|
156
273
|
obj.$modelId);
|
|
157
274
|
return (hasMSTProperties || Object.prototype.toString.call(obj) === '[object Proxy]');
|
|
158
275
|
}
|
|
276
|
+
// 自动识别并转换 vue 组件
|
|
277
|
+
function autoConvertVueComponent(component) {
|
|
278
|
+
if (isVueComponent(component)) {
|
|
279
|
+
return createVue2Component(component);
|
|
280
|
+
}
|
|
281
|
+
return component;
|
|
282
|
+
}
|
|
159
283
|
|
|
160
284
|
/**
|
|
161
285
|
* registerNeoEditorModel: 注册 neo-editor 自定义组件模型
|
|
@@ -203,123 +327,6 @@ function AddCustomEditorModel(cmpType, model) {
|
|
|
203
327
|
return null;
|
|
204
328
|
}
|
|
205
329
|
|
|
206
|
-
/**
|
|
207
|
-
* 将 vue2.0 自定义组件包裹成一个 react组件
|
|
208
|
-
*/
|
|
209
|
-
function createVue2Component(vueObj) {
|
|
210
|
-
if (!vueObj || (typeof vueObj !== 'function' && typeof vueObj !== 'object')) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
class VueFactory extends React.Component {
|
|
214
|
-
domRef;
|
|
215
|
-
vm;
|
|
216
|
-
isUnmount;
|
|
217
|
-
// 指定 contextType 读取当前的 scope context。
|
|
218
|
-
// React 会往上找到最近的 scope Provider,然后使用它的值。
|
|
219
|
-
// static contextType = ScopedContext; // 待支持
|
|
220
|
-
constructor(props, context) {
|
|
221
|
-
super(props);
|
|
222
|
-
this.domRef = React.createRef();
|
|
223
|
-
this.isUnmount = false;
|
|
224
|
-
/*
|
|
225
|
-
// 待支持(自定义组件支持事件动作)
|
|
226
|
-
const scoped = context;
|
|
227
|
-
scoped.registerComponent(this);
|
|
228
|
-
*/
|
|
229
|
-
this.resolveNeoProps = this.resolveNeoProps.bind(this);
|
|
230
|
-
}
|
|
231
|
-
componentDidMount() {
|
|
232
|
-
const { neoData, neoMSTData, neoFunc } = this.resolveNeoProps();
|
|
233
|
-
const { data, ...rest } = (vueObj =
|
|
234
|
-
typeof vueObj === 'function' ? new vueObj() : vueObj);
|
|
235
|
-
const vueData = typeof data === 'function' ? data() : data;
|
|
236
|
-
const curVueData = extendObject(vueData, neoData);
|
|
237
|
-
// 传入的Vue属性
|
|
238
|
-
this.vm = new Vue({
|
|
239
|
-
...rest,
|
|
240
|
-
data: () => curVueData,
|
|
241
|
-
props: extendObject(neoFunc, {
|
|
242
|
-
...(rest.props || {}),
|
|
243
|
-
...neoMSTData,
|
|
244
|
-
}),
|
|
245
|
-
});
|
|
246
|
-
Object.keys(neoFunc).forEach((key) => {
|
|
247
|
-
this.vm.$props[key] = neoFunc[key];
|
|
248
|
-
});
|
|
249
|
-
if (this.domRef.current) {
|
|
250
|
-
this.domRef.current.appendChild(this.vm.$mount().$el);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
componentDidUpdate() {
|
|
254
|
-
if (!this.isUnmount) {
|
|
255
|
-
const { neoData } = this.resolveNeoProps();
|
|
256
|
-
if (this.vm) {
|
|
257
|
-
Object.keys(neoData).forEach((key) => {
|
|
258
|
-
this.vm[key] = neoData[key];
|
|
259
|
-
});
|
|
260
|
-
this.vm.$forceUpdate();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
componentWillUnmount() {
|
|
265
|
-
this.isUnmount = true;
|
|
266
|
-
/*
|
|
267
|
-
// 待支持
|
|
268
|
-
const scoped = this.context;
|
|
269
|
-
scoped.unRegisterComponent(this);
|
|
270
|
-
*/
|
|
271
|
-
if (this.vm) {
|
|
272
|
-
this.vm.$destroy();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
resolveNeoProps() {
|
|
276
|
-
let neoFunc = {};
|
|
277
|
-
let neoData = {};
|
|
278
|
-
let neoMSTData = {};
|
|
279
|
-
Object.keys(this.props).forEach((key) => {
|
|
280
|
-
const value = this.props[key];
|
|
281
|
-
if (typeof value === 'function') {
|
|
282
|
-
neoFunc[key] = value;
|
|
283
|
-
}
|
|
284
|
-
else if (isProxy(value)) {
|
|
285
|
-
neoMSTData[key] = value;
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
neoData[key] = value;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
return { neoData, neoMSTData, neoFunc };
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* reload动作处理
|
|
295
|
-
*/
|
|
296
|
-
reload() {
|
|
297
|
-
if (this.vm && this.vm.reload) {
|
|
298
|
-
this.vm.reload();
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
console.warn('自定义组件暂不支持reload动作。');
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* 事件动作处理:
|
|
306
|
-
* 在这里设置自定义组件对外暴露的动作,其他组件可以通过组件动作触发自定义组件的对应动作
|
|
307
|
-
*/
|
|
308
|
-
doAction(action, args) {
|
|
309
|
-
if (this.vm && this.vm.doAction) {
|
|
310
|
-
this.vm.doAction(action, args);
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
console.warn('自定义组件中不存在 doAction。');
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
render() {
|
|
317
|
-
return React.createElement("div", { ref: this.domRef });
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return VueFactory;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
330
|
/**
|
|
324
331
|
* registerNeoCmp: 根据type类型注册 neo 自定义组件
|
|
325
332
|
*【方法参数说明】
|
|
@@ -422,4 +429,4 @@ function AddNeoCustomModel(componentType, rendererData) {
|
|
|
422
429
|
return null;
|
|
423
430
|
}
|
|
424
431
|
|
|
425
|
-
export { createVue2Component, registerNeoCmp, registerNeoEditorModel };
|
|
432
|
+
export { autoConvertVueComponent, createVue2Component, registerNeoCmp, registerNeoEditorModel };
|
package/dist/index.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import o from"vue";function t(e,o,t=!0){const r=function(e,o=!0){const t=e&&e.__super?Object.create(e.__super,{__super:{value:e.__super,writable:!1,enumerable:!1}}):Object.create(Object.prototype);return o&&e&&Object.keys(e).forEach(o=>t[o]=e[o]),t}(e,t);return o&&Object.keys(o).forEach(e=>r[e]=o[e]),r}const
|
|
1
|
+
import e from"react";import o from"vue";function t(t){if(t&&("function"==typeof t||"object"==typeof t)){class n extends e.Component{domRef;vm;isUnmount;constructor(o,t){super(o),this.domRef=e.createRef(),this.isUnmount=!1,this.resolveNeoProps=this.resolveNeoProps.bind(this)}componentDidMount(){const{neoData:e,neoMSTData:n,neoFunc:s}=this.resolveNeoProps(),{data:i,...c}=t="function"==typeof t?new t:t,a=r("function"==typeof i?i():i,e);this.vm=new o({...c,data:()=>a,props:r(s,{...c.props||{},...n})}),Object.keys(s).forEach(e=>{this.vm.$props[e]=s[e]}),this.domRef.current&&this.domRef.current.appendChild(this.vm.$mount().$el)}componentDidUpdate(){if(!this.isUnmount){const{neoData:e}=this.resolveNeoProps();this.vm&&(Object.keys(e).forEach(o=>{this.vm[o]=e[o]}),this.vm.$forceUpdate())}}componentWillUnmount(){this.isUnmount=!0,this.vm&&this.vm.$destroy()}resolveNeoProps(){let e={},o={},t={};return Object.keys(this.props).forEach(r=>{const n=this.props[r];"function"==typeof n?e[r]=n:!function(e){if(!e)return!1;return!!(e.$treenode||e.$mstObservable||e.$modelType||e.$modelId)||"[object Proxy]"===Object.prototype.toString.call(e)}(n)?o[r]=n:t[r]=n}),{neoData:o,neoMSTData:t,neoFunc:e}}reload(){this.vm&&this.vm.reload?this.vm.reload():console.warn("自定义组件暂不支持reload动作。")}doAction(e,o){this.vm&&this.vm.doAction?this.vm.doAction(e,o):console.warn("自定义组件中不存在 doAction。")}render(){return e.createElement("div",{ref:this.domRef})}}return n}}function r(e,o,t=!0){const r=function(e,o=!0){const t=e&&e.__super?Object.create(e.__super,{__super:{value:e.__super,writable:!1,enumerable:!1}}):Object.create(Object.prototype);return o&&e&&Object.keys(e).forEach(o=>t[o]=e[o]),t}(e,t);return o&&Object.keys(o).forEach(e=>r[e]=o[e]),r}const n="[neo-register]";function s(e){return"object"==typeof e&&(e._compiled&&e.components||e.__file&&e.__file.endsWith(".vue"))}var i,c;function a(e){return s(e)?t(e):e}function u(e,o){if(e&&function(e){let o=!1;if(!e)return!1;const t=new e;return t.label?t.tags?Array.isArray(t.tags)?(t.icon||Object.assign(e.prototype,{icon:"https://neo-widgets.bj.bcebos.com/custom-widget.svg"}),o=!0):console.error(`${n} / registerNeoEditorModel: 自定义组件注册失败,组件分类(tags)格式异常。`):console.error(`${n} / registerNeoEditorModel: 自定义组件注册失败,组件分类(tags)不能为空。`):console.error(`${n} / registerNeoEditorModel: 自定义组件注册失败,名称(label)不能为空。`),o}(e)){const t=o||(new e).cmpType;t||console.error(`${n} / registerNeoEditorModel: 自定义组件注册失败,cmpType 不能为空。`);const r=new e;if(Object.assign(e.prototype,{custom:!0,exposedToDesigner:r.exposedToDesigner??!0,namespace:r.namespace??"neo-cmp-cli",enableDuplicate:r.enableDuplicate??!0,cmpType:t}),window&&window.postMessage){const o=function(e,o){window&&!window.NEOEditorCustomModels&&(window.NEOEditorCustomModels={});if(!window.NEOEditorCustomModels[e])return window.NEOEditorCustomModels[e]=o,e;console.error(`${n}注册自定义组件模型失败,已存在重名插件(${e})。`);return null}(t,e);o&&(console.info(`${n}触发注册自定义组件模型(${t})事件`),window.postMessage({type:"neo-model-register-event",eventMsg:`${n}注册一个 neo-editor 自定义组件模型`,cmpType:t},"*"))}}}function m(e,o){if(!e)return;const r={cmpType:"",usage:i.renderer,weight:0};var a;if(o&&(a=o,"String"===Object.prototype.toString.call(a).slice(8,-1))?Object.assign(r,{cmpType:o}):Object.assign(r,o),r&&!r.cmpType)console.error(`${n} / registerNeoCmp: 自定义组件注册失败,cmpType 不能为空。`);else{r.framework=r.framework?function(e){let o=c.react;if(!e)return o;let t=e.toLowerCase().trim();switch(t){case"jquery":case"jq":t=c.jquery;break;case"vue2":case"vue 2":case"vue2.0":case"vue 2.0":t=c.vue2;break;case"vue":case"vue3":case"vue 3":case"vue3.0":case"vue 3.0":t=c.vue3,console.error(`${n} 暂不支持 vue3.0 技术栈。`);break;default:t=c.react}return t}(r.framework):s(e)?"vue2":"react",r.usage=function(e){let o=i.renderer;if(!e)return o;let t=e.toLowerCase().trim();switch(t){case"renderer":case"renderers":default:t=i.renderer;break;case"formitem":case"form-item":case"form item":t=i.formitem}return t}(r.usage);const o={renderer:()=>{},formitem:()=>{}},a={react:e=>e,vue2:t,vue3:t}[r.framework](e);if(o[r.usage]){if(window&&window.postMessage){const e=function(e,o){window&&!window.NeoCustomCmps&&(window.NeoCustomCmps={});if(!window.NeoCustomCmps[e])return window.NeoCustomCmps[e]=o,e;console.error(`${n} / registerNeoCmp: 自定义组件注册失败,已存在重名渲染器(${e})。`);return null}(r.cmpType,{cmpType:r.cmpType,weight:r.weight,usage:r.usage,framework:r.framework,component:a,config:r});e&&(console.info(`${n}触发注册自定义组件(${e})事件`),window.postMessage({type:"neo-cmp-register-event",eventMsg:`${n}注册一个自定义组件`,neoRenderer:{cmpType:e,weight:r.weight,usage:r.usage,config:r}},"*"))}}else console.error(`${n} / registerNeoCmp: 自定义组件注册失败,暂不支持 ${r.usage} 组件类型。`)}}!function(e){e.renderer="renderer",e.formitem="formitem"}(i||(i={})),function(e){e.react="react",e.vue2="vue2",e.vue3="vue3",e.jquery="jquery"}(c||(c={}));export{a as autoConvertVueComponent,t as createVue2Component,m as registerNeoCmp,u as registerNeoEditorModel};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.umd.js.LICENSE.txt */
|
|
2
|
-
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.neoRegister=o():e.neoRegister=o()}(this,function(){return function(){"use strict";var e={n:function(o){var r=o&&o.__esModule?function(){return o.default}:function(){return o};return e.d(r,{a:r}),r},d:function(o,r){for(var t in r)e.o(r,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:r[t]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{createVue2Component:function(){return
|
|
2
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.neoRegister=o():e.neoRegister=o()}(this,function(){return function(){"use strict";var e={n:function(o){var r=o&&o.__esModule?function(){return o.default}:function(){return o};return e.d(r,{a:r}),r},d:function(o,r){for(var t in r)e.o(r,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:r[t]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{autoConvertVueComponent:function(){return b},createVue2Component:function(){return d},registerNeoCmp:function(){return j},registerNeoEditorModel:function(){return h}});var r=require("@babel/runtime/helpers/extends"),t=e.n(r),n=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),i=e.n(n),s=require("@babel/runtime/helpers/inheritsLoose"),u=e.n(s),c=require("react"),a=e.n(c),p=require("vue"),f=e.n(p),m=["data"];function d(e){if(e&&("function"==typeof e||"object"==typeof e))return function(o){function r(e,r){var t;return(t=o.call(this,e)||this).domRef=void 0,t.vm=void 0,t.isUnmount=void 0,t.domRef=a().createRef(),t.isUnmount=!1,t.resolveNeoProps=t.resolveNeoProps.bind(t),t}u()(r,o);var n=r.prototype;return n.componentDidMount=function(){var o=this,r=this.resolveNeoProps(),n=r.neoData,s=r.neoMSTData,u=r.neoFunc,c=e="function"==typeof e?new e:e,a=c.data,p=i()(c,m),d=l("function"==typeof a?a():a,n);this.vm=new(f())(t()({},p,{data:function(){return d},props:l(u,t()({},p.props||{},s))})),Object.keys(u).forEach(function(e){o.vm.$props[e]=u[e]}),this.domRef.current&&this.domRef.current.appendChild(this.vm.$mount().$el)},n.componentDidUpdate=function(){var e=this;if(!this.isUnmount){var o=this.resolveNeoProps().neoData;this.vm&&(Object.keys(o).forEach(function(r){e.vm[r]=o[r]}),this.vm.$forceUpdate())}},n.componentWillUnmount=function(){this.isUnmount=!0,this.vm&&this.vm.$destroy()},n.resolveNeoProps=function(){var e=this,o={},r={},t={};return Object.keys(this.props).forEach(function(n){var i,s=e.props[n];"function"==typeof s?o[n]=s:(i=s)&&(i.$treenode||i.$mstObservable||i.$modelType||i.$modelId||"[object Proxy]"===Object.prototype.toString.call(i))?t[n]=s:r[n]=s}),{neoData:r,neoMSTData:t,neoFunc:o}},n.reload=function(){this.vm&&this.vm.reload?this.vm.reload():console.warn("自定义组件暂不支持reload动作。")},n.doAction=function(e,o){this.vm&&this.vm.doAction?this.vm.doAction(e,o):console.warn("自定义组件中不存在 doAction。")},n.render=function(){return a().createElement("div",{ref:this.domRef})},r}(a().Component)}function l(e,o,r){void 0===r&&(r=!0);var t=function(e,o){void 0===o&&(o=!0);var r=e&&e.__super?Object.create(e.__super,{__super:{value:e.__super,writable:!1,enumerable:!1}}):Object.create(Object.prototype);return o&&e&&Object.keys(e).forEach(function(o){return r[o]=e[o]}),r}(e,r);return o&&Object.keys(o).forEach(function(e){return t[e]=o[e]}),t}var v,w,g="[neo-register]";function y(e){return"object"==typeof e&&(e._compiled&&e.components||e.__file&&e.__file.endsWith(".vue"))}function b(e){return y(e)?d(e):e}function h(e,o){if(e&&function(e){var o=!1;if(!e)return!1;var r=new e;return r.label?r.tags?Array.isArray(r.tags)?(r.icon||Object.assign(e.prototype,{icon:"https://neo-widgets.bj.bcebos.com/custom-widget.svg"}),o=!0):console.error(g+" / registerNeoEditorModel: 自定义组件注册失败,组件分类(tags)格式异常。"):console.error(g+" / registerNeoEditorModel: 自定义组件注册失败,组件分类(tags)不能为空。"):console.error(g+" / registerNeoEditorModel: 自定义组件注册失败,名称(label)不能为空。"),o}(e)){var r,t,n,i=o||(new e).cmpType;i||console.error(g+" / registerNeoEditorModel: 自定义组件注册失败,cmpType 不能为空。");var s=new e;if(Object.assign(e.prototype,{custom:!0,exposedToDesigner:null==(r=s.exposedToDesigner)||r,namespace:null!=(t=s.namespace)?t:"neo-cmp-cli",enableDuplicate:null==(n=s.enableDuplicate)||n,cmpType:i}),window&&window.postMessage){var u=function(e,o){return window&&!window.NEOEditorCustomModels&&(window.NEOEditorCustomModels={}),window.NEOEditorCustomModels[e]?(console.error(g+"注册自定义组件模型失败,已存在重名插件("+e+")。"),null):(window.NEOEditorCustomModels[e]=o,e)}(i,e);u&&(console.info(g+"触发注册自定义组件模型("+i+")事件"),window.postMessage({type:"neo-model-register-event",eventMsg:g+"注册一个 neo-editor 自定义组件模型",cmpType:i},"*"))}}}function j(e,o){if(e){var r,t={cmpType:"",usage:v.renderer,weight:0};if(o&&(r=o,"String"===Object.prototype.toString.call(r).slice(8,-1))?Object.assign(t,{cmpType:o}):Object.assign(t,o),t&&!t.cmpType)console.error(g+" / registerNeoCmp: 自定义组件注册失败,cmpType 不能为空。");else{t.framework=t.framework?function(e){var o=w.react;if(!e)return o;var r=e.toLowerCase().trim();switch(r){case"jquery":case"jq":r=w.jquery;break;case"vue2":case"vue 2":case"vue2.0":case"vue 2.0":r=w.vue2;break;case"vue":case"vue3":case"vue 3":case"vue3.0":case"vue 3.0":r=w.vue3,console.error(g+" 暂不支持 vue3.0 技术栈。");break;default:r=w.react}return r}(t.framework):y(e)?"vue2":"react",t.usage=function(e){var o=v.renderer;if(!e)return o;var r=e.toLowerCase().trim();switch(r){case"renderer":case"renderers":default:r=v.renderer;break;case"formitem":case"form-item":case"form item":r=v.formitem}return r}(t.usage);var n={react:function(e){return e},vue2:d,vue3:d}[t.framework](e);if({renderer:function(){},formitem:function(){}}[t.usage]){if(window&&window.postMessage){var i=(s=t.cmpType,u={cmpType:t.cmpType,weight:t.weight,usage:t.usage,framework:t.framework,component:n,config:t},window&&!window.NeoCustomCmps&&(window.NeoCustomCmps={}),window.NeoCustomCmps[s]?(console.error(g+" / registerNeoCmp: 自定义组件注册失败,已存在重名渲染器("+s+")。"),null):(window.NeoCustomCmps[s]=u,s));i&&(console.info(g+"触发注册自定义组件("+i+")事件"),window.postMessage({type:"neo-cmp-register-event",eventMsg:g+"注册一个自定义组件",neoRenderer:{cmpType:i,weight:t.weight,usage:t.usage,config:t}},"*"))}}else console.error(g+" / registerNeoCmp: 自定义组件注册失败,暂不支持 "+t.usage+" 组件类型。")}}var s,u}return function(e){e.renderer="renderer",e.formitem="formitem"}(v||(v={})),function(e){e.react="react",e.vue2="vue2",e.vue3="vue3",e.jquery="jquery"}(w||(w={})),o}()});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* neo-register v1.0.
|
|
2
|
+
* neo-register v1.0.5
|
|
3
3
|
* author: wibetter
|
|
4
4
|
* build tool: AKFun
|
|
5
|
-
* build time:
|
|
5
|
+
* build time: Wed Nov 12 2025 14:21:11 GMT+0800 (中国标准时间)
|
|
6
6
|
* build tool info: https://github.com/wibetter/akfun
|
|
7
7
|
*/
|
|
@@ -36,3 +36,4 @@ export declare function isEditorModel(EditorModelClass: any): boolean;
|
|
|
36
36
|
export declare function isString(str: any): boolean;
|
|
37
37
|
export declare function isObject(obj: any): boolean;
|
|
38
38
|
export declare function isProxy(obj: any): boolean;
|
|
39
|
+
export declare function autoConvertVueComponent(component: any): any;
|