@fonixtree/magic-design 2.0.12 → 2.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.
Binary file
@@ -11,6 +11,8 @@ var _defaultJSON = require("./defaultJSON");
11
11
 
12
12
  var _compositeDecorator = _interopRequireDefault(require("../../../../decorator/compositeDecorator"));
13
13
 
14
+ var _coreUtil = require("../../../../utils/coreUtil");
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
17
 
16
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -63,58 +65,66 @@ function (_super) {
63
65
  function CustomCode() {
64
66
  var _this = _super !== null && _super.apply(this, arguments) || this;
65
67
 
66
- _this.htmlTemp = '';
67
-
68
- _this.createHtml = function () {
69
- var nodeData = _this.props.nodeData;
70
- console.log('----nodeData', nodeData);
71
- var htmlCode = window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html;
72
- _this.htmlTemp = htmlCode;
73
-
74
- if (document.getElementById('custom-wrap')) {
75
- document.getElementById('custom-wrap').innerHTML = htmlCode;
76
- }
68
+ _this.htmlTemp = ''; // createHtml = () => {
69
+ // const { nodeData } = this.props;
70
+ // const htmlCode = window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html;
71
+ // this.htmlTemp = htmlCode;
72
+ // if (document.getElementById('custom-wrap')) {
73
+ // document.getElementById('custom-wrap').innerHTML = htmlCode;
74
+ // }
75
+ // }
76
+
77
+ _this.handleClick = function (e) {
78
+ console.log(e.target.getAttribute('href'));
79
+ (0, _coreUtil.clickUrl)(e.target.getAttribute('href'));
77
80
  };
78
81
 
79
82
  return _this;
80
83
  }
81
84
 
82
85
  CustomCode.prototype.componentDidMount = function () {
83
- this.createHtml();
84
- };
85
-
86
- CustomCode.prototype.componentWillReceiveProps = function (prevProps) {
87
- console.log('111111');
86
+ var _this = this;
88
87
 
89
- if (window.magicDesign.device === 'pc') {
90
- console.log('22222222');
88
+ var aElements = document.querySelectorAll('#custom-wrap a');
89
+ aElements.forEach(function (element) {
90
+ element.addEventListener('click', _this.handleClick);
91
+ });
92
+ };
91
93
 
92
- if (prevProps.nodeData.content.pcHtml != this.props.nodeData.content.pcHtml) {
93
- console.log('4444444');
94
- this.createHtml();
95
- }
96
- } else {
97
- console.log('3333333333', this.htmlTemp, this.props.nodeData.content);
94
+ CustomCode.prototype.componentWillUnmount = function () {
95
+ var _this = this;
96
+
97
+ var aElements = document.querySelectorAll('#custom-wrap a');
98
+ aElements.forEach(function (element) {
99
+ element.removeEventListener('click', _this.handleClick);
100
+ });
101
+ }; // componentWillReceiveProps(prevProps) {
102
+ // console.log('111111');
103
+ // if (window.magicDesign.device === 'pc') {
104
+ // console.log('22222222');
105
+ // if (prevProps.nodeData.content.pcHtml != this.props.nodeData.content.pcHtml) {
106
+ // console.log('4444444');
107
+ // this.createHtml();
108
+ // }
109
+ // } else {
110
+ // console.log('3333333333', this.htmlTemp, this.props.nodeData.content);
111
+ // if (this.htmlTemp != this.props.nodeData.content.h5Html) {
112
+ // console.log('5555555');
113
+ // this.createHtml();
114
+ // }
115
+ // }
116
+ // }
98
117
 
99
- if (this.htmlTemp != this.props.nodeData.content.h5Html) {
100
- console.log('5555555');
101
- this.createHtml();
102
- }
103
- }
104
- };
105
118
 
106
119
  CustomCode.prototype.render = function () {
107
- // const { nodeData } = this.props;
108
- // console.log('----nodeData', nodeData);
109
- return (
110
- /*#__PURE__*/
111
- // <div dangerouslySetInnerHTML={{ __html: window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html }} />
112
- _react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
113
- id: "custom-wrap"
114
- }), /*#__PURE__*/_react["default"].createElement("a", {
115
- href: "https://www.baidu.com"
116
- }, "baidu11 "))
117
- );
120
+ var nodeData = this.props.nodeData;
121
+ return /*#__PURE__*/_react["default"].createElement("div", {
122
+ id: "custom-wrap"
123
+ }, /*#__PURE__*/_react["default"].createElement("div", {
124
+ dangerouslySetInnerHTML: {
125
+ __html: window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html
126
+ }
127
+ }));
118
128
  };
119
129
 
120
130
  CustomCode.defaultProps = {};
@@ -65,11 +65,12 @@ function History(_a) {
65
65
  var newSource = source.filter(function (src, index) {
66
66
  return !selected.includes(index);
67
67
  });
68
- var newSelectIndex = source.findIndex(function (src) {
69
- return src.key === selected;
68
+ var newSelectIndex = newSource.findIndex(function (src) {
69
+ return src.key === selectKey;
70
70
  });
71
71
  onChange(newSource.length ? newSource : [], newSelectIndex);
72
72
  setIsEdit(false);
73
+ setSelected([]);
73
74
  };
74
75
 
75
76
  var onHisItemClick = function onHisItemClick(index) {
@@ -107,7 +108,7 @@ function History(_a) {
107
108
  }, source.length > 0 && source.map(function (his, index) {
108
109
  return /*#__PURE__*/_react["default"].createElement("div", {
109
110
  className: (0, _classnames["default"])('historyNode', {
110
- active: selectKey === index
111
+ active: selectKey === his.key
111
112
  }),
112
113
  onClick: function onClick() {
113
114
  return onHisItemClick(index);
@@ -246,13 +246,17 @@ function (_super) {
246
246
  _this.onHisConfigClick = function () {};
247
247
 
248
248
  _this.historyChange = function (newHis, newIndex) {
249
+ if (newIndex === void 0) {
250
+ newIndex = null;
251
+ }
252
+
249
253
  (0, _storeUtil.setSessionStore)(_constants.STORAGE_KEY.FONIXTREE_AI_IMG_HIS, newHis);
250
254
 
251
255
  _this.setState({
252
256
  history: newHis
253
257
  });
254
258
 
255
- if (newIndex) {
259
+ if (newIndex !== null) {
256
260
  _this.setState({
257
261
  hisCursor: newIndex
258
262
  });
Binary file
@@ -11,6 +11,8 @@ var _defaultJSON = require("./defaultJSON");
11
11
 
12
12
  var _compositeDecorator = _interopRequireDefault(require("../../../../decorator/compositeDecorator"));
13
13
 
14
+ var _coreUtil = require("../../../../utils/coreUtil");
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
17
 
16
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -63,58 +65,66 @@ function (_super) {
63
65
  function CustomCode() {
64
66
  var _this = _super !== null && _super.apply(this, arguments) || this;
65
67
 
66
- _this.htmlTemp = '';
67
-
68
- _this.createHtml = function () {
69
- var nodeData = _this.props.nodeData;
70
- console.log('----nodeData', nodeData);
71
- var htmlCode = window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html;
72
- _this.htmlTemp = htmlCode;
73
-
74
- if (document.getElementById('custom-wrap')) {
75
- document.getElementById('custom-wrap').innerHTML = htmlCode;
76
- }
68
+ _this.htmlTemp = ''; // createHtml = () => {
69
+ // const { nodeData } = this.props;
70
+ // const htmlCode = window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html;
71
+ // this.htmlTemp = htmlCode;
72
+ // if (document.getElementById('custom-wrap')) {
73
+ // document.getElementById('custom-wrap').innerHTML = htmlCode;
74
+ // }
75
+ // }
76
+
77
+ _this.handleClick = function (e) {
78
+ console.log(e.target.getAttribute('href'));
79
+ (0, _coreUtil.clickUrl)(e.target.getAttribute('href'));
77
80
  };
78
81
 
79
82
  return _this;
80
83
  }
81
84
 
82
85
  CustomCode.prototype.componentDidMount = function () {
83
- this.createHtml();
84
- };
85
-
86
- CustomCode.prototype.componentWillReceiveProps = function (prevProps) {
87
- console.log('111111');
86
+ var _this = this;
88
87
 
89
- if (window.magicDesign.device === 'pc') {
90
- console.log('22222222');
88
+ var aElements = document.querySelectorAll('#custom-wrap a');
89
+ aElements.forEach(function (element) {
90
+ element.addEventListener('click', _this.handleClick);
91
+ });
92
+ };
91
93
 
92
- if (prevProps.nodeData.content.pcHtml != this.props.nodeData.content.pcHtml) {
93
- console.log('4444444');
94
- this.createHtml();
95
- }
96
- } else {
97
- console.log('3333333333', this.htmlTemp, this.props.nodeData.content);
94
+ CustomCode.prototype.componentWillUnmount = function () {
95
+ var _this = this;
96
+
97
+ var aElements = document.querySelectorAll('#custom-wrap a');
98
+ aElements.forEach(function (element) {
99
+ element.removeEventListener('click', _this.handleClick);
100
+ });
101
+ }; // componentWillReceiveProps(prevProps) {
102
+ // console.log('111111');
103
+ // if (window.magicDesign.device === 'pc') {
104
+ // console.log('22222222');
105
+ // if (prevProps.nodeData.content.pcHtml != this.props.nodeData.content.pcHtml) {
106
+ // console.log('4444444');
107
+ // this.createHtml();
108
+ // }
109
+ // } else {
110
+ // console.log('3333333333', this.htmlTemp, this.props.nodeData.content);
111
+ // if (this.htmlTemp != this.props.nodeData.content.h5Html) {
112
+ // console.log('5555555');
113
+ // this.createHtml();
114
+ // }
115
+ // }
116
+ // }
98
117
 
99
- if (this.htmlTemp != this.props.nodeData.content.h5Html) {
100
- console.log('5555555');
101
- this.createHtml();
102
- }
103
- }
104
- };
105
118
 
106
119
  CustomCode.prototype.render = function () {
107
- // const { nodeData } = this.props;
108
- // console.log('----nodeData', nodeData);
109
- return (
110
- /*#__PURE__*/
111
- // <div dangerouslySetInnerHTML={{ __html: window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html }} />
112
- _react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
113
- id: "custom-wrap"
114
- }), /*#__PURE__*/_react["default"].createElement("a", {
115
- href: "https://www.baidu.com"
116
- }, "baidu11 "))
117
- );
120
+ var nodeData = this.props.nodeData;
121
+ return /*#__PURE__*/_react["default"].createElement("div", {
122
+ id: "custom-wrap"
123
+ }, /*#__PURE__*/_react["default"].createElement("div", {
124
+ dangerouslySetInnerHTML: {
125
+ __html: window.magicDesign.device === 'pc' ? nodeData.content.pcHtml : nodeData.content.h5Html
126
+ }
127
+ }));
118
128
  };
119
129
 
120
130
  CustomCode.defaultProps = {};
@@ -65,11 +65,12 @@ function History(_a) {
65
65
  var newSource = source.filter(function (src, index) {
66
66
  return !selected.includes(index);
67
67
  });
68
- var newSelectIndex = source.findIndex(function (src) {
69
- return src.key === selected;
68
+ var newSelectIndex = newSource.findIndex(function (src) {
69
+ return src.key === selectKey;
70
70
  });
71
71
  onChange(newSource.length ? newSource : [], newSelectIndex);
72
72
  setIsEdit(false);
73
+ setSelected([]);
73
74
  };
74
75
 
75
76
  var onHisItemClick = function onHisItemClick(index) {
@@ -107,7 +108,7 @@ function History(_a) {
107
108
  }, source.length > 0 && source.map(function (his, index) {
108
109
  return /*#__PURE__*/_react["default"].createElement("div", {
109
110
  className: (0, _classnames["default"])('historyNode', {
110
- active: selectKey === index
111
+ active: selectKey === his.key
111
112
  }),
112
113
  onClick: function onClick() {
113
114
  return onHisItemClick(index);
@@ -246,13 +246,17 @@ function (_super) {
246
246
  _this.onHisConfigClick = function () {};
247
247
 
248
248
  _this.historyChange = function (newHis, newIndex) {
249
+ if (newIndex === void 0) {
250
+ newIndex = null;
251
+ }
252
+
249
253
  (0, _storeUtil.setSessionStore)(_constants.STORAGE_KEY.FONIXTREE_AI_IMG_HIS, newHis);
250
254
 
251
255
  _this.setState({
252
256
  history: newHis
253
257
  });
254
258
 
255
- if (newIndex) {
259
+ if (newIndex !== null) {
256
260
  _this.setState({
257
261
  hisCursor: newIndex
258
262
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "2.0.12",
4
+ "version": "2.0.14",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",