@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,7 +1,7 @@
1
1
  import type { ICodeCell } from '@difizen/libro-common';
2
- import { watch } from '@difizen/mana-app';
3
- import { ViewOption } from '@difizen/mana-app';
4
- import { inject } from '@difizen/mana-app';
2
+ import { watch } from '@difizen/libro-common/app';
3
+ import { ViewOption } from '@difizen/libro-common/app';
4
+ import { inject } from '@difizen/libro-common/app';
5
5
 
6
6
  import type { CellModel } from '../libro-protocol.js';
7
7
  import type { CellViewOptions } from '../libro-protocol.js';
@@ -1,4 +1,4 @@
1
- import { inject, prop, transient } from '@difizen/mana-app';
1
+ import { inject, prop, transient } from '@difizen/libro-common/app';
2
2
 
3
3
  import type { CellView } from './libro-protocol.js';
4
4
  import type { LibroView } from './libro-view.js';
@@ -1,5 +1,5 @@
1
1
  import { SaveOutlined, SettingOutlined } from '@ant-design/icons';
2
- import type { Command } from '@difizen/mana-app';
2
+ import type { Command } from '@difizen/libro-common/app';
3
3
 
4
4
  import { FormatCellIcon } from '../material-from-designer.js';
5
5
 
@@ -1,5 +1,5 @@
1
- import type { Command } from '@difizen/mana-app';
2
- import { l10n } from '@difizen/mana-l10n';
1
+ import type { Command } from '@difizen/libro-common/app';
2
+ import { l10n } from '@difizen/libro-common/l10n';
3
3
 
4
4
  export const KernelCommands: Record<string, Command & { keybind?: string }> = {
5
5
  //#region libro command
@@ -1,12 +1,12 @@
1
1
  import { MIME } from '@difizen/libro-common';
2
- import type { CommandRegistry } from '@difizen/mana-app';
2
+ import type { CommandRegistry } from '@difizen/libro-common/app';
3
3
  import {
4
4
  inject,
5
5
  ModalService,
6
6
  singleton,
7
7
  CommandContribution,
8
- } from '@difizen/mana-app';
9
- import { equals } from '@difizen/mana-app';
8
+ } from '@difizen/libro-common/app';
9
+ import { equals } from '@difizen/libro-common/app';
10
10
  import { v4 } from 'uuid';
11
11
 
12
12
  import { LibroCellView, ExecutableCellModel, EditorCellView } from '../cell/index.js';
@@ -4,8 +4,8 @@ import type {
4
4
  CommandHandlerWithContext,
5
5
  CommandRegistry,
6
6
  KeybindingRegistry,
7
- } from '@difizen/mana-app';
8
- import { inject, singleton } from '@difizen/mana-app';
7
+ } from '@difizen/libro-common/app';
8
+ import { inject, singleton } from '@difizen/libro-common/app';
9
9
 
10
10
  import type { CellView, NotebookView } from '../libro-protocol.js';
11
11
  import { LibroContextKeys } from '../libro-protocol.js';
@@ -1,4 +1,4 @@
1
- import { ManaModule } from '@difizen/mana-app';
1
+ import { ManaModule } from '@difizen/libro-common/app';
2
2
 
3
3
  import { LibroCommandContribution } from './libro-command-contribution.js';
4
4
  import { LibroCommandRegister } from './libro-command-register.js';
@@ -9,8 +9,8 @@ import {
9
9
  // ReloadOutlined,
10
10
  PoweroffOutlined,
11
11
  } from '@ant-design/icons';
12
- import type { Command } from '@difizen/mana-app';
13
- import { l10n } from '@difizen/mana-l10n';
12
+ import type { Command } from '@difizen/libro-common/app';
13
+ import { l10n } from '@difizen/libro-common/l10n';
14
14
 
15
15
  import {
16
16
  Undo,
@@ -8,8 +8,8 @@ import {
8
8
  useObserve,
9
9
  ViewInstance,
10
10
  ViewRender,
11
- } from '@difizen/mana-app';
12
- import { l10n } from '@difizen/mana-l10n';
11
+ } from '@difizen/libro-common/app';
12
+ import { l10n } from '@difizen/libro-common/l10n';
13
13
  import { Tooltip } from 'antd';
14
14
  import classnames from 'classnames';
15
15
  import type { FC } from 'react';
@@ -1,31 +1,27 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
- import { getOrigin, useInject, ViewInstance } from '@difizen/mana-app';
3
- import { useConfigurationValue } from '@difizen/mana-app';
2
+ import { getOrigin, useInject, ViewInstance } from '@difizen/libro-common/app';
3
+ import { useConfigurationValue } from '@difizen/libro-common/app';
4
4
  import { Button } from 'antd';
5
- import type { Identifier } from 'dnd-core';
6
5
  import React, {
7
6
  useCallback,
8
- useEffect,
9
7
  useLayoutEffect,
10
8
  useMemo,
11
9
  useRef,
12
10
  useState,
13
11
  forwardRef,
12
+ useContext,
14
13
  } from 'react';
15
- import { useDrag, useDragDropManager, useDrop } from 'react-dnd';
16
- import { getEmptyImage } from 'react-dnd-html5-backend';
17
14
  import 'resize-observer-polyfill';
18
15
 
19
- import type { CellService } from '../../cell/index.js';
20
- import { LibroCellService } from '../../cell/index.js';
21
16
  import { CellCollapsible } from '../../collapse-service.js';
22
- import { DragAreaKey, isCellView } from '../../libro-protocol.js';
23
17
  import type { CellView, DndContentProps } from '../../libro-protocol.js';
24
18
  import { MultiSelectionWhenShiftClick } from '../../libro-setting.js';
25
19
  import type { LibroView } from '../../libro-view.js';
26
20
  import { HolderOutlined, PlusOutlined } from '../../material-from-designer.js';
27
21
  import { BetweenCellProvider } from '../cell-protocol.js';
28
22
 
23
+ import { DragContext } from './dnd-list.js';
24
+
29
25
  export interface Dragparams {
30
26
  cell: CellView;
31
27
  index: number;
@@ -42,11 +38,21 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
42
38
  MultiSelectionWhenShiftClick,
43
39
  );
44
40
  const BetweenCellContent = useInject<BetweenCellProvider>(BetweenCellProvider);
45
- const cellService = useInject<CellService>(LibroCellService);
46
- const dragDropManager = useDragDropManager();
47
- const dragDropMonitor = dragDropManager.getMonitor();
41
+ const [isMouseOverDragArea, setIsMouseOverDragArea] = useState(false);
42
+ const [isDragDown, setIsDragDown] = useState(false);
48
43
  const ItemRender = getOrigin(instance.dndItemRender);
49
44
 
45
+ const {
46
+ dragOverIndex,
47
+ isDraging,
48
+ sourceIndex,
49
+ onDragStart,
50
+ onDragOver,
51
+ onDrop,
52
+ onDragEnd,
53
+ fragFromRef,
54
+ } = useContext(DragContext);
55
+
50
56
  useLayoutEffect(() => {
51
57
  if (typeof ref !== 'object') {
52
58
  return () => {
@@ -119,174 +125,102 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
119
125
  return;
120
126
  }
121
127
  instance.model.selectCell(cell);
122
- instance.model.selections = [];
128
+ if (instance.model.selections.length !== 0) {
129
+ instance.model.selections = [];
130
+ }
123
131
  }, [instance, cell]);
124
132
 
125
- const scrollTimer = useRef<null | NodeJS.Timeout>(null);
126
- const unsubscribe = useRef<null | any>(null);
133
+ const isMultiSelected =
134
+ instance.model.selections.length !== 0 && instance.isSelected(cell);
135
+
136
+ const isDragOver = useMemo(() => {
137
+ return index === dragOverIndex;
138
+ }, [index, dragOverIndex]);
127
139
 
128
- const [{ isDrag }, drag, preview] = useDrag(
129
- {
130
- type: DragAreaKey,
131
- item: { cell, index },
132
- collect: (monitor) => ({
133
- isDrag: monitor.isDragging(),
134
- }),
135
- end() {
136
- instance.isDragging = false;
137
- if (scrollTimer.current) {
138
- clearInterval(scrollTimer.current);
139
- }
140
- },
140
+ const handleDragStart = useCallback(
141
+ (e: React.DragEvent) => {
142
+ if (!instance.model.cellsEditable) {
143
+ e.preventDefault();
144
+ return;
145
+ }
146
+ onDragStart?.(e, index);
141
147
  },
142
- [cell, index],
148
+ [index, instance.model.cellsEditable, onDragStart],
143
149
  );
144
150
 
145
- const libroViewContent = instance.container?.current?.getElementsByClassName(
146
- 'libro-view-content',
147
- )[0] as HTMLElement;
151
+ const handleDragOver = useCallback(
152
+ (e: React.DragEvent) => {
153
+ //判断拖拽来源是否cell
154
+ if (fragFromRef.current !== 'cell') {
155
+ return;
156
+ }
157
+ e.preventDefault();
158
+ instance.model.mouseMode = 'drag';
159
+ //判断是向下拖拽还是向上拖拽
160
+ if (sourceIndex! < index) {
161
+ setIsDragDown(true);
162
+ } else {
163
+ setIsDragDown(false);
164
+ }
165
+ onDragOver(e, index);
166
+ },
167
+ [fragFromRef, index, instance.model, onDragOver, sourceIndex],
168
+ );
148
169
 
149
- useEffect(() => {
150
- unsubscribe.current = dragDropMonitor.subscribeToStateChange(() => {
151
- instance.isDragging = dragDropMonitor.isDragging();
152
- scrollTimer.current = setInterval(() => {
153
- const currentOffset = dragDropMonitor.getClientOffset();
154
- if (libroViewContent && instance.isDragging && currentOffset) {
155
- const libroViewClientRect = libroViewContent.getBoundingClientRect();
156
- const { top, bottom } = libroViewClientRect;
157
- const { y } = currentOffset;
158
- const topLimit = top + 30;
159
- const bottomLimit = bottom - 50;
160
- if (y < topLimit) {
161
- libroViewContent.scrollTop -= 0.5;
162
- } else if (y > bottomLimit) {
163
- libroViewContent.scrollTop += 0.5;
164
- }
165
- }
166
- }, 10);
167
- return () => {
168
- if (scrollTimer.current) {
169
- clearInterval(scrollTimer.current);
170
- }
171
- if (unsubscribe.current) {
172
- unsubscribe.current();
173
- }
174
- };
175
- });
176
- }, [dragDropMonitor]);
170
+ const handleDrop = useCallback(
171
+ (e: React.DragEvent) => {
172
+ e.preventDefault();
173
+ if (fragFromRef.current !== 'cell') {
174
+ return;
175
+ }
176
+ onDrop(e, index);
177
+ },
178
+ [fragFromRef, index, onDrop],
179
+ );
177
180
 
178
- useEffect(() => {
179
- // This gets called after every render, by default
180
- // (the first one, and every one after that)
181
+ const handleDragEnd = useCallback(
182
+ (e: React.DragEvent) => {
183
+ if (fragFromRef.current !== 'cell') {
184
+ return;
185
+ }
186
+ onDragEnd(e, index);
187
+ },
188
+ [fragFromRef, index, onDragEnd],
189
+ );
181
190
 
182
- // Use empty image as a drag preview so browsers don't draw it
183
- // and we can draw whatever we want on the custom drag layer instead.
184
- preview(getEmptyImage(), {
185
- // IE fallback: specify that we'd rather screenshot the node
186
- // when it already knows it's being dragged so we can hide it with CSS.
187
- captureDraggingState: true,
188
- });
189
- }, [preview]);
191
+ const opacity = useMemo(() => {
192
+ return {
193
+ opacity: isDraging && sourceIndex === index ? 0.4 : 1,
194
+ };
195
+ }, [index, isDraging, sourceIndex]);
190
196
 
191
- const [{ handlerId, isDragOver }, drop] = useDrop<
192
- Dragparams,
193
- void,
194
- {
195
- handlerId: Identifier | null;
196
- isDragOver: boolean;
197
- }
198
- >({
199
- accept: DragAreaKey,
200
- drop(item, monitor) {
201
- cellService
202
- .getOrCreateView(
203
- {
204
- ...item.cell.model.options,
205
- modelId: item.cell.model.id,
206
- singleSelectionDragPreview: true,
207
- },
208
- item.cell.parent.id,
209
- )
210
- .then((view) => {
211
- view.dispose();
212
- return;
213
- })
214
- .catch((e) => {
215
- //
216
- });
217
- if (isCellView(item.cell)) {
218
- const didDrop = monitor.didDrop();
219
- if (didDrop) {
220
- return;
221
- }
222
- const dragIndex = instance.findCellIndex(item.cell);
223
- const dropIndex = instance.findCellIndex(cell);
224
- if (instance.model.selections.length > 0) {
225
- const isDragInSelections =
226
- instance.model.selections.findIndex(
227
- (selection) => selection.id === item.cell.id,
228
- ) > -1
229
- ? true
230
- : false;
231
- const isDropInSelections =
232
- instance.model.selections.findIndex(
233
- (selection) => selection.id === cell.id,
234
- ) > -1
235
- ? true
236
- : false;
237
- if (isDragInSelections && isDropInSelections) {
238
- return;
239
- }
240
- if (isDragInSelections) {
241
- instance.model.exchangeCells(instance.model.selections, dropIndex);
242
- instance.model.scrollToView(cell);
197
+ const onMouseOver = useCallback(() => {
198
+ setIsMouseOverDragArea(true);
199
+ }, []);
243
200
 
244
- return;
245
- }
246
- }
247
- if (dragIndex < dropIndex) {
248
- instance.model.exchangeCell(dragIndex, dropIndex - 1);
249
- instance.model.scrollToView(cell);
250
- }
251
- if (dragIndex > dropIndex) {
252
- instance.model.exchangeCell(dragIndex, dropIndex);
253
- instance.model.scrollToView(cell);
254
- }
255
- }
256
- return;
257
- },
258
- collect(monitor) {
259
- return {
260
- isDragOver: monitor.isOver(),
261
- canDrop: monitor.canDrop(),
262
- handlerId: monitor.getHandlerId(),
263
- };
264
- },
265
- });
266
- const opacity = isDrag ? 0.4 : 1;
267
- if (instance.model.cellsEditable) {
268
- drop(ref);
269
- }
270
- if (isDrag) {
271
- instance.model.mouseMode = 'drag';
272
- }
201
+ const onMouseLeave = useCallback(() => {
202
+ setIsMouseOverDragArea(false);
203
+ }, []);
273
204
 
274
- const isMultiSelected =
275
- instance.model.selections.length !== 0 && instance.isSelected(cell);
276
205
  // let isMouseOver = false;
277
- const [isMouseOverDragArea, setIsMouseOverDragArea] = useState(false);
278
206
  const hasCellHidden = useMemo(() => {
279
207
  return cell.hasCellHidden();
280
208
  }, [cell]);
281
209
  const isCollapsible = CellCollapsible.is(cell);
282
210
 
211
+ const wrapperclassName = useMemo(() => {
212
+ return `libro-dnd-cell-container ${isMultiSelected ? 'multi-selected' : ''} ${
213
+ hasCellHidden ? 'hidden' : ''
214
+ }`;
215
+ }, [isMultiSelected]);
216
+
283
217
  return (
284
218
  <div
285
- className={`libro-dnd-cell-container ${isMultiSelected ? 'multi-selected' : ''} ${
286
- hasCellHidden ? 'hidden' : ''
287
- }`}
288
- data-handler-id={handlerId}
289
- style={{ opacity }}
219
+ className={wrapperclassName}
220
+ onDragOver={handleDragOver}
221
+ onDrop={handleDrop}
222
+ onDragEnd={handleDragEnd}
223
+ style={opacity}
290
224
  ref={ref}
291
225
  id={cell.id}
292
226
  >
@@ -294,15 +228,16 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
294
228
  index={position || index}
295
229
  addCell={cell.parent.addCellAbove}
296
230
  />
297
- {isDragOver && <div className="libro-drag-hoverline" />}
231
+ {!isDragDown && isDragOver && <div className="libro-drag-hoverline" />}
298
232
  {isMouseOverDragArea && <HolderOutlined className="libro-handle-style" />}
299
233
  <div
300
234
  className="libro-drag-area"
301
- ref={drag}
235
+ onDragStart={handleDragStart}
236
+ draggable={instance.model.cellsEditable}
302
237
  onMouseDown={handleMouseDown}
303
238
  onMouseUp={handleMouseUp}
304
- onMouseOver={() => setIsMouseOverDragArea(true)}
305
- onMouseLeave={() => setIsMouseOverDragArea(false)}
239
+ onMouseOver={onMouseOver}
240
+ onMouseLeave={onMouseLeave}
306
241
  />
307
242
  <div
308
243
  tabIndex={-1}
@@ -312,7 +247,7 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
312
247
  >
313
248
  <ItemRender
314
249
  isDragOver={!!isDragOver}
315
- isDrag={!!isDrag}
250
+ isDrag={!!isDraging}
316
251
  cell={cell}
317
252
  isMouseOverDragArea={isMouseOverDragArea}
318
253
  />
@@ -329,6 +264,7 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
329
264
  </Button>
330
265
  </div>
331
266
  )}
267
+ {isDragDown && isDragOver && <div className="libro-drag-hoverline-last-one" />}
332
268
  </div>
333
269
  );
334
270
  };