SCEditor

Toggle WYSIWYG and source modes

Toggle editor mode

Code behind

Create the editor

var textarea = document.getElementById('demo-toggle');
sceditor.create(textarea, {
	format: 'bbcode',
	toolbar: 'bold,italic,underline|source',
	style: '/minified/themes/content/default.min.css'
});

Toggle source mode

Then, to switch between WYSIWYG mode and source mode, simply call the toggleTextMode() method on an editor instance.

var textarea = document.getElementById('demo-toggle');
sceditor.instance(textarea).toggleSourceMode();

You can also use sourceMode([boolean] setToSourceMode) to set the editor mode and sourceMode() to get the editor mode.

var textarea = document.getElementById('demo-toggle');
var instance = sceditor.instance(textarea);

// InSourceMode will be true if the editor is in source mdoe, false if not.
var InSourceMode = instance.sourceMode();

// Set the editor to source mode
instance.sourceMode(true);

// Set the editor to WYSIWYG mode
instance.sourceMode(false);