Merge pull request #526 from trheyi/main
[add] sui page render wrapper option
This commit is contained in:
commit
e7d6cd43b9
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)
|
html := string(page.Codes.HTML.Code)
|
||||||
|
|
||||||
|
if option.WithWrapper {
|
||||||
|
html = fmt.Sprintf("<body>%s</body>", html)
|
||||||
|
}
|
||||||
|
|
||||||
if !option.IgnoreDocument {
|
if !option.IgnoreDocument {
|
||||||
html = string(page.Document)
|
html = string(page.Document)
|
||||||
if page.Codes.HTML.Code != "" {
|
if page.Codes.HTML.Code != "" {
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) {
|
||||||
SSR: true,
|
SSR: true,
|
||||||
IgnoreAssetRoot: true,
|
IgnoreAssetRoot: true,
|
||||||
IgnoreDocument: true,
|
IgnoreDocument: true,
|
||||||
|
WithWrapper: true,
|
||||||
KeepPageTag: true,
|
KeepPageTag: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -59,10 +60,25 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) {
|
||||||
res.Warnings = append(res.Warnings, warnings...)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// fmt.Println(res.HTML)
|
||||||
|
|
||||||
var data Data = nil
|
var data Data = nil
|
||||||
if page.Codes.DATA.Code != "" {
|
if page.Codes.DATA.Code != "" {
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ type BuildOption struct {
|
||||||
AssetRoot string `json:"asset_root,omitempty"`
|
AssetRoot string `json:"asset_root,omitempty"`
|
||||||
IgnoreAssetRoot bool `json:"ignore_asset_root,omitempty"`
|
IgnoreAssetRoot bool `json:"ignore_asset_root,omitempty"`
|
||||||
IgnoreDocument bool `json:"ignore_document,omitempty"`
|
IgnoreDocument bool `json:"ignore_document,omitempty"`
|
||||||
|
WithWrapper bool `json:"with_wrapper,omitempty"`
|
||||||
KeepPageTag bool `json:"keep_page_tag,omitempty"`
|
KeepPageTag bool `json:"keep_page_tag,omitempty"`
|
||||||
Namespace string `json:"namespace,omitempty"`
|
Namespace string `json:"namespace,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue