Skip to content

Commit 1056832

Browse files
committed
allow to resize image
1 parent 0093a53 commit 1056832

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

packages/ra-input-rich-text/src/RichTextInput.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ export const DefaultEditorOptions: Partial<EditorOptions> = {
192192
}),
193193
Image.configure({
194194
inline: true,
195+
resize: {
196+
enabled: true,
197+
alwaysPreserveAspectRatio: true,
198+
},
195199
}),
196200
TextStyle, // Required by Color
197201
Color,
@@ -248,6 +252,73 @@ const Root = styled('div', {
248252
marginBottom: 0,
249253
},
250254
},
255+
'& [data-resize-handle]': {
256+
position: 'absolute',
257+
background: 'rgba(0, 0, 0, 0.5)',
258+
border: '1px solid rgba(255, 255, 255, 0.8)',
259+
borderRadius: 2,
260+
zIndex: 10,
261+
'&:hover': {
262+
background: 'rgba(0, 0, 0, 0.8)',
263+
},
264+
/* Corner handles */
265+
"&[data-resize-handle='top-left'], &[data-resize-handle='top-right'], &[data-resize-handle='bottom-left'], &[data-resize-handle='bottom-right']":
266+
{
267+
width: 8,
268+
height: 8,
269+
},
270+
"&[data-resize-handle='top-left']": {
271+
top: -4,
272+
left: -4,
273+
cursor: 'nwse-resize',
274+
},
275+
"&[data-resize-handle='top-right']": {
276+
top: -4,
277+
right: -4,
278+
cursor: 'nesw-resize',
279+
},
280+
"&[data-resize-handle='bottom-left']": {
281+
bottom: -4,
282+
left: -4,
283+
cursor: 'nesw-resize',
284+
},
285+
"&[data-resize-handle='bottom-right']": {
286+
bottom: -4,
287+
right: -4,
288+
cursor: 'nwse-resize',
289+
},
290+
/* Edge handles */
291+
"&[data-resize-handle='top'], &[data-resize-handle='bottom']": {
292+
height: 6,
293+
left: 8,
294+
right: 8,
295+
},
296+
"&[data-resize-handle='top']": {
297+
top: -3,
298+
cursor: 'ns-resize',
299+
},
300+
"&[data-resize-handle='bottom']": {
301+
bottom: -3,
302+
cursor: 'ns-resize',
303+
},
304+
"&[data-resize-handle='left'], &[data-resize-handle='right']": {
305+
width: 6,
306+
top: 8,
307+
bottom: 8,
308+
},
309+
"&[data-resize-handle='left']": {
310+
left: -3,
311+
cursor: 'ew-resize',
312+
},
313+
"&[data-resize-handle='right']": {
314+
right: -3,
315+
cursor: 'ew-resize',
316+
},
317+
},
318+
"& [data-resize-state='true'] [data-resize-wrapper]": {
319+
outline: '1px solid rgba(0, 0, 0, 0.25)',
320+
borderRadius: '0.125rem',
321+
},
251322
},
252323
},
253324
}));

0 commit comments

Comments
 (0)