javascript - 创建 CKEditor 插件时,如何将 "colorpicker"添加到我的对话框中?

标签 javascript jquery colors ckeditor

  1. 用户点击我的插件按钮。
  2. 弹出对话框,其中有一些文本框等。
  3. 在该对话框中,用户可以单击一个按钮,然后会弹出一个颜色选择器,让用户选择他想要的颜色。

最佳答案

今天我也遇到了同样的问题。这是我的解决方案,它实际上是 CKEditor 4.2 的 TableCell 插件的复制粘贴。希望对您有帮助

CKEDITOR.dialog.add( 'myDialog', function( editor ) {
return {
    title: 'Add Data',
    minWidth: 300,
    minHeight: 200,
    contents: [
        {
            id: 'dataTab',
            label: 'Line',
            title: 'Line',
            elements: [
                ...
                {   
                    type: "hbox",
                    padding: 0,
                    widths: ["80%", "20%"],
                    children: [
                        {
                            id: 'linecolor',
                            type: 'text',
                            label: 'Line color',
                            setup: function( element ) {
                                ...
                            },
                            commit: function( element ) {
                                ...
                            }
                        },
                        {
                            type: "button",
                            id: "lineColorChooser",
                            "class": "colorChooser",
                            label: "Choose",
                            style: "margin-left: 8px",
                            onLoad: function () {
                                this.getElement().getParent().setStyle("vertical-align", "bottom")
                            },
                            onClick: function () {
                                editor.getColorFromDialog(function (color) {
                                    color && this.getDialog().getContentElement("dataTab", "linecolor").setValue( color );
                                    this.focus()
                                }, this)
                            }
                        }
                    ]
                },
                ...
            ]
        }
    ],

};
});

关于javascript - 创建 CKEditor 插件时,如何将 "colorpicker"添加到我的对话框中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8813872/

相关文章:

javascript - jQuery 验证 : form always valid issue

javascript - 在 Spring MVC 中的 AJAX 响应中发送文件

javascript - SVG:单击按钮后触发 animateTransform 上的单击事件

java - Java中文本颜色的意义是什么? (为什么 public/private = red | class = cyan)

javascript - 带参数的 Mocha 茶单元测试

javascript - 在 Visual Studio Code 中使用react智能感知

javascript - jquery检测输入焦点

jquery - Css 悬停在元素之前

c# - 根据值更改 DataGrid 单元格颜色

html - 快疯了...无法设置字体颜色