Connected md editor settings to logic for functionality

This commit is contained in:
Dan Brown
2022-11-28 12:12:36 +00:00
parent 9fd5190c70
commit ec3713bc74
10 changed files with 99 additions and 28 deletions

View File

@ -24,7 +24,13 @@ export async function init(editor) {
// Handle scroll to sync display view
const onScrollDebounced = debounce(editor.actions.syncDisplayPosition.bind(editor.actions), 100, false);
cm.on('scroll', instance => onScrollDebounced(instance));
let syncActive = editor.settings.get('scrollSync');
editor.settings.onChange('scrollSync', val => syncActive = val);
cm.on('scroll', instance => {
if (syncActive) {
onScrollDebounced(instance);
}
});
// Handle image paste
cm.on('paste', (cm, event) => {