[add] sui page render wrapper option
This commit is contained in:
parent
0318a2e525
commit
5e3fc81d09
3 changed files with 22 additions and 1 deletions
|
|
@ -197,6 +197,10 @@ func (page *Page) BuildHTML(option *BuildOption) (string, error) {
|
|||
|
||||
html := string(page.Codes.HTML.Code)
|
||||
|
||||
if option.WithWrapper {
|
||||
html = fmt.Sprintf("<body>%s</body>", html)
|
||||
}
|
||||
|
||||
if !option.IgnoreDocument {
|
||||
html = string(page.Document)
|
||||
if page.Codes.HTML.Code != "" {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) {
|
|||
SSR: true,
|
||||
IgnoreAssetRoot: true,
|
||||
IgnoreDocument: true,
|
||||
WithWrapper: true,
|
||||
KeepPageTag: true,
|
||||
})
|
||||
|
||||
|
|
@ -59,10 +60,25 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) {
|
|||
res.Warnings = append(res.Warnings, warnings...)
|
||||
}
|
||||
|
||||
res.HTML, err = doc.Html()
|
||||
// Block save event
|
||||
// jsCode := `
|
||||
// console.log("hello ifrme")
|
||||
// document.addEventListener('keydown', function (event) {
|
||||
// const isCtrlOrCmdPressed = event.ctrlKey || event.metaKey;
|
||||
// const isSPressed = event.key === 's';
|
||||
// if (isCtrlOrCmdPressed && isSPressed) {
|
||||
// event.preventDefault();
|
||||
// console.log('Control/Command + S pressed in iframe! Default save behavior prevented.');
|
||||
// }
|
||||
// });
|
||||
// `
|
||||
// jsCode := ` console.log("hello ifrme")`
|
||||
// doc.Find("body").AppendHtml(`<script language="javascript">` + jsCode + `</script>`)
|
||||
res.HTML, err = doc.Find("body").Html()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// fmt.Println(res.HTML)
|
||||
|
||||
var data Data = nil
|
||||
if page.Codes.DATA.Code != "" {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ type BuildOption struct {
|
|||
AssetRoot string `json:"asset_root,omitempty"`
|
||||
IgnoreAssetRoot bool `json:"ignore_asset_root,omitempty"`
|
||||
IgnoreDocument bool `json:"ignore_document,omitempty"`
|
||||
WithWrapper bool `json:"with_wrapper,omitempty"`
|
||||
KeepPageTag bool `json:"keep_page_tag,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue