@zzdadelu/schema-builder 1.0.0-alpha.32 → 1.0.0-alpha.34

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 +38 -1
  2. package/lib/main.js +37 -0
  3. package/package.json +1 -1
package/es/main.js CHANGED
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
9
9
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
10
- import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
10
+ import React, { useEffect, useRef, useImperativeHandle, forwardRef, useLayoutEffect } from 'react';
11
11
  import createIframe from './createIframe';
12
12
  import * as defaultSetting from './settings';
13
13
  var iframe;
@@ -57,6 +57,43 @@ var Design = function Design(props, ref) {
57
57
  }
58
58
  }, restProps));
59
59
  };
60
+ var modifyIframeContent = function modifyIframeContent() {
61
+ var iframe = document.getElementsByTagName("iframe")[0];
62
+ console.log(' modifyIframeContent iframe', iframe);
63
+
64
+ // Check if iframe exists and load the document
65
+ if (iframe) {
66
+ iframe.onload = function () {
67
+ var iframeDoc = iframe.contentDocument;
68
+ console.log('modifyIframe iframeDoc', iframeDoc);
69
+ if (iframeDoc) {
70
+ var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
71
+ var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
72
+ console.log('modifyIframe iframeDoc2', iframeDoc2);
73
+ if (iframeDoc2) {
74
+ // Find and replace the target script
75
+ var scripts = iframeDoc2.querySelectorAll('script');
76
+ var targetScript = Array.from(scripts).find(function (script) {
77
+ return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
78
+ });
79
+ if (targetScript) {
80
+ targetScript.remove();
81
+
82
+ // Create new script with timestamp
83
+ var newScript = iframeDoc2.createElement('script');
84
+ newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
85
+ iframeDoc2.body.appendChild(newScript);
86
+ }
87
+ }
88
+ }
89
+ };
90
+ }
91
+ };
92
+
93
+ // 使用 useLayoutEffect 确保修改发生在渲染前
94
+ useLayoutEffect(function () {
95
+ modifyIframeContent();
96
+ }, []);
60
97
  return /*#__PURE__*/React.createElement("div", {
61
98
  ref: containerRef,
62
99
  style: {
package/lib/main.js CHANGED
@@ -65,6 +65,43 @@ var Design = function Design(props, ref) {
65
65
  }
66
66
  }, restProps));
67
67
  };
68
+ var modifyIframeContent = function modifyIframeContent() {
69
+ var iframe = document.getElementsByTagName("iframe")[0];
70
+ console.log(' modifyIframeContent iframe', iframe);
71
+
72
+ // Check if iframe exists and load the document
73
+ if (iframe) {
74
+ iframe.onload = function () {
75
+ var iframeDoc = iframe.contentDocument;
76
+ console.log('modifyIframe iframeDoc', iframeDoc);
77
+ if (iframeDoc) {
78
+ var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
79
+ var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
80
+ console.log('modifyIframe iframeDoc2', iframeDoc2);
81
+ if (iframeDoc2) {
82
+ // Find and replace the target script
83
+ var scripts = iframeDoc2.querySelectorAll('script');
84
+ var targetScript = Array.from(scripts).find(function (script) {
85
+ return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
86
+ });
87
+ if (targetScript) {
88
+ targetScript.remove();
89
+
90
+ // Create new script with timestamp
91
+ var newScript = iframeDoc2.createElement('script');
92
+ newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
93
+ iframeDoc2.body.appendChild(newScript);
94
+ }
95
+ }
96
+ }
97
+ };
98
+ }
99
+ };
100
+
101
+ // 使用 useLayoutEffect 确保修改发生在渲染前
102
+ (0, _react.useLayoutEffect)(function () {
103
+ modifyIframeContent();
104
+ }, []);
68
105
  return /*#__PURE__*/_react.default.createElement("div", {
69
106
  ref: containerRef,
70
107
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.32",
3
+ "version": "1.0.0-alpha.34",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",