向 WMD (Stack Overflow) 编辑器添加自定义按钮

发布于 2024-10-01 16:49:50 字数 170 浏览 0 评论 0原文

如何在 WMD 编辑器中添加新按钮,例如 code按钮?如果我单击按钮 标记将添加到选定的文本上,如代码按钮。

How can I add a new button in the WMD editor, like the code button? If I click on the button <info></info> tag will add on the selected text like code button.

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

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

发布评论

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

评论(1

誰ツ都不明白 2024-10-08 16:49:50

该存储库有一个较新版本,名为 wmd-new。正如 StackOverflow 博客中所述,此版本使用 CSS sprites 以获得更好的性能。因此工具栏是一个图形:

在此处输入图像描述

存储库中有一个用于工具栏的 PSD (Photoshop) 文件您可以编辑。基本上,您需要向 wmd.css 和 wmd.js 文件添加一个新按钮。查看 CSS 中的第 93 行,您会看到:

/* sprite button slicing style information */
#wmd-button-bar #wmd-bold-button    {left: 0px;   background-position: 0px 0;}
#wmd-button-bar #wmd-italic-button  {left: 25px;  background-position: -20px 0;}
#wmd-button-bar #wmd-spacer1        {left: 50px;}
#wmd-button-bar #wmd-link-button    {left: 75px;  background-position: -40px 0;}
#wmd-button-bar #wmd-quote-button   {left: 100px;  background-position: -60px 0;}
#wmd-button-bar #wmd-code-button    {left: 125px;  background-position: -80px 0;}
#wmd-button-bar #wmd-image-button   {left: 150px;  background-position: -100px 0;}
#wmd-button-bar #wmd-spacer2        {left: 175px;}
#wmd-button-bar #wmd-olist-button   {left: 200px;  background-position: -120px 0;}
#wmd-button-bar #wmd-ulist-button   {left: 225px; background-position: -140px 0;}
#wmd-button-bar #wmd-heading-button {left: 250px; background-position: -160px 0;}
#wmd-button-bar #wmd-hr-button      {left: 275px; background-position: -180px 0;}
#wmd-button-bar #wmd-spacer3        {left: 300px;}
#wmd-button-bar #wmd-undo-button    {left: 325px; background-position: -200px 0;}
#wmd-button-bar #wmd-redo-button    {left: 350px; background-position: -220px 0;}
#wmd-button-bar #wmd-help-button    {right: 0px; background-position: -240px 0;}

请注意上面的 wmd-button-bar 的原始样式以及 left 的使用方式。

There is a newer version of the repository called wmd-new. As described on the StackOverflow blog this version uses CSS sprites for better performance. So the toolbar is a single graphic:

enter image description here

There is a PSD (Photoshop) file for the toolbar in the repository that you can edit. Basically you need to add a new button to the wmd.css and the wmd.js files. Look around line 93 in the CSS and you'll see:

/* sprite button slicing style information */
#wmd-button-bar #wmd-bold-button    {left: 0px;   background-position: 0px 0;}
#wmd-button-bar #wmd-italic-button  {left: 25px;  background-position: -20px 0;}
#wmd-button-bar #wmd-spacer1        {left: 50px;}
#wmd-button-bar #wmd-link-button    {left: 75px;  background-position: -40px 0;}
#wmd-button-bar #wmd-quote-button   {left: 100px;  background-position: -60px 0;}
#wmd-button-bar #wmd-code-button    {left: 125px;  background-position: -80px 0;}
#wmd-button-bar #wmd-image-button   {left: 150px;  background-position: -100px 0;}
#wmd-button-bar #wmd-spacer2        {left: 175px;}
#wmd-button-bar #wmd-olist-button   {left: 200px;  background-position: -120px 0;}
#wmd-button-bar #wmd-ulist-button   {left: 225px; background-position: -140px 0;}
#wmd-button-bar #wmd-heading-button {left: 250px; background-position: -160px 0;}
#wmd-button-bar #wmd-hr-button      {left: 275px; background-position: -180px 0;}
#wmd-button-bar #wmd-spacer3        {left: 300px;}
#wmd-button-bar #wmd-undo-button    {left: 325px; background-position: -200px 0;}
#wmd-button-bar #wmd-redo-button    {left: 350px; background-position: -220px 0;}
#wmd-button-bar #wmd-help-button    {right: 0px; background-position: -240px 0;}

Note how the original styling of wmd-button-bar and the how left is being used above.

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