mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-19 03:55:50 +08:00
feat(editor): stage overlay 支持放大缩小
This commit is contained in:
parent
95d6263f42
commit
32681964b3
@ -45,6 +45,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
||||
updateDragEl: stageOptions.updateDragEl,
|
||||
guidesOptions: stageOptions.guidesOptions,
|
||||
disabledMultiSelect: stageOptions.disabledMultiSelect,
|
||||
disabledRule: stageOptions.disabledRule,
|
||||
});
|
||||
|
||||
watch(
|
||||
|
@ -1,9 +1,19 @@
|
||||
<template>
|
||||
<div v-if="stageOverlayVisible" class="m-editor-stage-overlay" @click="closeOverlayHandler">
|
||||
<TMagicIcon class="m-editor-stage-overlay-close" :size="'20'" @click="closeOverlayHandler"
|
||||
<div v-if="stageOverlayVisible" class="m-editor-stage-overlay">
|
||||
<TMagicIcon class="m-editor-stage-overlay-close" :size="'30'" @click="closeOverlayHandler"
|
||||
><CloseBold
|
||||
/></TMagicIcon>
|
||||
<div ref="stageOverlay" class="m-editor-stage-overlay-container" :style="style" @click.stop></div>
|
||||
|
||||
<ScrollViewer
|
||||
class="m-editor-stage"
|
||||
:width="wrapWidth"
|
||||
:height="wrapHeight"
|
||||
:wrap-width="columnWidth.center"
|
||||
:wrap-height="frameworkRect.height"
|
||||
:zoom="zoom"
|
||||
>
|
||||
<div ref="stageOverlay" class="m-editor-stage-container" :style="style"></div>
|
||||
</ScrollViewer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -13,10 +23,11 @@ import { CloseBold } from '@element-plus/icons-vue';
|
||||
|
||||
import { TMagicIcon } from '@tmagic/design';
|
||||
|
||||
import ScrollViewer from '@editor/components/ScrollViewer.vue';
|
||||
import { useServices } from '@editor/hooks/use-services';
|
||||
import type { StageOptions } from '@editor/type';
|
||||
|
||||
const { stageOverlayService, editorService } = useServices();
|
||||
const { stageOverlayService, editorService, uiService } = useServices();
|
||||
|
||||
const stageOptions = inject<StageOptions>('stageOptions');
|
||||
|
||||
@ -26,10 +37,12 @@ const stageOverlayVisible = computed(() => stageOverlayService.get('stageOverlay
|
||||
const wrapWidth = computed(() => stageOverlayService.get('wrapWidth'));
|
||||
const wrapHeight = computed(() => stageOverlayService.get('wrapHeight'));
|
||||
const stage = computed(() => editorService.get('stage'));
|
||||
const zoom = computed(() => uiService.get('zoom'));
|
||||
const columnWidth = computed(() => uiService.get('columnWidth'));
|
||||
const frameworkRect = computed(() => uiService.get('frameworkRect'));
|
||||
|
||||
const style = computed(() => ({
|
||||
width: `${wrapWidth.value}px`,
|
||||
height: `${wrapHeight.value}px`,
|
||||
transform: `scale(${zoom.value})`,
|
||||
}));
|
||||
|
||||
watch(stage, (stage) => {
|
||||
@ -43,6 +56,12 @@ watch(stage, (stage) => {
|
||||
}
|
||||
});
|
||||
|
||||
watch(zoom, (zoom) => {
|
||||
const stage = stageOverlayService.get('stage');
|
||||
if (!stage || !zoom) return;
|
||||
stage.setZoom(zoom);
|
||||
});
|
||||
|
||||
watch(stageOverlayEl, (stageOverlay) => {
|
||||
const subStage = stageOverlayService.createStage(stageOptions);
|
||||
stageOverlayService.set('stage', subStage);
|
||||
|
@ -97,9 +97,9 @@ class StageOverlay extends BaseService {
|
||||
public createStage(stageOptions: StageOptions = {}) {
|
||||
return useStage({
|
||||
...stageOptions,
|
||||
zoom: 1,
|
||||
runtimeUrl: '',
|
||||
autoScrollIntoView: false,
|
||||
disabledRule: true,
|
||||
render: async (stage: StageCore) => {
|
||||
this.copyDocumentElement();
|
||||
|
||||
|
@ -35,22 +35,15 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
z-index: 20;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.m-editor-stage-overlay-container {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
margin: auto;
|
||||
box-shadow: rgba(0, 0, 0, 0.04) 0px 3px 5px;
|
||||
}
|
||||
|
||||
.m-editor-stage-overlay-close.tmagic-design-icon {
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
top: 10px;
|
||||
cursor: pointer;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.m-editor-stage-float-button {
|
||||
@ -66,8 +59,10 @@
|
||||
background-color: #ffffff;
|
||||
transition: background-color 0.2s;
|
||||
color: rgba(0, 0, 0, 0.88);
|
||||
box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
||||
0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
||||
box-shadow:
|
||||
0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
||||
0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
||||
0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.m-editor-node-list-menu {
|
||||
|
@ -164,6 +164,7 @@ export interface StageOptions {
|
||||
renderType?: RenderType;
|
||||
guidesOptions?: Partial<GuidesOptions>;
|
||||
disabledMultiSelect?: boolean;
|
||||
disabledRule?: boolean;
|
||||
zoom?: number;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user