6056 |
efrain |
1 |
<!DOCTYPE html>
|
|
|
2 |
<!--
|
|
|
3 |
Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
|
4 |
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
|
5 |
-->
|
|
|
6 |
<html lang="en">
|
|
|
7 |
<head>
|
|
|
8 |
<meta charset="utf-8">
|
|
|
9 |
<title>Replace DIV — CKEditor Sample</title>
|
|
|
10 |
<script src="../../ckeditor.js"></script>
|
|
|
11 |
<link href="sample.css" rel="stylesheet">
|
|
|
12 |
<meta name="description" content="Try the latest sample of CKEditor 4 and learn more about customizing your WYSIWYG editor with endless possibilities.">
|
|
|
13 |
<style>
|
|
|
14 |
|
|
|
15 |
div.editable
|
|
|
16 |
{
|
|
|
17 |
border: solid 2px transparent;
|
|
|
18 |
padding-left: 15px;
|
|
|
19 |
padding-right: 15px;
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
div.editable:hover
|
|
|
23 |
{
|
|
|
24 |
border-color: black;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
</style>
|
|
|
28 |
<script>
|
|
|
29 |
|
|
|
30 |
// Uncomment the following code to test the "Timeout Loading Method".
|
|
|
31 |
// CKEDITOR.loadFullCoreTimeout = 5;
|
|
|
32 |
|
|
|
33 |
window.onload = function() {
|
|
|
34 |
// Listen to the double click event.
|
|
|
35 |
if ( window.addEventListener )
|
|
|
36 |
document.body.addEventListener( 'dblclick', onDoubleClick, false );
|
|
|
37 |
else if ( window.attachEvent )
|
|
|
38 |
document.body.attachEvent( 'ondblclick', onDoubleClick );
|
|
|
39 |
|
|
|
40 |
};
|
|
|
41 |
|
|
|
42 |
function onDoubleClick( ev ) {
|
|
|
43 |
// Get the element which fired the event. This is not necessarily the
|
|
|
44 |
// element to which the event has been attached.
|
|
|
45 |
var element = ev.target || ev.srcElement;
|
|
|
46 |
|
|
|
47 |
// Find out the div that holds this element.
|
|
|
48 |
var name;
|
|
|
49 |
|
|
|
50 |
do {
|
|
|
51 |
element = element.parentNode;
|
|
|
52 |
}
|
|
|
53 |
while ( element && ( name = element.nodeName.toLowerCase() ) &&
|
|
|
54 |
( name != 'div' || element.className.indexOf( 'editable' ) == -1 ) && name != 'body' );
|
|
|
55 |
|
|
|
56 |
if ( name == 'div' && element.className.indexOf( 'editable' ) != -1 )
|
|
|
57 |
replaceDiv( element );
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
var editor;
|
|
|
61 |
|
|
|
62 |
function replaceDiv( div ) {
|
|
|
63 |
if ( editor )
|
|
|
64 |
editor.destroy();
|
|
|
65 |
|
|
|
66 |
editor = CKEDITOR.replace( div );
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
</script>
|
|
|
70 |
</head>
|
|
|
71 |
<body>
|
|
|
72 |
<h1 class="samples">
|
|
|
73 |
<a href="index.html">CKEditor Samples</a> » Replace DIV with CKEditor on the Fly
|
|
|
74 |
</h1>
|
|
|
75 |
<div class="warning deprecated">
|
|
|
76 |
This sample is not maintained anymore. Check out the <a href="https://ckeditor.com/docs/ckeditor4/latest/examples/index.html">brand new samples in CKEditor Examples</a>.
|
|
|
77 |
</div>
|
|
|
78 |
<div class="description">
|
|
|
79 |
<p>
|
|
|
80 |
This sample shows how to automatically replace <code><div></code> elements
|
|
|
81 |
with a CKEditor instance on the fly, following user's doubleclick. The content
|
|
|
82 |
that was previously placed inside the <code><div></code> element will now
|
|
|
83 |
be moved into CKEditor editing area.
|
|
|
84 |
</p>
|
|
|
85 |
<p>
|
|
|
86 |
For details on how to create this setup check the source code of this sample page.
|
|
|
87 |
</p>
|
|
|
88 |
</div>
|
|
|
89 |
<p>
|
|
|
90 |
Double-click any of the following <code><div></code> elements to transform them into
|
|
|
91 |
editor instances.
|
|
|
92 |
</p>
|
|
|
93 |
<div class="editable">
|
|
|
94 |
<h3>
|
|
|
95 |
Part 1
|
|
|
96 |
</h3>
|
|
|
97 |
<p>
|
|
|
98 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
|
|
|
99 |
semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
|
|
|
100 |
rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
|
|
|
101 |
nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
|
|
|
102 |
eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
|
|
|
103 |
</p>
|
|
|
104 |
</div>
|
|
|
105 |
<div class="editable">
|
|
|
106 |
<h3>
|
|
|
107 |
Part 2
|
|
|
108 |
</h3>
|
|
|
109 |
<p>
|
|
|
110 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
|
|
|
111 |
semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
|
|
|
112 |
rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
|
|
|
113 |
nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
|
|
|
114 |
eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
|
|
|
115 |
</p>
|
|
|
116 |
<p>
|
|
|
117 |
Donec velit. Mauris massa. Vestibulum non nulla. Nam suscipit arcu nec elit. Phasellus
|
|
|
118 |
sollicitudin iaculis ante. Ut non mauris et sapien tincidunt adipiscing. Vestibulum
|
|
|
119 |
vitae leo. Suspendisse nec mi tristique nulla laoreet vulputate.
|
|
|
120 |
</p>
|
|
|
121 |
</div>
|
|
|
122 |
<div class="editable">
|
|
|
123 |
<h3>
|
|
|
124 |
Part 3
|
|
|
125 |
</h3>
|
|
|
126 |
<p>
|
|
|
127 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
|
|
|
128 |
semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
|
|
|
129 |
rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
|
|
|
130 |
nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
|
|
|
131 |
eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
|
|
|
132 |
</p>
|
|
|
133 |
</div>
|
|
|
134 |
<div id="footer">
|
|
|
135 |
<hr>
|
|
|
136 |
<p>
|
|
|
137 |
CKEditor - The text editor for the Internet - <a class="samples" href="https://ckeditor.com/">https://ckeditor.com</a>
|
|
|
138 |
</p>
|
|
|
139 |
<p id="copy">
|
|
|
140 |
Copyright © 2003-2021, <a class="samples" href="https://cksource.com/">CKSource</a> - Frederico
|
|
|
141 |
Knabben. All rights reserved.
|
|
|
142 |
</p>
|
|
|
143 |
</div>
|
|
|
144 |
</body>
|
|
|
145 |
</html>
|