Untitled conversation
- 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
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 trace the core mark configuration and command conventions, read the repository’s code/testing/versioning guidance, then implement the focused behavior with unit coverage and a changeset if the repo conventions require it.
- Assistant
The current command indiscriminately calls ProseMirror’s range-wide
removeMark. I’m checking how resolved extension configuration is accessed at runtime soclearablesupports both booleans and callbacks consistently with existing mark options. - Assistant
The implementation can stay localized: add the public
MarkConfig.clearableoption, resolve it through the normal extension inheritance/callback machinery, and remove only the eligible ProseMirror mark types. This naturally preserves the requiredcan()successful no-op and leaves explicitunsetMarkunchanged. - Assistant
The focused code and regression tests are in place, covering default marks, boolean and callback opt-out, the override option,
can()no-op semantics, and explicitunsetMark. I’m running the targeted unit test and type/build validation now; I’ll adjust any repository-specific typing or formatting issues they surface. - Assistant
The initial test run exposed only a test fixture issue—the custom semantic marks needed DOM renderers—and after correcting that, all six focused tests pass and formatting is clean. I’m now validating the core package build and lint, then I’ll review the final diff for unintended changes.
- Assistant
Core now builds cleanly; the first workspace-filtered command also revealed an existing pnpm/Turborepo workspace parsing warning, but the direct package build completed with declarations successfully. Targeted lint is clean. I’m running the broader unit suite to catch command interactions beyond the new regression file.
- Assistant
The broader suite passed: 118 test files and 1,070 tests. It emitted pre-existing happy-dom network/iframe cleanup noise but exited successfully. Full lint is also clean; I’ve made a final JSDoc polish so the generated API describes semantic-mark usage and the override default clearly.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.