代码突出显示顶点(Firefox 31)

时间:2016-02-23 10:24:46

标签: oracle firefox oracle-apex highlighting

Oracle Application Express代码编辑器只是白色背景上的简单文本。没有代码突出显示。此外,如果没有文本字段失去焦点,我也无法按“标签”。

我正在使用firefox 31(无法升级,由管理员在这里重新定义)此外我无法安装插件。我知道你可以使用firefox中的特殊文件夹(“chrome”-folder / userContent.css)更改特定网站上的css。我已经用它来改变文本字段的默认大小,因为每次打开编辑页面时它都很小。

所以你知道我可以在Apex中使用的任何框架或脚本吗? (我每次都可以把那个狗屎复制到jsfiddle.net但是很糟糕

(我还在Firefox中找到了暂存器,它可以运行js和jquery。这有帮助吗?)

1 个答案:

答案 0 :(得分:1)

[解决] 因为你不能使用

    <script src = "">

等。在普通的js中,我不得不使用loadScript。对于css文件来说,它甚至更复杂,但我把它全部工作了。

这是我的代码,我在暂存器(firefox)中运行它。它使用ACE通过突出显示将div更改为编辑器。单击“应用”时,我将还原DOM中的编辑器更改,但保留文本/代码。

    // Load Ace js
    loadScript("http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js", function(){
        //initialization code
    });
    // Load Ace css
    var cssId = 'myCss';  // you could encode the css path itself to generate id..
    if (!document.getElementById(cssId)){
        var head  = document.getElementsByTagName('head')[0];
        var link  = document.createElement('link');
        link.id   = cssId;
        link.rel  = 'stylesheet';
        link.type = 'text/css';
        link.href = 'http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css';
        link.media = 'all';
        head.appendChild(link);
    }
    // change textarea to div
    var editorRegion = document.getElementById('F4000_P4651_PLUG_SOURCE_fieldset');
    editorRegion.innerHTML = editorRegion.innerHTML.replace("textarea","div");

    // run ACE
    highlight();


    // Modify the apply Button in Apex to first revert ACE-Editor to normal, then do the usual apply.
    var applyChanges = document.getElementById('B3456326662');
    applyChanges.setAttribute("onclick","modifiedApply()");
    function modifiedApply(){
      close();
      setTimeout(normalApply, 500);
    }
    function normalApply(){
      javascript:apex.submit('Apply_Changes');
    }

    // Revert ACE-Changes, but keep changed text/code.
    function close(){
        var value = editor.getValue();
        editor.destroy();
        var oldDiv = editor.container;
        var newDiv = oldDiv.cloneNode(false);
        newDiv.textContent = value;
        oldDiv.parentNode.replaceChild(newDiv, oldDiv);
        newDiv.outerHTML = newDiv.outerHTML.replace("div","textarea");
        var old_new_old = document.getElementById('F4000_P4651_PLUG_SOURCE');
        old_new_old.textContent = old_new_old.textContent.substring(0, old_new_old.textContent.length - 6);
    }
    var editor;
    function highlight() {
      editor = ace.edit("F4000_P4651_PLUG_SOURCE");
      editor.setTheme("ace/theme/monokai");
      editor.getSession().setUseWorker(false);
      editor.getSession().setMode("ace/mode/javascript");
      document.getElementsByClassName('ace_print-margin')[0].setAttribute("style","left:1000px");
    }


    function loadScript(url, callback){
        var script = document.createElement("script")
        script.type = "text/javascript";

        if (script.readyState){  //IE
            script.onreadystatechange = function(){
                if (script.readyState == "loaded" ||
                        script.readyState == "complete"){
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else {  //Others
            script.onload = function(){
                callback();
            };
        }
        script.src = url;
        document.getElementsByTagName("head")[0].appendChild(script);
    }
相关问题