@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,21 +1,108 @@
1
- import { getOrigin, useInject, useObserve, ViewInstance } from '@difizen/mana-app';
1
+ import {
2
+ getOrigin,
3
+ useInject,
4
+ useObserve,
5
+ ViewInstance,
6
+ } from '@difizen/libro-common/app';
2
7
  import classNames from 'classnames';
8
+ import { throttle } from 'lodash';
3
9
  import type { FC, ReactNode } from 'react';
4
- import { forwardRef, memo, useEffect, useState } from 'react';
5
- import type { XYCoord } from 'react-dnd';
6
- import { useDrop } from 'react-dnd';
10
+ import {
11
+ useRef,
12
+ useCallback,
13
+ createContext,
14
+ useMemo,
15
+ forwardRef,
16
+ memo,
17
+ useEffect,
18
+ useState,
19
+ } from 'react';
20
+ import { createRoot } from 'react-dom/client';
7
21
 
8
22
  import type { CellService } from '../../cell/index.js';
23
+ import { ExecutableCellModel } from '../../cell/index.js';
9
24
  import { LibroCellService } from '../../cell/index.js';
10
25
  import type { CellView, DndContentProps } from '../../libro-protocol.js';
11
- import { DragAreaKey, isCellView } from '../../libro-protocol.js';
26
+ import { isCellView } from '../../libro-protocol.js';
12
27
  import type { LibroView } from '../../libro-view.js';
13
28
  import { VirtualizedManagerHelper } from '../../virtualized-manager-helper.js';
14
29
  import { LibroCellsOutputRender } from '../libro-virtualized-render.js';
15
30
 
16
- import type { Dragparams } from './default-dnd-content.js';
17
31
  import './index.less';
18
32
 
33
+ interface IDragContextType {
34
+ dragOverIndex?: number;
35
+ isDraging: boolean;
36
+ sourceIndex?: number;
37
+ onDragStart: (e: React.DragEvent, index: number) => void;
38
+ onDragOver: (e: React.DragEvent, index: number) => void;
39
+ onDrop: (e: React.DragEvent, index: number) => void;
40
+ onDragEnd: (e?: React.DragEvent, index?: number) => void;
41
+ fragFromRef: any;
42
+ }
43
+
44
+ export const DragContext = createContext<IDragContextType>({
45
+ dragOverIndex: undefined,
46
+ isDraging: false,
47
+ sourceIndex: undefined,
48
+ onDragStart: () => {
49
+ return;
50
+ },
51
+ onDragOver: () => {
52
+ return;
53
+ },
54
+ onDrop: () => {
55
+ return;
56
+ },
57
+ onDragEnd: () => {
58
+ return;
59
+ },
60
+ fragFromRef: {},
61
+ });
62
+
63
+ const MultipleImageCompnent = ({ selections }: { selections: CellView[] }) => {
64
+ const firstCell = selections[0];
65
+ const executable = ExecutableCellModel.is(firstCell.model);
66
+ const executeState =
67
+ ExecutableCellModel.is(firstCell.model) && !firstCell.model.executing
68
+ ? firstCell.model.executeCount || ' '
69
+ : '*';
70
+ return (
71
+ <div className="libro-drag-image-container">
72
+ <div className="libro-cell-drag-image-input-container">
73
+ {executable && (
74
+ <pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
75
+ )}
76
+ <pre className="cell-drag-image-input">
77
+ <code>{firstCell.model.value}</code>
78
+ </pre>
79
+ <div className="libro-dnd-cascading-multiple-selection" />
80
+ </div>
81
+ </div>
82
+ );
83
+ };
84
+
85
+ const CellImageComponent = ({ cell }: { cell: CellView }) => {
86
+ const executable = ExecutableCellModel.is(cell.model);
87
+ const executeState =
88
+ ExecutableCellModel.is(cell.model) && !cell.model.executing
89
+ ? cell.model.executeCount || ' '
90
+ : '*';
91
+
92
+ return (
93
+ <div className="libro-single-drag-image-container">
94
+ <div className="libro-cell-drag-image-input-container">
95
+ {executable && (
96
+ <pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
97
+ )}
98
+ <pre className="cell-drag-image-input">
99
+ <code>{cell.model.value}</code>
100
+ </pre>
101
+ </div>
102
+ </div>
103
+ );
104
+ };
105
+
19
106
  export const DndCellRender: FC<DndContentProps> = memo(function DndCellRender({
20
107
  cell,
21
108
  index,
@@ -159,44 +246,236 @@ export const DndList = forwardRef<
159
246
  ref,
160
247
  ) {
161
248
  const cellService = useInject<CellService>(LibroCellService);
249
+ const [isDraging, setIsDraging] = useState<boolean>(false);
250
+ const [dragOverIndex, setDragOverIndex] = useState<number>();
251
+ const [sourceIndex, setSourceIndex] = useState<number>();
252
+ const followNodeRef = useRef<HTMLDivElement>();
253
+ const editorScrollRef = useRef<HTMLDivElement>();
254
+ const multipleImageRef = useRef<HTMLDivElement>();
255
+ const singleImageRef = useRef<HTMLDivElement>();
256
+ const fragFromRef = useRef<string>('');
257
+ useEffect(() => {
258
+ const multipleDrag = document.getElementById('libro-multiple-drag-container');
259
+ if (multipleDrag) {
260
+ multipleImageRef.current = multipleDrag as HTMLDivElement;
261
+ } else {
262
+ multipleImageRef.current = document.createElement('div');
263
+ multipleImageRef.current.id = 'libro-multiple-drag-container';
264
+ document.body.appendChild(multipleImageRef.current);
265
+ }
266
+
267
+ const singleDrag = document.getElementById('libro-single-drag-container');
268
+ if (singleDrag) {
269
+ singleImageRef.current = singleDrag as HTMLDivElement;
270
+ } else {
271
+ singleImageRef.current = document.createElement('div');
272
+ singleImageRef.current.id = 'libro-single-drag-container';
273
+ document.body.appendChild(singleImageRef.current);
274
+ }
275
+ }, []);
162
276
 
163
- const [, drop] = useDrop<Dragparams>(() => ({
164
- accept: DragAreaKey,
165
- drop(item, dropMonitor) {
277
+ const clearSelects = useCallback(() => {
278
+ if (libroView.model.selections.length > 0) {
279
+ libroView.model.selections = [];
280
+ }
281
+ }, [libroView.model]);
282
+
283
+ const exchangeCellIndex = useCallback(
284
+ (sourceCellIndex: number, targetIndex: number) => {
285
+ const sourceCellView = libroView.model.cells[sourceCellIndex];
286
+ if (!sourceCellView) {
287
+ return;
288
+ }
166
289
  cellService
167
290
  .getOrCreateView(
168
291
  {
169
- ...item.cell.model.options,
170
- modelId: item.cell.model.id,
292
+ ...sourceCellView.model.options,
293
+ modelId: sourceCellView.model.id,
171
294
  singleSelectionDragPreview: true,
172
295
  },
173
- item.cell.parent.id,
296
+ sourceCellView.parent.id,
174
297
  )
175
- .then((view) => {
298
+ .then((view: { dispose: () => void }) => {
176
299
  view.dispose();
177
300
  return;
178
301
  })
179
- .catch((e) => {
302
+ .catch(() => {
180
303
  //
181
304
  });
182
- if (isCellView(item.cell)) {
183
- const didDrop = dropMonitor.didDrop();
184
- if (didDrop) {
305
+ if (isCellView(sourceCellView)) {
306
+ const targetCell = libroView.model.cells[targetIndex];
307
+ if (sourceCellIndex < targetIndex) {
308
+ libroView.model.exchangeCell(sourceCellIndex, targetIndex);
309
+ libroView.model.scrollToView(targetCell);
310
+ }
311
+ if (sourceCellIndex > targetIndex) {
312
+ libroView.model.exchangeCell(sourceCellIndex, targetIndex);
313
+ libroView.model.scrollToView(targetCell);
314
+ }
315
+ }
316
+ },
317
+ [cellService, libroView.model],
318
+ );
319
+
320
+ const onDragStart = useCallback(
321
+ async (e: React.DragEvent, sourceCellIndex: number) => {
322
+ e.dataTransfer.setData('libro_notebook_drag_text', `${sourceCellIndex}`);
323
+ fragFromRef.current = 'cell';
324
+ e.dataTransfer.effectAllowed = 'move';
325
+
326
+ const selectCells: CellView[] = libroView.model.selections;
327
+
328
+ const childNode = (e.target as HTMLElement).parentElement?.getElementsByClassName(
329
+ 'libro-cell-input-content',
330
+ )[0] as HTMLDivElement;
331
+
332
+ // 多选cell拖拽排序
333
+ const sourceCellView = libroView.model.cells[sourceCellIndex];
334
+ if (
335
+ selectCells.length > 0 &&
336
+ selectCells.findIndex((selection) => selection.id === sourceCellView.id) > -1 &&
337
+ multipleImageRef.current
338
+ ) {
339
+ const root = createRoot(multipleImageRef.current);
340
+ root.render(<MultipleImageCompnent selections={selectCells} />);
341
+ // 清除编辑器中无效元素宽度(只针对e2编辑器)
342
+ const editorScrollNodex = childNode?.getElementsByClassName(
343
+ 'erd_scroll_detection_container',
344
+ )[0];
345
+ if (editorScrollNodex) {
346
+ editorScrollRef.current = editorScrollNodex as HTMLDivElement;
347
+ (editorScrollNodex as HTMLDivElement).style.display = 'none';
348
+ }
349
+ e.dataTransfer.setDragImage(multipleImageRef.current, 0, 0);
350
+ } else {
351
+ if (!childNode) {
352
+ return;
353
+ }
354
+ // 拖拽单个cell排序
355
+ clearSelects();
356
+ if (childNode.clientHeight > 300) {
357
+ followNodeRef.current = childNode;
358
+ childNode.style.maxHeight = '300px';
359
+ childNode.style.overflow = 'hidden';
360
+ }
361
+
362
+ if (singleImageRef.current) {
363
+ const root = createRoot(singleImageRef.current);
364
+ root.render(<CellImageComponent cell={sourceCellView} />);
365
+ e.dataTransfer.setDragImage(singleImageRef.current, 0, 0);
366
+ }
367
+ }
368
+ setSourceIndex(sourceCellIndex);
369
+ setIsDraging(true);
370
+ },
371
+ [clearSelects, libroView.model.cells, libroView.model.selections],
372
+ );
373
+
374
+ const onDragOver = useCallback((e: React.DragEvent, index: number) => {
375
+ e.preventDefault();
376
+ throttle(() => {
377
+ setDragOverIndex(index);
378
+ }, 1000)();
379
+ }, []);
380
+
381
+ const onDrop = useCallback(
382
+ (e: React.DragEvent, index: number) => {
383
+ e.preventDefault();
384
+ const sourceCellIndex = e.dataTransfer.getData('libro_notebook_drag_text');
385
+ setIsDraging(false);
386
+ setDragOverIndex(undefined);
387
+ setSourceIndex(undefined);
388
+ const _sourceIndex = Number(sourceCellIndex || 0);
389
+ if (libroView.model.selections.length > 0) {
390
+ const sourceCellView = libroView.model.cells[_sourceIndex];
391
+ const dropCellView = libroView.model.cells[index];
392
+ const isDragInSelections = libroView.model.selections.some(
393
+ (selection: { id: string }) => selection.id === sourceCellView.id,
394
+ );
395
+ const isDropInSelections = libroView.model.selections.some(
396
+ (selection: { id: string }) => selection.id === dropCellView.id,
397
+ );
398
+ if (isDragInSelections && isDropInSelections) {
399
+ return;
400
+ }
401
+ if (isDragInSelections) {
402
+ libroView.model.exchangeCells(libroView.model.selections, index);
403
+ libroView.model.scrollToView(dropCellView);
404
+ }
405
+ return;
406
+ }
407
+ if (_sourceIndex === index) {
408
+ return;
409
+ }
410
+ exchangeCellIndex(_sourceIndex, index);
411
+ },
412
+ [exchangeCellIndex, libroView.model],
413
+ );
414
+
415
+ const onDragEnd = useCallback((e?: React.DragEvent) => {
416
+ e?.dataTransfer.clearData();
417
+ setIsDraging(false);
418
+ setDragOverIndex(undefined);
419
+ setSourceIndex(undefined);
420
+ if (followNodeRef.current) {
421
+ followNodeRef.current.style.maxHeight = 'unset';
422
+ followNodeRef.current.style.overflow = 'unset';
423
+ }
424
+ if (editorScrollRef.current) {
425
+ editorScrollRef.current.style.display = 'unset';
426
+ }
427
+
428
+ fragFromRef.current = '';
429
+ }, []);
430
+
431
+ const dragContextValue = useMemo(() => {
432
+ return {
433
+ dragOverIndex,
434
+ isDraging,
435
+ sourceIndex,
436
+ onDragStart,
437
+ onDragOver,
438
+ onDrop,
439
+ onDragEnd,
440
+ fragFromRef,
441
+ };
442
+ }, [
443
+ dragOverIndex,
444
+ isDraging,
445
+ onDragEnd,
446
+ onDragOver,
447
+ onDragStart,
448
+ onDrop,
449
+ sourceIndex,
450
+ fragFromRef,
451
+ ]);
452
+
453
+ return (
454
+ <div
455
+ className="libro-dnd-list-container"
456
+ onDragOver={(e) => {
457
+ e.preventDefault();
458
+ }}
459
+ onDrop={(e) => {
460
+ if (fragFromRef.current !== 'cell') {
185
461
  return;
186
462
  }
187
- // Determine mouse position
188
- const clientOffset = dropMonitor.getClientOffset();
189
- const clientOffsetY = (clientOffset as XYCoord).y;
190
- const dragIndex = libroView.findCellIndex(item.cell);
191
- // Determine rectangle on screen
463
+ const sourceCellIndex = e.dataTransfer.getData('libro_notebook_drag_text');
464
+ const _sourceIndex = Number(sourceCellIndex || 0);
465
+
192
466
  const lastCell =
193
467
  libroView.model.getCells()[libroView.model.getCells().length - 1];
194
468
  const lastCellOffsetY = lastCell.container?.current?.getBoundingClientRect().y;
195
- if (lastCellOffsetY && clientOffsetY >= lastCellOffsetY) {
469
+ if (lastCellOffsetY && e.clientY >= lastCellOffsetY) {
470
+ e.preventDefault();
471
+ if (_sourceIndex === undefined) {
472
+ return;
473
+ }
196
474
  if (libroView.model.selections.length > 0) {
197
475
  const isDragInSelections =
198
476
  libroView.model.selections.findIndex(
199
- (selection) => selection.id === item.cell.id,
477
+ (selection) =>
478
+ selection.id === libroView.model.getCells()[_sourceIndex].id,
200
479
  ) > -1
201
480
  ? true
202
481
  : false;
@@ -208,18 +487,13 @@ export const DndList = forwardRef<
208
487
  return;
209
488
  }
210
489
  }
211
- libroView.model.exchangeCell(dragIndex, libroView.model.cells.length - 1);
490
+ exchangeCellIndex(_sourceIndex, libroView.model.cells.length - 1);
212
491
  }
213
- }
214
- // Determine mouse position
215
-
216
- return;
217
- },
218
- }));
219
-
220
- return (
221
- <div className="libro-dnd-list-container" ref={drop}>
222
- <DndCellsRender libroView={libroView} addCellButtons={children} />
492
+ }}
493
+ >
494
+ <DragContext.Provider value={dragContextValue}>
495
+ <DndCellsRender libroView={libroView} addCellButtons={children} />
496
+ </DragContext.Provider>
223
497
  </div>
224
498
  );
225
499
  });
@@ -10,3 +10,87 @@
10
10
  .libro-dnd-cells-container {
11
11
  padding-top: 8px;
12
12
  }
13
+
14
+ #libro-multiple-drag-container {
15
+ position: absolute;
16
+ top: 0;
17
+ left: 0;
18
+ z-index: -2;
19
+ height: 0;
20
+ }
21
+
22
+ #libro-single-drag-container {
23
+ position: absolute;
24
+ top: 0;
25
+ left: 0;
26
+ z-index: -2;
27
+ }
28
+
29
+ .libro-drag-image-container,
30
+ .libro-single-drag-image-container {
31
+ margin: 8px;
32
+
33
+ .libro-cell-drag-image-input-container {
34
+ position: relative;
35
+ display: flex;
36
+ padding: 12px;
37
+ background-color: var(--mana-libro-background);
38
+ }
39
+
40
+ .cell-drag-image-input {
41
+ z-index: 100;
42
+ max-height: 68px;
43
+ max-width: 300px;
44
+ min-height: 40px;
45
+ min-width: 100px;
46
+ overflow: hidden;
47
+ padding: 8px;
48
+ border: 1px solid var(--mana-libro-cell-border-color);
49
+ border-radius: 4px;
50
+ background: var(--mana-libro-input-background);
51
+ }
52
+
53
+ .libro-execute-state-tip {
54
+ padding-right: 8px;
55
+ color: var(--mana-libro-execution-count-color);
56
+ font-size: 11px;
57
+ vertical-align: top;
58
+ user-select: none;
59
+ }
60
+ }
61
+
62
+ .libro-dnd-cascading-multiple-selection {
63
+ position: absolute;
64
+ bottom: 6px;
65
+ right: 6px;
66
+ width: calc(100% - 60px);
67
+ height: calc(100% - 30px);
68
+ border: 1px solid var(--mana-libro-cell-border-color);
69
+ border-radius: 4px;
70
+ box-shadow:
71
+ 0 6px 16px 0 rgba(0, 0, 0, 8%),
72
+ 0 3px 6px -4px rgba(0, 0, 0, 12%),
73
+ 0 9px 28px 8px rgba(0, 0, 0, 5%);
74
+ }
75
+
76
+ .libro-drag-hoverline {
77
+ position: absolute;
78
+ top: -2px;
79
+ left: 56px;
80
+ z-index: 100;
81
+ width: calc(100% - 70px);
82
+ height: 4px;
83
+ background-color: var(--mana-libro-drag-hover-line-color);
84
+ border-radius: 2px;
85
+ }
86
+
87
+ .libro-drag-hoverline-last-one {
88
+ position: absolute;
89
+ left: 56px;
90
+ bottom: -2px;
91
+ z-index: 100;
92
+ width: calc(100% - 70px);
93
+ height: 4px;
94
+ background-color: var(--mana-libro-drag-hover-line-color);
95
+ border-radius: 2px;
96
+ }
@@ -1,4 +1,2 @@
1
- export * from './custom-drag-layer.js';
2
1
  export * from './default-dnd-content.js';
3
- export * from './dnd-context.js';
4
2
  export * from './dnd-list.js';
@@ -1,4 +1,4 @@
1
- import { prop, singleton } from '@difizen/mana-app';
1
+ import { prop, singleton } from '@difizen/libro-common/app';
2
2
 
3
3
  export interface IVirtualizedManager {
4
4
  openVirtualized: (length: number, size?: number) => Promise<boolean>;
@@ -20,15 +20,18 @@ export class VirtualizedManager implements IVirtualizedManager {
20
20
  * @param size undefined 或者 单位 为B
21
21
  * @returns 是否使用虚拟滚动
22
22
  */
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
24
  openVirtualized = async (length: number, size?: number) => {
25
+ this.isVirtualized = false;
26
+ return false;
24
27
  // this.isVirtualized = true;
25
28
  // return true;
26
- if (length > 100 || (size && size > 4)) {
27
- this.isVirtualized = true;
28
- return true;
29
- } else {
30
- this.isVirtualized = false;
31
- return false;
32
- }
29
+ // if (length > 100 || (size && size > 4)) {
30
+ // this.isVirtualized = true;
31
+ // return true;
32
+ // } else {
33
+ // this.isVirtualized = false;
34
+ // return false;
35
+ // }
33
36
  };
34
37
  }
@@ -1,5 +1,5 @@
1
- import { ViewRender } from '@difizen/mana-app';
2
- import { useInject } from '@difizen/mana-app';
1
+ import { ViewRender } from '@difizen/libro-common/app';
2
+ import { useInject } from '@difizen/libro-common/app';
3
3
  import { useEffect, useState } from 'react';
4
4
 
5
5
  import type { NotebookOption, NotebookView } from '../libro-protocol.js';
@@ -1,11 +1,11 @@
1
- import type { Toolbar } from '@difizen/mana-app';
1
+ import { Menu, MenuContext } from '@difizen/libro-common/react';
2
+ import type { Toolbar } from '@difizen/libro-common/app';
2
3
  import {
3
4
  CommandRegistry,
4
5
  getOrigin,
5
6
  ToolbarInstance,
6
7
  useInject,
7
- } from '@difizen/mana-app';
8
- import { Menu, MenuContext } from '@difizen/mana-react';
8
+ } from '@difizen/libro-common/app';
9
9
  import type { ReactNode } from 'react';
10
10
 
11
11
  import type { LibroToolbarArags } from '../toolbar/index.js';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
- import { ToolbarRender, useInject, ViewInstance } from '@difizen/mana-app';
2
+ import { ToolbarRender, useInject, ViewInstance } from '@difizen/libro-common/app';
3
3
  import type { FC } from 'react';
4
4
  import { useMemo } from 'react';
5
5
 
@@ -1,4 +1,4 @@
1
- import { singleton } from '@difizen/mana-app';
1
+ import { singleton } from '@difizen/libro-common/app';
2
2
 
3
3
  import { ContentContribution } from './libro-content-protocol.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { ManaModule } from '@difizen/mana-app';
1
+ import { ManaModule } from '@difizen/libro-common/app';
2
2
 
3
3
  import { DefaultContentContribution } from './libro-content-contribution.js';
4
4
  import {
@@ -1,5 +1,5 @@
1
1
  import type { INotebookContent } from '@difizen/libro-common';
2
- import { Syringe } from '@difizen/mana-app';
2
+ import { Syringe } from '@difizen/libro-common/app';
3
3
 
4
4
  export const ContentContribution = Syringe.defineToken('ContentContribution');
5
5
  export interface ContentContribution {
@@ -1,5 +1,5 @@
1
- import type { Contribution } from '@difizen/mana-app';
2
- import { contrib, Priority, singleton } from '@difizen/mana-app';
1
+ import type { Contribution } from '@difizen/libro-common/app';
2
+ import { contrib, Priority, singleton } from '@difizen/libro-common/app';
3
3
 
4
4
  import {
5
5
  ContentContribution,
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { singleton } from '@difizen/mana-app';
2
+ import { singleton } from '@difizen/libro-common/app';
3
3
 
4
4
  import { ContentSaveContribution } from './libro-content-protocol.js';
5
5
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
2
  import { concatMultilineString } from '@difizen/libro-common';
3
- import { singleton } from '@difizen/mana-app';
3
+ import { singleton } from '@difizen/libro-common/app';
4
4
 
5
5
  import {
6
6
  DefaultDecodedFormatter,
@@ -1,5 +1,5 @@
1
- import type { Contribution } from '@difizen/mana-app';
2
- import { contrib, Priority, singleton } from '@difizen/mana-app';
1
+ import type { Contribution } from '@difizen/libro-common/app';
2
+ import { contrib, Priority, singleton } from '@difizen/libro-common/app';
3
3
 
4
4
  import { CellModelContribution } from '../cell/index.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { ManaModule } from '@difizen/mana-app';
1
+ import { ManaModule } from '@difizen/libro-common/app';
2
2
 
3
3
  import { FormatterJsonContribution } from './libro-formatter-json-contribution.js';
4
4
  import { LibroFormatterManager } from './libro-formatter-manager.js';
@@ -1,5 +1,5 @@
1
1
  import type { MultilineString } from '@difizen/libro-common';
2
- import { Syringe } from '@difizen/mana-app';
2
+ import { Syringe } from '@difizen/libro-common/app';
3
3
 
4
4
  export const FormatterContribution = Syringe.defineToken('FormatterContribution');
5
5
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
2
  import { concatMultilineString } from '@difizen/libro-common';
3
- import { singleton } from '@difizen/mana-app';
3
+ import { singleton } from '@difizen/libro-common/app';
4
4
 
5
5
  import type { DefaultEncodedFormatter } from './libro-formatter-protocol.js';
6
6
  import {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { singleton } from '@difizen/mana-app';
2
+ import { singleton } from '@difizen/libro-common/app';
3
3
 
4
4
  import type { DefaultDecodedFormatter } from './libro-formatter-protocol.js';
5
5
  import { FormatterTransContribution } from './libro-formatter-protocol.js';
package/src/index.less CHANGED
@@ -315,17 +315,6 @@
315
315
  border: 1px solid var(--mana-color-border);
316
316
  }
317
317
 
318
- .libro-dnd-cascading-multiple-selection {
319
- position: absolute;
320
- top: -10px;
321
- left: -10px;
322
- z-index: 100;
323
- width: 700px;
324
- height: 40px;
325
- background-color: var(--mana-color-bg-container);
326
- border: 1px solid var(--mana-color-border);
327
- }
328
-
329
318
  .libro-cell-container {
330
319
  position: relative;
331
320
  background-color: var(--mana-color-bg-container);
@@ -558,17 +547,6 @@
558
547
  cursor: move;
559
548
  }
560
549
 
561
- .libro-drag-hoverline {
562
- position: absolute;
563
- top: -2px;
564
- left: 56px;
565
- z-index: 100;
566
- width: calc(100% - 70px);
567
- height: 4px;
568
- background-color: var(--mana-libro-drag-hover-line-color);
569
- border-radius: 2px;
570
- }
571
-
572
550
  .libro-view-content-left {
573
551
  position: relative;
574
552
  width: calc(100% - 20px);