Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/settings/styles/src/js/useStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand Down