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 inspect the core mark configuration and current
unsetAllMarksimplementation, then locate relevant command tests and the comments mark configuration. - Assistant
The command currently calls ProseMirror’s unfiltered
removeMark, so every mark is removed. I’ll find how extension configuration fields are resolved (including callbacks and inheritance), identify the comment mark, and inspect the test setup conventions before changing the API. - Assistant
The public repository does not contain the PRO comments package, so the core capability must be generic and the comments extension can opt into it externally. I’ll inspect command context types and similar commands that map schema mark types back to mark extensions, ensuring callback configuration is evaluated with the standard extension context.
- Assistant
I need the exact command context and extension object shape. Then I’ll implement filtering by calling
removeMark(from, to, markType)only for clearable mark extensions; this naturally makes the protected-onlycan()path returntruewithout dispatching changes, whileignoreClearableretains the old unfiltered behavior. - Assistant
The existing configuration resolver binds callback fields correctly, and command props provide the editor/extension manager. I’ll add the documented
clearablemark option and update the command signature and implementation. The default will be expressed as?? true, so existing marks remain clearable; protected marks are removed only withignoreClearable: true. - Assistant
The edit completed, but formatting triggered Corepack’s first-run download prompt and timed out because interactive prompts are unsupported. I’ll verify the files and rerun tooling with the prompt disabled, then run the core type/build checks.
- Assistant
The timed-out shell never reached the edits (the displayed files are unchanged). I’ll apply them again without invoking package tooling in the same command. To avoid importing the
Storageaugmentation through the package barrel, I’ll use the extension’s own storage object, which is the same object used to initializeeditor.extensionStorage. - Assistant
Python is not installed in this environment, so I’ll use the repository’s non-interactive
editutility to make the two source changes directly. - Assistant
Review caught a duplicated
exitabledeclaration caused by replacing only the original comment lines rather than the declaration itself. I’ll remove that duplicate, then build@tiptap/coreto catch command typing or declaration-generation errors. - Assistant
The core package builds successfully, including generated declarations. I’ll now run a temporary behavioral regression spec (removed immediately afterward) covering all evaluation-contract paths: default preservation, override removal, protected-only
can()success, callback-valued configuration, and explicitunsetMarkremoval. - Assistant
The first temporary regression run failed before reaching the command because the minimal custom nodes lacked DOM renderers; this is a test harness setup issue, not a source failure, and the temporary file was removed. I’ll rerun with valid node/mark renderers so the actual behavior is exercised.
- Assistant
The corrected regression passes all contract scenarios, including callback context and explicit removal. I’ll run the complete core unit-test suite plus targeted lint/format checks, then inspect the final diff for unintended generated or temporary files.
- Assistant
All 410 core tests pass, and targeted lint/format checks are clean. I’ll inspect the exact final patch and repository status, paying special attention to API docs, accidental build artifacts, and the no-test-modification requirement.
- Assistant
The final diff contains only the two intended source files and no temporary tests or generated artifacts. One minor documentation-spacing cleanup remains between adjacent config fields; I’ll apply it and recheck the patch 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.