Commit 41b63eb9 by Lin Wang

fix: diff buttons

parent 87397639
...@@ -31,7 +31,7 @@ const baselinePath = join(srcDir, baselineFile); ...@@ -31,7 +31,7 @@ const baselinePath = join(srcDir, baselineFile);
const baselineData = JSON.parse(readFileSync(baselinePath, 'utf-8')); const baselineData = JSON.parse(readFileSync(baselinePath, 'utf-8'));
// Fields to ignore during diff // Fields to ignore during diff
const ignoreFields = ['pageUid', 'pageTitle', 'id']; const ignoreFields = ['pageUid', 'pageTitle', 'id', 'path'];
selectedSelectors selectedSelectors
.filter(id => Number(id) !== baselineId) .filter(id => Number(id) !== baselineId)
...@@ -57,6 +57,8 @@ selectedSelectors ...@@ -57,6 +57,8 @@ selectedSelectors
if (typeof itemIdx === 'number') { if (typeof itemIdx === 'number') {
context[selectedLanguages[baselineId]].id = pageA.result?.[itemIdx]?.id; context[selectedLanguages[baselineId]].id = pageA.result?.[itemIdx]?.id;
context[selectedLanguages[otherId]].id = pageB.result?.[itemIdx]?.id; context[selectedLanguages[otherId]].id = pageB.result?.[itemIdx]?.id;
context[selectedLanguages[baselineId]].path = pageA.result?.[itemIdx]?.path;
context[selectedLanguages[otherId]].path = pageB.result?.[itemIdx]?.path;
} }
} }
} }
......
...@@ -28,7 +28,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -28,7 +28,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
const getInlineColors = extractInlineColors(node.value).join(','); const getInlineColors = extractInlineColors(node.value).join(',');
output.result.push({ output.result.push({
RichText_type: "RichText", RichText_type: "RichText",
RichText_path: path.join('.'), path: path.join('.'),
RichText_color: getInlineColors, RichText_color: getInlineColors,
id: node.id || null id: node.id || null
}); });
...@@ -41,7 +41,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -41,7 +41,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
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({
Button_type: "Button", Button_type: "Button",
Button_path: path.join('.'), path: path.join('.'),
Button_color: btn.color, Button_color: btn.color,
Button_backgroundSettings: btn.backgroundSettings || {}, Button_backgroundSettings: btn.backgroundSettings || {},
id: btn.id || null id: btn.id || null
...@@ -53,7 +53,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -53,7 +53,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
if (node.type === "Button") { if (node.type === "Button") {
output.result.push({ output.result.push({
Button_type: "Button", Button_type: "Button",
Button_path: path.join('.'), path: path.join('.'),
Button_color: node.color, Button_color: node.color,
Button_backgroundSettings: node.backgroundSettings || {}, Button_backgroundSettings: node.backgroundSettings || {},
id: node.id || null id: node.id || null
...@@ -63,7 +63,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -63,7 +63,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
if (node.type === "SlideSettings" && node.layout_config?.hasOwnProperty("card")) { if (node.type === "SlideSettings" && node.layout_config?.hasOwnProperty("card")) {
output.result.push({ output.result.push({
featureList_type: 'SlideSettings.layout_config.card', featureList_type: 'SlideSettings.layout_config.card',
featureList_path: path.join('.'), path: path.join('.'),
featureList_card: node.layout_config.card, featureList_card: node.layout_config.card,
featureList_card_color: node.layout_config.card_color, featureList_card_color: node.layout_config.card_color,
featureList_border: node.layout_config.border, featureList_border: node.layout_config.border,
...@@ -82,14 +82,14 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -82,14 +82,14 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
output.result.push({ output.result.push({
Background_textColor_type: "Background.textColor", Background_textColor_type: "Background.textColor",
Background_textColor: node.textColor || '', Background_textColor: node.textColor || '',
Background_textColor_path: path.join("."), path: path.join("."),
id: node.id || null, id: node.id || null,
Background_textColor_note: "The background is image", Background_textColor_note: "The background is image",
}) })
} else if (useVideo) { } else if (useVideo) {
output.result.push({ output.result.push({
Background_video_type: "Background.videoHtml", Background_video_type: "Background.videoHtml",
Background_video_path: path.join("."), path: path.join("."),
id: node.id || null, id: node.id || null,
Background_video_note: "The background is video", Background_video_note: "The background is video",
}) })
...@@ -97,7 +97,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) { ...@@ -97,7 +97,7 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
output.result.push({ output.result.push({
Background_color_type: "BackgroundColor", Background_color_type: "BackgroundColor",
Background_color: node.backgroundColor?.value || '', Background_color: node.backgroundColor?.value || '',
Background_color_path: path.join("."), path: path.join("."),
id: node.id || null, id: node.id || null,
Background_color_note: "The background is background color", Background_color_note: "The background is background color",
}) })
...@@ -508,10 +508,11 @@ function parseJsonForStyles( ...@@ -508,10 +508,11 @@ function parseJsonForStyles(
// 遍历子节点 // 遍历子节点
if (node.components && node.type !== "Buttons") { if (node.components && node.type !== "Buttons") {
// Only traverse individual Button when no Buttons group is present // Only traverse individual Button when no Buttons group is present
let componentKeys = Object.keys(node.components); let componentKeys = Object.keys(node.components)
if (componentKeys.includes('buttons') && componentKeys.includes('button1')) { // skip 'button1' when 'buttons' group is present
componentKeys = componentKeys.filter(k => k !== 'button1'); .filter(k => !(k === 'button1' && node.components.buttons))
} // sort keys for deterministic traversal order
.sort();
componentKeys.forEach((key) => { componentKeys.forEach((key) => {
const child = node.components[key]; const child = node.components[key];
traverse(child, [...path, `components.${key}`]); traverse(child, [...path, `components.${key}`]);
......
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