From e049b5505541900e35cfdbd43fef4f39fd80ca94 Mon Sep 17 00:00:00 2001 From: lizhijie429 <632163606@qq.com> Date: Mon, 25 Dec 2023 15:29:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=86=85=E7=BD=AE=E7=BB=84=E4=BB=B6img?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=9B=BE=E7=89=87=E9=95=BF=E5=BA=A6=E5=92=8C?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/settings/styles/src/js/useStyle.js | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/settings/styles/src/js/useStyle.js b/packages/settings/styles/src/js/useStyle.js index 2a2cb15f78..4b172886e0 100644 --- a/packages/settings/styles/src/js/useStyle.js +++ b/packages/settings/styles/src/js/useStyle.js @@ -293,7 +293,29 @@ const updateGlobalStyle = (newSelector) => { // 更新 style 对象到 schema const updateStyle = (properties) => { const schema = getSchema() || getCanvasPageSchema() + const currentSchema = getCurrentSchema() || schema + schema.props = schema.props || {} + currentSchema.props = currentSchema.props || {} + + // 更新行内样式 + if (currentSchema.props.style) { + const styleObj = currentSchema.props.style.split(';') + const propertyKey = Object.keys(properties)[0] + const hasProperty = currentSchema.props.style.includes(propertyKey) + if (hasProperty) { + for (let index = 0; index < styleObj.length; index++) { + const element = styleObj[index] + if (element.includes(propertyKey)) { + const indexOf = element.indexOf(element.indexOf(propertyKey)) + const newStr = element.replace(element.substring(indexOf - 1), properties[propertyKey]) + styleObj[index] = indexOf > 0 ? newStr : element + break + } + } + currentSchema.props.style = styleObj.join(';') + } + } if (properties) { Object.entries(properties).forEach(([key, value]) => {