1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import { action, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { emptyFunction, setupMoveUpEvents } from '../../../Utils';
import { UndoManager } from '../../util/UndoManager';
import { ObservableReactComponent } from '../ObservableReactComponent';
interface DividerProps {
index: number;
xMargin: number;
setColumnStartXCoords: (movementX: number, colIndex: number) => void;
isContentActive: () => boolean | undefined;
}
/**
* CollectionNoteTakingViewDivider are dividers between CollectionNoteTakingViewColumns,
* which only appear when there is more than 1 column in CollectionNoteTakingView. Dividers
* are two simple vertical lines that allow the user to alter the widths of CollectionNoteTakingViewColumns.
*/
@observer
export class CollectionNoteTakingViewDivider extends ObservableReactComponent<DividerProps> {
@observable private isResizingActive = false;
@action
private registerResizing = (e: React.PointerEvent<HTMLDivElement>) => {
let batch: UndoManager.Batch | undefined;
setupMoveUpEvents(
this,
e,
(e, down, delta) => {
if (!batch) batch = UndoManager.StartBatch('resizing');
this._props.setColumnStartXCoords(delta[0], this._props.index);
return false;
},
action(() => {
this.isResizingActive = false;
batch?.end();
}),
emptyFunction
);
this.isResizingActive = true;
};
render() {
return (
<div
className="columnResizer"
style={{
display: 'flex',
alignItems: 'center',
cursor: 'col-resize',
pointerEvents: this._props.isContentActive() ? 'all' : 'none',
}}>
<div
className="columnResizer-handler"
onPointerDown={e => this.registerResizing(e)}
style={{
height: '95%',
width: 12,
borderRight: '4px solid #282828',
borderLeft: '4px solid #282828',
position: 'fixed',
pointerEvents: 'none',
}}
/>
<div
className="columnResizer-handler"
onPointerDown={e => this.registerResizing(e)}
style={{
height: '95%',
width: 12,
borderRight: '4px solid #282828',
borderLeft: '4px solid #282828',
}}
/>
</div>
);
}
}
|