Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!this.store) {
this.store = initLocalStore(getLocalStorageKey(repository, view, path))
if (!this.store.supported) {
this.setState({
localStorageNotSupported: true
})
}
}
let committedEditorState
if (view === 'new') {
committedEditorState = Raw.deserialize(blank, {terse: true})
} else {
try {
const json = JSON.parse(repository.blob.text)
committedEditorState = Raw.deserialize(json, {terse: true})
} catch (e) {
console.log('parsing error', e)
}
}
let localState = this.store.getAll()
let localEditorState
if (localState && localState.editorState && localState.commit) {
try {
localEditorState = Raw.deserialize(localState.editorState, {terse: true})
} catch (e) {
console.log('parsing error', e)
}
}
if (localEditorState) {
const parseValue = (v, initialState, terse) => {
resetKeyGenerator();
if (!v) {
return Plain.deserialize('');
}
const value = JSON.parse(JSON.stringify(v));
try {
return Raw.deserialize(value, { terse });
} catch (err1) {
try {
return Raw.deserialize(value, { terse: !terse });
} catch (err2) {
console.error('Couldnt parse value in slate', err1, err2);
return initialState
? parseValue(initialState, undefined, { terse })
: Plain.deserialize('');
}
}
};
var parseValue = function (v, initialState, terse) {
resetKeyGenerator();
if (!v) {
return Plain.deserialize('');
}
var value = JSON.parse(JSON.stringify(v));
try {
return Raw.deserialize(value, { terse: terse });
}
catch (err1) {
try {
return Raw.deserialize(value, { terse: !terse });
}
catch (err2) {
console.error('Couldnt parse value in slate', err1, err2);
return initialState
? parseValue(initialState, undefined, { terse: terse })
: Plain.deserialize('');
}
}
};
var defaultGetValue = function (_a) {
const parseValue = (v, initialState, terse) => {
resetKeyGenerator();
if (!v) return Plain.deserialize('');
const value = JSON.parse(JSON.stringify(v));
try { return Raw.deserialize(value, { terse }); }
catch (err1) {
try { return Raw.deserialize(value, { terse: !terse }); }
catch (err2) {
console.error('Couldnt parse value in slate', err1, err2);
return initialState ? parseValue(initialState, undefined, { terse }) : Plain.deserialize('');
}
}
};
export const getDemoState = () => Raw.deserialize(demoState, { terse: true });
const parseValue = (value, initialState, terse) => {
resetKeyGenerator();
try { return Raw.deserialize(value, { terse }); }
catch(err) {
try { return Raw.deserialize(value, { terse: !terse }); }
catch(err) {
return initialState ? parseValue(initialState, undefined, { terse }) : Plain.deserialize('');
}
}
};
const defaultGetValue = ({ value }) => value;
const parseValue = (value, initialState, terse) => {
try { return Raw.deserialize(value, { terse }); }
catch (err) {
try { return Raw.deserialize(value, { terse: !terse }); }
catch(err){
return initialState ? Raw.deserialize(initialState, { terse }) : Plain.deserialize('');
}
}
};
const defaultGetValue = ({ value }) => value;
const parseValue = (value, initialState, terse) => {
try { return Raw.deserialize(value, { terse }); }
catch (err) {
try { return Raw.deserialize(value, { terse: !terse }); }
catch(err){
return initialState ? Raw.deserialize(initialState, { terse }) : Plain.deserialize('');
}
}
};
const defaultGetValue = ({ value }) => value;
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Editor, Raw } from 'slate';
const initialState = Raw.deserialize({
nodes: [
{
kind: 'block',
type: 'paragraph',
nodes: [
{
kind: 'text',
text: '',
},
],
},
],
}, { terse: true });
export default class TextEditor extends Component {
constructor(props) {
.then(fileContent => {
let editorState = Raw.deserialize(JSON.parse(fileContent), {
terse: true
});
editorState = mapFilesToEditorState(fileList, editorState);
dispatch({
type: t.FOLDER_EDITOR_INIT,
payload: {
path: path,
editorState: editorState
}
});
});
} else {