Feat: editable dom element (#39341)
* feat: __testEditable allows editable region tests It's not entirely isolated, but it makes it possible to select only the element with id 'editable-only' which is built solely from code inside the editable region. * fix(client): missing editableContents -> '' Previously it was added as the string 'undefined' * fix: more informative error messages * fix: DRY, correct and test getLines
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
a1a051bd3a
commit
9df098953d
@@ -3,6 +3,7 @@ import { createAction, handleActions } from 'redux-actions';
|
||||
import { createTypes } from '../../../../utils/stateManagement';
|
||||
|
||||
import { createPoly } from '../../../../../utils/polyvinyl';
|
||||
import { getLines } from '../../../../../utils/get-lines';
|
||||
import challengeModalEpic from './challenge-modal-epic';
|
||||
import completionEpic from './completion-epic';
|
||||
import codeLockEpic from './code-lock-epic';
|
||||
@@ -131,18 +132,6 @@ export const createFiles = createAction(types.createFiles, challengeFiles =>
|
||||
)
|
||||
);
|
||||
|
||||
// TODO: secure with tests
|
||||
function getLines(contents, range) {
|
||||
if (isEmpty(range)) {
|
||||
return '';
|
||||
}
|
||||
const lines = contents.split('\n');
|
||||
const editableLines = isEmpty(lines)
|
||||
? []
|
||||
: lines.slice(range[0], range[1] - 1);
|
||||
return editableLines.join('\n');
|
||||
}
|
||||
|
||||
export const createQuestion = createAction(types.createQuestion);
|
||||
export const initTests = createAction(types.initTests);
|
||||
export const updateTests = createAction(types.updateTests);
|
||||
|
Reference in New Issue
Block a user