Skip to content

Commit e82de49

Browse files
committed
refactor: canvas force update
1 parent 517de2f commit e82de49

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

frontend/src/views/dashboard/canvas/CanvasCore.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,18 @@ function afterInitOk(func) {
10371037
}, 100)
10381038
}
10391039
1040+
const forceComputed = () => {
1041+
// Force the trigger of copy-add calculation here, as the position calculation uses a method and there is no change in internal style attributes
1042+
// In some cases, recalculation may not be triggered, resulting in a positional offset. The cellHeight property is being monitored, and forced recalculation is performed here
1043+
cellHeight.value = cellHeight.value + 0.001
1044+
nextTick(function () {
1045+
cellHeight.value = cellHeight.value - 0.001
1046+
})
1047+
}
1048+
10401049
function addItemBox(item: CanvasItem) {
10411050
canvasComponentData.value.push(item)
1051+
forceComputed()
10421052
nextTick(() => {
10431053
addItem(item, canvasComponentData.value.length - 1)
10441054
})

frontend/src/views/dashboard/components/sq-text/index.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
22
<div class="rich-main-class" :class="{ 'edit-model': configItem.editing }" draggable="false">
33
<div
4-
v-if="isDisabled && !configItem.propValue"
5-
class="rich-text-empty"
4+
:class="{ 'rich-text-empty': true, 'layer-hidden': !isDisabled }"
65
@keydown.stop
76
@keyup.stop
87
@mousedown.stop
@@ -11,21 +10,19 @@
1110
{{ t('dashboard.rich_text_tips') }}
1211
</div>
1312
<div
14-
v-else-if="isDisabled"
1513
draggable="false"
16-
:class="{ 'custom-text-content': true, 'preview-text': true }"
14+
:class="{ 'custom-text-content': true, 'preview-text': true, 'layer-hidden': !isDisabled }"
1715
@keydown.stop
1816
@keyup.stop
1917
@mousedown.stop
2018
@dblclick.stop="setEdit"
2119
v-html="configItem.propValue"
2220
></div>
2321
<editor
24-
v-else
2522
:id="tinymceId"
2623
v-model="configItem.propValue"
2724
draggable="false"
28-
:class="{ 'custom-text-content': true }"
25+
:class="{ 'custom-text-content': true, 'layer-hidden': isDisabled }"
2926
:init="init"
3027
></editor>
3128
</div>
@@ -128,12 +125,14 @@ onMounted(() => {
128125
position: relative;
129126
padding: 12px !important;
130127
.rich-text-empty {
128+
position: absolute;
129+
width: calc(100% - 24px);
130+
height: calc(100% - 24px);
131131
display: flex;
132-
width: 100%;
133-
height: 100%;
134132
align-items: center;
135133
justify-content: center;
136134
font-size: 16px;
135+
z-index: 10;
137136
color: rgba(100, 106, 115, 1);
138137
}
139138
div::-webkit-scrollbar {

frontend/src/views/dashboard/editor/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const addComponent = (componentType: string, viewInfo?: any) => {
3838
component.propValue[0].name = subTabName
3939
component.activeTabName = subTabName
4040
}
41-
41+
component.y = 100
4242
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
4343
dashboardEditorInnerRef.value.addItemToBox(component)
4444
}

0 commit comments

Comments
 (0)