Skip to main content
Topic: Mother f#^$king code pasting in editor. (Read 10753 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Mother f#^$king code pasting in editor.

Why, for the love of all syphilitic wombats, does SCE insist of plonking code tags around any little skerrick of code I want to put inline with a post, AND do it without asking me if I want code tags, AND bork the process anyway by throwing in pre tags instead of the correct code tags?

Sheesh. :P

The only way to get a normal post past the sucker is to switch it to bbc mode so it doesn't think for itself. Grmmph.

Steps to reproduce: not telling. This is family-friendly site. :P

For the bug itself: start typing a post in wysiwyg mode and just try (go on, I dare ya) to include a passing reference to some (any) little bit of code in the middle of a sentence.

You'll be sorry. :D

Using latest FF and W7.
Last Edit: December 30, 2012, 12:39:22 am by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #1

 emanuele haz no idea of WTF Ant is saying...
Bugs creator.
Features destroyer.
Template killer.

Re: Mother f#^$king code pasting in editor.

Reply #2

Can't just copy a bit of code elsewhere and just paste it into a sentence. Can type it, but not paste it or the thing goes bonkers.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #3

Code: [Select]
<p class="text">
[/pre]
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #4

See? :D
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #5

So if I was typing along and just wanted to include that in the middle of a sentence it would do this
Code: [Select]
<p class="text">
[/pre]
instead of just doing this <p class="text"> which is what I would want it to do.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #6

Ohh...
 Orange-kun hates WYSIWYG

So I just need to paste a piece of html here for example?

So you want to write <p class="text"> and you get the code tag?

And if I try to type <p class="text"> does it show anything unusual?
LiveGallery - Simple gallery addon for ElkArte

test

Re: Mother f#^$king code pasting in editor.

Reply #7

I think I figured out what it's doing. Should have thought of it before. Seems that if you select a tiny bit of text that is within a code block of some sort on another site, the thingy will search right up to the parent tag, then try to copy that (and sorta fail).

IMO, what would be better behaviour would be to only grab the parent tag if you copy the entre element. Presumably, if you copy the entire element you want the formatting applied, whereas if you only copy a tiny snippet from inside an element, you probably don't want the whole circus coming to town (elephants can be a problem sometimes).

Not sure if it's feasible to make thing thing smarter.

 Antechinus is not that keen in wysiwyg either.

Wysiwyg is fine about half the time, and annoying the other half.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #8

I can reproduce this when I copy code from a code block and then paste it ... SCE sees this as a code paste since thats whats on the clipboard (at least on FF and I suspect others) .... I think the pre issue is the way we put in code tags to begin with is confusing SCE

Code: [Select]
(isBrowser('gecko') || isBrowser('opera') ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . (isBrowser('gecko') || isBrowser('opera') ? '</pre>' : '')

So we wrap the code tag in pre tags for gecko and opera ... not sure why or why its not code pre pre code vs pre code code pre .... if we move the pre stuff inside the code tag I would think things would be fine.
Last Edit: December 30, 2012, 02:54:12 pm by Spuds

Re: Mother f#^$king code pasting in editor.

Reply #9

Try ditching the pre tags. I suspect that is for very old versions of Gecko and Presto, and may not be needed any more. It's been there since 1.1.x.

1.1.x code here:
Code: [Select]
' . ($context['browser']['is_gecko'] ? '<pre>$1</pre>' : '$1') . '
Last Edit: December 30, 2012, 03:19:49 pm by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #10

Hey, I just removed the pre stuff from a pre-Christmas 2.1 GitHub build, and it does code tags just fine in FF.

It's just using this:
Code: [Select]
			array(
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
// @todo Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '

ETA: Fine in Opera too. :)
Last Edit: December 30, 2012, 03:30:04 pm by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #11

Oh I see what it does. It will lose the formatting when you copy paste from a code tag to somewhere else. Bleh. :P

Ok, I switched it to this and it works:
Code: [Select]
			array(
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">' . (isBrowser('gecko') || isBrowser('opera') ? '<pre style="margin: 0; padding: 0;">$1</pre>' : '$1') . '</code>',
Figured there's no point running two ternaries when one will do the job.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #12

Cool  code pre pre code looks better  .....  ? any reason to not do that everywhere .. why just gecko and opera, seems like it would not bother the others even if they don't strictly need it.

Re: Mother f#^$king code pasting in editor.

Reply #13

Yeah good point. Never thought of that, but it makes sense semantically so why run a ternary for the bugger? Go for it. :)

Oh and I can't see any point in the inline styles on the pre tag. Probably wont need them, but if it does it's better in the css.
Last Edit: December 30, 2012, 05:37:15 pm by Antechinus
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Mother f#^$king code pasting in editor.

Reply #14

Bugger. pre inside code is not valid HTML.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P