Skip to content

Commit

Permalink
fix: #1009 处理容器宽度发生变化时,编辑器光标出现错位的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed Dec 22, 2024
1 parent 2f732ea commit ccae682
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,16 @@ export default class Editor {
}
// 处理特殊字符,主要将base64等大文本替换成占位符,以提高可读性
this.dealSpecialWords();

this.domWidth = this.getEditorDom().offsetWidth;
// 监听编辑器宽度变化
const resizeObserver = new ResizeObserver((entries) => {
if (this.getEditorDom().offsetWidth !== this.domWidth) {
this.domWidth = this.getEditorDom().offsetWidth;
this.editor.refresh();
}
});
resizeObserver.observe(this.getEditorDom());
}

/**
Expand Down

0 comments on commit ccae682

Please sign in to comment.