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
16
utils/get-lines.js
Normal file
16
utils/get-lines.js
Normal file
@ -0,0 +1,16 @@
|
||||
const { isEmpty } = require('lodash');
|
||||
|
||||
// TODO: secure with tests
|
||||
function getLines(contents, range) {
|
||||
if (isEmpty(range)) {
|
||||
return '';
|
||||
}
|
||||
const lines = contents.split('\n');
|
||||
const editableLines =
|
||||
isEmpty(lines) || range[1] <= range[0]
|
||||
? []
|
||||
: lines.slice(range[0], range[1] - 1);
|
||||
return editableLines.join('\n');
|
||||
}
|
||||
|
||||
exports.getLines = getLines;
|
Reference in New Issue
Block a user