I am trying to make simple web editor using CKEditor but i cant find out how to make it work.
First i checked their samples site. Only thing they do to make CKEditor work is include .js file and add ckeditor class to form textarea element.
<script src="../ckeditor.js"></script>
.
.
.
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
So i copy .js file and try it in my own folder and when i run php script whole textarea element is hidden and doesnt create CKEditor panel as it should like in this sample page. There might be some javascript configuration but i havent found any in source code of sample page.
call CKEDITOR.replace( 'editor1' ); in your js files or simply in your html file like this:
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
<script>
CKEDITOR.replace( 'editor1' );
</script>
Copy all of your ckeditor folder to server.
Add it to html page ;like this:
<script src="../script/ckeditor/ckeditor.js" type="text/javascript"></script>
Assign CSS class of ckeditor to textarea; like class="ckeditor".
<script src="../ckeditor.js"></script>
<form name="ckeditor">
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
As given in the main website.
<script src="https://cdn.ckeditor.com/ckeditor5/34.2.0/classic/ckeditor.js"></script>
<form method="post">
<textarea name=msg id="editor">Text</textarea>
<input type="submit">
</form>
<script>
ClassicEditor
.create(document.querySelector('#editor'))
.then(editor => { console.log(editor); })
.catch(error => { console.error(error); });
</script>
Related
Why doesn't the ck editor load the last change that I made in source mode?
If I have disabled the ck_editor, then the textarea will show all the data.
This is my code:
<textarea name="content" id="editor1" rows="10" cols="80">
<?php print $selecteddata['content']; ?>
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'content' ,{
filebrowserBrowseUrl : './public/browse.php',
filebrowserUploadUrl : '/uploader/index.php',
uiColor : '#9AB8F3'
});
</script>
it was about CKEditor Data Filtering and Features Activation .
the answer was here.
CKEditor automatically strips classes from div
Try this:
<textarea name="content" id="editor1" rows="10" cols="80">
<?php print $selecteddata['content']; ?>
</textarea>
<script>
$(window).load(function(){
if (typeof(CKEDITOR.instances['content'])=='undefined') {
CKEDITOR.replace( 'content',{
filebrowserBrowseUrl : './public/browse.php',
filebrowserUploadUrl : '/uploader/index.php',
uiColor : '#9AB8F3'
});
}
});
</script>
Here i am creating an email editor template. for that template creations i used CKEditor to create templates. Here is my code.
<?php if (isset($_POST['submit']) ) {
//echo $_POST['message']; } ?>
and the script here.
<script>
//<![CDATA[
CKEDITOR.replace( 'message');
//]]>
</script>
and my HTML code here.
<form method="post" action="">
<textarea class="for_set_height" id="message" name="message" style="visibility: hidden; display: none;"></textarea>
<button type="submit" name="submit" value="submit" >
<i class="icon-book on-left"></i>
<span>Cancel</span>
</button>
</form>
and is it possible to save the Ckeditor datas directly using php form submissions.
Actually i dont know why its not working. but i found a way to do it.
Here is my js to save it.
var editor = CKEDITOR.replace('message'); editor.on( 'change', function( evt ) { $('[name="message"]').val(evt.editor.getData());});
hope it will help someone else.
I am trying to integrate Codemirror to one of my view in Yii 1
but the result is not good.
Please help me.
In Controller: I registered
$cs->registerScriptFile($baseUrl.'/js/codemirror.js', \CClientScript::POS_BEGIN);
$cs->registerScriptFile($baseUrl.'/js/php.js', \CClientScript::POS_BEGIN);
In view.php
<textarea id="editor" name="editor" rows="10" style="width: inherit;">
<?= htmlentities($model->diff_content); ?>
</textarea>
<script type="text/javascript">
var e = CodeMirror.fromTextArea(document.getElementById("editor"), {
mode: "application/x-httpd-php"
//theme: 'blackboard'
});
/*function app() {
var txt = "myText";
$('textarea#code').text(txt);
}*/
</script>
Result:
thank you very much
I found the answer for my question
$cs->registerCssFile($baseUrl.'/css/codemirror.css', \CClientScript::POS_BEGIN);
It will generate
and this is the problem
I have to change to
$cs->registerCssFile($baseUrl.'/css/codemirror.css');
without \CClientScript::POS_BEGIN
Everything back to work.
I want use ckeditor 4.3.4 to codeigniter 2.1.4 i tried to start testing it in jsbin, it did not work.what do i do?
How can you use ckeditor 4.3.4 in codeigniter 2.1.4?
How can install ckeditor basic?
DEMO: http://jsbin.com/lacekiyu/1/edit
Code:
<html>
<head>
<script src="www.ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
<script>
CKEDITOR.replace( 'editor1' );
</script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
</form>
</body>
</html>
1). Change your ckeditor js link to correct url: http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js.
2). Add body onload event, and it will work.
<html>
<head>
<script src="http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
<script>
function init() {
CKEDITOR.replace( 'editor1' );
}
</script>
</head>
<body onload="init()">
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
</form>
</body>
</html>
You need to correct the reference to the CKEditor script and add the CSS class ckeditor to the textarea.
<head>
<script src="http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
</head>
<body>
<form>
<textarea class="ckeditor" name="editor">
This is my textarea to be replaced with CKEditor.
</textarea>
</form>
</body>
You could host the CKEditor JavaScript on your server. Assuming it is stored in a folder in your web root, called assets (e.g. public_html/assets) and the URL helper is loaded, you can reference it in a view:
<script src="<?php echo base_url("assets/ckeeditor.js"); ?>"></script>
Below is the code in which changeme is the text i want to change on the click of the button.
HTML code and JS is below:
1) whatever user input in field will be capture and replace with changeme if the JavaScript and then with the new JavaScript page is loaded.
If someone will help me it will be really great help
<form>
Stream ID: <input id="csi" name="q" placeholder="Custom Streame Id">
<input id="btn" type="submit" value="View">
</form>
<script type="text/javascript">
jwplayer("test").setup({
aboutlink: "http://domain.com",
abouttext: "DOMAIN",
streamer: 'link',
file:'changeme'
});
To change the playing file dynamically use the load() function:
jwplayer().load("newfile").play();
Base on DevZer0 solution, you can try this
<form>
Stream ID: <input id="csi" name="q" placeholder="Custom Streame Id">
<input id="btn" type="submit" value="View" onclick="loadnewfile();">
</form>
<script type="text/javascript">
jwplayer("test").setup({
aboutlink: "http://domain.com",
abouttext: "DOMAIN",
streamer: 'link',
file:'ORIGINAL_FILE'
});
function loadnewfile(){
jwplayer().load($('#btn').val()).play();
}
</script>
Assuming you have jQuery loaded in the document.
<script type="text/javascript">
jwplayer("container").setup({
file: "http://content.bitsontherun.com/videos/i8oQD9zd-640.mp4",
image: "http://content.bitsontherun.com/thumbs/i8oQD9zd-640.jpg",
title: "Tears of Steel"
});
function playTrailer(key) {
jwplayer().load([{
file: "http://content.bitsontherun.com/videos/"+key+"-640.mp4",
image: "http://content.bitsontherun.com/thumbs/"+key+"-640.jpg"
}]);
jwplayer().play();
}
function playstream(key) {
jwplayer().load([{
file: "+key+",
streamer: 'rtmp://hideipforsecurity/golive',
type:'rtmp'
}]);
jwplayer().play();
}
</script>
<p>Live Streamers:</p>
<ul>
<li>Tears of Steel</li>
<li>Sintel</li>
<li>Big Buck Bunny</li>
<li>stream</li>
</ul>
Above is what I achieved. Now when I click stream it gives me an error in jwplayer:
ERROR PLAYING list : no playable source found.
If anyone knows whats wrong help me.