This commit is contained in:
kangwei 2020-04-21 23:05:51 +08:00
parent 4e00dc0434
commit cf69e6aa2f
6 changed files with 36 additions and 6 deletions

View File

@ -104,6 +104,10 @@ export class Node {
return this._slotFor != null; return this._slotFor != null;
} }
isRoot() {
return (this.document.rootNode as any) == this;
}
constructor(readonly document: DocumentModel, nodeSchema: NodeSchema, slotFor?: Prop) { constructor(readonly document: DocumentModel, nodeSchema: NodeSchema, slotFor?: Prop) {
const { componentName, id, children, props, ...extras } = nodeSchema; const { componentName, id, children, props, ...extras } = nodeSchema;
this.id = id || `node$${document.nextId()}`; this.id = id || `node$${document.nextId()}`;
@ -480,6 +484,9 @@ export class Node {
insertBefore(node: Node, ref?: Node) { insertBefore(node: Node, ref?: Node) {
this.children?.insert(node, ref ? ref.index : null); this.children?.insert(node, ref ? ref.index : null);
} }
getParent() {
return this.parent;
}
/** /**
* @deprecated * @deprecated
@ -510,6 +517,15 @@ export class Node {
console.warn('getPage is deprecated, use document instead'); console.warn('getPage is deprecated, use document instead');
return this.document; return this.document;
} }
/**
* @deprecated
*/
getSuitablePlace(node: Node, ref: any): any {
if (this.isRoot()) {
return { container: this, ref };
}
return { container: this.parent, ref: this };
}
} }
export interface NodeParent extends Node { export interface NodeParent extends Node {

View File

@ -1,11 +1,14 @@
.lc-setter-mixed { .lc-setter-mixed {
display: flex;
align-items: center;
width: 100%; width: 100%;
position: relative;
.lc-setter-actions { .lc-setter-actions {
margin-left: 5px; position: absolute;
right: 0px;
} }
padding-right: 30px;
&.lc-block-setter { &.lc-block-setter {
position: static;
display: block; display: block;
padding-right: 0;
} }
} }

View File

@ -41,7 +41,6 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
} }
render() { render() {
const { renderer } = this.props; const { renderer } = this.props;
// const { components, schemas } = LowCodeRenderer.others;
return ( return (
<LowCodeRenderer <LowCodeRenderer
schema={renderer.schema} schema={renderer.schema}

View File

@ -28,6 +28,12 @@
"name": "moment", "name": "moment",
"version": "2.24.0" "version": "2.24.0"
}, },
{
"urls": ["https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"],
"library": "nattyFetch",
"name": "natty-fetch",
"version": "2.24.0"
},
{ "library": "VisualEngine", "name": "engine" }, { "library": "VisualEngine", "name": "engine" },
{ "library": "VisualEngine", "name": "visualengine" }, { "library": "VisualEngine", "name": "visualengine" },
{ "library": "VisualEngine", "name": "@ali/visualengine" }, { "library": "VisualEngine", "name": "@ali/visualengine" },

View File

@ -10,10 +10,16 @@ const DragEngine = {
return null; return null;
} }
if (isNode(r)) { if (isNode(r)) {
return {
type: DragObjectType.NodeData,
data: r.export(false),
};
// FIXME! designer has bug
/*
return { return {
type: DragObjectType.Node, type: DragObjectType.Node,
nodes: [r], nodes: [r],
}; };*/
} else { } else {
return { return {
type: DragObjectType.NodeData, type: DragObjectType.NodeData,

View File

@ -10,6 +10,6 @@ export default {
}, },
getSelected: () => { getSelected: () => {
const nodes = designer.currentSelection?.getNodes(); const nodes = designer.currentSelection?.getNodes();
return nodes; return nodes?.[0];
}, },
} }