插件扩展 - 编排扩展

场景一:扩展选中节点操作项

增加节点操作项

插件扩展 - 编排扩展 - 图1

选中节点后,在选中框的右上角有操作按钮,编排模块默认实现了查看组件直系父节点、复制节点和删除节点按钮外,还可以通过相关 API 来扩展更多操作,如下代码:

  1. import { plugins } from '@alilc/lowcode-engine';
  2. import { Icon, Message } from '@alifd/next';
  3. const addHelloAction = (ctx: ILowCodePluginContext) => {
  4. return {
  5. async init() {
  6. const { addBuiltinComponentAction } = ctx.material;
  7. addBuiltinComponentAction({
  8. name: 'hello',
  9. content: {
  10. icon: <Icon type="atm" />,
  11. title: 'hello',
  12. action(node: Node) {
  13. Message.show('Welcome to Low-Code engine');
  14. },
  15. },
  16. condition: (node: Node) => {
  17. return node.componentMeta.componentName === 'NextTable';
  18. },
  19. important: true,
  20. });
  21. }
  22. };
  23. }
  24. addHelloAction.pluginName = 'addHelloAction';
  25. await plugins.register(addHelloAction);

效果如下:

插件扩展 - 编排扩展 - 图2

具体 API 参考:https://www.yuque.com/lce/doc/mu7lml#ieJzi

删除节点操作项

  1. import { plugins } from '@alilc/lowcode-engine';
  2. const removeCopyAction = (ctx: ILowCodePluginContext) => {
  3. return {
  4. async init() {
  5. const { removeBuiltinComponentAction } = ctx.material;
  6. removeBuiltinComponentAction('copy');
  7. }
  8. }
  9. }
  10. removeCopyAction.pluginName = 'removeCopyAction';
  11. await plugins.register(removeCopyAction);

效果如下:

插件扩展 - 编排扩展 - 图3具体 API 参考:https://www.yuque.com/lce/doc/mu7lml#va9mb