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
Comment | File | Size | Author |
---|---|---|---|
#8 | add_greek_chars.info | 218 bytes | digitalhorde |
#2 | DEFAULT.png | 36.68 KB | TimG1 |
#2 | THIRD.png | 9.96 KB | TimG1 |
#2 | SECOND.png | 9.88 KB | TimG1 |
#2 | FIRST.png | 9.91 KB | TimG1 |
Comments
Comment #1
TwoDThe 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.
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
'♣'
witharray('♣', 'Clubs')
, so the complete line becomesSay 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:
Comment #2
TimG1 CreditAttribution: TimG1 commentedThanks 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.
Produces FIRST.png. It seems that adding anything to the specialChars array will overwrite the entire character map.
Produces SECOND.png. Same here. Only Clubs.
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
Comment #3
TwoDAh, 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
as defined in the specialchars plugin file.
The translation to PHP value types is pretty straight forward:
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.
Comment #4
TimG1 CreditAttribution: TimG1 commentedHi 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
Comment #5
ericovk CreditAttribution: ericovk commentedHi,
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.
Comment #6
ericovk CreditAttribution: ericovk commentedbump
Comment #7
osmanI just had the same problem, needed to add greek characters to the "Special Characters" dialog box. And apparently this issue has the most complete solution for the problem. Even 12 months have passed, I couldn't find anything better.
So, if anyone may need to include greek characters, or any other entities that is not available in the default list could implement it like this:
tested and works with Wysiwyg 7.x-2.2+33-dev (2014-Mar-19) module + CKEditor 4.3.4.40ccd20 library.
Comment #8
digitalhorde CreditAttribution: digitalhorde commentedHey Osman,
Thank you, that solution works great, it really helped us out! I wrote it up as a module, do you think it would be worth publishing in some way so other people could find it if they search for this kind of issue? I have uploaded the .info file I used to make it accept module form but the forum won't let me upload the .module file.
Thanks again!
Comment #9
axroth CreditAttribution: axroth commentedThis works also for Drupal 8, like that:
Comment #10
david.chevillet CreditAttribution: david.chevillet commentedHello,
The solution from axroth doesn't work for me . I tried this :
$settings['editor']['formats']['full_html']['editorSettings']['specialChars'][] = array('Δ' , 'Delta');
But all the data from specialChar was delete and replace by Delta only.
Have you an idea why i can't just add my spacial character just after the default data ?
More other i dump
$settings['editor']['formats']['full_html']['editorSettings']['specialChars']
just before push my data and the result is null.My website is on 8.3x.
Comment #11
TwoD@axroth, @david.chevillet: This module was only an inspiration for the Editor module in D8 Core, other than that it's completely unrelated. Please check the D8 documentation for its hooks as their usage may differ from Wysiwyg's.
Comment #12
david.chevillet CreditAttribution: david.chevillet commentedThanks TwoD.
I found this module https://www.drupal.org/project/ckeditor_specialchars, that works for me. But firefox remove my non-breaking space in wysiwyg, but it's an other problem.
Comment #13
XorunaFor those like me who wonder how to add special characters without having to create a submodule, you have to edit the file "ckeditor.js" in the ckeditor library folder (I'm using drupal 7 and ckeditor 4.9.2).