Cleanup some unused code. Minor update in the readme and examples

This commit is contained in:
jos 2017-07-08 11:48:32 +02:00
parent ea06b877b8
commit ee85fb099d
5 changed files with 3 additions and 34 deletions

View File

@ -157,16 +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] 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 (text: string, path: string[], input: string, editor: JSONEditor)`
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. 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:* *Parameters:*
- `text` : The text in the current node part. (basically the text that the user is editing) - `text` : The text in the current node part. (basically the text that the user is editing)
- `path` : The path of the node that is being edited. - `path` : The path of the node that is being edited as an array with strings.
- `input` : Can be "field" or "value" depending if the user is editing a field name or a value of a node. - `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. - `editor` : The editor instance object that is being edited.
*Returns:* *Returns:*

View File

@ -31,7 +31,6 @@
// create the editor // create the editor
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var options = { var options = {
modes: ['text', 'tree'],
autocomplete: { autocomplete: {
getOptions: function () { getOptions: function () {
return ['apple', 'cranberry', 'raspberry', 'pie', 'mango', 'mandarine', 'melon', 'appleton']; return ['apple', 'cranberry', 'raspberry', 'pie', 'mango', 'mandarine', 'melon', 'appleton'];

View File

@ -32,7 +32,6 @@
// create the editor // create the editor
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var options = { var options = {
modes: ['text', 'tree'],
autocomplete: { autocomplete: {
applyTo:['value'], applyTo:['value'],
getOptions: function (text, path, input, editor) { getOptions: function (text, path, input, editor) {

View File

@ -34,7 +34,6 @@
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var activationChar = '*'; var activationChar = '*';
var options = { var options = {
modes: ['text', 'tree'],
autocomplete: { autocomplete: {
confirmKeys: [39, 35, 9, 190], // Confirm Autocomplete Keys: [right, end, tab, '.'] // By default are only [right, end, tab] confirmKeys: [39, 35, 9, 190], // Confirm Autocomplete Keys: [right, end, tab, '.'] // By default are only [right, end, tab]

View File

@ -372,34 +372,6 @@ Node.prototype.getLevel = function() {
return (this.parent ? this.parent.getLevel() + 1 : 0); return (this.parent ? this.parent.getLevel() + 1 : 0);
}; };
/**
* Get path of the root node till the current node
* @return {String} Returns a jsonpath of the current node in the form: node1.child1.child2, node1.array1[0].child, etc.
*/
Node.prototype.getNodeJsonPath = function () {
var path = this.parent ? this.parent.getNodePath() : [];
path.push(this);
var strPath = '';
path.forEach(function (node) {
strPath += !node.parent
? '$' // do not add an (optional) field name of the root node
: (node.parent.type != 'array')
? '.' + node.field
: '[' + node.index + ']';
});
return strPath;
};
/**
* Get jsonpath of the current node
* @return {Node[]} Returns an array with nodes
*/
Node.prototype.getNodePath = function () {
var path = this.parent ? this.parent.getNodePath() : [];
path.push(this);
return path;
};
/** /**
* Create a clone of a node * Create a clone of a node
* The complete state of a clone is copied, including whether it is expanded or * The complete state of a clone is copied, including whether it is expanded or