3 Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
4 For licensing, see LICENSE.md or http://ckeditor.com/license
9 <title>Replace DIV
— CKEditor Sample
</title>
10 <script src=
"../ckeditor.js"></script>
11 <link href=
"sample.css" rel=
"stylesheet">
16 border: solid
2px transparent;
29 // Uncomment the following code to test the
"Timeout Loading Method".
30 // CKEDITOR.loadFullCoreTimeout =
5;
32 window.onload = function() {
33 // Listen to the double click event.
34 if ( window.addEventListener )
35 document.body.addEventListener( 'dblclick', onDoubleClick, false );
36 else if ( window.attachEvent )
37 document.body.attachEvent( 'ondblclick', onDoubleClick );
41 function onDoubleClick( ev ) {
42 // Get the element which fired the event. This is not necessarily the
43 // element to which the event has been attached.
44 var element = ev.target || ev.srcElement;
46 // Find out the div that holds this element.
50 element = element.parentNode;
52 while ( element && ( name = element.nodeName.toLowerCase() ) &&
53 ( name != 'div' || element.className.indexOf( 'editable' ) == -
1 ) && name != 'body' );
55 if ( name == 'div' && element.className.indexOf( 'editable' ) != -
1 )
56 replaceDiv( element );
61 function replaceDiv( div ) {
65 editor = CKEDITOR.replace( div );
72 <a href=
"index.html">CKEditor Samples
</a> » Replace DIV with CKEditor on the Fly
74 <div class=
"description">
76 This sample shows how to automatically replace
<code><div
></code> elements
77 with a CKEditor instance on the fly, following user's doubleclick. The content
78 that was previously placed inside the
<code><div
></code> element will now
79 be moved into CKEditor editing area.
82 For details on how to create this setup check the source code of this sample page.
86 Double-click any of the following
<code><div
></code> elements to transform them into
89 <div class=
"editable">
94 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
95 semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
96 rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
97 nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
98 eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
101 <div class=
"editable">
106 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
107 semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
108 rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
109 nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
110 eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
113 Donec velit. Mauris massa. Vestibulum non nulla. Nam suscipit arcu nec elit. Phasellus
114 sollicitudin iaculis ante. Ut non mauris et sapien tincidunt adipiscing. Vestibulum
115 vitae leo. Suspendisse nec mi tristique nulla laoreet vulputate.
118 <div class=
"editable">
123 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
124 semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
125 rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
126 nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
127 eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
133 CKEditor - The text editor for the Internet -
<a class=
"samples" href=
"http://ckeditor.com/">http://ckeditor.com
</a>
136 Copyright
© 2003-
2014,
<a class=
"samples" href=
"http://cksource.com/">CKSource
</a> - Frederico
137 Knabben. All rights reserved.