Newer
Older
import { Editor } from '@tinymce/tinymce-react'
import React from 'react'
onSave: () => Promise<void>
onCancel: () => void
header: string
quote: string
handleChange: (
value: string,
type: 'header' | 'quote' | 'question' | 'link'
) => void
}
const MonthlyNews: React.FC<MonthlyNewsProps> = ({
onSave,
onCancel,
header,
quote,
handleChange,
}: MonthlyNewsProps) => {
return (
<>
<div className="subtitle">
<p className="title">Informations du mois</p>
</div>
<div>
<Editor
init={{
menubar: false,
toolbar:
'undo redo | bold italic underline | alignleft aligncenter alignright | code | ecolyoLink',
}}
value={header}
onEditorChange={(newHeader: string) =>
handleChange(newHeader, 'header')
}
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/>
<div className="subtitle">
<p className="title">Citation du mois</p>
</div>
<Editor
init={{
menubar: false,
toolbar:
'undo redo | bold italic underline | alignleft aligncenter alignright | code | ecolyoLink',
setup: function (editor) {
editor.ui.registry.addMenuButton('ecolyoLink', {
text: 'Lien Ecolyo',
fetch: function (callback) {
var items: any = [
{
type: 'menuitem',
text: 'consumption',
onAction: function () {
editor.insertContent(
' <a href="https://ecolyo.{cozyUrl}/consumption">Page de consommation</a>'
)
},
},
{
type: 'menuitem',
text: 'challenges',
onAction: function () {
editor.insertContent(
' <a href="https://ecolyo.{cozyUrl}/challenges">Page challenges</a>'
)
},
},
{
type: 'menuitem',
text: 'ecogestures',
onAction: function () {
editor.insertContent(
' <a href="https://ecolyo.{cozyUrl}/ecogestures">Page ecogestures</a>'
)
},
},
{
type: 'menuitem',
text: 'analysis',
onAction: function () {
editor.insertContent(
' <a href="https://ecolyo.{cozyUrl}/analysis">Page analyse</a>'
)
},
},
{
type: 'menuitem',
text: 'options',
onAction: function () {
editor.insertContent(
' <a href="https://ecolyo.{cozyUrl}/options">Page options</a>'
)
},
},
]
callback(items)
},
})
},
}}
value={quote}
onEditorChange={(newQuote: string) => handleChange(newQuote, 'quote')}
<div className="buttons">
<button className="btnCancel" onClick={onCancel}>
Annuler
</button>
<button className="btnValid" onClick={onSave}>
Sauvegarder
</button>
<button className="btnDelete" onClick={() => onDelete('monthlyNews')}>
Supprimer
</button>
</div>