ISSUE DESCRIPTION [PRO]: unsetAllMarks deletes comments Affected Packages…
- 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
unsetAllMarksto 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
unsetAllMarksto include comments, if we consider the comment tag a "mark," but at the same time I imagine users would generally not expectunsetAllMarksto delete comments.For now, as a workaround, we are calling
unsetMarkseparately 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
unsetAllMarksagain for formatting-specific marks. Thanks!Browser Used
Chrome
Code Example (Preferred)
No response
Expected Behavior
unsetAllMarkswill 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: falsemust surviveunsetAllMarks(), whileunsetAllMarks({ignoreClearable: true})removes it. Callingcan().unsetAllMarks()on a selection containing only non-clearable marks is a successful no-op and must returntrue; explicitly callingunsetMarkmay 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 usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto 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-$
- Assistant
I'll analyze the issue and implement the fix. Let me start by exploring the repository structure.
- Assistant
Let me explore the packages directory to find the relevant files.
- Assistant
Let me examine the current Mark.ts file to understand the structure:
- Assistant
Let me view the rest of the Mark.ts file:
- Assistant
Let me view the rest of the file:
- Assistant
Now let me examine the current unsetAllMarks command:
- Assistant
Now let me find the comments extension:
- Assistant
Let me search for comments extension more broadly:
- Assistant
Let me look at the existing tests for unsetAllMarks and understand how removeMark works:
- Assistant
Let me make only one call at a time.
- Assistant
Let me also check how ProseMirror's removeMark works, and look at the Extendable class to understand how config options are resolved.
- Assistant
No clearable references yet. Let me also check the Extendable class and see how config options are stored/accessed.
- Assistant
Let me look at how
keepOnSplitis used in the codebase as a reference for howclearableshould work: - Assistant
Let me look at the ExtensionManager to see how
keepOnSplitis resolved: - Assistant
I need to use
openwith the line number option properly. - Assistant
Let me look at
getExtensionFieldandcallOrReturnto understand how config properties are resolved: - Assistant
Let me look at
callOrReturn: - Assistant
Let me check how commands access the editor and extensions:
- Assistant
Now let me look at the command context to understand how to access the editor's extensions:
- Assistant
Let me look at a command that accesses
editorto understand the command context: - Assistant
Let me look at the
splitBlockcommand that accesseseditor: - Assistant
Good, I can see commands have access to
editor. Let me look at the types to understand the command context: - Assistant
Let me search for the command context type:
- Assistant
Let me see what the RawCommands type looks like and how the command context is structured:
- Assistant
Let me look at how
Commandis defined and howeditoris available in the context: - Assistant
Let me look at the CommandProps type:
- Assistant
Let me look at how the ExtensionManager is structured:
- Assistant
Now let me understand how to access extensions from the command context:
- Assistant
Let me look at the ExtensionManager to see how extensions are stored:
- Assistant
Let me look at
splitExtensionsto understand how to get mark extensions: - Assistant
Let me look at
splitExtensions: - Assistant
Now I have a clear understanding of the codebase. Let me plan the implementation:
- Add
clearableoption toMarkConfiginMark.ts(similar tokeepOnSplit) - Modify
unsetAllMarkscommand to accept anignoreClearableoption - When
ignoreClearableis true or not set, remove all marks (current behavior) - When
ignoreClearableis false, only remove marks that are clearable
Let me start implementing:
- Add
- Assistant
Now let me add the
clearableoption toMarkConfiginMark.ts: - Assistant
Good, I've added the
clearableoption to MarkConfig. Now let me modify theunsetAllMarkscommand: - Assistant
Now I need to update the
unsetAllMarkscommand. Let me implement the changes: - Assistant
I see I have an unused import. Let me clean that up:
- Assistant
Now let me check if there are existing tests for unsetAllMarks:
- Assistant
Let me check if there are any tests for the Mark class or the core package:
- Assistant
Let me check the test configuration:
- Assistant
Let me run the existing tests to make sure my changes don't break anything:
- Assistant
Let me see the rest of the test results:
- Assistant
All existing tests pass. Now let me verify my implementation by creating a test script to validate the behavior:
- Assistant
Let me write a proper test using vitest with the existing test infrastructure:
- Assistant
The test file needs to be inside the packages directory. Let me create it there:
- Assistant
I need to add vitest imports. Let me check how other test files import:
- Assistant
No
import { describe, it, expect }from vitest. Let me check the vitest config. It usesglobals: truemaybe? - Assistant
Let me check the vitest config:
- Assistant
Let me look at how another test file uses describe/it:
- Assistant
I need to import from vitest. Let me update the test file:
- Assistant
All 6 tests pass! Now let me clean up the test file since the instructions say not to add tests:
- Assistant
Now let me run all existing tests to make sure nothing is broken:
- Assistant
All 36 test files pass with 377 tests. Let me also check if there are any other tests across the whole repo that might be affected:
- Assistant
All 117 test files pass with 1064 tests. Let me review the final state of my changes:
- Assistant
The changes look correct and complete. Let me also verify the test file was removed:
- Assistant
Good, the test file was removed. Let me clean up any temp files and verify the final diff once more:
- Assistant
Let me verify the final state of both changed files:
- Assistant
Good, the
clearableoption is added correctly. Let me also verify theunsetAllMarks.tsfile: - Assistant
Let me run the full test suite one final time to confirm everything is working:
- Assistant
All 117 test files pass with 1064 tests. Let me now verify the final summary of changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →