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

Function liveEditingRule

packages/engine/src/modules/live-editing.ts:22–44  ·  view source on GitHub ↗
(target: EditingTarget)

Source from the content-addressed store, hash-verified

20}
21
22export function liveEditingRule(target: EditingTarget) {
23 // for vision components specific
24 const { node, event } = target;
25
26 const targetElement = event.target as HTMLElement;
27
28 if (!Array.from(targetElement.childNodes).every((item) => item.nodeType === Node.TEXT_NODE)) {
29 return null;
30 }
31
32 const { innerText } = targetElement;
33 const propTarget = ['title', 'label', 'text', 'content', 'children'].find((prop) => {
34 return equalText(getText(node, prop), innerText);
35 });
36
37 if (propTarget) {
38 return {
39 propElement: targetElement,
40 propTarget,
41 };
42 }
43 return null;
44}
45
46function equalText(v: any, innerText: string) {
47 // TODO: enhance compare text logic

Callers

nothing calls this directly

Calls 5

equalTextFunction · 0.85
getTextFunction · 0.85
everyMethod · 0.65
fromMethod · 0.65
findMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…