Skip to content

Conversation

ankitsharma38
Copy link

@ankitsharma38 ankitsharma38 commented Oct 9, 2025

Problem

When importing Notion HTML exports to AFFiNE, user avatars in database Person columns were being imported as large images at the top of pages instead of being properly handled.

Solution

  • Added notionHtmlUserIconToDeltaMatcher to specifically handle elements with user-icon class
  • These elements are now replaced with spaces, cleaning up the imported content
  • Added test case to verify the fix works correctly

Example

Before: Large avatar images appeared at the top of imported pages
After: Clean text like "Name with avatar CXXXX(Another name without avatar) KXXXX(2nd name without avatar)"

Testing

  • Added unit test case that verifies user icons are properly converted to spaces
  • Existing tests continue to pass

Summary by CodeRabbit

  • New Features
    • Notion HTML imports now skip user icon elements, inserting a space instead to prevent icon artifacts in text and produce cleaner paragraphs.
  • Tests
    • Added a snapshot test covering user icon handling during Notion HTML conversion to ensure consistent results.
  • Chores
    • Removed iOS Swift Package.resolved to avoid committing resolved dependency state and reduce churn.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added app:electron Related to electron app mod:dev test Related to test cases app:core labels Oct 9, 2025
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adds a Notion HTML inline matcher to skip user-icon elements by inserting a space in Delta output, includes it in the adapter exports, adds a unit test covering user icons, and removes the iOS SwiftPM Package.resolved file.

Changes

Cohort / File(s) Summary
Inline adapter: Notion HTML user-icon matcher
blocksuite/affine/inlines/preset/src/adapters/notion-html/html-inline.ts
Introduces notionHtmlUserIconToDeltaMatcher to map elements with class 'user-icon' to a single space insert; exports the matcher and adds it to NotionHtmlInlineToDeltaAdapterExtensions.
Tests: Notion HTML snapshots
blocksuite/affine/all/src/__tests__/adapters/notion-html.unit.spec.ts
Adds "user icons" test verifying user-icon elements are converted to a paragraph with concatenated user text (icons skipped).
iOS workspace metadata
packages/frontend/apps/ios/App/App.xcworkspace/xcshareddata/swiftpm/Package.resolved
Removes SwiftPM lockfile with pinned dependencies.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant H as Notion HTML
  participant A as InlineToDeltaAdapter
  participant M as user-icon Matcher
  participant D as Delta

  H->>A: Parse elements
  A->>M: Element classList contains "user-icon"?
  alt user-icon matched
    M-->>A: Return insert " "
    A->>D: Append " "
  else not matched
    A->>D: Process via other rules
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • akumatus
  • Saul-Mirone

Poem

I nibble through tags with whiskered grace,
Hop over user-icons, leaving just a space.
Tests bloom like clover in morning light,
Adapters align—everything just right.
SwiftPM crumbs swept from the trail—
Onward I bound, with a cotton-tail! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change of stripping user-icon avatars during Notion HTML import and aligns closely with the PR’s main fix.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c63e3e7 and 5d77437.

⛔ Files ignored due to path filters (5)
  • .yarn/releases/yarn-4.9.1.cjs is excluded by !**/.yarn/**
  • blocksuite/playground/apps/starter/data/snapshots/affine-default.zip is excluded by !**/*.zip
  • packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/Controller/AttachmentManagementController/AttachmentIcon.xcassets/FileAttachment_json.imageset/AiFileClip attachment icon.pdf is excluded by !**/*.pdf
  • packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/Controller/AttachmentManagementController/AttachmentIcon.xcassets/FileAttachment_pdf.imageset/AiFileClip attachment icon.pdf is excluded by !**/*.pdf
  • packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/Controller/AttachmentManagementController/AttachmentIcon.xcassets/FileAttachment_txt.imageset/AiFileClip attachment icon.pdf is excluded by !**/*.pdf
📒 Files selected for processing (3)
  • blocksuite/affine/all/src/__tests__/adapters/notion-html.unit.spec.ts (1 hunks)
  • blocksuite/affine/inlines/preset/src/adapters/notion-html/html-inline.ts (2 hunks)
  • packages/frontend/apps/ios/App/App.xcworkspace/xcshareddata/swiftpm/Package.resolved (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/frontend/apps/ios/App/App.xcworkspace/xcshareddata/swiftpm/Package.resolved
🧰 Additional context used
🧬 Code graph analysis (2)
blocksuite/affine/inlines/preset/src/adapters/notion-html/html-inline.ts (1)
blocksuite/affine/shared/src/adapters/index.ts (1)
  • NotionHtmlASTToDeltaExtension (58-58)
blocksuite/affine/all/src/__tests__/adapters/notion-html.unit.spec.ts (2)
blocksuite/framework/store/src/transformer/type.ts (1)
  • BlockSnapshot (6-13)
blocksuite/affine/model/src/themes/default.ts (1)
  • DefaultTheme (112-136)
🔇 Additional comments (3)
blocksuite/affine/all/src/__tests__/adapters/notion-html.unit.spec.ts (1)

2094-2141: LGTM! Comprehensive test coverage for user icon handling.

The test case effectively validates the new user-icon matcher by:

  • Covering both <img class="user-icon"> and <span class="user-icon"> elements
  • Verifying that user icons are replaced with spaces while preserving surrounding text
  • Following the established test pattern with proper adapter usage and nanoid normalization

The expected output correctly demonstrates that avatar images and icon containers are stripped, leaving clean text: "Person Name with avatar CXXXX(Another name without avatar) KXXXX(2nd name without avatar)".

blocksuite/affine/inlines/preset/src/adapters/notion-html/html-inline.ts (2)

243-259: LGTM! Clean implementation of user-icon handling.

The matcher implementation is straightforward and correct:

  • Properly identifies elements with the 'user-icon' class
  • Replaces them with a single space to maintain word separation
  • Follows the established pattern of other element matchers in this file

Note that this approach intentionally discards any text content within the user-icon element (e.g., initials in avatar placeholders), which aligns with the goal of stripping avatar UI elements during import.


274-274: Verify matcher ordering if conflicts arise.

Ripgrep search didn’t locate any references to user-icon; please manually confirm no other matcher targets this class to avoid ordering conflicts.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@darkskygit darkskygit left a comment

Choose a reason for hiding this comment

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

dont change file mode and remove non-required file changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:core app:electron Related to electron app mod:dev test Related to test cases

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants