Lock content from being proofread
Because your document might have important information, you might not want to generate suggestions about all its content. You might want to mark certain content as “locked”, and prevent the suggestion from generating suggestions that modify it.
We are working on an extension that implements this feature with minimal hassle. If you are interested in this upcoming feature and think you would use it in your application, contact us at humans@tiptap.dev.
You can also prevent certain content from being proofread by filtering the suggestions generated by the resolver. Implement your custom filter function that removes the suggestions that are applied to certain positions of the document, or that contain a specific type of content.
AiSuggestion.configure({
async resolver({ defaultResolver, ...options }) {
// Load suggestions
const suggestions = await defaultResolver(options)
// Remove suggestions that modify the locked content
const filteredSuggestions = filterSuggestions(suggestions)
return filteredSuggestions
},
})
// Filter function that removes the suggestions that modify the content in positions between 10 and 20.
function filterSuggestions(suggestions) {
return suggestions.filter(
(suggestion) => suggestion.deleteRange.from > 20 || suggestion.deleteRange.to < 10,
)
}