fix(editor): 样式修改,editor pannel使用resize组件

This commit is contained in:
parisma 2022-09-16 20:04:22 +08:00 committed by jia000
parent 27d8640fbc
commit c2637b1b0c
6 changed files with 72 additions and 62 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="m-fields-code-select" :key="fieldKey"> <div class="m-fields-code-select" :key="fieldKey">
<el-card> <el-card shadow="never">
<template #header> <template #header>
<m-fields-select <m-fields-select
:config="selectConfig" :config="selectConfig"

View File

@ -1,5 +1,5 @@
<template> <template>
<div ref="el"> <div ref="el" class="m-editor-layout">
<template v-if="typeof props.left !== 'undefined'"> <template v-if="typeof props.left !== 'undefined'">
<div class="m-editor-layout-left" :class="leftClass" :style="`width: ${left}px`"> <div class="m-editor-layout-left" :class="leftClass" :style="`width: ${left}px`">
<slot name="left"></slot> <slot name="left"></slot>

View File

@ -1,14 +1,15 @@
<template> <template>
<el-dialog <el-dialog
v-model="isShowCodeBlockEditor" v-model="isShowCodeBlockEditor"
:title="currentTitle"
:fullscreen="true" :fullscreen="true"
:before-close="saveAndClose" :before-close="saveAndClose"
:append-to-body="true" :append-to-body="true"
custom-class="code-editor-dialog" custom-class="code-editor-dialog"
> >
<!-- 左侧列表 --> <layout v-model:left="left" :min-left="45" class="code-editor-layout">
<template v-if="mode === EditorMode.LIST"> <!-- 左侧列表 -->
<el-card class="code-editor-side-menu"> <template #left v-if="mode === EditorMode.LIST">
<el-tree <el-tree
v-if="!isEmpty(state.codeList)" v-if="!isEmpty(state.codeList)"
ref="tree" ref="tree"
@ -28,46 +29,50 @@
</div> </div>
</template> </template>
</el-tree> </el-tree>
</el-card> </template>
</template> <!-- 右侧区域 -->
<!-- 右侧区域 --> <template #center>
<div <div
v-if="!isEmpty(codeConfig)" v-if="!isEmpty(codeConfig)"
:class="[ :class="[
mode === EditorMode.LIST ? 'm-editor-code-block-editor-panel-list-mode' : 'm-editor-code-block-editor-panel', mode === EditorMode.LIST
]" ? 'm-editor-code-block-editor-panel-list-mode'
> : 'm-editor-code-block-editor-panel',
<slot name="code-block-edit-panel-header" :id="id"></slot> ]"
<el-card shadow="never"> >
<template #header> <slot name="code-block-edit-panel-header" :id="id"></slot>
<div class="code-name-wrapper"> <el-card shadow="never">
<div class="code-name-label">代码块名称</div> <template #header>
<el-input class="code-name-input" v-model="codeConfig.name" :disabled="!editable" /> <div class="code-name-wrapper">
</div> <div class="code-name-label">代码块名称</div>
</template> <el-input class="code-name-input" v-model="codeConfig.name" :disabled="!editable" />
<div class="m-editor-wrapper"> </div>
<magic-code-editor </template>
ref="codeEditor" <div class="m-editor-wrapper">
class="m-editor-container" <magic-code-editor
:init-values="`${codeConfig.content}`" ref="codeEditor"
@save="saveCode" class="m-editor-container"
:options="{ :init-values="`${codeConfig.content}`"
tabSize: 2, @save="saveCode"
fontSize: 16, :options="{
formatOnPaste: true, tabSize: 2,
readOnly: !editable, fontSize: 16,
}" formatOnPaste: true,
></magic-code-editor> readOnly: !editable,
<div class="m-editor-content-bottom" v-if="editable"> }"
<el-button type="primary" class="button" @click="saveCode">保存</el-button> ></magic-code-editor>
<el-button type="primary" class="button" @click="saveAndClose">关闭</el-button> <div class="m-editor-content-bottom" v-if="editable">
</div> <el-button type="primary" class="button" @click="saveCode">保存</el-button>
<div class="m-editor-content-bottom" v-else> <el-button type="primary" class="button" @click="saveAndClose">关闭</el-button>
<el-button type="primary" class="button" @click="saveAndClose">关闭</el-button> </div>
</div> <div class="m-editor-content-bottom" v-else>
<el-button type="primary" class="button" @click="saveAndClose">关闭</el-button>
</div>
</div>
</el-card>
</div> </div>
</el-card> </template>
</div> </layout>
</el-dialog> </el-dialog>
</template> </template>
@ -78,10 +83,13 @@ import { forIn, isEmpty } from 'lodash-es';
import type { CodeBlockContent, CodeDslList, ListState, Services } from '../../../type'; import type { CodeBlockContent, CodeDslList, ListState, Services } from '../../../type';
import { EditorMode } from '../../../type'; import { EditorMode } from '../../../type';
import Layout from '../../Layout.vue';
const services = inject<Services>('services'); const services = inject<Services>('services');
const codeEditor = ref<any | null>(null); const codeEditor = ref<any | null>(null);
const left = ref(200);
const currentTitle = ref('');
// //
const codeConfig = ref<CodeBlockContent | null>(null); const codeConfig = ref<CodeBlockContent | null>(null);
// select(ListState) // select(ListState)
@ -114,6 +122,7 @@ watchEffect(async () => {
content: value.content, content: value.content,
}); });
}); });
currentTitle.value = state.codeList[0]?.name || '';
}); });
// //
@ -148,5 +157,6 @@ const saveAndClose = async () => {
const selectHandler = (data: CodeDslList) => { const selectHandler = (data: CodeDslList) => {
services?.codeBlockService.setId(data.id); services?.codeBlockService.setId(data.id);
currentTitle.value = data.name;
}; };
</script> </script>

View File

@ -69,6 +69,7 @@
.code-editor-dialog { .code-editor-dialog {
.el-dialog__body { .el-dialog__body {
height: 90%; height: 90%;
padding-top: 10px;
} }
.el-card { .el-card {
height: 100%; height: 100%;
@ -79,19 +80,18 @@
} }
} }
.code-editor-side-menu { .code-editor-layout {
width: 20%; height: 100%;
position: absolute; border: 1px solid #e4e7ed;
top: 0;
left: 0;
background: #fff;
.side-tree { .side-tree {
margin-top: 10px; height: 100%;
overflow: auto;
.list-container { .list-container {
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
margin-left: -20px; margin-left: -10px;
.list-item { .list-item {
width: 100%; width: 100%;
margin: 10px 0; margin: 10px 0;
@ -121,13 +121,12 @@
} }
.m-editor-code-block-editor-panel-list-mode { .m-editor-code-block-editor-panel-list-mode {
position: absolute;
top: 0;
left: 20%;
width: 80%;
height: 100%; height: 100%;
z-index: 10; z-index: 10;
background: #fff; background: #fff;
.el-card {
border: 0;
}
} }
.m-editor-code-block-editor-panel { .m-editor-code-block-editor-panel {
@ -146,15 +145,10 @@
height: 100%; height: 100%;
} }
.m-editor-content-bottom { .m-editor-content-bottom {
text-align: right;
height: 40px; height: 40px;
padding-right: 20px; width: 100%;
position: absolute;
width: calc(100% - 30px);
display: flex; display: flex;
justify-content: end; justify-content: end;
bottom: 20px;
right: 0;
background: #fff; background: #fff;
> button { > button {
height: 30px; height: 30px;

View File

@ -13,3 +13,4 @@
@import "./code-editor.scss"; @import "./code-editor.scss";
@import "./icon.scss"; @import "./icon.scss";
@import "./code-block.scss"; @import "./code-block.scss";
@import "./layout.scss";

View File

@ -0,0 +1,5 @@
.m-editor-layout {
width: 100%;
display: flex;
justify-self: space-between;
}