Skip to content

Commit

Permalink
chore: add custom toolbar type example
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Oct 8, 2024
1 parent 78364a8 commit cd67f30
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions types/cherry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ export interface CustomMenuType {
[key: string]: any;
}


/**
* 自定义按钮功能
* example:
* `customMenu:{
* customMenu_fileUpload: any,
* }`
* 其中`customMenu`是自定按钮的固定属性,`customMenu_fileUpload`是自定义按钮的键名
*/
type CherryToolbarsCustomType = {
CustomMenuType: CustomMenuType
}
Expand All @@ -30,6 +21,43 @@ type CherryCustomOptions = {
CustomToolbar: CherryToolbarsCustomType
}


/**
* @description By by default, the types declared by Cherry markdown are supported.
* @description If you want to force the **custom toolbar** key type, please refer to the following.
* @example
* ```
* type CustomConfig = {
* CustomToolbar: {
* CustomMenuType: {
* customMenu_fileUpload: string
* },
* },
* }
*
* const cherryConfig: CherryOptions<CustomConfig> = {
* ...
* toolbars: {
* toolbar: [
* 'bold',
* 'italic',
* "customMenu_fileUpload",
* {
* customMenu_fileUpload: [
* 'image',
* 'audio',
* ],
* },
* 'settings',
* ],
* customMenu: {
* customMenu_fileUpload: customMenu_fileUpload,
* },
* }
* ```
* Among them, `customMenu` is the fixed attribute of the custom menu, and `customMenu_fileUpload` is the key name of the custom button
*/

export interface Cherry<T extends CherryCustomOptions = CherryCustomOptions> {
options: CherryOptions<T>;
}
Expand Down

0 comments on commit cd67f30

Please sign in to comment.