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, the current
unsetAllMarksimplementation, command typing, and nearby tests to determine the minimal API-compatible change. Then I’ll reproduce the behavior with the repository’s test conventions, implement the option and command semantics, and run the affected test suites and type checks. - Assistant
The current command indiscriminately calls ProseMirror’s range-wide
removeMark, so it reproduces the reported deletion by construction. The new behavior needs to resolve each mark extension’sclearablefield (including function-valued and inherited configuration), then remove only eligible mark types. I’ll locate the standard extension-field resolver and command tests so the implementation follows existing context and inheritance semantics. - Assistant
There are no command-specific files matching that initial pattern, so I’ll inspect the test layout and the command execution context. In particular, I need to confirm that
editor.extensionManager.extensionsis available inRawCommands, and whether mark functions are normally invoked throughcallOrReturnwith a bound extension context. - Assistant
The command context does include
editor, and the standard resolver defaults similar booleans with?? true. I’ll implementclearableas a documented mark config field, updateunsetAllMarksto accept{ ignoreClearable?: boolean }, resolve function/inheritance behavior with the full extension context, and remove each clearable mark type explicitly. Returningtruebefore dispatch checks remains important: it makescan().unsetAllMarks()a successful no-op when every selected mark is protected, whileunsetMarkremains intentionally unchanged. - Assistant
Python is unavailable in this environment, so no files were changed. I’ll apply the same source-only edits using Node, then run the formatter/checker to catch import ordering or style issues.
- Assistant
The API and command are now implemented. Before testing, I’ll check whether this checkout includes the comments extension source and whether it already declares a mark config that should be set to
clearable: false; the issue contract may expect core capability only, but the affected package should opt in if present. I’ll also inspect package-local scripts to choose focused type/build tests. - Assistant
No comments package source is present, so the required fix is the core opt-out API that Pro’s comments mark can configure. I’ll now run formatting/lint checks on the changed files and build
@tiptap/core; this validates declaration merging, generic resolver context, and emitted command types. - Assistant
The validation did not run because Corepack attempted an interactive pnpm download, which this environment cannot answer. I’ll disable Corepack’s prompt and rerun; if network/package-manager bootstrapping remains unavailable, I’ll use the already installed local binaries directly.
- Assistant
Pnpm is now available and dependencies are installed. I’ll run focused formatting and linting first, then the package build separately to avoid combining multiple potentially long operations under one command timeout.
- Assistant
Formatting and linting pass. Next I’ll build core to ensure TypeScript accepts the newly added option and the mark-type filtering logic.
- Assistant
The core build passes, including declaration generation. I’ll now behaviorally verify all contract cases with a temporary script outside the repository: create two custom marks (default clearable and
clearable: false), select text carrying both, check normal clearing preserves only the protected mark, checkignoreClearableremoves both, checkcan()returns true with only a protected mark, and confirm explicitunsetMarkstill removes it. I’ll use the project’s existing DOM test setup patterns. - Assistant
The tests use Happy DOM globally. Rather than adding a test file (explicitly prohibited), I’ll run a
/tmpESM script against the freshly built core and use JSON content, which avoids HTML parsing. The temporary script will assert document JSON after each command and throw on any contract violation. - Assistant
The first behavioral attempt reached only DOM setup: Node 24 exposes a read-only global
navigator, so Happy DOM could not overwrite it. No editor code ran. I’ll adjust the temporary harness to leave Node’s navigator intact and provide the remaining DOM constructors individually, then rerun the same assertions. - Assistant
The prior shell command removed the temporary script even after its setup failure (because cleanup was separated by a semicolon), so I’ll recreate it with corrected globals and execute it. This remains entirely outside the repository.
- Assistant
The built bundle cannot run standalone because workspace
@tiptap/pmartifacts are not built, although core itself compiled successfully. I’ll instead use a temporary verification spec that Vitest transpiles directly through the repository aliases, run only that file, and remove it immediately afterward. This is a transient reproduction script, not a repository test change. - Assistant
Vitest reached editor rendering, but the temporary custom marks lacked
renderHTML, so ProseMirror could not render their DOM wrappers; this is a harness definition issue rather than command behavior. I’ll rerun with ordinary<span>renderers on both marks. - Assistant
All evaluation-contract behaviors now pass in the transient verification, and the script was removed. I’ll run the complete existing core test suite to check for regressions in command behavior, chaining, selection ranges, and extension handling.
- Assistant
The full core suite passes: 38 files and 410 tests. I’ll perform a final diff/status review to ensure the temporary verification file and build outputs are absent from the submitted changes, inspect the generated API declaration for the intended signature, and confirm only the two source files are modified.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.