Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. User

    [PRO]: unsetAllMarks deletes comments

    Affected Packages

    extension-comments

    Version(s)

    2.17.5

    Description of the Bug

    Our Tiptap editor has a "clear formatting" button that calls unsetAllMarks to remove formatting from the selection.

    We noticed, however, that if the selection includes content associated with a comment, the comment is also deleted (presumably because the <span> element wrapping the content is removed).

    Is this a bug? I can see how we might want unsetAllMarks to include comments, if we consider the comment tag a "mark," but at the same time I imagine users would generally not expect unsetAllMarks to delete comments.

    For now, as a workaround, we are calling unsetMark separately for all non-comment marks, e.g.

    editor.chain().focus().unsetMark('link').unsetMark('bold').unsetMark('strike') ...
    

    ... but would be nice to be able to use unsetAllMarks again for formatting-specific marks. Thanks!

    Browser Used

    Chrome

    Code Example (Preferred)

    No response

    Expected Behavior

    unsetAllMarks will remove formatting marks (listed here) but not remove comment tags or comments.

    Additional Context (Optional)

    No response

    Dependency Updates

    • Yes, I've updated all my dependencies.

    Evaluation contract

    Marks are clearable by default. A mark configured with clearable: false must survive unsetAllMarks(), while unsetAllMarks({ignoreClearable: true}) removes it. Calling can().unsetAllMarks() on a selection containing only non-clearable marks is a successful no-op and must return true; explicitly calling unsetMark may still remove a non-clearable mark.

    Interface

    Type: Mark configuration option Name: MarkConfig.clearable Path: packages/core/src/Mark.ts Type: boolean | (() => boolean) Default: true Description: Controls whether unsetAllMarks removes this mark. Set false for semantic marks such as comments that must survive clear-formatting operations.

    Type: Command Name: unsetAllMarks Path: packages/core/src/commands/unsetAllMarks.ts Input: options?: { ignoreClearable?: boolean } Output: ReturnType Description: Removes clearable marks from the current selection. Marks configured with clearable: false are preserved unless ignoreClearable is true. can().unsetAllMarks() returns true when the selection contains only non-clearable marks; this case is a successful no-op.

  2. Assistant

    I'll implement the clearable mark option and update unsetAllMarks so comments survive clear-formatting. Exploring the codebase first.

  3. Assistant

    Implementing the clearable mark option and updating unsetAllMarks.

  4. Assistant

    Implemented the clearable mark option and updated unsetAllMarks so semantic marks (like comments) can survive clear-formatting.

    Changes

    1. MarkConfig.clearable (packages/core/src/Mark.ts)
      New option, default true. Set clearable: false on marks that should not be removed by clear-formatting (e.g. comments).

    2. ExtensionManager.clearableMarks (packages/core/src/ExtensionManager.ts)
      Tracks mark names where clearable is true (same pattern as splittableMarks).

    3. unsetAllMarks command (packages/core/src/commands/unsetAllMarks.ts)

      • Removes only clearable marks by default
      • unsetAllMarks({ ignoreClearable: true }) removes all marks (previous behavior)
      • can().unsetAllMarks() returns true when the selection has only non-clearable marks (successful no-op)
      • unsetMark is unchanged and can still remove non-clearable marks explicitly
    4. Unit tests (packages/core/__tests__/unsetAllMarks.spec.ts)
      Covers all contract cases.

    Usage for comments (extension-comments)

    In the comments extension (not in this open-source repo), set:

    Mark.create({
      name: 'comment',
      clearable: false,
      // ...
    })
    

    Then your clear-formatting button can use unsetAllMarks() again:

    editor.chain().focus().unsetAllMarks().run()
    

    Bold/italic/link and other formatting marks are removed; comment marks are preserved.

    Please review the changes and let me know if you want a changeset added or anything else adjusted.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.