Skip to content

Viewer completeness read-only block types#20

Merged
RZEROSTERN merged 10 commits intomasterfrom
feat/phase-2-viewer-completeness-part-2
Mar 25, 2026
Merged

Viewer completeness read-only block types#20
RZEROSTERN merged 10 commits intomasterfrom
feat/phase-2-viewer-completeness-part-2

Conversation

@RZEROSTERN
Copy link
Copy Markdown
Collaborator

Phase 2 + Viewer Completeness: new block types, sanitization & rendering

Type of change

  • New feature
  • Bug fix
  • Refactor
  • Chore / dependency update
  • Documentation

Summary

Viewer completeness — read-only block types (0.2.1)

  • Added 4 viewer-only block types: embed, linkTool, attaches, raw
  • Extracted HtmlStyleBuilder shared utility — removes duplicate _buildStyleMap/_parseColor helpers from every renderer and propagates defaultFont to flutter_html body style
  • Applied HtmlSanitizer.sanitize() to QuoteRenderer and ListRenderer
  • ImageRenderer caption now respects styleConfig.defaultFont
  • Bumped version 0.2.00.2.1

Breaking changes

  • ListBlock.items type changed from List<String> to List<ListItem>. Any code constructing a ListBlock directly must update to ListItem(content: 'text') instead of plain strings.

Migration notes

// Before
ListBlock(style: ListStyle.unordered, items: ['Item 1', 'Item 2'])

// After
ListBlock(
  style: ListStyle.unordered,
  items: [
    ListItem(content: 'Item 1'),
    ListItem(content: 'Item 2'),
  ],
)

New public API

Symbol Description
QuoteBlock / QuoteAlignment Quote entity with alignment
CodeBlock Code block entity
ChecklistBlock / ChecklistItem Checklist with per-item checked state
TableBlock 2-D table with optional heading row
WarningBlock Alert box with title and message
ListItem Recursive list item
EmbedBlock Embedded content (YouTube, Vimeo, etc.) — viewer only
LinkToolBlock / LinkToolMeta Link preview card — viewer only
AttachesBlock File attachment download card — viewer only
RawBlock Raw HTML content — viewer only

Test plan

  • fvm flutter analyze passes with no issues ✅
  • Viewer renders each of the 14 supported block types from a sample EditorJS JSON
  • Nested list JSON (flat strings + nested objects) renders with correct indentation
  • Quote block respects alignment field
  • Code block copy button works
  • Checklist checked items render with strikethrough
  • Table with withHeadings: true renders first row bold
  • Warning block shows title + message with amber icon
  • embed block opens source URL externally on tap
  • linkTool block shows thumbnail + title + description + URL; opens on tap
  • attaches block shows correct icon per extension, formatted size, opens on tap
  • raw block sanitizes HTML before rendering (no <script> or on* attributes pass through)
  • defaultFont from StyleConfig applies inside flutter_html rendered content
  • Editor can create each Phase 2 block type via toolbar buttons
  • getContent() serialises all block types back to valid EditorJS JSON
  • Demo app tested manually on at least one platform

Copilot AI review requested due to automatic review settings March 25, 2026 17:05
Copy link
Copy Markdown
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

Adds viewer-only support for additional EditorJS block types and consolidates HTML styling/sanitization so the Flutter viewer renders more of the EditorJS ecosystem consistently.

Changes:

  • Added viewer-only blocks: embed, linkTool, attaches, raw (entities, mappers, renderers, registry wiring, exports)
  • Introduced HtmlStyleBuilder to centralize flutter_html style-map creation and propagate defaultFont
  • Expanded HTML sanitization usage (notably in quote/list) and bumped package version to 0.2.1

Reviewed changes

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

Show a summary per file
File Description
pubspec.yaml Bumps package version to 0.2.1
lib/src/presentation/utils/html_style_builder.dart New shared builder for flutter_html style maps (fonts + cssTags)
lib/src/presentation/registry/block_renderer_registry.dart Registers new renderers for the viewer-only block types
lib/src/presentation/blocks/raw/raw_renderer.dart Renders sanitized raw HTML via flutter_html
lib/src/presentation/blocks/quote/quote_renderer.dart Uses sanitizer + shared HTML styles (adds alignment handling in style map)
lib/src/presentation/blocks/paragraph/paragraph_renderer.dart Switches to shared HTML style builder
lib/src/presentation/blocks/list/list_renderer.dart Sanitizes list item HTML and switches to shared HTML style builder
lib/src/presentation/blocks/link_tool/link_tool_renderer.dart New link preview card renderer opening URLs externally
lib/src/presentation/blocks/image/image_renderer.dart Applies defaultFont to image captions
lib/src/presentation/blocks/embed/embed_renderer.dart New embed card renderer opening source URL externally
lib/src/presentation/blocks/attaches/attaches_renderer.dart New attachment card renderer opening download URL externally
lib/src/domain/entities/blocks/raw_block.dart New Raw block entity
lib/src/domain/entities/blocks/link_tool_block.dart New LinkTool block entity + meta model
lib/src/domain/entities/blocks/embed_block.dart New Embed block entity
lib/src/domain/entities/blocks/attaches_block.dart New Attaches block entity
lib/src/data/registry/block_type_registry.dart Registers new block mappers for JSON → entity parsing
lib/src/data/mappers/raw_mapper.dart Raw block JSON mapper
lib/src/data/mappers/link_tool_mapper.dart LinkTool block JSON mapper
lib/src/data/mappers/embed_mapper.dart Embed block JSON mapper
lib/src/data/mappers/attaches_mapper.dart Attaches block JSON mapper
lib/editorjs_flutter.dart Exports new public block entities
CHANGELOG.md Adds 0.2.1 release notes describing new viewer-only blocks and renderer improvements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/presentation/utils/html_style_builder.dart Outdated
Comment thread lib/src/presentation/blocks/quote/quote_renderer.dart Outdated
Comment thread lib/src/presentation/blocks/embed/embed_renderer.dart Outdated
Comment thread lib/src/presentation/blocks/link_tool/link_tool_renderer.dart Outdated
Comment thread lib/src/presentation/blocks/attaches/attaches_renderer.dart
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 25, 2026 17:32
RZEROSTERN and others added 2 commits March 25, 2026 11:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
RZEROSTERN and others added 2 commits March 25, 2026 11:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

@RZEROSTERN I've opened a new pull request, #21, to work on those changes. Once the pull request is ready, I'll request review from you.

…strict to http/https, check canLaunchUrl

Co-authored-by: RZEROSTERN <3065243+RZEROSTERN@users.noreply.github.com>
Agent-Logs-Url: https://github.com/RZEROSTERN/editorjs-flutter/sessions/97759922-db09-4059-af45-b959591f6f85
Copy link
Copy Markdown
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 22 out of 22 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/presentation/blocks/link_tool/link_tool_renderer.dart
Comment thread lib/src/presentation/blocks/attaches/attaches_renderer.dart Outdated
Comment thread lib/src/presentation/blocks/list/list_renderer.dart
RZEROSTERN and others added 2 commits March 25, 2026 11:38
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

@RZEROSTERN I've opened a new pull request, #22, to work on those changes. Once the pull request is ready, I'll request review from you.

Fix unsafe URL launch in LinkToolRenderer
@RZEROSTERN RZEROSTERN merged commit f35ef3c into master Mar 25, 2026
1 check passed
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.

3 participants