@zzdadelu/schema-builder 1.0.0-alpha.113 → 1.0.0-alpha.116

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.
Files changed (3) hide show
  1. package/es/main.js +25 -10
  2. package/lib/main.js +25 -10
  3. package/package.json +1 -1
package/es/main.js CHANGED
@@ -40,22 +40,37 @@ var Design = function Design(props, ref) {
40
40
  containerRef.current.appendChild(iframe);
41
41
  };
42
42
  var engineOnLoad = function engineOnLoad(event) {
43
- var _iframe3, _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2;
43
+ var _iframe3, _outerIframeWindow$__;
44
44
  if (event.data.type !== 'engine-load') {
45
45
  return;
46
46
  }
47
+ var outerIframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
48
+ if (!outerIframeWindow) return;
47
49
 
48
- // --- 解决方案开始 ---
49
- var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
50
- var iframeDoc = iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.document;
51
- if (!iframeWindow || !iframeDoc) {
52
- console.error('Iframe 窗口或文档引用丢失。');
53
- return;
54
- }
55
- (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : (_iframe4$contentWindo = _iframe4.contentWindow) === null || _iframe4$contentWindo === void 0 ? void 0 : (_iframe4$contentWindo2 = _iframe4$contentWindo.__FR_ENGINE__) === null || _iframe4$contentWindo2 === void 0 ? void 0 : _iframe4$contentWindo2.init(_objectSpread({
50
+ // 尝试监听外层 iframe 内部文档的变化
51
+ var innerDoc = outerIframeWindow.document;
52
+ if (!innerDoc) return;
53
+
54
+ // 创建一个 MutationObserver 来监听外层 iframe 内部 iframe 的创建
55
+ var innerObserver = new MutationObserver(function (mutations) {
56
+ console.log('检测到内层 iframe 被添加......');
57
+ mutations.forEach(function (mutation) {
58
+ mutation.addedNodes.forEach(function (node) {
59
+ console.log('检测到内层 iframe 被添加', node);
60
+ });
61
+ });
62
+ });
63
+
64
+ // 开始观察外层 iframe 内部 body 的变化
65
+ innerObserver.observe(innerDoc.body, {
66
+ childList: true,
67
+ subtree: true
68
+ });
69
+
70
+ // 初始化 __FR_ENGINE__
71
+ (_outerIframeWindow$__ = outerIframeWindow.__FR_ENGINE__) === null || _outerIframeWindow$__ === void 0 ? void 0 : _outerIframeWindow$__.init(_objectSpread({
56
72
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
57
73
  widgets: widgets,
58
- // recordEnable: true,
59
74
  logo: {
60
75
  title: 'XRender'
61
76
  }
package/lib/main.js CHANGED
@@ -48,22 +48,37 @@ var Design = function Design(props, ref) {
48
48
  containerRef.current.appendChild(iframe);
49
49
  };
50
50
  var engineOnLoad = function engineOnLoad(event) {
51
- var _iframe3, _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2;
51
+ var _iframe3, _outerIframeWindow$__;
52
52
  if (event.data.type !== 'engine-load') {
53
53
  return;
54
54
  }
55
+ var outerIframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
56
+ if (!outerIframeWindow) return;
55
57
 
56
- // --- 解决方案开始 ---
57
- var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
58
- var iframeDoc = iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.document;
59
- if (!iframeWindow || !iframeDoc) {
60
- console.error('Iframe 窗口或文档引用丢失。');
61
- return;
62
- }
63
- (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : (_iframe4$contentWindo = _iframe4.contentWindow) === null || _iframe4$contentWindo === void 0 ? void 0 : (_iframe4$contentWindo2 = _iframe4$contentWindo.__FR_ENGINE__) === null || _iframe4$contentWindo2 === void 0 ? void 0 : _iframe4$contentWindo2.init(_objectSpread({
58
+ // 尝试监听外层 iframe 内部文档的变化
59
+ var innerDoc = outerIframeWindow.document;
60
+ if (!innerDoc) return;
61
+
62
+ // 创建一个 MutationObserver 来监听外层 iframe 内部 iframe 的创建
63
+ var innerObserver = new MutationObserver(function (mutations) {
64
+ console.log('检测到内层 iframe 被添加......');
65
+ mutations.forEach(function (mutation) {
66
+ mutation.addedNodes.forEach(function (node) {
67
+ console.log('检测到内层 iframe 被添加', node);
68
+ });
69
+ });
70
+ });
71
+
72
+ // 开始观察外层 iframe 内部 body 的变化
73
+ innerObserver.observe(innerDoc.body, {
74
+ childList: true,
75
+ subtree: true
76
+ });
77
+
78
+ // 初始化 __FR_ENGINE__
79
+ (_outerIframeWindow$__ = outerIframeWindow.__FR_ENGINE__) === null || _outerIframeWindow$__ === void 0 ? void 0 : _outerIframeWindow$__.init(_objectSpread({
64
80
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
65
81
  widgets: widgets,
66
- // recordEnable: true,
67
82
  logo: {
68
83
  title: 'XRender'
69
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.113",
3
+ "version": "1.0.0-alpha.116",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",