Skip to content

[FEAT] Add TaskConversionReaction for live checkbox creation#15

Open
rutvik-at-pieces wants to merge 2 commits into
mainfrom
feat_markdown_checkbox_updates
Open

[FEAT] Add TaskConversionReaction for live checkbox creation#15
rutvik-at-pieces wants to merge 2 commits into
mainfrom
feat_markdown_checkbox_updates

Conversation

@rutvik-at-pieces

@rutvik-at-pieces rutvik-at-pieces commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Adds a new TaskConversionReaction that converts a ParagraphNode into a TaskNode when the user types [] or [x] at the start of a paragraph — matching the existing pattern used for unordered (- ) and ordered (1. ) list item conversions.

Changes

  • New TaskConversionReaction class in default_document_editor_reactions.dart
    • Extends ParagraphPrefixConversionReaction (same base as UnorderedListItemConversionReaction)
    • Detects [] (incomplete task) and [x] (complete task) prefixes
    • Replaces the ParagraphNode with a TaskNode, preserving remaining text content
    • Sets isComplete based on whether x is present in the prefix
    • Configurable via allowConversionOfNonEmptyParagraphs flag (defaults to true)

Motivation

Previously, there was no way to create a TaskNode by typing in the editor — users could only get checkboxes from deserialized markdown. This brings task creation UX in line with how list items already work (type a prefix, get a converted node).

Related PRs

  • pieces-app/pieces_platform_client_sdk#574 — Registers this reaction in the Pieces editor pipeline + handles nested task indentation in serialization, deserialization, and PDF export

@rutvik-at-pieces rutvik-at-pieces self-assigned this Jul 24, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 11:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new paragraph prefix conversion reaction intended to convert a ParagraphNode into a TaskNode when the user types a task checkbox prefix at the start of a paragraph.

Changes:

  • Introduces TaskConversionReaction to detect a task prefix and replace a ParagraphNode with a TaskNode.
  • Adds configurability via allowConversionOfNonEmptyParagraphs to control whether conversion triggers for non-empty paragraphs.
Comments suppressed due to low confidence (3)

super_editor/lib/src/default_editor/default_document_editor_reactions.dart:177

  • The task prefix regex only matches [] or [x], but the rest of the codebase serializes tasks using GitHub-style - [ ] / - [x] (see lib/src/infrastructure/serialization/markdown/document_to_markdown_serializer.dart:351-378). Consider also matching [ ] (and allowing uppercase X) so users can type the common task syntax.
  static final _taskInEmptyParagraphPattern = RegExp(r'^\s*\[x?\]\s+$');
  static final _taskInNonEmptyParagraphPattern = RegExp(r'^\s*\[x?\]\s+');

super_editor/lib/src/default_editor/default_document_editor_reactions.dart:197

  • match.contains('x') is case-sensitive, so [X] won't be treated as complete (especially if the regex is made case-insensitive). Prefer an explicit, case-insensitive check for the [x] token.
    final isComplete = match.contains('x');

super_editor/lib/src/default_editor/default_document_editor_reactions.dart:194

  • This new conversion behavior should have widget test coverage alongside the other paragraph conversions in test/super_editor/text_entry/paragraph_conversions_test.dart (e.g., for [] / [x] / [ ] in empty and non-empty paragraphs, and for allowConversionOfNonEmptyParagraphs: false).
  void onPrefixMatched(
    EditContext editContext,
    RequestDispatcher requestDispatcher,
    List<EditEvent> changeList,
    ParagraphNode paragraph,

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

@rutvik-at-pieces rutvik-at-pieces changed the title [FEAT] Added a TaskConversionReaction for checkbox patterns [FEAT] Add TaskConversionReaction for live checkbox creation Jul 24, 2026
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.

2 participants