Skip to content

Commit

Permalink
fix: dispatch scope
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Jun 9, 2020
1 parent 624dee2 commit 2628c73
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
6 changes: 4 additions & 2 deletions packages/bytemd/src/editor.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { onMount } from 'svelte';
import { onMount, createEventDispatcher } from 'svelte';
import Toolbar from './toolbar.svelte';
import Viewer from './viewer.svelte';
import { dataUrlFileHandler, initEditor } from './utils';
Expand All @@ -24,8 +24,10 @@
cm.setValue(value);
}
const dispatch = createEventDispatcher();
onMount(() => {
initEditor(textarea, editorConfig, value, viewer, fileHandler);
initEditor(textarea, editorConfig, value, viewer, fileHandler, dispatch);
});
</script>

Expand Down
6 changes: 2 additions & 4 deletions packages/bytemd/src/utils/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createEventDispatcher } from 'svelte';
import codemirror from 'codemirror';
import 'codemirror/mode/markdown/markdown.js';
import { EditorProps } from 'bytemd';
Expand All @@ -8,10 +7,9 @@ export function initEditor(
editorConfig: any,
value: string,
viewer: HTMLElement,
fileHandler: NonNullable<EditorProps['fileHandler']>
fileHandler: NonNullable<EditorProps['fileHandler']>,
dispatch: any
) {
const dispatch = createEventDispatcher();

const cm = codemirror.fromTextArea(textarea, {
mode: 'markdown',
lineNumbers: true,
Expand Down
8 changes: 0 additions & 8 deletions packages/bytemd/src/utils/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,3 @@ export function findPlugin(node: HastNode, plugins: BytemdPlugin[]) {
}
}
}

export const santitizeHref = (href?: string) => {
if (href && href.trim().toLowerCase().startsWith('javascript')) {
return;
} else {
return href;
}
};
2 changes: 1 addition & 1 deletion packages/bytemd/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { getParser } from './common';
export { initEditor, dataUrlFileHandler } from './editor';
export { findPlugin, santitizeHref } from './element';
export { findPlugin } from './element';
export {
handleDec,
handleTag,
Expand Down

0 comments on commit 2628c73

Please sign in to comment.