@fonixtree/magic-design 2.0.14 → 2.0.15

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 (171) hide show
  1. package/es/assets/fonts/magic-box-iconfont.css +23 -3
  2. package/es/assets/fonts/magic-box-iconfont.css.bak +23 -3
  3. package/es/assets/fonts/magic-box-iconfont.js +1 -1
  4. package/es/assets/fonts/magic-box-iconfont.js.bak +1 -1
  5. package/es/assets/fonts/magic-box-iconfont.ttf +0 -0
  6. package/es/assets/fonts/magic-box-iconfont.woff +0 -0
  7. package/es/assets/fonts/magic-box-iconfont.woff2 +0 -0
  8. package/es/assets/images/layout-icon/locationLayout.png +0 -0
  9. package/es/common/ColorPicker/index.js +4 -1
  10. package/es/common/ImagePicker/index.js +3 -1
  11. package/es/composite-comp/bol/components/Location/defaultJSON.js +54 -0
  12. package/es/composite-comp/bol/components/Location/index.js +138 -0
  13. package/es/composite-comp/bol/config-panels/LocationConfig/MyEditor/index.js +42 -0
  14. package/es/composite-comp/bol/config-panels/LocationConfig/index.js +122 -0
  15. package/es/composite-comp/dito/components/SearchBar/defaultJSON.js +8 -0
  16. package/es/composite-comp/dito/components/SearchBar/mobile/index.js +66 -7
  17. package/es/composite-comp/dito/components/SearchBar/pc/index.js +2 -2
  18. package/es/composite-comp/dito/config-panels/SearchBarConfig/SearchBarConfigContent/index.js +39 -9
  19. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/AlignSelectPicker/index.js +99 -0
  20. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/AlignSelectPicker/index.less +54 -0
  21. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/images/AlignCenterSVG.js +27 -0
  22. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/images/AlignLeftSVG.js +27 -0
  23. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/images/AlignRightSVG.js +27 -0
  24. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/index.js +96 -0
  25. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/index.less +26 -0
  26. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/ColorPickerBtn/index.js +95 -0
  27. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/ColorPickerBtn/index.less +26 -0
  28. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/LinkInputPicker/index.js +99 -0
  29. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/LinkInputPicker/index.less +39 -0
  30. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/index.js +93 -0
  31. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/index.less +26 -0
  32. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/BoldSVG.js +29 -0
  33. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/FontColorSVG.js +49 -0
  34. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/ItalicSVG.js +29 -0
  35. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/LinkSVG.js +26 -0
  36. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/OrderSVG.js +27 -0
  37. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/StrikeSVG.js +31 -0
  38. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/UnderlineSVG.js +34 -0
  39. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/images/UnorderSVG.js +41 -0
  40. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/index.js +129 -0
  41. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/index.less +25 -0
  42. package/es/core/Designer/TextEditModal/ToolBar/ToolBtn/type.js +1 -0
  43. package/es/core/Designer/TextEditModal/ToolBar/index.js +209 -0
  44. package/es/core/Designer/TextEditModal/ToolBar/index.less +19 -0
  45. package/es/core/Designer/TextEditModal/index.js +100 -0
  46. package/es/core/Designer/TextEditModal/index.less +4 -0
  47. package/es/core/Designer/TextEditModal_old/index.js +142 -0
  48. package/es/core/Designer/TextEditModal_old/index.less +25 -0
  49. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/AlignSelectPicker/index.js +99 -0
  50. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/AlignSelectPicker/index.less +54 -0
  51. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/images/AlignCenterSVG.js +27 -0
  52. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/images/AlignLeftSVG.js +27 -0
  53. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/images/AlignRightSVG.js +27 -0
  54. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/index.js +96 -0
  55. package/es/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/index.less +26 -0
  56. package/es/core/Designer/ToolBarModal/ToolBtn/components/ColorPickerBtn/index.js +95 -0
  57. package/es/core/Designer/ToolBarModal/ToolBtn/components/ColorPickerBtn/index.less +26 -0
  58. package/es/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/LinkInputPicker/index.js +99 -0
  59. package/es/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/LinkInputPicker/index.less +39 -0
  60. package/es/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/index.js +93 -0
  61. package/es/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/index.less +26 -0
  62. package/es/core/Designer/ToolBarModal/ToolBtn/images/BoldSVG.js +29 -0
  63. package/es/core/Designer/ToolBarModal/ToolBtn/images/FontColorSVG.js +49 -0
  64. package/es/core/Designer/ToolBarModal/ToolBtn/images/ItalicSVG.js +29 -0
  65. package/es/core/Designer/ToolBarModal/ToolBtn/images/LinkSVG.js +26 -0
  66. package/es/core/Designer/ToolBarModal/ToolBtn/images/OrderSVG.js +27 -0
  67. package/es/core/Designer/ToolBarModal/ToolBtn/images/StrikeSVG.js +31 -0
  68. package/es/core/Designer/ToolBarModal/ToolBtn/images/UnderlineSVG.js +34 -0
  69. package/es/core/Designer/ToolBarModal/ToolBtn/images/UnorderSVG.js +41 -0
  70. package/es/core/Designer/ToolBarModal/ToolBtn/index.js +129 -0
  71. package/es/core/Designer/ToolBarModal/ToolBtn/index.less +25 -0
  72. package/es/core/Designer/ToolBarModal/ToolBtn/type.js +1 -0
  73. package/es/core/Designer/ToolBarModal/index.js +281 -0
  74. package/es/core/Designer/ToolBarModal/index.less +32 -0
  75. package/es/core/Designer/index.js +28 -6
  76. package/es/locale/en/en.json +2 -0
  77. package/es/locale/es/es.json +2 -0
  78. package/es/locale/id/id.json +2 -0
  79. package/es/meta-comp/components/Text/index.js +101 -386
  80. package/es/meta-comp/components/Text/index.less +57 -0
  81. package/es/meta-comp/config-panels/TextConfig/TextEditModal/index.js +100 -0
  82. package/es/meta-comp/config-panels/TextConfig/TextEditModal/index.less +25 -0
  83. package/es/meta-comp/config-panels/TextConfig/index.less +19 -0
  84. package/es/mobx/Frame.js +7 -1
  85. package/es/utils/commonUtil.js +18 -4
  86. package/lib/assets/fonts/magic-box-iconfont.css +23 -3
  87. package/lib/assets/fonts/magic-box-iconfont.css.bak +23 -3
  88. package/lib/assets/fonts/magic-box-iconfont.js +1 -1
  89. package/lib/assets/fonts/magic-box-iconfont.js.bak +1 -1
  90. package/lib/assets/fonts/magic-box-iconfont.ttf +0 -0
  91. package/lib/assets/fonts/magic-box-iconfont.woff +0 -0
  92. package/lib/assets/fonts/magic-box-iconfont.woff2 +0 -0
  93. package/lib/assets/images/layout-icon/locationLayout.png +0 -0
  94. package/lib/common/ColorPicker/index.js +4 -1
  95. package/lib/common/ImagePicker/index.js +3 -1
  96. package/lib/composite-comp/bol/components/Location/defaultJSON.js +54 -0
  97. package/lib/composite-comp/bol/components/Location/index.js +138 -0
  98. package/lib/composite-comp/bol/config-panels/LocationConfig/MyEditor/index.js +42 -0
  99. package/lib/composite-comp/bol/config-panels/LocationConfig/index.js +122 -0
  100. package/lib/composite-comp/dito/components/SearchBar/defaultJSON.js +8 -0
  101. package/lib/composite-comp/dito/components/SearchBar/mobile/index.js +66 -7
  102. package/lib/composite-comp/dito/components/SearchBar/pc/index.js +2 -2
  103. package/lib/composite-comp/dito/config-panels/SearchBarConfig/SearchBarConfigContent/index.js +39 -9
  104. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/AlignSelectPicker/index.js +99 -0
  105. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/AlignSelectPicker/index.less +54 -0
  106. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/images/AlignCenterSVG.js +27 -0
  107. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/images/AlignLeftSVG.js +27 -0
  108. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/images/AlignRightSVG.js +27 -0
  109. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/index.js +96 -0
  110. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/AlignPicker/index.less +26 -0
  111. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/ColorPickerBtn/index.js +95 -0
  112. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/ColorPickerBtn/index.less +26 -0
  113. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/LinkInputPicker/index.js +99 -0
  114. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/LinkInputPicker/index.less +39 -0
  115. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/index.js +93 -0
  116. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/components/LinkBtn/index.less +26 -0
  117. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/BoldSVG.js +29 -0
  118. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/FontColorSVG.js +49 -0
  119. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/ItalicSVG.js +29 -0
  120. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/LinkSVG.js +26 -0
  121. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/OrderSVG.js +27 -0
  122. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/StrikeSVG.js +31 -0
  123. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/UnderlineSVG.js +34 -0
  124. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/images/UnorderSVG.js +41 -0
  125. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/index.js +129 -0
  126. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/index.less +25 -0
  127. package/lib/core/Designer/TextEditModal/ToolBar/ToolBtn/type.js +1 -0
  128. package/lib/core/Designer/TextEditModal/ToolBar/index.js +209 -0
  129. package/lib/core/Designer/TextEditModal/ToolBar/index.less +19 -0
  130. package/lib/core/Designer/TextEditModal/index.js +100 -0
  131. package/lib/core/Designer/TextEditModal/index.less +4 -0
  132. package/lib/core/Designer/TextEditModal_old/index.js +142 -0
  133. package/lib/core/Designer/TextEditModal_old/index.less +25 -0
  134. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/AlignSelectPicker/index.js +99 -0
  135. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/AlignSelectPicker/index.less +54 -0
  136. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/images/AlignCenterSVG.js +27 -0
  137. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/images/AlignLeftSVG.js +27 -0
  138. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/images/AlignRightSVG.js +27 -0
  139. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/index.js +96 -0
  140. package/lib/core/Designer/ToolBarModal/ToolBtn/components/AlignPicker/index.less +26 -0
  141. package/lib/core/Designer/ToolBarModal/ToolBtn/components/ColorPickerBtn/index.js +95 -0
  142. package/lib/core/Designer/ToolBarModal/ToolBtn/components/ColorPickerBtn/index.less +26 -0
  143. package/lib/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/LinkInputPicker/index.js +99 -0
  144. package/lib/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/LinkInputPicker/index.less +39 -0
  145. package/lib/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/index.js +93 -0
  146. package/lib/core/Designer/ToolBarModal/ToolBtn/components/LinkBtn/index.less +26 -0
  147. package/lib/core/Designer/ToolBarModal/ToolBtn/images/BoldSVG.js +29 -0
  148. package/lib/core/Designer/ToolBarModal/ToolBtn/images/FontColorSVG.js +49 -0
  149. package/lib/core/Designer/ToolBarModal/ToolBtn/images/ItalicSVG.js +29 -0
  150. package/lib/core/Designer/ToolBarModal/ToolBtn/images/LinkSVG.js +26 -0
  151. package/lib/core/Designer/ToolBarModal/ToolBtn/images/OrderSVG.js +27 -0
  152. package/lib/core/Designer/ToolBarModal/ToolBtn/images/StrikeSVG.js +31 -0
  153. package/lib/core/Designer/ToolBarModal/ToolBtn/images/UnderlineSVG.js +34 -0
  154. package/lib/core/Designer/ToolBarModal/ToolBtn/images/UnorderSVG.js +41 -0
  155. package/lib/core/Designer/ToolBarModal/ToolBtn/index.js +129 -0
  156. package/lib/core/Designer/ToolBarModal/ToolBtn/index.less +25 -0
  157. package/lib/core/Designer/ToolBarModal/ToolBtn/type.js +1 -0
  158. package/lib/core/Designer/ToolBarModal/index.js +281 -0
  159. package/lib/core/Designer/ToolBarModal/index.less +32 -0
  160. package/lib/core/Designer/index.js +28 -6
  161. package/lib/locale/en/en.json +2 -0
  162. package/lib/locale/es/es.json +2 -0
  163. package/lib/locale/id/id.json +2 -0
  164. package/lib/meta-comp/components/Text/index.js +101 -386
  165. package/lib/meta-comp/components/Text/index.less +57 -0
  166. package/lib/meta-comp/config-panels/TextConfig/TextEditModal/index.js +100 -0
  167. package/lib/meta-comp/config-panels/TextConfig/TextEditModal/index.less +25 -0
  168. package/lib/meta-comp/config-panels/TextConfig/index.less +19 -0
  169. package/lib/mobx/Frame.js +7 -1
  170. package/lib/utils/commonUtil.js +18 -4
  171. package/package.json +3 -1
@@ -9,19 +9,19 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
 
12
- var _lodash = require("lodash");
13
-
14
- require("./index.less");
15
-
16
- var _Iconfont = require("../../../common/Iconfont");
12
+ var _quill = _interopRequireDefault(require("quill"));
17
13
 
18
14
  var _decorator = require("../../../decorator");
19
15
 
20
16
  var _coreUtil = require("../../../utils/coreUtil");
21
17
 
18
+ var _commonUtil = require("../../../utils/commonUtil");
19
+
22
20
  var _mobx = require("../../../mobx");
23
21
 
24
- var _commonUtil = require("../../../utils/commonUtil");
22
+ var _ToolBarModal = require("../../../core/Designer/ToolBarModal");
23
+
24
+ require("./index.less");
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
27
 
@@ -78,20 +78,22 @@ var __decorate = void 0 && (void 0).__decorate || function (decorators, target,
78
78
  }
79
79
  return c > 3 && r && Object.defineProperty(target, key, r), r;
80
80
  };
81
+ /* eslint-disable react/no-danger */
81
82
 
82
- var __spreadArrays = void 0 && (void 0).__spreadArrays || function () {
83
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
84
- s += arguments[i].length;
85
- }
86
83
 
87
- for (var r = Array(s), k = 0, i = 0; i < il; i++) {
88
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
89
- r[k] = a[j];
90
- }
91
- }
84
+ var sizeStyle = _quill["default"]["import"]('attributors/style/size');
92
85
 
93
- return r;
94
- };
86
+ sizeStyle.whitelist = null;
87
+
88
+ _quill["default"].register(sizeStyle, true);
89
+
90
+ var fonts = _quill["default"]["import"]('formats/font');
91
+
92
+ fonts.whitelist = _ToolBarModal.fontFamilyList.map(function (item) {
93
+ return item.value;
94
+ });
95
+
96
+ _quill["default"].register(fonts, true);
95
97
 
96
98
  var contentStyle = function contentStyle(content) {
97
99
  return {
@@ -105,187 +107,9 @@ var contentStyle = function contentStyle(content) {
105
107
  width: '100%'
106
108
  };
107
109
  };
108
- /** 从父级数组中 分离出 片段数组 */
109
-
110
110
 
111
111
  exports.contentStyle = contentStyle;
112
112
 
113
- var calcSplitRange = function calcSplitRange(parentRange, splitRange) {
114
- if (parentRange[0] == splitRange[0]) {
115
- if (parentRange[1] == splitRange[1]) {
116
- return parentRange;
117
- } else {
118
- return [[parentRange[0], splitRange[1]], [splitRange[1], parentRange[1]]];
119
- }
120
- }
121
-
122
- if (parentRange[1] == splitRange[1]) {
123
- return [[parentRange[0], splitRange[0]], [splitRange[0], parentRange[1]]];
124
- }
125
-
126
- return [[parentRange[0], splitRange[0]], [splitRange[0], splitRange[1]], [splitRange[1], parentRange[1]]];
127
- };
128
- /** 驱动配置面板渲染 */
129
-
130
-
131
- var triggerTextConfigRender = function triggerTextConfigRender() {
132
- window.document.dispatchEvent(new Event('text-render', {
133
- bubbles: false
134
- }));
135
- };
136
- /** 初始化监听事件 */
137
-
138
-
139
- var initSelectionEvent = function initSelectionEvent() {
140
- if (!window.document.onselectionchange) {
141
- window.document.onselectionchange = (0, _lodash.debounce)(function (e) {
142
- var _a;
143
-
144
- var _b, _c, _d, _e;
145
- /** 找到选中的text区域 并且注册过事件 */
146
-
147
-
148
- var findSelectionTarget = window._selectionTarget.find(function (_a) {
149
- var target = _a.target;
150
- return target == e.target.activeElement;
151
- });
152
- /** 所有选中状态清楚 */
153
-
154
-
155
- var clearSelection = function clearSelection() {
156
- _mobx.store.setState({
157
- textSelection: null
158
- });
159
-
160
- triggerTextConfigRender();
161
- };
162
-
163
- if (findSelectionTarget) {
164
- var range = window.getSelection().getRangeAt(0);
165
- /** 记录当前选中的范围 给label使用 */
166
-
167
- window._currentRange = window.getSelection().getRangeAt(0);
168
- var startOffset = range.startOffset,
169
- endOffset = range.endOffset,
170
- startContainer_1 = range.startContainer,
171
- endContainer = range.endContainer;
172
- /** 起始点=终点 取消 */
173
-
174
- if (startOffset == endOffset) {
175
- clearSelection();
176
- return;
177
- }
178
- /** 如果全部选中 取消 */
179
-
180
-
181
- if (startOffset == 0 && endOffset == findSelectionTarget.data.text.length) {
182
- clearSelection();
183
- return;
184
- }
185
- /** 判断起始点和结束点是否相同 */
186
-
187
-
188
- if (startContainer_1 == endContainer) {
189
- /** 如果还没有选中区域 */
190
- if (findSelectionTarget.data.specialContent.length == 0) {
191
- var nowRange_1 = [startOffset, endOffset].sort(function (a, b) {
192
- return a - b;
193
- });
194
- var rangeList = calcSplitRange([0, findSelectionTarget.data.text.length], nowRange_1);
195
- findSelectionTarget.data.specialContent = rangeList.map(function (range) {
196
- return {
197
- range: range,
198
- content: {}
199
- };
200
- });
201
- var findSelectionRange = (_b = findSelectionTarget.data.specialContent) === null || _b === void 0 ? void 0 : _b.find(function (c) {
202
- return JSON.stringify(c.range) == JSON.stringify(nowRange_1);
203
- });
204
-
205
- _mobx.store.setState({
206
- textSelection: findSelectionRange.content
207
- });
208
- } else {
209
- /** 如果已有选中区域 */
210
- var nowRange_2 = [startOffset, endOffset].sort(function (a, b) {
211
- return a - b;
212
- });
213
- var selectionRangeJSON_1 = Object.keys(findSelectionTarget.selectionRefMap).find(function (rangeTarget) {
214
- return findSelectionTarget.selectionRefMap[rangeTarget] == startContainer_1.parentNode;
215
- });
216
- var findSelectionRangeTarget_1 = (_c = findSelectionTarget.data.specialContent) === null || _c === void 0 ? void 0 : _c.find(function (c) {
217
- return JSON.stringify(c.range) == selectionRangeJSON_1;
218
- });
219
- /** 选中没配置过的区域 可以进行拆分 */
220
-
221
- if ((0, _lodash.isEmpty)(findSelectionRangeTarget_1.content)) {
222
- /** 计算偏移值 */
223
- nowRange_2[0] += findSelectionRangeTarget_1.range[0];
224
- nowRange_2[1] += findSelectionRangeTarget_1.range[0];
225
- /** 补充新的选中区域 */
226
-
227
- if (JSON.stringify(findSelectionRangeTarget_1.range) != JSON.stringify(nowRange_2)) {
228
- var rangeList = calcSplitRange(findSelectionRangeTarget_1.range, nowRange_2);
229
- var nowContentIndex = (_d = findSelectionTarget.data.specialContent) === null || _d === void 0 ? void 0 : _d.findIndex(function (c) {
230
- return c == findSelectionRangeTarget_1;
231
- });
232
-
233
- (_a = findSelectionTarget.data.specialContent).splice.apply(_a, __spreadArrays([nowContentIndex, 1], rangeList.map(function (range) {
234
- return {
235
- range: range,
236
- content: {}
237
- };
238
- })));
239
- }
240
-
241
- var findSelectionRange = (_e = findSelectionTarget.data.specialContent) === null || _e === void 0 ? void 0 : _e.find(function (c) {
242
- return JSON.stringify(c.range) == JSON.stringify(nowRange_2);
243
- });
244
-
245
- _mobx.store.setState({
246
- textSelection: findSelectionRange.content
247
- });
248
- } else {
249
- /** 选中已经配置过的区域 不能拆分 */
250
- _mobx.store.setState({
251
- textSelection: findSelectionRangeTarget_1.content
252
- });
253
- }
254
- }
255
- } else {
256
- _mobx.store.setState({
257
- textSelection: null
258
- });
259
- }
260
-
261
- findSelectionTarget.refresh();
262
- } // todo 不知道干什么用的
263
-
264
-
265
- triggerTextConfigRender();
266
- }, 500);
267
- }
268
- };
269
- /** 添加选择区域监听目标 */
270
-
271
-
272
- var appendSelectionTarget = function appendSelectionTarget(data) {
273
- if (!window._selectionTarget) {
274
- window._selectionTarget = [__assign({}, data)];
275
- } else {
276
- window._selectionTarget.push(__assign({}, data));
277
- }
278
- };
279
- /** 删除监听目标 */
280
-
281
-
282
- var deleteSelectionTarget = function deleteSelectionTarget(deleteTarget) {
283
- window._selectionTarget = window._selectionTarget.filter(function (_a) {
284
- var target = _a.target;
285
- return target != deleteTarget;
286
- });
287
- };
288
-
289
113
  var Text =
290
114
  /** @class */
291
115
  function (_super) {
@@ -294,145 +118,56 @@ function (_super) {
294
118
  function Text() {
295
119
  var _this = _super !== null && _super.apply(this, arguments) || this;
296
120
 
297
- _this.state = {};
298
- /** 分割区域dom映射 */
299
-
300
- _this.selectionRefMap = {};
301
121
  _this.textRef = /*#__PURE__*/_react["default"].createRef();
302
- /** 备份历史数据 比对不一致时渲染 */
303
-
304
- _this.preData = '';
305
- _this.preTextSelection = null;
306
- /** 创建关闭图标按钮 */
307
-
308
- _this.createHoverClose = function (node, onCloseClick) {
309
- if (onCloseClick === void 0) {
310
- onCloseClick = function onCloseClick() {};
311
- }
312
-
313
- node.className = 'select-container';
314
- var closeNode = document.createElement('span');
315
- closeNode.className = 'close-wrap';
316
- closeNode.contentEditable = 'false';
317
- var iconNode = document.createElement('span');
318
- iconNode.contentEditable = 'false';
319
- iconNode.className = (0, _Iconfont.convertIconClass)('icon-close-circle');
320
- iconNode.onclick = onCloseClick;
321
- closeNode.appendChild(iconNode);
322
- node.appendChild(closeNode);
122
+ _this.quillRef = null;
123
+ _this.state = {
124
+ editabled: false
323
125
  };
324
126
 
325
- _this.renderText = function (data, mode) {
326
- var outputType = _this.props.outputType || window.magicDesign.outputType;
327
-
328
- var _mode = mode || window.magicDesign.mode;
329
-
330
- if (!_this.textRef.current) return;
331
-
332
- _this.textRef.current.blur();
333
- /** 保留历史数据 */
334
-
335
-
336
- _this.preData = JSON.stringify(data);
337
- _this.preTextSelection = _mobx.store.textSelection;
338
- _this.preDevice = window.magicDesign.device;
339
- /** 渲染html */
340
-
341
- if (data.specialContent.length == 0) {
342
- if (outputType == 'html' && _mode == 'renderer') {
343
- if (data === null || data === void 0 ? void 0 : data.content.clickUrl) {
344
- var a = document.createElement('a');
345
- a.href = _typeof(data.content.clickUrl) === 'object' ? data.content.clickUrl.value : data.content.clickUrl;
346
- a.target = '_blank';
347
- a.innerHTML = data.text;
348
- _this.textRef.current.innerHTML = '';
127
+ _this.renderEditor = function () {
128
+ _this.setState({
129
+ editabled: true
130
+ }, function () {
131
+ _this.quillRef = new _quill["default"](_this.textRef.current, {
132
+ placeholder: '请输入内容...'
133
+ });
349
134
 
350
- _this.textRef.current.appendChild(a);
351
- } else {
352
- _this.textRef.current.innerHTML = data.text;
135
+ _mobx.frameStore.setState({
136
+ textModalState: {
137
+ quillRef: null
353
138
  }
354
- } else {
355
- _this.textRef.current.innerHTML = data.text;
356
- }
357
- } else {
358
- _this.textRef.current.innerHTML = '';
359
- data.specialContent.forEach(function (c, index) {
360
- var _a, _b, _c;
361
-
362
- var node = document.createElement('span');
363
- node.style = (0, _commonUtil.styleStringify)(contentStyle(c.content));
364
-
365
- if (c === null || c === void 0 ? void 0 : c.content.clickUrl) {
366
- if (outputType == 'html' && _mode == 'renderer') {
367
- var a = document.createElement('a');
368
- a.href = _typeof(c.content.clickUrl) === 'object' ? c.content.clickUrl.value : c.content.clickUrl;
369
- a.target = '_blank';
370
-
371
- if (_mode == 'designer') {
372
- a.onclick = function (e) {
373
- e.preventDefault();
374
- };
375
- }
376
-
377
- a.innerText = (_a = data.text).slice.apply(_a, c.range);
378
- node.appendChild(a);
379
- } else {
380
- node.innerText = (_b = data.text).slice.apply(_b, c.range);
381
-
382
- node.onclick = function (e) {
383
- if (c.content.clickUrl) {
384
- e.stopPropagation();
385
- }
386
-
387
- (0, _coreUtil.clickUrl)(c.content.clickUrl);
388
- };
389
- }
390
- } else {
391
- node.innerText = (_c = data.text).slice.apply(_c, c.range);
392
- }
393
-
394
- _this.selectionRefMap[JSON.stringify(c.range)] = node;
395
-
396
- _this.textRef.current.appendChild(node);
397
- /** 找到当前选中的区域 */
398
-
399
-
400
- if (_mobx.store.textSelection == (c === null || c === void 0 ? void 0 : c.content)) {
401
- /** 添加删除按钮 */
402
- _this.createHoverClose(node, function () {
403
- /** 第一步去除选中区域 */
404
- _mobx.store.setState({
405
- textSelection: null
406
- });
407
- /** 清空区间配置 */
408
-
139
+ });
409
140
 
410
- data.specialContent[index].content = {};
411
- /** 合并区间无配置区间 */
141
+ setTimeout(function () {
142
+ _mobx.frameStore.setState({
143
+ textModalState: {
144
+ quillRef: _this.quillRef
145
+ }
146
+ });
147
+ }, 100);
148
+ });
149
+ };
412
150
 
413
- for (var i = 0; i < data.specialContent.length - 1;) {
414
- /** 如果本级和下级都是空值 那么合并 */
415
- if ((0, _lodash.isEmpty)(data.specialContent[i].content) && (0, _lodash.isEmpty)(data.specialContent[i + 1].content)) {
416
- data.specialContent[i].range = [data.specialContent[i].range[0], data.specialContent[i + 1].range[1]];
417
- data.specialContent.splice(i + 1, 1);
418
- } else {
419
- i += 1;
420
- }
421
- }
151
+ _this.onContentClick = function () {
152
+ var data = _this.props.data;
422
153
 
423
- triggerTextConfigRender();
424
- });
425
- }
426
- });
154
+ if (window.magicDesign.mode == 'designer') {
155
+ _this.renderEditor();
156
+ } else {
157
+ (0, _coreUtil.clickUrl)(data.content.clickUrl);
427
158
  }
428
- /** 清除无用的node */
159
+ };
429
160
 
161
+ _this.onEditorClose = function () {
162
+ _this.props.data.html = _this.quillRef.root.innerHTML;
430
163
 
431
- Object.keys(_this.selectionRefMap).forEach(function (key) {
432
- if (!data.specialContent.find(function (c) {
433
- return JSON.stringify(c.range) == key;
434
- })) {
435
- Reflect.deleteProperty(_this.selectionRefMap, key);
164
+ _this.setState({
165
+ editabled: false
166
+ });
167
+
168
+ _mobx.frameStore.setState({
169
+ textModalState: {
170
+ quillRef: null
436
171
  }
437
172
  });
438
173
  };
@@ -441,49 +176,24 @@ function (_super) {
441
176
  }
442
177
 
443
178
  Text.prototype.componentDidMount = function () {
444
- var _this = this;
445
-
446
- this.renderText(this.props.data, this.props.mode);
447
- initSelectionEvent();
448
- appendSelectionTarget({
449
- target: this.textRef.current,
450
- data: this.props.data,
451
- selectionRefMap: this.selectionRefMap,
452
- refresh: function refresh() {
453
- _this.renderText(_this.props.data, _this.props.mode);
454
- }
455
- });
456
- };
457
-
458
- Text.prototype.shouldComponentUpdate = function (nextProps) {
459
- var should1 = JSON.stringify(nextProps.data) != this.preData;
460
- var should2 = _mobx.store.textSelection != this.preTextSelection;
461
- var should3 = window.magicDesign.device != this.preDevice;
462
- var result = should1 || should2 || should3;
463
-
464
- if (result) {
465
- this.renderText(nextProps.data, nextProps.mode);
466
- }
179
+ var _a;
467
180
 
468
- return result;
469
- };
181
+ (_a = this.textRef.current.querySelector('.quill-text-content-wrap a')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', function (event) {
182
+ event.preventDefault();
183
+ var target = event.target;
184
+ var href = target.getAttribute('href'); // 在这里执行你想要的操作
470
185
 
471
- Text.prototype.componentWillUnmount = function () {
472
- deleteSelectionTarget(this.textRef.current);
186
+ console.log('链接点击事件:', href);
187
+ var data = JSON.parse(href);
188
+ (0, _coreUtil.clickUrl)(data);
189
+ });
473
190
  };
474
191
 
475
192
  Text.prototype.render = function () {
476
- var _this = this;
477
-
478
193
  var _a = this.props,
479
194
  data = _a.data,
480
- className = _a.className,
481
- readonly = _a.readonly,
482
- onTextInput = _a.onTextInput,
483
- mode = _a.mode;
484
-
485
- var _mode = mode || window.magicDesign.mode;
486
-
195
+ className = _a.className;
196
+ var editabled = this.state.editabled;
487
197
  var style = contentStyle(data.content);
488
198
 
489
199
  if (data.underline) {
@@ -501,41 +211,46 @@ function (_super) {
501
211
  } else {
502
212
  style = __assign(__assign({}, style), data.spacing.mobile);
503
213
  }
504
- } // const style: React.CSSProperties = {
505
- // ...contentStyle(data.content),
506
- // textDecorationLine: data?.underline.open ? 'underline' : 'none',
507
- // textDecorationColor: data?.underline.textDecorationColor,
508
- // textDecorationStyle: data?.underline.textDecorationStyle,
509
- // };
214
+ }
510
215
 
216
+ if (editabled) {
217
+ return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
218
+ className: "editor-shadow",
219
+ onClick: this.onEditorClose
220
+ }), /*#__PURE__*/_react["default"].createElement("div", {
221
+ className: "quill-text-content-wrap",
222
+ style: {
223
+ zIndex: 3
224
+ }
225
+ }, /*#__PURE__*/_react["default"].createElement("div", {
226
+ ref: this.textRef,
227
+ className: (0, _classnames["default"])('m-meta-text', className),
228
+ dangerouslySetInnerHTML: {
229
+ __html: data.html || data.text
230
+ },
231
+ onClick: function onClick() {
232
+ (0, _coreUtil.clickUrl)(data.content.clickUrl);
233
+ },
234
+ onKeyDown: function onKeyDown(e) {
235
+ e.stopPropagation();
236
+ },
237
+ style: (0, _commonUtil.pxToRem)(__assign({}, style))
238
+ })));
239
+ }
511
240
 
512
241
  return /*#__PURE__*/_react["default"].createElement("div", {
513
242
  ref: this.textRef,
514
- className: (0, _classnames["default"])('m-meta-text', className),
515
- contentEditable: _mode == 'designer' && !readonly,
516
- onClick: function onClick() {
517
- (0, _coreUtil.clickUrl)(data.content.clickUrl);
518
- },
519
- onInput: function onInput(e) {
520
- var text = e.target.textContent;
521
- data.text = text;
522
- /** 毁灭吧 累了 */
523
-
524
- data.specialContent = [];
525
- /** 主动更新历史数据避免render */
526
-
527
- _this.preData = JSON.stringify(__assign(__assign({}, JSON.parse(_this.preData)), {
528
- text: text
529
- }));
530
- /** 通知变更 */
531
-
532
- onTextInput(text);
243
+ className: (0, _classnames["default"])('m-meta-text', 'quill-text-content-wrap', className),
244
+ dangerouslySetInnerHTML: {
245
+ __html: data.html || data.text
533
246
  },
247
+ onClick: this.onContentClick,
534
248
  onKeyDown: function onKeyDown(e) {
535
249
  e.stopPropagation();
536
250
  },
537
- style: (0, _commonUtil.pxToRem)(__assign({}, style)),
538
- suppressContentEditableWarning: true
251
+ style: (0, _commonUtil.pxToRem)(__assign(__assign({}, style), {
252
+ zIndex: 1
253
+ }))
539
254
  });
540
255
  };
541
256
 
@@ -1,6 +1,63 @@
1
+ .editor-shadow {
2
+ position: fixed;
3
+ top: 0;
4
+ right: 0;
5
+ bottom: 0;
6
+ left: 0;
7
+ background-color: rgba(0, 0, 0, 0);
8
+ z-index: 2;
9
+ }
10
+
11
+ .quill-text-content-wrap {
12
+ position: relative;
13
+ z-index: 3;
14
+
15
+ .ql-font-Montserrat {
16
+ font-family: 'Montserrat';
17
+ font-style: normal;
18
+ font-weight: 400;
19
+ }
20
+
21
+ .ql-font-MontserratBold {
22
+ font-family: 'Montserrat';
23
+ font-style: normal;
24
+ font-weight: 600;
25
+ }
26
+
27
+ .ql-font-OpenSans {
28
+ font-family: 'Open Sans';
29
+ font-style: normal;
30
+ font-weight: 400;
31
+ }
32
+
33
+ .ql-font-OpenSansBold {
34
+ font-family: 'Open Sans';
35
+ font-style: normal;
36
+ font-weight: 600;
37
+ }
38
+ }
39
+
40
+ .ql-clipboard {
41
+ left: -100000px;
42
+ height: 1px;
43
+ overflow-y: hidden;
44
+ position: absolute;
45
+ top: 50%;
46
+ }
47
+
1
48
  .m-meta-text {
2
49
  display: block;
3
50
 
51
+
52
+ ol,
53
+ ul,
54
+ dl,
55
+ p {
56
+ margin-bottom: 0;
57
+ }
58
+
59
+
60
+
4
61
  .select-container {
5
62
  position: relative;
6
63