Paste as plain text

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
damjang
Moon lover
Moon lover
Posts: 99
Joined: 2012-01-14, 11:22

Paste as plain text

Unread post by damjang » 2024-01-05, 18:42

Hi! I see this function present in some other browsers (chrome, maybe others) and for me it is very useful, so asking here if it will be possible to implement also in our PaleMoon :clap: Thank you!

User avatar
suzyne
Lunatic
Lunatic
Posts: 364
Joined: 2023-06-28, 22:43
Location: Australia

Re: Paste as plain text

Unread post by suzyne » 2024-01-05, 20:16

I often want to paste plain text into Pale Moon, and think it would be an excellent feature either an item in the right click menu, or just a keyboard shortcut (in Windows I usually expect Ctrl+Shift+V) that works in the text area that is currently focused would be wonderful.

I read a discussion about this feature a while back and a plugin was suggested, (can't I remember which one it was?) but whatever it was didn't work for me. So now I am using PureText (on Windows).

https://stevemiller.net/puretext/

But for me this function as a core part of Pale Moon would be ideal.
Laptop 1: Windows 10 64-bit, i7 @ 2.80GHz, 16GB, NVIDIA GeForce MX450.
Laptop 2: Windows 10 32-bit, Atom Z3735F @ 1.33GHz, 2GB, Intel HD Graphics.

Potkeny
Fanatic
Fanatic
Posts: 132
Joined: 2018-08-03, 17:00

Re: Paste as plain text

Unread post by Potkeny » 2024-01-05, 20:21

There is an addon for copying as plain text (https://addons.palemoon.org/addon/copy-as-plain-text/), but I never used it, so I guess it doesn't help for pasting from outside sources.

User avatar
LuftWafflePilot
Fanatic
Fanatic
Posts: 225
Joined: 2021-02-19, 20:46

Re: Paste as plain text

Unread post by LuftWafflePilot » 2024-01-05, 20:26

This is a functionality that feels so simple it makes sense to be a browser feature.

User avatar
athenian200
Contributing developer
Contributing developer
Posts: 1537
Joined: 2018-10-28, 19:56
Location: Georgia

Re: Paste as plain text

Unread post by athenian200 » 2024-01-06, 00:06

Well, what I usually do in the case that I'm dealing with formatted text and I want to lose the formatting, is I just paste the text into Notepad and copy it back to the clipboard again. Is that pretty much the effect you are trying to automate with this feature?
Off-topic:
I've been doing that Notepad trick since Windows 3.11, mostly because of this one CD-ROM encyclopedia that had a ton of formatted text and crashed rather frequently. I wound up copying the contents of each article into Notepad before it crashed so I could remove the formatting (which was often kind of ugly) and also to read it after the software crashed. I saved a ton of articles into Notepad documents to refer back to later.
"The Athenians, however, represent the unity of these opposites; in them, mind or spirit has emerged from the Theban subjectivity without losing itself in the Spartan objectivity of ethical life. With the Athenians, the rights of the State and of the individual found as perfect a union as was possible at all at the level of the Greek spirit." -- Hegel's philosophy of Mind

damjang
Moon lover
Moon lover
Posts: 99
Joined: 2012-01-14, 11:22

Re: Paste as plain text

Unread post by damjang » 2024-01-06, 00:15

athenian200 wrote:
2024-01-06, 00:06
Well, what I usually do in the case that I'm dealing with formatted text and I want to lose the formatting, is I just paste the text into Notepad and copy it back to the clipboard again. Is that pretty much the effect you are trying to automate with this feature?
Yes, but copy > open notepad > paste > select all > copy > close notepad is not very simple to perform :-) . PureText utility mentioned before is very useful too. Thank you for mention :-)

BenFenner
Astronaut
Astronaut
Posts: 588
Joined: 2015-06-01, 12:52
Location: US Southeast

Re: Paste as plain text

Unread post by BenFenner » 2024-01-07, 16:36

You'd think this would be handled by the OS at this point, not on a per-app basis. Maybe the OS vendors will catch on some day.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35651
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: Paste as plain text

Unread post by Moonchild » 2024-01-07, 17:40

BenFenner wrote:
2024-01-07, 16:36
You'd think this would be handled by the OS at this point
You can't, because applications may accept multiple data formats and it's up to the application to determine what to accept and what to do with it. e.g. Pale Moon also allows you to paste image data; how could the OS determine for the application what the intended data format is?
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

BenFenner
Astronaut
Astronaut
Posts: 588
Joined: 2015-06-01, 12:52
Location: US Southeast

Re: Paste as plain text

Unread post by BenFenner » 2024-01-07, 21:37

Don't have the OS determine anything, have the user decide as they already do with the per-app solution.

The OS context menu can present "Paste" as usual, then below it "Paste as text" (or whatever) just like in the per-app situatoin. That second option could always be present, and whatever is in the clipboard can be coerced into plain text as best as possible, even if it's an image or whatever. So you get "garbage" out of it sometimes, no big deal. Or for the Apple folks and similar who'd find that uncouth, the menu option could enable conditionally, only when plaintext coercion does/would produce meaningful results.
Last edited by BenFenner on 2024-01-07, 22:47, edited 2 times in total.

User avatar
suzyne
Lunatic
Lunatic
Posts: 364
Joined: 2023-06-28, 22:43
Location: Australia

Re: Paste as plain text

Unread post by suzyne » 2024-01-07, 21:59

My understanding is that the OS clipboard can hold several formats of data, and in the case of text, there will likely be one that is "plain text". Pale Moon doesn't need to convert anything, if the plain text exists then that is pasted, and if that format is not present nothing happens?
Laptop 1: Windows 10 64-bit, i7 @ 2.80GHz, 16GB, NVIDIA GeForce MX450.
Laptop 2: Windows 10 32-bit, Atom Z3735F @ 1.33GHz, 2GB, Intel HD Graphics.

User avatar
RealityRipple
Astronaut
Astronaut
Posts: 666
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California

Re: Paste as plain text

Unread post by RealityRipple » 2024-01-08, 00:26

https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats

Clipboard data can be any number of these types - for example, you could copy the image data, the filesystem file, and the path, all with ctrl+c in a file explorer on a .bmp - depending on if you paste in a text editor, an image editor, or a different folder, the program would prioritize what it wants, and goes down a list of types in functional priority until it either finds something it wants or runs out of types it knows how to handle. For text, there's CF_TEXT, CF_UNICODETEXT, CF_OEMTEXT, and CF_DSPTEXT (which is usually like placeholder text for another custom [usually binary] format, that would be used as a descriptor for clipboard viewer/editor programs). Rich text tends to be stored, RTF-encoded, in a text clipboard slot, if I recall. So unfortunately plain and rich texts aren't stored separately - if you have rich text copied to the clipboard in Windows and you paste it into something that doesn't understand rich text (or know to check for and strip it), you get RTF data.

User avatar
suzyne
Lunatic
Lunatic
Posts: 364
Joined: 2023-06-28, 22:43
Location: Australia

Re: Paste as plain text

Unread post by suzyne » 2024-01-08, 00:58

Using WordPad as a simple test (given it is known for RTF files on Windows), I did an experiment with a short bullet list. In this case, the RTF data got its own slot and the CF_UNICODETEXT looks like the closest to what I would call "plain text". I expect there would more going on in the general case across a diverse set of apps when a copy to clipboard is done, but the optimist in me wants to think there should usually be at least one item that is text only and ready for pasting without any formatting?

Image

Image
Laptop 1: Windows 10 64-bit, i7 @ 2.80GHz, 16GB, NVIDIA GeForce MX450.
Laptop 2: Windows 10 32-bit, Atom Z3735F @ 1.33GHz, 2GB, Intel HD Graphics.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35651
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: Paste as plain text

Unread post by Moonchild » 2024-01-08, 10:29

BenFenner wrote:
2024-01-07, 21:37
Don't have the OS determine anything, have the user decide as they already do with the per-app solution.
Let's make a thought experiment out of that, shall we?
Imagine every time a user presses Paste, they have a pop-up with all the entries listed in Suzyne's screenshot to choose from. What do you think the loss in user experience will be?
Or list every entry in the context menu? People would be thoroughly confused.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
back2themoon
Moon Magic practitioner
Moon Magic practitioner
Posts: 2411
Joined: 2012-08-19, 20:32

Re: Paste as plain text

Unread post by back2themoon » 2024-01-08, 16:15

The Selected Search extension (v. 0.4.160328, available in the CAA) has an option to automatically copy text on selection. It is copied as plain text.

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 940
Joined: 2021-01-26, 11:18

Re: Paste as plain text

Unread post by Kris_88 » 2024-01-08, 16:58

CTRL+SHIFT+V works in Pale Moon.

Example HTML where you can paste something:

Code: Select all

<html>
<body>
<div style="float:left; width:400px; min-height:200px; background:#ffc0c0" contenteditable ></div>
<div style="float:left; width:400px; min-height:200px; background:#c0ffc0" contenteditable ></div>
</body>
</html>
Results, left - shift+ins, right - ctrl+shift+v
u9.png
You do not have the required permissions to view the files attached to this post.

User avatar
suzyne
Lunatic
Lunatic
Posts: 364
Joined: 2023-06-28, 22:43
Location: Australia

Re: Paste as plain text

Unread post by suzyne » 2024-01-08, 20:29

Kris_88 wrote:
2024-01-08, 16:58
CTRL+SHIFT+V works in Pale Moon.
You are partially right, it does work sometimes. I have tried a few different web pages, and it can paste unformatted text, but not everywhere.

For example in this very forum in the POST A REPLY area when I try to use Ctrl+Shift+V to paste some text and am wanting to lose the formatting, nothing gets pasted.

I would have thought that phpBB should be fairly vanilla in how it works, so it is a surprise that the keyboard shortcut doesn't work here.

Can anyone use Ctrl+Shift+V to paste into a reply in these forums?
Laptop 1: Windows 10 64-bit, i7 @ 2.80GHz, 16GB, NVIDIA GeForce MX450.
Laptop 2: Windows 10 32-bit, Atom Z3735F @ 1.33GHz, 2GB, Intel HD Graphics.

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 940
Joined: 2021-01-26, 11:18

Re: Paste as plain text

Unread post by Kris_88 » 2024-01-08, 20:48

suzyne wrote:
2024-01-08, 20:29
For example in this very forum in the POST A REPLY area when I try to use Ctrl+Shift+V to paste some text and am wanting to lose the formatting, nothing gets pasted.
Textarea doesn't support anything other than plain text, so a simple Shift+Ins inserts plain text. Ctrl+Shift+V doesn't really work in textarea, but that doesn't make sense.

The problem is not that the browser cannot handle Ctrl+Shift+V correctly. It can. But if some WYSIWYG editor processes the paste operation independently, then it is the editor’s task to process various paste modes. The browser is not to blame in this case.

BenFenner
Astronaut
Astronaut
Posts: 588
Joined: 2015-06-01, 12:52
Location: US Southeast

Re: Paste as plain text

Unread post by BenFenner » 2024-01-09, 00:37

Off-topic:
Moonchild wrote:
2024-01-08, 10:29
BenFenner wrote:
2024-01-07, 21:37
Don't have the OS determine anything, have the user decide as they already do with the per-app solution.
Let's make a thought experiment out of that, shall we?
Imagine every time a user presses Paste, they have a pop-up with all the entries listed in Suzyne's screenshot to choose from. What do you think the loss in user experience will be?
That would be awful, assuming I am understanding what you mean you when you say "press Paste".
I'm not sure how we got here, but okay...
Moonchild wrote:
2024-01-08, 10:29
Or list every entry in the context menu? People would be thoroughly confused.
1) I don't really care about non-power users and how confused they get. But yah, that would be silly.
2) The context menu would only need "Paste" and "Paste other ►" with a secondary menu that displays all of the available options if we want to go so crazy as to give the user the choice of all of them.

This would work exactly like "New ►", "Sort by ►", and "View ►" context menu items in Windows...

User avatar
suzyne
Lunatic
Lunatic
Posts: 364
Joined: 2023-06-28, 22:43
Location: Australia

Re: Paste as plain text

Unread post by suzyne » 2024-01-09, 01:32

Kris_88 wrote:
2024-01-08, 20:48
a simple Shift+Ins inserts plain text.
Thank you for the heads-up, I wasn't aware of this Windows keyboard shortcut, but it works well when composing a reply in these forums which is excellent!
Laptop 1: Windows 10 64-bit, i7 @ 2.80GHz, 16GB, NVIDIA GeForce MX450.
Laptop 2: Windows 10 32-bit, Atom Z3735F @ 1.33GHz, 2GB, Intel HD Graphics.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35651
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: Paste as plain text

Unread post by Moonchild » 2024-01-09, 09:31

Off-topic:
BenFenner wrote:
2024-01-09, 00:37
I don't really care about non-power users and how confused they get.
Well, I do, and I have to.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite