ish-ui 1.1.3 → 1.2.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/dist/layout/index.d.ts
CHANGED
package/dist/layout/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Tree from '@atlaskit/tree';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare class PatchTree extends Tree {
|
|
4
|
+
setPlaceholderProps: (placeholderProps: any) => void;
|
|
5
|
+
onDragStartCustom: (event: any) => void;
|
|
6
|
+
onDragUpdateCustom: (event: any) => void;
|
|
7
|
+
render(): React.JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: typeof PatchTree;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2025.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
import Tree from '@atlaskit/tree';
|
|
9
|
+
import isEmpty from 'lodash.isempty';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import * as ReactBeautifulDnD from 'react-beautiful-dnd-next';
|
|
12
|
+
import { withStyles } from 'tss-react/mui';
|
|
13
|
+
const TAG_ITEMS_SPACING = 8;
|
|
14
|
+
const getDraggedDom = draggableId => document.querySelector(`[data-draggable-id='${draggableId}']`);
|
|
15
|
+
const styles = (theme) => ({
|
|
16
|
+
placeholder: {
|
|
17
|
+
border: `2px dashed ${theme.palette.action.focus}`,
|
|
18
|
+
borderRadius: `${theme.shape.borderRadius}px`,
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
boxSizing: 'border-box',
|
|
21
|
+
zIndex: 0
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
class PatchTree extends Tree {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.setPlaceholderProps = placeholderProps => {
|
|
28
|
+
this.setState({
|
|
29
|
+
placeholderProps
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
this.onDragStartCustom = event => {
|
|
33
|
+
const draggedDOM = getDraggedDom(event.draggableId);
|
|
34
|
+
if (!draggedDOM) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const { clientHeight, clientWidth } = draggedDOM;
|
|
38
|
+
const sourceIndex = event.source.index;
|
|
39
|
+
const paddingLeft = parseFloat(window.getComputedStyle(draggedDOM).paddingLeft);
|
|
40
|
+
const prevNode = draggedDOM.parentNode.children[sourceIndex - 1];
|
|
41
|
+
const clientY = prevNode ? prevNode.offsetTop + prevNode.clientHeight + TAG_ITEMS_SPACING : TAG_ITEMS_SPACING;
|
|
42
|
+
this.setPlaceholderProps({
|
|
43
|
+
clientHeight: clientHeight - TAG_ITEMS_SPACING,
|
|
44
|
+
clientWidth: clientWidth - paddingLeft,
|
|
45
|
+
clientY,
|
|
46
|
+
clientX: paddingLeft
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
this.onDragUpdateCustom = event => {
|
|
50
|
+
if (!event.destination) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const draggedDOM = getDraggedDom(event.draggableId);
|
|
54
|
+
if (!draggedDOM) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const destinationIndex = event.destination.index;
|
|
58
|
+
const sourceIndex = event.source.index;
|
|
59
|
+
const childrenArray = [...draggedDOM.parentNode.children];
|
|
60
|
+
const targetDOM = childrenArray[destinationIndex > sourceIndex ? destinationIndex + 1 : destinationIndex];
|
|
61
|
+
const { clientWidth, offsetTop } = targetDOM;
|
|
62
|
+
const clientY = sourceIndex === destinationIndex
|
|
63
|
+
? sourceIndex > 0
|
|
64
|
+
? (childrenArray[sourceIndex - 1].offsetTop + childrenArray[sourceIndex - 1].clientHeight + TAG_ITEMS_SPACING)
|
|
65
|
+
: TAG_ITEMS_SPACING
|
|
66
|
+
: offsetTop + TAG_ITEMS_SPACING;
|
|
67
|
+
let paddingLeft = parseFloat(window.getComputedStyle(targetDOM).paddingLeft);
|
|
68
|
+
if (destinationIndex > 0 && destinationIndex !== sourceIndex) {
|
|
69
|
+
const prevPadding = parseFloat(window.getComputedStyle(childrenArray[destinationIndex - 1]).paddingLeft);
|
|
70
|
+
if (prevPadding > paddingLeft) {
|
|
71
|
+
paddingLeft = prevPadding;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
this.setPlaceholderProps({
|
|
75
|
+
clientHeight: draggedDOM.clientHeight - TAG_ITEMS_SPACING,
|
|
76
|
+
clientWidth: clientWidth - paddingLeft,
|
|
77
|
+
clientY,
|
|
78
|
+
clientX: paddingLeft
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
const { isNestingEnabled, classes } = this.props;
|
|
84
|
+
const { placeholderProps } = this.state;
|
|
85
|
+
const renderedItems = this.renderItems();
|
|
86
|
+
return (React.createElement(ReactBeautifulDnD.DragDropContext, { onDragStart: e => {
|
|
87
|
+
this.onDragStartCustom(e);
|
|
88
|
+
this.onDragStart(e);
|
|
89
|
+
}, onDragEnd: this.onDragEnd, onDragUpdate: e => {
|
|
90
|
+
this.onDragUpdateCustom(e);
|
|
91
|
+
this.onDragUpdate(e);
|
|
92
|
+
} },
|
|
93
|
+
React.createElement(ReactBeautifulDnD.Droppable, { droppableId: "tree", isCombineEnabled: isNestingEnabled, ignoreContainerClipping: true }, (dropProvided, snapshot) => {
|
|
94
|
+
const finalProvided = this.patchDroppableProvided(dropProvided);
|
|
95
|
+
return (React.createElement("div", Object.assign({ ref: finalProvided.innerRef, style: { pointerEvents: 'auto', position: 'relative' }, onTouchMove: this.onPointerMove, onMouseMove: this.onPointerMove }, finalProvided.droppableProps),
|
|
96
|
+
renderedItems,
|
|
97
|
+
dropProvided.placeholder,
|
|
98
|
+
!isEmpty(placeholderProps) && snapshot.isDraggingOver && (React.createElement("div", { className: classes.placeholder, style: {
|
|
99
|
+
top: placeholderProps.clientY,
|
|
100
|
+
left: placeholderProps.clientX,
|
|
101
|
+
height: placeholderProps.clientHeight,
|
|
102
|
+
width: placeholderProps.clientWidth
|
|
103
|
+
} }))));
|
|
104
|
+
})));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export default withStyles(PatchTree, styles);
|
|
@@ -7,12 +7,11 @@ import 'ace-builds/src-noconflict/theme-tomorrow';
|
|
|
7
7
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
8
8
|
import 'ace-builds/src-noconflict/snippets/html';
|
|
9
9
|
import 'ace-builds/src-noconflict/snippets/textile';
|
|
10
|
-
function HtmlEditor(
|
|
11
|
-
const { value, onChange, mode = 'html', height } = props;
|
|
10
|
+
function HtmlEditor({ value, onChange, mode = 'html', height }) {
|
|
12
11
|
return (React.createElement(AceEditor, { mode: mode, theme: "tomorrow", fontSize: 14, height: height, showGutter: false, width: "100%", wrapEnabled: true, highlightActiveLine: true, enableLiveAutocompletion: mode === 'html', enableBasicAutocompletion: mode === 'html', setOptions: {
|
|
13
12
|
enableSnippets: true,
|
|
14
13
|
showLineNumbers: true,
|
|
15
14
|
tabSize: 2,
|
|
16
|
-
}, editorProps: { $blockScrolling: Infinity },
|
|
15
|
+
}, editorProps: { $blockScrolling: Infinity }, value: value, onChange: onChange }));
|
|
17
16
|
}
|
|
18
17
|
export default HtmlEditor;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ish-ui",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"description": "UI elements for onCourse and other ish apps",
|
|
6
6
|
"main": "main.ts",
|
|
7
7
|
"devDependencies": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"webpack-dev-server": "^5.1.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@atlaskit/tree": "^9.0.0",
|
|
43
44
|
"@ckeditor/ckeditor5-autoformat": "43.1.1",
|
|
44
45
|
"@ckeditor/ckeditor5-basic-styles": "43.1.1",
|
|
45
46
|
"@ckeditor/ckeditor5-dev-utils": "^42.1.0",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"date-fns-tz": "^2.0.0",
|
|
73
74
|
"decimal.js-light": "^2.5.1",
|
|
74
75
|
"lodash.debounce": "^4.0.8",
|
|
76
|
+
"lodash.isempty": "^4.4.0",
|
|
75
77
|
"re-resizable": "^6.10.0",
|
|
76
78
|
"react": "^18.3.1",
|
|
77
79
|
"react-ace": "^12.0.0",
|