diu / neos-anchorlink
Extends the Neos CKE5 linkeditor custom anchor link option
Installs: 2 532
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 2
Open Issues: 24
Type:neos-package
Requires
- neos/neos-ui: *
- dev-master
- 0.1.0
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/qs-6.11.0
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/loader-utils-1.4.2
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/terser-4.8.1
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/shell-quote-1.7.3
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/async-2.6.4
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/url-parse-1.5.10
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/ajv-6.12.6
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/mout-1.2.3
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/shelljs-0.8.5
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/browserslist-4.16.6
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/lodash-4.17.21
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/ssri-6.0.2
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/y18n-4.0.1
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/elliptic-6.5.4
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/ini-1.3.8
- dev-dependabot/npm_and_yarn/Resources/Private/AnchorLink/acorn-6.4.1
This package is auto-updated.
Last update: 2025-03-06 20:42:01 UTC
README
Extends the Neos CKE5 linkeditor with server-side resolvable anchor links.
Installation
-
Install the package:
composer require diu/neos-anchorlink
-
Enable additional linking options with such config:
"Neos.NodeTypes.BaseMixins:TextMixin": # Or other nodetype properties: text: ui: inline: editorOptions: linking: anchorLink: true
- For all content nodetypes that you would like to be able to link to, inherit from
DIU.Neos.AnchorLink:AnchorMixin
, e.g.:
Neos.Neos:Content: # Or other nodetype superTypes: DIU.Neos.AnchorLink:AnchorMixin: true
- Adjust the rendering for those nodes to insert anchors before them, e.g. there is included a Fusion processor to help with that:
prototype(Neos.Neos:Content).@process.anchor = DIU.Neos.AnchorLink:AnchorLinkAugmentor
Note: this will add an id
attribute to the corresponding output. For this to work reliably the corresponding prototype should render
a single root element. Otherwise an additional wrapping div
element will be rendered.
Also the rendered content must not already contain an id
attribute because it would be merged with the one from the augmentor in that case.
Configuration
It's possible to configure the content node nodetype that is used for linking. Also it's possible to use a different property for the anchor value and the label via Settings.yaml.
These are the defaults:
DIU: Neos: AnchorLink: # Only nodes of this type will appear in the "Choose link anchor" selector contentNodeType: "DIU.Neos.AnchorLink:AnchorMixin" # Eel Expression that returns the anchor (without leading "#") for a given node anchor: ${node.properties.anchor || node.name} # Eel Expression that returns the label to be rendered in the anchor selector in the Backend label: ${node.label} # Eel Expression that returns a group for the anchor selector (empty string == no grouping) group: ${I18n.translate(node.nodeType.label)} # Eel Expression that returns an icon for the anchor selector (empty string = no icon) icon: ${node.nodeType.fullConfiguration.ui.icon}
It's possible to disable the searchbox or adjust its threshold via Settings.yaml, the default settings are:
Neos: Neos: Ui: frontendConfiguration: "Diu.Neos.AnchorLink": displaySearchBox: true threshold: 0
Low-level Customization
Finally it is possible to create a completely custom anchor nodes resolver.
Create a class implementing AnchorLinkResolverInterface
that would take current content node, link and a searchTerm and return an array of options for the link anchor selector and configure it in Objects.yaml
like this:
'DIU\Neos\AnchorLink\Controller\AnchorLinkController':
properties:
resolver:
object: Your\Custom\AnchorLinkResolver
Development
If you need to adjust anything in this package, just do so and then rebuild the code like this:
cd Resources/Private/AnchorLink
yarn && yarn build
And then commit changed filed including Plugin.js