包含标题菜单的扩展,在AEM内容片段控制台的标题中引入一个按钮,该按钮在 否 已选择内容片段。 由于标题菜单扩展按钮仅在未选择内容片段时才显示,因此它们通常不会对现有内容片段采取任何操作。 标题菜单扩展通常:
ExtensionRegistration.js
是AEM扩展的入口点,并定义:
getButton()
函数。onClick()
函数。./src/aem-cf-console-admin-1/web-src/src/components/ExtensionRegistration.js
function ExtensionRegistration() {
const init = async () => {
const guestConnection = await register({
id: extensionId, // Must be unique
methods: {
// Configure your Header Menu button here
headerMenu: {
getButton() {
return {
'id': 'example.my-header-menu-button', // Unique ID for the button
'label': 'My header menu button', // Button label
'icon': 'Bookmark' // Button icon; get name from: https://spectrum.adobe.com/page/icons/ (Remove spaces, keep uppercase)
}
},
// Click handler for the Header Menu extension button
onClick() {
// Header Menu buttons are not associated with selected Content Fragment, and thus are not provided a selection parameter.
// Do work like importing data from a well known location, or exporting a welll known set of data
doWork();
},
}
}
}
}
init().catch(console.error);
}
AEM内容片段控制台标题菜单扩展可能需要:
为了支持这些要求,AEM内容片段控制台扩展允许自定义模式以作为React应用程序呈现。
./src/aem-cf-console-admin-1/web-src/src/components/ExtensionRegistration.js
function ExtensionRegistration() {
...
onClick() {
// Create a URL that maps to the React route to be rendered in the modal
const modalURL = "/index.html#/content-fragment/my-extension";
// Open the modal and display the React route created above
guestConnection.host.modal.showUrl({
title: "My modal title",
url: modalURL
})
}
...
}...
有时,AEM内容片段控制台标题菜单扩展不需要与用户进行进一步的交互,例如:
在这些情况下,AEM内容片段控制台扩展不需要 模态,并且可以直接在标题菜单按钮的 onClick
处理程序。
AEM内容片段控制台扩展允许使用进度指示器在执行工作时覆盖AEM内容片段控制台,从而阻止用户执行其他操作。 使用进度指示器是可选的,但对于将同步工作的进度告知用户非常有用。
./src/aem-cf-console-admin-1/web-src/src/components/ExtensionRegistration.js
function ExtensionRegistration() {
guestConnection: { ...
methods: { ...
headerMenu: { ...
onClick() {
// Optionally, show the progress indicator overlay on the AEM Content Fragment console
guestConnection.host.progressCircle.start();
// Perform work on the selected Content Fragments
doWork();
// Hide the progress indicator overlay on the AEM Content Fragment console when the work is done
guestConnection.host.progressCircle.stop();
}
}
}
}
}