ckeditor插件对话框选择从所选的一个获取描述

Zii*_*der 5 javascript ckeditor

我正在为CKEDITOR开发一个占位符插件,它基本上是完整的.我遇到的问题是我试图从对话框中的选择中获取值和描述,而我只是获得了值.包含描述和值的数组如下所示

- > items: [['description1', 'value1'], ['description2', 'value2']] < -

在返回 - > contents - >元素中ID dropdown我有setup和commit函数.在这些函数中,我需要获取描述就像从select选项中获取名称一样.

真的需要帮助这个,谢谢你提前

例子 - >

<select>
    <option value="value1">description1</option>
    <option value="value2">description2</option>
</select>
Run Code Online (Sandbox Code Playgroud)

示例< -

(function () {

    function placeholderDialog(editor, isEdit) {

        var lang = editor.lang.phlink,
            generalLabel = editor.lang.common.generalTab;

        return {
            title: lang.title,
            minWidth: 300,
            minHeight: 80,
            contents: [
                {
                    id: 'info',
                    label: generalLabel,
                    title: generalLabel,
                    elements: [
                    {
                        id: 'dropdown'
                        , type: 'select'
                        , label: lang.chooseVal
                        , 'default': 'Detta är default'
                        , items: [['description1', 'value1'], ['description2', 'value2']]
                        , setup: function (data) {
                            // need the description
                            this.setValue(data.title);
                        }
                        , commit: function (data) {
                            // need the description
                            data.title = this.getValue();
                        }
                    },
                    {
                        id: 'text',
                        type: 'text',
                        style: 'width: 100%;',
                        label: lang.text,
                        'default': '',
                        required: true,
                        validate: CKEDITOR.dialog.validate.notEmpty(lang.textMissing),
                        setup: function (data) {
                            this.setValue(data.text);
                        },
                        commit: function (data) {
                            data.text = this.getValue();
                        }
                    }
                ]
                }
            ],
            onShow: function () {
                var data = { tag: 'link', content: "detta är innehåll", title: "Länk till svar", text: "detta är text" };
                if (isEdit) {
                    this._element = CKEDITOR.plugins.phlink.getSelectedPlaceHolder(editor);
                    data.title = this._element.getAttribute('title');
                    data.text = this._element.getText();
                    data.tag = this._element.getAttribute('data-jztag');
                }

                this.setupContent(data);
            },
            onOk: function () {
                var data = { tag: 'link', content: null, title: null, text: null };

                this.commitContent(data);

                CKEDITOR.plugins.phlink.createPlaceholder(editor, this._element, data);

                delete this._element;
            }
        };
    }

    CKEDITOR.dialog.add('createplaceholder', function (editor) {
        return placeholderDialog(editor);
    });
    CKEDITOR.dialog.add('editplaceholder', function (editor) {
        return placeholderDialog(editor, 1);
    });
})();
Run Code Online (Sandbox Code Playgroud)

ole*_*leq 6

使用以下命令获取选项的文本:

var input = this.getInputElement().$;
console.log( input.options[ input.selectedIndex ].text );
>> "description1"
Run Code Online (Sandbox Code Playgroud)