Skip to content

Commit 0702b57

Browse files
committed
fix: tinyMCE form fields types handling issue
1 parent 378333c commit 0702b57

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

frontend-dev/src/components/Utilities/TinyMCE.jsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export default function TinyMCE({
2222

2323
useEffect(() => {
2424
if (!show && window?.tinymce?.get(editorId)) {
25-
window.tinymce.get(editorId).remove();
25+
window.tinymce.get(editorId).remove()
2626
} else if (typeof tinymce !== 'undefined') {
2727
timyMceInit()
2828
} else {
2929
console.warn('TinyMCE is not loaded yet')
3030
}
3131
}, [show])
3232

33-
const insertFieldKey = (fld) => {
33+
const insertFieldKey = fld => {
3434
if (fld.type === 'signature') {
3535
return `<img width="250" src="\${${fld.name}}" alt="${fld.name}" />`
3636
}
@@ -69,8 +69,8 @@ export default function TinyMCE({
6969
type: 'menubutton',
7070
icon: false,
7171
menu: formFields?.map(
72-
(i) =>
73-
!i.type.match(/^(file-up|recaptcha|section|divider|image|advanced-file-up|)$/) && {
72+
i =>
73+
!i?.type?.match(/^(file-up|recaptcha|section|divider|image|advanced-file-up|)$/) && {
7474
text: i.name,
7575
onClick() {
7676
editor.insertContent(insertFieldKey(i))
@@ -84,7 +84,7 @@ export default function TinyMCE({
8484
tooltip: 'Add Smart Tag Field Value in Message',
8585
type: 'menubutton',
8686
icon: false,
87-
menu: SmartTagField?.map((i) => ({
87+
menu: SmartTagField?.map(i => ({
8888
text: i.label,
8989
onClick() {
9090
editor.insertContent(`\${${i.name}}`)
@@ -118,13 +118,17 @@ export default function TinyMCE({
118118
}
119119
}
120120

121-
return show && <textarea
122-
id={editorId}
123-
className="btcd-paper-inp mt-1 w-10"
124-
rows={5}
125-
value={value}
126-
onChange={(ev) => onChangeHandler(ev.target.value)}
127-
style={{ width: '95.5%', height: 'auto' }}
128-
disabled={disabled}
129-
/>
121+
return (
122+
show && (
123+
<textarea
124+
id={editorId}
125+
className="btcd-paper-inp mt-1 w-10"
126+
rows={5}
127+
value={value}
128+
onChange={ev => onChangeHandler(ev.target.value)}
129+
style={{ width: '95.5%', height: 'auto' }}
130+
disabled={disabled}
131+
/>
132+
)
133+
)
130134
}

0 commit comments

Comments
 (0)