|
257 | 257 | var profiles = window.eTinyMCEProfiles || {}; |
258 | 258 | var defaultKey = cfg.defaultProfile || ''; |
259 | 259 |
|
260 | | - function normalizePluginList(value) { |
261 | | - if (Array.isArray(value)) { |
262 | | - return value.slice(); |
263 | | - } |
264 | | - if (typeof value === 'string') { |
265 | | - return value.split(/[\\s,]+/).filter(Boolean); |
266 | | - } |
267 | | - return []; |
268 | | - } |
269 | | - |
270 | | - function ensurePlugin(options, pluginName) { |
271 | | - var list = normalizePluginList(options.plugins); |
272 | | - if (list.indexOf(pluginName) === -1) { |
273 | | - list.push(pluginName); |
274 | | - } |
275 | | - options.plugins = list.join(' '); |
276 | | - } |
277 | | - |
278 | | - function ensureExternalPlugin(options, name, url) { |
279 | | - if (!url) { |
280 | | - return; |
281 | | - } |
282 | | - var external = options.external_plugins; |
283 | | - if (!external || typeof external !== 'object') { |
284 | | - external = {}; |
285 | | - } |
286 | | - if (!external[name]) { |
287 | | - external[name] = url; |
288 | | - } |
289 | | - options.external_plugins = external; |
290 | | - } |
291 | | - |
292 | 260 | queue.forEach(function (item) { |
293 | 261 | var profileKey = item.profile; |
294 | 262 | if (!profiles[profileKey]) { |
|
301 | 269 | } |
302 | 270 | } |
303 | 271 |
|
304 | | - var profileOptions = Object.assign({}, profiles[profileKey] || {}); |
305 | | - var evolinksDefaults = { |
306 | | - searchUrl: normalizedBaseUrl + '/assets/plugins/eTinyMCE/connectors/evolinks-search.php', |
307 | | - minChars: 2, |
308 | | - debounce: 250, |
309 | | - limit: 10, |
310 | | - outputMode: 'placeholder', |
311 | | - includeUnpublished: false, |
312 | | - enableTree: true, |
313 | | - cacheSize: 20 |
314 | | - }; |
315 | | - |
316 | | - var evolinksOverrides = {}; |
317 | | - if (profileOptions.evolinks && typeof profileOptions.evolinks === 'object') { |
318 | | - evolinksOverrides = Object.assign({}, profileOptions.evolinks); |
319 | | - } |
320 | | - if (item.options && item.options.evolinks && typeof item.options.evolinks === 'object') { |
321 | | - evolinksOverrides = Object.assign(evolinksOverrides, item.options.evolinks); |
322 | | - } |
323 | | - profileOptions.evolinks = Object.assign({}, evolinksDefaults, evolinksOverrides); |
| 272 | + var profileOptions = profiles[profileKey] || {}; |
324 | 273 | var baseOptions = { |
325 | 274 | selector: item.selectors, |
326 | 275 | file_picker_callback: window.eTinyMCEFilePicker, |
|
329 | 278 | }; |
330 | 279 |
|
331 | 280 | var initOptions = Object.assign({}, profileOptions, item.options || {}, baseOptions); |
332 | | - var evolinksUrl = normalizedBaseUrl + '/assets/plugins/eTinyMCE/js/evolinks/plugin.js'; |
333 | | - ensureExternalPlugin(initOptions, 'evolinks', evolinksUrl); |
334 | | - ensurePlugin(initOptions, 'evolinks'); |
335 | 281 | tinymce.init(initOptions); |
336 | 282 | }); |
337 | 283 | })(); |
0 commit comments