-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardize Dialog Components, handle zero width spaces in common blo…
…cks, fix flip cards in Firefox (#1368) * Make PageEditor to remove non-breaking spaces from content on save - Added `removeNonBreakingSpaces` utility to clean up uncommon space characters in paragraph blocks. - Updated `PageEditor` to utilize the new utility when normalizing document content. - Introduced unit tests for `removeNonBreakingSpaces` to ensure functionality across various block types and nested structures. * Rename `removeNonBreakingSpaces` to `removeUncommonSpacesFromBlocks` * Update space normalization in Gutenberg blocks to support more blocks * Refactor FlipCard components, fix content showing through in Firefox * Make images not interactive inside the flip cards * Fix clicking on images * WIP cleaning up dialogs * Clean up dialogs * Remove unused variables * Add missing props * FIx * Update snapshots * System test fixes * More dialog cleanup
- Loading branch information
Showing
72 changed files
with
1,205 additions
and
989 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { BlockInstance } from "@wordpress/blocks" | ||
|
||
import { removeUncommonSpacesFromBlocks } from "../../src/utils/Gutenberg/modifyBlocks" | ||
|
||
describe("removeUncommonSpacesFromBlocks", () => { | ||
it("should replace non-breaking spaces with regular spaces in paragraph blocks", () => { | ||
const blocks: BlockInstance[] = [ | ||
{ | ||
name: "core/paragraph", | ||
attributes: { | ||
content: "Hello\u00A0World\u2003More\u3000Text", | ||
}, | ||
clientId: "1", | ||
isValid: true, | ||
innerBlocks: [], | ||
}, | ||
] | ||
|
||
const result = removeUncommonSpacesFromBlocks(blocks) | ||
|
||
expect(result[0].attributes.content).toBe("Hello World More Text") | ||
expect(blocks[0].attributes.content).toBe("Hello\u00A0World\u2003More\u3000Text") | ||
}) | ||
|
||
it("should replace non-breaking spaces in heading blocks", () => { | ||
const blocks: BlockInstance[] = [ | ||
{ | ||
name: "core/heading", | ||
attributes: { | ||
content: "Header\u00A0Text\u2003Here", | ||
level: 2, | ||
}, | ||
clientId: "1", | ||
isValid: true, | ||
innerBlocks: [], | ||
}, | ||
] | ||
|
||
const result = removeUncommonSpacesFromBlocks(blocks) | ||
|
||
expect(result[0].attributes.content).toBe("Header Text Here") | ||
expect(blocks[0].attributes.content).toBe("Header\u00A0Text\u2003Here") | ||
}) | ||
|
||
it("should replace non-breaking spaces in hero-section blocks", () => { | ||
const blocks: BlockInstance[] = [ | ||
{ | ||
name: "moocfi/hero-section", | ||
attributes: { | ||
title: "Main\u00A0Title\u2003Here", | ||
subtitle: "Sub\u00A0Title\u2003Text", | ||
}, | ||
clientId: "1", | ||
isValid: true, | ||
innerBlocks: [], | ||
}, | ||
] | ||
|
||
const result = removeUncommonSpacesFromBlocks(blocks) | ||
|
||
expect(result[0].attributes.title).toBe("Main Title Here") | ||
expect(result[0].attributes.subtitle).toBe("Sub Title Text") | ||
expect(blocks[0].attributes.title).toBe("Main\u00A0Title\u2003Here") | ||
expect(blocks[0].attributes.subtitle).toBe("Sub\u00A0Title\u2003Text") | ||
}) | ||
|
||
it("should handle nested blocks", () => { | ||
const blocks: BlockInstance[] = [ | ||
{ | ||
name: "core/group", | ||
attributes: {}, | ||
clientId: "1", | ||
isValid: true, | ||
innerBlocks: [ | ||
{ | ||
name: "core/paragraph", | ||
attributes: { | ||
content: "Nested\u00A0Content", | ||
}, | ||
clientId: "2", | ||
isValid: true, | ||
innerBlocks: [], | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
const result = removeUncommonSpacesFromBlocks(blocks) | ||
|
||
expect(result[0].innerBlocks[0].attributes.content).toBe("Nested Content") | ||
expect(blocks[0].innerBlocks[0].attributes.content).toBe("Nested\u00A0Content") | ||
}) | ||
|
||
it("should ignore unsupported block types", () => { | ||
const blocks: BlockInstance[] = [ | ||
{ | ||
name: "core/image", | ||
attributes: { | ||
caption: "Image\u00A0Caption", | ||
}, | ||
clientId: "1", | ||
isValid: true, | ||
innerBlocks: [], | ||
}, | ||
] | ||
|
||
const result = removeUncommonSpacesFromBlocks(blocks) | ||
|
||
expect(result[0].attributes.caption).toBe("Image\u00A0Caption") | ||
expect(blocks[0].attributes.caption).toBe("Image\u00A0Caption") | ||
}) | ||
|
||
it("should handle empty blocks array", () => { | ||
const blocks: BlockInstance[] = [] | ||
const result = removeUncommonSpacesFromBlocks(blocks) | ||
expect(result).toEqual([]) | ||
}) | ||
}) |
Oops, something went wrong.