liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.html or http://ckeditor.com/license
 */
 
(function()
{
    function placeholderDialog( editor, isEdit )
    {
 
        var lang = editor.lang.placeholder,
            generalLabel = editor.lang.common.generalTab;
        return {
            title : lang.title,
            minWidth : 300,
            minHeight : 80,
            contents :
            [
                {
                    id : 'info',
                    label : generalLabel,
                    title : generalLabel,
                    elements :
                    [
                        {
                            id : 'text',
                            type : 'text',
                            style : 'width: 100%;',
                            label : lang.text,
                            'default' : '',
                            required : true,
                            validate : CKEDITOR.dialog.validate.notEmpty( lang.textMissing ),
                            setup : function( element )
                            {
                                if ( isEdit )
                                    this.setValue( element.getText().slice( 2, -2 ) );
                            },
                            commit : function( element )
                            {
                                var text = '[[' + this.getValue() + ']]';
                                // The placeholder must be recreated.
                                CKEDITOR.plugins.placeholder.createPlaceholder( editor, element, text );
                            }
                        }
                    ]
                }
            ],
            onShow : function()
            {
                if ( isEdit )
                    this._element = CKEDITOR.plugins.placeholder.getSelectedPlaceHoder( editor );
 
                this.setupContent( this._element );
            },
            onOk : function()
            {
                this.commitContent( this._element );
                delete this._element;
            }
        };
    }
 
    CKEDITOR.dialog.add( 'createplaceholder', function( editor )
        {
            return placeholderDialog( editor );
        });
    CKEDITOR.dialog.add( 'editplaceholder', function( editor )
        {
            return placeholderDialog( editor, 1 );
        });
} )();