-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,236 additions
and
99 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
src/MicroweberPackages/Admin/resources/views/live_edit/iframe.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html prefix="og: http://ogp.me/ns#" <?php print lang_attributes(); ?>> | ||
<head> | ||
<title></title> | ||
<title>Live edit</title> | ||
<meta charset="utf-8"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"/> | ||
|
||
@viteReactRefresh | ||
@viteReactRefresh | ||
@vite('userfiles/modules/microweber/api/live-edit-app/app.tsx') | ||
<?php print \MicroweberPackages\LiveEdit\Facades\LiveEditManager::headTags(); ?> | ||
|
||
</head> | ||
<body> | ||
<div id="live-edit-root"></div> | ||
<script> | ||
mw.quickSettings = {} | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
userfiles/modules/microweber/api/live-edit-app/components/LiveEditorFrame.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { useEffect, useRef,useState,createContext,useContext} from 'react'; | ||
|
||
import LiveEdit from '../../liveedit2/@live.js' | ||
|
||
|
||
function LiveEditor() { | ||
const frameRef = useRef(null); | ||
const frameUrl = useRef(null); | ||
const frameHolderRef = useRef(null); | ||
const [frameSrc, setFrameSrc] = useState(null); | ||
|
||
useEffect(() => { | ||
const frame = frameRef.current; | ||
const frameHolder = frameHolderRef.current; | ||
|
||
setFrameSrc(mw.settings.site_url + '/?editmode=n'); | ||
mw.spinner({ | ||
element: frameHolder, | ||
size: 52, | ||
decorate: true | ||
}); | ||
|
||
frame.addEventListener('load', function () { | ||
const doc = frame.contentWindow.document; | ||
const link = doc.createElement('link'); | ||
link.rel = 'stylesheet'; | ||
link.href = mw.settings.site_url + '/userfiles/modules/microweber/api/liveedit2/css/dist.css'; | ||
doc.head.prepend(link); | ||
|
||
var liveEdit = new LiveEdit({ | ||
root: frame.contentWindow.document.body, | ||
strict: false, | ||
mode: 'auto', | ||
document: frame.contentWindow.document | ||
}); | ||
|
||
liveEdit.moduleHandle.on('targetChange', function (target) { | ||
|
||
}); | ||
const LiveEditContext = createContext(liveEdit); | ||
|
||
|
||
// const theme = useContext(LiveEditContext); | ||
|
||
liveEdit.name = 'liveEdit'; | ||
mw.spinner({ | ||
element: frameHolder | ||
}).remove(); | ||
|
||
//window.liveEditApp.register(liveEdit); | ||
mw.trigger('LiveEdit::ready', liveEdit); | ||
}); | ||
|
||
// Clean up event listener | ||
return () => { | ||
frame.removeEventListener('load', () => { | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<div ref={frameHolderRef}></div> | ||
<iframe id="live-editor-frame" ref={frameRef} src={frameSrc}></iframe> | ||
</div> | ||
); | ||
} | ||
|
||
export default LiveEditor; |
46 changes: 46 additions & 0 deletions
46
userfiles/modules/microweber/api/live-edit-app/components/ServiceContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class ServiceContainer { | ||
private id: string; | ||
private modules: []; | ||
|
||
constructor(id: string) { | ||
this.id = id; | ||
this.modules = []; | ||
} | ||
|
||
public register(classInstance: any): void { | ||
// @ts-ignore | ||
this.modules.push(classInstance); | ||
if (typeof classInstance.init === 'function') { | ||
classInstance.init(); | ||
} | ||
} | ||
|
||
public getInstance(moduleName: string): any { | ||
return this.modules.find((module) => module.name === moduleName); | ||
} | ||
|
||
public call(moduleName: string, methodName: string, params: any): void { | ||
const module = this.getInstance(moduleName); | ||
if (module && module[methodName]) { | ||
module[methodName](params); | ||
} | ||
} | ||
|
||
public has(moduleName: string): boolean { | ||
if (this.getInstance(moduleName)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public get(moduleName: string): any { | ||
const module = this.getInstance(moduleName); | ||
if (module) { | ||
return module; | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
|
||
export default ServiceContainer; |
22 changes: 22 additions & 0 deletions
22
userfiles/modules/microweber/api/live-edit-app/components/Test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { useEffect, useRef,useState,createContext,useContext} from 'react'; | ||
|
||
const LiveEditContext = createContext(); | ||
|
||
function Test() { | ||
const frameRef = useRef(null); | ||
const frameUrl = useRef(null); | ||
const frameHolderRef = useRef(null); | ||
const [frameSrc, setFrameSrc] = useState(null); | ||
const theme = useContext(LiveEditContext); | ||
useEffect(() => { | ||
|
||
},[]); | ||
|
||
return ( | ||
<div> | ||
aaaa | ||
</div> | ||
); | ||
} | ||
|
||
export default Test; |
Oops, something went wrong.