@labelbee/lb-annotation 1.14.0-alpha.2 → 1.14.0-alpha.3

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 (187) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +8 -1
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +35 -2
  3. package/dist/_virtual/filterBoxWorker.js +8 -1
  4. package/dist/_virtual/highlightWorker.js +8 -1
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +5 -1
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +5 -1
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +5 -1
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +5 -1
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +5 -1
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +5 -1
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +5 -1
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +5 -1
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +5 -1
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +5 -1
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +5 -7
  17. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
  18. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
  19. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +5 -12
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +5 -1
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +5 -1
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +5 -1
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +5 -1
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +5 -1
  25. package/dist/constant/annotation.js +127 -1
  26. package/dist/constant/annotationTask.js +30 -1
  27. package/dist/constant/defaultConfig.js +266 -1
  28. package/dist/constant/keyCode.js +38 -1
  29. package/dist/constant/style.js +98 -1
  30. package/dist/constant/tool.js +236 -1
  31. package/dist/core/index.js +150 -1
  32. package/dist/core/pointCloud/OrbitControls.js +665 -1
  33. package/dist/core/pointCloud/PCDLoader.js +260 -2
  34. package/dist/core/pointCloud/annotation.js +215 -1
  35. package/dist/core/pointCloud/cache.js +53 -1
  36. package/dist/core/pointCloud/index.js +991 -5
  37. package/dist/core/pointCloud/matrix.js +138 -1
  38. package/dist/core/pointCloud/segmentation.js +144 -0
  39. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +26 -0
  40. package/dist/core/pointCloud/selector/Sse3dSelector.js +16 -0
  41. package/dist/core/scheduler.js +233 -1
  42. package/dist/core/toolOperation/LineToolOperation.js +1434 -1
  43. package/dist/core/toolOperation/ScribbleTool.js +292 -1
  44. package/dist/core/toolOperation/TextToolOperation.js +131 -1
  45. package/dist/core/toolOperation/ViewOperation.js +556 -1
  46. package/dist/core/toolOperation/basicToolOperation.js +881 -1
  47. package/dist/core/toolOperation/checkOperation.js +208 -1
  48. package/dist/core/toolOperation/cuboidOperation.js +754 -1
  49. package/dist/core/toolOperation/cuboidToggleButtonClass.js +152 -7
  50. package/dist/core/toolOperation/eventListener.js +37 -1
  51. package/dist/core/toolOperation/measureOperation.js +41 -1
  52. package/dist/core/toolOperation/pointCloud2dOperation.js +365 -1
  53. package/dist/core/toolOperation/pointOperation.js +696 -1
  54. package/dist/core/toolOperation/polygonOperation.js +1251 -1
  55. package/dist/core/toolOperation/rectOperation.js +1233 -1
  56. package/dist/core/toolOperation/segmentByRect.js +174 -1
  57. package/dist/core/toolOperation/tagOperation.js +201 -3
  58. package/dist/core/toolOperation/textAttributeClass.js +182 -16
  59. package/dist/index.js +185 -1
  60. package/dist/locales/constants.js +24 -1
  61. package/dist/locales/en_US/message.js +25 -1
  62. package/dist/locales/index.js +19 -1
  63. package/dist/locales/zh_CN/message.js +25 -1
  64. package/dist/newCore/CanvasScheduler.js +35 -1
  65. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  66. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  67. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  68. package/dist/utils/ActionsHistory.js +84 -1
  69. package/dist/utils/ImgUtils.js +23 -1
  70. package/dist/utils/MathUtils.js +385 -2
  71. package/dist/utils/VectorUtils.js +25 -1
  72. package/dist/utils/tool/AttributeUtils.js +218 -1
  73. package/dist/utils/tool/AxisUtils.js +340 -1
  74. package/dist/utils/tool/CanvasUtils.js +62 -1
  75. package/dist/utils/tool/CommonToolUtils.js +174 -1
  76. package/dist/utils/tool/CuboidUtils.js +704 -1
  77. package/dist/utils/tool/DblClickEventListener.js +102 -1
  78. package/dist/utils/tool/DrawUtils.js +492 -3
  79. package/dist/utils/tool/EnhanceCommonToolUtils.js +53 -1
  80. package/dist/utils/tool/ImgPosUtils.js +58 -1
  81. package/dist/utils/tool/LineToolUtils.js +261 -1
  82. package/dist/utils/tool/MarkerUtils.js +56 -1
  83. package/dist/utils/tool/PolygonUtils.js +460 -1
  84. package/dist/utils/tool/RectUtils.js +155 -1
  85. package/dist/utils/tool/RenderDomClass.js +57 -7
  86. package/dist/utils/tool/RenderDomUtils.js +21 -4
  87. package/dist/utils/tool/StyleUtils.js +31 -1
  88. package/dist/utils/tool/TagUtils.js +129 -1
  89. package/dist/utils/tool/UnitUtils.js +12 -1
  90. package/dist/utils/tool/ZoomUtils.js +72 -1
  91. package/dist/utils/tool/polygonTool.js +133 -1
  92. package/dist/utils/uuid.js +26 -1
  93. package/es/_virtual/MathUtilsWorker.js +6 -1
  94. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  95. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  96. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -2
  97. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  98. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  99. package/es/_virtual/filterBoxWorker.js +6 -1
  100. package/es/_virtual/highlightWorker.js +6 -1
  101. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -1
  102. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -1
  103. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -1
  104. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -1
  105. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -1
  106. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -1
  107. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -1
  108. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -1
  109. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -1
  110. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -1
  111. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -5
  112. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -7
  113. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -5
  114. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -5
  115. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -12
  116. package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -1
  117. package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -1
  118. package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -1
  119. package/es/assets/attributeIcon/icon_editLV.svg.js +3 -1
  120. package/es/assets/attributeIcon/icon_editQING.svg.js +3 -1
  121. package/es/constant/annotation.js +113 -1
  122. package/es/constant/annotationTask.js +25 -1
  123. package/es/constant/defaultConfig.js +260 -1
  124. package/es/constant/keyCode.js +36 -1
  125. package/es/constant/style.js +74 -1
  126. package/es/constant/tool.js +220 -1
  127. package/es/core/index.js +148 -1
  128. package/es/core/pointCloud/OrbitControls.js +661 -1
  129. package/es/core/pointCloud/PCDLoader.js +256 -2
  130. package/es/core/pointCloud/annotation.js +211 -1
  131. package/es/core/pointCloud/cache.js +49 -1
  132. package/es/core/pointCloud/index.js +962 -5
  133. package/es/core/pointCloud/matrix.js +109 -1
  134. package/es/core/pointCloud/segmentation.js +120 -0
  135. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +24 -0
  136. package/es/core/pointCloud/selector/Sse3dSelector.js +14 -0
  137. package/es/core/scheduler.js +228 -1
  138. package/es/core/toolOperation/LineToolOperation.js +1421 -1
  139. package/es/core/toolOperation/ScribbleTool.js +290 -1
  140. package/es/core/toolOperation/TextToolOperation.js +129 -1
  141. package/es/core/toolOperation/ViewOperation.js +549 -1
  142. package/es/core/toolOperation/basicToolOperation.js +877 -1
  143. package/es/core/toolOperation/checkOperation.js +206 -1
  144. package/es/core/toolOperation/cuboidOperation.js +752 -1
  145. package/es/core/toolOperation/cuboidToggleButtonClass.js +150 -7
  146. package/es/core/toolOperation/eventListener.js +35 -1
  147. package/es/core/toolOperation/measureOperation.js +39 -1
  148. package/es/core/toolOperation/pointCloud2dOperation.js +359 -1
  149. package/es/core/toolOperation/pointOperation.js +690 -1
  150. package/es/core/toolOperation/polygonOperation.js +1245 -1
  151. package/es/core/toolOperation/rectOperation.js +1228 -1
  152. package/es/core/toolOperation/scribbleTool2.js +249 -0
  153. package/es/core/toolOperation/segmentByRect.js +172 -1
  154. package/es/core/toolOperation/tagOperation.js +199 -3
  155. package/es/core/toolOperation/textAttributeClass.js +180 -16
  156. package/es/index.js +46 -1
  157. package/es/locales/constants.js +22 -1
  158. package/es/locales/en_US/message.js +23 -1
  159. package/es/locales/index.js +17 -1
  160. package/es/locales/zh_CN/message.js +23 -1
  161. package/es/newCore/CanvasScheduler.js +31 -1
  162. package/es/utils/ActionsHistory.js +78 -1
  163. package/es/utils/ImgUtils.js +21 -1
  164. package/es/utils/MathUtils.js +380 -2
  165. package/es/utils/VectorUtils.js +23 -1
  166. package/es/utils/tool/AttributeUtils.js +212 -1
  167. package/es/utils/tool/AxisUtils.js +335 -1
  168. package/es/utils/tool/CanvasUtils.js +60 -1
  169. package/es/utils/tool/CommonToolUtils.js +172 -1
  170. package/es/utils/tool/CuboidUtils.js +680 -1
  171. package/es/utils/tool/DblClickEventListener.js +100 -1
  172. package/es/utils/tool/DrawUtils.js +490 -3
  173. package/es/utils/tool/EnhanceCommonToolUtils.js +48 -1
  174. package/es/utils/tool/ImgPosUtils.js +56 -1
  175. package/es/utils/tool/LineToolUtils.js +255 -1
  176. package/es/utils/tool/MarkerUtils.js +54 -1
  177. package/es/utils/tool/PolygonUtils.js +458 -1
  178. package/es/utils/tool/RectUtils.js +153 -1
  179. package/es/utils/tool/RenderDomClass.js +55 -7
  180. package/es/utils/tool/RenderDomUtils.js +19 -4
  181. package/es/utils/tool/StyleUtils.js +29 -1
  182. package/es/utils/tool/TagUtils.js +127 -1
  183. package/es/utils/tool/UnitUtils.js +10 -1
  184. package/es/utils/tool/ZoomUtils.js +70 -1
  185. package/es/utils/tool/polygonTool.js +126 -1
  186. package/es/utils/uuid.js +24 -1
  187. package/package.json +7 -5
@@ -1,37 +1,201 @@
1
- import d from"../../constant/keyCode.js";import{TEXT_ATTRIBUTE_LINE_HEIGHT as c,TEXT_ATTRIBUTE_MAX_LENGTH as u}from"../../constant/tool.js";const h=30,x=164;class M{constructor(t){this.textKeyDown=a=>{switch(a.stopPropagation(),a.keyCode){case d.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:i,icon:e,color:r,getCurrentSelectedData:o,updateSelectedTextAttribute:n}=t,s=t.width||x;this.container=i,this.getCurrentSelectedData=o,this.updateSelectedTextAttribute=n,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(e),this._textDOM=this.initTextDOM(s,c),this._textareaDOM=this.initTextareaDOM(s,r),this.appendToContainer()}get isExit(){return this._textAttributeDOM?this.container.contains(this._textAttributeDOM):!1}get isExitTextareaDOM(){return this._textareaDOM?this.container.contains(this._textareaDOM):!1}updateIcon(t){this._iconDOM&&(this._iconDOM.innerHTML=t)}appendToContainer(){!this._textAttributeDOM||!this._textDOM||!this._iconDOM||(this.container.appendChild(this._textAttributeDOM),this._textAttributeDOM.appendChild(this._textDOM),this._textAttributeDOM.appendChild(this._iconDOM))}initTextAttributeDOM(){const t=document.createElement("div");return t.setAttribute("id","textArea"),t}initTextDOM(t,i){const e=document.createElement("span");return e.setAttribute("style",`
2
- width: ${Math.max(t,h)}px;
3
- line-height: ${i}px;
1
+ import EKeyCode from '../../constant/keyCode.js';
2
+ import { TEXT_ATTRIBUTE_LINE_HEIGHT, TEXT_ATTRIBUTE_MAX_LENGTH } from '../../constant/tool.js';
3
+
4
+ const defaultWidth = 30;
5
+ const DEFAULT_TEXT_WIDTH = 164;
6
+ class TextAttributeClass {
7
+ constructor(props) {
8
+ this.textKeyDown = (e) => {
9
+ e.stopPropagation();
10
+ switch (e.keyCode) {
11
+ case EKeyCode.Enter:
12
+ this.submitTextarea();
13
+ this.appendToContainer();
14
+ break;
15
+ }
16
+ };
17
+ const {container, icon, color, getCurrentSelectedData, updateSelectedTextAttribute} = props;
18
+ const width = props.width || DEFAULT_TEXT_WIDTH;
19
+ this.container = container;
20
+ this.getCurrentSelectedData = getCurrentSelectedData;
21
+ this.updateSelectedTextAttribute = updateSelectedTextAttribute;
22
+ this._textAttributeDOM = this.initTextAttributeDOM();
23
+ this._iconDOM = this.initIconDOM(icon);
24
+ this._textDOM = this.initTextDOM(width, TEXT_ATTRIBUTE_LINE_HEIGHT);
25
+ this._textareaDOM = this.initTextareaDOM(width, color);
26
+ this.appendToContainer();
27
+ }
28
+ get isExit() {
29
+ if (!this._textAttributeDOM) {
30
+ return false;
31
+ }
32
+ return this.container.contains(this._textAttributeDOM);
33
+ }
34
+ get isExitTextareaDOM() {
35
+ if (!this._textareaDOM) {
36
+ return false;
37
+ }
38
+ return this.container.contains(this._textareaDOM);
39
+ }
40
+ updateIcon(icon) {
41
+ if (this._iconDOM) {
42
+ this._iconDOM.innerHTML = icon;
43
+ }
44
+ }
45
+ appendToContainer() {
46
+ if (!this._textAttributeDOM || !this._textDOM || !this._iconDOM) {
47
+ return;
48
+ }
49
+ this.container.appendChild(this._textAttributeDOM);
50
+ this._textAttributeDOM.appendChild(this._textDOM);
51
+ this._textAttributeDOM.appendChild(this._iconDOM);
52
+ }
53
+ initTextAttributeDOM() {
54
+ const _textAttributeDOM = document.createElement("div");
55
+ _textAttributeDOM.setAttribute("id", "textArea");
56
+ return _textAttributeDOM;
57
+ }
58
+ initTextDOM(width, lineHeight) {
59
+ const _textDOM = document.createElement("span");
60
+ _textDOM.setAttribute("style", `
61
+ width: ${Math.max(width, defaultWidth)}px;
62
+ line-height: ${lineHeight}px;
4
63
  word-break: break-all;
5
64
  white-space: pre-line;
6
65
  font-style: italic;
7
- `),e}initIconDOM(t){const i=document.createElement("div");return i.setAttribute("id","annotation_text"),i.innerHTML=t,i.addEventListener("mouseup",e=>{e.stopPropagation(),this.renderTextarea()}),i.addEventListener("mousedown",e=>{e.stopPropagation()}),i.addEventListener("contextmenu",e=>{e.stopPropagation()}),i.setAttribute("style",`
66
+ `);
67
+ return _textDOM;
68
+ }
69
+ initIconDOM(icon) {
70
+ const _iconDOM = document.createElement("div");
71
+ _iconDOM.setAttribute("id", "annotation_text");
72
+ _iconDOM.innerHTML = icon;
73
+ _iconDOM.addEventListener("mouseup", (e) => {
74
+ e.stopPropagation();
75
+ this.renderTextarea();
76
+ });
77
+ _iconDOM.addEventListener("mousedown", (e) => {
78
+ e.stopPropagation();
79
+ });
80
+ _iconDOM.addEventListener("contextmenu", (e) => {
81
+ e.stopPropagation();
82
+ });
83
+ _iconDOM.setAttribute("style", `
8
84
  position: absolute;
9
85
  left: -20px;
10
86
  top: 4px;
11
87
  cursor: pointer;
12
88
  z-index: 10
13
- `),i}initTextareaDOM(t,i){const e=document.createElement("textarea");return e.addEventListener("click",r=>{r.stopPropagation()}),e.addEventListener("mouseup",r=>{r.stopPropagation()}),e.setAttribute("style",`
89
+ `);
90
+ return _iconDOM;
91
+ }
92
+ initTextareaDOM(width, color) {
93
+ const _textareaDOM = document.createElement("textarea");
94
+ _textareaDOM.addEventListener("click", (e) => {
95
+ e.stopPropagation();
96
+ });
97
+ _textareaDOM.addEventListener("mouseup", (e) => {
98
+ e.stopPropagation();
99
+ });
100
+ _textareaDOM.setAttribute("style", `
14
101
  background-color: transparent;
15
102
  border-radius: 5px;
16
- border-color: ${i};
103
+ border-color: ${color};
17
104
  outline: none;
18
105
  resize: none;
19
- width: ${Math.max(t,30)}px;
20
- `),e.setAttribute("maxLength",`${u}`),e}removeTextDOM(){!this._textAttributeDOM||this._textDOM&&this._textAttributeDOM.removeChild(this._textDOM)}removeIconDOM(){!this._textAttributeDOM||this._iconDOM&&this._textAttributeDOM.removeChild(this._iconDOM)}removeTextareaDOM(){var t,i;this._textareaDOM&&this._textAttributeDOM&&((t=this._textAttributeDOM)==null?void 0:t.contains(this._textareaDOM))&&((i=this._textAttributeDOM)==null||i.removeChild(this._textareaDOM))}submitTextarea(){var t;this._textareaDOM&&(this.updateSelectedTextAttribute((t=this._textareaDOM)==null?void 0:t.value),this.removeTextareaDOM(),this.clearTextAttribute())}clearTextAttribute(){this._textAttributeDOM&&this.container.contains(this._textAttributeDOM)&&this.container.removeChild(this._textAttributeDOM)}renderTextarea(){if(!this._textAttributeDOM||!this._textareaDOM)return;const t=this.getCurrentSelectedData();if(!t)return;const{width:i=x,textAttribute:e,color:r}=t;this._textareaDOM.value=`${e}`,this._textareaDOM.setAttribute("style",`
106
+ width: ${Math.max(width, 30)}px;
107
+ `);
108
+ _textareaDOM.setAttribute("maxLength", `${TEXT_ATTRIBUTE_MAX_LENGTH}`);
109
+ return _textareaDOM;
110
+ }
111
+ removeTextDOM() {
112
+ if (!this._textAttributeDOM) {
113
+ return;
114
+ }
115
+ if (this._textDOM) {
116
+ this._textAttributeDOM.removeChild(this._textDOM);
117
+ }
118
+ }
119
+ removeIconDOM() {
120
+ if (!this._textAttributeDOM) {
121
+ return;
122
+ }
123
+ if (this._iconDOM) {
124
+ this._textAttributeDOM.removeChild(this._iconDOM);
125
+ }
126
+ }
127
+ removeTextareaDOM() {
128
+ var _a, _b;
129
+ if (this._textareaDOM && this._textAttributeDOM && ((_a = this._textAttributeDOM) == null ? void 0 : _a.contains(this._textareaDOM))) {
130
+ (_b = this._textAttributeDOM) == null ? void 0 : _b.removeChild(this._textareaDOM);
131
+ }
132
+ }
133
+ submitTextarea() {
134
+ var _a;
135
+ if (this._textareaDOM) {
136
+ this.updateSelectedTextAttribute((_a = this._textareaDOM) == null ? void 0 : _a.value);
137
+ this.removeTextareaDOM();
138
+ this.clearTextAttribute();
139
+ }
140
+ }
141
+ clearTextAttribute() {
142
+ if (this._textAttributeDOM && this.container.contains(this._textAttributeDOM)) {
143
+ this.container.removeChild(this._textAttributeDOM);
144
+ }
145
+ }
146
+ renderTextarea() {
147
+ if (!this._textAttributeDOM || !this._textareaDOM) {
148
+ return;
149
+ }
150
+ const data = this.getCurrentSelectedData();
151
+ if (!data) {
152
+ return;
153
+ }
154
+ const {width = DEFAULT_TEXT_WIDTH, textAttribute, color} = data;
155
+ this._textareaDOM.value = `${textAttribute}`;
156
+ this._textareaDOM.setAttribute("style", `
21
157
  background-color: rgba(0,0,0,0.4);
22
158
  border-radius: 5px;
23
- border-color: ${r};
159
+ border-color: ${color};
24
160
  outline: none;
25
161
  resize: none;
26
162
  font-style: italic;
27
163
  font-weight: 900;
28
164
  text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.6);
29
- width: ${Math.max(i,h)}px;
30
- `),this._textareaDOM.setAttribute("maxLength",`${u}`),this._textAttributeDOM.appendChild(this._textareaDOM),this.removeIconDOM(),this.removeTextDOM(),this._textareaDOM.focus(),this._textareaDOM.addEventListener("keydown",this.textKeyDown)}update(t,i){var e;const{left:r,top:o,color:n,width:s=x}=i,a=Math.max(s,h);(e=this._textAttributeDOM)==null||e.setAttribute("style",`
165
+ width: ${Math.max(width, defaultWidth)}px;
166
+ `);
167
+ this._textareaDOM.setAttribute("maxLength", `${TEXT_ATTRIBUTE_MAX_LENGTH}`);
168
+ this._textAttributeDOM.appendChild(this._textareaDOM);
169
+ this.removeIconDOM();
170
+ this.removeTextDOM();
171
+ this._textareaDOM.focus();
172
+ this._textareaDOM.addEventListener("keydown", this.textKeyDown);
173
+ }
174
+ update(textAttribute, position) {
175
+ var _a;
176
+ const {left, top, color, width = DEFAULT_TEXT_WIDTH} = position;
177
+ const newWidth = Math.max(width, defaultWidth);
178
+ (_a = this._textAttributeDOM) == null ? void 0 : _a.setAttribute("style", `
31
179
  position: absolute;
32
- width: ${a}px;
180
+ width: ${newWidth}px;
33
181
  font-size: 14px;
34
- left:${r}px;
35
- top: ${o}px;
36
- color: ${n};
37
- `),this._textDOM&&(this._textDOM.innerHTML=`${t}`),this._textareaDOM&&(this._textareaDOM.style.width=`${a}px`,this._textareaDOM.style.borderColor=`${n}`)}changeSelected(){this.isExitTextareaDOM&&this.submitTextarea()}}export{M as default};
182
+ left:${left}px;
183
+ top: ${top}px;
184
+ color: ${color};
185
+ `);
186
+ if (this._textDOM) {
187
+ this._textDOM.innerHTML = `${textAttribute}`;
188
+ }
189
+ if (this._textareaDOM) {
190
+ this._textareaDOM.style.width = `${newWidth}px`;
191
+ this._textareaDOM.style.borderColor = `${color}`;
192
+ }
193
+ }
194
+ changeSelected() {
195
+ if (this.isExitTextareaDOM) {
196
+ this.submitTextarea();
197
+ }
198
+ }
199
+ }
200
+
201
+ export { TextAttributeClass as default };
package/es/index.js CHANGED
@@ -1 +1,46 @@
1
- export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
1
+ export { RectOperation } from './core/toolOperation/rectOperation.js';
2
+ export { default as TagOperation } from './core/toolOperation/tagOperation.js';
3
+ export { default as PointOperation } from './core/toolOperation/pointOperation.js';
4
+ export { default as LineToolOperation } from './core/toolOperation/LineToolOperation.js';
5
+ export { default as TextToolOperation } from './core/toolOperation/TextToolOperation.js';
6
+ export { default as PolygonOperation } from './core/toolOperation/polygonOperation.js';
7
+ export { default as MeasureOperation } from './core/toolOperation/measureOperation.js';
8
+ export { BasicToolOperation } from './core/toolOperation/basicToolOperation.js';
9
+ export { default as ViewOperation } from './core/toolOperation/ViewOperation.js';
10
+ export { default as ScribbleTool } from './core/toolOperation/ScribbleTool.js';
11
+ export { default as PointCloud2dOperation } from './core/toolOperation/pointCloud2dOperation.js';
12
+ import * as annotation from './constant/annotation.js';
13
+ export { annotation as cAnnotation };
14
+ import * as annotationTask from './constant/annotationTask.js';
15
+ export { annotationTask as cAnnotationTask };
16
+ import * as keyCode from './constant/keyCode.js';
17
+ export { keyCode as cKeyCode };
18
+ import * as style from './constant/style.js';
19
+ export { style as cStyle };
20
+ import * as tool from './constant/tool.js';
21
+ export { tool as cTool };
22
+ export { CLIENT_TOOL_HEAD_TYPE, CLIENT_TOOL_NAME, DEFAULT_FONT, DEFAULT_TEXT_MAX_WIDTH, EAnnotationMode, EAuditStatus, ECheckModel, EDependPattern, EDragTarget, EDrawPointPattern, EFilterToolOperation, ELineColor, ELineTypes, EOperationMode, EPageOperator, EPointCloudName, EPolygonPattern, ERectPattern, EScribblePattern, ESelectedType, ETextType, EThumbnailOption, EToolName, EToolType, EVideoToolName, OPERATION_LIST, SEGMENT_NUMBER, TEXT_ATTRIBUTE_LINE_HEIGHT, TEXT_ATTRIBUTE_MAX_LENGTH, TEXT_TYPE, TOOL_NAME, TOOL_NAME_EN, edgeAdsorptionScope, editStepWidth } from './constant/tool.js';
23
+ export { default as TagUtils } from './utils/tool/TagUtils.js';
24
+ export { default as uuid } from './utils/uuid.js';
25
+ import EnhanceCommonToolUtils from './utils/tool/EnhanceCommonToolUtils.js';
26
+ export { default as MarkerUtils } from './utils/tool/MarkerUtils.js';
27
+ export { default as RectUtils } from './utils/tool/RectUtils.js';
28
+ export { default as AxisUtils } from './utils/tool/AxisUtils.js';
29
+ export { default as DrawUtils } from './utils/tool/DrawUtils.js';
30
+ export { default as ImgUtils } from './utils/ImgUtils.js';
31
+ export { default as MathUtils } from './utils/MathUtils.js';
32
+ export { default as AttributeUtils } from './utils/tool/AttributeUtils.js';
33
+ export { default as ActionsHistory } from './utils/ActionsHistory.js';
34
+ export { default as DblClickEventListener } from './utils/tool/DblClickEventListener.js';
35
+ export { default as AnnotationEngine } from './core/index.js';
36
+ export { default as UnitUtils } from './utils/tool/UnitUtils.js';
37
+ export { default as StyleUtils } from './utils/tool/StyleUtils.js';
38
+ export { CanvasScheduler } from './newCore/CanvasScheduler.js';
39
+ export { PointCloud } from './core/pointCloud/index.js';
40
+ export { createThreeMatrix4, getCuboidFromPointCloudBox, lidar2image, pointCloudLidar2image, rotatePoint, transferKitti2Matrix } from './core/pointCloud/matrix.js';
41
+ export { PointCloudAnnotation } from './core/pointCloud/annotation.js';
42
+
43
+ const CommonToolUtils = EnhanceCommonToolUtils;
44
+ const toolUtils = EnhanceCommonToolUtils;
45
+
46
+ export { CommonToolUtils, toolUtils };
@@ -1 +1,22 @@
1
- var o;(function(r){r.NoRotateNotice="noRotateNotice",r.RectErrorSizeNotice="rectErrorSizeNotice",r.TextCheckNumberErrorNotice="textCheckNumberErrorNotice",r.TextCheckEnglishErrorNotice="textCheckEnglishErrorNotice",r.TextCheckCustomErrorNotice="textCheckCustomErrorNotice",r.UpperLimitErrorNotice="UpperLimitErrorNotice",r.LowerLimitErrorNotice="LowerLimitErrorNotice",r.InvalidImage="InvalidImage",r.DisableDelete="DisableDelete",r.ClearPartialData="ClearPartialData",r.MarkerFinish="MarkerFinish",r.LowerLimitPoint="LowerLimitPoint",r.NoRotateInDependence="noRotateInDependence",r.UnableToReannotation="unableToReannotation",r.ForbiddenCreationOutsideBoundary="ForbiddenCreationOutsideBoundary",r.SuccessfulEdgeAdsorption="SuccessfulEdgeAdsorption",r.ForbidAddNewPoint="ForbidAddNewPoint"})(o||(o={}));export{o as EMessage};
1
+ var EMessage;
2
+ (function(EMessage2) {
3
+ EMessage2["NoRotateNotice"] = "noRotateNotice";
4
+ EMessage2["RectErrorSizeNotice"] = "rectErrorSizeNotice";
5
+ EMessage2["TextCheckNumberErrorNotice"] = "textCheckNumberErrorNotice";
6
+ EMessage2["TextCheckEnglishErrorNotice"] = "textCheckEnglishErrorNotice";
7
+ EMessage2["TextCheckCustomErrorNotice"] = "textCheckCustomErrorNotice";
8
+ EMessage2["UpperLimitErrorNotice"] = "UpperLimitErrorNotice";
9
+ EMessage2["LowerLimitErrorNotice"] = "LowerLimitErrorNotice";
10
+ EMessage2["InvalidImage"] = "InvalidImage";
11
+ EMessage2["DisableDelete"] = "DisableDelete";
12
+ EMessage2["ClearPartialData"] = "ClearPartialData";
13
+ EMessage2["MarkerFinish"] = "MarkerFinish";
14
+ EMessage2["LowerLimitPoint"] = "LowerLimitPoint";
15
+ EMessage2["NoRotateInDependence"] = "noRotateInDependence";
16
+ EMessage2["UnableToReannotation"] = "unableToReannotation";
17
+ EMessage2["ForbiddenCreationOutsideBoundary"] = "ForbiddenCreationOutsideBoundary";
18
+ EMessage2["SuccessfulEdgeAdsorption"] = "SuccessfulEdgeAdsorption";
19
+ EMessage2["ForbidAddNewPoint"] = "ForbidAddNewPoint";
20
+ })(EMessage || (EMessage = {}));
21
+
22
+ export { EMessage };
@@ -1 +1,23 @@
1
- import{EMessage as e}from"../constants.js";const t={[e.NoRotateNotice]:"This Image contains data and cannot be rotated",[e.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[e.TextCheckNumberErrorNotice]:"Please enter in number-only format",[e.TextCheckEnglishErrorNotice]:"Please enter in English only format",[e.TextCheckCustomErrorNotice]:"Please enter in the required format",[e.UpperLimitErrorNotice]:"The number of vertices is not more than",[e.LowerLimitErrorNotice]:"The number of vertices is not less than",[e.InvalidImage]:"Invalid image, please skip this image",[e.DisableDelete]:"Disable delete",[e.ClearPartialData]:"Clear partial data",[e.MarkerFinish]:"ListAnnotation is finished",[e.LowerLimitPoint]:"The maximum number of points has been reached",[e.NoRotateInDependence]:"Disallow rotation in dependent cases",[e.UnableToReannotation]:"Unabled to reannotation",[e.ForbiddenCreationOutsideBoundary]:"Fobid creation outside boundary",[e.SuccessfulEdgeAdsorption]:"Successful edge adsorption",[e.ForbidAddNewPoint]:"Forbid to add new point in rect-polygon"};export{t as default};
1
+ import { EMessage } from '../constants.js';
2
+
3
+ const message = {
4
+ [EMessage.NoRotateNotice]: "This Image contains data and cannot be rotated",
5
+ [EMessage.RectErrorSizeNotice]: "The drawing frame size is smaller than the minimum drawing size",
6
+ [EMessage.TextCheckNumberErrorNotice]: "Please enter in number-only format",
7
+ [EMessage.TextCheckEnglishErrorNotice]: "Please enter in English only format",
8
+ [EMessage.TextCheckCustomErrorNotice]: "Please enter in the required format",
9
+ [EMessage.UpperLimitErrorNotice]: "The number of vertices is not more than",
10
+ [EMessage.LowerLimitErrorNotice]: "The number of vertices is not less than",
11
+ [EMessage.InvalidImage]: "Invalid image, please skip this image",
12
+ [EMessage.DisableDelete]: "Disable delete",
13
+ [EMessage.ClearPartialData]: "Clear partial data",
14
+ [EMessage.MarkerFinish]: "ListAnnotation is finished",
15
+ [EMessage.LowerLimitPoint]: "The maximum number of points has been reached",
16
+ [EMessage.NoRotateInDependence]: "Disallow rotation in dependent cases",
17
+ [EMessage.UnableToReannotation]: "Unabled to reannotation",
18
+ [EMessage.ForbiddenCreationOutsideBoundary]: "Fobid creation outside boundary",
19
+ [EMessage.SuccessfulEdgeAdsorption]: "Successful edge adsorption",
20
+ [EMessage.ForbidAddNewPoint]: "Forbid to add new point in rect-polygon"
21
+ };
22
+
23
+ export { message as default };
@@ -1 +1,17 @@
1
- import{ELang as e}from"../constant/annotation.js";import o from"./en_US/message.js";import r from"./zh_CN/message.js";class a{}a.getMessagesByLocale=(s,t)=>{switch(t){case e.US:return o[s];case e.Zh:default:return r[s]}};export{a as default};
1
+ import { ELang } from '../constant/annotation.js';
2
+ import message$1 from './en_US/message.js';
3
+ import message from './zh_CN/message.js';
4
+
5
+ class Locale {
6
+ }
7
+ Locale.getMessagesByLocale = (key, locale) => {
8
+ switch (locale) {
9
+ case ELang.US:
10
+ return message$1[key];
11
+ case ELang.Zh:
12
+ default:
13
+ return message[key];
14
+ }
15
+ };
16
+
17
+ export { Locale as default };
@@ -1 +1,23 @@
1
- import{EMessage as u}from"../constants.js";const F={[u.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[u.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[u.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[u.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[u.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[u.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[u.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[u.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[u.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[u.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[u.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[u.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[u.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[u.UnableToReannotation]:"\u65E0\u6CD5\u8FDB\u884C\u7EED\u6807\u64CD\u4F5C",[u.ForbiddenCreationOutsideBoundary]:"\u8FB9\u754C\u5916\u7981\u6B62\u521B\u5EFA",[u.SuccessfulEdgeAdsorption]:"\u8FB9\u7F18\u5438\u9644\u6210\u529F",[u.ForbidAddNewPoint]:"\u6846\u4F53\u65E0\u6CD5\u6DFB\u52A0\u70B9"};export{F as default};
1
+ import { EMessage } from '../constants.js';
2
+
3
+ const message = {
4
+ [EMessage.NoRotateNotice]: "\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",
5
+ [EMessage.RectErrorSizeNotice]: "\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",
6
+ [EMessage.TextCheckNumberErrorNotice]: "\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",
7
+ [EMessage.TextCheckEnglishErrorNotice]: "\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",
8
+ [EMessage.TextCheckCustomErrorNotice]: "\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",
9
+ [EMessage.UpperLimitErrorNotice]: "\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",
10
+ [EMessage.LowerLimitErrorNotice]: "\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",
11
+ [EMessage.InvalidImage]: "\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",
12
+ [EMessage.DisableDelete]: "\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",
13
+ [EMessage.ClearPartialData]: "\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",
14
+ [EMessage.MarkerFinish]: "\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",
15
+ [EMessage.LowerLimitPoint]: "\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",
16
+ [EMessage.NoRotateInDependence]: "\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",
17
+ [EMessage.UnableToReannotation]: "\u65E0\u6CD5\u8FDB\u884C\u7EED\u6807\u64CD\u4F5C",
18
+ [EMessage.ForbiddenCreationOutsideBoundary]: "\u8FB9\u754C\u5916\u7981\u6B62\u521B\u5EFA",
19
+ [EMessage.SuccessfulEdgeAdsorption]: "\u8FB9\u7F18\u5438\u9644\u6210\u529F",
20
+ [EMessage.ForbidAddNewPoint]: "\u6846\u4F53\u65E0\u6CD5\u6DFB\u52A0\u70B9"
21
+ };
22
+
23
+ export { message as default };
@@ -1 +1,31 @@
1
- class a{constructor(e){this.container=e.container}createCanvas(e,t){if(typeof e!="string")return this.container.appendChild(e),e.style.position="absolute",e.style.left="0",e.style.top="0",e;const n=document.createElement("canvas");return n.id=e,t&&t.size&&(n.width=t.size.width,n.height=t.size.height),this.container.appendChild(n),n}destroyCanvas(e){const t=document.getElementById(e);return t&&this.container.removeChild(t),t}}export{a as CanvasScheduler};
1
+ class CanvasScheduler {
2
+ constructor(props) {
3
+ this.container = props.container;
4
+ }
5
+ createCanvas(id, options) {
6
+ if (typeof id !== "string") {
7
+ this.container.appendChild(id);
8
+ id.style.position = "absolute";
9
+ id.style.left = "0";
10
+ id.style.top = "0";
11
+ return id;
12
+ }
13
+ const canvas = document.createElement("canvas");
14
+ canvas.id = id;
15
+ if (options && options.size) {
16
+ canvas.width = options.size.width;
17
+ canvas.height = options.size.height;
18
+ }
19
+ this.container.appendChild(canvas);
20
+ return canvas;
21
+ }
22
+ destroyCanvas(id) {
23
+ const dom = document.getElementById(id);
24
+ if (dom) {
25
+ this.container.removeChild(dom);
26
+ }
27
+ return dom;
28
+ }
29
+ }
30
+
31
+ export { CanvasScheduler };
@@ -1 +1,78 @@
1
- import r from"lodash";class h{constructor(e){this.record=[],this.recordIndex=-1,this.minRecordIndex=-1,this.emitHistoryChanged=()=>{this.historyChanged&&(this.constructor.name==="ActionsHistory"?!0:this.record.length>0)&&this.historyChanged(this.undoEnabled,this.redoEnabled)},this.historyChanged=e}get undoEnabled(){return this.recordIndex>this.minRecordIndex}get redoEnabled(){return this.recordIndex<this.record.length-1}pushHistory(e){if(this.recordIndex!==this.record.length-1){const t=this.record.slice(0,Math.min(this.recordIndex+1,this.record.length));this.record=t}this.record.push(r.cloneDeepWith(e)),this.recordIndex+=1,this.emitHistoryChanged()}updateHistory(e){this.record[this.recordIndex]=r.cloneDeep(e)}applyAttribute(e,t,i){e&&this.record.forEach(d=>{const s=d.find(o=>o.id===e);s&&(s[t]=i)})}undo(){if(this.undoEnabled)return this.recordIndex-=1,this.emitHistoryChanged(),r.cloneDeep(this.record[this.recordIndex])||[]}redo(){if(this.redoEnabled)return this.recordIndex+=1,this.emitHistoryChanged(),r.cloneDeep(this.record[this.recordIndex])}init(){this.record=[[]],this.recordIndex=0,this.emitHistoryChanged()}empty(){this.record=[],this.recordIndex=-1,this.emitHistoryChanged()}initRecord(e,t=!1){const i=e.length>0||t;this.record=i?[r.cloneDeep(e)]:[],this.minRecordIndex=i?0:-1,this.recordIndex=0}}export{h as default};
1
+ import _ from 'lodash';
2
+
3
+ class ActionsHistory {
4
+ constructor(historyChanged) {
5
+ this.record = [];
6
+ this.recordIndex = -1;
7
+ this.minRecordIndex = -1;
8
+ this.emitHistoryChanged = () => {
9
+ if (this.historyChanged) {
10
+ const isEmit = this.constructor.name === "ActionsHistory" ? true : this.record.length > 0;
11
+ if (isEmit) {
12
+ this.historyChanged(this.undoEnabled, this.redoEnabled);
13
+ }
14
+ }
15
+ };
16
+ this.historyChanged = historyChanged;
17
+ }
18
+ get undoEnabled() {
19
+ return this.recordIndex > this.minRecordIndex;
20
+ }
21
+ get redoEnabled() {
22
+ return this.recordIndex < this.record.length - 1;
23
+ }
24
+ pushHistory(action) {
25
+ if (this.recordIndex !== this.record.length - 1) {
26
+ const newRecord = this.record.slice(0, Math.min(this.recordIndex + 1, this.record.length));
27
+ this.record = newRecord;
28
+ }
29
+ this.record.push(_.cloneDeepWith(action));
30
+ this.recordIndex += 1;
31
+ this.emitHistoryChanged();
32
+ }
33
+ updateHistory(newRecord) {
34
+ this.record[this.recordIndex] = _.cloneDeep(newRecord);
35
+ }
36
+ applyAttribute(id, key, value) {
37
+ if (id) {
38
+ this.record.forEach((lines) => {
39
+ const line = lines.find((i) => i.id === id);
40
+ if (line) {
41
+ line[key] = value;
42
+ }
43
+ });
44
+ }
45
+ }
46
+ undo() {
47
+ if (this.undoEnabled) {
48
+ this.recordIndex -= 1;
49
+ this.emitHistoryChanged();
50
+ return _.cloneDeep(this.record[this.recordIndex]) || [];
51
+ }
52
+ }
53
+ redo() {
54
+ if (this.redoEnabled) {
55
+ this.recordIndex += 1;
56
+ this.emitHistoryChanged();
57
+ return _.cloneDeep(this.record[this.recordIndex]);
58
+ }
59
+ }
60
+ init() {
61
+ this.record = [[]];
62
+ this.recordIndex = 0;
63
+ this.emitHistoryChanged();
64
+ }
65
+ empty() {
66
+ this.record = [];
67
+ this.recordIndex = -1;
68
+ this.emitHistoryChanged();
69
+ }
70
+ initRecord(data, isExitData = false) {
71
+ const existData = data.length > 0 || isExitData;
72
+ this.record = existData ? [_.cloneDeep(data)] : [];
73
+ this.minRecordIndex = existData ? 0 : -1;
74
+ this.recordIndex = 0;
75
+ }
76
+ }
77
+
78
+ export { ActionsHistory as default };
@@ -1 +1,21 @@
1
- class r{static load(o){return new Promise((s,n)=>{const e=new Image;e.crossOrigin="anonymous",o.startsWith("file")?e.src=encodeURI(o):e.src=o,e.onload=()=>{s(e)},e.onerror=()=>{n(e)}})}}export{r as default};
1
+ class ImgUtils {
2
+ static load(src) {
3
+ return new Promise((resolve, reject) => {
4
+ const imgNode = new Image();
5
+ imgNode.crossOrigin = "anonymous";
6
+ if (src.startsWith("file")) {
7
+ imgNode.src = encodeURI(src);
8
+ } else {
9
+ imgNode.src = src;
10
+ }
11
+ imgNode.onload = () => {
12
+ resolve(imgNode);
13
+ };
14
+ imgNode.onerror = () => {
15
+ reject(imgNode);
16
+ };
17
+ });
18
+ }
19
+ }
20
+
21
+ export { ImgUtils as default };