make logging quiet

This commit is contained in:
Bruno Windels 2019-05-13 17:45:54 +01:00
parent 4ff37ca046
commit a3b02cf0cc
3 changed files with 7 additions and 9 deletions

View file

@ -57,7 +57,6 @@ export default class MessageEditor extends React.Component {
}; };
this._editorRef = null; this._editorRef = null;
this._autocompleteRef = null; this._autocompleteRef = null;
// document.execCommand("insertBrOnReturn", undefined, true);
} }
_updateEditorState = (caret) => { _updateEditorState = (caret) => {
@ -75,8 +74,9 @@ export default class MessageEditor extends React.Component {
} }
_onInput = (event) => { _onInput = (event) => {
console.log("finding newValue", this._editorRef.innerHTML); const sel = document.getSelection();
const {caret, text} = getCaretOffsetAndText(this._editorRef, document.getSelection()); // console.log("finding newValue", this._editorRef.innerHTML, sel);
const {caret, text} = getCaretOffsetAndText(this._editorRef, sel);
this.model.update(text, event.inputType, caret); this.model.update(text, event.inputType, caret);
} }

View file

@ -80,8 +80,8 @@ export default class EditorModel {
update(newValue, inputType, caret) { update(newValue, inputType, caret) {
const diff = this._diff(newValue, inputType, caret); const diff = this._diff(newValue, inputType, caret);
const position = this._positionForOffset(diff.at, caret.atNodeEnd); const position = this._positionForOffset(diff.at, caret.atNodeEnd);
const valueWithCaret = newValue.slice(0, caret.offset) + "|" + newValue.slice(caret.offset); // const valueWithCaret = newValue.slice(0, caret.offset) + "|" + newValue.slice(caret.offset);
console.log("update at", {diff, valueWithCaret}); // console.log("update at", {diff, valueWithCaret});
let removedOffsetDecrease = 0; let removedOffsetDecrease = 0;
if (diff.removed) { if (diff.removed) {
removedOffsetDecrease = this._removeText(position, diff.removed.length); removedOffsetDecrease = this._removeText(position, diff.removed.length);
@ -93,6 +93,7 @@ export default class EditorModel {
this._mergeAdjacentParts(); this._mergeAdjacentParts();
const caretOffset = diff.at - removedOffsetDecrease + addedLen; const caretOffset = diff.at - removedOffsetDecrease + addedLen;
const newPosition = this._positionForOffset(caretOffset, true); const newPosition = this._positionForOffset(caretOffset, true);
// console.log("caretOffset", {at: diff.at, removedOffsetDecrease, addedLen}, newPosition);
this._setActivePart(newPosition); this._setActivePart(newPosition);
this._updateCallback(newPosition); this._updateCallback(newPosition);
} }

View file

@ -74,12 +74,10 @@ export function renderModel(editor, model) {
--surplusElementCount; --surplusElementCount;
} }
} else { } else {
// empty div needs to have a BR in it // empty div needs to have a BR in it to give it height
let foundBR = false; let foundBR = false;
let partNode = lineContainer.firstChild; let partNode = lineContainer.firstChild;
console.log("partNode", partNode, editor.innerHTML);
while (partNode) { while (partNode) {
console.log("partNode(in loop)", partNode);
if (!foundBR && partNode.tagName === "BR") { if (!foundBR && partNode.tagName === "BR") {
foundBR = true; foundBR = true;
} else { } else {
@ -88,7 +86,6 @@ export function renderModel(editor, model) {
partNode = partNode.nextSibling; partNode = partNode.nextSibling;
} }
if (!foundBR) { if (!foundBR) {
console.log("adding a BR in an empty div because there was none already");
lineContainer.appendChild(document.createElement("br")); lineContainer.appendChild(document.createElement("br"));
} }
} }