本来想试下 actiontext, 结果发现 trix 这玩意是真的不怎么好用,而且 toolbar 还没法 i18n,虽然 wiki 里有写,https://github.com/basecamp/trix/wiki/I18n , 结果发现没用。
还真试过,也试过你发的 lite 版的,不过这个项目用了 activestorage,发现上传图片不能像 actiontext 一样处理,就又用回 actiontext。搞了半天,trix 的 Trix.config.lang 根本没效果,最后还是暴力解决,直接把 toolbar 覆盖掉了,
Trix.config.toolbar = {
getDefaultHTML: function() {
return `
<div class="trix-button-row">
<span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="加粗" tabindex="-1">加粗</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="斜体" tabindex="-1">斜体</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="删除线" tabindex="-1">删除线</button>
</span>
<span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-heading-1 trix-active" data-trix-attribute="heading1" title="标题" tabindex="-1" data-trix-active="">标题</button>
</span>
<span class="trix-button-group trix-button-group--file-tools" data-trix-button-group="file-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-attach" data-trix-action="attachFiles" title="上传图片" tabindex="-1">上传图片</button>
</span>
<span class="trix-button-group-spacer"></span>
<span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="撤销" tabindex="-1" disabled="">撤销</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="重做" tabindex="-1" disabled="">重做</button>
</span>
</div>
`
}
}