我正在尝试为„ bootstrap卡“ 基本上基本上是”只是一个div元素。一旦用户单击我的新插件按钮,我该如何使已插入的卡可选卡当然可以编辑?奖励问题:;-)是否有任何关于Tinymce插件撰写的全面教程的建议?
I'm trying to author my very first plugin for tinymce. Now, how do I make an element selectable? With the official image-plugin for example the user can click on a already inserted image, it visually gets focused and the image-plugin-button gets focused as well - see gif. Let's say I want to write a plugin that inserts a „Bootstrap Card“ which basically is just a div element. How do I make an already inserted Card selectable plus of course editable once the users clicks my new plugin button? Bonus question: ;-) Any suggestion for a comprehensive tutorial on tinymce plugin authoring?

发布评论
评论(2)
首先要回答奖励问题,在Tinymce博客上有一篇文章浏览创建自己的Tinymce插件,示例是
本文中降低转换的HTML,在“将插件添加到编辑器”标题下,Shahed Nasser写下了将自定义插件按钮添加到中的步骤工具栏。在该标题下检查有关获取自定义工具栏图标启动和运行的更多信息。
对于Bootstrap卡项目问题 - 因此,听起来您的用户选择卡片时,您需要以下内容:
第一步是识别卡项。 Tinymce.html.domparser API具有一种方法,该方法将过滤编辑器中的特定节点,并允许您在匹配过滤器的任何节点上运行一个函数。您可以在此处找到API文档 -
这正达到我对做什么的知识的限制为了使您的自定义插件运行。
To answer the bonus question first, there is an article on the TinyMCE blog that walks through creating your own TinyMCE plugin, with the example being an HTML to Markdown transformation
In the article, under the "Add the plugin to the editor" heading, Shahed Nasser writes the steps for adding the custom plugin button to the toolbar. Check under that heading for more information on getting the custom toolbar icon up and running.
For the Bootstrap Card item question – so it sounds like when your users select the Card, you need the following:
The first step would be to identify the card items. The TinyMCE.html.DOMparser API has a method that will filter for a specific node within the editor, and allow you to run a function on any nodes that match the filter. You can find the API docs here - https://www.tiny.cloud/docs/tinymce/6/apis/tinymce.html.domparser/#addNodeFilter
That's reaching the limits of my knowledge of what to do, hopefully the docs and article help give you the first steps to get your custom plugin going.
我正在开发与您所描述的类似的东西,并且发现此示例代码及其readme.md文件有用
只需添加可满足的属性设置为false,这将使元素成为元素,并且它的内容是不可编辑的,因此您可以t在Tinymce编辑器中单击它的内部,然后编辑内容,但仅选择整个Div。
在选择元素时将插件按钮“ active”:
要定义插件按钮时使用“ statelector”:
我强烈建议在继续之前阅读整个读数文件。
I am developing something similar to what u described and I found this example code and its README.md file helpful
to make an element selectable:
just add contenteditable attribute set to false, which will make the element and it's content uneditable, so you can’t click inside of it in the TinyMCE editor and edit the contents, but only select the whole div.
to make plugin button "active" when element is selected :
when you want to define your plugin button use "stateSelector":
I highly recommend reading the entire readme file before proceeding.