argous 1.2.218 → 1.2.220
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/components/ArgousComplexTable/ArgousComplexTable.js +8 -10
- package/dist/components/ArgousComplexTableHead/ArgousComplexTableHead.js +6 -6
- package/dist/components/Carousel/Carousel.js +2 -2
- package/dist/components/Editor/skins/content/dark/content.min.css +1 -0
- package/dist/components/Editor/skins/content/default/content.min.css +1 -0
- package/dist/components/Editor/skins/content/document/content.min.css +1 -0
- package/dist/components/Editor/skins/content/tinymce-5/content.min.css +1 -0
- package/dist/components/Editor/skins/content/tinymce-5-dark/content.min.css +1 -0
- package/dist/components/Editor/skins/content/writer/content.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide/content.inline.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide/content.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide/skin.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide/skin.shadowdom.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide-dark/content.inline.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide-dark/content.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide-dark/skin.min.css +1 -0
- package/dist/components/Editor/skins/ui/oxide-dark/skin.shadowdom.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5/content.inline.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5/content.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5/skin.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5/skin.shadowdom.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5-dark/content.inline.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5-dark/content.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5-dark/skin.min.css +1 -0
- package/dist/components/Editor/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +1 -0
- package/dist/components/Editor/tinymce/icons/default/icons.js +194 -0
- package/dist/components/Editor/tinymce/icons/default/icons.min.js +1 -0
- package/dist/components/Editor/tinymce/skins/content/dark/content.css +66 -0
- package/dist/components/Editor/tinymce/skins/content/dark/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/content/default/content.css +61 -0
- package/dist/components/Editor/tinymce/skins/content/default/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/content/document/content.css +66 -0
- package/dist/components/Editor/tinymce/skins/content/document/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/content/tinymce-5/content.css +61 -0
- package/dist/components/Editor/tinymce/skins/content/tinymce-5/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/content/tinymce-5-dark/content.css +66 -0
- package/dist/components/Editor/tinymce/skins/content/tinymce-5-dark/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/content/writer/content.css +62 -0
- package/dist/components/Editor/tinymce/skins/content/writer/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/content.css +785 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/content.inline.css +779 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/content.inline.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/skin.css +3763 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/skin.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/skin.shadowdom.css +30 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide/skin.shadowdom.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/content.css +766 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/content.inline.css +779 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/content.inline.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/skin.css +3766 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/skin.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +30 -0
- package/dist/components/Editor/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/content.css +785 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/content.inline.css +779 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/content.inline.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/skin.css +3857 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/skin.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/skin.shadowdom.css +30 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/content.css +766 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/content.inline.css +779 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/content.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/skin.css +3857 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/skin.min.css +2 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.css +30 -0
- package/dist/components/Editor/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +2 -0
- package/dist/components/TextToHtml/TextToHtml.js +5 -16
- package/dist/components/TextToHtml/icons/resize_area.svg +2 -0
- package/dist/components/TextToHtml/style.css +40 -0
- package/dist/components/Zoom/style.css +25 -0
- package/dist/components/index.d.ts +10 -1
- package/dist/components/index.js +11 -1
- package/lib/components/ArgousComplexTable/ArgousComplexTable.js +6 -11
- package/lib/components/ArgousComplexTableHead/ArgousComplexTableHead.js +7 -7
- package/lib/components/Carousel/Carousel.d.ts +71 -0
- package/lib/components/Carousel/Carousel.js +218 -0
- package/lib/components/Carousel/index.d.ts +2 -0
- package/lib/components/Carousel/index.js +1 -0
- package/lib/components/TextToHtml/Cursor.js +24 -0
- package/lib/components/TextToHtml/TextStyles.js +111 -0
- package/lib/components/TextToHtml/TextToHtml.d.ts +38 -0
- package/lib/components/TextToHtml/TextToHtml.js +450 -0
- package/lib/components/TextToHtml/icons/resize_area.svg +2 -0
- package/lib/components/TextToHtml/index.d.ts +2 -0
- package/lib/components/TextToHtml/index.js +1 -0
- package/lib/components/TextToHtml/style.css +40 -0
- package/lib/components/TextToHtml/utils.js +848 -0
- package/lib/components/Zoom/Zoom.d.ts +11 -0
- package/lib/components/Zoom/Zoom.js +56 -0
- package/lib/components/Zoom/index.d.ts +2 -0
- package/lib/components/Zoom/index.js +1 -0
- package/lib/components/Zoom/style.css +25 -0
- package/lib/components/index.d.ts +10 -1
- package/lib/components/index.js +11 -1
- package/package.json +2 -1
- package/dist/components/CodeReader/CodeReader.d.ts +0 -29
- package/dist/components/CodeReader/CodeReader.js +0 -487
- package/dist/components/CodeReader/index.d.ts +0 -1
- package/dist/components/CodeReader/index.js +0 -8
- package/dist/components/Editor/ScriptLoader.d.ts +0 -20
- package/dist/components/Editor/ScriptLoader.js +0 -70
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { makeStyles } from '@material-ui/core';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { IoIosArrowBack, IoIosArrowForward } from 'react-icons/io';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles(theme => ({
|
|
8
|
+
container: {
|
|
9
|
+
height: '100%',
|
|
10
|
+
width: '100%'
|
|
11
|
+
},
|
|
12
|
+
carouselContainer: {
|
|
13
|
+
width: '100%',
|
|
14
|
+
height: ({ indicator, indicatorPadding }) => (indicator) ? `calc(100% - ${indicatorPadding * 2}px)` : '100%',
|
|
15
|
+
minWidth: '100%',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center'
|
|
18
|
+
},
|
|
19
|
+
carousel: {
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
margin: 'auto',
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
scrollBehavior: 'smooth',
|
|
28
|
+
'&>*:not(:last-child)': {
|
|
29
|
+
marginRight: ({ itemSpacing }) => (itemSpacing || '')
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
button: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
border: 0,
|
|
37
|
+
padding: 0,
|
|
38
|
+
backgroundColor: '#0000',
|
|
39
|
+
color: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .4)' : 'rgba(255, 255, 255, .5)',
|
|
40
|
+
'&:hover': {
|
|
41
|
+
color: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .6)' : 'rgba(255, 255, 255, .8)'
|
|
42
|
+
},
|
|
43
|
+
'&:disabled': {
|
|
44
|
+
color: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .23)' : 'rgba(255, 255, 255, .3)',
|
|
45
|
+
backgroundColor: 'transparent',
|
|
46
|
+
cursor: 'default',
|
|
47
|
+
pointerEvents: 'none'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
leftButton: {
|
|
51
|
+
left: 0
|
|
52
|
+
},
|
|
53
|
+
rightButton: {
|
|
54
|
+
right: 0
|
|
55
|
+
},
|
|
56
|
+
indicator: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
flexWrap: 'wrap',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
gap: ({ indicatorGap }) => (indicatorGap || ''),
|
|
62
|
+
padding: ({ indicatorPadding, indicatorSize, iconSize }) => `${indicatorPadding - (indicatorSize / 2)}px ${iconSize}px`,
|
|
63
|
+
'& span': {
|
|
64
|
+
width: ({ indicatorSize }) => (indicatorSize || ''),
|
|
65
|
+
height: ({ indicatorSize }) => (indicatorSize || ''),
|
|
66
|
+
borderRadius: '50%',
|
|
67
|
+
backgroundColor: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .4)' : 'rgba(255, 255, 255, .5)',
|
|
68
|
+
transition: 'background-color 500ms'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
currentIndicator: {
|
|
72
|
+
backgroundColor: (theme.palette.type === 'light') ? '#000 !important' : '#fff !important'
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const CAROUSEL_ID = 'carousel';
|
|
78
|
+
|
|
79
|
+
const initialState = {
|
|
80
|
+
position: 0,
|
|
81
|
+
indicatorArray: []
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const Carousel = ({
|
|
86
|
+
id,
|
|
87
|
+
leftIcon: LEFT_ICON = IoIosArrowBack,
|
|
88
|
+
rightIcon: RIGHT_ICON = IoIosArrowForward,
|
|
89
|
+
iconSize = 20,
|
|
90
|
+
scrollSensitivity = 2,
|
|
91
|
+
itemSpacing = '.5rem',
|
|
92
|
+
children,
|
|
93
|
+
buttons = true,
|
|
94
|
+
indicator,
|
|
95
|
+
indicatorSize = 6,
|
|
96
|
+
indicatorGap = 10,
|
|
97
|
+
indicatorPadding = 20,
|
|
98
|
+
carouselStyle,
|
|
99
|
+
onClick,
|
|
100
|
+
buttonClassName,
|
|
101
|
+
indicatorClassName,
|
|
102
|
+
currentIndicatorClassName
|
|
103
|
+
}) => {
|
|
104
|
+
|
|
105
|
+
const classes = useStyles({ itemSpacing, indicator, indicatorSize, indicatorGap, indicatorPadding, iconSize });
|
|
106
|
+
const [state, setState] = useState(initialState);
|
|
107
|
+
const { position, indicatorArray } = state;
|
|
108
|
+
const carousel = useRef(null);
|
|
109
|
+
const childWidth = carousel.current?.children?.[0]?.offsetWidth;
|
|
110
|
+
const disabledButtonsRef = useRef(false);
|
|
111
|
+
const carouselId = (id) ? id : CAROUSEL_ID;
|
|
112
|
+
const leftButtonId = `${carouselId}-left-button`;
|
|
113
|
+
const rightButtonId = `${carouselId}-right-button`;
|
|
114
|
+
|
|
115
|
+
const logicSetState = ({ type, field, value }) => setState(states => ({
|
|
116
|
+
...states,
|
|
117
|
+
[type]: (type && field) ? { ...states[type], [field]: value } : value
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const control = useCallback(e => {
|
|
122
|
+
if (disabledButtonsRef.current) return;
|
|
123
|
+
|
|
124
|
+
const childWidth = carousel.current?.children?.[0]?.offsetWidth;
|
|
125
|
+
const maxWidth = (childWidth * (carousel.current?.children?.length - 1));
|
|
126
|
+
const scrollLeft = carousel.current?.scrollLeft;
|
|
127
|
+
const leftButtonElement = document.getElementById(leftButtonId);
|
|
128
|
+
const rightButtonElement = document.getElementById(rightButtonId);
|
|
129
|
+
const childrenWidth = ((childWidth + itemSpacing) * carousel.current?.children?.length);
|
|
130
|
+
const childrenSmallerThanParent = (childrenWidth < carousel.current?.offsetWidth);
|
|
131
|
+
|
|
132
|
+
if (leftButtonElement) {
|
|
133
|
+
if ((scrollLeft === 0) || childrenSmallerThanParent) leftButtonElement.disabled = true;
|
|
134
|
+
else if (scrollLeft > 0) leftButtonElement.disabled = false;
|
|
135
|
+
}
|
|
136
|
+
if (rightButtonElement) {
|
|
137
|
+
if ((scrollLeft === maxWidth) || childrenSmallerThanParent) rightButtonElement.disabled = true;
|
|
138
|
+
else if (scrollLeft < maxWidth) rightButtonElement.disabled = false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
(position === children.length) && logicSetState({ type: 'position', value: (children.length - 1) });
|
|
142
|
+
}, [itemSpacing, leftButtonId, rightButtonId, position, children.length]);
|
|
143
|
+
useEffect(() => control(), [control]);
|
|
144
|
+
control();
|
|
145
|
+
|
|
146
|
+
const createIndicatorArray = useCallback(() => {
|
|
147
|
+
const childrenLength = carousel.current?.children?.length;
|
|
148
|
+
const newIndicatorArray = Array.from(Array(childrenLength).keys());
|
|
149
|
+
logicSetState({ type: 'indicatorArray', value: newIndicatorArray });
|
|
150
|
+
}, []);
|
|
151
|
+
useEffect(() => (indicator) && createIndicatorArray(), [indicator, children, createIndicatorArray]);
|
|
152
|
+
|
|
153
|
+
const handleCarouselClick = (e, direction) => {
|
|
154
|
+
if (!childWidth || (typeof childWidth !== 'number')) return;
|
|
155
|
+
|
|
156
|
+
let newPosition = position;
|
|
157
|
+
const scrollWidth = (childWidth * scrollSensitivity);
|
|
158
|
+
const leftButtonElement = document.getElementById(leftButtonId);
|
|
159
|
+
const rightButtonElement = document.getElementById(rightButtonId);
|
|
160
|
+
|
|
161
|
+
leftButtonElement.disabled = true;
|
|
162
|
+
rightButtonElement.disabled = true;
|
|
163
|
+
disabledButtonsRef.current = true;
|
|
164
|
+
|
|
165
|
+
if (direction === 'right') {
|
|
166
|
+
(carousel.current.scrollLeft += scrollWidth);
|
|
167
|
+
(position < (indicatorArray.length - 1)) && logicSetState({ type: 'position', value: (newPosition += 1) });
|
|
168
|
+
} else {
|
|
169
|
+
(carousel.current.scrollLeft -= scrollWidth);
|
|
170
|
+
(position > 0) && logicSetState({ type: 'position', value: (newPosition -= 1) });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
(onClick && (typeof onClick === 'function')) && onClick(e);
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
leftButtonElement.disabled = false;
|
|
176
|
+
rightButtonElement.disabled = false;
|
|
177
|
+
disabledButtonsRef.current = false;
|
|
178
|
+
control();
|
|
179
|
+
}, ((childWidth <= 500) ? 500 : (childWidth * ((childWidth > 1000) ? 0.6 : 0.9)) || 500));
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
return <div id={carouselId} className={classes.container}>
|
|
184
|
+
<div className={classes.carouselContainer}>
|
|
185
|
+
{(buttons && LEFT_ICON) && (
|
|
186
|
+
<button id={leftButtonId} onClick={(e) => handleCarouselClick(e, 'left')} className={clsx(classes.button, classes.leftButton, buttonClassName)}>
|
|
187
|
+
<LEFT_ICON size={iconSize} className={classes.leftButton} />
|
|
188
|
+
</button>
|
|
189
|
+
)}
|
|
190
|
+
<div ref={carousel} style={{ ...carouselStyle }} className={classes.carousel}>
|
|
191
|
+
{children}
|
|
192
|
+
</div>
|
|
193
|
+
{(buttons && RIGHT_ICON) && (
|
|
194
|
+
<button id={rightButtonId} onClick={(e) => handleCarouselClick(e, 'right')} className={clsx(classes.button, classes.rightButton, buttonClassName)}>
|
|
195
|
+
<RIGHT_ICON size={iconSize} className={classes.rightButton} />
|
|
196
|
+
</button>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
{(indicator) && (
|
|
200
|
+
<div className={clsx(classes.indicator, indicatorClassName)}>
|
|
201
|
+
{indicatorArray.map((_, index) => (
|
|
202
|
+
<span
|
|
203
|
+
key={`indicator-${index}`}
|
|
204
|
+
className={
|
|
205
|
+
clsx({
|
|
206
|
+
[classes.currentIndicator]: (position === index),
|
|
207
|
+
[currentIndicatorClassName]: (position === index)
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
/>
|
|
211
|
+
))}
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</div>;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
export default Carousel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Carousel';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const Cursor = ({ id, speed = 500, className }) => {
|
|
5
|
+
|
|
6
|
+
const cursorId = `${id}-cursor-component`;
|
|
7
|
+
const intervalIdRef = useRef(null);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const cursorElement = document.getElementById(cursorId);
|
|
12
|
+
if (cursorElement) cursorElement.style.opacity = '1';
|
|
13
|
+
intervalIdRef.current = setInterval(() => {
|
|
14
|
+
if (cursorElement) cursorElement.style.opacity = (cursorElement.style.opacity === '0') ? '1' : '0';
|
|
15
|
+
}, speed);
|
|
16
|
+
return () => clearInterval(intervalIdRef.current);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
return <span id={cursorId} className={`${className}`}>|</span>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export default Cursor;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ClickAwayListener, IconButton, makeStyles } from '@material-ui/core';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { RgbaColorPicker } from 'react-colorful';
|
|
4
|
+
import { RiAlignCenter, RiAlignJustify, RiAlignLeft, RiAlignRight, RiFontColor, RiFontSize } from 'react-icons/ri';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const ICON_SIZE = '2.5rem';
|
|
8
|
+
const BOX_SHADOW = 'rgba(0, 0, 0, 0.3) 0px 1px 12px -2px';
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles(theme => ({
|
|
11
|
+
container: {
|
|
12
|
+
zIndex: 1,
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
top: 0,
|
|
15
|
+
right: 0,
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'flex-start',
|
|
18
|
+
justifyContent: 'flex-end',
|
|
19
|
+
gap: ({ defaultSpacing }) => (defaultSpacing) ? defaultSpacing : ''
|
|
20
|
+
},
|
|
21
|
+
button: {
|
|
22
|
+
padding: ({ defaultSpacing }) => (defaultSpacing) ? (defaultSpacing / 2) : '',
|
|
23
|
+
color: `rgba(${(theme.palette.type === 'light') ? '0, 0, 0' : '255, 255, 255'}, .7)`,
|
|
24
|
+
backgroundColor: `rgba(${(theme.palette.type === 'light') ? '255, 255, 255' : '0, 0, 0'}, .5)`,
|
|
25
|
+
'&:hover': {
|
|
26
|
+
backgroundColor: `rgba(${(theme.palette.type === 'light') ? '255, 255, 255' : '0, 0, 0'}, .7)`
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
colorPickerContainer: {
|
|
30
|
+
zIndex: 2,
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
padding: '2rem'
|
|
33
|
+
},
|
|
34
|
+
colorPickerBoxShadow: {
|
|
35
|
+
borderRadius: 8,
|
|
36
|
+
webKitBoxShadow: BOX_SHADOW,
|
|
37
|
+
mozBoxShadow: BOX_SHADOW,
|
|
38
|
+
boxShadow: BOX_SHADOW
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const initialStateOpen = {
|
|
44
|
+
colorPicker: undefined
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const initialState = {
|
|
48
|
+
open: initialStateOpen
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const TextStyles = ({ color, setColor, defaultSpacing, toggleClickAway, handleFontSizeChange, textAlign, handleTextAlignChange }) => {
|
|
53
|
+
|
|
54
|
+
const classes = useStyles({ defaultSpacing });
|
|
55
|
+
const [state, setState] = useState(initialState);
|
|
56
|
+
const { open } = state;
|
|
57
|
+
|
|
58
|
+
const logicSetState = (type, field, value) => setState(values => ({
|
|
59
|
+
...values,
|
|
60
|
+
[type]: (type && field) ? { ...values[type], [field]: value } : value
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const handleColorPickerOpen = e => {
|
|
64
|
+
toggleClickAway();
|
|
65
|
+
const elRect = e.target.parentElement.getBoundingClientRect();
|
|
66
|
+
logicSetState('open', 'colorPicker', elRect);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleColorPickerClose = e => {
|
|
70
|
+
toggleClickAway();
|
|
71
|
+
logicSetState('open', 'colorPicker', undefined);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
return <div className={classes.container}>
|
|
76
|
+
<IconButton onClick={handleTextAlignChange} onTouchStart={handleTextAlignChange} className={classes.button}>
|
|
77
|
+
{(() => {
|
|
78
|
+
switch (textAlign) {
|
|
79
|
+
case 'start':
|
|
80
|
+
return <RiAlignLeft size={ICON_SIZE} />;
|
|
81
|
+
case 'end':
|
|
82
|
+
return <RiAlignRight size={ICON_SIZE} />;
|
|
83
|
+
case 'center':
|
|
84
|
+
return <RiAlignCenter size={ICON_SIZE} />;
|
|
85
|
+
case 'justify':
|
|
86
|
+
return <RiAlignJustify size={ICON_SIZE} />;
|
|
87
|
+
default:
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
})()}
|
|
91
|
+
</IconButton>
|
|
92
|
+
<IconButton onClick={handleColorPickerOpen} onTouchStart={handleColorPickerOpen} className={classes.button}>
|
|
93
|
+
<RiFontColor size={ICON_SIZE} />
|
|
94
|
+
</IconButton>
|
|
95
|
+
<IconButton onClick={handleFontSizeChange} onTouchStart={handleFontSizeChange} className={classes.button}>
|
|
96
|
+
<RiFontSize size={ICON_SIZE} />
|
|
97
|
+
</IconButton>
|
|
98
|
+
{(!!open.colorPicker) && (
|
|
99
|
+
<ClickAwayListener disableReactTree onClickAway={handleColorPickerClose}>
|
|
100
|
+
<div className={classes.colorPickerContainer}>
|
|
101
|
+
<div className={classes.colorPickerBoxShadow}>
|
|
102
|
+
<RgbaColorPicker color={color} onChange={setColor} />
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</ClickAwayListener>
|
|
106
|
+
)}
|
|
107
|
+
</div>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
export default TextStyles;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface TextToHtmlInitialValue {
|
|
2
|
+
text?: string,
|
|
3
|
+
cssText?: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface TextToHtmlProps {
|
|
7
|
+
/**
|
|
8
|
+
* Object containing properties to use as initial value
|
|
9
|
+
*/
|
|
10
|
+
initialValue?: TextToHtmlInitialValue,
|
|
11
|
+
/**
|
|
12
|
+
* Function called on change
|
|
13
|
+
* @param htmlString
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
onChange?: (htmlString: string) => void,
|
|
17
|
+
/**
|
|
18
|
+
* Function called on delete
|
|
19
|
+
* @param event
|
|
20
|
+
* @param deleted
|
|
21
|
+
* @param newCharacters
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
onDelete?: (event: Event, deleted: object, newCharacters: Array<object>) => void,
|
|
25
|
+
/**
|
|
26
|
+
* Number to represent the default spacing in pixels
|
|
27
|
+
*/
|
|
28
|
+
defaultSpacing?: number,
|
|
29
|
+
/**
|
|
30
|
+
* Function called to set external values
|
|
31
|
+
*/
|
|
32
|
+
setExternalValues?: (state: object) => void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
declare function TextToHtml(props: TextToHtmlProps) : JSX.Element
|
|
37
|
+
|
|
38
|
+
export default TextToHtml;
|