mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-17 23:32:49 +00:00
fix(outline-pane): tree does not change when doc.importSchema call
This commit is contained in:
parent
6015c5d1d1
commit
7eed0966e9
@ -593,7 +593,7 @@ export class PaneController implements IPublicModelSensor, ITreeBoard, IPublicTy
|
|||||||
// at this moment, it is possible that pane is not ready yet, so
|
// at this moment, it is possible that pane is not ready yet, so
|
||||||
// put ui related operations to the next loop
|
// put ui related operations to the next loop
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
tree.setNodeSelected(treeNode.id);
|
tree.setNodeSelected(treeNode.nodeId);
|
||||||
this.scrollToNode(treeNode, null, 4);
|
this.scrollToNode(treeNode, null, 4);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
@ -615,21 +615,21 @@ export class PaneController implements IPublicModelSensor, ITreeBoard, IPublicTy
|
|||||||
if (!this._shell) {
|
if (!this._shell) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return this._shell.querySelector(`.tree-node[data-id="${treeNode.id}"]`)?.getBoundingClientRect();
|
return this._shell.querySelector(`.tree-node[data-id="${treeNode.nodeId}"]`)?.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTreeTitleRect(treeNode: TreeNode): DOMRect | undefined {
|
private getTreeTitleRect(treeNode: TreeNode): DOMRect | undefined {
|
||||||
if (!this._shell) {
|
if (!this._shell) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return this._shell.querySelector(`.tree-node-title[data-id="${treeNode.id}"]`)?.getBoundingClientRect();
|
return this._shell.querySelector(`.tree-node-title[data-id="${treeNode.nodeId}"]`)?.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTreeSlotsRect(treeNode: TreeNode): DOMRect | undefined {
|
private getTreeSlotsRect(treeNode: TreeNode): DOMRect | undefined {
|
||||||
if (!this._shell) {
|
if (!this._shell) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return this._shell.querySelector(`.tree-node-slots[data-id="${treeNode.id}"]`)?.getBoundingClientRect();
|
return this._shell.querySelector(`.tree-node-slots[data-id="${treeNode.nodeId}"]`)?.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import {
|
|||||||
IPublicModelNode,
|
IPublicModelNode,
|
||||||
IPublicTypeDisposable,
|
IPublicTypeDisposable,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { isI18nData, isLocationChildrenDetail } from '@alilc/lowcode-utils';
|
import { isI18nData, isLocationChildrenDetail, uniqueId } from '@alilc/lowcode-utils';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { Tree } from './tree';
|
import { Tree } from './tree';
|
||||||
import { IOutlinePanelPluginContext } from './tree-master';
|
import { IOutlinePanelPluginContext } from './tree-master';
|
||||||
@ -60,7 +60,9 @@ export default class TreeNode {
|
|||||||
*/
|
*/
|
||||||
private _expanded = false;
|
private _expanded = false;
|
||||||
|
|
||||||
get id(): string {
|
id = uniqueId('treeNode');
|
||||||
|
|
||||||
|
get nodeId(): string {
|
||||||
return this.node.id;
|
return this.node.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +258,7 @@ export default class TreeNode {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
isLocationChildrenDetail(loc.detail) && loc.detail.focus?.type === 'node' && loc.detail?.focus?.node.id === this.id
|
isLocationChildrenDetail(loc.detail) && loc.detail.focus?.type === 'node' && loc.detail?.focus?.node.id === this.nodeId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +280,7 @@ export default class TreeNode {
|
|||||||
if (!loc) {
|
if (!loc) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return loc.target?.id === this.id;
|
return loc.target?.id === this.nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitleLabel(label: string) {
|
setTitleLabel(label: string) {
|
||||||
|
|||||||
@ -45,6 +45,10 @@ export class Tree {
|
|||||||
const treeNode = this.getTreeNodeById(node.id);
|
const treeNode = this.getTreeNodeById(node.id);
|
||||||
treeNode?.setHidden(!visible);
|
treeNode?.setHidden(!visible);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
doc?.onImportSchema(() => {
|
||||||
|
this.treeNodesMap = new Map<string, TreeNode>();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setNodeSelected(nodeId: string): void {
|
setNodeSelected(nodeId: string): void {
|
||||||
|
|||||||
@ -169,12 +169,12 @@ class TreeNodeChildren extends PureComponent<{
|
|||||||
children.push(insertion);
|
children.push(insertion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
groupContents.push(<TreeNodeView key={child.id} treeNode={child} isModal={isModal} />);
|
groupContents.push(<TreeNodeView key={child.nodeId} treeNode={child} isModal={isModal} />);
|
||||||
} else {
|
} else {
|
||||||
if (index === dropIndex) {
|
if (index === dropIndex) {
|
||||||
children.push(insertion);
|
children.push(insertion);
|
||||||
}
|
}
|
||||||
children.push(<TreeNodeView key={child.id} treeNode={child} isModal={isModal} />);
|
children.push(<TreeNodeView key={child.nodeId} treeNode={child} isModal={isModal} />);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
endGroup();
|
endGroup();
|
||||||
@ -201,14 +201,14 @@ class TreeNodeSlots extends PureComponent<{
|
|||||||
className={classNames('tree-node-slots', {
|
className={classNames('tree-node-slots', {
|
||||||
'insertion-at-slots': treeNode.dropDetail?.focus?.type === 'slots',
|
'insertion-at-slots': treeNode.dropDetail?.focus?.type === 'slots',
|
||||||
})}
|
})}
|
||||||
data-id={treeNode.id}
|
data-id={treeNode.nodeId}
|
||||||
>
|
>
|
||||||
<div className="tree-node-slots-title">
|
<div className="tree-node-slots-title">
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
<Title title={{ type: 'i18n', intl: this.props.treeNode.pluginContext.intlNode('Slots') }} />
|
<Title title={{ type: 'i18n', intl: this.props.treeNode.pluginContext.intlNode('Slots') }} />
|
||||||
</div>
|
</div>
|
||||||
{treeNode.slots.map(tnode => (
|
{treeNode.slots.map(tnode => (
|
||||||
<TreeNodeView key={tnode.id} treeNode={tnode} />
|
<TreeNodeView key={tnode.nodeId} treeNode={tnode} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -225,7 +225,7 @@ export default class TreeNodeView extends PureComponent<{
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={className}
|
className={className}
|
||||||
data-id={treeNode.id}
|
data-id={treeNode.nodeId}
|
||||||
>
|
>
|
||||||
<TreeTitle
|
<TreeTitle
|
||||||
treeNode={treeNode}
|
treeNode={treeNode}
|
||||||
|
|||||||
@ -135,7 +135,7 @@ export default class TreeTitle extends PureComponent<{
|
|||||||
<div
|
<div
|
||||||
className={classNames('tree-node-title', { editing })}
|
className={classNames('tree-node-title', { editing })}
|
||||||
style={style}
|
style={style}
|
||||||
data-id={treeNode.id}
|
data-id={treeNode.nodeId}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (isModal) {
|
if (isModal) {
|
||||||
if (this.state.visible) {
|
if (this.state.visible) {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export default class TreeView extends PureComponent<{
|
|||||||
private onDoubleClick = (e: ReactMouseEvent) => {
|
private onDoubleClick = (e: ReactMouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const treeNode = this.getTreeNodeFromEvent(e);
|
const treeNode = this.getTreeNodeFromEvent(e);
|
||||||
if (treeNode?.id === this.state.root?.id) {
|
if (treeNode?.nodeId === this.state.root?.nodeId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!treeNode?.expanded) {
|
if (!treeNode?.expanded) {
|
||||||
@ -188,6 +188,11 @@ export default class TreeView extends PureComponent<{
|
|||||||
root: tree.root,
|
root: tree.root,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
doc?.onImportSchema(() => {
|
||||||
|
this.setState({
|
||||||
|
root: tree.root,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user