From 7f6e7459df96355aecf0c5d7fc239fa8d2dd74c3 Mon Sep 17 00:00:00 2001 From: jos Date: Fri, 5 Aug 2016 11:21:16 +0200 Subject: [PATCH] Fixed preact errors regarding `contentEditable` --- src/JSONNode.js | 14 ++++++-------- src/Main.js | 4 ++-- src/develop.html | 8 +++++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/JSONNode.js b/src/JSONNode.js index 6372a18..6760d39 100644 --- a/src/JSONNode.js +++ b/src/JSONNode.js @@ -53,7 +53,6 @@ export default class JSONNode extends Component { this.renderExpandButton(), this.renderContextMenuButton(), this.renderProperty(path, data, options), - this.renderSeparator(), // TODO: remove separator for Object and Array (gives an issue in Preact) this.renderReadonly(`{${childCount}}`, `Array containing ${childCount} items`) ]) ] @@ -81,7 +80,6 @@ export default class JSONNode extends Component { this.renderExpandButton(), this.renderContextMenuButton(), this.renderProperty(path, data, options), - this.renderSeparator(), // TODO: remove separator for Object and Array (gives an issue in Preact) this.renderReadonly(`[${childCount}]`, `Array containing ${childCount} items`) ]) ] @@ -105,7 +103,7 @@ export default class JSONNode extends Component { renderJSONValue ({path, data, options}) { return h('li', {}, [ h('div', {class: 'jsoneditor-node'}, [ - h('div', {class: 'jsoneditor-button-placeholder'}), + h('div', {class: 'jsoneditor-button-placeholder', contentEditable: 'false'}), this.renderContextMenuButton(), this.renderProperty(path, data, options), this.renderSeparator(), @@ -115,7 +113,7 @@ export default class JSONNode extends Component { } renderReadonly (text, title = null) { - return h('div', {class: 'jsoneditor-readonly', contentEditable: false, title}, text) + return h('div', {class: 'jsoneditor-readonly', contentEditable: 'false', title}, text) } renderProperty (path, data, options) { @@ -153,7 +151,7 @@ export default class JSONNode extends Component { } renderSeparator() { - return h('div', {class: 'jsoneditor-separator'}, ':') + return h('div', {class: 'jsoneditor-separator', contentEditable: 'false'}, ':') } renderValue (value) { @@ -163,7 +161,7 @@ export default class JSONNode extends Component { return h('div', { class: valueClass, - contentEditable: true, + contentEditable: 'true', spellCheck: 'false', onInput: this.handleChangeValue, onClick: this.handleClickValue, @@ -174,7 +172,7 @@ export default class JSONNode extends Component { renderExpandButton () { const className = `jsoneditor-button jsoneditor-${this.props.data.expanded ? 'expanded' : 'collapsed'}` - return h('div', {class: 'jsoneditor-button-container'}, + return h('div', {class: 'jsoneditor-button-container', contentEditable: 'false'}, h('button', {class: className, onClick: this.handleExpand}) ) } @@ -183,7 +181,7 @@ export default class JSONNode extends Component { const className = 'jsoneditor-button jsoneditor-contextmenu' + (this.props.data.contextMenu ? ' jsoneditor-visible' : '') - return h('div', {class: 'jsoneditor-button-container'}, + return h('div', {class: 'jsoneditor-button-container', contentEditable: 'false'}, this.props.data.contextMenu ? this.renderContextMenu(this.props.data.contextMenu) : null, diff --git a/src/Main.js b/src/Main.js index c476bb9..64f9022 100644 --- a/src/Main.js +++ b/src/Main.js @@ -47,8 +47,8 @@ export default class Main extends Component { } render() { - return h('div', {class: 'jsoneditor', onClick: this.handleHideContextMenu}, [ - h('ul', {class: 'jsoneditor-list'}, [ + return h('div', {class: 'jsoneditor', contentEditable: 'false', onClick: this.handleHideContextMenu}, [ + h('ul', {class: 'jsoneditor-list', contentEditable: 'false'}, [ h(JSONNode, { data: this.state.data, events: this.state.events, diff --git a/src/develop.html b/src/develop.html index 7b7e4a4..e0fbb07 100644 --- a/src/develop.html +++ b/src/develop.html @@ -20,6 +20,8 @@ const editor = jsoneditor(container, options); const json = { 'array': [1, 2, 3], + 'emptyArray': [], + 'emptyObject': {}, 'boolean': true, 'null': null, 'number': 123, @@ -28,9 +30,9 @@ }; editor.set(json, { name: 'myObject', - expand: function (path) { - return true - } +// expand: function (path) { +// return true +// } }); // set json