pull/21833/head
Bruno Windels 2019-05-14 15:49:53 +01:00
parent 0b18ff52c5
commit fd31e793d1
3 changed files with 8 additions and 5 deletions

View File

@ -37,7 +37,8 @@ function walkDOMDepthFirst(editor, enterNodeCallback, leaveNodeCallback) {
}
export function getCaretOffsetAndText(editor, sel) {
let {focusOffset, focusNode} = sel;
let {focusNode} = sel;
const {focusOffset} = sel;
let caretOffset = focusOffset;
let foundCaret = false;
let text = "";

View File

@ -171,6 +171,8 @@ export default class EditorModel {
/**
* removes `len` amount of characters at `pos`.
* @param {Object} pos
* @param {Number} len
* @return {Number} how many characters before pos were also removed,
* usually because of non-editable parts that can only be removed in their entirety.
*/
@ -205,10 +207,12 @@ export default class EditorModel {
/**
* inserts `str` into the model at `pos`.
* @param {Object} pos
* @param {string} str
* @return {Number} how far from position (in characters) the insertion ended.
* This can be more than the length of `str` when crossing non-editable parts, which are skipped.
*/
_addText(pos, str, actions) {
_addText(pos, str) {
let {index} = pos;
const {offset} = pos;
let addLen = str.length;

View File

@ -40,9 +40,7 @@ export function renderModel(editor, model) {
}
return lines;
}, [[]]);
// console.log(lines.map(parts => parts.map(p => p.toString())));
// TODO: refactor this code, DRY it
lines.forEach((parts, i) => {
let lineContainer = editor.childNodes[i];
while (lineContainer && (lineContainer.tagName !== "DIV" || !!lineContainer.className)) {