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>標籤