-
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.
Bundle everything in one property
- Loading branch information
Showing
13 changed files
with
172 additions
and
212 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 |
---|---|---|
@@ -1,39 +1,103 @@ | ||
import React from "react"; | ||
import { Button, Icon, Label } from "@neos-project/react-ui-components"; | ||
import I18n from "@neos-project/neos-ui-i18n"; | ||
import { Button, Icon, TextArea } from "@neos-project/react-ui-components"; | ||
import { neos } from "@neos-project/neos-ui-decorators"; | ||
import Markdown from "markdown-to-jsx"; | ||
|
||
const neosifier = neos((globalRegistry) => ({ | ||
i18nRegistry: globalRegistry.get("i18n"), | ||
})); | ||
|
||
const defaultOptions = { | ||
// General options | ||
disabled: false, | ||
|
||
// TextArea options | ||
showTextarea: true, | ||
maxlength: null, | ||
readonly: false, | ||
placeholder: "", | ||
minRows: 2, | ||
maxRows: 24, | ||
expandedRows: 6, | ||
help: "Garagist.Mautic:NodeTypes.Mixin.Email:properties.mauticPreviewText.options.help", | ||
|
||
// This is for the Button and the iframe | ||
// If src is null, the button will not show up | ||
showButton: true, | ||
src: null, | ||
icon: "paper-plane", | ||
name: "email-module", | ||
moduleLabel: "Garagist.Mautic:NodeTypes.Mixin.Email:properties.mauticPreviewText.options.moduleLabel", | ||
|
||
// Description text below everything | ||
showDescription: true, | ||
description: "Garagist.Mautic:NodeTypes.Mixin.Email:properties.mauticPreviewText.options.description", | ||
}; | ||
|
||
const markdownStyle = (opacity = null) => ({ | ||
fontSize: "var(--fontSize-Small)", | ||
lineHeight: 1.3, | ||
opacity, | ||
}); | ||
|
||
function EmailModuleEditor(props) { | ||
const { label, className, identifier, options, renderHelpIcon, renderSecondaryInspector } = props; | ||
const { src, icon, name, disabled} = options; | ||
const { id, value, commit, className, identifier, options, renderSecondaryInspector, i18nRegistry } = props; | ||
const CONFIG = { ...defaultOptions, ...options }; | ||
const { disabled, src, icon, help, description, moduleLabel, placeholder } = CONFIG; | ||
|
||
return ( | ||
<div style={{display:"flex"}}> | ||
<Label htmlFor={identifier}> | ||
<Button | ||
className={className} | ||
disabled={disabled} | ||
style="lighter" | ||
onClick={() => { | ||
renderSecondaryInspector("IFRAME", () => ( | ||
<iframe | ||
style={{ height: "100%", width: "100%", border: 0 }} | ||
name={name || "email-module"} | ||
src={ | ||
src.startsWith("ClientEval:") | ||
? (0, eval)(src.replace("ClientEval:", "")) | ||
: src | ||
} | ||
/> | ||
)) | ||
}} | ||
> | ||
{icon && <Icon icon={icon} padded="right" />} | ||
<I18n id={label} /> | ||
</Button> | ||
</Label> | ||
{renderHelpIcon && renderHelpIcon()} | ||
</div> | ||
<> | ||
{CONFIG.showTextarea && ( | ||
<> | ||
<TextArea | ||
id={id} | ||
value={value === null ? "" : value} | ||
className={className} | ||
onChange={commit} | ||
disabled={disabled} | ||
maxLength={CONFIG.maxlength} | ||
readOnly={CONFIG.readonly} | ||
placeholder={placeholder && i18nRegistry.translate(unescape(placeholder))} | ||
minRows={CONFIG.minRows} | ||
maxRows={CONFIG.maxRows} | ||
expandedRows={CONFIG.expandedRows} | ||
/> | ||
{help && <Markdown style={markdownStyle(0.8)} children={i18nRegistry.translate(help)} />} | ||
</> | ||
)} | ||
|
||
{CONFIG.showButton && src && moduleLabel && ( | ||
<div style={{ margin: "2em 0" }}> | ||
<Button | ||
disabled={disabled} | ||
style="lighter" | ||
onClick={() => { | ||
renderSecondaryInspector("IFRAME", () => ( | ||
<iframe | ||
style={{ | ||
height: "100%", | ||
width: "100%", | ||
border: 0, | ||
}} | ||
name={CONFIG.name} | ||
src={ | ||
src.startsWith("ClientEval:") ? (0, eval)(src.replace("ClientEval:", "")) : src | ||
} | ||
/> | ||
)); | ||
}} | ||
> | ||
{icon && <Icon icon={icon} padded="right" />} | ||
<span>{i18nRegistry.translate(moduleLabel)}</span> | ||
</Button> | ||
</div> | ||
)} | ||
|
||
{CONFIG.showDescription && description && ( | ||
<Markdown style={markdownStyle()} children={i18nRegistry.translate(description)} /> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default EmailModuleEditor; | ||
export default neosifier(EmailModuleEditor); |
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.