在CKEditor中,如何添加“文本”按钮上的标签?

发布于 2024-12-21 01:38:24 字数 349 浏览 1 评论 0原文

editor.ui.addButton( 'ImageUpload',{
                label: 'Upload Image',
                command: 'popup_image_uploader',
                icon: this.path + 'images/icon.png'
            });

这就是我现在的代码。当您加载页面时,您只能看到该图标。

但如果您访问此处的演示,您会看到“Source”是一个文本。我想在图标旁边添加“上传图像”一词。

editor.ui.addButton( 'ImageUpload',{
                label: 'Upload Image',
                command: 'popup_image_uploader',
                icon: this.path + 'images/icon.png'
            });

That's my current code right now. When you load the page, you only see the icon.

But if you go to the demo here, you'll see that "Source" is a text. I want to add the word "Upload Image" next to the icon.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

陌若浮生 2024-12-28 01:38:24

CKeditor 工具栏按钮的标签有一个类 .cke_label,默认情况下具有 display:none,因此按钮仅是图标:

.cke_skin_kama .cke_button .cke_label {
    ...
    display: none;
    ...
}

就像 Source 按钮,你必须使用 CSS 来显示你的标签。

通常在创建按钮CKeditor时添加一个类似.cke_button_CMDNAMEHERE的类,其中CMDNAMEHERE是命令的名称。因此,您将:

.cke_skin_kama .cke_button_CMDNAMEHERE .cke_label {
   display: inline;
}

检查 html 源代码以查看添加的类的确切名称,并相应地制定 CSS 规则。

The label for CKeditor toolbar buttons have a class .cke_label which has by default display:none so the buttons are icon-only:

.cke_skin_kama .cke_button .cke_label {
    ...
    display: none;
    ...
}

Like for the Source button, you have to use CSS to show your label.

Normally when creating the button CKeditor add a class like .cke_button_CMDNAMEHERE where CMDNAMEHERE being the name of your command. So you'll have:

.cke_skin_kama .cke_button_CMDNAMEHERE .cke_label {
   display: inline;
}

Check the html source to see the exact name of the added class and make your CSS rule accordingly.

柒夜笙歌凉 2024-12-28 01:38:24

另一种解决方案是仅使用 css ":before" 或 ":after" 伪类在按钮之前/之后添加一些自定义内容。

例如,自定义“链接”按钮:

创建一些空间(取决于内容的长度):

.cke_button_icon.cke_button__link_icon {
padding-right: 25px;
}

添加内容:

.cke_button_icon.cke_button__link_icon:after {
content: "Link";
position: relative;
left: 15px;
}

another solution would be to just use the css ":before" or ":after" pseudo class to add some custom content before / after the buttons.

for example, customizing the "link" button:

create some space (depends on length of content):

.cke_button_icon.cke_button__link_icon {
padding-right: 25px;
}

add content:

.cke_button_icon.cke_button__link_icon:after {
content: "Link";
position: relative;
left: 15px;
}
暮年 2024-12-28 01:38:24
.cke_button_label.cke_button__CMDNAMEHERE{
   display: inline;
}

将适用于所有皮肤,与上面的答案不同(请注意按钮和 CMDNAME 之间的双下划线),

您可以将其放置在您自己的 css 中的任何位置

.cke_button_label.cke_button__CMDNAMEHERE{
   display: inline;
}

will work for all skins, unlike the answer above(note the double underscore between buttons and CMDNAMEHERE)

you can place it anywhere in your own css

衣神在巴黎 2024-12-28 01:38:24

在当前的ckeditor(4.6.x)中,上面的答案对我不起作用。

我在 ckeditor/skins/moono-list/editor.css 中进行了挖掘,并搜索了“源”以查找他们如何执行带有文本的“源”按钮。我发现了这一点:

.cke_button__source_label,
.cke_button__sourcedialog_label
{
    display:inline
}

请注意,自定义按钮名称之前有两个下划线。当我尝试只使用一个下划线时,它不起作用。

无论如何,您可以将上面的“source”或“sourcedialog”替换为您想要的任何内容,并将其添加到您自己的css文件中。

此外,它似乎只适用于完全小写的按钮名称。

In the current ckeditor (4.6.x) the answers above do not work for me.

I dug around in ckeditor/skins/moono-list/editor.css and did a search for "source" to find how they did the Source button which has text. I found this:

.cke_button__source_label,
.cke_button__sourcedialog_label
{
    display:inline
}

Notice that there are TWO underscores here before the name of your custom button. When I tried with only one underscore it did not work.

Anyway you would replace "source" or "sourcedialog" above with whatever you want and add that to your own css file.

Additionally, it seems to only work for button names that are entirely lowercase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文