Skip to content

[3.21] Fix editor.js in descriptions#5911

Merged
kzuraw merged 3 commits into3.21from
eng-807-editorjs-improv-321
Oct 1, 2025
Merged

[3.21] Fix editor.js in descriptions#5911
kzuraw merged 3 commits into3.21from
eng-807-editorjs-improv-321

Conversation

@kzuraw
Copy link
Contributor

@kzuraw kzuraw commented Sep 30, 2025

Scope of the change

This PR fixes issues with ordered and unordered lists in rich text descriptions and adds backward compatibility handling for EditorJS list format changes.

Problem

After upgrading to @editorjs/list v2.0.0+, the list format changed from simple string arrays to objects with content and metadata. This created compatibility issues with storefronts expecting the legacy format, potentially breaking existing list rendering.

Changes

🐛 Bug Fixes

  • Fixed list format compatibility: Added conversion utility to transform new EditorJS list format back to legacy format
  • Fixed inline toolbar display: Resolved issue where formatting toolbar was being cut off on smaller screens
  • Updated list icons: Migrated custom icons to match new EditorJS icon style

🔧 Technical Implementation

1. List Format Conversion (convertEditorJSListBlocks)

Created a utility function to convert between EditorJS list formats:

New Format (v2.0.0+):

{
  "items": [
    { "content": "Item 1", "meta": {} },
    { "content": "Item 2", "meta": {} }
  ]
}

Legacy Format (pre-v2.0.0):

{
  "items": ["Item 1", "Item 2"]
}

Location: src/components/RichTextEditor/utils.ts:37

2. Integration Points

The conversion is applied at two critical points:

3. Dependencies Updated

  • @editorjs/editorjs: ^2.30.2^2.30.6
  • @editorjs/checklist: ^1.6.0^1.7.0
  • @editorjs/header: ^2.8.7^2.8.8
  • @editorjs/list: ^1.10.0^2.0.1 (major version with format changes)
  • @editorjs/quote: ^2.7.2^2.7.4

4. UI/UX Improvements

  • Fixed strikethrough icon styling
  • Adjusted inline toolbar positioning to prevent truncation
  • Updated icon styles to match EditorJS v2 design system

📝 Documentation

  • Added comprehensive JSDoc documentation for convertEditorJSListBlocks
  • Documented format transformation with examples
  • Explained backward compatibility rationale

✅ Testing

Added comprehensive unit test suite covering:

  • ✓ New format (objects) → legacy format (strings) conversion
  • ✓ Ordered and unordered list handling
  • ✓ Already-legacy-format lists (no modification)
  • ✓ Non-list blocks (passthrough)
  • ✓ Mixed block types
  • ✓ Empty list items
  • ✓ OutputData properties preservation
  • ✓ Multiple list blocks in one document

Test file: src/components/RichTextEditor/utils.test.ts

Impact

User-Facing

  • ✅ Lists now work correctly when editing product and category descriptions
  • ✅ Inline formatting toolbar displays properly on all screen sizes
  • ✅ No breaking changes for existing content

Developer-Facing

  • ✅ Backward compatibility maintained with storefront APIs
  • ✅ Well-documented conversion logic
  • ✅ Comprehensive test coverage for list transformations
  • ✅ EditorJS dependencies up to date

Testing Instructions

  1. Test list creation:

    • Navigate to any product or category
    • Edit the description field
    • Create ordered and unordered lists
    • Verify lists save and display correctly
  2. Test legacy content:

    • Open existing products/categories with lists
    • Verify existing lists display correctly
    • Edit and re-save
    • Confirm no data corruption
  3. Test toolbar:

    • Select text in the rich text editor
    • Verify inline toolbar appears and is not cut off
    • Test on various screen sizes

Copilot AI review requested due to automatic review settings September 30, 2025 12:45
@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2025

🦋 Changeset detected

Latest commit: b76edb6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-dashboard Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
saleor-dashboard-storybook Ignored Ignored Preview Oct 1, 2025 9:59am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates Editor.js dependencies to fix list editing issues and inline toolbar truncation problems in description fields. The changes migrate custom icons to match the new Editor.js icon format and remove positioning styles that were causing toolbar display issues.

  • Updated Editor.js and related plugin dependencies to newer versions
  • Migrated strikethrough icon to match new Editor.js icon format
  • Fixed inline toolbar positioning and overflow issues

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
package.json Updates Editor.js and plugin dependencies to newer versions
src/icons/StrikethroughIcon.tsx Replaces custom strikethrough icon with Editor.js compatible version
src/components/RichTextEditor/consts.ts Updates import to use new strikethrough icon export
src/components/RichTextEditor/styles.ts Removes problematic positioning styles and adds overflow fix
.changeset/two-glasses-doubt.md Adds changelog entry for the dependency updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.17%. Comparing base (701c135) to head (b76edb6).
⚠️ Report is 1 commits behind head on 3.21.

Files with missing lines Patch % Lines
src/components/RichTextEditor/RichTextEditor.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             3.21    #5911      +/-   ##
==========================================
+ Coverage   65.16%   65.17%   +0.01%     
==========================================
  Files        1445     1446       +1     
  Lines       25046    25065      +19     
  Branches     4926     4933       +7     
==========================================
+ Hits        16322    16337      +15     
- Misses       8680     8684       +4     
  Partials       44       44              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 30, 2025

Differences Found

⚠️ 3 packages or licenses were added.

Expand
License	Package
MIT	@codexteam/icons
MIT	@editorjs/dom
MIT	@editorjs/helpers

Summary

Expand
License Name Package Count Packages
0BSD 1
Packages
  • tslib
BlueOak-1.0.0 1
Packages
  • path-scurry
CC0-1.0 1
Packages
  • type-fest
MIT/X11 1
Packages
  • nub
MPL-1.1 1
Packages
  • harmony-reflect
MPL-2.0 1
Packages
  • dompurify
Public Domain 1
Packages
  • jsonify
Python-2.0 1
Packages
  • argparse
WTFPL 1
Packages
  • opener
<<missing>> 2
Packages
  • busboy
  • streamsearch
CC-BY-4.0 2
Packages
  • @saleor/macaw-ui
  • caniuse-lite
BSD-2-Clause 24
Packages
  • @typescript-eslint/parser
  • @typescript-eslint/typescript-estree
  • browser-process-hrtime
  • css-select
  • css-what
  • domelementtype
  • domhandler
  • domutils
  • dotenv
  • dotenv-expand
  • entities
  • escodegen
  • eslint-scope
  • espree
  • esprima
  • esrecurse
  • estraverse
  • esutils
  • nth-check
  • stringify-object
  • And 4 more...
Apache-2.0 45
Packages
  • @ampproject/remapping
  • @editorjs/editorjs
  • @humanwhocodes/config-array
  • @humanwhocodes/module-importer
  • @opentelemetry/api
  • @opentelemetry/semantic-conventions
  • @playwright/test
  • @swc/core
  • @swc/core-darwin-arm64
  • @swc/core-darwin-x64
  • @swc/core-linux-arm-gnueabihf
  • @swc/core-linux-arm64-gnu
  • @swc/core-linux-arm64-musl
  • @swc/core-linux-x64-gnu
  • @swc/core-linux-x64-musl
  • @swc/core-win32-arm64-msvc
  • @swc/core-win32-ia32-msvc
  • @swc/core-win32-x64-msvc
  • @swc/counter
  • @swc/types
  • And 25 more...
BSD-3-Clause 47
Packages
  • @humanwhocodes/object-schema
  • @saleor/app-sdk
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • @sinonjs/commons
  • @sinonjs/fake-timers
  • abab
  • asn1js
  • babel-plugin-istanbul
  • charenc
  • chroma-js
  • crypt
  • diff
  • esquery
  • And 27 more...
ISC 48
Packages
  • @istanbuljs/load-nyc-config
  • anymatch
  • boolbase
  • browser-stdout
  • cli-width
  • cliui
  • electron-to-chromium
  • fastq
  • flatted
  • fs.realpath
  • get-caller-file
  • get-own-enumerable-property-symbols
  • glob
  • glob-parent
  • graceful-fs
  • inflight
  • inherits
  • ini
  • isexe
  • json-stringify-safe
  • And 28 more...
MIT 1146
Packages
  • @adobe/css-tools
  • @apollo/client
  • @ardatan/relay-compiler
  • @ardatan/sync-fetch
  • @babel/code-frame
  • @babel/compat-data
  • @babel/core
  • @babel/generator
  • @babel/helper-annotate-as-pure
  • @babel/helper-compilation-targets
  • @babel/helper-create-class-features-plugin
  • @babel/helper-member-expression-to-functions
  • @babel/helper-module-imports
  • @babel/helper-module-transforms
  • @babel/helper-optimise-call-expression
  • @babel/helper-plugin-utils
  • @babel/helper-replace-supers
  • @babel/helper-simple-access
  • @babel/helper-skip-transparent-expression-wrappers
  • @babel/helper-string-parser
  • And 1126 more...

@github-actions github-actions bot temporarily deployed to pr-5911 September 30, 2025 12:49 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5911 October 1, 2025 09:38 Destroyed
@kzuraw kzuraw marked this pull request as ready for review October 1, 2025 09:52
@kzuraw kzuraw requested a review from a team as a code owner October 1, 2025 09:52
@kzuraw kzuraw requested review from Copilot, lkostrowski and witoszekdev and removed request for Copilot October 1, 2025 09:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lucide will not fit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately not - it will be different than the rest of the icons 😞

"saleor-dashboard": patch
---

Fixed issues with ordered and unordered lists in product and category descriptions. Lists now work correctly when editing, and the inline formatting toolbar no longer gets cut off on smaller screens.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: should we also add a note about the format change in editor.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering about it - format is changed but we are converting to old one anyway and end users won't be able to see the difference

@kzuraw kzuraw merged commit bf70951 into 3.21 Oct 1, 2025
24 checks passed
@kzuraw kzuraw deleted the eng-807-editorjs-improv-321 branch October 1, 2025 12:32
@kzuraw kzuraw mentioned this pull request Oct 2, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants