Support » Fixing WordPress » Editor: Entities in text mode, copy/paste in visual mode

  • Hello, not complete newbie – about a decade ago or so I wrote some plugins (long abandoned) but its been awhile since I used WordPress. I am using it for my new ePub project (the website, not the ePub…)

    Anyhoo – I’m using the Classic Editor plugin, the one developed by WP developers, and there are two things I hope I can change.

    1) For several characters, I go into text mode and just type the XML entity – left/right single/double curly quotes, em/en dash, etc.

    I want them to stay as entities. It is hard for me to visually distinguish the characters from each other but it is easy for me to visually distinguish the entities from each other. When I proof read, I have to proof read both visual and text.

    I have a disability that causes me to sometimes type something similar to what is in my brain by different – e.g. their when I mean there etc. and that sometimes happens when I type the entities so I need them to be visually distinguishable which is why I type them as raw entities.

    I suspect there is some script I can just disable that is doing the conversion, but when I type an entity in text mode of editor I want it to stay an entity even when served to the client viewing the content (but of course converted by their browser).

    -=-

    2) When I copy and paste something while in visual editor mode (might happen in text too but haven’t tried) like many web interfaces, formatting is pasted with the string which never what I want – I want just the string. Often it is something like the name of a city or a binomial nomenclature or a name of a person that I am likely to spell wrong (e.g. I often spell Aaron Swartz – a hero of mine – as Aaron Schwarz as the latter is how my mom spells her maiden name) so I often find the spelling elsewhere on the web and copy paste, but that brings formatting (bold, italic, even headings) with it that I don’t want – so I end up having to first paste into a text editor and then copy from that to nuke the formatting.

    Since the formatting isn’t pasted with all websites that have input fields, I’m guessing whether or not to include the formatting with the string is an addition to the text input that can be disabled. So… how do I disable that?

    -=-

    Thank you for any help.

    • This topic was modified 3 years, 10 months ago by pipfroschpress.
    • This topic was modified 3 years, 10 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 5 replies - 1 through 5 (of 5 total)
  • 1) Since the block editor is in core, the classic editor is supported, but not enhanced. However, if you type entities in Text mode and save, you can leave and come back to the editor in Text mode with the entities still there. It’s when you switch between Visual and Text that the replacement happens. You can disable the Visual editor in your user profile, and just use the Preview button to see it in a separate window.

    2) If you expand the toolbar (it used to be called Kitchen Sink, but the icon now says Toolbar Toggle), one of the icons in the added row is a T on a clipboard. This toggles between pasting as HTML or pasting as text. Unfortunately for the previous answer, this is only available in Visual mode. But in Text mode, you get just the text with no HTML.

    Thread Starter pipfroschpress

    (@pipfroschpress)

    Anyone happen to know which piece of JS is called when switching from Text to Visual?

    That’s undoubtedly where the code that converts the entity is, I could just probably edit that. Might have to repeat every WP update but that would solve #1 and let me solve #2 by continual to use visual except when I need to add an entity or custom markup.

    Thread Starter pipfroschpress

    (@pipfroschpress)

    Oh and than you.

    Actually, I just tried it in the block editor and it’s even worse there, because it converts the entities as soon as you click outside the block!
    I put a message to the main designer, but I’ll probably have to open an issue for it.

    That still doesn’t help the older editor though (most likely).
    I don’t know enough about the JS to point out the culprit file, but if you find it, you might be able to filter the setup args for the editor to load a modified version instead of the core version.
    hooks with mce

    I created an issue for this on the Gutenberg side. https://github.com/WordPress/gutenberg/issues/22337

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Editor: Entities in text mode, copy/paste in visual mode’ is closed to new replies.