@difizen/libro-core 0.3.2 → 0.3.4
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.
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -1
- package/es/components/dnd-component/default-dnd-content.js +88 -165
- package/es/components/dnd-component/dnd-list.d.ts +12 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -1
- package/es/components/dnd-component/dnd-list.js +306 -62
- package/es/components/dnd-component/index.d.ts +0 -2
- package/es/components/dnd-component/index.d.ts.map +1 -1
- package/es/components/dnd-component/index.js +0 -2
- package/es/components/dnd-component/index.less +84 -0
- package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -1
- package/es/components/dnd-component/virtualized-manager.js +2 -8
- package/es/formatter/libro-formatter-json-contribution.d.ts +1 -1
- package/es/formatter/libro-formatter-string-contribution.d.ts +1 -1
- package/es/index.less +0 -22
- package/es/libro-model.js +1 -1
- package/es/libro-view.d.ts.map +1 -1
- package/es/libro-view.js +122 -135
- package/es/virtualized-manager.d.ts.map +1 -1
- package/es/virtualized-manager.js +1 -8
- package/package.json +10 -6
- package/src/components/dnd-component/default-dnd-content.tsx +99 -163
- package/src/components/dnd-component/dnd-list.tsx +303 -34
- package/src/components/dnd-component/index.less +84 -0
- package/src/components/dnd-component/index.tsx +0 -2
- package/src/components/dnd-component/virtualized-manager.ts +10 -7
- package/src/index.less +0 -22
- package/src/libro-model.ts +1 -1
- package/src/libro-view.tsx +22 -29
- package/src/virtualized-manager.ts +9 -7
- package/es/components/dnd-component/custom-drag-layer.d.ts +0 -9
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +0 -1
- package/es/components/dnd-component/custom-drag-layer.js +0 -140
- package/es/components/dnd-component/dnd-context.d.ts +0 -3
- package/es/components/dnd-component/dnd-context.d.ts.map +0 -1
- package/es/components/dnd-component/dnd-context.js +0 -20
- package/src/components/dnd-component/custom-drag-layer.tsx +0 -144
- package/src/components/dnd-component/dnd-context.tsx +0 -28
|
@@ -1,21 +1,103 @@
|
|
|
1
1
|
import { getOrigin, useInject, useObserve, ViewInstance } from '@difizen/mana-app';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
+
import { throttle } from 'lodash';
|
|
3
4
|
import type { FC, ReactNode } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
useRef,
|
|
7
|
+
useCallback,
|
|
8
|
+
createContext,
|
|
9
|
+
useMemo,
|
|
10
|
+
forwardRef,
|
|
11
|
+
memo,
|
|
12
|
+
useEffect,
|
|
13
|
+
useState,
|
|
14
|
+
} from 'react';
|
|
15
|
+
import { createRoot } from 'react-dom/client';
|
|
7
16
|
|
|
8
17
|
import type { CellService } from '../../cell/index.js';
|
|
18
|
+
import { ExecutableCellModel } from '../../cell/index.js';
|
|
9
19
|
import { LibroCellService } from '../../cell/index.js';
|
|
10
20
|
import type { CellView, DndContentProps } from '../../libro-protocol.js';
|
|
11
|
-
import {
|
|
21
|
+
import { isCellView } from '../../libro-protocol.js';
|
|
12
22
|
import type { LibroView } from '../../libro-view.js';
|
|
13
23
|
import { VirtualizedManagerHelper } from '../../virtualized-manager-helper.js';
|
|
14
24
|
import { LibroCellsOutputRender } from '../libro-virtualized-render.js';
|
|
15
25
|
|
|
16
|
-
import type { Dragparams } from './default-dnd-content.js';
|
|
17
26
|
import './index.less';
|
|
18
27
|
|
|
28
|
+
interface IDragContextType {
|
|
29
|
+
dragOverIndex?: number;
|
|
30
|
+
isDraging: boolean;
|
|
31
|
+
sourceIndex?: number;
|
|
32
|
+
onDragStart: (e: React.DragEvent, index: number) => void;
|
|
33
|
+
onDragOver: (e: React.DragEvent, index: number) => void;
|
|
34
|
+
onDrop: (e: React.DragEvent, index: number) => void;
|
|
35
|
+
onDragEnd: (e?: React.DragEvent, index?: number) => void;
|
|
36
|
+
fragFromRef: any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const DragContext = createContext<IDragContextType>({
|
|
40
|
+
dragOverIndex: undefined,
|
|
41
|
+
isDraging: false,
|
|
42
|
+
sourceIndex: undefined,
|
|
43
|
+
onDragStart: () => {
|
|
44
|
+
return;
|
|
45
|
+
},
|
|
46
|
+
onDragOver: () => {
|
|
47
|
+
return;
|
|
48
|
+
},
|
|
49
|
+
onDrop: () => {
|
|
50
|
+
return;
|
|
51
|
+
},
|
|
52
|
+
onDragEnd: () => {
|
|
53
|
+
return;
|
|
54
|
+
},
|
|
55
|
+
fragFromRef: {},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const MultipleImageCompnent = ({ selections }: { selections: CellView[] }) => {
|
|
59
|
+
const firstCell = selections[0];
|
|
60
|
+
const executable = ExecutableCellModel.is(firstCell.model);
|
|
61
|
+
const executeState =
|
|
62
|
+
ExecutableCellModel.is(firstCell.model) && !firstCell.model.executing
|
|
63
|
+
? firstCell.model.executeCount || ' '
|
|
64
|
+
: '*';
|
|
65
|
+
return (
|
|
66
|
+
<div className="libro-drag-image-container">
|
|
67
|
+
<div className="libro-cell-drag-image-input-container">
|
|
68
|
+
{executable && (
|
|
69
|
+
<pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
|
|
70
|
+
)}
|
|
71
|
+
<pre className="cell-drag-image-input">
|
|
72
|
+
<code>{firstCell.model.value}</code>
|
|
73
|
+
</pre>
|
|
74
|
+
<div className="libro-dnd-cascading-multiple-selection" />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const CellImageComponent = ({ cell }: { cell: CellView }) => {
|
|
81
|
+
const executable = ExecutableCellModel.is(cell.model);
|
|
82
|
+
const executeState =
|
|
83
|
+
ExecutableCellModel.is(cell.model) && !cell.model.executing
|
|
84
|
+
? cell.model.executeCount || ' '
|
|
85
|
+
: '*';
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="libro-single-drag-image-container">
|
|
89
|
+
<div className="libro-cell-drag-image-input-container">
|
|
90
|
+
{executable && (
|
|
91
|
+
<pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
|
|
92
|
+
)}
|
|
93
|
+
<pre className="cell-drag-image-input">
|
|
94
|
+
<code>{cell.model.value}</code>
|
|
95
|
+
</pre>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
19
101
|
export const DndCellRender: FC<DndContentProps> = memo(function DndCellRender({
|
|
20
102
|
cell,
|
|
21
103
|
index,
|
|
@@ -159,44 +241,236 @@ export const DndList = forwardRef<
|
|
|
159
241
|
ref,
|
|
160
242
|
) {
|
|
161
243
|
const cellService = useInject<CellService>(LibroCellService);
|
|
244
|
+
const [isDraging, setIsDraging] = useState<boolean>(false);
|
|
245
|
+
const [dragOverIndex, setDragOverIndex] = useState<number>();
|
|
246
|
+
const [sourceIndex, setSourceIndex] = useState<number>();
|
|
247
|
+
const followNodeRef = useRef<HTMLDivElement>();
|
|
248
|
+
const editorScrollRef = useRef<HTMLDivElement>();
|
|
249
|
+
const multipleImageRef = useRef<HTMLDivElement>();
|
|
250
|
+
const singleImageRef = useRef<HTMLDivElement>();
|
|
251
|
+
const fragFromRef = useRef<string>('');
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
const multipleDrag = document.getElementById('libro-multiple-drag-container');
|
|
254
|
+
if (multipleDrag) {
|
|
255
|
+
multipleImageRef.current = multipleDrag as HTMLDivElement;
|
|
256
|
+
} else {
|
|
257
|
+
multipleImageRef.current = document.createElement('div');
|
|
258
|
+
multipleImageRef.current.id = 'libro-multiple-drag-container';
|
|
259
|
+
document.body.appendChild(multipleImageRef.current);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const singleDrag = document.getElementById('libro-single-drag-container');
|
|
263
|
+
if (singleDrag) {
|
|
264
|
+
singleImageRef.current = singleDrag as HTMLDivElement;
|
|
265
|
+
} else {
|
|
266
|
+
singleImageRef.current = document.createElement('div');
|
|
267
|
+
singleImageRef.current.id = 'libro-single-drag-container';
|
|
268
|
+
document.body.appendChild(singleImageRef.current);
|
|
269
|
+
}
|
|
270
|
+
}, []);
|
|
162
271
|
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
272
|
+
const clearSelects = useCallback(() => {
|
|
273
|
+
if (libroView.model.selections.length > 0) {
|
|
274
|
+
libroView.model.selections = [];
|
|
275
|
+
}
|
|
276
|
+
}, [libroView.model]);
|
|
277
|
+
|
|
278
|
+
const exchangeCellIndex = useCallback(
|
|
279
|
+
(sourceCellIndex: number, targetIndex: number) => {
|
|
280
|
+
const sourceCellView = libroView.model.cells[sourceCellIndex];
|
|
281
|
+
if (!sourceCellView) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
166
284
|
cellService
|
|
167
285
|
.getOrCreateView(
|
|
168
286
|
{
|
|
169
|
-
...
|
|
170
|
-
modelId:
|
|
287
|
+
...sourceCellView.model.options,
|
|
288
|
+
modelId: sourceCellView.model.id,
|
|
171
289
|
singleSelectionDragPreview: true,
|
|
172
290
|
},
|
|
173
|
-
|
|
291
|
+
sourceCellView.parent.id,
|
|
174
292
|
)
|
|
175
|
-
.then((view) => {
|
|
293
|
+
.then((view: { dispose: () => void }) => {
|
|
176
294
|
view.dispose();
|
|
177
295
|
return;
|
|
178
296
|
})
|
|
179
|
-
.catch((
|
|
297
|
+
.catch(() => {
|
|
180
298
|
//
|
|
181
299
|
});
|
|
182
|
-
if (isCellView(
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
300
|
+
if (isCellView(sourceCellView)) {
|
|
301
|
+
const targetCell = libroView.model.cells[targetIndex];
|
|
302
|
+
if (sourceCellIndex < targetIndex) {
|
|
303
|
+
libroView.model.exchangeCell(sourceCellIndex, targetIndex);
|
|
304
|
+
libroView.model.scrollToView(targetCell);
|
|
305
|
+
}
|
|
306
|
+
if (sourceCellIndex > targetIndex) {
|
|
307
|
+
libroView.model.exchangeCell(sourceCellIndex, targetIndex);
|
|
308
|
+
libroView.model.scrollToView(targetCell);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
[cellService, libroView.model],
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
const onDragStart = useCallback(
|
|
316
|
+
async (e: React.DragEvent, sourceCellIndex: number) => {
|
|
317
|
+
e.dataTransfer.setData('libro_notebook_drag_text', `${sourceCellIndex}`);
|
|
318
|
+
fragFromRef.current = 'cell';
|
|
319
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
320
|
+
|
|
321
|
+
const selectCells: CellView[] = libroView.model.selections;
|
|
322
|
+
|
|
323
|
+
const childNode = (e.target as HTMLElement).parentElement?.getElementsByClassName(
|
|
324
|
+
'libro-cell-input-content',
|
|
325
|
+
)[0] as HTMLDivElement;
|
|
326
|
+
|
|
327
|
+
// 多选cell拖拽排序
|
|
328
|
+
const sourceCellView = libroView.model.cells[sourceCellIndex];
|
|
329
|
+
if (
|
|
330
|
+
selectCells.length > 0 &&
|
|
331
|
+
selectCells.findIndex((selection) => selection.id === sourceCellView.id) > -1 &&
|
|
332
|
+
multipleImageRef.current
|
|
333
|
+
) {
|
|
334
|
+
const root = createRoot(multipleImageRef.current);
|
|
335
|
+
root.render(<MultipleImageCompnent selections={selectCells} />);
|
|
336
|
+
// 清除编辑器中无效元素宽度(只针对e2编辑器)
|
|
337
|
+
const editorScrollNodex = childNode?.getElementsByClassName(
|
|
338
|
+
'erd_scroll_detection_container',
|
|
339
|
+
)[0];
|
|
340
|
+
if (editorScrollNodex) {
|
|
341
|
+
editorScrollRef.current = editorScrollNodex as HTMLDivElement;
|
|
342
|
+
(editorScrollNodex as HTMLDivElement).style.display = 'none';
|
|
343
|
+
}
|
|
344
|
+
e.dataTransfer.setDragImage(multipleImageRef.current, 0, 0);
|
|
345
|
+
} else {
|
|
346
|
+
if (!childNode) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
// 拖拽单个cell排序
|
|
350
|
+
clearSelects();
|
|
351
|
+
if (childNode.clientHeight > 300) {
|
|
352
|
+
followNodeRef.current = childNode;
|
|
353
|
+
childNode.style.maxHeight = '300px';
|
|
354
|
+
childNode.style.overflow = 'hidden';
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (singleImageRef.current) {
|
|
358
|
+
const root = createRoot(singleImageRef.current);
|
|
359
|
+
root.render(<CellImageComponent cell={sourceCellView} />);
|
|
360
|
+
e.dataTransfer.setDragImage(singleImageRef.current, 0, 0);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
setSourceIndex(sourceCellIndex);
|
|
364
|
+
setIsDraging(true);
|
|
365
|
+
},
|
|
366
|
+
[clearSelects, libroView.model.cells, libroView.model.selections],
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
const onDragOver = useCallback((e: React.DragEvent, index: number) => {
|
|
370
|
+
e.preventDefault();
|
|
371
|
+
throttle(() => {
|
|
372
|
+
setDragOverIndex(index);
|
|
373
|
+
}, 1000)();
|
|
374
|
+
}, []);
|
|
375
|
+
|
|
376
|
+
const onDrop = useCallback(
|
|
377
|
+
(e: React.DragEvent, index: number) => {
|
|
378
|
+
e.preventDefault();
|
|
379
|
+
const sourceCellIndex = e.dataTransfer.getData('libro_notebook_drag_text');
|
|
380
|
+
setIsDraging(false);
|
|
381
|
+
setDragOverIndex(undefined);
|
|
382
|
+
setSourceIndex(undefined);
|
|
383
|
+
const _sourceIndex = Number(sourceCellIndex || 0);
|
|
384
|
+
if (libroView.model.selections.length > 0) {
|
|
385
|
+
const sourceCellView = libroView.model.cells[_sourceIndex];
|
|
386
|
+
const dropCellView = libroView.model.cells[index];
|
|
387
|
+
const isDragInSelections = libroView.model.selections.some(
|
|
388
|
+
(selection: { id: string }) => selection.id === sourceCellView.id,
|
|
389
|
+
);
|
|
390
|
+
const isDropInSelections = libroView.model.selections.some(
|
|
391
|
+
(selection: { id: string }) => selection.id === dropCellView.id,
|
|
392
|
+
);
|
|
393
|
+
if (isDragInSelections && isDropInSelections) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (isDragInSelections) {
|
|
397
|
+
libroView.model.exchangeCells(libroView.model.selections, index);
|
|
398
|
+
libroView.model.scrollToView(dropCellView);
|
|
399
|
+
}
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (_sourceIndex === index) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
exchangeCellIndex(_sourceIndex, index);
|
|
406
|
+
},
|
|
407
|
+
[exchangeCellIndex, libroView.model],
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
const onDragEnd = useCallback((e?: React.DragEvent) => {
|
|
411
|
+
e?.dataTransfer.clearData();
|
|
412
|
+
setIsDraging(false);
|
|
413
|
+
setDragOverIndex(undefined);
|
|
414
|
+
setSourceIndex(undefined);
|
|
415
|
+
if (followNodeRef.current) {
|
|
416
|
+
followNodeRef.current.style.maxHeight = 'unset';
|
|
417
|
+
followNodeRef.current.style.overflow = 'unset';
|
|
418
|
+
}
|
|
419
|
+
if (editorScrollRef.current) {
|
|
420
|
+
editorScrollRef.current.style.display = 'unset';
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
fragFromRef.current = '';
|
|
424
|
+
}, []);
|
|
425
|
+
|
|
426
|
+
const dragContextValue = useMemo(() => {
|
|
427
|
+
return {
|
|
428
|
+
dragOverIndex,
|
|
429
|
+
isDraging,
|
|
430
|
+
sourceIndex,
|
|
431
|
+
onDragStart,
|
|
432
|
+
onDragOver,
|
|
433
|
+
onDrop,
|
|
434
|
+
onDragEnd,
|
|
435
|
+
fragFromRef,
|
|
436
|
+
};
|
|
437
|
+
}, [
|
|
438
|
+
dragOverIndex,
|
|
439
|
+
isDraging,
|
|
440
|
+
onDragEnd,
|
|
441
|
+
onDragOver,
|
|
442
|
+
onDragStart,
|
|
443
|
+
onDrop,
|
|
444
|
+
sourceIndex,
|
|
445
|
+
fragFromRef,
|
|
446
|
+
]);
|
|
447
|
+
|
|
448
|
+
return (
|
|
449
|
+
<div
|
|
450
|
+
className="libro-dnd-list-container"
|
|
451
|
+
onDragOver={(e) => {
|
|
452
|
+
e.preventDefault();
|
|
453
|
+
}}
|
|
454
|
+
onDrop={(e) => {
|
|
455
|
+
if (fragFromRef.current !== 'cell') {
|
|
185
456
|
return;
|
|
186
457
|
}
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const dragIndex = libroView.findCellIndex(item.cell);
|
|
191
|
-
// Determine rectangle on screen
|
|
458
|
+
const sourceCellIndex = e.dataTransfer.getData('libro_notebook_drag_text');
|
|
459
|
+
const _sourceIndex = Number(sourceCellIndex || 0);
|
|
460
|
+
|
|
192
461
|
const lastCell =
|
|
193
462
|
libroView.model.getCells()[libroView.model.getCells().length - 1];
|
|
194
463
|
const lastCellOffsetY = lastCell.container?.current?.getBoundingClientRect().y;
|
|
195
|
-
if (lastCellOffsetY &&
|
|
464
|
+
if (lastCellOffsetY && e.clientY >= lastCellOffsetY) {
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
if (_sourceIndex === undefined) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
196
469
|
if (libroView.model.selections.length > 0) {
|
|
197
470
|
const isDragInSelections =
|
|
198
471
|
libroView.model.selections.findIndex(
|
|
199
|
-
(selection) =>
|
|
472
|
+
(selection) =>
|
|
473
|
+
selection.id === libroView.model.getCells()[_sourceIndex].id,
|
|
200
474
|
) > -1
|
|
201
475
|
? true
|
|
202
476
|
: false;
|
|
@@ -208,18 +482,13 @@ export const DndList = forwardRef<
|
|
|
208
482
|
return;
|
|
209
483
|
}
|
|
210
484
|
}
|
|
211
|
-
|
|
485
|
+
exchangeCellIndex(_sourceIndex, libroView.model.cells.length - 1);
|
|
212
486
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}));
|
|
219
|
-
|
|
220
|
-
return (
|
|
221
|
-
<div className="libro-dnd-list-container" ref={drop}>
|
|
222
|
-
<DndCellsRender libroView={libroView} addCellButtons={children} />
|
|
487
|
+
}}
|
|
488
|
+
>
|
|
489
|
+
<DragContext.Provider value={dragContextValue}>
|
|
490
|
+
<DndCellsRender libroView={libroView} addCellButtons={children} />
|
|
491
|
+
</DragContext.Provider>
|
|
223
492
|
</div>
|
|
224
493
|
);
|
|
225
494
|
});
|
|
@@ -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
|
+
}
|
|
@@ -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
|
-
|
|
28
|
-
|
|
29
|
-
} else {
|
|
30
|
-
|
|
31
|
-
|
|
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
|
}
|
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);
|
package/src/libro-model.ts
CHANGED
|
@@ -640,7 +640,7 @@ export class LibroModel implements NotebookModel, DndListModel {
|
|
|
640
640
|
//往上交换cell
|
|
641
641
|
if (startIndex === this.activeIndex) {
|
|
642
642
|
//active在头
|
|
643
|
-
this.activeIndex = targetIndex
|
|
643
|
+
this.activeIndex = targetIndex;
|
|
644
644
|
} else {
|
|
645
645
|
//active在尾
|
|
646
646
|
this.activeIndex = targetIndex + 1;
|
package/src/libro-view.tsx
CHANGED
|
@@ -41,13 +41,7 @@ import type { LibroCell } from './cell/index.js';
|
|
|
41
41
|
import type { LibroCellModel } from './cell/libro-cell-model.js';
|
|
42
42
|
import { CollapseServiceFactory } from './collapse-service.js';
|
|
43
43
|
import type { CollapseService } from './collapse-service.js';
|
|
44
|
-
import {
|
|
45
|
-
CustomDragLayer,
|
|
46
|
-
DndCellContainer,
|
|
47
|
-
DndCellItemRender,
|
|
48
|
-
DndContext,
|
|
49
|
-
DndList,
|
|
50
|
-
} from './components/index.js';
|
|
44
|
+
import { DndCellContainer, DndCellItemRender, DndList } from './components/index.js';
|
|
51
45
|
import { LibroViewHeader } from './components/libro-view-header.js';
|
|
52
46
|
import { LibroContextKey } from './libro-context-key.js';
|
|
53
47
|
import { LibroModel } from './libro-model.js';
|
|
@@ -81,7 +75,6 @@ export interface ClipboardType {
|
|
|
81
75
|
|
|
82
76
|
export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
83
77
|
const libroSlotManager = useInject(LibroSlotManager);
|
|
84
|
-
const ref = useRef<HTMLDivElement | null>(null);
|
|
85
78
|
const libroViewTopRef = useRef<HTMLDivElement>(null);
|
|
86
79
|
const libroViewRightContentRef = useRef<HTMLDivElement>(null);
|
|
87
80
|
const libroViewLeftContentRef = useRef<HTMLDivElement>(null);
|
|
@@ -173,15 +166,12 @@ export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
|
173
166
|
style={leftContentStyles}
|
|
174
167
|
ref={libroViewLeftContentRef}
|
|
175
168
|
>
|
|
176
|
-
<
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
/>
|
|
183
|
-
</DndList>
|
|
184
|
-
</DndContext>
|
|
169
|
+
<DndList libroView={instance}>
|
|
170
|
+
<Slot
|
|
171
|
+
name={libroSlotManager.getSlotName(instance, 'list')}
|
|
172
|
+
slotView={LibroSlotView}
|
|
173
|
+
/>
|
|
174
|
+
</DndList>
|
|
185
175
|
</div>
|
|
186
176
|
<div
|
|
187
177
|
className="libro-view-content-right"
|
|
@@ -742,13 +732,15 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
742
732
|
this.collapseCell(previousCell, false);
|
|
743
733
|
}
|
|
744
734
|
if (this.model.selections.length !== 0 && this.isSelected(cell)) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
735
|
+
const startIndex = this.findCellIndex(this.model.selections[0]);
|
|
736
|
+
const endIndex = this.findCellIndex(
|
|
737
|
+
this.model.selections[this.model.selections.length - 1],
|
|
738
|
+
);
|
|
739
|
+
const index = Math.min(startIndex, endIndex);
|
|
740
|
+
if (startIndex === 0) {
|
|
741
|
+
return;
|
|
751
742
|
}
|
|
743
|
+
this.model.exchangeCells(this.model.selections, index - 1);
|
|
752
744
|
} else {
|
|
753
745
|
const sourceIndex = this.findCellIndex(cell);
|
|
754
746
|
if (sourceIndex > -1) {
|
|
@@ -764,13 +756,14 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
764
756
|
this.collapseCell(nextCell, false);
|
|
765
757
|
}
|
|
766
758
|
if (this.model.selections.length !== 0 && this.isSelected(cell)) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
759
|
+
const startIndex = this.findCellIndex(this.model.selections[0]) + 1;
|
|
760
|
+
const endIndex =
|
|
761
|
+
this.findCellIndex(this.model.selections[this.model.selections.length - 1]) + 1;
|
|
762
|
+
const index = Math.max(startIndex, endIndex);
|
|
763
|
+
if (index === this.model.cells.length) {
|
|
764
|
+
return;
|
|
773
765
|
}
|
|
766
|
+
this.model.exchangeCells(this.model.selections, index + 1);
|
|
774
767
|
} else {
|
|
775
768
|
const sourceIndex = this.findCellIndex(cell);
|
|
776
769
|
if (sourceIndex > -1) {
|
|
@@ -34,14 +34,16 @@ export class VirtualizedManager implements IVirtualizedManager {
|
|
|
34
34
|
*/
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
36
|
openVirtualized = async (length: number, size?: number, path?: string) => {
|
|
37
|
+
this.isVirtualized = false;
|
|
38
|
+
return false;
|
|
37
39
|
// this.isVirtualized = true;
|
|
38
40
|
// return true;
|
|
39
|
-
if (length > 100 || (size && size > 4)) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} else {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
41
|
+
// if (length > 100 || (size && size > 4)) {
|
|
42
|
+
// this.isVirtualized = true;
|
|
43
|
+
// return true;
|
|
44
|
+
// } else {
|
|
45
|
+
// this.isVirtualized = false;
|
|
46
|
+
// return false;
|
|
47
|
+
// }
|
|
46
48
|
};
|
|
47
49
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import type { CellView } from '../../libro-protocol.js';
|
|
3
|
-
export interface SelectionPreviewProps {
|
|
4
|
-
activeCell: CellView;
|
|
5
|
-
}
|
|
6
|
-
export declare const MultipleSelectionPreviewMemo: FC<SelectionPreviewProps>;
|
|
7
|
-
export declare const SingleSelectionPreviewMemo: FC<SelectionPreviewProps>;
|
|
8
|
-
export declare const CustomDragLayer: () => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
-
//# sourceMappingURL=custom-drag-layer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-drag-layer.d.ts","sourceRoot":"","sources":["../../../src/components/dnd-component/custom-drag-layer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAiB,MAAM,OAAO,CAAC;AAO/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,QAAQ,CAAC;CACtB;AAoDD,eAAO,MAAM,4BAA4B,EAAE,EAAE,CAAC,qBAAqB,CAElE,CAAC;AA+BF,eAAO,MAAM,0BAA0B,EAAE,EAAE,CAAC,qBAAqB,CAEhE,CAAC;AAEF,eAAO,MAAM,eAAe,sDAuC3B,CAAC"}
|