sitegeist / Sitegeist.Archaeopteryx

The missing link editor for Neos
MIT License
21 stars 11 forks source link

FEATURE Inspector link value object property #44

Open mhsdesign opened 10 months ago

mhsdesign commented 10 months ago

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:

https://github.com/sitegeist/Sitegeist.Archaeopteryx/assets/85400359/821b6b14-9e06-4727-9348-7235aece56ef

Benjamin-K commented 10 months ago

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

mhsdesign commented 10 months ago

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 commented 7 months ago

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

nezaniel commented 5 months ago

yep, works