How to Customize Color Picker in TypeScript DOCX Editor
28 Aug 20262 minutes to read
TypeScript DOCX Editor (Document Editor) provides an option to customize the color picker using colorPickerSettings in the Document Editor settings. The color picker offers customization for the default appearance, allowing selection between Picker or Palette mode for font and border colors.
Similarly, you can use the documentEditorSettings property for the DocumentEditor as well.
The following example code illustrates how to customize the color picker in the Document Editor container.
let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToolbar: true, height: '590px',
//Customizing options for the color picker.
documentEditorSettings: {
colorPickerSettings: { mode: 'Palette', modeSwitcher: true, showButtons: true },
}
});
DocumentEditorContainer.Inject(Toolbar);
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
container.appendTo('#container');The Web API hosted link
https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/utilized in the DOCX Editor’s serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the GitHub Web Service example or Docker image for hosting your own web service and use for the serviceUrl property.
The following table illustrates all the possible properties for the color picker.
| Property | Behavior |
|---|---|
| columns | It is used to render the ColorPicker palette with specified columns. Defaults to 10 |
| disabled | It is used to enable / disable the ColorPicker component. If it is disabled, the ColorPicker popup won’t open. Defaults to false |
| mode | It is used to render the ColorPicker with the specified mode. Defaults to Picker
|
| modeSwitcher | It is used to show / hide the mode switcher button of the ColorPicker component. Defaults to true |
| showButtons | It is used to show / hide the control buttons (apply / cancel) of the ColorPicker component. Defaults to true |
According to the Word document specifications, it is not possible to modify the
predefined highlight colors. This limitation means that the range of highlight colors provided by default cannot be customized or expanded by the user to suit individual preferences. Consequently, users must work within the confines of the existing color palette, as no functionality currently exists to modify or personalize these predefined highlighting options.
Online Demo
Explore how to customize the color picker in the JavaScript DOCX Editor for Word documents in this live demo here.