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

project.currentDocument.onMountNode 中的node 缺少方法 #2577

Closed
mywei1989 opened this issue Oct 23, 2023 · 1 comment
Closed

project.currentDocument.onMountNode 中的node 缺少方法 #2577

mywei1989 opened this issue Oct 23, 2023 · 1 comment
Assignees
Labels
WIP Working in Progress / 有人跟进中
Milestone

Comments

@mywei1989
Copy link

mywei1989 commented Oct 23, 2023

版本号:AliLowCodeEngine v1.1.10 AliLowCodeExt v1.0.6
根据本文档

/**
 * 当前 document 新增节点事件,此时节点已经挂载到 document 上
 * set callback for event on node is mounted to canvas
 */
onMountNode(fn: (payload: { node: IPublicModelNode }) => void): IPublicTypeDisposable;

IPublicModelNode 含有 importSchema 与 exportSchema方法
可是实际使用中缺少这个两个方法
也不存在 这一对方法 getExtraPropValue setExtraPropValue
存在 node.schema 属性可以获取到schema 但无法修改

project.currentDocument.onMountNode(({ node }) => {
     let nodeSchema = node.exportSchema() //  Uncaught TypeError: node.exportSchema is not a function
    let schemaObj = node.schema 
    node.importSchema(schemaObj) //  Uncaught TypeError: node.importSchema is not a function
})
@eightHundreds
Copy link
Contributor

+1

原因是 315行抛出的是 INode,而不是IPublicModelNode

internalInsert(node: INode, at?: number | null, useMutator = true): void {
const { children } = this;
let index = at == null || at === -1 ? children.length : at;
const i = children.map(d => d.id).indexOf(node.id);
if (node.parent) {
const editor = node.document?.designer.editor;
editor?.eventBus.emit('node.remove.topLevel', {
node,
index: node.index,
});
}
if (i < 0) {
if (index < children.length) {
children.splice(index, 0, node);
} else {
children.push(node);
}
node.internalSetParent(this.owner, useMutator);
} else {
if (index > i) {
index -= 1;
}
if (index === i) {
return;
}
children.splice(i, 1);
children.splice(index, 0, node);
}
this.emitter.emit('change', {
type: 'insert',
node,
});
this.emitter.emit('insert', node);
/* istanbul ignore next */
const editor = node.document?.designer.editor;
editor?.eventBus.emit('node.add', { node });
if (useMutator) {

@liujuping liujuping added this to the 1.2.1 milestone Oct 26, 2023
@liujuping liujuping added the WIP Working in Progress / 有人跟进中 label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Working in Progress / 有人跟进中
Projects
None yet
Development

No branches or pull requests

3 participants