mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Merge pull request #2405 from daiyam/fix-scroll
Better scroll sync between the editor and the preview in the SplitEditor
This commit is contained in:
@@ -170,6 +170,10 @@ export default class CodeEditor extends React.Component {
|
||||
}
|
||||
|
||||
handleEditorActivity() {
|
||||
if (this.props.onCursorActivity) {
|
||||
this.props.onCursorActivity(this.editor)
|
||||
}
|
||||
|
||||
if (!this.textEditorInterface.transaction) {
|
||||
this.updateTableEditorState()
|
||||
}
|
||||
@@ -380,6 +384,7 @@ export default class CodeEditor extends React.Component {
|
||||
|
||||
eventEmitter.emit('code:init')
|
||||
this.editor.on('scroll', this.scrollHandler)
|
||||
this.editor.on('cursorActivity', this.editorActivityHandler)
|
||||
|
||||
const editorTheme = document.getElementById('editorTheme')
|
||||
editorTheme.addEventListener('load', this.loadStyleHandler)
|
||||
@@ -517,7 +522,6 @@ export default class CodeEditor extends React.Component {
|
||||
})
|
||||
|
||||
if (this.props.enableTableEditor) {
|
||||
this.editor.on('cursorActivity', this.editorActivityHandler)
|
||||
this.editor.on('changes', this.editorActivityHandler)
|
||||
}
|
||||
|
||||
@@ -576,12 +580,18 @@ export default class CodeEditor extends React.Component {
|
||||
this.editor.off('paste', this.pasteHandler)
|
||||
eventEmitter.off('top:search', this.searchHandler)
|
||||
this.editor.off('scroll', this.scrollHandler)
|
||||
this.editor.off('cursorActivity', this.editorActivityHandler)
|
||||
this.editor.off('contextmenu', this.contextMenuHandler)
|
||||
|
||||
const editorTheme = document.getElementById('editorTheme')
|
||||
editorTheme.removeEventListener('load', this.loadStyleHandler)
|
||||
|
||||
spellcheck.setLanguage(null, spellcheck.SPELLCHECK_DISABLED)
|
||||
eventEmitter.off('code:format-table', this.formatTable)
|
||||
|
||||
if (this.props.enableTableEditor) {
|
||||
this.editor.off('changes', this.editorActivityHandler)
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
|
||||
Reference in New Issue
Block a user