medium-editor icon indicating copy to clipboard operation
medium-editor copied to clipboard

HTML Mode

Open bhadaway opened this issue 5 years ago • 0 comments

I've actually got this started already, if someone can help me complete it.

Step 1: Create the ability to toggle between Rich Mode and HTML Mode:

jQuery:

$('.medium-editor-hidden').hide();
$('.editor-mode').click(function() {
$('.medium-editor-element,.medium-editor-hidden').toggle();
});

HTML:

<a href="javascript:void(0)" class="editor-mode medium-editor-element">Switch to HTML Mode</a><a href="javascript:void(0)" class="editor-mode medium-editor-hidden">Switch to Rich Mode</a>

Done.

Step 2: Copy content back to Rich Mode from HTML Mode without losing/breaking stuff:

I've tried:

$('.medium-editor-hidden').keyup(function() {
$('.medium-editor-element').val( $('.medium-editor-hidden').val() );
});

And:

$('.medium-editor-hidden').clone().appendTo('.medium-editor-element');

With mixed success.

Quick reference to default JS:

https://cdn.jsdelivr.net/npm/medium-editor@latest/dist/js/medium-editor.js

bhadaway avatar May 06 '19 16:05 bhadaway