Skip to content
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

FEATURE Inspector link value object property #44

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mhsdesign
Copy link
Collaborator

@mhsdesign mhsdesign commented Oct 23, 2023

This feature introduces a php link value object which can also be used as node property with editor support.

Advanced Inspector Editor Configuration with Sitegeist\Archaeopteryx\Link value object type:

'Vendor.Site:MyAwesomeNodeTypeWithALinkValueObjectProperty':
  # ...
  properties:
    link:
      type: Sitegeist\Archaeopteryx\Link
      ui:
        inspector:
          # ...
          editorOptions:
            # optionally enable link options, which will be encoded into the value object.
            anchor: true
            title: true
            relNofollow: true
            targetBlank: true

As the value object can serialize more than just the href we can also edit other link related options like title and the target.

The link value object can be queried as usual. An example rendering would look the following:

link = ${q(node).property("link")}
renderer = afx`
    <a href={props.link.href} title={props.link.title} target={props.link.target} rel={props.link.rel} rel.@if={props.link.rel != []}>
        My Text
    </a>
`

To try this feature out already, require this dev branch in your composer root:

composer require --no-update sitegeist/archaeopteryx:"dev-feature/inspectorLinkProperty as 1.4.0"

Demo Video:

Bildschirmaufnahme.2023-10-23.um.20.25.50.mov

With neos/flow-development-collection#2762 native support for vo's in various places was introduced.

Also in node property values where the neos ui uses the `DenormalizingObjectConverter` to convert the serialized data to the object.

Unfortunately the reverse currently does NOT use the expected `\JsonSerializable::jsonSerialize` but rather asks the `ArrayFromObjectConverter` for object types when serializing properties for the ui.

That leads to the need of aop like here https://github.com/sitegeist/Sitegeist.InspectorGadget/blob/78f5f4a206287b1c4bedf5cb88582ed51cb4a311/Classes/Infrastructure/NodeInfo/NodeInfoPostProcessingAspect.php#L17

This bugfix will make use of the `\JsonSerializable` interface instead directly when serializing properties for the neos ui.
@Benjamin-K
Copy link

Sounds really good. But just to be clear: This does not affect the existing editor and its output, right?

@mhsdesign
Copy link
Collaborator Author

Yes exactly. This feature is only available for the type: 'Sitegeist\Archaeopteryx\Link'. If you use "string" everything will stay as is ;)

(Im thinking about allowing fragments also for strings (if enabled) as it would be possible to encode this into the uri (obviously))

@mhsdesign mhsdesign marked this pull request as ready for review November 15, 2023 09:05
@mhsdesign mhsdesign changed the title Feature: inspector link property FEATURE Inspector link value object property Dec 1, 2023
Copy link
Member

@mficzel mficzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally very much like this and it looks fine by 👀 .

Much cleaner to specify a type: link than to say a string with a link editor.

Classes/Link.php Show resolved Hide resolved
@mhsdesign
Copy link
Collaborator Author

Does this work in your project? @mficzel or @nezaniel? in that case we should resolve the conflicts and merge?

@nezaniel
Copy link
Member

yep, works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants