Skip to content

Commit

Permalink
Feature/paste opt (#804)
Browse files Browse the repository at this point in the history
* chore(release): 0.8.42

* fix: 长文本情况下,全选粘贴替换内容时会有性能问题

* fix: 修改全选判定方式

* fix: 修改selectAll参数获取

---------

Co-authored-by: sunsonliu(刘阳) <[email protected]>
  • Loading branch information
wind416 and sunsonliu committed Jun 24, 2024
1 parent 08a6a5f commit 3ca0bf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default class Editor {
* @type {{ timer?: number; destinationTop?: number }}
*/
this.animation = {};
this.selectAll = false;
const { codemirror, ...restOptions } = options;
if (codemirror) {
Object.assign(this.options.codemirror, codemirror);
Expand Down Expand Up @@ -535,6 +536,9 @@ export default class Editor {
editor.on('cursorActivity', () => {
this.onCursorActivity();
});
editor.on('beforeChange', (codemirror) => {
this.selectAll = this.editor.getValue() === codemirror.getSelection();
});

addEvent(
this.getEditorDom(),
Expand Down
3 changes: 3 additions & 0 deletions src/Previewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ export default class Previewer {
// 预览区未隐藏时,直接更新
const tmpDiv = document.createElement('div');
const domContainer = this.getDomContainer();
if (this.editor.selectAll) {
domContainer.innerHTML = '';
}
tmpDiv.innerHTML = newHtml;
const newHtmlList = this.$getSignData(tmpDiv);
const oldHtmlList = this.$getSignData(domContainer);
Expand Down

0 comments on commit 3ca0bf8

Please sign in to comment.