Do you have an issue with a specific file(s)?
Can you reproduce using one of our samples or online demos?
Are you using the WebViewer server?
Does the issue only happen on certain browsers?
Is your issue related to a front-end framework?
Is your issue related to annotations?
Please give a brief summary of your issue:
(Think of this as an email subject)
Trying to create a discard edits button
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
<>
<Button
size="xs"
colorScheme="norm.blue"
onClick={() => {
// Undo all content edits via history manager
const contentEditHistoryManager =
documentViewer?.getContentEditHistoryManager();
if (contentEditHistoryManager) {
while (contentEditHistoryManager.canUndo()) {
contentEditHistoryManager.undo();
}
}
// Clear tracked edits from state
setPendingDocumentEdits([]);
contentEditManager?.endContentEditMode();
// Force rerender of document to refresh view
if (documentViewer) {
documentViewer.refreshAll();
documentViewer.updateView();
}
}}
>
Discard Edits
</Button>
This code puts the editing in a bad stae so was wondering if you guys have a proper way to discard all the edits and return the tools selected and everything into a good state
Please provide a link to a minimal sample where the issue is reproducible:
Hello, I’m AiRon, an automated tech support bot While you wait for one of our customer support representatives, I can help you with your question.
You’re attempting to create a “Discard Edits” button in WebViewer, and it seems like your current implementation isn’t working as expected. This is likely due to the way you’re managing the content edit history and the state of the document viewer.
Some things you can try:
Ensure that the contentEditHistoryManager is correctly initialized and is managing the history of edits properly.
Use the undo() method in a loop to revert all changes made during the editing session effectively.
After undoing all changes, ensure that the document is refreshed by calling documentViewer.refreshAll() and documentViewer.updateView() to update the display.
Check that the endContentEditMode() method is properly resetting the editing mode.
Verify that the state management for setPendingDocumentEdits([]) is correctly clearing any tracked edits.
When I stop content editing mode, my stop content edit mode event listener fires and the rectangle(without the dashes) over the text stays, even though the viewer switches to view mode?
const handleContentEditEnded = async () => {
// If there is no currently being edited annotation, do nothing.
// This should never happen.
if (
!trackedAnnotationRef.current ||
!trackedAnnotationRef.current.isContentEditPlaceholder()
) {
return;
}
try {
const placeholder = annotationManager?.getAnnotationById(
trackedAnnotationRef.current?.Id,
);
// 1. Get the latest content
const { xmlString } = await instance.Core.ContentEdit.getContent(
placeholder as Core.Annotations.RectangleAnnotation,
);
// Update the last content edit instead of adding a new one
const newEdits = [...pendingDocumentEdits];
setPendingDocumentEdits(newEdits);
trackedAnnotationRef.current = null;
} catch (error) {
console.error('Error updating content:', error);
}
};