forked from knadh/listmonk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added preview component with preview support for campaigns and templates
- Loading branch information
Showing
12 changed files
with
201 additions
and
86 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react" | ||
import { Modal } from "antd" | ||
import * as cs from "./constants" | ||
|
||
class ModalPreview extends React.PureComponent { | ||
makeForm(body) { | ||
let form = document.createElement("form") | ||
form.method = cs.MethodPost | ||
form.action = this.props.previewURL | ||
form.target = "preview-iframe" | ||
|
||
let input = document.createElement("input") | ||
input.type = "hidden" | ||
input.name = "body" | ||
input.value = body | ||
form.appendChild(input) | ||
document.body.appendChild(form) | ||
form.submit() | ||
} | ||
|
||
render () { | ||
return ( | ||
<Modal visible={ true } title={ this.props.title } | ||
className="preview-modal" | ||
width="90%" | ||
height={ 900 } | ||
onCancel={ this.props.onCancel } | ||
onOk={ this.props.onCancel }> | ||
<div className="preview-iframe-container"> | ||
<iframe title={ this.props.title ? this.props.title : "Preview" } | ||
name="preview-iframe" | ||
id="preview-iframe" | ||
className="preview-iframe" | ||
ref={(o) => { | ||
if(o) { | ||
// When the DOM reference for the iframe is ready, | ||
// see if there's a body to post with the form hack. | ||
if(this.props.body !== undefined | ||
&& this.props.body !== null) { | ||
this.makeForm(this.props.body) | ||
} | ||
} | ||
}} | ||
src={ this.props.previewURL ? this.props.previewURL : "about:blank" }> | ||
</iframe> | ||
|
||
</div> | ||
</Modal> | ||
|
||
) | ||
} | ||
} | ||
|
||
export default ModalPreview |
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
Oops, something went wrong.