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
Let me start by exploring the repository structure to understand the codebase and find the relevant files mentioned in the issue description.
The issue is about
unsetAllMarksdeleting comments when it shouldn't. The user expects thatunsetAllMarksshould only remove formatting marks, not semantic marks like comments.The evaluation contract specifies:
- Marks are clearable by default
- A mark configured with
clearable: falsemust surviveunsetAllMarks() unsetAllMarks({ignoreClearable: true})removes non-clearable marks- Calling
can().unsetAllMarks()on a selection containing only non-clearable marks should returntrue(successful no-op)
I need to:
- Explore the repository structure
- Find the Mark.ts file in packages/core/src/
- Find the unsetAllMarks.ts command
- Understand the current implementation
- Implement the fix according to the interface specification
Assistant
Let me find the specific files mentioned in the issue - Mark.ts and unsetAllMarks.ts.
<tool_call> <function=bash_terminal> <parameter=command> find /tiptap -path "/packages/core/src/Mark.ts" -o -path "/packages/core/src/commands/unsetAllMarks.ts" 2>/dev/null </tool_call>
Assistant
Let me use bash command to find the files.
Assistant
Let me find the unsetAllMarks.ts command file.
<tool_call> <function=bash_terminal> <parameter=command> find /tiptap/packages/core -name "unsetAllMarks.ts" 2>/dev/null </tool_call>
Assistant
Let me try running the bash command directly without using tool calls.
Assistant
Let me examine the Mark.ts file first.
Assistant
Now let me look at the unsetAllMarks.ts command file to understand the current implementation.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/src/commands/unsetAllMarks.ts </tool_call>
Assistant
I need to run the bash command to view the file.
Assistant
Now let me understand the structure better. Let me look at the RawCommands type to understand how unsetAllMarks is defined and check if there's a can() implementation.
Assistant
Let me search for can() implementations in the codebase to understand how they work for marks.
Assistant
Let me look for a "can" command pattern in the codebase to understand how they define can() for unsetAllMarks.
Assistant
Let me search for "can" in a broader way to understand how can() implementations work.
Assistant
Let me explore the Editor.ts and the commands index to understand how can() is integrated with commands.
Assistant
Let me look at the unsetMark.ts command to understand how marks work and compare with unsetAllMarks.
Assistant
Let me look at the types file to understand the commands structure better, especially the can() method.
Assistant
Let me continue exploring the types file and look for the Commands interface definition and how can() is used.
Assistant
Let me continue looking at the commands types to understand how can() works.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "can()" /tiptap/packages/core/src -A 3 -B 3 | head -100 </tool_call>
Assistant
Let me run the grep command correctly to find information about can().
Assistant
Now let me explore the CommandManager to understand how can() works.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/src/CommandManager.ts | head -300 </tool_call>
Assistant
Let me run the bash command to view the CommandManager.ts file.
Assistant
Now I understand how the can() method works. It passes
dispatch: undefinedto the command, which is used to determine if the command can be executed. Let me look at how other commands implement their can() method by looking for how they check conditions.Let me also check if there are any existing tests for unsetAllMarks.
<tool_call> <function=bash_terminal> <parameter=command> find /tiptap -name ".spec.ts" -o -name ".test.ts" | xargs grep -l "unsetAllMarks" 2>/dev/null </tool_call>
Assistant
Let me search for tests related to unsetAllMarks.
Assistant
Let me look for tests related to unsetMark.
Assistant
Let me also look at the comments extension since that's what's involved in the issue.
Assistant
Let me look at the extension-comments package.
Assistant
Let me try a different approach.
<tool_call> <function=bash_terminal> <parameter=command> find /tiptap/packages -type d -name "comment" 2>/dev/null </tool_call>
Assistant
I need to run a bash command to find the comment extension directory.
Assistant
Let me look at the packages folder to see what's there.
Assistant
I see there's no "extension-comments" directory. Let me check if there's a comments extension somewhere in the repository.
<tool_call> <function=bash_terminal> <parameter=command> find /tiptap/packages -name "*.ts" -path "comment" 2>/dev/null | head -20 </tool_call>
Assistant
Let me run the bash command to search for comment-related files.
Assistant
It seems like there's no comment extension in the packages folder. The issue mentions that the bug is in the
extension-commentspackage, but it seems like it might be a separate package that's not included in this repository, or it's a hypothetical scenario where we need to implement a mechanism to prevent unsetAllMarks from removing comments.Let me focus on the core issue: implementing the
clearableoption for Mark configurations and modifyingunsetAllMarksto respect this option.Based on the evaluation contract:
- Marks are clearable by default (clearable: true)
- A mark configured with
clearable: falsemust surviveunsetAllMarks() unsetAllMarks({ignoreClearable: true})removes non-clearable markscan().unsetAllMarks()returns true when the selection contains only non-clearable marks (successful no-op)
Now let me look at how to implement this:
- Add
clearableoption to Mark.ts - Modify unsetAllMarks.ts to respect the
clearableoption - Make sure the can() check works correctly
Assistant
Let me run the bash command properly.
Assistant
Now I need to understand how marks are retrieved and checked. Let me look at how ProseMirror's
removeMarkmethod works and how we can check the mark type.I need to:
- Get all marks in the selection
- Check if each mark is clearable (using the mark type's config)
- Only remove clearable marks
- Support the
ignoreClearableoption - Implement the
can()check
Let me first look at how marks are accessed in ProseMirror state.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "marks()" /tiptap/packages/core/src --include="*.ts" | head -20 </tool_call>
Assistant
Let me run the grep command properly to understand how marks are accessed.
Assistant
Now I need to understand how to get the mark configuration from a mark type. Let me check how extensions are accessed.
Assistant
Let me look at the setMark.ts file to see how marks are handled there.
Assistant
I need to see how the CommandProps include access to the editor and its extensions. Let me look at the CommandProps type.
Assistant
I need to find how to access the mark configuration from a command. Let me search for how extensions are accessed from commands.
Assistant
Now I see how to access extensions from commands. Let me look at the ExtensionManager to see what properties it exposes.
Assistant
Let me look at the ExtensionManager to understand how to get mark configuration.
Assistant
Let me continue looking at the ExtensionManager to understand how to access mark options.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/src/ExtensionManager.ts | head -300 | tail -150 </tool_call>
Assistant
Let me run the bash command to view more of the ExtensionManager file.
Assistant
Now I understand how the ExtensionManager works. The
extensionsarray contains all extensions with their options. I can access the mark configuration by looking up the mark type by name in the extensions array.Let me now look at how I can access the extensions from a command and understand what's available on an extension.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "extensions" /tiptap/packages/core/src/commands/toggleList.ts -B 5 -A 10 </tool_call>
Assistant
Let me run the grep command properly.
Assistant
Now I understand the pattern. I can access
editor.extensionManager.extensionsto get all extensions. I need to:- First, add the
clearableoption to MarkConfig in Mark.ts - Modify the unsetAllMarks command to:
- Get the mark types in the selection
- Check if each mark is clearable
- Only remove clearable marks (unless ignoreClearable is true)
- Implement the can() check
Let me start implementing. First, let me update the Mark.ts file to add the clearable option.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/src/Mark.ts </tool_call>
- First, add the
Assistant
Let me run the bash command properly to view the Mark.ts file.
Assistant
Now I need to add the
clearableoption to theMarkConfiginterface. Let me use the edit command to add this option.Assistant
Let me add the
clearableoption to the MarkConfig interface. I'll add it after theaddAttributesoption, before the closing brace of the interface.<tool_call> <function=bash_terminal> <parameter=command> sed -n '136,145p' /tiptap/packages/core/src/Mark.ts </tool_call>
Assistant
Let me run the bash command properly.
Assistant
Now I need to add the
clearableoption to the MarkConfig interface. I'll use the edit command to add it before line 144 (before the closing brace of the interface).<tool_call> <function=bash_terminal> <parameter=command> sed -n '140,146p' /tiptap/packages/core/src/Mark.ts </tool_call>
Assistant
Let me run the bash command properly to view the lines I need to edit.
Assistant
Now I need to add the
clearableoption before line 145 (before the closing brace). Let me use the bash command to insert the new option.<tool_call> <function=bash_terminal> <parameter=command> cat > /tmp/mark_patch.txt << 'EOF' parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'] editor?: Editor // oxlint-disable-next-lineno-empty-object-type }) => Attributes | {}
/**
- Clearable */ clearable?: boolean | (() => boolean) } EOF cat /tmp/mark_patch.txt
Assistant
Let me think about this more carefully. I need to edit the Mark.ts file to add the
clearableoption. The best way to do this is to use sed or create a new file with the modification.Let me use sed to insert the clearable option before the closing brace of the interface (line 145).
Assistant
Let me verify that the change was applied correctly.
Assistant
I need to fix the Mark.ts file structure. The closing brace should come after the
clearableoption.Assistant
Let me view the current state and fix it properly.
Assistant
I need to add the closing brace
}after theclearableoption. Let me fix this.<tool_call> <function=bash_terminal> <parameter=command> sed -i '147a}' /tiptap/packages/core/src/Mark.ts </tool_call>
Assistant
I need to add the closing brace for the interface. Let me try again with the proper command.
Assistant
The command executed. Let me verify the change.
Assistant
Now I need to modify the unsetAllMarks.ts command to respect the
clearableoption. Let me first view the current file again.Assistant
Now I need to modify the unsetAllMarks.ts command to respect the
clearableoption. Let me rewrite this file to:- Add support for the
ignoreClearableoption - Get marks in the selection and check if they are clearable
- Only remove clearable marks (unless ignoreClearable is true)
- Implement the can() check - return true when only non-clearable marks are present (successful no-op)
- Add support for the
Assistant
Now I need to understand how to properly access the mark configuration. Let me check how the schema stores mark extensions and how to access their config.
Assistant
I see that the ProseMirror schema stores marks but doesn't directly expose the config. Let me think about how to properly access the extension configuration. The schema marks are ProseMirror marks, not Tiptap extensions. I need to access the extension manager to get the mark options.
Let me check how other commands access the extensions.
Assistant
Let me look at how to access extensions from the command props.
Assistant
Now I need to update the unsetAllMarks command to use the editor to access extensions. Let me rewrite it:
Assistant
Now I need to check how the
can()method works for unsetAllMarks. According to the evaluation contract:can().unsetAllMarks()should returntruewhen the selection contains only non-clearable marks (successful no-op)
The
can()method passesdispatch: undefinedto commands. The command should return a boolean indicating whether the command can be executed. Let me check how other commands implement thecan()check.Assistant
Let me escape the bang properly.
Assistant
Let me look at how the can() method is typically used. When
dispatchisundefined, the command should return a boolean indicating whether the command can be executed. Let me check how other commands handle this.<tool_call> <function=bash_terminal> <parameter=command> grep -r "dispatch:" /tiptap/packages/core/src/commands/*.ts | head -20 </tool_call>
Assistant
Let me run the grep command properly to see how dispatch is handled in commands.
Assistant
Let me look at how commands return false when they can't be executed in the can() mode.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "canSetMark" /tiptap/packages/core/src/commands/setMark.ts -A 2 </tool_call>
Assistant
Let me run the grep command to see how setMark returns false for the can() check.
Assistant
Assistant
The command was executed. Let me verify that the unsetAllMarks.ts file was updated correctly.
Assistant
Now let me check if the Mark.ts file is correctly updated with the
clearableoption.<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/src/Mark.ts | head -160 </tool_call>
Assistant
Let me run the bash command properly to check the Mark.ts file.
Assistant
The Mark.ts file has the
clearableoption added. However, I notice that the formatting is not ideal - there should be a blank line before the/**comment. But this is just a cosmetic issue, the code should work.Now let me check if there are existing tests I can run to verify that my changes don't break anything.
<tool_call> <function=bash_terminal> <parameter=command> find /tiptap/packages/core -name "*.spec.ts" | head -10 </tool_call>
Assistant
I need to run the bash command to find test files in the core package.
Assistant
Let me look at the delete.spec.ts file to see if there are tests for unsetMark that I can use as a reference.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/tests/delete.spec.ts | head -100 </tool_call>
Assistant
Let me run the bash command to view the delete.spec.ts file.
Assistant
Let me check if there's a way to run the tests and also understand how to properly test my changes. Let me first check if there's a package.json with test commands.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/package.json | head -50 </tool_call>
Assistant
Let me run the bash command to view the package.json.
Assistant
Now let me try to run the unit tests to see if my changes break anything. But first, let me check if the code compiles by checking for TypeScript errors.
<tool_call> <function=bash_terminal> <parameter=command> cd /tiptap && pnpm run test:unit 2>&1 | head -100 </tool_call>
Assistant
I need to run the test command properly. Let me execute the test to see if my changes work.
Assistant
The command is timing out. Let me try running a simpler test to verify the code works. First, let me create a simple test script to verify my changes.
<tool_call> <function=bash_terminal> <parameter=command> cat > /tmp/test_unsetAllMarks.ts << 'EOF' // Simple test to verify unsetAllMarks handles clearable option
// This is a mock test to verify the logic const markExtensions = [ { name: 'bold', type: 'mark', options: { clearable: true } }, { name: 'italic', type: 'mark', options: { clearable: true } }, { name: 'comment', type: 'mark', options: { clearable: false } }, { name: 'strike', type: 'mark', options: {} }, // should default to true ]
Assistant
Let me try to run a simple JavaScript test to verify the logic works.
Assistant
The logic works correctly. Now let me think about edge cases:
- Empty selection: Already handled - returns true
- Only non-clearable marks (ignoreClearable=false): Should return true (no-op)
- Only non-clearable marks (ignoreClearable=true): Should remove them and return true
- Mixed marks: Should only remove clearable ones
- No clearable option set: Should default to true (clearable by default)
- clearable as a function: Should call the function and use the result
Now let me think about potential issues:
- The
editor.extensionManager.extensionsfiltering withext.isToplevelmight not be correct. Let me check how extensions are accessed elsewhere. - The
can()check needs to returntruewhen only non-clearable marks are present (successful no-op).
Let me check how extensions are filtered in other commands.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "extensions.filter" /tiptap/packages/core/src/commands/*.ts | head -10 </tool_call>
Assistant
Let me run the grep command to check how extensions are filtered.
Assistant
Let me check how extensions are accessed in other commands to ensure I'm using the correct pattern.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "editor.extensionManager" /tiptap/packages/core/src/commands/*.ts | head -10 </tool_call>
Assistant
Let me try the grep command to check how extensions are accessed in other commands.
Assistant
Let me look at how toggleList.ts accesses the extensions to ensure I'm using the correct pattern.
Assistant
The
toggleListcommand usesconst { extensions, splittableMarks } = editor.extensionManager. Let me look at how it uses the extensions.<tool_call> <function=bash_terminal> <parameter=command> grep -r "extensions" /tiptap/packages/core/src/commands/toggleList.ts | head -10 </tool_call>
Assistant
Let me run the grep command to see how extensions are used in toggleList.ts.
Assistant
It seems the pattern is correct. Now let me check if the
isToplevelproperty exists on extensions or if I need to use a different approach.<tool_call> <function=bash_terminal> <parameter=command> grep -r "isToplevel" /tiptap/packages/core/src --include="*.ts" | head -10 </tool_call>
Assistant
Let me check if the
isToplevelproperty exists on extensions.<tool_call> <function=bash_terminal> <parameter=command> grep -r "isToplevel" /tiptap/packages/core/src --include="*.ts" | head -10 </tool_call>
Assistant
It looks like
isTopleveldoesn't exist on extensions. Let me check what properties are available on extensions by looking at the Extendable class.Assistant
Let me check how to correctly filter marks from the extensions list. I need to look at the extension properties more carefully.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/core/src/Extendable.ts | head -80 </tool_call>
Assistant
Let me run the bash command to view the Extendable.ts file to understand the extension structure.
Assistant
I see that
isToplevelis not a standard property on extensions. Let me check the Extendable class to see how it defines its properties.Assistant
Let me check the Mark class to see what type is set:
Assistant
The Mark class has
type = 'mark'. Now let me check if the extensions ineditor.extensionManager.extensionsinclude theoptionsproperty and if they have atypeproperty that can be used to filter for marks.Let me update the unsetAllMarks command to properly filter the extensions. Instead of using
isToplevel, I should just filter bytype === 'mark'.Assistant
Now let me think about the edge case where
can().unsetAllMarks()is called. According to the evaluation contract:can().unsetAllMarks()should returntruewhen the selection contains only non-clearable marks (successful no-op)
Currently, my implementation always returns
true, which should work for the can() case as well. However, I need to verify that the implementation correctly handles all the scenarios.Let me also check if there are any type errors by looking at the existing tests or trying to build the project.
First, let me verify the unsetAllMarks.ts file was correctly updated:
Assistant
The file looks correct. Now let me think about potential issues:
-
The
editorparameter in the command might not always be available. Let me check how other commands access it. -
The logic for collecting marks might not be correct. I need to ensure I'm collecting all unique marks in the selection properly.
Let me verify how commands receive the
editorparameter by looking at another command.-
Assistant
The
editorparameter is available in commands. My implementation should work correctly.Now, let me think about a potential issue: I'm using
$from.marks()to get all marks at a position, but this only gives me the marks at the start of each range. I might need to collect marks from the entire range to be accurate. However, for the purpose ofunsetAllMarks, thetr.removeMark(from, to, markType)call will remove the mark from the entire range, so I just need to identify which mark types are present in the selection.Actually, I realize there's an issue with my implementation. I'm iterating over the ranges and collecting marks at
$from, but if there are multiple marks at the same position, I might miss some. Let me think about this more carefully.Looking at ProseMirror's
removeMarkfunction, it removes the mark from all text in the given range. So my approach of getting marks at$fromand removing them from the entire range should work.However, there's another issue: I need to handle the case where multiple ranges might overlap or have different marks. Let me also make sure I'm not removing the same mark multiple times.
Let me refine my implementation:
Assistant
Now let me verify the file was updated correctly:
Assistant
The implementation looks correct. Now let me also verify that the Mark.ts file is correctly updated:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '140,160p' /tiptap/packages/core/src/Mark.ts </tool_call>
Assistant
Let me run the bash command properly to check the Mark.ts file.
Assistant
The
clearableoption is present in the MarkConfig interface. However, there's a formatting issue - the blank line before the comment is missing. Let me fix this.<tool_call> <function=bash_terminal> <parameter=command> sed -i '144s/^ /**/\n /**/' /tiptap/packages/core/src/Mark.ts </tool_call>
Assistant
The sed command didn't work as expected. Let me try a different approach to add the blank line.
Assistant
I see the formatting issue. Let me fix it by adding a blank line before the
/**comment for theclearableoption.<tool_call> <function=bash_terminal> <parameter=command> sed -i '143s/^ }) => Attributes | {}/ }) => Attributes | {}\n/' /tiptap/packages/core/src/Mark.ts </tool_call>
Assistant
Let me try a different approach to fix the formatting. I'll view the file and manually edit it to add the blank line.
Assistant
The formatting issue is minor but let me fix it properly using sed. I need to insert a blank line before the
/**comment forclearable.Assistant
Let me verify the change was applied:
Assistant
The formatting is now correct. Now let me verify that my implementation is complete by checking if there are any tests I can run.
Let me check if there are tests for unsetAllMarks or if I should create a simple test to verify the implementation:
Assistant
There are no existing tests for
unsetAllMarks. Let me verify that the implementation is correct by reviewing the changes I made:- Added
clearable?: boolean | (() => boolean)option toMarkConfiginterface inMark.ts - Modified
unsetAllMarkscommand to:- Accept an optional
ignoreClearableparameter - Check each mark's
clearableoption - Only remove clearable marks (unless
ignoreClearableis true) - Default
clearabletotrueif not specified
- Accept an optional
Let me now also verify that the code compiles by checking if there are any obvious TypeScript errors. Let me look at how other commands access
editor.extensionManager.extensions:- Added
Assistant
Good, I see that
editor.extensionManager.extensionsis the correct way to access the extensions. My implementation should work correctly.Now let me create a simple test script to verify the implementation works as expected:
Assistant
Let me fix the test script:
Assistant
The logic is working correctly. Now let me review the changes I've made to ensure they fully address the issue:
- Added
clearableoption toMarkConfiginterface inMark.ts(default:true) - Modified
unsetAllMarkscommand to:- Accept an optional
ignoreClearableparameter (default:false) - Check each mark's
clearableoption - Only remove clearable marks (unless
ignoreClearableis true) - Default
clearabletotrueif not specified
- Accept an optional
Let me now verify that the implementation handles all the edge cases mentioned in the evaluation contract:
- ✓ Marks are clearable by default
- ✓ A mark configured with
clearable: falsemust surviveunsetAllMarks() - ✓
unsetAllMarks({ignoreClearable: true})removes non-clearable marks - ✓
can().unsetAllMarks()returnstruewhen the selection contains only non-clearable marks (successful no-op) - because we always return
- Added
Assistant
Let me run the bash command to list the test files in the core package.
Assistant
Let me look at the can.spec.ts file to see how the can() checks are tested:
Assistant
Now I have a better understanding of how the can() checks work. The command returns a boolean, and when
dispatchisundefined, the boolean is returned as-is for the can() check.My implementation always returns
true, which should work correctly for both execution and can() checks. However, I should verify that this is the expected behavior according to the evaluation contract.According to the evaluation contract:
can().unsetAllMarks()returnstruewhen the selection contains only non-clearable marks (successful no-op)
This means my implementation is correct - it always returns
truebecause:- If there are clearable marks, the command succeeds (returns
true) - If only non-clearable marks are present, it's a no-op (returns
true) - If
ignoreClearableis true, all marks are removed (returnstrue)
Let me now verify that the implementation is complete by checking the diff of the changes I made:
<tool_call> <function=bash_terminal> <parameter=command> cd /tiptap && git diff --no-color </tool_call>
Assistant
Let me run the git diff command to see the changes I made.
Assistant
The changes look good. I've made the following modifications:
-
Mark.ts: Added the
clearableoption to theMarkConfiginterface with proper documentation. -
unsetAllMarks.ts:
- Added the
ignoreClearableoption parameter - Modified the command to check the
clearableoption of each mark - Only remove clearable marks by default
- Use
ignoreClearableto force removal of all marks including non-clearable ones - Default
clearabletotrueif not specified
- Added the
Now let me verify that the implementation is correct and run some tests if possible. Let me check if there's a way to run the tests without waiting too long.
<tool_call> <function=bash_terminal> <parameter=command> cd /tiptap && timeout 60 pnpm run test:unit -- --run packages/core/tests/can.spec.ts 2>&1 | tail -50 </tool_call>
-
Assistant
Let me try to run the test for the can.spec.ts file to see if my changes break any existing tests. I'll use a timeout to prevent the test from running too long.
Assistant
The test command is timing out. Let me try a different approach - I'll check if the TypeScript compiles correctly by running the type checker.
<tool_call> <function=bash_terminal> <parameter=command> cd /tiptap/packages/core && timeout 30 npx tsc --noEmit 2>&1 | head -50 </tool_call>
Assistant
The command timed out. Let me try a simpler approach to verify the code compiles correctly.
Assistant
The TypeScript errors are not related to my changes - they're in the demo files and node_modules, not in the core package files I modified. Let me check if there are any TypeScript errors specifically in the files I modified.
<tool_call> <function=bash_terminal> <parameter=command> cd /tiptap && timeout 30 npx tsc --noEmit packages/core/src/Mark.ts packages/core/src/commands/unsetAllMarks.ts 2>&1 </tool_call>
Assistant
Let me try a different approach to verify the TypeScript compilation for my changes.
Assistant
The TypeScript errors shown are not specific to my changes - they are configuration errors in the TypeScript project that pre-exist. The key errors in my file (
unsetAllMarks.ts) are:- Invalid module name in augmentation
- Property 'unsetAllMarks' does not exist on type 'RawCommands'
- Property 'ignoreClearable' does not exist on type '{}'
- Cannot find name 'Map', 'Set'
These errors are all related to the TypeScript configuration, not my code. The project seems to have a tsconfig that targets an older ECMAScript version, causing errors with modern JavaScript features like
Map,Set,Object.fromEntries, etc.Let me verify that my code is syntactically correct by checking if there are any actual logic errors in my implementation. The errors related to my code:
Assistant
I need to check the git status to see what files I've modified.
Assistant
Let me verify the final state of the changes I made:
Assistant
I've made the required changes to implement the
clearableoption for marks. Let me summarize what I've done:-
Mark.ts: Added the
clearableoption to theMarkConfiginterface with:- Type:
boolean | (() => boolean) - Default:
true(if not specified) - Description: Controls whether unsetAllMarks removes this mark
- Type:
-
unsetAllMarks.ts: Modified the command to:
- Accept an optional
ignoreClearableparameter (default:false) - Get all mark extensions and build a map of their
clearableoption - Check each mark's
clearableoption before removing it - Only remove clearable marks by default (unless
ignoreClearableistrue) - Default
clearabletotrueif not specified - Always return
true(for both execution and can() checks, as per the evaluation contract)
- Accept an optional
-
Assistant
I need to run the submit command to submit my changes. Let me use the bash_terminal tool to execute the submit command.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.