tinymce.PluginManager.add('charmap', function(editor) {
var charmap = [
['160', 'no-break space'],
- ['38', 'ampersand'],
+ ['173', 'soft hyphen'],
['34', 'quotation mark'],
// finance
['162', 'cent sign'],
['969', 'omega'],
// symbols
['8501', 'alef symbol'],
- ['982', 'pi symbol'],
+ ['982', 'pi symbol'],
['8476', 'real part symbol'],
- ['978', 'upsilon - hook symbol'],
+ ['978', 'upsilon - hook symbol'],
['8472', 'Weierstrass p'],
['8465', 'imaginary part'],
// arrows
['8204', 'zero width non-joiner'],
['8205', 'zero width joiner'],
['8206', 'left-to-right mark'],
- ['8207', 'right-to-left mark'],
- ['173', 'soft hyphen']
+ ['8207', 'right-to-left mark']
];
function showDialog() {
gridHtml = '<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>';
var width = 25;
- for (y = 0; y < 10; y++) {
+ var height = Math.ceil(charmap.length / width);
+ for (y = 0; y < height; y++) {
gridHtml += '<tr>';
for (x = 0; x < width; x++) {
- var chr = charmap[y * width + x];
+ var index = y * width + x;
+ if (index < charmap.length) {
+ var chr = charmap[index];
- gridHtml += '<td title="' + chr[1] + '"><div tabindex="-1" title="' + chr[1] + '" role="button">' +
- (chr ? String.fromCharCode(parseInt(chr[0], 10)) : ' ') + '</div></td>';
+ gridHtml += '<td title="' + chr[1] + '"><div tabindex="-1" title="' + chr[1] + '" role="button">' +
+ (chr ? String.fromCharCode(parseInt(chr[0], 10)) : ' ') + '</div></td>';
+ } else {
+ gridHtml += '<td />';
+ }
}
gridHtml += '</tr>';
onclick: function(e) {
var target = e.target;
if (/^(TD|DIV)$/.test(target.nodeName)) {
- editor.execCommand('mceInsertContent', false, tinymce.trim(target.innerText || target.textContent));
+ if (getParentTd(target).firstChild) {
+ editor.execCommand('mceInsertContent', false, tinymce.trim(target.innerText || target.textContent));
- if (!e.ctrlKey) {
- win.close();
+ if (!e.ctrlKey) {
+ win.close();
+ }
}
}
},
onmouseover: function(e) {
var td = getParentTd(e.target);
- if (td) {
+ if (td && td.firstChild) {
win.find('#preview').text(td.firstChild.firstChild.data);
+ win.find('#previewTitle').text(td.title);
+ } else {
+ win.find('#preview').text(' ');
+ win.find('#previewTitle').text(' ');
}
}
};
items: [
charMapPanel,
{
- type: 'label',
- name: 'preview',
- text: ' ',
- style: 'font-size: 40px; text-align: center',
- border: 1,
- minWidth: 100,
- minHeight: 80
+ type: 'container',
+ layout: 'flex',
+ direction: 'column',
+ align: 'center',
+ spacing: 5,
+ minWidth: 160,
+ minHeight: 160,
+ items: [
+ {
+ type: 'label',
+ name: 'preview',
+ text: ' ',
+ style: 'font-size: 40px; text-align: center',
+ border: 1,
+ minWidth: 140,
+ minHeight: 80
+ },
+ {
+ type: 'label',
+ name: 'previewTitle',
+ text: ' ',
+ style: 'text-align: center',
+ border: 1,
+ minWidth: 140,
+ minHeight: 80
+ }
+ ]
}
],
buttons: [