Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
nodes.splice((currentPosition + 1), 0, clauseNodeJSON, paragraphSpaceNodeJSON);
const realNewMd = slateTransformer.toMarkdown(Value.fromJSON(newSlateValueAsJSON));
// update contract on store with new slate and md values
yield put(actions.documentEdited(Value.fromJSON(newSlateValueAsJSON), realNewMd));
const grammar = templateObj.parserManager.getTemplatizedGrammar();
// Temporary roundtrip and rebuild grammar
const grammarRound = roundTrip(grammar);
templateObj.parserManager.buildGrammar(grammarRound);
const sampleText = templateObj.getMetadata().getSamples().default;
const model = templateObj.getModelManager().getModels();
const logic = templateObj.getScriptManager().getLogic();
const clauseTemplateId = uuidv4(); // unique identifier for a clause template
// add a new clause template to the store so user can edit template
yield put(clauseTemplatesActions.addClauseTemplate({
metadata, model, logic, sampleText, grammar, id: clauseTemplateId, clauseId
}));
// add instatiated clause to list of clauses in the contract state
yield put(actions.addToContractSuccess(clauseId, clauseTemplateId));
} catch (err) {
console.error(err);
yield put(appActions.addAppError('Failed to add clause to contract', err));
}
}
uri: clauseTemplateRef
};
// get the templateObj from the store if we already have it or load if not
const templateObj = yield call(addTemplateObjectToStore, actionRedesign);
const metadata = templateObj.getMetadata();
const grammar = templateObj.parserManager.getTemplatizedGrammar();
// Temporary roundtrip and rebuild grammar
const grammarRound = roundTrip(grammar);
templateObj.parserManager.buildGrammar(grammarRound);
const sampleText = templateObj.getMetadata().getSamples().default;
const model = templateObj.getModelManager().getModels();
const logic = templateObj.getScriptManager().getLogic();
const clauseTemplateId = uuidv4(); // unique identifier for a clause template
// add a new clause template to the store so user can edit template
yield put(clauseTemplatesActions.addClauseTemplate({
metadata, model, logic, sampleText, grammar, id: clauseTemplateId, clauseId
}));
// add instatiated clause to list of clauses in the contract state
yield put(actions.pasteToContractSuccess(clauseId, clauseTemplateId));
} catch (err) {
yield put(appActions.addAppError('Failed to add clause to contract', err));
}
}
export function* addToContract(action) {
try {
// get the templateObj from the store if we already have it
// or load it and add it to the store if we do not
const templateObj = yield call(addTemplateObjectToStore, action);
const slateValue = yield select(contractSelectors.slateValue);
const metadata = templateObj.getMetadata();
// get the user's current position in Slate dom to insert clause at
const currentPosition = slateValue.selection.anchor.path.get(0);
const clauseId = uuidv4(); // unique identifier for a clause instance
const clauseMd = `\`\`\`
${metadata.getSample()}
\`\`\``;
// Create a new paragraph in JSON for spacing between clauses
const paragraphSpaceNodeJSON = {
object: 'block',
type: 'paragraph',
data: {
},
nodes: [
{
object: 'text',
text: '',
marks: []
}
import { CONSTANTS } from "../actions";
import uuid from "uuidv4";
console.log(uuid());
const initialState = ["board-0"];
const boardOrderReducer = (state = initialState, action) => {
switch (action.type) {
case CONSTANTS.ADD_BOARD: {
return [...state, `board-${action.payload.id}`];
}
default:
return state;
}
};
export default boardOrderReducer;
export const todoReducer: Reducer = (state: TodoState = defaultState, action: TodoAction): TodoState => {
switch (action.type) {
case Type.ADD_TODO: {
if (state.fetching) {
return state
}
const newTodo = {
id: uuid(),
done: false,
text: action.payload.text,
}
return { ...state, todos: [...state.todos, newTodo] }
}
case Type.UPDATE_TODO: {
if (state.fetching) {
return state
}
const index = state.todos.findIndex((todo: Todo) => todo.id === action.payload.id)
if (index === -1) {
return state
}
export const addCard = (listID, text) => {
const id = uuid();
return {
type: CONSTANTS.ADD_CARD,
payload: { text, listID, id }
};
};
export const addBoard = title => {
const id = uuid();
return {
type: CONSTANTS.ADD_BOARD,
payload: { title, id }
};
};
return (dispatch, getState) => {
const boardID = getState().activeBoard;
const id = uuid();
dispatch({
type: CONSTANTS.ADD_LIST,
payload: { title, boardID, id }
});
};
};