@univerjs/sheets-conditional-formatting 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,34 +7,43 @@ import { FConditionalFormattingBuilder } from './conditional-formatting-builder'
7
7
  export interface IFRangeConditionalFormattingMixin {
8
8
  /**
9
9
  * Gets all the conditional formatting for the current range
10
- * @returns {*} {IConditionFormattingRule[]}
11
- * @memberof IFWorksheetConditionalFormattingMixin
10
+ * @returns {IConditionFormattingRule[]} conditional formatting rules for the current range
12
11
  * @example
13
12
  * ```ts
14
- * const workbook = univerAPI.getActiveWorkbook();
15
- * const worksheet = workbook?.getActiveSheet();
16
- * workbook?.setActiveRange(worksheet?.getRange(5, 5, 3, 3)!);
17
- * const rules = univerAPI.getActiveWorkbook()?.getActiveRange()?.getConditionalFormattingRules();
13
+ * const fWorkbook = univerAPI.getActiveWorkbook();
14
+ * const fWorksheet = fWorkbook.getActiveSheet();
15
+ * const fRange = fWorksheet.getRange('A1:T100');
16
+ * const rule = fWorksheet.newConditionalFormattingRule()
17
+ * .whenCellNotEmpty()
18
+ * .setRanges([fRange.getRange()])
19
+ * .setItalic(true)
20
+ * .setBackground('red')
21
+ * .setFontColor('green')
22
+ * .build();
23
+ * fWorksheet.addConditionalFormattingRule(rule);
24
+ *
25
+ * const targetRange = fWorksheet.getRange('F6:H8');
26
+ * const rules = targetRange.getConditionalFormattingRules();
27
+ * console.log(rules);
18
28
  * ```
19
29
  */
20
30
  getConditionalFormattingRules(): IConditionFormattingRule[];
21
31
  /**
22
32
  * Creates a constructor for conditional formatting
23
- * @returns {*} {ConditionalFormatRuleBuilder}
24
- * @memberof IFWorksheetConditionalFormattingMixin
33
+ * @returns {FConditionalFormattingBuilder} The conditional formatting builder
25
34
  * @example
26
35
  * ```ts
27
- * const workbook = univerAPI.getActiveWorkbook();
28
- * const worksheet = workbook?.getActiveSheet();
29
- * const rule = worksheet?.createConditionalFormattingRule()
30
- * .whenCellNotEmpty()
31
- * .setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])
32
- * .setItalic(true)
33
- * .setItalic(true)
34
- * .setBackground('red')
35
- * .setFontColor('green')
36
- * .build();
37
- * worksheet?.addConditionalFormattingRule(rule!);
36
+ * const fWorkbook = univerAPI.getActiveWorkbook();
37
+ * const fWorksheet = fWorkbook.getActiveSheet();
38
+ * const fRange = fWorksheet.getRange('A1:T100');
39
+ * const rule = fRange.createConditionalFormattingRule()
40
+ * .whenCellNotEmpty()
41
+ * .setItalic(true)
42
+ * .setBackground('red')
43
+ * .setFontColor('green')
44
+ * .build();
45
+ * fWorksheet.addConditionalFormattingRule(rule);
46
+ * console.log(fRange.getConditionalFormattingRules());
38
47
  * ```
39
48
  */
40
49
  createConditionalFormattingRule(): FConditionalFormattingBuilder;
@@ -7,119 +7,134 @@ import { FConditionalFormattingBuilder } from './conditional-formatting-builder'
7
7
  export interface IFWorksheetConditionalFormattingMixin {
8
8
  /**
9
9
  * Gets all the conditional formatting for the current sheet
10
- * @returns {*} {IConditionFormattingRule[]}
10
+ * @returns {IConditionFormattingRule[]} conditional formatting rules for the current sheet
11
11
  * @memberof IFWorksheetConditionalFormattingMixin
12
12
  * @example
13
13
  * ```ts
14
- * univerAPI.getActiveWorkbook()?.getActiveSheet().getConditionalFormattingRules();
14
+ * const fWorkbook = univerAPI.getActiveWorkbook();
15
+ * const fWorksheet = fWorkbook.getActiveSheet();
16
+ * const rules = fWorksheet.getConditionalFormattingRules();
17
+ * console.log(rules);
15
18
  * ```
16
19
  */
17
20
  getConditionalFormattingRules(): IConditionFormattingRule[];
18
21
  /**
19
- * @deprecated use newConditionalFormattingRule instead.
22
+ * @deprecated use `newConditionalFormattingRule` instead.
20
23
  * Creates a constructor for conditional formatting
21
- * @returns {ConditionalFormatRuleBuilder}
24
+ * @returns {FConditionalFormattingBuilder} The conditional formatting builder
22
25
  * @memberof IFWorksheetConditionalFormattingMixin
23
26
  * @example
24
27
  * ```ts
25
- * const workbook = univerAPI.getActiveWorkbook();
26
- * const worksheet = workbook?.getActiveSheet();
27
- * const rule = worksheet?.createConditionalFormattingRule()
28
- * .whenCellNotEmpty()
29
- * .setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])
30
- * .setItalic(true)
31
- * .setItalic(true)
32
- * .setBackground('red')
33
- * .setFontColor('green')
34
- * .build();
28
+ * const fWorkbook = univerAPI.getActiveWorkbook();
29
+ * const fWorksheet = fWorkbook.getActiveSheet();
30
+ * const fRange = fWorksheet.getRange('A1:T100');
31
+ * const rule = fWorksheet.createConditionalFormattingRule()
32
+ * .whenCellNotEmpty()
33
+ * .setRanges([fRange.getRange()])
34
+ * .setItalic(true)
35
+ * .setBackground('red')
36
+ * .setFontColor('green')
37
+ * .build();
38
+ * fWorksheet.addConditionalFormattingRule(rule);
35
39
  * ```
36
40
  */
37
41
  createConditionalFormattingRule(): FConditionalFormattingBuilder;
38
42
  /**
39
43
  * Creates a constructor for conditional formatting
40
- * @returns {ConditionalFormatRuleBuilder}@example
44
+ * @returns {FConditionalFormattingBuilder} The conditional formatting builder
41
45
  * @memberof IFWorksheetConditionalFormattingMixin
42
46
  * @example
43
47
  * ```ts
44
- * const workbook = univerAPI.getActiveWorkbook();
45
- * const worksheet = workbook?.getActiveSheet();
46
- * const rule = worksheet?.createConditionalFormattingRule()
47
- * .whenCellNotEmpty()
48
- * .setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])
49
- * .setItalic(true)
50
- * .setItalic(true)
51
- * .setBackground('red')
52
- * .setFontColor('green')
53
- * .build();
48
+ * const fWorkbook = univerAPI.getActiveWorkbook();
49
+ * const fWorksheet = fWorkbook.getActiveSheet();
50
+ * const fRange = fWorksheet.getRange('A1:T100');
51
+ * const rule = fWorksheet.newConditionalFormattingRule()
52
+ * .whenCellNotEmpty()
53
+ * .setRanges([fRange.getRange()])
54
+ * .setItalic(true)
55
+ * .setBackground('red')
56
+ * .setFontColor('green')
57
+ * .build();
58
+ * fWorksheet.addConditionalFormattingRule(rule);
54
59
  * ```
55
60
  */
56
61
  newConditionalFormattingRule(): FConditionalFormattingBuilder;
57
62
  /**
58
63
  * Add a new conditional format
59
- * @param {IConditionFormattingRule} rule
64
+ * @param {IConditionFormattingRule} rule - The conditional formatting rule to add
60
65
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
61
66
  * @memberof IFWorksheetConditionalFormattingMixin
62
67
  * @example
63
68
  * ```ts
64
- * const workbook = univerAPI.getActiveWorkbook();
65
- * const worksheet = workbook?.getActiveSheet();
66
- * const rule = worksheet?.createConditionalFormattingRule()
67
- * .whenCellNotEmpty()
68
- * .setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])
69
- * .setItalic(true)
70
- * .setItalic(true)
71
- * .setBackground('red')
72
- * .setFontColor('green')
73
- * .build();
74
- * worksheet?.addConditionalFormattingRule(rule!);
69
+ * const fWorkbook = univerAPI.getActiveWorkbook();
70
+ * const fWorksheet = fWorkbook.getActiveSheet();
71
+ * const fRange = fWorksheet.getRange('A1:T100');
72
+ * const rule = fWorksheet.newConditionalFormattingRule()
73
+ * .whenCellNotEmpty()
74
+ * .setRanges([fRange.getRange()])
75
+ * .setItalic(true)
76
+ * .setBackground('red')
77
+ * .setFontColor('green')
78
+ * .build();
79
+ * fWorksheet.addConditionalFormattingRule(rule);
75
80
  * ```
76
81
  */
77
82
  addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet;
78
83
  /**
79
84
  * Delete conditional format according to `cfId`
80
- * @param {string} cfId
85
+ * @param {string} cfId - The conditional formatting rule id to delete
81
86
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
82
87
  * @memberof IFWorksheetConditionalFormattingMixin
83
88
  * @example
84
89
  * ```ts
85
- * const workbook = univerAPI.getActiveWorkbook();
86
- * const worksheet = workbook?.getActiveSheet();
87
- * const rules = worksheet?.getConditionalFormattingRules();
88
- * worksheet?.deleteConditionalFormattingRule(rules![0].cfId);
90
+ * const fWorkbook = univerAPI.getActiveWorkbook();
91
+ * const fWorksheet = fWorkbook.getActiveSheet();
92
+ * const rules = fWorksheet.getConditionalFormattingRules();
93
+ * fWorksheet.deleteConditionalFormattingRule(rules[0]?.cfId);
89
94
  * ```
90
95
  */
91
96
  deleteConditionalFormattingRule(cfId: string): FWorksheet;
92
97
  /**
93
98
  * Modify the priority of the conditional format
94
- * @param {string} cfId Rules that need to be moved
99
+ * @param {string} cfId - The conditional formatting rule id to move
95
100
  * @param {string} toCfId Target rule
96
101
  * @param {IAnchor['type']} [type] After the default move to the destination rule, if type = before moves to the front, the default value is after
97
102
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
98
103
  * @memberof FWorksheetConditionalFormattingMixin
99
104
  * @example
100
105
  * ```ts
101
- * const workbook = univerAPI.getActiveWorkbook();
102
- * const worksheet = workbook?.getActiveSheet();
103
- * const rules = worksheet?.getConditionalFormattingRules()!;
106
+ * const fWorkbook = univerAPI.getActiveWorkbook();
107
+ * const fWorksheet = fWorkbook.getActiveSheet();
108
+ * const rules = fWorksheet.getConditionalFormattingRules();
104
109
  * const rule = rules[2];
105
110
  * const targetRule = rules[0];
106
- * worksheet?.moveConditionalFormattingRule(rule.cfId, targetRule.cfId, 'before');
111
+ * fWorksheet.moveConditionalFormattingRule(rule?.cfId, targetRule?.cfId, 'before');
107
112
  * ```
108
113
  */
109
114
  moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FWorksheet;
110
115
  /**
111
116
  * Set the conditional format according to `cfId`
112
- * @param {string} cfId
113
- * @param {IConditionFormattingRule} rule
117
+ * @param {string} cfId - The conditional formatting rule id to set
118
+ * @param {IConditionFormattingRule} rule - The conditional formatting rule to set
114
119
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
115
120
  * @memberof IFWorksheetConditionalFormattingMixin
116
121
  * @example
117
122
  * ```ts
118
- * const workbook = univerAPI.getActiveWorkbook();
119
- * const worksheet = workbook?.getActiveSheet();
120
- * const rules = worksheet?.getConditionalFormattingRules()!;
121
- * const rule = rules[0];
122
- * worksheet?.setConditionalFormattingRule(rule.cfId, { ...rule, ranges: [] });
123
+ * const fWorkbook = univerAPI.getActiveWorkbook();
124
+ * const fWorksheet = fWorkbook.getActiveSheet();
125
+ * const fRange = fWorksheet.getRange('A1:T100');
126
+ * const rule = fWorksheet.newConditionalFormattingRule()
127
+ * .whenCellNotEmpty()
128
+ * .setRanges([fRange.getRange()])
129
+ * .setItalic(true)
130
+ * .setBackground('red')
131
+ * .setFontColor('green')
132
+ * .build();
133
+ * fWorksheet.addConditionalFormattingRule(rule);
134
+ *
135
+ * const rules = fWorksheet.getConditionalFormattingRules();
136
+ * const newRuleRange = fWorksheet.getRange('A1:D10');
137
+ * fWorksheet.setConditionalFormattingRule(rules[0]?.cfId, { ...rules[0], ranges: [newRuleRange.getRange()] });
123
138
  * ```
124
139
  */
125
140
  setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FWorksheet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,18 +53,18 @@
53
53
  "rxjs": ">=7.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@univerjs/core": "0.6.0",
57
- "@univerjs/engine-formula": "0.6.0",
58
- "@univerjs/sheets": "0.6.0",
59
- "@univerjs/engine-render": "0.6.0"
56
+ "@univerjs/core": "0.6.1",
57
+ "@univerjs/engine-formula": "0.6.1",
58
+ "@univerjs/engine-render": "0.6.1",
59
+ "@univerjs/sheets": "0.6.1"
60
60
  },
61
61
  "devDependencies": {
62
- "@univerjs/icons-svg": "^0.2.15",
62
+ "@univerjs/icons-svg": "^0.2.20",
63
63
  "rxjs": "^7.8.1",
64
64
  "typescript": "^5.7.3",
65
- "vite": "^6.1.0",
66
- "vitest": "^3.0.5",
67
- "@univerjs-infra/shared": "0.6.0"
65
+ "vite": "^6.1.1",
66
+ "vitest": "^3.0.6",
67
+ "@univerjs-infra/shared": "0.6.1"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",