Skip to content

Commit 7071f00

Browse files
committed
Add API (auto-generated)
Fixes #180
1 parent 851a201 commit 7071f00

File tree

2 files changed

+29
-33
lines changed

2 files changed

+29
-33
lines changed

api/classes/CKEDITOR.plugins.placeholder.html

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ <h2 class="off-left">Index</h2>
195195
<h3>Methods</h3>
196196

197197
<ul class="index-list methods">
198-
<li class="index-item method">
199-
<a href="#method_init">init</a>
198+
<li class="index-item method protected">
199+
<a href="#method__checkEmptyData">_checkEmptyData</a>
200200

201201
</li>
202-
<li class="index-item method protected">
202+
<li class="index-item method">
203203
<a href="#method_init">init</a>
204204

205205
</li>
@@ -222,8 +222,8 @@ <h3>Attributes</h3>
222222
<div id="methods" class="api-class-tabpanel tab-pane">
223223
<h2 class="off-left">Methods</h2>
224224

225-
<div id="method_init" class="method item">
226-
<h3 class="name"><code>init</code></h3>
225+
<div id="method__checkEmptyData" class="method item protected">
226+
<h3 class="name"><code>_checkEmptyData</code></h3>
227227

228228
<div class="args">
229229
<span class="paren">(</span><ul class="args-list inline commas">
@@ -235,6 +235,7 @@ <h3 class="name"><code>init</code></h3>
235235

236236

237237

238+
<span class="flag protected">protected</span>
238239

239240

240241

@@ -243,16 +244,16 @@ <h3 class="name"><code>init</code></h3>
243244
<div class="meta">
244245
<p>
245246
Defined in
246-
<a href="../files/src_plugins_placeholder.js.html#l26"><code>src&#x2F;plugins&#x2F;placeholder.js:26</code></a>
247+
<a href="../files/src_plugins_placeholder.js.html#l38"><code>src&#x2F;plugins&#x2F;placeholder.js:38</code></a>
247248
</p>
248249

249250

250251

251252
</div>
252253

253254
<div class="description">
254-
<p>Initialization of the plugin, part of CKEditor plugin lifecycle.
255-
The function registers a &#39;blur&#39; listener to CKEditor&#39;s blur event.</p>
255+
<p>Removes any data from the content and adds a class,
256+
specified by the &quot;placeholderClass&quot; config attribute.</p>
256257

257258
</div>
258259

@@ -262,11 +263,11 @@ <h4>Parameters:</h4>
262263
<ul class="params-list">
263264
<li class="param">
264265
<code class="param-name">editor</code>
265-
<span class="type">Object</span>
266+
<span class="type">CKEDITOR.dom.event</span>
266267

267268

268269
<div class="param-description">
269-
<p>The current editor instance</p>
270+
<p>event, fired from CKEditor</p>
270271

271272
</div>
272273

@@ -276,7 +277,7 @@ <h4>Parameters:</h4>
276277

277278

278279
</div>
279-
<div id="method_init" class="method item protected">
280+
<div id="method_init" class="method item">
280281
<h3 class="name"><code>init</code></h3>
281282

282283
<div class="args">
@@ -289,7 +290,6 @@ <h3 class="name"><code>init</code></h3>
289290

290291

291292

292-
<span class="flag protected">protected</span>
293293

294294

295295

@@ -298,17 +298,16 @@ <h3 class="name"><code>init</code></h3>
298298
<div class="meta">
299299
<p>
300300
Defined in
301-
<a href="../files/src_plugins_placeholder.js.html#l37"><code>src&#x2F;plugins&#x2F;placeholder.js:37</code></a>
301+
<a href="../files/src_plugins_placeholder.js.html#l26"><code>src&#x2F;plugins&#x2F;placeholder.js:26</code></a>
302302
</p>
303303

304304

305305

306306
</div>
307307

308308
<div class="description">
309-
<p>Handles the fired blur event. The function removes any data from CKEditor, because an
310-
empty paragraph may still exist despite for the user the editor looks empty and
311-
adds a class, specified via &quot;placeholderClass&quot; config attribute.</p>
309+
<p>Initialization of the plugin, part of CKEditor plugin lifecycle.
310+
The function registers a &#39;blur&#39; and &#39;contentDom&#39; event listeners.</p>
312311

313312
</div>
314313

@@ -318,11 +317,11 @@ <h4>Parameters:</h4>
318317
<ul class="params-list">
319318
<li class="param">
320319
<code class="param-name">editor</code>
321-
<span class="type">CKEDITOR.dom.event</span>
320+
<span class="type">Object</span>
322321

323322

324323
<div class="param-description">
325-
<p>Blur event, fired from CKEditor</p>
324+
<p>The current editor instance</p>
326325

327326
</div>
328327

api/files/src_plugins_placeholder.js.html

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,37 +190,34 @@ <h1><small>File</small> <code>src/plugins/placeholder.js</code></h1>
190190

191191
/**
192192
* Initialization of the plugin, part of CKEditor plugin lifecycle.
193-
* The function registers a &#x27;blur&#x27; listener to CKEditor&#x27;s blur event.
193+
* The function registers a &#x27;blur&#x27; and &#x27;contentDom&#x27; event listeners.
194194
*
195195
* @method init
196196
* @param {Object} editor The current editor instance
197197
*/
198198
init: function(editor) {
199-
editor.on(&#x27;blur&#x27;, this._onBlur, this);
199+
editor.on(&#x27;blur&#x27;, this._checkEmptyData, this);
200+
editor.once(&#x27;contentDom&#x27;, this._checkEmptyData, this);
200201
},
201202

202203
/**
203-
* Handles the fired blur event. The function removes any data from CKEditor, because an
204-
* empty paragraph may still exist despite for the user the editor looks empty and
205-
* adds a class, specified via &quot;placeholderClass&quot; config attribute.
204+
* Removes any data from the content and adds a class,
205+
* specified by the &quot;placeholderClass&quot; config attribute.
206206
*
207207
* @protected
208-
* @method init
209-
* @param {CKEDITOR.dom.event} editor Blur event, fired from CKEditor
208+
* @method _checkEmptyData
209+
* @param {CKEDITOR.dom.event} editor event, fired from CKEditor
210210
*/
211-
_onBlur: function(event) {
212-
var editor,
213-
editorNode;
214-
215-
editor = event.editor;
211+
_checkEmptyData: function(event) {
212+
var editor = event.editor;
216213

217214
if (editor.getData() === &#x27;&#x27;) {
218-
editorNode = new CKEDITOR.dom.element(editor.element.$);
215+
var editorNode = new CKEDITOR.dom.element(editor.element.$);
219216

220217
// Despite getData() returns empty string, the content still may have
221-
// content - an empty paragrapgh. This prevents :empty selector in
218+
// data - an empty paragraph. This breaks the :empty selector in
222219
// placeholder&#x27;s CSS and placeholder does not appear.
223-
// For that reason we will intentionally remove any content from editorNode.
220+
// For that reason, we will intentionally remove any content from editorNode.
224221
editorNode.setHtml(&#x27;&#x27;);
225222

226223
editorNode.addClass(editor.config.placeholderClass);

0 commit comments

Comments
 (0)