|
|
@@ -373,19 +373,38 @@ export default {
|
|
|
|
|
|
// 同步对象数据到右侧面板
|
|
|
syncObjectDataToPanel(obj) {
|
|
|
- if (!obj || !this.editLayer || obj.id !== this.editLayer.id) {
|
|
|
+ if (!obj) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 同步图片尺寸
|
|
|
if (obj.type === 'image') {
|
|
|
- if (this.imageSize) {
|
|
|
+ if (this.imageSize && this.editLayer && obj.id === this.editLayer.id) {
|
|
|
this.imageSize.width = Math.round(obj.getScaledWidth());
|
|
|
this.imageSize.height = Math.round(obj.getScaledHeight());
|
|
|
// 强制更新Vue组件以反映数据变化
|
|
|
this.$forceUpdate();
|
|
|
}
|
|
|
}
|
|
|
+ // 同步文字内容
|
|
|
+ else if (obj.type === 'textbox' || obj.type === 'text') {
|
|
|
+ // 同步文字内容到右侧面板
|
|
|
+ if (obj.text !== undefined) {
|
|
|
+ console.log('文字同步:', {
|
|
|
+ objId: obj.id,
|
|
|
+ oldText: this.reactiveTextContent,
|
|
|
+ newText: obj.text
|
|
|
+ });
|
|
|
+
|
|
|
+ // 更新响应式文字内容状态
|
|
|
+ this.reactiveTextContent = obj.text;
|
|
|
+
|
|
|
+ // 同时更新fabric对象的文字内容
|
|
|
+ if (this.editLayer) {
|
|
|
+ this.editLayer.text = obj.text;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
async setCursor(){
|
|
|
if(!['draw','erase'].includes(this.action)) return
|
|
|
@@ -761,6 +780,8 @@ export default {
|
|
|
const coreEvents = [
|
|
|
"object:modified", // 对象修改(移动、缩放、旋转等)
|
|
|
"path:created", // 绘制路径
|
|
|
+ "text:changed", // 文字内容变化
|
|
|
+ "editing:exited", // 文字编辑结束
|
|
|
];
|
|
|
|
|
|
coreEvents.forEach(eventName => {
|