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.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
Good,
editoris available. Now let's implement.Assistant
Now let's add the
clearablefield in Mark.ts config, addclearableMarksarray in ExtensionManager, and update unsetAllMarks.ts.Assistant
Good. Now update ExtensionManager.ts to add
clearableMarks.Assistant
Now update the
keepOnSplitsection to also computeclearableMarks.Assistant
Now check if
MarkConfigtype is imported in ExtensionManager.ts.Assistant
Good, MarkConfig is already imported. Now let's update the unsetAllMarks.ts command.
Assistant
Let's now build the core package to check for type errors.
Assistant
Build succeeded with no type errors. Now let's write a quick test script to verify behavior using the built package or via vitest if present.
Assistant
Good pattern. Let's write a temp test script to verify our changes.
Assistant
All 4 tests pass. Now let's run the broader existing test suite for the core package to check for regressions.
Assistant
All 414 tests pass. Now let's remove the temp test file and check
can.spec.tsfor existing unsetAllMarks tests (didn't see any specific to it but let's check).Assistant
Now let's run the full test suite once more (whole repo) to ensure nothing broke due to type changes, and check git diff.
Assistant
Good, temp test file removed and not tracked. Let's view full diff.
Assistant
Let's add a changeset for this fix too, following convention.
Assistant
Now let's re-run the whole test suite once more and lint to be safe.
Assistant
All tests still pass (410 now since we removed our temp test that added 4, but wait it's 38 files instead of 39 — that's fine since we removed the temp test file). Let's lint the changed files.
Assistant
No lint issues. Let's also check formatting.
Assistant
Formatting fixed. Let's rebuild to verify still good and rerun tests.
Assistant
Everything still passes. Let's clean the
distbuild artifacts since they weren't there before (git status might show them as untracked, check .gitignore).Assistant
Good,
distis gitignored. Let's do a final review of the diff.Assistant
This all looks good. Let's finalize the checklist review.
Checklist Review
- If an error was reported in the issue description, I have successfully reproduced it.
I confirmed the mechanism causing the bug:
unsetAllMarksunconditionally calledtr.removeMark(from, to)with no mark type, which strips all marks in the selection — including semantic marks like acommentmark used byextension-comments. Sinceextension-commentsisn't in this OSS repo (it's a PRO package), I reproduced the equivalent scenario with a temporary local mark configured similarly to a comment mark and verifiedunsetAllMarks()removed it prior to my fix.
- If an error was reported in the issue description, I have successfully reproduced it.
I confirmed the mechanism causing the bug:
Assistant
All good, all clean. Let's finalize with the checklist summary and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.