0
A
回答
0
我建议使用事件来捕获工具应用时,然后应用你以后的具体行为。
目前没有很好的方式来访问这些事件(我将在未来的版本中看到),但同时这里有一个解决方法,它给你你以后的行为,并且应用到任何工具都应该相对简单:
// Override the behaviour of the `ToolboxUI.tools` method so that we can
// bind to the applied event for the tools of interest.
var superTools = ContentTools.ToolboxUI.prototype.tools;
ContentTools.ToolboxUI.prototype.tools = function (tools) {
superTools.call(this, tools);
function _followWithP(ev) {
var element = ev.detail().element;
// Find the top level element
if (element.parent().type() !== 'Region') {
element = element.closest(function(node) {
return node.parent().type() === 'Region';
});
}
// Find the newely insert element
var newElement = element.nextSibling();
// Check if this is the last item in the region
var siblings = newElement.parent().children;
if (newElement === siblings[siblings.length - 1]) {
// This is the last child so apply add a paragraph
var p = new ContentEdit.Text('p', {}, '');
newElement.parent().attach(p);
p.focus();
}
}
// Modify the applied behaviour of the image, table and video tools to use
// `_followWithP`.
this._toolUIs['image'].addEventListener('applied', _followWithP);
this._toolUIs['table'].addEventListener('applied', _followWithP);
this._toolUIs['video'].addEventListener('applied', _followWithP);
}
相关问题
- 1. jQuery UI标签动态添加标签和内容不工作
- 2. 添加自定义视图到标签
- 3. 自动添加工具栏
- 4. 在html body标签内添加内容
- 5. 在视频上添加标签iOS
- 6. 添加内容标签布局
- 7. ASP.Net - AJAX控件工具包 - 动态添加和删除标签
- 8. Infobubble仅显示来自通过PHP/Mysql添加的标签添加的最后一个标记的内容
- 9. 如何添加自定义图标stimulsoft工具,工具栏
- 10. 你在Subversion和CVS中调用添加自动内容的标签是什么?
- 11. 添加视频
- 12. 添加标签到主视图
- 13. 空视图添加任何内容
- 14. Drupal:将内容添加到视图
- 15. 添加内容(图片和文字)到jQuery的工具水平滚动
- 16. 在android工具栏中添加视图
- 17. 将工具栏添加到视图
- 18. 将标签添加到图像NodeJS ImageMagick
- 19. 使用选项标签添加图像
- 20. 将随机图像添加到标签
- 21. LWUIT:将GIF图像添加到标签
- 22. 添加div后图像移出容器
- 23. APEX_MAIL将图像添加到内容
- 24. 添加图像到工具栏
- 25. 添加工具提示图像从PHP
- 26. 添加图像到视图
- 27. Safari添加书签视图
- 28. TinyMCE:禁用自动添加标签
- 29. Joomla 1.6自动添加h1标签
- 30. 自动添加<a>标签