Jump to content
Chinese-Forums
  • Sign Up

HTML editor when posting or editing


markhavemann

Recommended Posts

Is there some way to be able to edit the HTML of a post?

 

Sometimes when pasting content from other places it can be really difficult to get it to look right, and occasionally things will look ok in the editor but be broken when you actually submit the post or the changes.

Link to comment
Share on other sites

On 6/7/2023 at 4:34 PM, roddy said:

Theoretically yes, but it's not something I'd be keen to turn on. What specifically are you trying to do?

Copying and pasting tables from word (the best way to keep them formatted nicely) is a bit unpredictable. Pasting one table is fine but pasting another table does some weird things. It either puts them next to each other or creates a huge amount of space between them, and no matter how much tweaking I do I can't seem to get it to display decently. Usually the extra space is invisible in the editing pane and only shows up after you submit.

 

I also get "phantom" cells popping up that can't be deleted if I delete empty rows in a table. Selecting the table, including new lines above and below and pressing delete will only delete the new lines most of the time. The only thing I can do is delete a big chunk above and below the cell, and that usually gets it. 

 

I can understand why you wouldn't want to turn HTML editing on since 95% of the time things are better without it. It sure would make things easier for that 5% of the time though.

Link to comment
Share on other sites

  • 2 weeks later...

I found the solution to part of this.

 

It turns out pasting from Word does it's best to keep every aspect of formatting. This includes text wrapping of a table. Word had set it to wrap text around the table, and so it was floating things to the right of my table after pasting to the site. There are still some small issues but mostly it's manageable now.

Link to comment
Share on other sites

There's a hacky way to do it:

  1. Open the editor/submit-reply text box
  2. In Chrome or Edge, press Ctrl+Shift+C
  3. Hover over the editable area, then click (the blue hover indicator should show the whole editable area)
  4. Check that the selected element (in dev tools Elements pane) is named something like <div class="cke_wysiwyg_div cke_reset cke_enable_context_menu cke_editable cke_editable_themed cke_contents_ltr" ...
  5. Right click on that element in the dev tools pane, then click Edit as HTML from the context menu
  6. Edit the inner HTML of that element (i.e. don't change the element itself or any of its attributes)
  7. Save/submit the post

This gives you finer-grained control, but doesn't guarantee the HTML will be exactly what you submitted, as some sanitization is performed, which is necessary to prevent bad actors from injecting scripts, messing with the site layout, etc. But it does allow you access to some handy features that aren't supported by the editor, such as code blocks and abbreviations:

<abbr title="HyperText Markup Language">HTML</abbr>

HTML

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and select your username and password later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Click here to reply. Select text to quote.

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...