Skip to content

Commit

Permalink
fix: first render ctrl-z
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed May 12, 2021
1 parent 4325c16 commit c882148
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/bytemd/src/editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
})(split);
let root: HTMLElement;
let editorEl: HTMLElement;
let previewEl: HTMLElement;
let textarea: HTMLTextAreaElement;
let containerWidth = Infinity; // TODO: first screen
let codemirror: ReturnType<typeof factory>;
Expand Down Expand Up @@ -202,7 +202,9 @@
return annotations;
};
editor = codemirror.fromTextArea(textarea, {
// @ts-ignore TODO: type
editor = codemirror(editorEl, {
value,
mode: 'yaml-frontmatter',
lineWrapping: true,
tabSize: 8, // keep consistent with preview: https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size#formal_definition
Expand All @@ -218,7 +220,6 @@
Tab: 'indentMore',
'Shift-Tab': 'indentLess',
});
editor.setValue(value);
editor.on('change', (doc, change) => {
dispatch('change', { value: editor.getValue() });
});
Expand Down Expand Up @@ -420,9 +421,7 @@
}}
/>
<div class="bytemd-body">
<div class="bytemd-editor" style={styles.edit}>
<textarea bind:this={textarea} class="bytemd-hidden" />
</div>
<div class="bytemd-editor" style={styles.edit} bind:this={editorEl} />
<div bind:this={previewEl} class="bytemd-preview" style={styles.preview}>
{#if !overridePreview}
<Viewer
Expand Down

0 comments on commit c882148

Please sign in to comment.