| 1 |
'use strict'; |
| 2 |
|
| 3 |
jQuery(function ($) { |
| 4 |
|
| 5 |
(function() { |
| 6 |
const targets = ['#description', '#tag-description']; // edit term + add term |
| 7 |
targets.forEach(function(sel){ |
| 8 |
const el = document.querySelector(sel); |
| 9 |
if (!el) return; |
| 10 |
|
| 11 |
// Базові налаштування CodeMirror від WP |
| 12 |
try { |
| 13 |
const settings = wp.codeEditor.defaultSettings ? _.clone(wp.codeEditor.defaultSettings) : {}; |
| 14 |
// Увімкнути markdown-режим (файли markdown.js/gfm.js вже завантажені) |
| 15 |
settings.codemirror = Object.assign({}, settings.codemirror || {}, { |
| 16 |
mode: 'gfm', // або 'markdown' |
| 17 |
lineNumbers: false, |
| 18 |
lineWrapping: true, |
| 19 |
viewportMargin: Infinity, // render all content (no inner scroll) |
| 20 |
styleActiveLine: true, |
| 21 |
matchBrackets: true, |
| 22 |
autoCloseBrackets: true, |
| 23 |
indentUnit: 2, |
| 24 |
tabSize: 2, |
| 25 |
}); |
| 26 |
wp.codeEditor.initialize(el, settings); |
| 27 |
} catch(e) { |
| 28 |
// fallback: нічого страшного, просто лишається textarea |
| 29 |
console.warn('WPCoder: failed to init markdown editor for taxonomy description', e); |
| 30 |
} |
| 31 |
}); |
| 32 |
})(); |
| 33 |
|
| 34 |
|
| 35 |
}); |