nhammadi/Smileys

bored smiley appearing in URLs with autodetection

Opened this issue · 6 comments

Hi,

I have an issue where autodetection puts a smiley whenever i hate an url in the text because of the :/ in the url.

I tried to directly remove the unsure smiley from the plugin.js code without success but i'm not very familiar with tweaking tinyMCE plugins.

While your autodetect feature is working well, i have no doubt that this exact case when having an url might be a common problem amongst your users. you might want to give it a quick look and it shouldn't be much of a problem to fix for a seasoned MCE plugin coder.

Much thanks!

After some googling, i found out it's the plugin's min file that was running and i fixed it. But i still think it might be an issue for other users.

I had the same problem and here's a fix for http:// and https:// not being replaced by smilies....

At line 241 you will find this piece of code
while ((m = regex.exec(text))) { matches.push(getMatchIndexes(m, captureGroup)); }

Replace those lines with this code
`
while ((m = regex.exec(text))) {
currentMatch = getMatchIndexes(m, captureGroup);
replaceCurrentMatch = 1;
if (currentMatch[2][0] === ':/') {
if (currentMatch[0] >= 5) {
withPrevious = text.substr(currentMatch[0] - 4, currentMatch[1]);
if (withPrevious.indexOf('http:/') >= 0 || withPrevious.indexOf('ttps:/') >= 0)
replaceCurrentMatch = 0;
}
}

		if (replaceCurrentMatch > 0){
			matches.push(currentMatch);
		}
	}

`

Thanks, that's a better solution than simply removing the bored smiley from the list of smileys. I'll give this a try!

I have this implemented on a working production cakePhp app - works flawlesly for over a year...
I added the logic to check if ":/" has http or https before it... Dont know if git messed up the code I pasted, if it did - i can put the code on pastebin, just let me know....

i'll hit you up if i encounter any problem with this solution but i trust git when it comes to copy some code.
I believe it's their core business :P
I'm also innocent and filled with illusions and lord knows a programmer shouldn't make such assumptions...

Thanks for the offer! :D

please help where I made a mistake. smilies :-) If I enter it like this, nothing happens ... I have a system laravel. Code

<script type="text/javascript">
        tinymce.init({
            selector: '#description',
            language: '{{ (!empty($editorI18nJson)) ? config('app.locale') : 'en' }}',
            directionality: '{{ (config('lang.direction') == 'rtl') ? 'rtl' : 'ltr' }}',
            height: 350,
            menubar: false,
            auto_convert_smileys: true,
            statusbar: false,
            plugins: 'lists  table emoticons',
            toolbar: 'emoticons | undo redo | bold italic underline | forecolor backcolor | link unlink | alignleft aligncenter alignright | outdent indent | fontsizeselect ',
            smileys:[
      [
          { shortcut: ':-)', url: 'http://www.fbsmileys.com/wp-content/emos/smile.png', title: 'smile' },
          { shortcut: 'O:)', url: 'http://www.fbsmileys.com/wp-content/emos/angel.png', title: 'angel' },
          { shortcut: 'o.O', url: 'http://www.fbsmileys.com/wp-content/emos/confused.png', title: 'confused' },
          { shortcut: '3:)', url: 'http://www.fbsmileys.com/wp-content/emos/devil.png', title: 'devil' },
          { shortcut: ':-O', url: 'http://www.fbsmileys.com/wp-content/emos/gasp.png', title: 'gasp' },
          { shortcut: '8-)', url: 'http://www.fbsmileys.com/wp-content/emos/glasses.png', title: 'glasses' },
          { shortcut: ':-D', url: 'http://www.fbsmileys.com/wp-content/emos/grin.png', title: 'grin' }
      ]
      ]

        });
        @if (!empty($editorI18nJson))