-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to sync node expand/collapse operations across editors (#…
…1440) * Add support to get notified when a JSON node is expanded/collapsed. * Added onExpand callback option to be passed while creating JSONEditor * The callback is invoked when the expand/collapse is done non-programatically * Add API to expand/collapse a given node * Added JSONEditor.expand() method * Add example to demostrate syncing expanded nodes across editors * Added examples/25_sync_node_expand.html
- Loading branch information
Showing
5 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>JSONEditor | Sync Node Expand</title> | ||
|
||
<link href="../dist/jsoneditor.css" rel="stylesheet" type="text/css"> | ||
<script src="../dist/jsoneditor.js"></script> | ||
|
||
<style type="text/css"> | ||
#jsoneditor-left { | ||
width: 45%; | ||
height: 90%; | ||
float: left; | ||
margin-left: 2%; | ||
} | ||
#jsoneditor-right { | ||
width: 45%; | ||
height: 90%; | ||
float: right; | ||
margin-right: 2%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div> | ||
<div id="jsoneditor-left"></div> | ||
<div id="jsoneditor-right"></div> | ||
</div> | ||
|
||
<script> | ||
const left_json = { | ||
'student_details': { | ||
'name': { | ||
'first_name': 'foo', | ||
'last_name': 'bar' | ||
}, | ||
'school': { | ||
'name': 'foo', | ||
'address': 'bar' | ||
}, | ||
'contact': '434343', | ||
'age': '39' | ||
}, | ||
'marks': [50, 49, 36] | ||
} | ||
|
||
const right_json = { | ||
'marks': [50, 49], | ||
'student_details': { | ||
'name': 'foo bar', | ||
'address': { | ||
'street': 'foo', | ||
'city': 'bar', | ||
'zip': '444444' | ||
}, | ||
'school': { | ||
'name': 'foo', | ||
'address': 'bar' | ||
}, | ||
'age': '39', | ||
'contact': ['434355', '343433', '324343'] | ||
} | ||
} | ||
|
||
const editor_left = new JSONEditor(document.getElementById('jsoneditor-left'), { | ||
mode: "tree", | ||
onExpand: (options) => { | ||
if (editor_right) { | ||
editor_right.expand(options) | ||
} | ||
} | ||
}, left_json) | ||
|
||
const editor_right = new JSONEditor(document.getElementById('jsoneditor-right'), { | ||
mode: "tree", | ||
onExpand: (options) => { | ||
if (editor_left) { | ||
editor_left.expand(options) | ||
} | ||
} | ||
}, right_json) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters