Commit 2c07fbd0 by Lin Wang

fix: handle the buttons type

parent 9f3e0c39
...@@ -27,7 +27,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -27,7 +27,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
if (node.type === "RichText") { if (node.type === "RichText") {
const getInlineColors = extractInlineColors(node.value); const getInlineColors = extractInlineColors(node.value);
output.result.push({ output.result.push({
type: 'RichText', type: "RichText",
path: path.join('.'), path: path.join('.'),
inlineColors: getInlineColors, inlineColors: getInlineColors,
id: node.id || null id: node.id || null
...@@ -40,7 +40,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -40,7 +40,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
const items = node.components.block1?.items || []; const items = node.components.block1?.items || [];
items.filter((btn: any) => btn.type === "Button").forEach((btn: any) => { items.filter((btn: any) => btn.type === "Button").forEach((btn: any) => {
output.result.push({ output.result.push({
type: 'Button', type: "Button",
path: path.join('.'), path: path.join('.'),
color: btn.color, color: btn.color,
backgroundSettings: btn.backgroundSettings || {}, backgroundSettings: btn.backgroundSettings || {},
...@@ -52,7 +52,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -52,7 +52,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
// 检查当前节点是否为 Button // 检查当前节点是否为 Button
if (node.type === "Button") { if (node.type === "Button") {
output.result.push({ output.result.push({
type: 'Button', type: "Button",
path: path.join('.'), path: path.join('.'),
color: node.color, color: node.color,
backgroundSettings: node.backgroundSettings || {}, backgroundSettings: node.backgroundSettings || {},
...@@ -434,6 +434,23 @@ function handlePartialDiffAndFix(node: any, path: string[], output: any, { secti ...@@ -434,6 +434,23 @@ function handlePartialDiffAndFix(node: any, path: string[], output: any, { secti
} }
} }
// 检查当前节点是否为 Buttons,并将其内部每个 Button 当成独立 Button 处理
if (node.type === "Buttons") {
// 直接获取 block1 下的 items 数组
const items = node.components.block1?.items || [];
items.filter((btn: any) => btn.type === "Button").forEach((btn: any) => {
if ((btn.color || (!btn.color && btn.hasOwnProperty("backgroundSettings"))) && !btn.backgroundSettings?.type) {
output.result.push({
parentType: "Buttons",
type: "Button",
path: path.join("."),
id: btn.id || null,
note: "The Button doesn't selected any option, like 'Use Default'、'Custom Color' or 'preset color'.",
});
}
});
}
// 检查当前节点是否为 Button // 检查当前节点是否为 Button
if (node.type === "Button") { if (node.type === "Button") {
if ((node.color || (!node.color && node.hasOwnProperty("backgroundSettings"))) && !node.backgroundSettings?.type) { if ((node.color || (!node.color && node.hasOwnProperty("backgroundSettings"))) && !node.backgroundSettings?.type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment