fix initial get root rect

This commit is contained in:
kangwei 2020-05-05 18:40:58 +08:00
parent 103c0fa881
commit 641a11d412
5 changed files with 20 additions and 16 deletions

View File

@ -331,17 +331,6 @@ const builtinComponentActions: ComponentAction[] = [
}, },
important: true, important: true,
}, },
{
name: 'copy',
content: {
icon: IconClone,
title: intlNode('copy'),
action(node: Node) {
// node.remove();
},
},
important: true,
},
{ {
name: 'hide', name: 'hide',
content: { content: {
@ -356,6 +345,17 @@ const builtinComponentActions: ComponentAction[] = [
}, },
important: true, important: true,
}, },
{
name: 'copy',
content: {
icon: IconClone,
title: intlNode('copy'),
action(node: Node) {
// node.remove();
},
},
important: true,
},
]; ];
export function removeBuiltinComponentAction(name: string) { export function removeBuiltinComponentAction(name: string) {

View File

@ -461,14 +461,11 @@ export class DocumentModel {
return config.checkNestingDown(parent, obj) && this.checkNestingUp(parent, obj); return config.checkNestingDown(parent, obj) && this.checkNestingUp(parent, obj);
} }
// ======= compatibles // ======= compatibles for vision
getRoot() { getRoot() {
return this.rootNode; return this.rootNode;
} }
/**
* vision
*/
getHistory(): History { getHistory(): History {
return this.history; return this.history;
} }
@ -476,6 +473,10 @@ export class DocumentModel {
get root() { get root() {
return this.rootNode; return this.rootNode;
} }
toData() {
return this.export(TransformStage.Save);
}
} }
export function isDocumentModel(obj: any): obj is DocumentModel { export function isDocumentModel(obj: any): obj is DocumentModel {

View File

@ -685,6 +685,9 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
} }
getRect(): DOMRect | null { getRect(): DOMRect | null {
if (this.isRoot()) {
return this.document.simulator?.viewport.contentBounds || null;
}
return this.document.simulator?.computeRect(this) || null; return this.document.simulator?.computeRect(this) || null;
} }

View File

@ -228,7 +228,6 @@ export default class BaseEngine extends PureComponent {
let Comp = components[schema.componentName] || Div; let Comp = components[schema.componentName] || Div;
console.info('node schema', schema, engine.props);
if (schema.hidden) { if (schema.hidden) {
return null; return null;
} }

View File

@ -108,4 +108,5 @@ addBuiltinComponentAction({
name: 'instance-node-selector', name: 'instance-node-selector',
content: InstanceNodeSelector, content: InstanceNodeSelector,
important: true, important: true,
condition: 'always'
}); });