Commit | Line | Data |
---|---|---|
ed3f188f | 1 | <script data-relocate="true"> |
e709be77 AE |
2 | head.load([ |
3 | {if ENABLE_DEBUG_MODE} | |
4 | {* Imperavi *} | |
5 | '{@$__wcf->getPath()}js/3rdParty/redactor2/redactor.js?v={@LAST_UPDATE_TIME}', | |
6 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/alignment.js?v={@LAST_UPDATE_TIME}', | |
7 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/source.js?v={@LAST_UPDATE_TIME}', | |
8 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/table.js?v={@LAST_UPDATE_TIME}', | |
9 | ||
10 | {* WoltLab *} | |
dcb74ba6 | 11 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAlignment.js?v={@LAST_UPDATE_TIME}', |
e709be77 | 12 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAttachment.js?v={@LAST_UPDATE_TIME}', |
21b3c837 | 13 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAutosave.js?v={@LAST_UPDATE_TIME}', |
eb104f97 | 14 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabBlock.js?v={@LAST_UPDATE_TIME}', |
e709be77 | 15 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabButton.js?v={@LAST_UPDATE_TIME}', |
5a7a1cd8 | 16 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabCaret.js?v={@LAST_UPDATE_TIME}', |
d809bfdd | 17 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabClean.js?v={@LAST_UPDATE_TIME}', |
eb104f97 | 18 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabCode.js?v={@LAST_UPDATE_TIME}', |
e709be77 AE |
19 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabColor.js?v={@LAST_UPDATE_TIME}', |
20 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabDropdown.js?v={@LAST_UPDATE_TIME}', | |
21 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabEvent.js?v={@LAST_UPDATE_TIME}', | |
22 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabImage.js?v={@LAST_UPDATE_TIME}', | |
eb104f97 | 23 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInlineCode.js?v={@LAST_UPDATE_TIME}', |
d809bfdd | 24 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInsert.js?v={@LAST_UPDATE_TIME}', |
8399847c | 25 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabKeydown.js?v={@LAST_UPDATE_TIME}', |
e709be77 AE |
26 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabLink.js?v={@LAST_UPDATE_TIME}', |
27 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}', | |
28 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}', | |
29 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabModal.js?v={@LAST_UPDATE_TIME}', | |
0ce51dff | 30 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabPaste.js?v={@LAST_UPDATE_TIME}', |
e709be77 AE |
31 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}', |
32 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}', | |
eb104f97 | 33 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}', |
d809bfdd | 34 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSource.js?v={@LAST_UPDATE_TIME}', |
8dbbbdef AE |
35 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSpoiler.js?v={@LAST_UPDATE_TIME}', |
36 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabUtils.js?v={@LAST_UPDATE_TIME}' | |
e709be77 AE |
37 | {else} |
38 | '{@$__wcf->getPath()}js/3rdParty/redactor2/redactor.min.js?v={@LAST_UPDATE_TIME}', | |
39 | '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/combined.min.js?v={@LAST_UPDATE_TIME}' | |
ed3f188f | 40 | {/if} |
c540a503 AE |
41 | |
42 | {if $__redactorJavaScript|isset}{@$__redactorJavaScript}{/if} | |
c516794d | 43 | {assign var=__redactorJavaScript value=''} |
c540a503 AE |
44 | |
45 | {event name='redactorJavaScript'} | |
e709be77 | 46 | ], function () { |
58d7e8f8 | 47 | require(['Language', 'WoltLabSuite/Core/Ui/Redactor/Autosave', 'WoltLabSuite/Core/Ui/Redactor/Metacode'], function(Language, UiRedactorAutosave, UiRedactorMetacode) { |
7d753078 | 48 | Language.addObject({ |
eb104f97 AE |
49 | 'wcf.editor.code.edit': '{lang}wcf.editor.code.edit{/lang}', |
50 | 'wcf.editor.code.file': '{lang}wcf.editor.code.file{/lang}', | |
51 | 'wcf.editor.code.file.description': '{lang}wcf.editor.code.file.description{/lang}', | |
52 | 'wcf.editor.code.highlighter': '{lang}wcf.editor.code.highlighter{/lang}', | |
53 | 'wcf.editor.code.highlighter.description': '{lang}wcf.editor.code.highlighter.description{/lang}', | |
54 | 'wcf.editor.code.highlighter.detect': '{lang}wcf.editor.code.highlighter.detect{/lang}', | |
55 | 'wcf.editor.code.line': '{lang}wcf.editor.code.line{/lang}', | |
56 | 'wcf.editor.code.line.description': '{lang}wcf.editor.code.line.description{/lang}', | |
57 | 'wcf.editor.code.title': '{lang __literal=true}wcf.editor.code.title{/lang}', | |
58 | ||
7d753078 AE |
59 | 'wcf.editor.image.edit': '{lang}wcf.editor.image.edit{/lang}', |
60 | 'wcf.editor.image.insert': '{lang}wcf.editor.image.insert{/lang}', | |
61 | 'wcf.editor.image.link': '{lang}wcf.editor.image.link{/lang}', | |
62 | 'wcf.editor.image.link.error.invalid': '{lang}wcf.editor.image.link.error.invalid{/lang}', | |
63 | 'wcf.editor.image.float': '{lang}wcf.editor.image.float{/lang}', | |
64 | 'wcf.editor.image.float.left': '{lang}wcf.editor.image.float.left{/lang}', | |
65 | 'wcf.editor.image.float.right': '{lang}wcf.editor.image.float.right{/lang}', | |
66 | 'wcf.editor.image.source': '{lang}wcf.editor.image.source{/lang}', | |
eb104f97 AE |
67 | 'wcf.editor.image.source.error.invalid': '{lang}wcf.editor.image.source.error.invalid{/lang}', |
68 | ||
69 | 'wcf.editor.link.add': '{lang}wcf.editor.link.add{/lang}', | |
70 | 'wcf.editor.link.edit': '{lang}wcf.editor.link.edit{/lang}', | |
71 | 'wcf.editor.link.url': '{lang}wcf.editor.link.url{/lang}', | |
72 | 'wcf.editor.link.text': '{lang}wcf.editor.link.text{/lang}', | |
73 | ||
74 | 'wcf.editor.quote.author': '{lang}wcf.editor.quote.author{/lang}', | |
75 | 'wcf.editor.quote.edit': '{lang}wcf.editor.quote.edit{/lang}', | |
76 | 'wcf.editor.quote.title': '{lang __literal=true}wcf.editor.quote.title{/lang}', | |
77 | 'wcf.editor.quote.url': '{lang}wcf.editor.quote.url{/lang}', | |
78 | 'wcf.editor.quote.url.description': '{lang}wcf.editor.quote.url.description{/lang}', | |
21b3c837 | 79 | 'wcf.editor.quote.url.error.invalid': '{lang}wcf.editor.quote.url.error.invalid{/lang}', |
eb104f97 AE |
80 | |
81 | 'wcf.editor.spoiler.label': '{lang}wcf.editor.spoiler.label{/lang}', | |
82 | 'wcf.editor.spoiler.label.description': '{lang}wcf.editor.spoiler.label.description{/lang}', | |
83 | 'wcf.editor.spoiler.edit': '{lang}wcf.editor.spoiler.edit{/lang}', | |
84 | 'wcf.editor.spoiler.title': '{lang __literal=true}wcf.editor.spoiler.title{/lang}' | |
7d753078 AE |
85 | }); |
86 | ||
8399847c | 87 | var buttons = [], buttonMobile = [], buttonOptions = [], customButtons = []; |
e709be77 AE |
88 | {include file='wysiwygToolbar'} |
89 | ||
eb104f97 AE |
90 | var highlighters = { {implode from=$__wcf->getBBCodeHandler()->getHighlighters() item=__highlighter}'{$__highlighter}': '{lang}wcf.bbcode.code.{@$__highlighter}.title{/lang}'{/implode} }; |
91 | ||
e709be77 AE |
92 | {include file='mediaJavaScript'} |
93 | ||
94 | var element = elById('{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}'); | |
95 | UiRedactorMetacode.convert(element); | |
96 | ||
21b3c837 | 97 | var autosave = elData(element, 'autosave') || null; |
e709be77 | 98 | if (autosave) { |
21b3c837 AE |
99 | autosave = new UiRedactorAutosave(element); |
100 | element.value = autosave.getInitialValue(); | |
e709be77 AE |
101 | } |
102 | ||
103 | var config = { | |
104 | buttons: buttons, | |
eb104f97 | 105 | formatting: ['p', 'h2', 'h3', 'h4'], |
e709be77 | 106 | imageCaption: false, |
eb104f97 AE |
107 | lang: 'wsc', // fake language to offload phrases |
108 | langs: { | |
109 | wsc: { | |
8399847c AE |
110 | // general |
111 | edit: '{lang}wcf.global.button.edit{/lang}', | |
112 | ||
eb104f97 AE |
113 | // formatting dropdown |
114 | heading2: '{lang}wcf.editor.format.heading2{/lang}', | |
115 | heading3: '{lang}wcf.editor.format.heading3{/lang}', | |
116 | heading4: '{lang}wcf.editor.format.heading4{/lang}', | |
117 | paragraph: '{lang}wcf.editor.format.paragraph{/lang}', | |
118 | ||
8399847c AE |
119 | // links |
120 | 'link-edit': '{lang}wcf.editor.link.edit{/lang}', | |
121 | 'link-insert': '{lang}wcf.editor.link.add{/lang}', | |
122 | unlink: '{lang}wcf.editor.link.unlink{/lang}', | |
123 | ||
124 | // text alignment | |
dcb74ba6 AE |
125 | 'align-center': '{lang}wcf.editor.alignment.center{/lang}', |
126 | 'align-justify': '{lang}wcf.editor.alignment.justify{/lang}', | |
127 | 'align-left': '{lang}wcf.editor.alignment.left{/lang}', | |
128 | 'align-right': '{lang}wcf.editor.alignment.right{/lang}', | |
129 | ||
eb104f97 AE |
130 | // table plugin |
131 | 'add-head': '{lang}wcf.editor.table.addHead{/lang}', | |
132 | 'delete-column': '{lang}wcf.editor.table.deleteColumn{/lang}', | |
133 | 'delete-head': '{lang}wcf.editor.table.deleteHead{/lang}', | |
134 | 'delete-row': '{lang}wcf.editor.table.deleteRow{/lang}', | |
135 | 'delete-table': '{lang}wcf.editor.table.deleteTable{/lang}', | |
136 | 'insert-table': '{lang}wcf.editor.table.insertTable{/lang}', | |
137 | 'insert-column-left': '{lang}wcf.editor.table.insertColumnLeft{/lang}', | |
138 | 'insert-column-right': '{lang}wcf.editor.table.insertColumnRight{/lang}', | |
139 | 'insert-row-above': '{lang}wcf.editor.table.insertRowAbove{/lang}', | |
2aadba64 AE |
140 | 'insert-row-below': '{lang}wcf.editor.table.insertRowBelow{/lang}', |
141 | ||
142 | // size | |
143 | 'remove-size': '{lang}wcf.editor.button.size.removeSize{/lang}', | |
144 | ||
145 | // color | |
d809bfdd | 146 | 'remove-color': '{lang}wcf.editor.button.color.removeColor{/lang}' |
eb104f97 AE |
147 | } |
148 | }, | |
533094eb AE |
149 | linkify: false, |
150 | linkSize: 0xBADC0DED, // some random value to disable truncating | |
e709be77 | 151 | minHeight: 200, |
d809bfdd | 152 | placeholder: elData(element, 'placeholder') || '', |
e709be77 | 153 | plugins: [ |
8399847c | 154 | // Imperavi |
e709be77 AE |
155 | 'alignment', |
156 | 'source', | |
157 | 'table', | |
8399847c AE |
158 | |
159 | // WoltLab specials | |
160 | 'WoltLabBlock', | |
161 | 'WoltLabKeydown', | |
162 | ||
163 | // WoltLab core | |
dcb74ba6 | 164 | 'WoltLabAlignment', |
e709be77 | 165 | 'WoltLabAttachment', |
21b3c837 | 166 | 'WoltLabAutosave', |
5a7a1cd8 | 167 | 'WoltLabCaret', |
d809bfdd | 168 | 'WoltLabClean', |
eb104f97 | 169 | 'WoltLabCode', |
e709be77 AE |
170 | 'WoltLabColor', |
171 | 'WoltLabDropdown', | |
172 | 'WoltLabEvent', | |
173 | 'WoltLabImage', | |
eb104f97 | 174 | 'WoltLabInlineCode', |
d809bfdd | 175 | 'WoltLabInsert', |
e709be77 AE |
176 | 'WoltLabLink', |
177 | 'WoltLabModal', | |
0ce51dff | 178 | 'WoltLabPaste', |
e709be77 AE |
179 | 'WoltLabQuote', |
180 | 'WoltLabSize', | |
eb104f97 | 181 | 'WoltLabSmiley', |
d809bfdd | 182 | 'WoltLabSource', |
8dbbbdef AE |
183 | 'WoltLabSpoiler', |
184 | 'WoltLabUtils' | |
e709be77 AE |
185 | ], |
186 | toolbarFixed: false, | |
187 | woltlab: { | |
188 | autosave: autosave, | |
7d753078 | 189 | buttons: buttonOptions, |
8399847c | 190 | buttonMobile: buttonMobile, |
eb104f97 AE |
191 | customButtons: customButtons, |
192 | highlighters: highlighters | |
e709be77 AE |
193 | } |
194 | }; | |
195 | ||
196 | // user mentions | |
197 | if (elDataBool(element, 'support-mention')) { | |
198 | config.plugins.push('WoltLabMention'); | |
199 | } | |
200 | ||
201 | // media | |
202 | {if $__wcf->session->getPermission('admin.content.cms.canUseMedia')} | |
203 | config.plugins.push('WoltLabMedia'); | |
204 | {/if} | |
205 | ||
c540a503 | 206 | {if $__redactorConfig|isset}{@$__redactorConfig}{/if} |
c516794d | 207 | {assign var=__redactorConfig value=''} |
c540a503 AE |
208 | |
209 | {event name='redactorConfig'} | |
210 | ||
e5c625ac AE |
211 | // load the button plugin last to ensure all buttons have been initialized |
212 | // already and we can safely add all icons | |
213 | config.plugins.push('WoltLabButton'); | |
214 | ||
2aadba64 AE |
215 | var content = element.value; |
216 | element.value = ''; | |
217 | ||
218 | config.callbacks = config.callbacks || { }; | |
219 | config.callbacks.init = function() { | |
220 | // slight delay to allow Redactor to initialize itself | |
221 | window.setTimeout(function() { | |
222 | $(element).redactor('code.set', content); | |
223 | }, 10); | |
224 | }; | |
225 | ||
e709be77 AE |
226 | $(element).redactor(config); |
227 | }); | |
ed3f188f | 228 | }); |
ed3f188f | 229 | </script> |