@difizen/libro-core 0.3.3 → 1.0.0

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 (307) hide show
  1. package/es/add-cell/libro-add-cell-module.d.ts +1 -1
  2. package/es/add-cell/libro-add-cell-module.d.ts.map +1 -1
  3. package/es/add-cell/libro-add-cell-module.js +1 -1
  4. package/es/add-cell/libro-add-cell-slot-contribution.d.ts +1 -1
  5. package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -1
  6. package/es/add-cell/libro-add-cell-slot-contribution.js +2 -2
  7. package/es/add-cell/libro-add-cell-view.d.ts +1 -1
  8. package/es/add-cell/libro-add-cell-view.d.ts.map +1 -1
  9. package/es/add-cell/libro-add-cell-view.js +1 -1
  10. package/es/cell/libro-cell-contribution.js +1 -1
  11. package/es/cell/libro-cell-model.d.ts +1 -1
  12. package/es/cell/libro-cell-model.d.ts.map +1 -1
  13. package/es/cell/libro-cell-model.js +2 -2
  14. package/es/cell/libro-cell-module.d.ts +1 -1
  15. package/es/cell/libro-cell-module.d.ts.map +1 -1
  16. package/es/cell/libro-cell-module.js +1 -1
  17. package/es/cell/libro-cell-protocol.d.ts +2 -2
  18. package/es/cell/libro-cell-protocol.d.ts.map +1 -1
  19. package/es/cell/libro-cell-protocol.js +1 -1
  20. package/es/cell/libro-cell-service.d.ts +2 -2
  21. package/es/cell/libro-cell-service.d.ts.map +1 -1
  22. package/es/cell/libro-cell-service.js +3 -3
  23. package/es/cell/libro-cell-view.d.ts +4 -4
  24. package/es/cell/libro-cell-view.d.ts.map +1 -1
  25. package/es/cell/libro-cell-view.js +6 -6
  26. package/es/cell/libro-edit-cell-view.d.ts +1 -1
  27. package/es/cell/libro-edit-cell-view.d.ts.map +1 -1
  28. package/es/cell/libro-edit-cell-view.js +1 -1
  29. package/es/cell/libro-executable-cell-model.d.ts +1 -1
  30. package/es/cell/libro-executable-cell-model.d.ts.map +1 -1
  31. package/es/cell/libro-executable-cell-view.js +3 -3
  32. package/es/collapse-service.js +1 -1
  33. package/es/command/document-commands.d.ts +1 -1
  34. package/es/command/document-commands.d.ts.map +1 -1
  35. package/es/command/kernel-command.d.ts +1 -1
  36. package/es/command/kernel-command.d.ts.map +1 -1
  37. package/es/command/kernel-command.js +1 -1
  38. package/es/command/libro-command-contribution.d.ts +2 -2
  39. package/es/command/libro-command-contribution.d.ts.map +1 -1
  40. package/es/command/libro-command-contribution.js +2 -2
  41. package/es/command/libro-command-register.d.ts +1 -1
  42. package/es/command/libro-command-register.d.ts.map +1 -1
  43. package/es/command/libro-command-register.js +1 -1
  44. package/es/command/module.d.ts +1 -1
  45. package/es/command/module.d.ts.map +1 -1
  46. package/es/command/module.js +1 -1
  47. package/es/command/notebook-commands.d.ts +1 -1
  48. package/es/command/notebook-commands.d.ts.map +1 -1
  49. package/es/command/notebook-commands.js +1 -1
  50. package/es/components/dnd-cell-item-render.js +2 -2
  51. package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -1
  52. package/es/components/dnd-component/default-dnd-content.js +90 -167
  53. package/es/components/dnd-component/dnd-list.d.ts +12 -0
  54. package/es/components/dnd-component/dnd-list.d.ts.map +1 -1
  55. package/es/components/dnd-component/dnd-list.js +307 -63
  56. package/es/components/dnd-component/index.d.ts +0 -2
  57. package/es/components/dnd-component/index.d.ts.map +1 -1
  58. package/es/components/dnd-component/index.js +0 -2
  59. package/es/components/dnd-component/index.less +84 -0
  60. package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -1
  61. package/es/components/dnd-component/virtualized-manager.js +3 -9
  62. package/es/components/libro-component.js +2 -2
  63. package/es/components/libro-side-toolbar-menu.js +2 -2
  64. package/es/components/libro-view-header.js +1 -1
  65. package/es/content/libro-content-contribution.js +1 -1
  66. package/es/content/libro-content-module.d.ts +1 -1
  67. package/es/content/libro-content-module.d.ts.map +1 -1
  68. package/es/content/libro-content-module.js +1 -1
  69. package/es/content/libro-content-protocol.d.ts +1 -1
  70. package/es/content/libro-content-protocol.d.ts.map +1 -1
  71. package/es/content/libro-content-protocol.js +1 -1
  72. package/es/content/libro-content-service.d.ts +1 -1
  73. package/es/content/libro-content-service.d.ts.map +1 -1
  74. package/es/content/libro-content-service.js +1 -1
  75. package/es/content/libro-save-content-contribution.js +1 -1
  76. package/es/formatter/libro-formatter-json-contribution.d.ts +1 -1
  77. package/es/formatter/libro-formatter-json-contribution.js +1 -1
  78. package/es/formatter/libro-formatter-manager.d.ts +1 -1
  79. package/es/formatter/libro-formatter-manager.d.ts.map +1 -1
  80. package/es/formatter/libro-formatter-manager.js +1 -1
  81. package/es/formatter/libro-formatter-module.d.ts +1 -1
  82. package/es/formatter/libro-formatter-module.d.ts.map +1 -1
  83. package/es/formatter/libro-formatter-module.js +1 -1
  84. package/es/formatter/libro-formatter-protocol.d.ts +1 -1
  85. package/es/formatter/libro-formatter-protocol.d.ts.map +1 -1
  86. package/es/formatter/libro-formatter-protocol.js +1 -1
  87. package/es/formatter/libro-formatter-string-contribution.d.ts +1 -1
  88. package/es/formatter/libro-formatter-string-contribution.js +1 -1
  89. package/es/formatter/libro-formatter-trans-default-contribution.js +1 -1
  90. package/es/index.d.ts +2 -0
  91. package/es/index.d.ts.map +1 -1
  92. package/es/index.js +2 -0
  93. package/es/index.less +0 -22
  94. package/es/libro-context-key.d.ts +3 -3
  95. package/es/libro-context-key.d.ts.map +1 -1
  96. package/es/libro-context-key.js +2 -2
  97. package/es/libro-keybind-registry.d.ts +1 -1
  98. package/es/libro-keybind-registry.d.ts.map +1 -1
  99. package/es/libro-keybind-registry.js +2 -2
  100. package/es/libro-model.d.ts +9 -9
  101. package/es/libro-model.d.ts.map +1 -1
  102. package/es/libro-model.js +4 -4
  103. package/es/libro-protocol.d.ts +2 -2
  104. package/es/libro-protocol.d.ts.map +1 -1
  105. package/es/libro-service.d.ts +13 -13
  106. package/es/libro-service.d.ts.map +1 -1
  107. package/es/libro-service.js +4 -4
  108. package/es/libro-setting-contribution.d.ts +2 -2
  109. package/es/libro-setting-contribution.d.ts.map +1 -1
  110. package/es/libro-setting-contribution.js +1 -1
  111. package/es/libro-setting.d.ts +1 -1
  112. package/es/libro-setting.d.ts.map +1 -1
  113. package/es/libro-setting.js +1 -1
  114. package/es/libro-view-tracker.js +1 -1
  115. package/es/libro-view.d.ts +9 -9
  116. package/es/libro-view.d.ts.map +1 -1
  117. package/es/libro-view.js +8 -12
  118. package/es/libro-workspace-service.d.ts +1 -1
  119. package/es/libro-workspace-service.d.ts.map +1 -1
  120. package/es/libro-workspace-service.js +2 -2
  121. package/es/module.d.ts +1 -1
  122. package/es/module.d.ts.map +1 -1
  123. package/es/module.js +2 -2
  124. package/es/output/output-area.d.ts +4 -4
  125. package/es/output/output-area.d.ts.map +1 -1
  126. package/es/output/output-area.js +2 -2
  127. package/es/output/output-contribution.d.ts +1 -1
  128. package/es/output/output-contribution.d.ts.map +1 -1
  129. package/es/output/output-contribution.js +1 -1
  130. package/es/output/output-model.d.ts +1 -1
  131. package/es/output/output-model.d.ts.map +1 -1
  132. package/es/output/output-model.js +2 -2
  133. package/es/output/output-module.d.ts +1 -1
  134. package/es/output/output-module.d.ts.map +1 -1
  135. package/es/output/output-module.js +1 -1
  136. package/es/output/output-protocol.d.ts +3 -3
  137. package/es/output/output-protocol.d.ts.map +1 -1
  138. package/es/output/output-protocol.js +1 -1
  139. package/es/settings/module.d.ts +1 -1
  140. package/es/settings/module.d.ts.map +1 -1
  141. package/es/settings/module.js +1 -1
  142. package/es/settings/setting-editor/configuration-panel-view.d.ts +2 -2
  143. package/es/settings/setting-editor/configuration-panel-view.d.ts.map +1 -1
  144. package/es/settings/setting-editor/configuration-panel-view.js +1 -1
  145. package/es/settings/setting-editor/configuration-render-contribution.d.ts +2 -2
  146. package/es/settings/setting-editor/configuration-render-contribution.d.ts.map +1 -1
  147. package/es/settings/setting-editor/configuration-render-contribution.js +1 -1
  148. package/es/settings/setting-editor/default-node-render.d.ts +1 -1
  149. package/es/settings/setting-editor/default-node-render.d.ts.map +1 -1
  150. package/es/settings/setting-editor/default-node-render.js +1 -1
  151. package/es/settings/setting-editor/module.d.ts +1 -1
  152. package/es/settings/setting-editor/module.d.ts.map +1 -1
  153. package/es/settings/setting-editor/module.js +1 -1
  154. package/es/settings/setting-editor/setting-editor-view.d.ts +1 -1
  155. package/es/settings/setting-editor/setting-editor-view.d.ts.map +1 -1
  156. package/es/settings/setting-editor/setting-editor-view.js +2 -2
  157. package/es/settings/setting-editor/setting-tree-service.d.ts +3 -3
  158. package/es/settings/setting-editor/setting-tree-service.d.ts.map +1 -1
  159. package/es/settings/setting-editor/setting-tree-service.js +2 -2
  160. package/es/settings/setting-editor/setting-tree-view.d.ts +2 -2
  161. package/es/settings/setting-editor/setting-tree-view.d.ts.map +1 -1
  162. package/es/settings/setting-editor/setting-tree-view.js +2 -2
  163. package/es/settings/settings-contribution.d.ts +3 -3
  164. package/es/settings/settings-contribution.d.ts.map +1 -1
  165. package/es/settings/settings-contribution.js +2 -2
  166. package/es/settings/settings-modal.d.ts +1 -1
  167. package/es/settings/settings-modal.d.ts.map +1 -1
  168. package/es/settings/settings-modal.js +3 -3
  169. package/es/settings/settings-protocol.d.ts +1 -1
  170. package/es/settings/settings-protocol.d.ts.map +1 -1
  171. package/es/slot/libro-slot-manager.d.ts +2 -2
  172. package/es/slot/libro-slot-manager.d.ts.map +1 -1
  173. package/es/slot/libro-slot-manager.js +2 -2
  174. package/es/slot/libro-slot-protocol.d.ts +2 -2
  175. package/es/slot/libro-slot-protocol.d.ts.map +1 -1
  176. package/es/slot/libro-slot-protocol.js +1 -1
  177. package/es/slot/libro-slot-view.d.ts +2 -2
  178. package/es/slot/libro-slot-view.d.ts.map +1 -1
  179. package/es/slot/libro-slot-view.js +3 -3
  180. package/es/slot/module.d.ts +1 -1
  181. package/es/slot/module.d.ts.map +1 -1
  182. package/es/slot/module.js +1 -1
  183. package/es/theme/libro-color-registry.d.ts +2 -2
  184. package/es/theme/libro-color-registry.d.ts.map +1 -1
  185. package/es/theme/libro-color-registry.js +2 -2
  186. package/es/toolbar/all-outputs-scroll-icon.js +1 -1
  187. package/es/toolbar/change-cell-to-selector.js +1 -1
  188. package/es/toolbar/hide-all-selector.js +2 -2
  189. package/es/toolbar/libro-toolbar.d.ts +2 -2
  190. package/es/toolbar/libro-toolbar.d.ts.map +1 -1
  191. package/es/toolbar/libro-toolbar.js +3 -3
  192. package/es/toolbar/module.d.ts +1 -1
  193. package/es/toolbar/module.d.ts.map +1 -1
  194. package/es/toolbar/module.js +1 -1
  195. package/es/toolbar/restart-clear-outputs-contribution.d.ts +2 -2
  196. package/es/toolbar/restart-clear-outputs-contribution.d.ts.map +1 -1
  197. package/es/toolbar/restart-clear-outputs-contribution.js +1 -1
  198. package/es/toolbar/restart-clear-outputs-modal.d.ts +1 -1
  199. package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -1
  200. package/es/toolbar/restart-clear-outputs-modal.js +1 -1
  201. package/es/toolbar/save-icon.js +1 -1
  202. package/es/toolbar/shutdown-contribution.d.ts +2 -2
  203. package/es/toolbar/shutdown-contribution.d.ts.map +1 -1
  204. package/es/toolbar/shutdown-contribution.js +1 -1
  205. package/es/toolbar/shutdown-modal.d.ts +1 -1
  206. package/es/toolbar/shutdown-modal.d.ts.map +1 -1
  207. package/es/toolbar/side-toolar-more-select.js +4 -4
  208. package/es/utils/index.js +1 -1
  209. package/es/virtualized-manager-helper.js +1 -1
  210. package/es/virtualized-manager.d.ts.map +1 -1
  211. package/es/virtualized-manager.js +2 -9
  212. package/package.json +10 -9
  213. package/src/add-cell/libro-add-cell-module.ts +1 -1
  214. package/src/add-cell/libro-add-cell-slot-contribution.ts +2 -2
  215. package/src/add-cell/libro-add-cell-view.tsx +1 -1
  216. package/src/cell/libro-cell-contribution.ts +1 -1
  217. package/src/cell/libro-cell-model.ts +2 -2
  218. package/src/cell/libro-cell-module.ts +1 -1
  219. package/src/cell/libro-cell-protocol.ts +2 -2
  220. package/src/cell/libro-cell-service.ts +4 -4
  221. package/src/cell/libro-cell-view.tsx +7 -7
  222. package/src/cell/libro-edit-cell-view.tsx +1 -1
  223. package/src/cell/libro-executable-cell-model.ts +1 -1
  224. package/src/cell/libro-executable-cell-view.ts +3 -3
  225. package/src/collapse-service.ts +1 -1
  226. package/src/command/document-commands.ts +1 -1
  227. package/src/command/kernel-command.ts +2 -2
  228. package/src/command/libro-command-contribution.ts +3 -3
  229. package/src/command/libro-command-register.ts +2 -2
  230. package/src/command/module.ts +1 -1
  231. package/src/command/notebook-commands.ts +2 -2
  232. package/src/components/dnd-cell-item-render.tsx +2 -2
  233. package/src/components/dnd-component/default-dnd-content.tsx +101 -165
  234. package/src/components/dnd-component/dnd-list.tsx +309 -35
  235. package/src/components/dnd-component/index.less +84 -0
  236. package/src/components/dnd-component/index.tsx +0 -2
  237. package/src/components/dnd-component/virtualized-manager.ts +11 -8
  238. package/src/components/libro-component.tsx +2 -2
  239. package/src/components/libro-side-toolbar-menu.tsx +3 -3
  240. package/src/components/libro-view-header.tsx +1 -1
  241. package/src/content/libro-content-contribution.ts +1 -1
  242. package/src/content/libro-content-module.ts +1 -1
  243. package/src/content/libro-content-protocol.ts +1 -1
  244. package/src/content/libro-content-service.ts +2 -2
  245. package/src/content/libro-save-content-contribution.ts +1 -1
  246. package/src/formatter/libro-formatter-json-contribution.ts +1 -1
  247. package/src/formatter/libro-formatter-manager.ts +2 -2
  248. package/src/formatter/libro-formatter-module.ts +1 -1
  249. package/src/formatter/libro-formatter-protocol.ts +1 -1
  250. package/src/formatter/libro-formatter-string-contribution.ts +1 -1
  251. package/src/formatter/libro-formatter-trans-default-contribution.ts +1 -1
  252. package/src/index.less +0 -22
  253. package/src/index.tsx +3 -0
  254. package/src/libro-context-key.ts +4 -4
  255. package/src/libro-keybind-registry.ts +2 -2
  256. package/src/libro-model.ts +4 -4
  257. package/src/libro-protocol.ts +2 -2
  258. package/src/libro-service.ts +5 -5
  259. package/src/libro-setting-contribution.ts +1 -1
  260. package/src/libro-setting.ts +2 -2
  261. package/src/libro-view-tracker.ts +1 -1
  262. package/src/libro-view.tsx +8 -18
  263. package/src/libro-workspace-service.ts +2 -2
  264. package/src/module.ts +2 -2
  265. package/src/output/output-area.tsx +3 -3
  266. package/src/output/output-contribution.ts +1 -1
  267. package/src/output/output-model.tsx +2 -2
  268. package/src/output/output-module.ts +1 -1
  269. package/src/output/output-protocol.ts +3 -3
  270. package/src/settings/module.ts +1 -1
  271. package/src/settings/setting-editor/configuration-panel-view.tsx +2 -2
  272. package/src/settings/setting-editor/configuration-render-contribution.ts +2 -2
  273. package/src/settings/setting-editor/default-node-render.tsx +2 -2
  274. package/src/settings/setting-editor/module.ts +1 -1
  275. package/src/settings/setting-editor/setting-editor-view.tsx +2 -2
  276. package/src/settings/setting-editor/setting-tree-service.ts +3 -3
  277. package/src/settings/setting-editor/setting-tree-view.tsx +3 -3
  278. package/src/settings/settings-contribution.tsx +7 -3
  279. package/src/settings/settings-modal.tsx +4 -4
  280. package/src/settings/settings-protocol.ts +1 -1
  281. package/src/slot/libro-slot-manager.ts +3 -3
  282. package/src/slot/libro-slot-protocol.ts +2 -2
  283. package/src/slot/libro-slot-view.tsx +9 -4
  284. package/src/slot/module.ts +1 -1
  285. package/src/theme/libro-color-registry.ts +3 -3
  286. package/src/toolbar/all-outputs-scroll-icon.tsx +1 -1
  287. package/src/toolbar/change-cell-to-selector.tsx +2 -2
  288. package/src/toolbar/hide-all-selector.tsx +3 -3
  289. package/src/toolbar/libro-toolbar.tsx +4 -4
  290. package/src/toolbar/module.ts +1 -1
  291. package/src/toolbar/restart-clear-outputs-contribution.tsx +1 -1
  292. package/src/toolbar/restart-clear-outputs-modal.tsx +2 -2
  293. package/src/toolbar/save-icon.tsx +2 -2
  294. package/src/toolbar/shutdown-contribution.tsx +1 -1
  295. package/src/toolbar/shutdown-modal.tsx +1 -1
  296. package/src/toolbar/side-toolar-more-select.tsx +5 -5
  297. package/src/utils/index.ts +1 -1
  298. package/src/virtualized-manager-helper.ts +1 -1
  299. package/src/virtualized-manager.ts +10 -8
  300. package/es/components/dnd-component/custom-drag-layer.d.ts +0 -9
  301. package/es/components/dnd-component/custom-drag-layer.d.ts.map +0 -1
  302. package/es/components/dnd-component/custom-drag-layer.js +0 -140
  303. package/es/components/dnd-component/dnd-context.d.ts +0 -3
  304. package/es/components/dnd-component/dnd-context.d.ts.map +0 -1
  305. package/es/components/dnd-component/dnd-context.js +0 -20
  306. package/src/components/dnd-component/custom-drag-layer.tsx +0 -144
  307. package/src/components/dnd-component/dnd-context.tsx +0 -28
@@ -1,8 +1,3 @@
1
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -11,23 +6,19 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
6
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
8
  /* eslint-disable react-hooks/exhaustive-deps */
14
- import { getOrigin, useInject, ViewInstance } from '@difizen/mana-app';
15
- import { useConfigurationValue } from '@difizen/mana-app';
9
+ import { getOrigin, useInject, ViewInstance } from '@difizen/libro-common/app';
10
+ import { useConfigurationValue } from '@difizen/libro-common/app';
16
11
  import { Button } from 'antd';
17
- import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, forwardRef } from 'react';
18
- import { useDrag, useDragDropManager, useDrop } from 'react-dnd';
19
- import { getEmptyImage } from 'react-dnd-html5-backend';
12
+ import React, { useCallback, useLayoutEffect, useMemo, useRef, useState, forwardRef, useContext } from 'react';
20
13
  import 'resize-observer-polyfill';
21
- import { LibroCellService } from "../../cell/index.js";
22
14
  import { CellCollapsible } from "../../collapse-service.js";
23
- import { DragAreaKey, isCellView } from "../../libro-protocol.js";
24
15
  import { MultiSelectionWhenShiftClick } from "../../libro-setting.js";
25
16
  import { HolderOutlined, PlusOutlined } from "../../material-from-designer.js";
26
17
  import { BetweenCellProvider } from "../cell-protocol.js";
18
+ import { DragContext } from "./dnd-list.js";
27
19
  import { jsx as _jsx } from "react/jsx-runtime";
28
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
29
21
  export var DndCellContainer = function DndCellContainer(_ref) {
30
- var _instance$container;
31
22
  var cell = _ref.cell,
32
23
  index = _ref.index,
33
24
  position = _ref.position;
@@ -37,10 +28,24 @@ export var DndCellContainer = function DndCellContainer(_ref) {
37
28
  _useConfigurationValu2 = _slicedToArray(_useConfigurationValu, 1),
38
29
  multiSelectionWhenShiftClick = _useConfigurationValu2[0];
39
30
  var BetweenCellContent = useInject(BetweenCellProvider);
40
- var cellService = useInject(LibroCellService);
41
- var dragDropManager = useDragDropManager();
42
- var dragDropMonitor = dragDropManager.getMonitor();
31
+ var _useState = useState(false),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ isMouseOverDragArea = _useState2[0],
34
+ setIsMouseOverDragArea = _useState2[1];
35
+ var _useState3 = useState(false),
36
+ _useState4 = _slicedToArray(_useState3, 2),
37
+ isDragDown = _useState4[0],
38
+ setIsDragDown = _useState4[1];
43
39
  var ItemRender = getOrigin(instance.dndItemRender);
40
+ var _useContext = useContext(DragContext),
41
+ dragOverIndex = _useContext.dragOverIndex,
42
+ isDraging = _useContext.isDraging,
43
+ sourceIndex = _useContext.sourceIndex,
44
+ onDragStart = _useContext.onDragStart,
45
+ onDragOver = _useContext.onDragOver,
46
+ onDrop = _useContext.onDrop,
47
+ onDragEnd = _useContext.onDragEnd,
48
+ fragFromRef = _useContext.fragFromRef;
44
49
  useLayoutEffect(function () {
45
50
  if (_typeof(ref) !== 'object') {
46
51
  return function () {
@@ -93,176 +98,92 @@ export var DndCellContainer = function DndCellContainer(_ref) {
93
98
  return;
94
99
  }
95
100
  instance.model.selectCell(cell);
96
- instance.model.selections = [];
101
+ if (instance.model.selections.length !== 0) {
102
+ instance.model.selections = [];
103
+ }
97
104
  }, [instance, cell]);
98
- var scrollTimer = useRef(null);
99
- var unsubscribe = useRef(null);
100
- var _useDrag = useDrag({
101
- type: DragAreaKey,
102
- item: {
103
- cell: cell,
104
- index: index
105
- },
106
- collect: function collect(monitor) {
107
- return {
108
- isDrag: monitor.isDragging()
109
- };
110
- },
111
- end: function end() {
112
- instance.isDragging = false;
113
- if (scrollTimer.current) {
114
- clearInterval(scrollTimer.current);
115
- }
116
- }
117
- }, [cell, index]),
118
- _useDrag2 = _slicedToArray(_useDrag, 3),
119
- isDrag = _useDrag2[0].isDrag,
120
- drag = _useDrag2[1],
121
- preview = _useDrag2[2];
122
- var libroViewContent = (_instance$container = instance.container) === null || _instance$container === void 0 || (_instance$container = _instance$container.current) === null || _instance$container === void 0 ? void 0 : _instance$container.getElementsByClassName('libro-view-content')[0];
123
- useEffect(function () {
124
- unsubscribe.current = dragDropMonitor.subscribeToStateChange(function () {
125
- instance.isDragging = dragDropMonitor.isDragging();
126
- scrollTimer.current = setInterval(function () {
127
- var currentOffset = dragDropMonitor.getClientOffset();
128
- if (libroViewContent && instance.isDragging && currentOffset) {
129
- var libroViewClientRect = libroViewContent.getBoundingClientRect();
130
- var top = libroViewClientRect.top,
131
- bottom = libroViewClientRect.bottom;
132
- var y = currentOffset.y;
133
- var topLimit = top + 30;
134
- var bottomLimit = bottom - 50;
135
- if (y < topLimit) {
136
- libroViewContent.scrollTop -= 0.5;
137
- } else if (y > bottomLimit) {
138
- libroViewContent.scrollTop += 0.5;
139
- }
140
- }
141
- }, 10);
142
- return function () {
143
- if (scrollTimer.current) {
144
- clearInterval(scrollTimer.current);
145
- }
146
- if (unsubscribe.current) {
147
- unsubscribe.current();
148
- }
149
- };
150
- });
151
- }, [dragDropMonitor]);
152
- useEffect(function () {
153
- // This gets called after every render, by default
154
- // (the first one, and every one after that)
155
-
156
- // Use empty image as a drag preview so browsers don't draw it
157
- // and we can draw whatever we want on the custom drag layer instead.
158
- preview(getEmptyImage(), {
159
- // IE fallback: specify that we'd rather screenshot the node
160
- // when it already knows it's being dragged so we can hide it with CSS.
161
- captureDraggingState: true
162
- });
163
- }, [preview]);
164
- var _useDrop = useDrop({
165
- accept: DragAreaKey,
166
- drop: function drop(item, monitor) {
167
- cellService.getOrCreateView(_objectSpread(_objectSpread({}, item.cell.model.options), {}, {
168
- modelId: item.cell.model.id,
169
- singleSelectionDragPreview: true
170
- }), item.cell.parent.id).then(function (view) {
171
- view.dispose();
172
- return;
173
- }).catch(function (e) {
174
- //
175
- });
176
- if (isCellView(item.cell)) {
177
- var didDrop = monitor.didDrop();
178
- if (didDrop) {
179
- return;
180
- }
181
- var dragIndex = instance.findCellIndex(item.cell);
182
- var dropIndex = instance.findCellIndex(cell);
183
- if (instance.model.selections.length > 0) {
184
- var isDragInSelections = instance.model.selections.findIndex(function (selection) {
185
- return selection.id === item.cell.id;
186
- }) > -1 ? true : false;
187
- var isDropInSelections = instance.model.selections.findIndex(function (selection) {
188
- return selection.id === cell.id;
189
- }) > -1 ? true : false;
190
- if (isDragInSelections && isDropInSelections) {
191
- return;
192
- }
193
- if (isDragInSelections) {
194
- instance.model.exchangeCells(instance.model.selections, dropIndex);
195
- instance.model.scrollToView(cell);
196
- return;
197
- }
198
- }
199
- if (dragIndex < dropIndex) {
200
- instance.model.exchangeCell(dragIndex, dropIndex - 1);
201
- instance.model.scrollToView(cell);
202
- }
203
- if (dragIndex > dropIndex) {
204
- instance.model.exchangeCell(dragIndex, dropIndex);
205
- instance.model.scrollToView(cell);
206
- }
207
- }
208
- return;
209
- },
210
- collect: function collect(monitor) {
211
- return {
212
- isDragOver: monitor.isOver(),
213
- canDrop: monitor.canDrop(),
214
- handlerId: monitor.getHandlerId()
215
- };
216
- }
217
- }),
218
- _useDrop2 = _slicedToArray(_useDrop, 2),
219
- _useDrop2$ = _useDrop2[0],
220
- handlerId = _useDrop2$.handlerId,
221
- isDragOver = _useDrop2$.isDragOver,
222
- drop = _useDrop2[1];
223
- var opacity = isDrag ? 0.4 : 1;
224
- if (instance.model.cellsEditable) {
225
- drop(ref);
226
- }
227
- if (isDrag) {
228
- instance.model.mouseMode = 'drag';
229
- }
230
105
  var isMultiSelected = instance.model.selections.length !== 0 && instance.isSelected(cell);
106
+ var isDragOver = useMemo(function () {
107
+ return index === dragOverIndex;
108
+ }, [index, dragOverIndex]);
109
+ var handleDragStart = useCallback(function (e) {
110
+ if (!instance.model.cellsEditable) {
111
+ e.preventDefault();
112
+ return;
113
+ }
114
+ onDragStart === null || onDragStart === void 0 || onDragStart(e, index);
115
+ }, [index, instance.model.cellsEditable, onDragStart]);
116
+ var handleDragOver = useCallback(function (e) {
117
+ //判断拖拽来源是否cell
118
+ if (fragFromRef.current !== 'cell') {
119
+ return;
120
+ }
121
+ e.preventDefault();
122
+ instance.model.mouseMode = 'drag';
123
+ //判断是向下拖拽还是向上拖拽
124
+ if (sourceIndex < index) {
125
+ setIsDragDown(true);
126
+ } else {
127
+ setIsDragDown(false);
128
+ }
129
+ onDragOver(e, index);
130
+ }, [fragFromRef, index, instance.model, onDragOver, sourceIndex]);
131
+ var handleDrop = useCallback(function (e) {
132
+ e.preventDefault();
133
+ if (fragFromRef.current !== 'cell') {
134
+ return;
135
+ }
136
+ onDrop(e, index);
137
+ }, [fragFromRef, index, onDrop]);
138
+ var handleDragEnd = useCallback(function (e) {
139
+ if (fragFromRef.current !== 'cell') {
140
+ return;
141
+ }
142
+ onDragEnd(e, index);
143
+ }, [fragFromRef, index, onDragEnd]);
144
+ var opacity = useMemo(function () {
145
+ return {
146
+ opacity: isDraging && sourceIndex === index ? 0.4 : 1
147
+ };
148
+ }, [index, isDraging, sourceIndex]);
149
+ var onMouseOver = useCallback(function () {
150
+ setIsMouseOverDragArea(true);
151
+ }, []);
152
+ var onMouseLeave = useCallback(function () {
153
+ setIsMouseOverDragArea(false);
154
+ }, []);
155
+
231
156
  // let isMouseOver = false;
232
- var _useState = useState(false),
233
- _useState2 = _slicedToArray(_useState, 2),
234
- isMouseOverDragArea = _useState2[0],
235
- setIsMouseOverDragArea = _useState2[1];
236
157
  var hasCellHidden = useMemo(function () {
237
158
  return cell.hasCellHidden();
238
159
  }, [cell]);
239
160
  var isCollapsible = CellCollapsible.is(cell);
161
+ var wrapperclassName = useMemo(function () {
162
+ return "libro-dnd-cell-container ".concat(isMultiSelected ? 'multi-selected' : '', " ").concat(hasCellHidden ? 'hidden' : '');
163
+ }, [isMultiSelected]);
240
164
  return /*#__PURE__*/_jsxs("div", {
241
- className: "libro-dnd-cell-container ".concat(isMultiSelected ? 'multi-selected' : '', " ").concat(hasCellHidden ? 'hidden' : ''),
242
- "data-handler-id": handlerId,
243
- style: {
244
- opacity: opacity
245
- },
165
+ className: wrapperclassName,
166
+ onDragOver: handleDragOver,
167
+ onDrop: handleDrop,
168
+ onDragEnd: handleDragEnd,
169
+ style: opacity,
246
170
  ref: ref,
247
171
  id: cell.id,
248
172
  children: [/*#__PURE__*/_jsx(BetweenCellContent, {
249
173
  index: position || index,
250
174
  addCell: cell.parent.addCellAbove
251
- }), isDragOver && /*#__PURE__*/_jsx("div", {
175
+ }), !isDragDown && isDragOver && /*#__PURE__*/_jsx("div", {
252
176
  className: "libro-drag-hoverline"
253
177
  }), isMouseOverDragArea && /*#__PURE__*/_jsx(HolderOutlined, {
254
178
  className: "libro-handle-style"
255
179
  }), /*#__PURE__*/_jsx("div", {
256
180
  className: "libro-drag-area",
257
- ref: drag,
181
+ onDragStart: handleDragStart,
182
+ draggable: instance.model.cellsEditable,
258
183
  onMouseDown: handleMouseDown,
259
184
  onMouseUp: handleMouseUp,
260
- onMouseOver: function onMouseOver() {
261
- return setIsMouseOverDragArea(true);
262
- },
263
- onMouseLeave: function onMouseLeave() {
264
- return setIsMouseOverDragArea(false);
265
- }
185
+ onMouseOver: onMouseOver,
186
+ onMouseLeave: onMouseLeave
266
187
  }), /*#__PURE__*/_jsx("div", {
267
188
  tabIndex: -1,
268
189
  onFocus: handleFocus
@@ -271,7 +192,7 @@ export var DndCellContainer = function DndCellContainer(_ref) {
271
192
  className: "libro-dnd-cell-content",
272
193
  children: /*#__PURE__*/_jsx(ItemRender, {
273
194
  isDragOver: !!isDragOver,
274
- isDrag: !!isDrag,
195
+ isDrag: !!isDraging,
275
196
  cell: cell,
276
197
  isMouseOverDragArea: isMouseOverDragArea
277
198
  })
@@ -288,6 +209,8 @@ export var DndCellContainer = function DndCellContainer(_ref) {
288
209
  type: "default",
289
210
  children: [cell.collapsibleChildNumber, " cell hidden"]
290
211
  })
212
+ }), isDragDown && isDragOver && /*#__PURE__*/_jsx("div", {
213
+ className: "libro-drag-hoverline-last-one"
291
214
  })]
292
215
  });
293
216
  };
@@ -2,6 +2,17 @@ import type { FC, ReactNode } from 'react';
2
2
  import type { DndContentProps } from '../../libro-protocol.js';
3
3
  import type { LibroView } from '../../libro-view.js';
4
4
  import './index.less';
5
+ interface IDragContextType {
6
+ dragOverIndex?: number;
7
+ isDraging: boolean;
8
+ sourceIndex?: number;
9
+ onDragStart: (e: React.DragEvent, index: number) => void;
10
+ onDragOver: (e: React.DragEvent, index: number) => void;
11
+ onDrop: (e: React.DragEvent, index: number) => void;
12
+ onDragEnd: (e?: React.DragEvent, index?: number) => void;
13
+ fragFromRef: any;
14
+ }
15
+ export declare const DragContext: import("react").Context<IDragContextType>;
5
16
  export declare const DndCellRender: FC<DndContentProps>;
6
17
  export declare const DndCellsRender: import("react").ForwardRefExoticComponent<{
7
18
  libroView: LibroView;
@@ -11,4 +22,5 @@ export declare const DndList: import("react").ForwardRefExoticComponent<{
11
22
  libroView: LibroView;
12
23
  children: ReactNode;
13
24
  } & import("react").RefAttributes<HTMLDivElement>>;
25
+ export {};
14
26
  //# sourceMappingURL=dnd-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dnd-list.d.ts","sourceRoot":"","sources":["../../../src/components/dnd-component/dnd-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3C,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,eAAe,CAY5C,CAAC;AA2BH,eAAO,MAAM,cAAc;eAEZ,SAAS;oBAAkB,SAAS;kDAsFjD,CAAC;AAEH,eAAO,MAAM,OAAO;eAEL,SAAS;cAAY,SAAS;kDA2E3C,CAAC"}
1
+ {"version":3,"file":"dnd-list.d.ts","sourceRoot":"","sources":["../../../src/components/dnd-component/dnd-list.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAgB3C,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,OAAO,cAAc,CAAC;AAEtB,UAAU,gBAAgB;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,eAAO,MAAM,WAAW,2CAiBtB,CAAC;AA6CH,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,eAAe,CAY5C,CAAC;AA2BH,eAAO,MAAM,cAAc;eAEZ,SAAS;oBAAkB,SAAS;kDAsFjD,CAAC;AAEH,eAAO,MAAM,OAAO;eAEL,SAAS;cAAY,SAAS;kDAsQ3C,CAAC"}