Skip to content

Commit

Permalink
🎨 fix #411 自动新行
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Aug 1, 2020
1 parent 6e33add commit 62112db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/ts/ir/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class IR {
if (event.target.isEqualNode(this.element) && this.element.lastElementChild && range.collapsed) {
const lastRect = this.element.lastElementChild.getBoundingClientRect();
if (event.y > lastRect.top + lastRect.height) {
if (this.element.lastElementChild.tagName === "P") {
if (this.element.lastElementChild.tagName === "P" &&
this.element.lastElementChild.textContent.trim().replace(Constants.ZWSP, "") === "") {
range.selectNodeContents(this.element.lastElementChild);
range.collapse(false);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/ts/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ class WYSIWYG {
if (event.target.isEqualNode(this.element) && this.element.lastElementChild && range.collapsed) {
const lastRect = this.element.lastElementChild.getBoundingClientRect();
if (event.y > lastRect.top + lastRect.height) {
if (this.element.lastElementChild.tagName === "P") {
if (this.element.lastElementChild.tagName === "P" &&
this.element.lastElementChild.textContent.trim().replace(Constants.ZWSP, "") === "") {
range.selectNodeContents(this.element.lastElementChild);
range.collapse(false);
} else {
Expand Down

0 comments on commit 62112db

Please sign in to comment.