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
Now let's add
clearableMarksarray similarly.Assistant
Now update setupExtensions to populate clearableMarks.
Assistant
Now let's add the
clearablefield to Mark.ts config nearkeepOnSplit.Assistant
Now let's update the
unsetAllMarkscommand.Assistant
Good,
editoris available in command context. Now let's rewrite unsetAllMarks.ts.Assistant
Good pattern matches. Now let's check comments extension to add
clearable: false.Assistant
Build succeeds. Now let's write a quick test script to verify behavior using existing test infra (vitest) if present.
Assistant
Good, happy-dom environment available. Let's create temp test.
Assistant
All three tests pass. Now let's clean up the temp test file and run full core test suite to make sure nothing broke.
Assistant
All 410 tests pass. Now let's check for the CHANGELOG or other places to update docs, and double check
getExtensionFieldaccepts arbitrary fields.Assistant
Good, this generically works since
clearableis now part ofMarkConfig. Now let's double checkgit diffsummary.Assistant
This looks complete. Let's run the full core test suite once more plus a broader lint check.
Assistant
Lint clean. Let's run the full unit test suite once more (broader) to be safe, and also verify build.
Assistant
All 1064 tests pass across the whole repo. Let's also confirm builds clean.
Assistant
Good, dist is gitignored, only the three intended source files show as modified. The implementation is complete.
Assistant
Now let me go through the checklist:
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. — The issue is about
unsetAllMarksdeleting comment marks (a PRO extension not present in this open-source repo). I reproduced the equivalent scenario using a temporary customMarkextension (simulating a "comment" mark) combined withBold, confirmed that with the original codeunsetAllMarksremoved both marks, and with my fix only the formatting mark (Bold) is removed while the non-clearable mark is preserved.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.