gpt4 book ai didi

trix - 有没有一种简便的方法可以从Trix工具栏中删除特定按钮,而无需创建自定义工具栏

转载 作者:行者123 更新时间:2023-12-03 16:09:13 26 4
gpt4 key购买 nike

有没有简便的方法可以从Trix工具栏中删除“降低水平”和“升高水平”按钮?

现在,我可以通过使用以下haml简单地渲染自定义工具栏(不包含令人讨厌的按钮)来实现此目的:

%trix-toolbar#trix-toolbar-1
.trix-button-row
%span.trix-button-group.trix-button-group--text-tools{"data-trix-button-group" => "text-tools"}
%button.trix-button.trix-button--icon.trix-button--icon-bold{"data-trix-attribute" => "bold", "data-trix-key" => "b", :tabindex => "-1", :title => "Bold", :type => "button"} Bold
%button.trix-button.trix-button--icon.trix-button--icon-italic{"data-trix-attribute" => "italic", "data-trix-key" => "i", :tabindex => "-1", :title => "Italic", :type => "button"} Italic
%button.trix-button.trix-button--icon.trix-button--icon-link.trix-active{"data-trix-action" => "link", "data-trix-active" => "", "data-trix-attribute" => "href", "data-trix-key" => "k", :tabindex => "-1", :title => "Link", :type => "button"} Link
%span.trix-button-group.trix-button-group--block-tools{"data-trix-button-group" => "block-tools"}
%button.trix-button.trix-button--icon.trix-button--icon-heading-1{"data-trix-attribute" => "heading1", :tabindex => "-1", :title => "Heading", :type => "button"} Heading
%button.trix-button.trix-button--icon.trix-button--icon-quote{"data-trix-attribute" => "quote", :tabindex => "-1", :title => "Quote", :type => "button"} Quote
%button.trix-button.trix-button--icon.trix-button--icon-code{"data-trix-attribute" => "code", :tabindex => "-1", :title => "Code", :type => "button"} Code
%button.trix-button.trix-button--icon.trix-button--icon-bullet-list{"data-trix-attribute" => "bullet", :tabindex => "-1", :title => "Bullets", :type => "button"} Bullets
%button.trix-button.trix-button--icon.trix-button--icon-number-list{"data-trix-attribute" => "number", :tabindex => "-1", :title => "Numbers", :type => "button"} Numbers
%span.trix-button-group-spacer
%span.trix-button-group.trix-button-group--history-tools{"data-trix-button-group" => "history-tools"}
%button.trix-button.trix-button--icon.trix-button--icon-undo{"data-trix-action" => "undo", "data-trix-key" => "z", :disabled => "disabled", :tabindex => "-1", :title => "Undo", :type => "button"} Undo
%button.trix-button.trix-button--icon.trix-button--icon-redo{"data-trix-action" => "redo", "data-trix-key" => "shift+z", :disabled => "disabled", :tabindex => "-1", :title => "Redo", :type => "button"} Redo
.trix-dialogs{"data-trix-dialogs" => ""}
.trix-dialog.trix-dialog--link.trix-active{"data-trix-active" => "", "data-trix-dialog" => "href", "data-trix-dialog-attribute" => "href"}
.trix-dialog__link-fields
%input.trix-input.trix-input--dialog{"aria-label" => "URL", "data-trix-input" => "", :name => "href", :placeholder => "Enter a URL…", :required => "", :type => "url"}/
.trix-button-group
%input.trix-button.trix-button--dialog{"data-trix-method" => "setAttribute", :type => "button", :value => "Link"}/
%input.trix-button.trix-button--dialog{"data-trix-method" => "removeAttribute", :type => "button", :value => "Unlink"}/
%trix-editor{ input: 'about_page_body', class: 'trix-editor', tabindex: '2', toolbar: 'trix-toolbar-1' }

但是如果API发生更改,我希望可以使用javascript做到这一点。遵循以下几点可能会更好:
Trix.config.blockAttributes.decreaseBlockLevel.hide = true
Trix.config.blockAttributes.increaseBlockLevel.hide = true

最佳答案

找到了一个很简单的方法:

.trix-button--icon-increase-nesting-level,
.trix-button--icon-decrease-nesting-level { display: none; }

CSS来解救。

关于trix - 有没有一种简便的方法可以从Trix工具栏中删除特定按钮,而无需创建自定义工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52616297/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com