禁用tinymce可视化编辑器的书签?

发布于 2024-11-17 05:05:45 字数 658 浏览 4 评论 0原文

我正在寻找一个书签来禁用tinymce可视化编辑器。也就是说,一些代码可以粘贴到地址栏中以禁用编辑器(也可以添加书签)。

有人有什么想法吗?

我想使用它的页面正在使用旧版本的 TinyMce,我认为此页面上使用的版本相同: http://www.imathas.com/editordemo/demo.html

只是重申一下,我想删除 TinyMce 编辑器并保留文本区域。

如果您想查看我正在谈论的功能,您还可以访问此示例页面: http://www.matracas.org/sentido/tinymce/examples/full.html 并单击编辑器下方的启用/禁用按钮。

这里的问题是语法依赖于知道要放入 .get() 函数中的编辑器 ID。

tinyMCE.get('elm1').hide();
tinyMCE.get('elm1').show();

理想情况下,小书签仅使用tinMCE 的显示/隐藏功能,但它适用于页面上的所有编辑器。

I'm looking for a bookmarklet to disable the tinymce visual editor. This is to say, some code that could be pasted into the address bar to disable the editor (and also bookmarked).

Anyone have any ideas?

The page I want to use it on is using an older version of TinyMce, I think the same version that is used on this page: http://www.imathas.com/editordemo/demo.html

Just to reiterate, I want to remove the TinyMce editor and leave the textarea.

If you would like to see the functionality I am talking about, you could also visit this example page: http://www.matracas.org/sentido/tinymce/examples/full.html and click on the enable / disable buttons below the editor.

The problem here is that the syntax relies on knowing what editor id to put into the .get() function.

tinyMCE.get('elm1').hide();
tinyMCE.get('elm1').show();

The bookmarklet would ideally just use tinMCE's show / hide functionality, but it would work for all editors on a page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巷子口的你 2024-11-24 05:05:45

干得好!

javascript:(function(){var arr=Object.keys(tinyMCE.editors);for(var i=0;i<arr.length;i++){try{tinyMCE.editors[arr[i]].remove();}catch(e){}}})()

看起来更令人愉悦,但代码相同:

javascript:
(function(){
  var arr=Object.keys(tinyMCE.editors);
  for(var i=0;i<arr.length;i++){
    try{
      tinyMCE.editors[arr[i]].remove();
    }
    catch(e){
    }
  }
}
)()

Here you go!

javascript:(function(){var arr=Object.keys(tinyMCE.editors);for(var i=0;i<arr.length;i++){try{tinyMCE.editors[arr[i]].remove();}catch(e){}}})()

More visibly pleasing, but same code:

javascript:
(function(){
  var arr=Object.keys(tinyMCE.editors);
  for(var i=0;i<arr.length;i++){
    try{
      tinyMCE.editors[arr[i]].remove();
    }
    catch(e){
    }
  }
}
)()
饮惑 2024-11-24 05:05:45

我用 jQuery 启动我的所有小书签,尽管根据您想要执行的操作,这可能作为greasemonkey 脚本效果更好。

javascript:
function loadScript(url, callback){
        var head = document.getElementsByTagName("head")[0];
        var script = document.createElement("script");
        script.src = url;

        var done = false;
        script.onload = script.onreadystatechange = function()        {
                if( !done && ( !this.readyState 
                                        || this.readyState == "loaded" 
                                        || this.readyState == "complete") )
                {
                        done = true;

                        callback();

                        script.onload = script.onreadystatechange = null;
                        head.removeChild( script );
                }
        };

        head.appendChild(script);
}

loadScript("http://code.jquery.com/jquery-latest.js", function(){
    jQuery('.mceEditor').remove(); }

I start all my bookmarklets with jQuery, although this may work better as a greasemonkey script depending on what you're trying to do.

javascript:
function loadScript(url, callback){
        var head = document.getElementsByTagName("head")[0];
        var script = document.createElement("script");
        script.src = url;

        var done = false;
        script.onload = script.onreadystatechange = function()        {
                if( !done && ( !this.readyState 
                                        || this.readyState == "loaded" 
                                        || this.readyState == "complete") )
                {
                        done = true;

                        callback();

                        script.onload = script.onreadystatechange = null;
                        head.removeChild( script );
                }
        };

        head.appendChild(script);
}

loadScript("http://code.jquery.com/jquery-latest.js", function(){
    jQuery('.mceEditor').remove(); }
秋风の叶未落 2024-11-24 05:05:45

我已将 TinyMCE 删除程序添加到我的书签集合中:
http://richardbronosky.github.com/Perfect-Bookmarklets/tinymce.html

与我见过的其他产品相比,它有一个主要优点。它将文本区域的内容恢复到源中的内容。我不知道其他人是否经历过这种情况,但我们的 CMS 和 TinyMCE 有一个网络管理员,删除后会使代码发生变化。我已经解决了这个问题。

这是代码:

  for(var i=0;i<tinymce.editors.length;i++){
    var tmpId=tinymce.editors[i].id;
    var tmpVal=document.getElementById(tmpId).value;
    tinyMCE.execCommand("mceRemoveControl",true,tmpId);
    document.getElementById(tmpId).value=tmpVal
  }

也在 github 上:
https://github.com/RichardBronosky/Perfect-Bookmarklets/blob/master /tinymce.html

I have added a TinyMCE remover to my bookmarklet collection:
http://richardbronosky.github.com/Perfect-Bookmarklets/tinymce.html

It has one major advantage over the others I have seen. It restores the content of the textarea back to what was in the source. I don't know if others have experienced this, but we have a web admin to our CMS and TinyMCE, when removed leaves the code altered. I have resolved this.

Here is the code:

  for(var i=0;i<tinymce.editors.length;i++){
    var tmpId=tinymce.editors[i].id;
    var tmpVal=document.getElementById(tmpId).value;
    tinyMCE.execCommand("mceRemoveControl",true,tmpId);
    document.getElementById(tmpId).value=tmpVal
  }

Also on github:
https://github.com/RichardBronosky/Perfect-Bookmarklets/blob/master/tinymce.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文