Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: createIcon props #2629

Merged
merged 2 commits into from
Nov 15, 2023
Merged

fix: createIcon props #2629

merged 2 commits into from
Nov 15, 2023

Conversation

Super-Rz
Copy link
Contributor

@Super-Rz Super-Rz commented Nov 9, 2023

addBuiltinComponentAction中icon的dom无法获取node节点,建议在 createAction中的 createIcon 补充 key,node参数

issuesId:#2622

@CLAassistant
Copy link

CLAassistant commented Nov 9, 2023

CLA assistant check
All committers have signed the CLA.

@@ -143,7 +143,7 @@ function createAction(content: ReactNode | ComponentType<any> | IPublicTypeActio
});
}}
>
{icon && createIcon(icon)}
{icon && createIcon(icon, { key, node })}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 node 得用 node.internalToShellNode()

另外,还需要补充一下相关的示例

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

示例:

// demo.tsx
import React from 'react';
import { Node } from '@alilc/lowcode-designer';
import { Dropdown, Icon } from '@alifd/next';
import store from 'store';

const model = [
  {
      value: 'option1',
      label: '选项1',
    },
    {
      value: ' option2',
      label: '选项2',
    },
]

import './index.less';

function SettetSwitch(props: any) {
 // 该 node 为 createIcon 传入
  const { node } = props;

  return (
    <Dropdown
      trigger={<Icon type="switch" size="small" />}
      onVisibleChange={() => store.set('setterValue', null)}
      triggerType={['hover']}
    >
      <div>
        {model.map((item) => (
          <div
            className="component-select-item"
            onClick={() => {
              // 设置物料属性
              node?.setPropValue('setter.componentName', item.value);
              node?.document?.selection.remove(node.id);
            }}
          >
            {item.label}
          </div>
        ))}
      </div>
    </Dropdown>
  );
}

export default {
  name: 'settetSwitch',
  content: {
    icon: <SettetSwitch />,
    title: 'Setter切换',
  },
  condition: (node: Node) => {
    return node.componentMeta?.componentName === 'Setters';
  },
  important: true,
};


// plugin.tsx
export default async function registerPlugins() {
  // 在设计器辅助层增加一个扩展 action
  material.addBuiltinComponentAction(setterSelect);
}

@liujuping
Copy link
Collaborator

@Super-Rz 分支指向 develop。

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b3b2a03) 85.04% compared to head (86b14c0) 85.04%.
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2629   +/-   ##
=======================================
  Coverage   85.04%   85.04%           
=======================================
  Files         222      222           
  Lines        8967     8967           
  Branches     2111     2111           
=======================================
  Hits         7626     7626           
  Misses       1248     1248           
  Partials       93       93           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Super-Rz Super-Rz changed the base branch from main to develop November 15, 2023 03:29
@liujuping liujuping merged commit e7884fd into alibaba:develop Nov 15, 2023
18 checks passed
JackLian pushed a commit that referenced this pull request Nov 16, 2023
* fix: createIcon props

* fix: createIcon props
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants