MyBB Community Forums

Full Version: Copy text from any website into reply is always T1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

if i copy text from websites into post reply, it is pasted as T1 (T0?). What then looks like 

[attachment=46745]

If i copy text from a file from my computer, it is pasted as normal T4 in post reply.


So the problem seems to be with browsers/websites, not MyBB.

How can i set all text, what is copy/pasted from websites into post reply, automatically to T4 if pasted?

Thx for help.
Its carrying the source styling.
Easiest way is to put the editor in source mode (Ctrl+Shift+S) and then paste.
(2024-03-10, 06:03 PM)effone Wrote: [ -> ]Its carrying the source styling.
Easiest way is to put the editor in source mode (Ctrl+Shift+S) and then paste.

I had the same thoughts with the source styling. But (Ctrl+Shift+S) will not make the users funny, like "why i have to do this in this forum and in others not?" So i look for an "automatic" resolution.
There is an editor plugin for the behavior you desire.
I haven't played around with it though; but you can try and implement:

https://www.sceditor.com/documentation/p...plaintext/
Looks like what i want. I will try to implement it.

the sceditor documentation is such a ***** docu

I found a place in "codebuttons" where i put the "plaintext" behind the "undo" plugin

[attachment=46752]

and that works with the copy/pasted text from websites, but now my textarea isnt width=100% anymore

[attachment=46753]

how can i bring back the width?

no, this "plaintext" isnt good cause it take away all the codebuttons and also smilies dont work with it
(2024-03-10, 11:54 PM)meisme Wrote: [ -> ]Looks like what i want. I will try to implement it.

the sceditor documentation is such a ***** docu

I found a place in "codebuttons" where i put the "plaintext" behind the "undo" plugin



and that works with the copy/pasted text from websites, but now my textarea isnt width=100% anymore



how can i bring back the width?

no, this "plaintext" isnt good cause it take away all the codebuttons and also smilies dont work with it

I don't know and can't check (as I can't re-create the problem .... but I know folk who have the issue) if this will help!

I think the "Plain Text" plugin from ScEditor is not working as it is being over written by another file (same thing happening with me on a different issue).

In "bbcodes_sceditor.js" .... at line 153 (up to line 239) you will find this code which changes the default actions of sceditor:

	// Update size tag to use xx-small-xx-large instead of 1-7
	$.sceditor.formats.bbcode.set('size', {
		format: function ($elm, content) {
			var fontsize = 1,
				scefontsize = $($elm).data('scefontsize'),
				parsed = parseInt(scefontsize, 10),
				size = parseInt($($elm).attr('size'), 10),
				iframe = $('.sceditor-container iframe'),
				editor_body = $('body', iframe.contents());

			if ($($elm).css('font-size') == editor_body.css('font-size')) {
				// Eliminate redundant [size] tags for unformatted text.
				// Part of the fix for the browser-dependent bug of issue #4184.
				// Also fixes the browser-dependent bug described here:
				//   <https://community.mybb.com/thread-229726.html>
				fontsize = -1;
			} else if (!isNaN(size) && size >= 1 && size <= mybbCmd.fsStr.length) {
				fontsize = mybbCmd.fsStr[size - 1];
			} else if ($.inArray(scefontsize, mybbCmd.fsStr) !== -1) {
				fontsize = scefontsize;
			} else if (!isNaN(parsed)) {
				fontsize = parsed;
			}

			return fontsize != -1 ? '[size=' + fontsize + ']' + content + '[/size]' : content;
		},
		html: function (token, attrs, content) {
			var size = 0,
				units = "",
				parsed = parseInt(attrs.defaultattr, 10);
			if (!isNaN(parsed)) {
				size = parsed;
				if (size < 1) {
					size = 1;
				} else if (size > 50) {
					size = 50;
				}
				units = "pt";
			} else {
				var fsStrPos = $.inArray(attrs.defaultattr, mybbCmd.fsStr);
				if (fsStrPos !== -1) {
					size = attrs.defaultattr;
				}
			}
			return '<font data-scefontsize="' + $.sceditor.escapeEntities(attrs.defaultattr) + '" style="font-size: ' + size + units + ';">' + content + '</font>';
		}
	});

	$.sceditor.command.set('size', {
		_dropDown: function (editor, caller, callback) {
			var content = $('<div />'),
				clickFunc = function (e) {
					callback($(this).data('size'));
					editor.closeDropDown(true);
					e.preventDefault();
				};

			for (var i = 1; i <= 7; i++)
				content.append($('<a class="sceditor-fontsize-option" data-size="' + i + '" href="#"><font style="font-size: ' + mybbCmd.fsStr[i-1] + '">' + i + '</font></a>').on('click', clickFunc));

			editor.createDropDown(caller, 'fontsize-picker', content.get(0));
		},
		exec: function (caller) {
			var editor = this;

			$.sceditor.command.get('size')._dropDown(
				editor,
				caller,
				function (fontSize) {
					editor.execCommand('fontsize', fontSize);
				}
			);
		},
		txtExec: function (caller) {
			var editor = this;

			$.sceditor.command.get('size')._dropDown(
				editor,
				caller,
				function (size) {
					size = (~~size);
					size = (size > 7) ? 7 : ((size < 1) ? 1 : size);
					editor.insertText('[size=' + mybbCmd.fsStr[size - 1] + ']', '[/size]');
				}
			);
		}
	});

As you can see from the starting comment "Update size tag to use xx-small-xx-large instead of 1-7" .... it is changing the way the sceditor interacts with font size!

This was first introduced in MyBB version 1.8.23 but the sceditor version now in 1.8.37 is a newer version (but not the most updated) .... I think that old code is conflicting with your "Plain Text" plugin (or maybe you just won't need the plugin .... if you remove that above code from the "bbcodes_sceditor.js" file???).

I wish that I could test it but I can't make it happen to me Sad 

Please only test this out on your test forum .... just delete it from the file and see what happens (you can always paste it back in)

As said .... I can't test it but I did just remove that block of code from the file!

Before removal and viewing source mode:

[attachment=46775]

After removing the code:

[attachment=46774]

So you can see that maybe pasting in text (sometimes) is looked at incorrectly .... but I don't know lol
Had a look at this briefly, before giving it up.  As as far as I can tell, the sceditor version in MyBB is around 1.4.x.  Can't confirm that though.  The "plaintext" plugin @effone mentions, I think is sceditor version 3.x.

Either way, you'd need the associated jscript file to place in the MyBB sceditor plugin directory - I think. Confused  Looking around, even once found the file.  But never tried it, given the versioning mismatch.

Bit much for me - lol.
(2024-03-15, 04:36 PM)nixer55 Wrote: [ -> ]Had a look at this briefly, before giving it up.  As as far as I can tell, the sceditor version in MyBB is around 1.4.x.  Can't confirm that though.  The "plaintext" plugin @effone mentions, I think is sceditor version 3.x.

MyBB is being shipped with SC Editor 3.1.1
https://github.com/mybb/mybb/pull/4598
(2024-03-15, 04:36 PM)nixer55 Wrote: [ -> ]Had a look at this briefly, before giving it up.  As as far as I can tell, the sceditor version in MyBB is around 1.4.x.  Can't confirm that though.  The "plaintext" plugin @effone mentions, I think is sceditor version 3.x.

Either way, you'd need the associated jscript file to place in the MyBB sceditor plugin directory - I think. Confused  Looking around, even once found the file.  But never tried it, given the versioning mismatch.

Bit much for me - lol.

I agree .... it is well past my "pay grade" lol

I looked at all the 3442 lines of code in the "jquery.sceditor.bbcode.min.js" (once it is formatted) .... and while most of it I didn't really know what it was doing, I got a minimal idea.

The "bbcodes_sceditor.js" overwrites some of the actions of the sceditor (from what I can see).

The sceditor is a fully functional editor .... all on it's own, which can be placed into any website.

I can comprehend that back in the 1.8.22 days .... the version of sceditor needed to have some overwrites .... but with updates?? I don't know.

And I can't get an answer in my thread as yet!

There is code in there which seems to not be needed now but which is restricting functionality?

I don't know Big Grin 

As to this threads problem .... I made 2 posts on my test forum .... one with the code removed and the next with the code intact:

[attachment=46778]

As you can see .... neither show the smaller sized font correctly but with the code there are zero font size change which leads me to consider that MyBB is blocking it in some other file??

(2024-03-15, 06:02 PM)effone Wrote: [ -> ]
(2024-03-15, 04:36 PM)nixer55 Wrote: [ -> ]Had a look at this briefly, before giving it up.  As as far as I can tell, the sceditor version in MyBB is around 1.4.x.  Can't confirm that though.  The "plaintext" plugin @effone mentions, I think is sceditor version 3.x.

MyBB is being shipped with SC Editor 3.1.1
https://github.com/mybb/mybb/pull/4598

3.2.0 being the current version and in MyBB version 1.8.22 it was sceditor version 2.1.3
I also tried with

Format:"xhtml",

After copy/paste from website into New-Reply-Editor it looks correct

[attachment=46781]

But posted it looks like this then

[attachment=46782]

so still no resolution. I will have a look for the part in bbcodes_sceditor.js, test around...

whereas me think the "plaintext" works correct in "quick reply" cause there are no codebuttons/smilies

and yes, "plaintext" is "build in" in 1.8.37. i first thought i have to build a plugin for "plaintext", but it works without plugin in the sceditor plugin folder when i just wrote it behind the "undo" plugin (for what a plugin exists) in the codebuttons-template.

Browsers

i have this "bug" in

Brave
Chrom
Opera

but not in

Firefox (115.8.0esr (64-bit))

so it seems to be browser related. I only used Brave over the last year. I will change to Firefox now till Brave get an update.