MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / getSuitablePlace

Method getSuitablePlace

packages/designer/src/document/node/node.ts:1242–1310  ·  view source on GitHub ↗

* @deprecated no one is using this, will be removed in a future release

(node: INode, ref: any)

Source from the content-addressed store, hash-verified

1240 * @deprecated no one is using this, will be removed in a future release
1241 */
1242 getSuitablePlace(node: INode, ref: any): any {
1243 const focusNode = this.document?.focusNode;
1244 // 如果节点是模态框,插入到根节点下
1245 if (node?.componentMeta?.isModal) {
1246 return { container: focusNode, ref };
1247 }
1248
1249 if (!ref && focusNode && this.contains(focusNode)) {
1250 const rootCanDropIn = focusNode.componentMeta?.prototype?.options?.canDropIn;
1251 if (
1252 rootCanDropIn === undefined ||
1253 rootCanDropIn === true ||
1254 (typeof rootCanDropIn === 'function' && rootCanDropIn(node))
1255 ) {
1256 return { container: focusNode };
1257 }
1258
1259 return null;
1260 }
1261
1262 if (this.isRoot() && this.children) {
1263 const dropElement = this.children.filter((c) => {
1264 if (!c.isContainerNode) {
1265 return false;
1266 }
1267 const canDropIn = c.componentMeta?.prototype?.options?.canDropIn;
1268 if (
1269 canDropIn === undefined ||
1270 canDropIn === true ||
1271 (typeof canDropIn === 'function' && canDropIn(node))
1272 ) {
1273 return true;
1274 }
1275 return false;
1276 })[0];
1277
1278 if (dropElement) {
1279 return { container: dropElement, ref };
1280 }
1281
1282 const rootCanDropIn = this.componentMeta?.prototype?.options?.canDropIn;
1283 if (
1284 rootCanDropIn === undefined ||
1285 rootCanDropIn === true ||
1286 (typeof rootCanDropIn === 'function' && rootCanDropIn(node))
1287 ) {
1288 return { container: this, ref };
1289 }
1290
1291 return null;
1292 }
1293
1294 const canDropIn = this.componentMeta?.prototype?.options?.canDropIn;
1295 if (this.isContainer()) {
1296 if (
1297 canDropIn === undefined ||
1298 (typeof canDropIn === 'boolean' && canDropIn) ||
1299 (typeof canDropIn === 'function' && canDropIn(node))

Callers

nothing calls this directly

Calls 5

containsMethod · 0.95
isRootMethod · 0.95
isContainerMethod · 0.95
filterMethod · 0.65
getSuitablePlaceMethod · 0.65

Tested by

no test coverage detected