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
I'll explore the repository structure and the current
unsetAllMarks/ Mark implementation to add aclearableoption. - Assistant
Reading the core Mark and unsetAllMarks implementations next.
- Assistant
Inspecting how mark config options are resolved and whether comments or similar tests already exist.
- Assistant
Inspecting mark schema setup and how other commands access mark configuration.
- Assistant
Let me look at how commands get access to editor/extensions, and how can() works. Also look at similar PRs or CHANGELOG for any mention of clearable.
- Assistant
Let me look at CommandProps and how editor is available. Also look at getExtensionField and how we can determine if a mark is clearable.
- Assistant
Checking how configs inherit and whether comments or similar marks define options elsewhere.
- Assistant
Checking docs and CHANGELOG references, and inspecting how ExtensionManager initializes mark-related lists.
- Assistant
I notice the packages have dist folders potentially with built files. When tests run they might use src or dist. Let me check how tests import things and if I need to build. I understand the issue you're facing with
unsetAllMarksdeleting comments. The evaluation contract provides a clear path forward by treatingclearable: falseas a way to preserve semantic marks like comments during formatting clear operations.Let me start by checking the current state of the codebase to see what's already implemented and what needs to be updated.
First, let me check the Mark configuration to see if
clearableis already present:grep -r "clearable" packages/core/src/Let me also check the Mark.ts file to see the current MarkConfig:
cat packages/core/src/Mark .tsLet me check the unsetAllMarks implementation:
cat packages/core/src/commands/unsetAllMarks.tsLet me also check the ExtensionManager to see how fields are handled:
cat packages/core/src/ExtensionManager. - Assistant
Checking the test and build setup so we know where changes need to land.
- Assistant
Implementing the
clearableoption on Mark and updatingunsetAllMarks. - Assistant
I'll add clearable after keepOnSplit or after exitable.
- Assistant
I'll add a blank line between
clearableandInclusivefor style consistency. - Assistant
Restoring the Inclusive comment that was accidentally removed.
- Assistant
Still broken - missing closing
*/. Let me fix properly. - Assistant
Updating
unsetAllMarks.tsnext. - Assistant
I'll look at existing command tests so I can mirror their editor setup.
- Assistant
There's can.spec.ts and extendMarkRange.spec.ts - let me look at those for patterns.
- Assistant
I'll create a temporary verification script (not a repo test) to validate the behavior.
- Assistant
I'll put the temporary test under packages so vitest's include pattern picks it up.
- Assistant
All temp tests passed. Cleaning up and scanning for a comments extension that should set
clearable: false. - Assistant
Running the existing core tests to ensure nothing regressed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.