File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 11<script >
2- import { onMount , createEventDispatcher } from ' svelte' ;
2+ import { onMount , createEventDispatcher , onDestroy } from ' svelte' ;
33 import Toolbar from ' ./toolbar.svelte' ;
44 import Viewer from ' ./viewer.svelte' ;
55 import { dataUrlFileHandler , initEditor } from ' ./editor' ;
1616 let textarea;
1717 let viewer;
1818 let cm;
19+ let cbs = [];
1920
2021 let activeTab = 0 ;
2122 function setActiveTab (e ) {
3839 dispatch,
3940 debounceMs
4041 );
41- dispatch (' mount' , { cm });
42+ cbs = plugins .map (({ editorEffect }) => editorEffect && editorEffect ());
43+ });
44+
45+ onDestroy (() => {
46+ cbs .forEach ((cb ) => cb && cb ());
4247 });
4348 </script >
4449
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export interface BytemdPlugin {
1919 remark ?: UnifiedProcessor ;
2020 rehype ?: UnifiedProcessor ;
2121 sanitizeSchema ?: any ;
22+ editorEffect ?( cm : codemirror . Editor ) : void | ( ( ) => void ) ;
2223 viewerEffect ?( el : HTMLElement ) : void | ( ( ) => void ) ;
2324}
2425
Original file line number Diff line number Diff line change @@ -24,9 +24,6 @@ export default {
2424 editor .$on (' change' , (e ) => {
2525 this .$emit (' change' , e .detail .value );
2626 });
27- editor .$on (' mount' , (e ) => {
28- this .$emit (' mount' , e .detail .cm );
29- });
3027 this .editor = editor;
3128 },
3229 watch: {
You can’t perform that action at this time.
0 commit comments