Document Editor allows you to add comments to documents. You can add, navigate and remove comments in code and from the UI.
Comments can be inserted to the selected text.
this.$refs.documenteditor.ej2Instances.editor.insertComment("Test comment");
Next and previous comments can be navigated using the below code snippet.
//Navigate to next comment
this.$refs.documenteditor.ej2Instances.selection.navigateNextComment();
//Navigate to previous comment
this.$refs.documenteditor.ej2Instances.selection.navigatePreviousComment();
Current comment can be be deleted using the below code snippet.
this.$refs.documenteditor.ej2Instances.editor.deleteComment();
All the comments in the document can be deleted using the below code snippet.
this.$refs.documenteditor.ej2Instances.editor.deleteAllComments();
Document Editor provides support for protecting the document with CommentsOnly
protection. In this protection, user allowed to add or edit comments alone in the document.
Document editor provides an option to protect and unprotect document using enforceProtection
and stopProtection
API.
The following example code illustrates how to enforce and stop protection in Document editor container.
<template>
<div id="app">
<ejs-documenteditorcontainer ref='container' :serviceUrl='serviceUrl' height="590px" id='container' :enableToolbar='true'></ejs-documenteditorcontainer>
</div>
</template>
<script>
import Vue from 'vue';
import { DocumentEditorContainerPlugin, DocumentEditorContainerComponent,Toolbar} from '@syncfusion/ej2-vue-documenteditor';
Vue.use(DocumentEditorContainerPlugin);
export default {
data() {
return { serviceUrl:'https://ej2services.syncfusion.com/production/web-services/api/documenteditor/'};
},
provide: {
//Inject require modules.
DocumentEditorContainer: [Toolbar]
},
mounted(){
//enforce protection
this.$refs.container.ej2Instances.documentEditor.editor.enforceProtection('123','CommentsOnly');
//stop the document protection
this.$refs.container.ej2Instances.documentEditor.editor.stopProtection('123');
}
}
</script>
Comment only protection can be enabled in UI by using Restrict Editing pane
Note: In enforce Protection method, first parameter denotes password and second parameter denotes protection type. Possible values of protection type are NoProtection |ReadOnly |FormFieldsOnly |CommentsOnly
. In stop protection method, parameter denotes the password.