1
我試圖在Aloha中設置一個自定義操作,添加一個將所選文本放入span類的按鈕。Aloha編輯器 - 獲取突出顯示的文本並用html代碼替換
舉例: 你選擇了「如字」
,它會改變它的
<span>example word</span>
我的問題是,我不能讓所選文本從阿羅哈甚至更少重新插入的那一刻它。
從文檔,這些線繼續返回什麼:
var range;
if (Aloha.getSelection().rangeCount > 0) {
range = Aloha.getSelection().getRangeAt(0);
}
全碼:
var redHighlight = "";
Aloha.require(['ui/ui', 'ui/button'], function(Ui, Button) {
var redButton = Ui.adopt("redButton", Button, {
tooltip: 'Label',//gives inner text
click: function(){
var range;
if (Aloha.getSelection().rangeCount > 0) {
range = Aloha.getSelection().getRangeAt(0);
}
console.log(range); //returns nothing
}
});
});
Aloha.settings.toolbar = {
tabs: [
{
label: 'Urgent',
components: [ 'redButton' ],
}
],
exclude: [ 'strong', 'emphasis', 'strikethrough' ]
};
編輯1: 我去阿羅哈論壇這個問題,從國防部我得到在輸出重新插入html可能會導致一些DOM問題,我第一次錯過了文檔,範圍功能與我正在開發/谷歌Chrome不兼容。
仍有意雖然解決:)
由於提前,
對不起,我遲到的驗證,會嘗試這並獲得abck你。謝謝 – jonBreizh