MCPcopy Create free account
hub / github.com/ccj-007/easy-lowcode / handleEditor

Function handleEditor

src/package/editor/handler.ts:21–56  ·  view source on GitHub ↗
(json: GlobalJSON, options: { id: string })

Source from the content-addressed store, hash-verified

19}
20
21export const handleEditor = async (json: GlobalJSON, options: { id: string }) => {
22 // validator
23 if (!document || !json.content) {
24 throw new Error('exist error json or document not loaded')
25 }
26 await sleep(0)
27
28 // 对json解析找到iframe的dom,并监听事件,修改ui
29 const compJsonList = json.content
30
31 const compDOMList: HTMLElement[] = []
32 compJsonList.forEach(compJson => {
33 const compDOM = document.getElementById(compJson.id)
34 console.log(compDOM, compJson.id);
35
36 compDOM && compDOMList.push(compDOM)
37 compDOM?.addEventListener('click', () => {
38 store.cid = compDOM.id
39
40 compDOMList.forEach(item => {
41 item.style.border = ''
42 if (item.id === store.cid) {
43 item.style.border = '1px solid #006cff'
44 }
45 })
46 })
47 })
48 if (options.id) {
49 let rootDOM = document.getElementById(options.id) as HTMLElement
50 rootDOM && rootDOM.addEventListener('mouseover', (e: MouseEvent) => {
51 store.pageX = e.pageX
52 store.pageY = e.pageY
53 console.log("store position", store.pageX, store.pageY);
54 })
55 }
56}

Callers 1

initEditorFunction · 0.90

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected