全部對話框中獲取輸入字段值。從TinyMCE
我很難搞清楚這是第二次需要用tinyMCE做點什麼,但是這次我找不到答案。
以下是我想要做的事情:我在編輯器中添加了一個按鈕,打開一個帶有單個文本輸入字段和按鈕的新彈出窗口。我想單擊按鈕並獲取我在輸入字段中設置的值,然後使用該值修改我在編輯器中的內容。
這裏是我迄今爲止 - 唯一的相關代碼:
init : function(ed, url) {
ed.addCommand('mceTooltip', function() {
ed.windowManager.open({
file: 'imageurl.html',
width: 480,
height: 180,
inline: 1,
title: 'Please enter an image URL'
}, {});
});
}
這是imageurl.html有:
<input type="text" id="image-url" />
<input type="button" id="submit-image-url" value="Ok" />
所以,我需要做的是得到任何「圖像 - url「文本輸入每當我點擊確定按鈕,並在我的編輯器中使用該文本。我知道我可以使用ed.selection.setContent(fieldValue),它將用image-url值替換我選中的文本,我只是不知道如何獲取圖片url值。
我能找到的最詳細的信息是http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser,但我無法滿足我的需求。 任何人都可以幫我解決這個問題嗎?我確信對於有更多經驗的人來說,這應該很簡單。
謝謝大家的關注。
更新imageurl.html **
<script>
document.getElementById('submit-image-url').onclick = function(){
var imageUrl = document.getElementById('image-url').value;
window.parent.tinyMCE.activeEditor.execCommand('mceInsertContent', 0, imageUrl);
window.parent.tinyMCEPopup.close(); // this line gets me this error: "Uncaught TypeError: Cannot read property 'windowManager' of undefined "
};
</script>
什麼是圖像的URL?它從何而來? – Thariama 2013-04-23 07:44:48
image-url是一個文本字段,我將粘貼一個圖片url,然後當我點擊OK時,我想能夠在我的編輯器中使用該URL – andrux 2013-04-24 16:22:50