Skip to content

Commit

Permalink
fix: add an example of markdown embedded in the form #138
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Dec 23, 2020
1 parent 10cd4fc commit 7db0c5c
Show file tree
Hide file tree
Showing 16 changed files with 463 additions and 354 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- 新增 `v-ripple`水波纹指令
- 新增左侧菜单混合模式
- 新增 markdown 嵌入表单内示例

### 🐛 Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions src/components/Container/src/ScrollContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:wrapClass="`scrollbar__wrap`"
:viewClass="`scrollbar__view`"
class="scroll-container"
v-bind="$attrs"
>
<slot />
</Scrollbar>
Expand Down
64 changes: 53 additions & 11 deletions src/components/Markdown/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
<div class="markdown" ref="wrapRef" />
</template>
<script lang="ts">
import { defineComponent, ref, onMounted, unref, onUnmounted, nextTick, watchEffect } from 'vue';
import {
defineComponent,
ref,
onMounted,
unref,
onUnmounted,
nextTick,
// watch,
computed,
} from 'vue';
import Vditor from 'vditor';
import 'vditor/dist/index.css';
import { propTypes } from '/@/utils/propTypes';
import { useLocale } from '/@/hooks/web/useLocale';
type Lang = 'zh_CN' | 'en_US' | 'ja_JP' | 'ko_KR' | undefined;
export default defineComponent({
emits: ['update:value'],
emits: ['change'],
props: {
height: propTypes.number.def(360),
value: propTypes.string.def(''),
Expand All @@ -19,17 +30,42 @@
const vditorRef = ref<Nullable<Vditor>>(null);
const initedRef = ref(false);
const lang = ref<Lang>();
const { getLang } = useLocale();
const getCurrentLang = computed((): 'zh_CN' | 'en_US' | 'ja_JP' | 'ko_KR' => {
switch (unref(getLang)) {
case 'en':
lang.value = 'en_US';
break;
case 'ja':
lang.value = 'ja_JP';
break;
case 'ko':
lang.value = 'ko_KR';
break;
default:
lang.value = 'zh_CN';
}
return lang.value;
});
function init() {
const wrapEl = unref(wrapRef);
if (!wrapEl) return;
const bindValue = { ...attrs, ...props };
vditorRef.value = new Vditor(wrapEl, {
lang: unref(getCurrentLang),
mode: 'sv',
preview: {
actions: [],
},
input: (v) => {
emit('update:value', v);
// emit('update:value', v);
emit('change', v);
},
blur: () => {
unref(vditorRef)?.setValue(props.value);
},
...bindValue,
cache: {
Expand All @@ -39,14 +75,20 @@
initedRef.value = true;
}
watchEffect(() => {
nextTick(() => {
const vditor = unref(vditorRef);
if (unref(initedRef) && props.value && vditor) {
vditor.setValue(props.value);
}
});
});
// watch(
// () => props.value,
// () => {
// nextTick(() => {
// const vditor = unref(vditorRef);
// if (unref(initedRef) && props.value && vditor) {
// vditor.setValue(props.value);
// }
// });
// },
// {
// immediate: true,
// }
// );
onMounted(() => {
nextTick(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Scrollbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { withInstall } from '../util';

import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
export const Scrollbar = createAsyncComponent(() => import('./src/Scrollbar'));
export const Scrollbar = createAsyncComponent(() => import('./src/index.vue'));

withInstall(Scrollbar);

Expand Down
106 changes: 0 additions & 106 deletions src/components/Scrollbar/src/Bar.tsx

This file was deleted.

146 changes: 0 additions & 146 deletions src/components/Scrollbar/src/Scrollbar.tsx

This file was deleted.

Loading

0 comments on commit 7db0c5c

Please sign in to comment.