@hailin-zheng/editor-core 1.0.18 → 1.0.20

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 (291) hide show
  1. package/lib/doc-ruler.d.ts +1 -0
  2. package/lib/doc-ruler.d.ts.map +1 -0
  3. package/lib/framework/common-util.d.ts +1 -0
  4. package/lib/framework/common-util.d.ts.map +1 -0
  5. package/lib/framework/document-change.d.ts +1 -0
  6. package/lib/framework/document-change.d.ts.map +1 -0
  7. package/lib/framework/document-combine.d.ts +1 -0
  8. package/lib/framework/document-combine.d.ts.map +1 -0
  9. package/lib/framework/document-comment.d.ts +1 -0
  10. package/lib/framework/document-comment.d.ts.map +1 -0
  11. package/lib/framework/document-context.d.ts +1 -0
  12. package/lib/framework/document-context.d.ts.map +1 -0
  13. package/lib/framework/document-eval-func.d.ts +1 -0
  14. package/lib/framework/document-eval-func.d.ts.map +1 -0
  15. package/lib/framework/document-event.d.ts +1 -0
  16. package/lib/framework/document-event.d.ts.map +1 -0
  17. package/lib/framework/document-history.d.ts +1 -0
  18. package/lib/framework/document-history.d.ts.map +1 -0
  19. package/lib/framework/document-images-loader.d.ts +1 -0
  20. package/lib/framework/document-images-loader.d.ts.map +1 -0
  21. package/lib/framework/document-input-cursor.d.ts +1 -0
  22. package/lib/framework/document-input-cursor.d.ts.map +1 -0
  23. package/lib/framework/document-paint.d.ts +1 -0
  24. package/lib/framework/document-paint.d.ts.map +1 -0
  25. package/lib/framework/document-print-offscreen.d.ts +1 -0
  26. package/lib/framework/document-print-offscreen.d.ts.map +1 -0
  27. package/lib/framework/document-print.d.ts +1 -0
  28. package/lib/framework/document-print.d.ts.map +1 -0
  29. package/lib/framework/document-segmenter.d.ts +1 -0
  30. package/lib/framework/document-segmenter.d.ts.map +1 -0
  31. package/lib/framework/document-selection.d.ts +1 -0
  32. package/lib/framework/document-selection.d.ts.map +1 -0
  33. package/lib/framework/document-template.d.ts +1 -0
  34. package/lib/framework/document-template.d.ts.map +1 -0
  35. package/lib/framework/document-textline-mode.d.ts +1 -0
  36. package/lib/framework/document-textline-mode.d.ts.map +1 -0
  37. package/lib/framework/element-define.d.ts +1 -0
  38. package/lib/framework/element-define.d.ts.map +1 -0
  39. package/lib/framework/element-event-define.d.ts +1 -0
  40. package/lib/framework/element-event-define.d.ts.map +1 -0
  41. package/lib/framework/element-measure.d.ts +1 -0
  42. package/lib/framework/element-measure.d.ts.map +1 -0
  43. package/lib/framework/element-paint.d.ts +1 -0
  44. package/lib/framework/element-paint.d.ts.map +1 -0
  45. package/lib/framework/element-props.d.ts +2 -1
  46. package/lib/framework/element-props.d.ts.map +1 -0
  47. package/lib/framework/element-reader.d.ts +1 -0
  48. package/lib/framework/element-reader.d.ts.map +1 -0
  49. package/lib/framework/element-render-cut.d.ts +1 -0
  50. package/lib/framework/element-render-cut.d.ts.map +1 -0
  51. package/lib/framework/element-serialize.d.ts +1 -0
  52. package/lib/framework/element-serialize.d.ts.map +1 -0
  53. package/lib/framework/element-util.d.ts +1 -0
  54. package/lib/framework/element-util.d.ts.map +1 -0
  55. package/lib/framework/impl/checkbox/checkbox-impl.d.ts +1 -0
  56. package/lib/framework/impl/checkbox/checkbox-impl.d.ts.map +1 -0
  57. package/lib/framework/impl/comments/comment-content-impl.d.ts +1 -0
  58. package/lib/framework/impl/comments/comment-content-impl.d.ts.map +1 -0
  59. package/lib/framework/impl/comments/comment-element-impl.d.ts +1 -0
  60. package/lib/framework/impl/comments/comment-element-impl.d.ts.map +1 -0
  61. package/lib/framework/impl/comments/comments-container-impl.d.ts +1 -0
  62. package/lib/framework/impl/comments/comments-container-impl.d.ts.map +1 -0
  63. package/lib/framework/impl/comments/comments-util.d.ts +1 -0
  64. package/lib/framework/impl/comments/comments-util.d.ts.map +1 -0
  65. package/lib/framework/impl/comments/validate-msg-impl.d.ts +1 -0
  66. package/lib/framework/impl/comments/validate-msg-impl.d.ts.map +1 -0
  67. package/lib/framework/impl/data-element/data-decorate-impl.d.ts +1 -0
  68. package/lib/framework/impl/data-element/data-decorate-impl.d.ts.map +1 -0
  69. package/lib/framework/impl/data-element/data-element-barcode.d.ts +1 -0
  70. package/lib/framework/impl/data-element/data-element-barcode.d.ts.map +1 -0
  71. package/lib/framework/impl/data-element/data-element-base-impl.d.ts +1 -0
  72. package/lib/framework/impl/data-element/data-element-base-impl.d.ts.map +1 -0
  73. package/lib/framework/impl/data-element/data-element-check-impl.d.ts +1 -0
  74. package/lib/framework/impl/data-element/data-element-check-impl.d.ts.map +1 -0
  75. package/lib/framework/impl/data-element/data-element-date-impl.d.ts +1 -0
  76. package/lib/framework/impl/data-element/data-element-date-impl.d.ts.map +1 -0
  77. package/lib/framework/impl/data-element/data-element-group-impl.d.ts +1 -0
  78. package/lib/framework/impl/data-element/data-element-group-impl.d.ts.map +1 -0
  79. package/lib/framework/impl/data-element/data-element-image-impl.d.ts +1 -0
  80. package/lib/framework/impl/data-element/data-element-image-impl.d.ts.map +1 -0
  81. package/lib/framework/impl/data-element/data-element-list-impl.d.ts +1 -0
  82. package/lib/framework/impl/data-element/data-element-list-impl.d.ts.map +1 -0
  83. package/lib/framework/impl/data-element/data-element-text-impl.d.ts +1 -0
  84. package/lib/framework/impl/data-element/data-element-text-impl.d.ts.map +1 -0
  85. package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +1 -0
  86. package/lib/framework/impl/decorate/fill-null-space-imple.d.ts.map +1 -0
  87. package/lib/framework/impl/document/doc-body-impl.d.ts +1 -0
  88. package/lib/framework/impl/document/doc-body-impl.d.ts.map +1 -0
  89. package/lib/framework/impl/document/doc-body-part-impl.d.ts +1 -0
  90. package/lib/framework/impl/document/doc-body-part-impl.d.ts.map +1 -0
  91. package/lib/framework/impl/document/doc-container-impl.d.ts +1 -0
  92. package/lib/framework/impl/document/doc-container-impl.d.ts.map +1 -0
  93. package/lib/framework/impl/document/doc-footer-impl.d.ts +1 -0
  94. package/lib/framework/impl/document/doc-footer-impl.d.ts.map +1 -0
  95. package/lib/framework/impl/document/doc-header-impl.d.ts +1 -0
  96. package/lib/framework/impl/document/doc-header-impl.d.ts.map +1 -0
  97. package/lib/framework/impl/document/doc-impl.d.ts +1 -0
  98. package/lib/framework/impl/document/doc-impl.d.ts.map +1 -0
  99. package/lib/framework/impl/index.d.ts +37 -0
  100. package/lib/framework/impl/index.d.ts.map +1 -0
  101. package/lib/framework/impl/media-formula/menstrual-history.d.ts +1 -0
  102. package/lib/framework/impl/media-formula/menstrual-history.d.ts.map +1 -0
  103. package/lib/framework/impl/paragraph/p-impl.d.ts +1 -0
  104. package/lib/framework/impl/paragraph/p-impl.d.ts.map +1 -0
  105. package/lib/framework/impl/picture/image-impl.d.ts +1 -0
  106. package/lib/framework/impl/picture/image-impl.d.ts.map +1 -0
  107. package/lib/framework/impl/radio/radio-impl.d.ts +1 -0
  108. package/lib/framework/impl/radio/radio-impl.d.ts.map +1 -0
  109. package/lib/framework/impl/symbol/br-symbol-impl.d.ts +1 -0
  110. package/lib/framework/impl/symbol/br-symbol-impl.d.ts.map +1 -0
  111. package/lib/framework/impl/symbol/p-symbol-impl.d.ts +1 -0
  112. package/lib/framework/impl/symbol/p-symbol-impl.d.ts.map +1 -0
  113. package/lib/framework/impl/table/table-cell-impl.d.ts +1 -0
  114. package/lib/framework/impl/table/table-cell-impl.d.ts.map +1 -0
  115. package/lib/framework/impl/table/table-impl.d.ts +1 -0
  116. package/lib/framework/impl/table/table-impl.d.ts.map +1 -0
  117. package/lib/framework/impl/table/table-row-impl.d.ts +1 -0
  118. package/lib/framework/impl/table/table-row-impl.d.ts.map +1 -0
  119. package/lib/framework/impl/table/table-split-cell-patch.d.ts +1 -0
  120. package/lib/framework/impl/table/table-split-cell-patch.d.ts.map +1 -0
  121. package/lib/framework/impl/table/table-split-cell.d.ts +1 -0
  122. package/lib/framework/impl/table/table-split-cell.d.ts.map +1 -0
  123. package/lib/framework/impl/table/table-util.d.ts +1 -0
  124. package/lib/framework/impl/table/table-util.d.ts.map +1 -0
  125. package/lib/framework/impl/text/text-impl.d.ts +1 -0
  126. package/lib/framework/impl/text/text-impl.d.ts.map +1 -0
  127. package/lib/framework/impl/text/track-run-impl.d.ts +1 -0
  128. package/lib/framework/impl/text/track-run-impl.d.ts.map +1 -0
  129. package/lib/framework/notify.d.ts +1 -0
  130. package/lib/framework/notify.d.ts.map +1 -0
  131. package/lib/framework/range-util.d.ts +1 -0
  132. package/lib/framework/range-util.d.ts.map +1 -0
  133. package/lib/framework/render-context.d.ts +1 -0
  134. package/lib/framework/render-context.d.ts.map +1 -0
  135. package/lib/framework/render-define.d.ts +1 -0
  136. package/lib/framework/render-define.d.ts.map +1 -0
  137. package/lib/framework/selection-overlays.d.ts +1 -0
  138. package/lib/framework/selection-overlays.d.ts.map +1 -0
  139. package/lib/index.d.ts +35 -0
  140. package/lib/index.d.ts.map +1 -0
  141. package/lib/index.js +15671 -0
  142. package/lib/texteditor.d.ts +3 -2
  143. package/lib/texteditor.d.ts.map +1 -0
  144. package/lib/util/subject.d.ts +1 -0
  145. package/lib/util/subject.d.ts.map +1 -0
  146. package/lib/util/table-bind.d.ts +1 -0
  147. package/lib/util/table-bind.d.ts.map +1 -0
  148. package/package.json +32 -23
  149. package/README.md +0 -1613
  150. package/lib/doc-ruler.js +0 -313
  151. package/lib/doc-ruler.js.map +0 -1
  152. package/lib/framework/common-util.js +0 -178
  153. package/lib/framework/common-util.js.map +0 -1
  154. package/lib/framework/document-change.js +0 -1342
  155. package/lib/framework/document-change.js.map +0 -1
  156. package/lib/framework/document-combine.js +0 -40
  157. package/lib/framework/document-combine.js.map +0 -1
  158. package/lib/framework/document-comment.js +0 -148
  159. package/lib/framework/document-comment.js.map +0 -1
  160. package/lib/framework/document-context.js +0 -330
  161. package/lib/framework/document-context.js.map +0 -1
  162. package/lib/framework/document-eval-func.js +0 -48
  163. package/lib/framework/document-eval-func.js.map +0 -1
  164. package/lib/framework/document-event.js +0 -1054
  165. package/lib/framework/document-event.js.map +0 -1
  166. package/lib/framework/document-history.js +0 -65
  167. package/lib/framework/document-history.js.map +0 -1
  168. package/lib/framework/document-images-loader.js +0 -66
  169. package/lib/framework/document-images-loader.js.map +0 -1
  170. package/lib/framework/document-input-cursor.js +0 -239
  171. package/lib/framework/document-input-cursor.js.map +0 -1
  172. package/lib/framework/document-paint.js +0 -103
  173. package/lib/framework/document-paint.js.map +0 -1
  174. package/lib/framework/document-print-offscreen.js +0 -128
  175. package/lib/framework/document-print-offscreen.js.map +0 -1
  176. package/lib/framework/document-print.js +0 -203
  177. package/lib/framework/document-print.js.map +0 -1
  178. package/lib/framework/document-segmenter.js +0 -106
  179. package/lib/framework/document-segmenter.js.map +0 -1
  180. package/lib/framework/document-selection.js +0 -358
  181. package/lib/framework/document-selection.js.map +0 -1
  182. package/lib/framework/document-template.js +0 -20
  183. package/lib/framework/document-template.js.map +0 -1
  184. package/lib/framework/document-textline-mode.js +0 -30
  185. package/lib/framework/document-textline-mode.js.map +0 -1
  186. package/lib/framework/element-define.js +0 -579
  187. package/lib/framework/element-define.js.map +0 -1
  188. package/lib/framework/element-event-define.js +0 -108
  189. package/lib/framework/element-event-define.js.map +0 -1
  190. package/lib/framework/element-measure.js +0 -551
  191. package/lib/framework/element-measure.js.map +0 -1
  192. package/lib/framework/element-paint.js +0 -170
  193. package/lib/framework/element-paint.js.map +0 -1
  194. package/lib/framework/element-props.js +0 -809
  195. package/lib/framework/element-props.js.map +0 -1
  196. package/lib/framework/element-reader.js +0 -151
  197. package/lib/framework/element-reader.js.map +0 -1
  198. package/lib/framework/element-render-cut.js +0 -449
  199. package/lib/framework/element-render-cut.js.map +0 -1
  200. package/lib/framework/element-serialize.js +0 -113
  201. package/lib/framework/element-serialize.js.map +0 -1
  202. package/lib/framework/element-util.js +0 -1463
  203. package/lib/framework/element-util.js.map +0 -1
  204. package/lib/framework/impl/checkbox/checkbox-impl.js +0 -64
  205. package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
  206. package/lib/framework/impl/comments/comment-content-impl.js +0 -105
  207. package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
  208. package/lib/framework/impl/comments/comment-element-impl.js +0 -62
  209. package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
  210. package/lib/framework/impl/comments/comments-container-impl.js +0 -62
  211. package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
  212. package/lib/framework/impl/comments/comments-util.js +0 -67
  213. package/lib/framework/impl/comments/comments-util.js.map +0 -1
  214. package/lib/framework/impl/comments/validate-msg-impl.js +0 -83
  215. package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
  216. package/lib/framework/impl/data-element/data-decorate-impl.js +0 -91
  217. package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
  218. package/lib/framework/impl/data-element/data-element-barcode.js +0 -115
  219. package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
  220. package/lib/framework/impl/data-element/data-element-base-impl.js +0 -205
  221. package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
  222. package/lib/framework/impl/data-element/data-element-check-impl.js +0 -133
  223. package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
  224. package/lib/framework/impl/data-element/data-element-date-impl.js +0 -111
  225. package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
  226. package/lib/framework/impl/data-element/data-element-group-impl.js +0 -130
  227. package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
  228. package/lib/framework/impl/data-element/data-element-image-impl.js +0 -137
  229. package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
  230. package/lib/framework/impl/data-element/data-element-list-impl.js +0 -131
  231. package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
  232. package/lib/framework/impl/data-element/data-element-text-impl.js +0 -103
  233. package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
  234. package/lib/framework/impl/decorate/fill-null-space-imple.js +0 -43
  235. package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
  236. package/lib/framework/impl/document/doc-body-impl.js +0 -79
  237. package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
  238. package/lib/framework/impl/document/doc-body-part-impl.js +0 -94
  239. package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
  240. package/lib/framework/impl/document/doc-container-impl.js +0 -21
  241. package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
  242. package/lib/framework/impl/document/doc-footer-impl.js +0 -77
  243. package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
  244. package/lib/framework/impl/document/doc-header-impl.js +0 -83
  245. package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
  246. package/lib/framework/impl/document/doc-impl.js +0 -209
  247. package/lib/framework/impl/document/doc-impl.js.map +0 -1
  248. package/lib/framework/impl/media-formula/menstrual-history.js +0 -153
  249. package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
  250. package/lib/framework/impl/paragraph/p-impl.js +0 -156
  251. package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
  252. package/lib/framework/impl/picture/image-impl.js +0 -124
  253. package/lib/framework/impl/picture/image-impl.js.map +0 -1
  254. package/lib/framework/impl/radio/radio-impl.js +0 -72
  255. package/lib/framework/impl/radio/radio-impl.js.map +0 -1
  256. package/lib/framework/impl/symbol/br-symbol-impl.js +0 -54
  257. package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
  258. package/lib/framework/impl/symbol/p-symbol-impl.js +0 -54
  259. package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
  260. package/lib/framework/impl/table/table-cell-impl.js +0 -145
  261. package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
  262. package/lib/framework/impl/table/table-impl.js +0 -363
  263. package/lib/framework/impl/table/table-impl.js.map +0 -1
  264. package/lib/framework/impl/table/table-row-impl.js +0 -75
  265. package/lib/framework/impl/table/table-row-impl.js.map +0 -1
  266. package/lib/framework/impl/table/table-split-cell-patch.js +0 -89
  267. package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
  268. package/lib/framework/impl/table/table-split-cell.js +0 -464
  269. package/lib/framework/impl/table/table-split-cell.js.map +0 -1
  270. package/lib/framework/impl/table/table-util.js +0 -678
  271. package/lib/framework/impl/table/table-util.js.map +0 -1
  272. package/lib/framework/impl/text/text-impl.js +0 -149
  273. package/lib/framework/impl/text/text-impl.js.map +0 -1
  274. package/lib/framework/impl/text/track-run-impl.js +0 -112
  275. package/lib/framework/impl/text/track-run-impl.js.map +0 -1
  276. package/lib/framework/notify.js +0 -116
  277. package/lib/framework/notify.js.map +0 -1
  278. package/lib/framework/range-util.js +0 -312
  279. package/lib/framework/range-util.js.map +0 -1
  280. package/lib/framework/render-context.js +0 -384
  281. package/lib/framework/render-context.js.map +0 -1
  282. package/lib/framework/render-define.js +0 -195
  283. package/lib/framework/render-define.js.map +0 -1
  284. package/lib/framework/selection-overlays.js +0 -124
  285. package/lib/framework/selection-overlays.js.map +0 -1
  286. package/lib/texteditor.js +0 -913
  287. package/lib/texteditor.js.map +0 -1
  288. package/lib/util/subject.js +0 -88
  289. package/lib/util/subject.js.map +0 -1
  290. package/lib/util/table-bind.js +0 -6
  291. package/lib/util/table-bind.js.map +0 -1
@@ -1,124 +0,0 @@
1
- import { ElementUtil } from "./element-util";
2
- import { RangeUtil } from "./range-util";
3
- import { TableElement } from "./impl/table/table-impl";
4
- import { TableCellElement } from "./impl/table/table-cell-impl";
5
- /**
6
- * 用于处理选区拖蓝
7
- */
8
- export class SelectionOverlays {
9
- selectionState;
10
- selectionRange;
11
- selectedSets = new Map();
12
- constructor(selectionState) {
13
- this.selectionState = selectionState;
14
- }
15
- getSelectionTreeData() {
16
- let { ancestorCommonControl, startControl, startOffset, endControl, endOffset, collapsed } = this.selectionState;
17
- this.selectedSets.clear();
18
- if (this.selectionRange) {
19
- this.selectionRange.selectedChildren.length = 0;
20
- }
21
- this.selectionRange = null;
22
- if (!startControl || !endControl || !ancestorCommonControl) {
23
- //this.selectionRange?.selectedChildren.length=0;
24
- this.selectionState.selectedRange = null;
25
- return;
26
- }
27
- if (collapsed) {
28
- const commonRange = RangeUtil.getSelctionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);
29
- this.selectionState.selectedRange = commonRange;
30
- this.selectedSets.clear();
31
- return;
32
- }
33
- const fixStartElement = this.fixStartSelectionElement(startControl, startOffset, ancestorCommonControl);
34
- startControl = fixStartElement.element;
35
- startOffset = fixStartElement.offset;
36
- const fixEndElement = this.fixEndSelectionElement(endControl, endOffset, ancestorCommonControl);
37
- endControl = fixEndElement.element;
38
- endOffset = fixEndElement.offset;
39
- const commonRange = RangeUtil.getSelctionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);
40
- //console.log(commonRange);
41
- this.selectionRange = commonRange;
42
- this.convertSelectRangeToSet();
43
- this.selectionState.selectedRange = commonRange;
44
- }
45
- convertSelectRangeToSet() {
46
- this.selectedSets.clear();
47
- if (this.selectionRange) {
48
- SelectionOverlays.addToSets(this.selectionRange, this.selectedSets);
49
- }
50
- }
51
- static addToSets(range, set) {
52
- set.set(range.target, range);
53
- for (let i = 0; i < range.selectedChildren.length; i++) {
54
- //单元格全部选中效果,单元格整个拖蓝即可
55
- if (range.isFullSelected && range.target.type === 'tbc') {
56
- continue;
57
- }
58
- this.addToSets(range.selectedChildren[i], set);
59
- }
60
- }
61
- /**
62
- * 添加到批注集合
63
- * @param range
64
- * @param set
65
- */
66
- static addToCommentSets(range, set) {
67
- set.set(range.target, range);
68
- for (let i = 0; i < range.selectedChildren.length; i++) {
69
- this.addToCommentSets(range.selectedChildren[i], set);
70
- }
71
- }
72
- /**
73
- * 修正开始选区内容
74
- * 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素
75
- */
76
- fixStartSelectionElement(element, offset, ancestorCommonControl) {
77
- if (!(ancestorCommonControl instanceof TableElement)) {
78
- const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);
79
- if (lookupParentCell) {
80
- if (!lookupParentCell.parent || !lookupParentCell.parent.parent) {
81
- }
82
- const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);
83
- const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);
84
- if (ancestorCommonControlIndex < lookupParentTbIndex) {
85
- const rowFirstLeafElement = ElementUtil.getFirstLeafElement(lookupParentCell.parent);
86
- if (!rowFirstLeafElement) {
87
- throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');
88
- }
89
- return {
90
- element: rowFirstLeafElement,
91
- offset: 0
92
- };
93
- }
94
- }
95
- }
96
- return { element, offset };
97
- }
98
- /**
99
- * 修正开始选区内容
100
- * 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素
101
- */
102
- fixEndSelectionElement(element, offset, ancestorCommonControl) {
103
- if (!(ancestorCommonControl instanceof TableElement)) {
104
- const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);
105
- if (lookupParentCell) {
106
- const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);
107
- const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);
108
- if (ancestorCommonControlIndex < lookupParentTbIndex) {
109
- const rowLastLeafElement = ElementUtil.getLastLeafElement(lookupParentCell.parent);
110
- if (!rowLastLeafElement) {
111
- const rowLastLeafElement = ElementUtil.getLastLeafElement(lookupParentCell.parent);
112
- throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');
113
- }
114
- return {
115
- element: rowLastLeafElement,
116
- offset: 1
117
- };
118
- }
119
- }
120
- }
121
- return { element, offset };
122
- }
123
- }
124
- //# sourceMappingURL=selection-overlays.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selection-overlays.js","sourceRoot":"lib/","sources":["framework/selection-overlays.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,O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AO,EAAE,gBAAgB,CAAC,CAAC;YAChF,IAAI,gBAAgB,EAAE;gBAClB,MAAM,mBAAmB,GAAG,WAAW,CAAC,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACxF,MAAM,0BAA0B,GAAG,WAAW,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC;gBACtF,IAAI,0BAA0B,GAAG,mBAAmB,EAAE;oBAClD,MAAM,kBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;oBACnF,IAAI,CAAC,kBAAkB,EAAE;wBACrB,MAAM,kBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;wBACnF,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;qBACjD;oBACD,OAAO;wBACH,OAAO,EAAE,kBAAkB;wBAC3B,MAAM,EAAE,CAAC;qBACZ,CAAC;iBACL;aACJ;SACJ;QACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC/B,CAAC;CAEJ","sourcesContent":["import { SelectionState } from \"./document-selection\"\nimport { ElementUtil } from \"./element-util\";\nimport { BranchElement, Element, LeafElement, SelectionContentRange } from \"./element-define\";\nimport { RangeUtil } from \"./range-util\";\nimport { TableElement } from \"./impl/table/table-impl\";\nimport { TableCellElement } from \"./impl/table/table-cell-impl\";\n\n\n\n\n/**\n * 用于处理选区拖蓝\n */\nexport class SelectionOverlays {\n private selectionRange!: SelectionContentRange | null;\n selectedSets: Map<Element, SelectionContentRange> = new Map();\n constructor(private selectionState: SelectionState) { }\n\n getSelectionTreeData(): void {\n let { ancestorCommonControl, startControl, startOffset, endControl, endOffset, collapsed } = this.selectionState;\n this.selectedSets.clear();\n if (this.selectionRange) {\n this.selectionRange.selectedChildren.length = 0;\n }\n this.selectionRange = null;\n if (!startControl || !endControl || !ancestorCommonControl) {\n //this.selectionRange?.selectedChildren.length=0;\n this.selectionState.selectedRange = null;\n return;\n }\n if (collapsed) {\n const commonRange = RangeUtil.getSelctionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);\n this.selectionState.selectedRange = commonRange;\n this.selectedSets.clear();\n return;\n }\n const fixStartElement = this.fixStartSelectionElement(startControl, startOffset, ancestorCommonControl);\n startControl = fixStartElement.element;\n startOffset = fixStartElement.offset;\n const fixEndElement = this.fixEndSelectionElement(endControl, endOffset, ancestorCommonControl);\n endControl = fixEndElement.element;\n endOffset = fixEndElement.offset;\n const commonRange = RangeUtil.getSelctionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);\n //console.log(commonRange);\n this.selectionRange = commonRange;\n this.convertSelectRangeToSet();\n this.selectionState.selectedRange = commonRange;\n }\n\n private convertSelectRangeToSet(): void {\n this.selectedSets.clear();\n if (this.selectionRange) {\n SelectionOverlays.addToSets(this.selectionRange, this.selectedSets);\n }\n }\n\n static addToSets(range: SelectionContentRange, set: Map<Element, SelectionContentRange>): void {\n set.set(range.target, range);\n for (let i = 0; i < range.selectedChildren.length; i++) {\n //单元格全部选中效果,单元格整个拖蓝即可\n if (range.isFullSelected && range.target.type === 'tbc') {\n continue;\n }\n this.addToSets(range.selectedChildren[i], set);\n }\n }\n\n /**\n * 添加到批注集合\n * @param range \n * @param set \n */\n static addToCommentSets(range: SelectionContentRange, set: Map<Element, SelectionContentRange>): void {\n set.set(range.target, range);\n for (let i = 0; i < range.selectedChildren.length; i++) {\n this.addToCommentSets(range.selectedChildren[i], set);\n }\n }\n\n /**\n * 修正开始选区内容\n * 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素\n */\n private fixStartSelectionElement(element: LeafElement, offset: number, ancestorCommonControl: BranchElement): { element: LeafElement, offset: number } {\n if (!(ancestorCommonControl instanceof TableElement)) {\n const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);\n if (lookupParentCell) {\n if (!lookupParentCell.parent || !lookupParentCell.parent.parent) {\n }\n const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);\n const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);\n if (ancestorCommonControlIndex < lookupParentTbIndex) {\n const rowFirstLeafElement = ElementUtil.getFirstLeafElement(lookupParentCell.parent);\n if (!rowFirstLeafElement) {\n throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');\n }\n return {\n element: rowFirstLeafElement,\n offset: 0\n };\n }\n }\n }\n return { element, offset };\n }\n\n /**\n * 修正开始选区内容\n * 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素\n */\n private fixEndSelectionElement(element: LeafElement, offset: number, ancestorCommonControl: BranchElement): { element: LeafElement, offset: number } {\n if (!(ancestorCommonControl instanceof TableElement)) {\n const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);\n if (lookupParentCell) {\n const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);\n const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);\n if (ancestorCommonControlIndex < lookupParentTbIndex) {\n const rowLastLeafElement = ElementUtil.getLastLeafElement(lookupParentCell.parent);\n if (!rowLastLeafElement) {\n const rowLastLeafElement = ElementUtil.getLastLeafElement(lookupParentCell.parent);\n throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');\n }\n return {\n element: rowLastLeafElement,\n offset: 1\n };\n }\n }\n }\n return { element, offset };\n }\n\n}"]}