GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: remove dependency of nodeSymbol · li55/lowcode-engine@67a5e72

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs/docs/api/model
    • node.md
  • packages
    • designer/src/document/node
      • node.ts
    • engine/src/inner-plugins
      • builtin-hotkey.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/docs/api/model/node.md‎

Copy file name to clipboardExpand all lines: docs/docs/api/model/node.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ sidebar_position: 1
160160

161161
`@type {IPublicModelComponentMeta | null}`
162162

163-
相关类型:[IPublicTypeIconType](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/component-meta.ts)
163+
相关类型:[IPublicModelComponentMeta](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/component-meta.ts)
164164

165165

166166
### document
@@ -644,4 +644,4 @@ isConditionalVisible(): boolean | undefined;
644644
setConditionalVisible(): void;
645645
```
646646

647-
**@since v1.1.0**
647+
**@since v1.1.0**
Collapse file

‎packages/designer/src/document/node/node.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/document/node/node.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
11491149
}
11501150

11511151
/**
1152-
* TODO: replace non standard metas with standard ones.
1152+
* @deprecated no one is using this, will be removed in a future release
11531153
*/
11541154
getSuitablePlace(node: INode, ref: any): any {
11551155
const focusNode = this.document?.focusNode;
Collapse file

‎packages/engine/src/inner-plugins/builtin-hotkey.ts‎

Copy file name to clipboardExpand all lines: packages/engine/src/inner-plugins/builtin-hotkey.ts
+64-6Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import {
99
IPublicEnumDragObjectType,
1010
IPublicTypeDragNodeObject,
1111
} from '@alilc/lowcode-types';
12-
import symbols from '../modules/symbols';
13-
14-
const { nodeSymbol } = symbols;
1512

1613
function insertChild(
1714
container: IPublicModelNode,
@@ -163,6 +160,67 @@ function getPrevForSelect(prev: IPublicModelNode | null, head?: any, parent?: IP
163160
return null;
164161
}
165162

163+
function getSuitablePlaceForNode(targetNode: IPublicModelNode, node: IPublicModelNode, ref: any): any {
164+
const { document } = targetNode;
165+
if (!document) {
166+
return null;
167+
}
168+
169+
const dragNodeObject: IPublicTypeDragNodeObject = {
170+
type: IPublicEnumDragObjectType.Node,
171+
nodes: [node],
172+
};
173+
174+
const focusNode = document?.focusNode;
175+
// 如果节点是模态框,插入到根节点下
176+
if (node?.componentMeta?.isModal) {
177+
return { container: focusNode, ref };
178+
}
179+
const canDropInFn = document.checkNesting;
180+
181+
if (!ref && focusNode && targetNode.contains(focusNode)) {
182+
if (canDropInFn(focusNode, dragNodeObject)) {
183+
return { container: focusNode };
184+
}
185+
186+
return null;
187+
}
188+
189+
if (targetNode.isRootNode && targetNode.children) {
190+
const dropElement = targetNode.children.filter((c) => {
191+
if (!c.isContainerNode) {
192+
return false;
193+
}
194+
if (canDropInFn(c, dragNodeObject)) {
195+
return true;
196+
}
197+
return false;
198+
})[0];
199+
200+
if (dropElement) {
201+
return { container: dropElement, ref };
202+
}
203+
204+
if (canDropInFn(targetNode, dragNodeObject)) {
205+
return { container: targetNode, ref };
206+
}
207+
208+
return null;
209+
}
210+
211+
if (targetNode.isContainerNode) {
212+
if (canDropInFn(targetNode, dragNodeObject)) {
213+
return { container: targetNode, ref };
214+
}
215+
}
216+
217+
if (targetNode.parent) {
218+
return getSuitablePlaceForNode(targetNode.parent, node, { index: targetNode.index });
219+
}
220+
221+
return null;
222+
}
223+
166224
// 注册默认的 setters
167225
export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
168226
return {
@@ -426,14 +484,14 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
426484
const silbing = firstNode.prevSibling;
427485
if (silbing) {
428486
if (silbing.isContainerNode) {
429-
const place = (silbing as any)[nodeSymbol].getSuitablePlace(firstNode, null);
487+
const place = getSuitablePlaceForNode(silbing, firstNode, null);
430488
silbing.insertAfter(firstNode, place.ref, true);
431489
} else {
432490
parent.insertBefore(firstNode, silbing, true);
433491
}
434492
firstNode?.select();
435493
} else {
436-
const place = (parent as any)[nodeSymbol].getSuitablePlace(firstNode, null); // upwards
494+
const place = getSuitablePlaceForNode(parent, firstNode, null); // upwards
437495
if (place) {
438496
const container = place.container.internalToShellNode();
439497
container.insertBefore(firstNode, place.ref);
@@ -474,7 +532,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
474532
}
475533
firstNode?.select();
476534
} else {
477-
const place = (parent as any)[nodeSymbol].getSuitablePlace(firstNode, null); // upwards
535+
const place = getSuitablePlaceForNode(parent, firstNode, null); // upwards
478536
if (place) {
479537
const container = place.container.internalToShellNode();
480538
container.insertAfter(firstNode, place.ref, true);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.