josdejong / josdejong/jsoneditor

Feature request - events handling with more informations

Open
#39 12 comments 1 reaction 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
12.3k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,
I want to use jsoneditor in a large project, but to do so I need to interact more deeply with the editor. To do so I need to handle events like : click, double click, right click, etc.
I patched the latest editor release but I'm unsure how to submit my modifications si here is a proposition :
Line 2753 add :

``` javascript
case 'contextmenu':
if(this.editor.options.contextmenu) this.editor.options.contextmenu(event,target,dom,node);
break;
```

Line 2735 add :

``` javascript
case 'dblclick':
if(this.editor.options.dblclick) this.editor.options.dblclick(event,target,dom,node);
break;
case 'click':
if(this.editor.options.click) this.editor.options.click(event,target,dom,node);
break;
```

Line 2711 add :

``` javascript
case 'contextmenu':
if(this.editor.options.contextmenu) this.editor.options.contextmenu(event,target,dom,node);
break;

```

Line 2693 add :

``` javascript
case 'dblclick':
if(this.editor.options.dblclick) this.editor.options.dblclick(event,target,dom,node);
break;
```

Line 2662 add :

``` javascript
// Modif YB
if(type == 'click' && this.editor.options.click) this.editor.options.click(event,target,dom,node);

```

Line 524 add :

``` javascript
// Modif YB oncontextmenu
this.frame.oncontextmenu = function (event) {
onEvent(event);
jsoneditor.util.preventDefault(event);
return false;
};
// Modif YB ajout du dblclick
this.frame.ondblclick = function (event) {
onEvent(event);

// prevent default submit action when JSONEditor is located inside a form
jsoneditor.util.preventDefault(event);
};
```

This allows me basically to fully handle events, including interacting with the clicked elements etc.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.