]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/core/htmlparser/text.js
Upgrade to 4.5.7 and add some plugin
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / core / htmlparser / text.js
1 /**
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6 'use strict';
7
8 ( function() {
9 /**
10 * A lightweight representation of HTML text.
11 *
12 * @class
13 * @extends CKEDITOR.htmlParser.node
14 * @constructor Creates a text class instance.
15 * @param {String} value The text node value.
16 */
17 CKEDITOR.htmlParser.text = function( value ) {
18 /**
19 * The text value.
20 *
21 * @property {String}
22 */
23 this.value = value;
24
25 /** @private */
26 this._ = {
27 isBlockLike: false
28 };
29 };
30
31 CKEDITOR.htmlParser.text.prototype = CKEDITOR.tools.extend( new CKEDITOR.htmlParser.node(), {
32 /**
33 * The node type. This is a constant value set to {@link CKEDITOR#NODE_TEXT}.
34 *
35 * @readonly
36 * @property {Number} [=CKEDITOR.NODE_TEXT]
37 */
38 type: CKEDITOR.NODE_TEXT,
39
40 /**
41 * Filter this text node with given filter.
42 *
43 * @since 4.1
44 * @param {CKEDITOR.htmlParser.filter} filter
45 * @returns {Boolean} Method returns `false` when this text node has
46 * been removed. This is an information for {@link CKEDITOR.htmlParser.element#filterChildren}
47 * that it has to repeat filter on current position in parent's children array.
48 */
49 filter: function( filter, context ) {
50 if ( !( this.value = filter.onText( context, this.value, this ) ) ) {
51 this.remove();
52 return false;
53 }
54 },
55
56 /**
57 * Writes the HTML representation of this text to a {CKEDITOR.htmlParser.basicWriter}.
58 *
59 * @param {CKEDITOR.htmlParser.basicWriter} writer The writer to which write the HTML.
60 * @param {CKEDITOR.htmlParser.filter} [filter] The filter to be applied to this node.
61 * **Note:** it's unsafe to filter offline (not appended) node.
62 */
63 writeHtml: function( writer, filter ) {
64 if ( filter )
65 this.filter( filter );
66
67 writer.text( this.value );
68 }
69 } );
70 } )();