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.jseditor.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 mark configuration type, the
unsetAllMarkscommand, and existing command tests. I’ll implement the newclearablebehavior with the specifiedignoreClearableoption, ensurecan()treats a preserved-only selection as a successful no-op, then run focused and broader relevant tests. - Assistant
The current command blindly removes every mark via
tr.removeMark, and the type has no filtering metadata. The repository lacksrg, so I’ll usegrepto locate how extension config values are exposed on ProseMirror mark types and how command tests are structured before editing. - Assistant
Mark types retain their generated
spec, so the cleanest integration is to resolveMarkConfig.clearablewhile building each schema mark and store it on that spec. The command can then collect mark types present in each selected range and remove only those whose spec is clearable (defaulting to true for compatibility). It must not gate success on whether a transaction changes, preserving the existingtruebehavior forcan(). - Assistant
The first edit attempt was blocked because this environment has no
python3; no files were changed. I’ll apply the same targeted edits with a Node script, then typecheck the core package. - Assistant
The implementation is in place. The build command hit Corepack’s first-run download prompt and timed out before compiling, rather than reporting a code failure. I’ll rerun with the prompt disabled and, if needed, use the repository’s local TypeScript tooling for verification.
- Assistant
Core build and the existing
cantests pass. Formatting found only the new command’s line wrapping, so I’ll apply the repository formatter to the three modified source files, recheck formatting, and inspect the final diff before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.