PR feedback, cleanup
This commit is contained in:
parent
dc21faa240
commit
d83e278f6b
4 changed files with 8 additions and 57 deletions
|
@ -66,8 +66,6 @@ export default class EditorModel {
|
|||
}
|
||||
|
||||
_diff(newValue, inputType, caret) {
|
||||
// handle deleteContentForward (Delete key)
|
||||
// and deleteContentBackward (Backspace)
|
||||
const previousValue = this.parts.reduce((text, p) => text + p.text, "");
|
||||
// can't use caret position with drag and drop
|
||||
if (inputType === "deleteByDrag") {
|
||||
|
@ -80,8 +78,6 @@ export default class EditorModel {
|
|||
update(newValue, inputType, caret) {
|
||||
const diff = this._diff(newValue, inputType, caret);
|
||||
const position = this._positionForOffset(diff.at, caret.atNodeEnd);
|
||||
// const valueWithCaret = newValue.slice(0, caret.offset) + "|" + newValue.slice(caret.offset);
|
||||
// console.log("update at", {diff, valueWithCaret});
|
||||
let removedOffsetDecrease = 0;
|
||||
if (diff.removed) {
|
||||
removedOffsetDecrease = this._removeText(position, diff.removed.length);
|
||||
|
@ -93,7 +89,6 @@ export default class EditorModel {
|
|||
this._mergeAdjacentParts();
|
||||
const caretOffset = diff.at - removedOffsetDecrease + addedLen;
|
||||
const newPosition = this._positionForOffset(caretOffset, true);
|
||||
// console.log("caretOffset", {at: diff.at, removedOffsetDecrease, addedLen}, newPosition);
|
||||
this._setActivePart(newPosition);
|
||||
this._updateCallback(newPosition);
|
||||
}
|
||||
|
@ -146,12 +141,6 @@ export default class EditorModel {
|
|||
this._updateCallback(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
updateCaret(caret) {
|
||||
// update active part here as well, hiding/showing autocomplete if needed
|
||||
}
|
||||
*/
|
||||
|
||||
_mergeAdjacentParts(docPos) {
|
||||
let prevPart = this._parts[0];
|
||||
for (let i = 1; i < this._parts.length; ++i) {
|
||||
|
|
|
@ -14,22 +14,6 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
export function rerenderModel(editor, model) {
|
||||
while (editor.firstChild) {
|
||||
editor.removeChild(editor.firstChild);
|
||||
}
|
||||
let lineContainer = document.createElement("div");
|
||||
editor.appendChild(lineContainer);
|
||||
for (const part of model.parts) {
|
||||
if (part.type === "newline") {
|
||||
lineContainer = document.createElement("div");
|
||||
editor.appendChild(lineContainer);
|
||||
} else {
|
||||
lineContainer.appendChild(part.toDOMNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function renderModel(editor, model) {
|
||||
const lines = model.parts.reduce((lines, part) => {
|
||||
if (part.type === "newline") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue