Javascript 如何从新的windowManager窗口进行更改?

Javascript 如何从新的windowManager窗口进行更改?,javascript,tinymce,tinymce-4,Javascript,Tinymce,Tinymce 4,我对JavaScript相当陌生,所以我在做事情的同时也在学习。在实习期间,我被要求调整所见即所得html编辑器,以便它可以用于电子邮件。我正在使用占位符,稍后将由用户替换 我的问题:如何检测文本框中的输入并在编辑器中替换它 我看了其他的帖子,比如一篇,但我还是无法让它发挥作用 到目前为止,我的代码是: setup: function(ed) { // on mouse up gets selected text ed.on('mouseup', function(ed,

我对JavaScript相当陌生,所以我在做事情的同时也在学习。在实习期间,我被要求调整所见即所得html编辑器,以便它可以用于电子邮件。我正在使用占位符,稍后将由用户替换

我的问题:如何检测文本框中的输入并在编辑器中替换它

我看了其他的帖子,比如一篇,但我还是无法让它发挥作用

到目前为止,我的代码是:

setup: function(ed) {
    // on mouse up gets selected text
        ed.on('mouseup', function(ed, e) {
            var highlighted = tinyMCE.activeEditor.selection.getContent();
            // Checks if highlighted texts contains a placeholder
            if (highlighted.indexOf("[!") > -1) {
                //alert(highlighted);
                tinyMCE.activeEditor.windowManager.open({
                    title: 'replace',
                    width: 320,
                    height: 240,
                    body: [
                        {type: 'textbox'}
                    ]
                })
            }
        });
    }

提前谢谢

我已经弄明白了!如果人们想知道我是如何做到的,下面是我的代码:

setup: function(ed) {
    // on mouse up gets selected text
        ed.on('mouseup', function(ed) {
            var highlighted = tinyMCE.activeEditor.selection.getContent();
            // Checks if highlighted texts contains a placeholder
            if (highlighted.indexOf("[!") > -1) {
                //alert(highlighted);
                tinyMCE.activeEditor.windowManager.open({
                    title: 'Replace placeholder',
                    file: 'namechange.html',
                    width: 320,
                    height: 80,
                })
            }
        });
    }
下面是“namechange.html”文件的外观:

<body>
    <input type="text" id="namechange"/>
    <input type="button" id="submit-namechange" value="Oké"/>
    <script>
        document.getElementById('submit-namechange').onclick = function(){
            var namechange = document.getElementById('namechange').value;

            window.parent.tinyMCE.get('editor1').selection.setContent(namechange);
            window.parent.tinyMCE.activeEditor.windowManager.close();
        };
    </script>
    <script src="scripts/settings.js"></script>
</body>

document.getElementById('submit-namechange')。onclick=function(){
var namechange=document.getElementById('namechange').value;
window.parent.tinyMCE.get('editor1').selection.setContent(namechange);
window.parent.tinyMCE.activeEditor.windowManager.close();
};