AceEditor Module Error on loading ext-lang_tools.js

Using Javascript from SpiderBasic
skinkairewalker
Posts: 122
Joined: Tue Jun 14, 2016 7:17 pm

AceEditor Module Error on loading ext-lang_tools.js

Post by skinkairewalker »

Guys, I'm trying to use this module : https://github.com/spiderbytes/AceEditor
from Peter, but when I load the ext-language_tools.js from the Ace Editor, it throws a bunch of errors : screenshot https://prnt.sc/Ypezs0bwvZWC .
The weird thing is that sometimes it works. Is there any way to fix this?

trying loading

Code: Select all

  
Procedure Init(Callback)

  ! require([
  !   "https://cdnjs.cloudflare.com/ajax/libs/ace/1.40.0/ace.js",
   ; LOADING LANG TOOLS<-------------------------------------------
  !   "https://cdnjs.cloudflare.com/ajax/libs/ace/1.40.0/ext-language_tools.min.js"
  ! ], function() {

    IsInitialized = #True

  !   v_callback();
  ! });

EndProcedure

Procedure BindGadget(Gadget)

  GetSelector

  ! editor = ace.edit(selector[0]);

  ! ace.require("ace/ext/language_tools");
  
 ; SETTINGS<-------------------------------------------
  ! editor.setOptions({
  !   enableBasicAutocompletion: true,
  !   enableSnippets: true,
  !   enableLiveAutocompletion: true
  ! });

  ! selector.data("editor", editor);

  ! spider.DojoAspect.after(dijit.byId(spider_GadgetID(v_gadget).gadget.id), "resize", function() {
    Resize(Gadget)
  ! });

EndProcedure
ERROR ON BROWSER CONSOLE :

Code: Select all

:9080/spiderbasic/libraries/javascript/ace/lib/dom.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
:9080/spiderbasic/libraries/javascript/ace/lib/oop.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
ace.js:1 misspelled option "enableBasicAutocompletion"
a @ ace.js:1
ace.js:1 misspelled option "enableSnippets"
a @ ace.js:1
ace.js:1 misspelled option "enableLiveAutocompletion"
a @ ace.js:1
:9080/spiderbasic/libraries/javascript/ace/lib/event_emitter.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/lib/lang.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/range.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/range_list.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/tokenizer.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/keyboard/hash_handler.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/clipboard.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/virtual_renderer.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/editor.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/lib/event.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/lib/useragent.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/config.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
:9080/spiderbasic/libraries/javascript/ace/lib/scroll.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28
dojo.js:28 Error: scriptError
    at l (dojo.js:2:382)
    at HTMLScriptElement.<anonymous> (dojo.js:27:69)
(anonymous) @ dojo.js:28

Dirk Geppert
Posts: 345
Joined: Fri Sep 22, 2017 7:02 am

Re: AceEditor Module Error on loading ext-lang_tools.js

Post by Dirk Geppert »

ChatGPT means:

Your problem had two main causes:

Ace was loaded through Dojo’s require(), so Ace’s internal modules (like ace/lib/dom.js, ace/range.js, etc.) were requested from
:9080/spiderbasic/libraries/javascript/ace/...
Those files don’t exist there ⇒ 404 errors.

You were using a non-existent/failing Ace CDN version, so ext-language_tools never loaded correctly.
Because of that, Ace didn’t know the options
enableBasicAutocompletion, enableSnippets, enableLiveAutocompletion
⇒ Ace complained they were “misspelled options”.

Fix: load Ace and ext-language_tools as normal <script> tags (or correct local paths), not via Dojo’s AMD loader, and use a valid Ace version.

Code: Select all

Procedure Init(Callback)

  ; Ace NICHT über dojo.require laden, sondern als normale Scripts
  ! var aceScript = document.createElement("script");
  ! aceScript.src = "https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.3/ace.js";
  ! aceScript.onload = function () {

  !   var langToolsScript = document.createElement("script");
  !   langToolsScript.src = "https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.3/ext-language_tools.js";
  !   langToolsScript.onload = function () {

        ; SpiderBasic-Teil läuft im onload von ext-language_tools
        IsInitialized = #True

  !     v_callback();   // ruft das übergebene Callback aus SpiderBasic auf
  !   };

  !   document.head.appendChild(langToolsScript);
  ! };

  ! document.head.appendChild(aceScript);

EndProcedure


Procedure BindGadget(Gadget)

  GetSelector   ; liefert dir "selector" (jQuery-Objekt) für dieses Gadget

  ; Ace-Editor auf das Gadget binden
  ! var editor = ace.edit(selector[0]);

  ; Sprachextension laden (ist durch ext-language_tools.js schon registriert,
  ; der Aufruf schadet aber nicht)
  ! ace.require("ace/ext/language_tools");

  ; Autocomplete-Optionen aktivieren
  ! editor.setOptions({
  !   enableBasicAutocompletion: true,
  !   enableSnippets: true,
  !   enableLiveAutocompletion: true
  ! });

  ; Editor im Gadget speichern (falls du später nochmal dran willst)
  ! selector.data("editor", editor);

  ; Editor bei Gadget-Resize mitziehen
  ! spider.DojoAspect.after(
  !   dijit.byId(spider_GadgetID(v_gadget).gadget.id),
  !   "resize",
  !   function () {
        Resize(Gadget)
  !   }
  ! );

EndProcedure

skinkairewalker
Posts: 122
Joined: Tue Jun 14, 2016 7:17 pm

Re: AceEditor Module Error on loading ext-lang_tools.js

Post by skinkairewalker »

Awesome Dirk Geppert !!!
thanks :)
Post Reply