alibaba / alibaba/lowcode-engine
IDocumentModel 的 onMountNode 触发时组件实例并未挂载到 document 上
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
## **Describe the bug (required)** / **详细描述 bug(必填)**
拖动组件到画布上,插件内部监听 project 的当前文档的 onMountNode 事件,期望获取组件的 DomNode 并执行其它逻辑,但是此时节点并未挂载到 document 上,无法获取到 Dom 节点;
``` ts
/**
* 当前 document 新增节点事件,此时节点已经挂载到 document 上
* set callback for event on node is mounted to canvas
*/
onMountNode(fn: (payload: { node: Node }) => void): IPublicTypeDisposable;
```
**这里的 document 指的是引擎的 IPublicModelDocumentModel 吧,而非 HTML 的 Document?
如果是引擎的 document,是否考虑增加引擎 Node 的生命周期回调?**
---
## **To Reproduce (required)** / **如何复现 bug?(必填,非常重要)**
加载插件,
``` ts
const TestPlugin = (ctx: IPublicModelPluginContext) => {
return {
async init() {
const { project } = ctx;
project.getCurrentDocument()?.onMountNode(({ node }) => {
console.log('onMountNode', node);
const domNode: HTMLElement = node.getDOMNode();
// domNode is undefined, it not exists
domNode.style.position = 'fixed';
domNode.style.left = `${this.x}px`;
domNode.style.top = `${this.y}px`;
domNode.style.transition = 'none';
});
},
};
};
```
拖到组件到画布上,onMountMode 触发,node.getDOMNode() 为 undefined
---
## **Expected behavior (required)** / **预期行为(必填,非常重要)**
期望 onMountNode 时 node.getDOMNode() 可以获取到 Dom 节点
---
## **Screenshots (optional)** / **bug 截图(可选)**

---
## **Environments (please complete the following information) (required):** / **请提供如下信息(必填)**
- AliLowCodeEngine version: v1.2.2
- AliLowCodeEngineExt version: v1.0.6
- Browser: Chrome V119.0.6045.200 (Official Build) (64-bit)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.