Hello,

Sorry I feel like this is answered somewhere, but after 30 mins of diligent searching I just cannot find it.

I have my function in my module....

function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    $settings['height'] = 150;
    $settings['entities_greek'] = TRUE;
   $settings['entities_additional'] = 'quot';
  }
}

Which is loading correctly, the height does change to 150. I tried taking the code from comment #7 in #1108046: Can't Insert Special Characters WYSIWYG with CKEDITOR but I don't see greek entities or the additional quote. I've found http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.spec... which seems like I'm supposed to somehow use config.specialChars = config.specialChars.concat( [ '"', [ '’', 'Custom label' ] ] ); but somehow translated to the above Drupal/Wysiwyg function.

I've started taking stabs in the dark and tried...

$settings['specialChars.concat'] = array('clubs', 'clubs');

$settings['specialChars.concat'] = 'clubs';

$settings['specialChars'] = 'clubs';

The first two do nothing, the last one prints out c, l, u, b, s as individual characters in the character map and nothing else.

How do I go about adding a few special characters to the end?

Thanks for reading,
-Tim

Files: 
CommentFileSizeAuthor
#2 DEFAULT.png36.68 KBTimG1
#2 THIRD.png9.96 KBTimG1
#2 SECOND.png9.88 KBTimG1
#2 FIRST.png9.91 KBTimG1

Comments

Status:Active» Fixed

The first two don't work because Wysiwyg doesn't know specialChars.concat is a function (it just sets a setting called 'specialChars.concat' to a value, which never gets used).

specialChars.concat appears to be the regular array concatenation function in JavaScript, and by comparing that to the plugin code we can deduce what the setting value should actually look like.
The base appears to be a simple array of characters or HTML entities in it. If the array value is a plain string, that string is also used as the value shown to the user for that character, the label. To show a more user friendly label, we can use a nested array instead of a string. That array should in turn have two values; the character/HTML entity and the label.

Now, since we set these settings in PHP, which then gets translated to a JSON object and passed to the editor, we need to use PHP's array syntax.

<?php
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if (
$context['profile']->editor == 'ckeditor') {
   
$settings['height'] = 150;
   
$settings['entities_greek'] = TRUE;
   
$settings['entities_additional'] = array('quot');
   
$settings['specialChars'] = array('&clubs;');
  }
}
?>

That should show you the clubs entity. It printed out c, l, u, b, s earlier because a string can be treated as an array of characters.
Say you wanted to use the word "Clubs" for that entity, you'd replace '&clubs;' with array('&clubs;', 'Clubs'), so the complete line becomes
<?php
    $settings
['specialChars'] = array(
      array(
'&clubs;', 'Clubs'),
    );
?>

Say you also want the quote entities from the example, you'd be able to mix using custom lables or not, and thus do something like:

<?php
    $settings
['specialChars'] = array(
      array(
'&clubs;', 'Clubs label'),
     
"'",
      array(
'"', 'Double quote label'),
    );
?>

Status:Fixed» Active
StatusFileSize
new9.91 KB
new9.88 KB
new9.96 KB
new36.68 KB

Thanks for that TwoD.

I tried your three example codes to see what is produced. I've attached the output in attached screenshots FIRST, SECOND, and THIRD.

<?php
    $settings
['entities_greek'] = TRUE;
   
$settings['entities_additional'] = array('quot');
   
$settings['specialChars'] = array('&clubs;');
?>

Produces FIRST.png. It seems that adding anything to the specialChars array will overwrite the entire character map.

<?php
    $settings
['specialChars'] = array(
      array(
'&clubs;', 'Clubs'),
    );
?>

Produces SECOND.png. Same here. Only Clubs.

<?php
    $settings
['specialChars'] = array(
      array(
'&clubs;', 'Clubs label'),
     
"'",
      array(
'"', 'Double quote label'),
    );
?>

Produces THIRD.png. All three characters. I could rebuild the character map using this method. But is it possible to just add a character to the end of the default character map without rebuilding? Basically just add the clubs character to the end of the attached DEFAULT.png so it appears right after the Almost Equal To ≈ sign. I tried using entities_additional but that doesn't seem to change anything at all.

Thanks again,
-Tim

Ah, sorry, I should have been more clear on that setting a value like this will overwrite the setting's default value.
Now, there's currently no list of the default values for each editor setting in Wysiwyg (huge amount of data to keep updated for each version), so you'll have to include these when you override the setting.

So, yes, you'll need to rebuild the complete character map.

The default value of specialChars is

specialChars = [
  '!','"','#','$','%','&',"'",'(',')','*','+','-','.','/',
  '0','1','2','3','4','5','6','7','8','9',':',';',
  '<','=','>','?','@',
  'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
  'P','Q','R','S','T','U','V','W','X','Y','Z',
  '[',']','^','_','`',
  'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
  'q','r','s','t','u','v','w','x','y','z',
  '{','|','}','~',
  "€", "‘", "’", "“", "”", "–", "—", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "®", "¯", "°", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "Œ", "œ", "Ŵ", "Ŷ", "ŵ", "ŷ", "‚", "‛", "„", "…", "™", "►", "•", "→", "⇒", "⇔", "♦", "≈"
];

as defined in the specialchars plugin file.

The translation to PHP value types is pretty straight forward:

<?php
$settings
['specialChars'] = array(
 
'!','"','#','$','%','&',"'",'(',')','*','+','-','.','/',
 
'0','1','2','3','4','5','6','7','8','9',':',';',
 
'<','=','>','?','@',
 
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
 
'P','Q','R','S','T','U','V','W','X','Y','Z',
 
'[',']','^','_','`',
 
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
 
'q','r','s','t','u','v','w','x','y','z',
 
'{','|','}','~',
 
"€", "‘", "’", "“", "”", "–", "—", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "®", "¯", "°", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "Œ", "œ", "Ŵ", "Ŷ", "ŵ", "ŷ", "‚", "‛", "„", "…", "™", "►", "•", "→", "⇒", "⇔", "♦", "≈", '&clubs;',
);
?>

The positive side is at least that you can now reorder or remove the characters you don't need.
Note: There may be slight differences in how PHP interprets these characters compared to JavaScript, so maybe some of them have to be replaced. I think the character encoding settings Drupal enforces should make all these work, but I can't guarantee it.

Status:Active» Closed (works as designed)

Hi TwoD,

Ah okay. Thanks for the default character map and explanation. Now I know what needs to be done and can move forward. =)

Thanks again,
-Tim

Hi,

I am trying to add Greek characters to the Ckeditor special character map, but it is not working at all.
Did you write your own module to accomplish this? My develop skill are not that advanced.

bump