Skip to content

Example Usage

Peace Ngara edited this page Mar 29, 2017 · 1 revision

Example Usages of CKEditor Plugin V2

There are 2 Ways the Plugin can be used:

  1. As a Laravel Plugin
  2. As a CK Editor Standalone Plugin

Usage in Laravel

The Plugin already has an Implementation of Laravel and Database Usages see below:

Creating a New Instance of CKEditor

			 <div class="container">
					<div class="row">
						<form name="save" id="save" action="/ckesavedata">
							<textarea id="ckeditorplugin" class="ckeditor">&lt;p&gt;Initial editor content.&lt;/p&gt;</textarea>
							<br/>
							<button id="submit" class="btn btn-sm unisa-blue-btn bnt-success" name="submit">Save Data</button>
							<input type="hidden" id="token" value="{{ csrf_token() }}"/>
						</form>
						<script>
							/**
							 * Create a New Instance of the CK Editor
							 */
							CKEDITOR.replace('ckeditorplugin', {
										// Load the Course Content Plugin to the Editor
										extraPlugins: 'coursecontent'
									}
							);
							CKEDITOR.document.appendStyleSheet("{{URL::asset('/vendor/ckeditorplugin/css/custom-contents.css')}}");

							$('#submit').click(function (event) {
								event.preventDefault();
								CKEDITOR.instances.ckeditorplugin.updateElement();
								var data = $('#ckeditorplugin').val();
								$.ajax({
									url: '/ckesavedata',
									context: document.body,
									data: {
										data: data
									},
									success: function (response) {
										alert(data); // Get Current Editor Data.
										console.log(response);
									}

								});

							});

						</script>
						<script>
							//Dialogue Insertion Point -->
							CKEDITOR.config = {
								extraPlugins: 'dialog',
								toolbar: [['LTIButton']],
								allowedContent: true
							};
						</script>
					</div>

				</div>

Clone this wiki locally