Fix objects/arrays not copied correctly to clipboard
This commit is contained in:
parent
a869fa0f3a
commit
76e4bf5e16
|
@ -1,10 +1,12 @@
|
||||||
import { deleteIn, getIn, setIn, transform } from './utils/immutabilityHelpers'
|
import mapValues from 'lodash/mapValues'
|
||||||
import { compileJSONPointer, parseJSONPointer } from './jsonPointer'
|
|
||||||
import first from 'lodash/first'
|
import first from 'lodash/first'
|
||||||
import last from 'lodash/last'
|
import last from 'lodash/last'
|
||||||
import initial from 'lodash/initial'
|
import initial from 'lodash/initial'
|
||||||
import isEmpty from 'lodash/isEmpty'
|
import isEmpty from 'lodash/isEmpty'
|
||||||
import isEqual from 'lodash/isEqual'
|
import isEqual from 'lodash/isEqual'
|
||||||
|
|
||||||
|
import { deleteIn, getIn, setIn, transform } from './utils/immutabilityHelpers'
|
||||||
|
import { compileJSONPointer, parseJSONPointer } from './jsonPointer'
|
||||||
import { immutableJSONPatch } from './immutableJSONPatch'
|
import { immutableJSONPatch } from './immutableJSONPatch'
|
||||||
import { compareArrays } from './utils/arrayUtils'
|
import { compareArrays } from './utils/arrayUtils'
|
||||||
import { compareStrings } from './utils/stringUtils'
|
import { compareStrings } from './utils/stringUtils'
|
||||||
|
@ -82,7 +84,6 @@ export function syncEson(json, eson) {
|
||||||
updatedEson[ID] = sameType ? eson[ID] : createId()
|
updatedEson[ID] = sameType ? eson[ID] : createId()
|
||||||
updatedEson[TYPE] = jsonType
|
updatedEson[TYPE] = jsonType
|
||||||
updatedEson[EXPANDED] = sameType ? eson[EXPANDED] : false
|
updatedEson[EXPANDED] = sameType ? eson[EXPANDED] : false
|
||||||
|
|
||||||
return updatedEson
|
return updatedEson
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -100,7 +101,6 @@ export function syncEson(json, eson) {
|
||||||
updatedEson[TYPE] = jsonType
|
updatedEson[TYPE] = jsonType
|
||||||
updatedEson[VALUE] = json
|
updatedEson[VALUE] = json
|
||||||
updatedEson[EXPANDED] = false
|
updatedEson[EXPANDED] = false
|
||||||
updatedEson.valueOf = () => json
|
|
||||||
|
|
||||||
return updatedEson
|
return updatedEson
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,21 @@ export function syncEson(json, eson) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an ESON object into JSON, strip all symbols and change
|
||||||
|
* regular values back.
|
||||||
|
* @param {ESON} eson
|
||||||
|
* @returns {JSON}
|
||||||
|
*/
|
||||||
|
export function toJSON(eson) {
|
||||||
|
if (eson[TYPE] === 'array' || eson[TYPE] === 'object') {
|
||||||
|
return mapValues(eson, toJSON)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return eson[VALUE]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand or collapse all items matching a filter callback
|
* Expand or collapse all items matching a filter callback
|
||||||
* @param {ESON} eson
|
* @param {ESON} eson
|
||||||
|
@ -389,8 +404,10 @@ export function applySelection (eson, selection) {
|
||||||
* @return {Array.<{name: string, value: JSON, state: Object}>}
|
* @return {Array.<{name: string, value: JSON, state: Object}>}
|
||||||
*/
|
*/
|
||||||
export function contentsFromPaths (eson, paths) {
|
export function contentsFromPaths (eson, paths) {
|
||||||
|
console.log('contents')
|
||||||
|
|
||||||
return paths.map(path => {
|
return paths.map(path => {
|
||||||
const value = getIn(eson, path.concat(VALUE))
|
const value = toJSON(getIn(eson, path))
|
||||||
return {
|
return {
|
||||||
name: last(path),
|
name: last(path),
|
||||||
value,
|
value,
|
||||||
|
|
Loading…
Reference in New Issue