格式工具栏

I make a highly opinionated fork here :

https://github.com/linuxuser-gr/discourse-formatting-toolbar

It look like this and needs the maths plugin

Is there a way to move some buttons to the cog menu ;

1 个赞

The way to code the buttons in the cog menu is a bit different, you can take inspiration in my theme component : https://github.com/iunctis/md-composer-extras/blob/master/desktop/head_tag.html

Here is a button in the toolbar

api.onToolbarCreate(toolbar => {
    toolbar.addButton({
        id: "align_justify_button",
        group: "extras",
        icon: "align-justify",
        perform: e => e.applySurround('[wrap="justify"]\n', '\n[/wrap]', 'align_justify_text')
    });
});

Here is a button in the menu

api.addToolbarPopupMenuOptionsCallback(() => {
  return {
      action: "columns",
      icon: "columns",
      label: "columns_button"
  };
});

api.modifyClass("controller:composer", {
  actions: {
       columns() {
	  this.get("toolbarEvent").applySurround('[wrap="columns"]\n', '\n[/wrap]', "columns_text");
	}
  }
});
3 个赞

Yeah, TinyMCE WYSIWYG Editor is good option to work with. There are few other good providers as well. But I myself is familar to something old style of Wordpress, that’s why I would like to choose it.

我想知道这个插件是否可以作为主题组件使用?谢谢。

有一个主题组件:https://github.com/iunctis/md-composer-extras

有几种不同的选项,但或多或少是同一个想法

是的,谢谢史蒂文,但我缺少主题组件中用于文本着色的选项。理想情况下,它应该比 BBCode 更直观,并带有颜色选择器和预设文本。

坦白说,我不知道主题组件是否可以实现这样的功能。主题组件中有一个分支,包含一个基本的 bbcode 颜色选项 \u003chttps://github.com/iunctis/md-composer-extras/tree/color\u003e

我对编码只有非常基础的了解,所以我无法实现颜色选择器。但如果有人想升级插件,我很乐意接受 pull request!

哦,我真的很喜欢所有这些格式选项,而且我几乎只使用 floatr :wink:
我在哪里可以看到这个选项,就像上面引用的那样?
在经典主题中,没有 CSS 选项可以添加或禁用按钮
安装后我收到了这个错误:
/var/discourse# 在切片源时意外找到“! template-lint-disable ~”,但预期是“ template-lint-disable ”

我认为那个错误不是来自那个插件。因为我也遇到了同样的问题,但它并没有破坏任何东西。我猜它来自核心。

感谢 @Jagster 我添加了这个主题组件

然后“卸载”了插件,错误现在消失了,所以……

真有意思 :thinking: 因为我没用过。会不会有其他插件在使用类似的东西?

该死……我得去看看我是否在尝试过之后忘记了它 →

回来了。我确实用过,但它被注释掉了。第二次重建能解决问题吗?

几年前删除了这些选项,它与新版本的 Discourse 冲突。我没有知识或时间来重新实现它们,很遗憾。

关于您的问题,您需要在插件或主题组件之间进行选择,否则它将损坏,它们基本上共享相同的代码。

如果要尝试插件,请卸载主题组件。

请注意,此插件或主题组件也与官方 Discourse bbcode 等插件冲突。

2 个赞

也许/或许是时候更改置顶的通知帖子并禁用 GitHub 链接了?因为它基本上不起作用。

这是一个很棒的主意(谢谢),希望它能成为 Discourse 的标准功能,或者作为插件支持。

该插件有效,OP 中已删除对这些选项的提及,我已添加一些警告。目前没有理由进行编辑或停用该插件。

1 个赞

很棒的工具栏插件!想知道您是否可以为背景颜色添加双色 BBCode?

另一个有趣的想法是在工具栏中使用下拉菜单。例如,这在移动设备上可能很有用。

另外,想知道您的插件是否支持 BBCode 的主列表?

谢谢

我想我可以添加兼容性。代码的基础可以在这个官方插件中找到:discourse-bbcode-color/assets/javascripts/lib/discourse-markdown/bbcode-color.js at main · discourse/discourse-bbcode-color · GitHub

我会考虑的。我可能不会添加按钮 :thinking:

我已添加对以下BBCode的支持:

color=
size=
small
floatl
floatr
floatc
left
center
right
justify

1 个赞

非常感谢。是的,我们确实不需要为所有事情都设置按钮。
:clinking_beer_mugs::smiling_face_with_sunglasses::+1::sparkles: :discourse:

已添加对 [bgcolor] bbcode 的支持

1 个赞

您好!如果 bbcode 标签内的文本包含两个连续的换行符,或者一个换行符和一个回车符的序列:

[center]
text "\n\n" text
[/center]

[center]
text "\r\n" text
[/center]

那么在帖子中,我们会得到带有 [center][/center] 标签本身的纯文本。

但是通过这种方式:

[center]
text "\n" text
[/center]

或者这种方式:

[center]
text text
[/center]

bbcode 被正确包装,并且我得到了居中文本。

我曾认为这是 discourse 的限制,但也许我们可以对此做些什么?

您已启用富文本编辑器(第一个按钮),但该插件尚不兼容。\n\n上次我检查时,它应该可以与 Markdown 编辑器一起使用。

2 个赞