chore: remove unused APIs

This commit is contained in:
Rongjian Zhang 2020-07-21 16:32:59 +08:00
parent e257253e55
commit 49621403fd
7 changed files with 12 additions and 39 deletions

View File

@ -3,16 +3,12 @@ import * as bytemd from 'bytemd';
export interface ViewerProps extends bytemd.ViewerProps {}
export const Viewer: FC<ViewerProps> = ({
value,
markdownOptions,
plugins,
}) => {
export const Viewer: FC<ViewerProps> = ({ value, plugins }) => {
const el = useRef<HTMLDivElement>(null);
const html = useMemo(
() => bytemd.processMarkdown({ value, markdownOptions, plugins }),
[value, markdownOptions, plugins]
);
const html = useMemo(() => bytemd.processMarkdown({ value, plugins }), [
value,
plugins,
]);
useEffect(() => {
const $ = el.current;

View File

@ -10,11 +10,8 @@
import Viewer from './viewer.svelte';
export let value = '';
export let markdownOptions = [];
export let plugins = [];
export let mode = 'split';
export let editorConfig = {};
export let toolbarItems = [];
export let previewDebounce = 300;
let el;
@ -64,7 +61,6 @@
cm = codemirror.fromTextArea(textarea, {
mode: 'markdown',
lineWrapping: true,
...editorConfig,
});
cm.setValue(value);
cm.on('change', (doc, change) => {
@ -76,7 +72,7 @@
</script>
<div class="bytemd" bind:this={el}>
<Toolbar {cm} {toolbarItems} {mode} {activeTab} on:tab={setActiveTab} />
<Toolbar {cm} {mode} {activeTab} on:tab={setActiveTab} />
<div class="bytemd-body">
<div
class="bytemd-editor"
@ -86,7 +82,7 @@
<div
class="bytemd-preview"
style={mode === 'tab' && activeTab === 0 ? 'display:none' : undefined}>
<Viewer value={viewerValue} {markdownOptions} {plugins} />
<Viewer value={viewerValue} {plugins} />
</div>
</div>
</div>

View File

@ -4,7 +4,6 @@ import Editor from './editor.svelte';
import Viewer from './viewer.svelte';
import codemirror from 'codemirror';
import * as unified from 'unified';
import { RemarkParseOptions } from 'remark-parse';
import 'codemirror/lib/codemirror.css';
import 'tippy.js/dist/tippy.css';
@ -61,10 +60,6 @@ export interface EditorProps extends ViewerProps {
* - tab: click tabs to switch between edit and preview
*/
mode?: 'split' | 'tab';
/**
* CodeMirror configuration
*/
editorConfig?: Omit<codemirror.EditorConfiguration, 'value'>;
/**
* Components which should be added to toolbar
*/
@ -83,7 +78,6 @@ export interface ViewerProps {
* Markdown text
*/
value: string;
markdownOptions?: Partial<RemarkParseOptions>;
/**
* ByteMD plugin list
*/

View File

@ -12,12 +12,8 @@ import merge from 'deepmerge';
import ghSchema from 'hast-util-sanitize/lib/github.json';
import { ViewerProps } from '.';
export function processMarkdown({
value,
markdownOptions,
plugins = [],
}: ViewerProps) {
let parser = unified().use(remarkParse, markdownOptions);
export function processMarkdown({ value, plugins = [] }: ViewerProps) {
let parser = unified().use(remarkParse);
plugins.forEach(({ remark }) => {
if (remark) parser = remark(parser);

View File

@ -8,7 +8,6 @@
import { processMarkdown } from './utils';
export let value = '';
export let markdownOptions = {};
export let plugins = [];
let el;
@ -24,7 +23,7 @@
}
onDestroy(off);
$: html = processMarkdown({ value, plugins, markdownOptions });
$: html = processMarkdown({ value, plugins });
$: if (html != null && plugins) {
off();
tick().then(() => {

View File

@ -6,15 +6,7 @@
import * as bytemd from 'bytemd';
export default {
props: [
'value',
'markdownOptions',
'plugins',
'mode',
'editorConfig',
'toolbarItems',
'previewDebounce',
],
props: ['value', 'plugins', 'mode', 'previewDebounce'],
mounted() {
const editor = new bytemd.Editor({
target: this.$el,

View File

@ -6,7 +6,7 @@
import { processMarkdown } from 'bytemd';
export default {
props: ['value', 'markdownOptions', 'plugins'],
props: ['value', 'plugins'],
computed: {
html() {
return processMarkdown(this.$props);