Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting HTML to TinyMCE? #24

Open
reox opened this issue Nov 5, 2024 · 0 comments
Open

Pasting HTML to TinyMCE? #24

reox opened this issue Nov 5, 2024 · 0 comments

Comments

@reox
Copy link

reox commented Nov 5, 2024

When using the TinyMCE editor, it is possible to copy formatted text and paste it with formatting into the editor.
I have a script that generates HTML code for the editor and I want to paste the rich text into the editor, rather than going to the source code tab and paste the raw HTML there.
Unfortunately, I cannot get this to work with klembord...

Here is a minimal example that takes an existing clipboard and just puts it again into the clipboard:

import klembord

klembord.init()
raw, rich = klembord.get_with_rich_text()
print(raw)
print(rich)
klembord.set_with_rich_text(raw, rich)

But if I paste then into the editor, I just see the raw text...

I further noticed that TinyMCE puts <!-- x-tinymce/html --> in front of the HTML content, and I tried that with simple examples such as:

import klembord
klembord.init()
klembord.set_with_rich_text('hello world', '<!-- x-tinymce/html -->hello <strong>world</strong>')

Which also does not work.

Is there something I do wrong, do I have to set the HTML code differently? Has anyone used klembord to paste stuff to TinyMCE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant