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.
Type: Command Name: unsetAllMarks Path: packages/core/src/commands/unsetAllMarks.ts Input: options?: { ignoreClearable?: boolean } Output: ReturnType Description: Removes clearable marks from the current selection. Marks configured with clearable: false are preserved unless ignoreClearable is true. can().unsetAllMarks() returns true when the selection contains only non-clearable marks; this case is a successful no-op.
- Assistant
I’ll trace the core command and mark configuration patterns, read the repository’s code/testing/versioning guidance, then implement the smallest tested change and add the required changeset.
- Assistant
The current command removes every ProseMirror mark indiscriminately. I’m checking how extension fields are resolved (including function-valued config) and the existing command-test conventions so
clearablebehaves consistently with other mark options. - Assistant
I’ll implement this as a core mark policy: all marks remain clearable by default, semantic extensions can opt out with
clearable: false, and the command’s override restores the legacy “remove everything” behavior. Tests will cover defaults, preservation, function-valued config, the override,can()no-op semantics, and directunsetMark. - Assistant
The first test run exposed a fixture issue, not command behavior: custom marks need a DOM renderer because
Editorconstructs a live view. I’m correcting the test mark definitions and the expected JSON shape, then rerunning. - Assistant
The targeted runtime tests pass. The core declaration build caught one strict generic-storage indexing error in the new extension context; I’m applying the same typed-key pattern already used by
ExtensionManager, then I’ll rerun build and checks. - Assistant
Core’s full unit suite now passes (382 tests), and there is no public
extension-commentspackage in this checkout, so the reusable core opt-out is the applicable change here. I’m moving through the repository-wide validation checklist now; any unrelated environment failure will be called out distinctly. - Assistant
Repository-wide lint, build, and all 1,069 unit tests pass. The unit runner emitted existing happy-dom iframe/network teardown warnings, but exited successfully with no failed tests. I’m running the final Chromium e2e check and then doing a clean diff review.
- Assistant
The e2e suite is blocked before execution because the required Playwright Chromium binary is not installed; all 608 cases report the same missing executable. Installing it would require an external download, which is outside this task’s no-internet constraint. I’m finishing with a source/diff sanity check and rerunning the focused tests after the last formatting pass.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →