Skip to content

Commit 74ff84b

Browse files
committed
Add new WYSIWYG example. Version bump.
1 parent 1afe5a4 commit 74ff84b

File tree

5 files changed

+68
-17
lines changed

5 files changed

+68
-17
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-editor",
3-
"version": "0.7.4",
3+
"version": "0.7.5",
44
"authors": [
55
"Jeremy Dorn <[email protected]>"
66
],

dist/jsoneditor.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/*! JSON Editor v0.7.4 - JSON Schema -> HTML Editor
1+
/*! JSON Editor v0.7.5 - JSON Schema -> HTML Editor
22
* By Jeremy Dorn - https://github.com/jdorn/json-editor/
33
* Released under the MIT license
44
*
5-
* Date: 2014-07-29
5+
* Date: 2014-08-10
66
*/
77

88
/**
@@ -1735,9 +1735,10 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
17351735
return;
17361736
}
17371737

1738-
value = value || '';
1739-
if(typeof value === "object") value = JSON.stringify(value);
1740-
if(typeof value !== "string") value = ""+value;
1738+
if(value === null) value = "";
1739+
else if(typeof value === "object") value = JSON.stringify(value);
1740+
else if(typeof value !== "string") value = ""+value;
1741+
17411742
if(value === this.serialized) return;
17421743

17431744
// Sanitize value before setting it
@@ -1780,7 +1781,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
17801781
this.jsoneditor.notifyWatchers(this.path);
17811782
},
17821783
getNumColumns: function() {
1783-
var min = Math.ceil(this.getTitle().length/5);
1784+
var min = Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);
17841785
var num;
17851786

17861787
if(this.input_type === 'textarea') num = 6;
@@ -3888,12 +3889,12 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
38883889
this.container.appendChild(this.title);
38893890
this.title_controls = this.theme.getHeaderButtonHolder();
38903891
this.title.appendChild(this.title_controls);
3891-
this.panel = this.theme.getIndentedPanel();
3892-
this.container.appendChild(this.panel);
38933892
if(this.schema.description) {
38943893
this.description = this.theme.getDescription(this.schema.description);
3895-
this.panel.appendChild(this.description);
3894+
this.container.appendChild(this.description);
38963895
}
3896+
this.panel = this.theme.getIndentedPanel();
3897+
this.container.appendChild(this.panel);
38973898
this.error_holder = document.createElement('div');
38983899
this.panel.appendChild(this.error_holder);
38993900
}
@@ -4842,9 +4843,10 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
48424843

48434844
self.value = self.enum_values[self.enum_options.indexOf(val)];
48444845

4846+
self.watch_listener();
4847+
self.notify();
48454848
if(self.parent) self.parent.onChildEditorChange(self);
48464849
else self.jsoneditor.onChange();
4847-
self.jsoneditor.notifyWatchers(self.path);
48484850
});
48494851

48504852
this.control = this.theme.getFormControl(this.label, this.input, this.description);

dist/jsoneditor.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/wysiwyg.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>JSON Editor WYSIWYG Example</title>
6+
<script src="../dist/jsoneditor.js"></script>
7+
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
8+
<script src="//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.bbcode.min.js"></script>
9+
<link rel="stylesheet" href="//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.default.min.css">
10+
<script src="//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.xhtml.min.js"></script>
11+
<link rel="stylesheet" href="//cdn.jsdelivr.net/sceditor/1.4.3/themes/default.min.css">
12+
</head>
13+
<body>
14+
<h1>JSON Editor WYSIWYG Example</h1>
15+
16+
<p style='margin-bottom:20px;'>This example demonstrates JSONEditor's integration with SCEditor</p>
17+
18+
<div id='editor_holder'></div>
19+
<button id='submit'>Submit (console.log)</button>
20+
21+
<script>
22+
// Initialize the editor with a JSON schema
23+
var editor = new JSONEditor(document.getElementById('editor_holder'),{
24+
schema: {
25+
type: "object",
26+
title: "Blog Post",
27+
properties: {
28+
title: {
29+
type: "string"
30+
},
31+
body: {
32+
type: "string",
33+
format: "html",
34+
options: {
35+
wysiwyg: true
36+
}
37+
}
38+
}
39+
}
40+
});
41+
42+
// Hook up the submit button to log to the console
43+
document.getElementById('submit').addEventListener('click',function() {
44+
// Get the value from the editor
45+
console.log(editor.getValue());
46+
});
47+
</script>
48+
</body>
49+
</html>

src/intro.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/*! JSON Editor v0.7.4 - JSON Schema -> HTML Editor
1+
/*! JSON Editor v0.7.5 - JSON Schema -> HTML Editor
22
* By Jeremy Dorn - https://github.com/jdorn/json-editor/
33
* Released under the MIT license
44
*
5-
* Date: 2014-07-29
5+
* Date: 2014-08-10
66
*/
77

88
/**

0 commit comments

Comments
 (0)