-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable linking options for the inspector LinkEditor
- Loading branch information
Showing
7 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Resources/Private/LinkEditor/src/components/LinkEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { GlobalNeos } from '../util/useNeos'; | ||
import { fromEntries } from '../util/objects'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import { LinkInput } from '@neos-project/neos-ui-editors'; | ||
|
||
type LinkEditorProps = { | ||
value?: string; | ||
commit: (newValue: string) => void; | ||
options?: { | ||
[key: string]: unknown, | ||
linking?: Record<string, unknown>, | ||
}; | ||
neos: GlobalNeos; | ||
} | ||
|
||
/** | ||
* Custom wrapper around the LinkEditor to support linking options in the inspector | ||
* @param props | ||
* @constructor | ||
*/ | ||
export const LinkEditor: React.FunctionComponent<LinkEditorProps> = props => { | ||
const { linking, ...options } = props.options; | ||
|
||
const editorConfiguration = props.neos.globalRegistry | ||
.get('frontendConfiguration') | ||
.get<{linkEditor?: { ignoredOptions: string[] }}>('Prgfx.Neos.LinkEditor'); | ||
const ignoredOptions = editorConfiguration.linkEditor?.ignoredOptions ?? []; | ||
|
||
const linkingOptions = { | ||
...linking, | ||
...fromEntries(ignoredOptions.map(option => [ option, false ])), | ||
}; | ||
|
||
return ( | ||
<LinkInput | ||
linkValue={props.value} | ||
onLinkChange={props.commit} | ||
options={options} | ||
linkingOptions={linkingOptions} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.