mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 19:29:04 +08:00
feat(tinymce): add rich editor
This commit is contained in:
58
src/views/demo/comp/tinymce/Editor.vue
Normal file
58
src/views/demo/comp/tinymce/Editor.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="m-4">
|
||||
<CollapseContainer title="富文本表单">
|
||||
<BasicForm
|
||||
:labelWidth="100"
|
||||
:schemas="schemas"
|
||||
:actionColOptions="{ span: 24 }"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
</BasicForm>
|
||||
</CollapseContainer>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, h } from 'vue';
|
||||
import { BasicForm, FormSchema } from '/@/components/Form/index';
|
||||
import { CollapseContainer } from '/@/components/Container/index';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { Tinymce } from '/@/components/Tinymce/index';
|
||||
|
||||
const schemas: FormSchema[] = [
|
||||
{
|
||||
field: 'title',
|
||||
component: 'Input',
|
||||
label: 'title',
|
||||
defaultValue: 'defaultValue',
|
||||
rules: [{ required: true }],
|
||||
},
|
||||
{
|
||||
field: 'tinymce',
|
||||
component: 'Input',
|
||||
label: 'tinymce',
|
||||
defaultValue: 'defaultValue',
|
||||
rules: [{ required: true }],
|
||||
render: ({ model, field }) => {
|
||||
return h(Tinymce, {
|
||||
value: model[field],
|
||||
onChange: (value: string) => {
|
||||
model[field] = value;
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
export default defineComponent({
|
||||
components: { BasicForm, CollapseContainer, Tinymce },
|
||||
setup() {
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
return {
|
||||
schemas,
|
||||
handleSubmit: (values: any) => {
|
||||
createMessage.success('click search,values:' + JSON.stringify(values));
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
19
src/views/demo/comp/tinymce/index.vue
Normal file
19
src/views/demo/comp/tinymce/index.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<div class="flex p-4">
|
||||
<Tinymce value="Hello, World!" @change="handleChange" width="100%" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { Tinymce } from '/@/components/Tinymce/index';
|
||||
|
||||
export default defineComponent({
|
||||
components: { Tinymce },
|
||||
setup() {
|
||||
function handleChange(value: string) {
|
||||
console.log(value);
|
||||
}
|
||||
return { handleChange };
|
||||
},
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user