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.
Assistant
Let me start by understanding the repository structure and the issue. The issue is about
unsetAllMarksdeleting comments when it shouldn't. We need to add aclearableoption to marks that controls whetherunsetAllMarksremoves them. Let me explore the repository structure first.The key files mentioned:
packages/core/src/Mark.ts- where we need to add theclearableconfig optionpackages/core/src/commands/unsetAllMarks.ts- where we need to modify the command
Let me start by exploring the repo.
Assistant
Let me look at the key files: Mark.ts and the commands directory.
Assistant
Let me do one command at a time.
Assistant
Now let me look at the unsetAllMarks command:
Assistant
Let me look at the types file for better understanding and also find where comments extension is:
Assistant
No results. Let me search for comment-related extensions.
Assistant
Let me look at the overall package structure.
Assistant
Let me look at more of the core files to understand the full picture.
Assistant
Let me look at the index.ts to understand the exports and command structure.
Assistant
Let me look at the commands index and the Extension base class.
Assistant
Let me also look at
unsetMarkand theExtendableclass to understand the full pattern.Assistant
Let me do one thing at a time.
Assistant
Now let me look at the Extendable class.
Assistant
Now let me understand how mark configurations are accessed. Let me look at
getMarkTypeand related helpers.Assistant
Let me look at how extensions are accessed and the
getMarksBetweenhelperAssistant
Let me look at the Editor to understand how extensions are stored.
Assistant
Let me look at ExtensionManager.
Assistant
Let me check the ExtensionManager for relevant bits.
Assistant
Let me look at the command.ts file to understand what context is available in commands.
Assistant
Let me check the Command type in types.ts.
Assistant
Let me see the full CommandProps.
Assistant
Now I have a good understanding. Let me look at how
exitableandkeepOnSplitare used elsewhere as they are similar boolean config options on marksAssistant
Let me look at
getExtensionField:Assistant
Let me also check how
keepOnSplitis used in the codebase for the pattern:Assistant
Let me look at how
toggleMarkorsetMarkcommands work for reference on how to access marksAssistant
Let me check for any commands that access extension manager:
Assistant
Let me look at
splitBlock.tsto see how it accesses extension config:Assistant
Let me check for existing tests for
unsetAllMarks:Assistant
Let me check the
callOrReturnutility:Assistant
Now I have a complete understanding. Let me implement the changes.
Step 1: Add
clearabletoMarkConfiginMark.tsAssistant
Let me use the edit command to add the
clearableproperty toMarkConfigAssistant
Let me view the full file to see the current state:
Assistant
I see the problem - the edit split the interface. Let me revert and redo this
Assistant
Good, let me view the file again and do the edit properly
Assistant
Now I need to insert the
clearableproperty after line 112 (afterparseHTML) and before line 114 (renderHTML). Let me replace the empty line 113 with the new property:Assistant
Let me check the full file to see if there are formatting issues:
Assistant
I need to add a blank line between the
clearableproperty (line 119) and therenderHTMLcomment. Let me fix that:Assistant
There's a duplicate comment. Let me fix this by removing lines 124-126:
Assistant
Good. Now let me modify
unsetAllMarks.tsto respect theclearableoption:Assistant
Now let me rewrite `unsetAllMarks.ts
Assistant
Now let me verify the changes compile properly by checking the TypeScript:
Assistant
Let me find the proper tsconfig path
Assistant
Let me check the build system and try to verify differently
Assistant
Let me try building to verify:
Assistant
Those are all pre-existing errors in demos. Let me try building just the core package
Assistant
Let me check just the core package by filtering for errors from packages/core:
Assistant
There's a TypeScript error. Let me fix the typing issue in our new code:
Assistant
Let me fix the type error:
Assistant
Let me recheck TypeScript for our files:
Assistant
No errors from our files. Let me verify this properly:
Assistant
Good - no TypeScript errors in our files. Now let me check if there are any existing tests for
unsetAllMarks:Assistant
No tests for unsetAllMarks. Let me check for any tests related to marks or the extension system:
Assistant
Let me verify both files are properly formatted:
Assistant
Let me check if there are any other places that might need to be updated:
Assistant
The changes look good. Let me now run the existing tests to make sure nothing is broken:
Assistant
Let me check for test scripts and run what we can:
Assistant
Let me check the package.json for the core package:
Assistant
Let me check what test runner is used:
Assistant
Let me run the core tests:
Assistant
All 33 existing tests pass. Let me also check other packages that might have tests related to our changes:
Assistant
All 1064 tests pass across 117 test files. Our changes don't break anything. Let me do a final review of both files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.