-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I've been reviewing the ZK wrapper around the ACE Javascript editor found at...
https://github.com/zkoss/zk8-datahandler/tree/master/datahandler-ace-code-editor
I can't get the auto complete features to work. Any suggestions?
I created my own version of this ace data handler, basing it around the https://github.com/ajaxorg/ace latest source.
However, when I run this I get an error in the data wrapper js
var editor = ace.edit(editor_id);
error = "ace is not defined"
What you can do is to check in the developer tools that the scripts are loaded as expected. If there are no network and console errors, I assume if the scripts load and execute.
After that's done the issue must be somewhere inside ACE editor or your configuration, which is somewhat outside the scope of this forum, unless there are errors caused by ZK.
One possible thing to narrow down the cause is to test the same setup on a plain non-ZK html/jsp page, with an html-<div>
. If that still doesn't give the results you need, then you have a case to ask in the ACE forums or their support.
If you identify a ZK issue you can refer to ZK support.
I've installed the 'src/min' version from the github location suggested.
I adapted the zk.xml to reference the js lib required for auto completion...
<zk>
<config-name>datahandler-ace-code-editor</config-name>
<client-config>
<data-handler>
<name>ace-code-editor</name> <!-- data-ace-code-editor -->
<link href="~./css/data-ace-code-editor.css" rel="stylesheet" /> <!-- custom css -->
<script src="~./js/lib/ace.js" /> <!-- ace.js Library -->
<script src="~./js/lib/ext-language_tools.js" /> <!-- ace.js Library -->
<script src="~./js/data-ace-code-editor.js" /> <!-- Data Handler Script -->
</data-handler>
</client-config>
</zk>
I then updated the data-ace-code-editor.js to switch on autocompletion..
function (wgt, dataValue) {
//Create a Div to init Ace
var wgtDOM = wgt.$n(),
editor_id = 'zk-ace-code-editor',
div = document.createElement('div'),
old = document.getElementById(editor_id);
if (old) old.remove();
jq(wgtDOM).hide();
div.setAttribute('id', editor_id);
div.setAttribute('class', 'data-ace');
jq(div).insertAfter(wgtDOM);
var editor = ace.edit(editor_id);
//settings
var settings = dataValue.length > 0 ? $.evalJSON(dataValue) : {};
if (settings.theme)
editor.setTheme(settings.theme);
if (settings.mode)
editor.getSession().setMode(settings.mode);
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
//Set the default value
editor.getSession().setValue(wgt.getValue());
//Synchronize the value
editor.getSession().on('change', function(){
wgt.setValue(editor.getSession().getValue());
wgt.fireOnChange();
});
}
When I run this I still don't get autocomplete working within ace. Any suggestions?
Instead of the raw sources you need to use the release/build versions ace provides in a separate "ace-builds" repository (e.g. tag v1.4.5).
I haven't tried that yet however it's the first thing that comes to mind based on your description.
Asked: 2019-06-18 21:02:28 +0800
Seen: 18 times
Last updated: Jun 20 '19