paessler / anchorlink
扩展Neos CKE5链接编辑器的自定义锚点链接选项
1.0.0
2024-06-11 07:59 UTC
Requires
- neos/neos-ui: ^9.0
This package is not auto-updated.
Last update: 2024-10-01 10:06:38 UTC
README
通过服务器端可解析的锚点链接扩展Neos CKE5链接编辑器
安装
-
安装包:
composer require paessler/anchorlink
-
使用以下配置启用额外的链接选项
"Neos.NodeTypes.BaseMixins:TextMixin": # Or other nodetype properties: text: ui: inline: editorOptions: linking: anchorLink: true
- 对于您想要能够链接到的所有内容节点类型,继承自
Paessler.AnchorLink:AnchorMixin
,例如:
Neos.Neos:Content: # Or other nodetype superTypes: Paessler.AnchorLink:AnchorMixin: true
- 调整这些节点的渲染以在它们之前插入锚点,例如,包括了一个Fusion处理器来帮助实现这一点
prototype(Neos.Neos:Content).@process.anchor = Paessler.AnchorLink:AnchorLinkAugmenter
注意:这将向相应的输出添加一个id
属性。为了可靠地工作,相应的原型应该渲染单个根元素。否则,将渲染一个额外的包装div
元素。此外,渲染的内容不应已包含id
属性,因为在这种情况下它将与增强器中的属性合并。
配置
可以配置用于链接的内容节点节点类型。也可以通过Settings.yaml使用不同的属性作为锚点值和标签。
以下是默认值
Paessler: AnchorLink: # Only nodes of this type will appear in the "Choose link anchor" selector contentNodeType: "Paessler.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}
可以通过Settings.yaml禁用搜索框或调整其阈值,默认设置如下:
Neos: Neos: Ui: frontendConfiguration: "Paessler.AnchorLink": displaySearchBox: true threshold: 0
低级定制
最后,可以创建一个完全自定义的锚点节点解析器。
创建一个实现AnchorLinkResolverInterface
的类,该类将接受当前内容节点、链接和搜索词,并返回用于链接锚点选择器的选项数组,并在Objects.yaml
中配置它如下:
'Paessler\AnchorLink\Controller\AnchorLinkController':
properties:
resolver:
object: Your\Custom\AnchorLinkResolver
开发
如果您需要调整此包中的任何内容,请进行修改,然后像这样重建代码:
cd Resources/Private/JavaScript/AnchorLink
yarn && yarn build
然后提交更改的文件,包括Plugin.js
关于
该包基于DIU.Neos.AnchorLink
包。我们感谢DIU团队所做的所有努力。