-
-
Notifications
You must be signed in to change notification settings - Fork 146
TASK: Add ability for read-only users to interact with nodes in the preview page and view node data in the inspector #3921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.4
Are you sure you want to change the base?
Changes from 3 commits
f913346
f5bf20d
fe9c23d
676d25b
b58e4c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ public function getNodePolicyInformation(NodeInterface $node): array | |
| 'disallowedNodeTypes' => $this->getDisallowedNodeTypes($node), | ||
| 'canRemove' => $this->canRemoveNode($node), | ||
| 'canEdit' => $this->canEditNode($node), | ||
| 'canView' => $this->canReadNode($node), | ||
JamesAlias marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'disallowedProperties' => $this->getDisallowedProperties($node) | ||
| ]; | ||
| } | ||
|
|
@@ -102,6 +103,22 @@ public function isNodeTreePrivilegeGranted(NodeInterface $node): bool | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @param NodeInterface $node | ||
| * @return bool | ||
| */ | ||
| public function canReadNode(NodeInterface $node): bool | ||
| { | ||
| if (!isset(self::getUsedPrivilegeClassNames($this->objectManager)[ReadNodePropertyPrivilege::class])) { | ||
|
||
| return true; | ||
| } | ||
|
|
||
| return $this->privilegeManager->isGranted( | ||
| ReadNodePropertyPrivilege::class, | ||
| new NodePrivilegeSubject($node) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @param NodeInterface $node | ||
| * @return array | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| ], | ||
| "require": { | ||
| "neos/neos": "^8.3.0", | ||
| "neos/neos-ui-compiled": "self.version" | ||
| "neos/neos-ui-compiled": "8.4.x-dev" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. !!!Revert this before merging!!!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could have probably also did this override from your root composer.json.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ☝️
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will revert this right before merging |
||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ export const bootstrap = _editorConfig => { | |
| }; | ||
|
|
||
| export const createEditor = store => async options => { | ||
| const {propertyDomNode, propertyName, editorOptions, globalRegistry, userPreferences, onChange} = options; | ||
| const {propertyDomNode, propertyName, editorOptions, globalRegistry, userPreferences, onChange, isReadOnly} = options; | ||
| const ckEditorConfig = editorConfig.configRegistry.getCkeditorConfig({ | ||
| editorOptions, | ||
| userPreferences, | ||
|
|
@@ -58,26 +58,34 @@ export const createEditor = store => async options => { | |
| return NeosEditor | ||
| .create(propertyDomNode, ckEditorConfig) | ||
| .then(editor => { | ||
| const debouncedOnChange = debounce(() => onChange(cleanupContentBeforeCommit(editor.getData())), 1500, {maxWait: 5000}); | ||
| editor.model.document.on('change:data', debouncedOnChange); | ||
| editor.ui.focusTracker.on('change:isFocused', event => { | ||
| if (!event.source.isFocused) { | ||
| // when another editor is focused commit all possible pending changes | ||
| debouncedOnChange.flush(); | ||
| return | ||
| } | ||
| editor.isReadOnly = isReadOnly; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think i also attempted to use the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see your point and feel free to implement this. For me personally I don't have the time and as long as it works like intended I will just keep it like this. |
||
|
|
||
| currentEditor = editor; | ||
| editorConfig.setCurrentlyEditedPropertyName(propertyName); | ||
| handleUserInteractionCallback(); | ||
| }); | ||
| // Set placeholder text as Data if editor is empty because readOnly mode hides the placeholder | ||
| if (isReadOnly && editor.getData() === '') { | ||
| editor.setData(ckEditorConfig.placeholder, {doNotFireChange: true}); | ||
| } else { | ||
| const debouncedOnChange = debounce(() => onChange(cleanupContentBeforeCommit(editor.getData())), 1500, {maxWait: 5000}); | ||
| editor.model.document.on('change:data', debouncedOnChange); | ||
| editor.ui.focusTracker.on('change:isFocused', event => { | ||
| if (!event.source.isFocused) { | ||
| // when another editor is focused commit all possible pending changes | ||
| debouncedOnChange.flush(); | ||
| return | ||
| } | ||
|
|
||
| currentEditor = editor; | ||
| editorConfig.setCurrentlyEditedPropertyName(propertyName); | ||
| handleUserInteractionCallback(); | ||
| }); | ||
|
|
||
| editor.keystrokes.set('Ctrl+K', (_, cancel) => { | ||
| store.dispatch(actions.UI.ContentCanvas.toggleLinkEditor()); | ||
| cancel(); | ||
| }); | ||
| editor.keystrokes.set('Ctrl+K', (_, cancel) => { | ||
| store.dispatch(actions.UI.ContentCanvas.toggleLinkEditor()); | ||
| cancel(); | ||
| }); | ||
|
|
||
| editor.model.document.on('change', () => handleUserInteractionCallback()); | ||
| } | ||
|
|
||
| editor.model.document.on('change', () => handleUserInteractionCallback()); | ||
| return editor; | ||
| }).catch(e => { | ||
| if (e instanceof TypeError && e.message.match(/Class constructor .* cannot be invoked without 'new'/)) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.