Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [PRO]: unsetAllMarks deletes comments Affected Packages…

  1. User

    ISSUE DESCRIPTION

    [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.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /tiptap, current file: none) bash-$

  2. MiniMax Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. MiniMax Assistant

    Now let me check the extension-comments package to see how the comment mark is implemented:

  4. MiniMax Assistant

    The extension-comments package isn't in this repo. Let me look at the test files and find relevant existing patterns:

  5. MiniMax Assistant

    Let me look at how extension-bold implements its mark and similar options:

  6. MiniMax Assistant

    Let me look at the Mark.ts more carefully and understand how options are evaluated:

  7. MiniMax Assistant

    Let me look at getExtensionField to understand how clearable should be evaluated:

  8. MiniMax Assistant

    Now let me look at how schema.marks looks like to understand the structure:

  9. MiniMax Assistant

    Let me look at how extensions are passed to commands (so I can find the mark extensions and their config):

  10. MiniMax Assistant

    Now I have a good understanding of the structure. Let me look at how exitable is used, since it's a similar boolean config option:

  11. MiniMax Assistant

    Now let me look at how keepOnSplit is used, which is similar:

  12. MiniMax Assistant

    Let me look at getExtensionField<MarkConfig['exitable']> to understand the pattern:

  13. MiniMax Assistant

    Let me look at the editor.extensionManager.extensions:

  14. MiniMax Assistant

    Let me check the toggleList.ts file as it uses the extensionManager.extensions:

  15. MiniMax Assistant

    Good - now I understand how to access extensions and their config. Let me look at the removeMark function from ProseMirror to understand:

  16. MiniMax Assistant

    Now let me explore the tests for commands in core:

  17. MiniMax Assistant

    Let me look at the existing implementations of marks and how keepOnSplit is configured:

  18. MiniMax Assistant

    Now let me check how extension-code defines exitable:

  19. MiniMax Assistant

    Now I have a complete understanding. Let me set up a reproduction script. Let me first check the existing build setup:

  20. MiniMax Assistant

    Let me first run the existing tests for core to make sure they pass before I make changes:

  21. MiniMax Assistant

    All existing tests pass. Now let me write a reproduction script:

  22. MiniMax Assistant

    Let me create a reproduction script to confirm the issue:

  23. MiniMax Assistant

    Let me write a vitest-style test to verify the behavior, since the codebase uses vitest:

  24. MiniMax Assistant

    Let me fix the test to use proper setup with the comment containing the bold mark (as described in the original issue):

  25. MiniMax Assistant

    I've successfully reproduced the bug. Now let me look at how the isActive helper works for marks:

  26. MiniMax Assistant

    Now I have a clear picture. Let me implement the fix.

    Step 1: Add clearable to MarkConfig

  27. MiniMax Assistant

    Now let me modify Mark.ts to add the clearable option:

  28. MiniMax Assistant

    I made a mistake with the sed. Let me revert and apply the change correctly:

  29. MiniMax Assistant

    Now let me use edit instead:

  30. MiniMax Assistant

    Let me use Python to do the substitution precisely:

  31. MiniMax Assistant

    Step 2: Modify the unsetAllMarks command

  32. MiniMax Assistant

    Let me test the change:

  33. MiniMax Assistant

    I'm passing the extension instance instead of the MarkType. Let me fix this by getting the actual MarkType:

  34. MiniMax Assistant

    Now let me update my reproduction script to also test the new functionality:

  35. MiniMax Assistant

    All my reproduction and fix tests pass. Now let me run all existing tests to make sure I didn't break anything:

  36. MiniMax Assistant

    All 384 tests pass. Let me also run tests for related packages that use marks:

  37. MiniMax Assistant

    Let me also run the tests for all packages in packages/ to make sure nothing is broken:

  38. MiniMax Assistant

    Let me also think about edge cases and verify:

  39. MiniMax Assistant

    Let me check the issue. The code mark has excludes: '_' which excludes all other marks. Let me investigate:

  40. MiniMax Assistant

    I see - code has excludes: '_' which excludes all other marks. Let me update my test to remove that combination:

  41. MiniMax Assistant

    All tests pass. Now let me clean up the temporary test files I created:

  42. MiniMax Assistant

    Now let me also clean up other temporary files:

  43. MiniMax Assistant

    Let me look at my final implementation once more:

  44. MiniMax Assistant

    Let me look at CommandProps to ensure state is available:

  45. MiniMax Assistant

    Good - state is available in CommandProps. Let me also check if there are any issues with getExtensionField when the mark extension doesn't have clearable set:

  46. MiniMax Assistant

    Let me also verify the getExtensionField behavior for missing clearable field:

  47. MiniMax Assistant

    Now let me run the full test suite once more to make sure I didn't break anything:

  48. MiniMax Assistant

    All 377 existing tests pass.

    Let me also test a few edge cases I might have missed - the chain().unsetAllMarks() command:

  49. MiniMax Assistant

    All tests pass. Let me run the full test suite once more to be safe:

  50. MiniMax Assistant

    All 1064 tests pass. Let me also check the extension-comments package is somewhere. Actually let me search the extension-comments location more broadly:

  51. MiniMax Assistant

    Let me check if there are any changesets related to this issue or whether I should add one:

  52. MiniMax Assistant

    Let me add a changeset for this fix:

  53. MiniMax Assistant

    Now let me verify the final implementation:

  54. MiniMax Assistant

    Let me also check if there are any TypeScript issues:

  55. MiniMax Assistant

    Let me check if there are any TS errors specific to my changes:

  56. MiniMax Assistant

    Let me fix this TS error:

  57. MiniMax Assistant

    Let me check how other commands handle this:

  58. MiniMax Assistant

    The Storage is exported from index.ts, not types.ts. Let me check where ExtensionManager.ts imports it from:

  59. MiniMax Assistant

    Storage is imported from ./index.js, not ./types.js. Let me fix my import:

  60. MiniMax Assistant

    No more TS errors related to my changes. Let me run the full test suite once more:

  61. MiniMax Assistant

    All 377 tests pass. Let me also write a final reproduction script to confirm the original issue is fixed:

  62. MiniMax Assistant

    All my tests pass and the original issue is fixed. Let me check the final state of the implementation:

  63. MiniMax Assistant

    Let me also check if there's a callOrReturn re-exported from @tiptap/core (so I don't need a separate import):

  64. MiniMax Assistant

    Let me run the full test suite one more time to confirm everything works:

  65. MiniMax Assistant

    All 1064 tests pass. Let me also check the .changeset file:

  66. MiniMax Assistant

    Let me also check if there are any lint issues:

  67. MiniMax Assistant

    No lint errors. Let me also check the formatting:

  68. MiniMax Assistant

    Let me see the format issues:

  69. MiniMax Assistant

    Good, oxfmt just made minor formatting changes. Let me run the tests again to confirm everything still works:

  70. MiniMax Assistant

    All formatting checks pass. Let me also run all tests once more:

  71. MiniMax Assistant

    All 1064 tests pass. Let me show the final diff:

  72. MiniMax Assistant

    The implementation is complete. Let me also verify my changes one more time by running all tests once more:

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