- move 'editor' parameter to the last position
- send standard array path instead of jsonpath in getOptions
This commit is contained in:
parent
d423a70a5d
commit
495ed38063
|
@ -157,15 +157,16 @@ Constructs a new JSONEditor.
|
|||
|
||||
Indicate the KeyCodes for trigger confirm completion, by default those keys are: [39, 35, 9] which are the code for [right, end, tab]
|
||||
|
||||
- `{Function} getOptions (editor: object, text: string, path: string, input: string)`
|
||||
- `{Function} getOptions (editor: object, text: string, path: string[], input: string)`
|
||||
|
||||
This function will return your possible options for create the autocomplete selection, you can control dynamically which options you want to display according to the current active editing node.
|
||||
|
||||
*Parameters:*
|
||||
- `editor` : The editor instance object that the node belongs to.
|
||||
|
||||
- `text` : The text in the current node part. (basically the text that the user is editing)
|
||||
- `path` : The json path of the node that is being edited.
|
||||
- `path` : The path of the node that is being edited.
|
||||
- `input` : Can be "field" or "value" depending if the user is editing a field name or a value of a node.
|
||||
- `editor` : The editor instance object that the node belongs to.
|
||||
|
||||
*Returns:*
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
modes: ['text', 'tree'],
|
||||
autocomplete: {
|
||||
applyTo:['value'],
|
||||
getOptions: function (editor, text) {
|
||||
getOptions: function (text, path, input, editor) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var options = extractUniqueWords(editor.get());
|
||||
if (options.length > 0) resolve(options); else reject();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
autocomplete: {
|
||||
confirmKeys: [39, 35, 9, 190], // Confirm Autocomplete Keys: [right, end, tab, '.'] // By default are only [right, end, tab]
|
||||
|
||||
getOptions: function (editor, text, path, input) {
|
||||
getOptions: function (text, path, input, editor) {
|
||||
if (!text.startsWith(activationChar) || input !== 'value') return [];
|
||||
var data = {};
|
||||
var startFrom = 0;
|
||||
|
|
|
@ -1115,7 +1115,7 @@ treemode._onKeyDown = function (event) {
|
|||
// Activate autocomplete
|
||||
setTimeout(function (hnode, element) {
|
||||
if (element.innerText.length > 0) {
|
||||
var result = this.options.autocomplete.getOptions(hnode.editor, element.innerText, hnode.getNodeJsonPath(), jsonElementType);
|
||||
var result = this.options.autocomplete.getOptions(element.innerText, hnode.getPath(), jsonElementType, hnode.editor);
|
||||
if (typeof result.then === 'function') {
|
||||
// probably a promise
|
||||
if (result.then(function (obj) {
|
||||
|
|
Loading…
Reference in New Issue