Skip to content

Commit 4a75b21

Browse files
committed
add new picker to tineyMCE editor
1 parent e20a43a commit 4a75b21

File tree

7 files changed

+79
-93
lines changed

7 files changed

+79
-93
lines changed

apps/sensenet/src/components/field-controls/reference-grid.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ReactClientFieldSetting, ReferenceGrid as SnReferenceGrid } from '@sens
22
import { clsx } from 'clsx'
33
import React from 'react'
44
import { useGlobalStyles } from '../../globalStyles'
5-
import { DialogTitle } from '../dialogs/dialog-title'
65
import { Icon } from '../Icon'
76

87
export const ReferenceGrid: React.FC<ReactClientFieldSetting> = (props) => {
@@ -11,7 +10,6 @@ export const ReferenceGrid: React.FC<ReactClientFieldSetting> = (props) => {
1110
<SnReferenceGrid
1211
{...props}
1312
dialogProps={{ classes: { paper: clsx(globalClasses.dialog, globalClasses.pickerDialog) } }}
14-
dialogTitleComponent={DialogTitle}
1513
renderPickerIcon={(item) => <Icon item={item} />}
1614
pickerClasses={{ cancelButton: globalClasses.cancelButton }}
1715
/>

apps/sensenet/src/globalStyles.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ export const useGlobalStyles = makeStyles((theme: Theme) => {
126126
border: theme.palette.type === 'light' ? clsx(globals.light.borderColor, '1px') : 'none',
127127
maxWidth: '700px',
128128
},
129-
pickerDialog: {
130-
maxHeight: 750,
131-
},
132129
cancelButton: {
133130
//border: theme.palette.type === 'light' ? '2px solid #212121DE' : '2px solid #505050',
134131
backgroundColor: theme.palette.type === 'light' ? '#cecece' : 'rgba(255, 255, 255, 0.05)',
@@ -145,6 +142,12 @@ export const useGlobalStyles = makeStyles((theme: Theme) => {
145142
marginBottom: '12px',
146143
},
147144
},
145+
pickerDialog: {
146+
width: '950px',
147+
maxWidth: '80%',
148+
height: '900px',
149+
maxHeight: '80%',
150+
},
148151
})
149152
})
150153

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './default-item-template'
22
export * from './reference-grid'
33
export * from './reference-picker'
4-
export * from './picker-advanced'

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-grid.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@ import {
44
createStyles,
55
Dialog,
66
DialogProps,
7-
DialogTitle,
87
FormControl,
98
FormHelperText,
109
makeStyles,
1110
TextField,
1211
Typography,
1312
useTheme,
1413
} from '@material-ui/core'
15-
import { deepMerge, PathHelper } from '@sensenet/client-utils'
14+
import { PathHelper } from '@sensenet/client-utils'
1615
import { GenericContent, ReferenceFieldSetting, User } from '@sensenet/default-content-types'
17-
import { GenericContentWithIsParent, PickerClassKey } from '@sensenet/pickers-react'
16+
import { GenericContentWithIsParent, PickerAdvanced, PickerClassKey } from '@sensenet/pickers-react'
1817
import { ColDef } from 'ag-grid-community'
1918
import { AgGridReact } from 'ag-grid-react'
20-
import React, { ElementType, useCallback, useEffect, useState } from 'react'
19+
import React, { useCallback, useEffect, useState } from 'react'
2120
import { ReactClientFieldSetting } from '../client-field-setting'
2221
import { renderIconDefault } from '../icon'
23-
import { defaultLocalization } from '../localization'
24-
import { PickerAdvanced } from './picker-advanced'
2522

2623
const useStyles = makeStyles(() =>
2724
createStyles({
@@ -51,6 +48,14 @@ const useStyles = makeStyles(() =>
5148
minWidth: '0',
5249
padding: '0 12px',
5350
},
51+
pickerDialog: {
52+
width: '950px',
53+
maxWidth: '80%',
54+
height: '900px',
55+
maxHeight: '80%',
56+
padding: '8px 8px 0',
57+
border: '2px solid grey',
58+
},
5459
}),
5560
)
5661

@@ -88,14 +93,11 @@ const referemceGridColumns: ColDef[] = [
8893

8994
interface ReferenceGridProps extends ReactClientFieldSetting<ReferenceFieldSetting> {
9095
dialogProps?: Partial<DialogProps>
91-
dialogTitleComponent?: ElementType
9296
renderPickerIcon?: (item: any) => JSX.Element
9397
pickerClasses?: PickerClassKey
9498
}
9599

96100
export const ReferenceGrid: React.FC<ReferenceGridProps> = (props) => {
97-
const localization = deepMerge(defaultLocalization.referenceGrid, props.localization?.referenceGrid)
98-
const DialogTitleComponent = props.dialogTitleComponent ?? DialogTitle
99101
const theme = useTheme()
100102
const classes = useStyles()
101103

@@ -283,7 +285,7 @@ export const ReferenceGrid: React.FC<ReferenceGridProps> = (props) => {
283285
{`${props.settings.DisplayName} (${props.settings.Name})`}
284286
</label>
285287

286-
<div style={{ height: `${35 + (fieldValue?.length || 0) * 28}px`, width: '100%' }}>
288+
<div style={{ height: `${34 + (fieldValue?.length || 0) * 27}px`, width: '100%' }}>
287289
<AgGridReact
288290
rowData={fieldValue}
289291
columnDefs={[iconCol, ...referemceGridColumns, removeCol]}
@@ -298,18 +300,17 @@ export const ReferenceGrid: React.FC<ReferenceGridProps> = (props) => {
298300

299301
<Dialog
300302
fullWidth
301-
PaperProps={{ style: { maxWidth: '950px', height: '900px' } }}
303+
PaperProps={{ className: classes.pickerDialog }}
302304
maxWidth={false}
303305
onClose={handleDialogClose}
304306
open={isPickerOpen}
305307
{...props.dialogProps}>
306-
<DialogTitleComponent style={{ width: '100%' }}>{localization.referencePickerTitle}</DialogTitleComponent>
307308
<PickerAdvanced
308309
defaultValue={fieldValue}
309310
repository={props.repository!}
310311
path={currentParent}
311312
renderIcon={renderIconLocal}
312-
fieldSettings={props.settings}
313+
allowMultiple={props.settings.AllowMultiple}
313314
onCancel={handleCancelClick}
314315
onSubmit={handleOkClick}
315316
/>

packages/sn-editor-react/src/tinymce/controls/repo-file-plugin.tsx

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createStyles, DialogActions, DialogContent, makeStyles } from '@material-ui/core'
1+
import { createStyles, makeStyles } from '@material-ui/core'
22
import {
33
AddAlert,
44
AllInboxOutlined,
@@ -43,39 +43,21 @@ import {
4343
VisibilityOff,
4444
Widgets,
4545
} from '@material-ui/icons'
46-
import { ODataParams, Repository } from '@sensenet/client-core'
46+
import { Repository } from '@sensenet/client-core'
4747
import { File } from '@sensenet/default-content-types'
48-
import { Picker } from '@sensenet/pickers-react'
48+
import { PickerAdvanced } from '@sensenet/pickers-react'
4949
import React, { useEffect, useRef } from 'react'
5050

5151
const useStyles = makeStyles(() => {
5252
return createStyles({
53-
dialog: {
54-
border: 'none !important',
55-
borderRadius: 12,
56-
boxShadow: '0 0 #0000, 0 0 #0000, 0 25px 50px -12px rgba(0, 0, 0, 0.25)',
57-
padding: '1.6rem',
58-
maxWidth: '600px',
59-
width: '100%',
60-
'&::backdrop': {
61-
backgroundColor: 'rgba(255, 255, 255, .75)',
62-
},
63-
64-
'& .MuiDialogContent-root': {
65-
padding: 0,
66-
},
67-
'& .MuiDialogTitle-root': {
68-
paddingLeft: 0,
69-
},
70-
'& .tox-icon': {
71-
position: 'absolute',
72-
top: '0',
73-
right: '0',
74-
marginRight: '25px',
75-
marginTop: '20px',
76-
cursor: 'pointer',
77-
padding: '10px',
78-
},
53+
pickerDialog: {
54+
width: '950px',
55+
maxWidth: '80%',
56+
height: '900px',
57+
maxHeight: '80%',
58+
border: '2px solid grey',
59+
borderRadius: '8px',
60+
padding: '8px 8px 0',
7961
},
8062
})
8163
})
@@ -113,14 +95,6 @@ export const RepoFilePluginControl: React.FC<RepoFilePluginControlProps> = ({
11395
dialogRef.current?.close()
11496
closeDialog()
11597
}
116-
const queryObject: ODataParams<any> = {
117-
expand: ['Children'],
118-
filter: "isOf('GenericContent')",
119-
metadata: 'no',
120-
orderby: 'DisplayName',
121-
select: ['DisplayName', 'Path', 'Id', 'Children/IsFolder', 'IsFolder', 'Avatar', 'Icon', 'Size'],
122-
}
123-
12498
useEffect(() => {
12599
dialogRef.current?.showModal()
126100

@@ -243,23 +217,14 @@ export const RepoFilePluginControl: React.FC<RepoFilePluginControlProps> = ({
243217
if (!repository) return <></>
244218

245219
return (
246-
<dialog ref={dialogRef} className={classes.dialog}>
247-
<Picker
220+
<dialog ref={dialogRef} className={classes.pickerDialog}>
221+
<PickerAdvanced
248222
repository={repository}
249-
defaultValue={undefined}
250-
currentPath={'/Root'}
251-
selectionRoots={['/Root']}
252-
itemsODataOptions={queryObject}
253-
pickerContainer={DialogContent}
254-
actionsContainer={DialogActions}
255-
renderIcon={renderIcon}
256-
required={1}
223+
path={path ?? '/Root'}
257224
allowMultiple={true}
258-
contextPath={path}
259-
handleSubmit={handleInsert}
260-
handleCancel={closeDialog}
261-
localization={{}}
262-
classes={{}}
225+
renderIcon={renderIcon}
226+
onCancel={closeDialog}
227+
onSubmit={handleInsert}
263228
/>
264229
</dialog>
265230
)

0 commit comments

Comments
 (0)