@univerjs/sheets-find-replace 0.6.0 → 0.6.1-nightly.202502221605

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.
package/lib/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var p=(i,e,t)=>e in i?_(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>p(i,typeof e!="symbol"?e+"":e,t);const l=require("@univerjs/core"),c=require("@univerjs/find-replace"),m=require("@univerjs/sheets/facade"),u=require("@univerjs/core/facade");var f=Object.getOwnPropertyDescriptor,v=(i,e,t,s)=>{for(var n=s>1?void 0:s?f(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(n=a(n)||n);return n},h=(i,e)=>(t,s)=>e(t,s,i);let d=class extends l.Disposable{constructor(e,t,s,n){super();o(this,"_state",new c.FindReplaceState);o(this,"_model");o(this,"_complete");this._injector=t,this._univerInstanceService=s,this._findReplaceService=n;const r=this._findReplaceService.getProviders();this._model=this._injector.createInstance(c.FindReplaceModel,this._state,r);const a={...c.createInitFindReplaceState(),...e};this._state.changeState(a)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var t;if(!this._state.findCompleted||!this._complete)return null;const e=(t=this._model)==null?void 0:t.moveToNextMatch();return e?this._findMatchToFRange(e):null}findPrevious(){var t;const e=(t=this._model)==null?void 0:t.moveToPreviousMatch();return e?this._findMatchToFRange(e):null}getCurrentMatch(){var t;if(!this._state.findCompleted||!this._complete)throw new Error("Find operation is not completed.");const e=(t=this._model)==null?void 0:t.currentMatch$.value;return e?this._findMatchToFRange(e):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?c.FindBy.FORMULA:c.FindBy.VALUE}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async replaceAllWithAsync(e){var s,n,r;await this._state.changeState({replaceRevealed:!0,replaceString:e});const t=(r=(n=await((s=this._model)==null?void 0:s.replaceAll()))==null?void 0:n.success)!=null?r:0;return this._state.changeState({replaceRevealed:!1}),t}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;return(!this._state.findCompleted||!this._complete)&&(this._complete=await((e=this._model)==null?void 0:e.start())),this._complete}_findMatchToFRange(e){const{unitId:t}=e,{subUnitId:s,range:n}=e.range,r=this._univerInstanceService.getUnit(t),a=r.getSheetBySheetId(s);return this._injector.createInstance(m.FRange,r,a,n)}};d=v([h(1,l.Inject(l.Injector)),h(2,l.IUniverInstanceService),h(3,c.IFindReplaceService)],d);class g extends u.FUniver{async createTextFinderAsync(e){const t={findString:e},s=this._injector.createInstance(d,t);return await s.ensureCompleteAsync(),s}}u.FUniver.extend(g);
1
+ "use strict";var p=Object.defineProperty;var _=(a,e,t)=>e in a?p(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>_(a,typeof e!="symbol"?e+"":e,t);const l=require("@univerjs/core"),c=require("@univerjs/find-replace"),m=require("@univerjs/sheets/facade"),u=require("@univerjs/core/facade");var f=Object.getOwnPropertyDescriptor,v=(a,e,t,s)=>{for(var n=s>1?void 0:s?f(e,t):e,i=a.length-1,r;i>=0;i--)(r=a[i])&&(n=r(n)||n);return n},h=(a,e)=>(t,s)=>e(t,s,a);let d=class extends l.Disposable{constructor(e,t,s,n){super();o(this,"_state",new c.FindReplaceState);o(this,"_model");o(this,"_complete");this._injector=t,this._univerInstanceService=s,this._findReplaceService=n;const i=this._findReplaceService.getProviders();this._model=this._injector.createInstance(c.FindReplaceModel,this._state,i);const r={...c.createInitFindReplaceState(),...e};this._state.changeState(r)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var t;if(!this._state.findCompleted||!this._complete)return null;const e=(t=this._model)==null?void 0:t.moveToNextMatch();return e?this._findMatchToFRange(e):null}findPrevious(){var t;const e=(t=this._model)==null?void 0:t.moveToPreviousMatch();return e?this._findMatchToFRange(e):null}getCurrentMatch(){var t;if(!this._state.findCompleted||!this._complete)throw new Error("Find operation is not completed.");const e=(t=this._model)==null?void 0:t.currentMatch$.value;return e?this._findMatchToFRange(e):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e,findCompleted:!1}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(s.unsubscribe(),await this.ensureCompleteAsync(),t(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e,findCompleted:!1}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(s.unsubscribe(),await this.ensureCompleteAsync(),t(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?c.FindBy.FORMULA:c.FindBy.VALUE,findCompleted:!1}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(s.unsubscribe(),await this.ensureCompleteAsync(),t(this))})})}async replaceAllWithAsync(e){var s,n,i;await this._state.changeState({replaceRevealed:!0,replaceString:e});const t=(i=(n=await((s=this._model)==null?void 0:s.replaceAll()))==null?void 0:n.success)!=null?i:0;return this._state.changeState({replaceRevealed:!1}),t}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;this._complete=await((e=this._model)==null?void 0:e.start())}_findMatchToFRange(e){const{unitId:t}=e,{subUnitId:s,range:n}=e.range,i=this._univerInstanceService.getUnit(t),r=i.getSheetBySheetId(s);return this._injector.createInstance(m.FRange,i,r,n)}};d=v([h(1,l.Inject(l.Injector)),h(2,l.IUniverInstanceService),h(3,c.IFindReplaceService)],d);class y extends u.FUniver{async createTextFinderAsync(e){const t={findString:e},s=this._injector.createInstance(d,t);return await s.ensureCompleteAsync(),s}}u.FUniver.extend(y);
package/lib/es/facade.js CHANGED
@@ -1,29 +1,29 @@
1
1
  var u = Object.defineProperty;
2
- var _ = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var c = (i, e, t) => _(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { Inject as p, Injector as m, IUniverInstanceService as f, Disposable as v } from "@univerjs/core";
5
- import { IFindReplaceService as g, FindReplaceModel as S, createInitFindReplaceState as b, FindReplaceState as F, FindBy as h } from "@univerjs/find-replace";
6
- import { FRange as y } from "@univerjs/sheets/facade";
2
+ var p = (a, e, t) => e in a ? u(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var c = (a, e, t) => p(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Inject as m, Injector as _, IUniverInstanceService as f, Disposable as v } from "@univerjs/core";
5
+ import { IFindReplaceService as g, FindReplaceModel as y, createInitFindReplaceState as S, FindReplaceState as b, FindBy as h } from "@univerjs/find-replace";
6
+ import { FRange as F } from "@univerjs/sheets/facade";
7
7
  import { FUniver as d } from "@univerjs/core/facade";
8
- var R = Object.getOwnPropertyDescriptor, w = (i, e, t, s) => {
9
- for (var n = s > 1 ? void 0 : s ? R(e, t) : e, r = i.length - 1, a; r >= 0; r--)
10
- (a = i[r]) && (n = a(n) || n);
8
+ var w = Object.getOwnPropertyDescriptor, C = (a, e, t, s) => {
9
+ for (var n = s > 1 ? void 0 : s ? w(e, t) : e, i = a.length - 1, r; i >= 0; i--)
10
+ (r = a[i]) && (n = r(n) || n);
11
11
  return n;
12
- }, o = (i, e) => (t, s) => e(t, s, i);
12
+ }, o = (a, e) => (t, s) => e(t, s, a);
13
13
  let l = class extends v {
14
14
  constructor(e, t, s, n) {
15
15
  super();
16
- c(this, "_state", new F());
16
+ c(this, "_state", new b());
17
17
  c(this, "_model");
18
18
  c(this, "_complete");
19
19
  this._injector = t, this._univerInstanceService = s, this._findReplaceService = n;
20
- const r = this._findReplaceService.getProviders();
21
- this._model = this._injector.createInstance(S, this._state, r);
22
- const a = {
23
- ...b(),
20
+ const i = this._findReplaceService.getProviders();
21
+ this._model = this._injector.createInstance(y, this._state, i);
22
+ const r = {
23
+ ...S(),
24
24
  ...e
25
25
  };
26
- this._state.changeState(a);
26
+ this._state.changeState(r);
27
27
  }
28
28
  findAll() {
29
29
  return !this._state.findCompleted || !this._complete ? [] : this._complete.results.map((e) => this._findMatchToFRange(e));
@@ -48,30 +48,30 @@ let l = class extends v {
48
48
  return e ? this._findMatchToFRange(e) : null;
49
49
  }
50
50
  async matchCaseAsync(e) {
51
- return this._state.changeState({ caseSensitive: e }), new Promise((t) => {
52
- const s = this._state.stateUpdates$.subscribe((n) => {
53
- n.findCompleted === !0 && (s.unsubscribe(), t(this));
51
+ return this._state.changeState({ caseSensitive: e, findCompleted: !1 }), new Promise((t) => {
52
+ const s = this._state.stateUpdates$.subscribe(async (n) => {
53
+ n.findCompleted === !0 && (s.unsubscribe(), await this.ensureCompleteAsync(), t(this));
54
54
  });
55
55
  });
56
56
  }
57
57
  async matchEntireCellAsync(e) {
58
- return this._state.changeState({ matchesTheWholeCell: e }), new Promise((t) => {
59
- const s = this._state.stateUpdates$.subscribe((n) => {
60
- n.findCompleted === !0 && (s.unsubscribe(), t(this));
58
+ return this._state.changeState({ matchesTheWholeCell: e, findCompleted: !1 }), new Promise((t) => {
59
+ const s = this._state.stateUpdates$.subscribe(async (n) => {
60
+ n.findCompleted === !0 && (s.unsubscribe(), await this.ensureCompleteAsync(), t(this));
61
61
  });
62
62
  });
63
63
  }
64
64
  async matchFormulaTextAsync(e) {
65
- return this._state.changeState({ findBy: e ? h.FORMULA : h.VALUE }), new Promise((t) => {
66
- const s = this._state.stateUpdates$.subscribe((n) => {
67
- n.findCompleted === !0 && (s.unsubscribe(), t(this));
65
+ return this._state.changeState({ findBy: e ? h.FORMULA : h.VALUE, findCompleted: !1 }), new Promise((t) => {
66
+ const s = this._state.stateUpdates$.subscribe(async (n) => {
67
+ n.findCompleted === !0 && (s.unsubscribe(), await this.ensureCompleteAsync(), t(this));
68
68
  });
69
69
  });
70
70
  }
71
71
  async replaceAllWithAsync(e) {
72
- var s, n, r;
72
+ var s, n, i;
73
73
  await this._state.changeState({ replaceRevealed: !0, replaceString: e });
74
- const t = (r = (n = await ((s = this._model) == null ? void 0 : s.replaceAll())) == null ? void 0 : n.success) != null ? r : 0;
74
+ const t = (i = (n = await ((s = this._model) == null ? void 0 : s.replaceAll())) == null ? void 0 : n.success) != null ? i : 0;
75
75
  return this._state.changeState({ replaceRevealed: !1 }), t;
76
76
  }
77
77
  async replaceWithAsync(e) {
@@ -80,22 +80,22 @@ let l = class extends v {
80
80
  }
81
81
  async ensureCompleteAsync() {
82
82
  var e;
83
- return (!this._state.findCompleted || !this._complete) && (this._complete = await ((e = this._model) == null ? void 0 : e.start())), this._complete;
83
+ this._complete = await ((e = this._model) == null ? void 0 : e.start());
84
84
  }
85
85
  _findMatchToFRange(e) {
86
- const { unitId: t } = e, { subUnitId: s, range: n } = e.range, r = this._univerInstanceService.getUnit(t), a = r.getSheetBySheetId(s);
87
- return this._injector.createInstance(y, r, a, n);
86
+ const { unitId: t } = e, { subUnitId: s, range: n } = e.range, i = this._univerInstanceService.getUnit(t), r = i.getSheetBySheetId(s);
87
+ return this._injector.createInstance(F, i, r, n);
88
88
  }
89
89
  };
90
- l = w([
91
- o(1, p(m)),
90
+ l = C([
91
+ o(1, m(_)),
92
92
  o(2, f),
93
93
  o(3, g)
94
94
  ], l);
95
- class C extends d {
95
+ class R extends d {
96
96
  async createTextFinderAsync(e) {
97
97
  const t = { findString: e }, s = this._injector.createInstance(l, t);
98
98
  return await s.ensureCompleteAsync(), s;
99
99
  }
100
100
  }
101
- d.extend(C);
101
+ d.extend(R);
@@ -6,130 +6,314 @@ import { FRange } from '@univerjs/sheets/facade';
6
6
  */
7
7
  export interface IFTextFinder {
8
8
  /**
9
- * get all the matched range in the univer
10
- * @returns all the matched range
11
- * @throws if the find operation is not completed
9
+ * Get all the matched cells of the current sheet, the current matched cell is the last matched cell.
10
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
11
+ * @returns {FRange[]} All the matched cells.
12
+ * @throws If the find operation is not completed.
12
13
  * @example
13
14
  * ```typescript
14
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
15
- * const ranges = textFinder.findAll();
16
- * ranges.forEach((range) => {
17
- * console.log(range.getA1Notation());
15
+ * // Assume the current sheet is empty sheet.
16
+ * const fWorkbook = univerAPI.getActiveWorkbook();
17
+ * const fWorksheet = fWorkbook.getActiveSheet();
18
+ * const fRange = fWorksheet.getRange('A1:D10');
19
+ * fRange.setValues([
20
+ * [1, 2, 3, 4],
21
+ * [2, 3, 4, 5],
22
+ * [3, 4, 5, 6],
23
+ * [4, 5, 6, 7],
24
+ * [5, 6, 7, 8],
25
+ * [6, 7, 8, 9],
26
+ * [7, 8, 9, 10],
27
+ * [8, 9, 10, 11],
28
+ * [9, 10, 11, 12],
29
+ * [10, 11, 12, 13]
30
+ * ]);
31
+ *
32
+ * // Create a text-finder to find the text '5'.
33
+ * const textFinder = await univerAPI.createTextFinderAsync('5');
34
+ *
35
+ * // Find all cells that contain the text '5'.
36
+ * const matchCells = textFinder.findAll();
37
+ * matchCells.forEach((cell) => {
38
+ * console.log(cell.getA1Notation()); // D2, C3, B4, A5
18
39
  * });
19
40
  * ```
20
41
  */
21
42
  findAll(): FRange[];
22
43
  /**
23
- * find the next matched range in the univer
24
- * @returns the next matched range
25
- * @throws if the find operation is not completed
26
- * @returns null if no more match
44
+ * Get the next matched cell of the current sheet, if exists return the next matched cell and move the current matched cell to the next matched cell.
45
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
46
+ * @returns {Nullable<FRange>} The next matched cell.
47
+ * @throws If the find operation is not completed.
27
48
  * @example
28
49
  * ```typescript
29
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
30
- * const range = textFinder.findNext();
31
- * if (range) {
32
- * console.log(range.getA1Notation());
33
- * }
50
+ * // Assume the current sheet is empty sheet.
51
+ * const fWorkbook = univerAPI.getActiveWorkbook();
52
+ * const fWorksheet = fWorkbook.getActiveSheet();
53
+ * const fRange = fWorksheet.getRange('A1:D10');
54
+ * fRange.setValues([
55
+ * [1, 2, 3, 4],
56
+ * [2, 3, 4, 5],
57
+ * [3, 4, 5, 6],
58
+ * [4, 5, 6, 7],
59
+ * [5, 6, 7, 8],
60
+ * [6, 7, 8, 9],
61
+ * [7, 8, 9, 10],
62
+ * [8, 9, 10, 11],
63
+ * [9, 10, 11, 12],
64
+ * [10, 11, 12, 13]
65
+ * ]);
66
+ *
67
+ * // Create a text-finder to find the text '5'.
68
+ * const textFinder = await univerAPI.createTextFinderAsync('5');
69
+ * console.log(textFinder.getCurrentMatch().getA1Notation()); // current match cell is A5
70
+ *
71
+ * // Find the next matched range
72
+ * const nextMatch = textFinder.findNext();
73
+ * console.log(nextMatch.getA1Notation()); // D2
74
+ * console.log(textFinder.getCurrentMatch().getA1Notation()); // current match cell is D2
34
75
  * ```
35
76
  */
36
77
  findNext(): Nullable<FRange>;
37
78
  /**
38
- * find the previous matched range in the univer
39
- * @returns the previous matched range
40
- * @throws if the find operation is not completed
41
- * @returns null if no more match
79
+ * Get the previous matched cell of the current sheet, if exists return the previous matched cell and move the current matched cell to the previous matched cell.
80
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
81
+ * @returns {Nullable<FRange>} The previous matched cell.
82
+ * @throws If the find operation is not completed.
42
83
  * @example
43
84
  * ```typescript
44
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
45
- * const range = textFinder.findPrevious();
46
- * if (range) {
47
- * console.log(range.getA1Notation());
48
- * }
85
+ * // Assume the current sheet is empty sheet.
86
+ * const fWorkbook = univerAPI.getActiveWorkbook();
87
+ * const fWorksheet = fWorkbook.getActiveSheet();
88
+ * const fRange = fWorksheet.getRange('A1:D10');
89
+ * fRange.setValues([
90
+ * [1, 2, 3, 4],
91
+ * [2, 3, 4, 5],
92
+ * [3, 4, 5, 6],
93
+ * [4, 5, 6, 7],
94
+ * [5, 6, 7, 8],
95
+ * [6, 7, 8, 9],
96
+ * [7, 8, 9, 10],
97
+ * [8, 9, 10, 11],
98
+ * [9, 10, 11, 12],
99
+ * [10, 11, 12, 13]
100
+ * ]);
101
+ *
102
+ * // Create a text-finder to find the text '5'.
103
+ * const textFinder = await univerAPI.createTextFinderAsync('5');
104
+ * console.log(textFinder.getCurrentMatch().getA1Notation()); // current match cell is A5
105
+ *
106
+ * // Find the previous matched range.
107
+ * const previousMatch = textFinder.findPrevious();
108
+ * console.log(previousMatch.getA1Notation()); // B4
109
+ * console.log(textFinder.getCurrentMatch().getA1Notation()); // current match cell is B4
49
110
  * ```
50
111
  */
51
112
  findPrevious(): Nullable<FRange>;
52
113
  /**
53
- * get the current matched range in the univer
54
- * @returns the current matched range
55
- * @throws if the find operation is not completed
114
+ * Get the current matched cell of the current sheet.
115
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
116
+ * @returns {Nullable<FRange>} The current matched cell.
117
+ * @throws If the find operation is not completed.
56
118
  * @example
57
119
  * ```typescript
58
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
59
- * const range = textFinder.getCurrentMatch();
60
- * if (range) {
61
- * console.log(range.getA1Notation());
62
- * }
120
+ * // Assume the current sheet is empty sheet.
121
+ * const fWorkbook = univerAPI.getActiveWorkbook();
122
+ * const fWorksheet = fWorkbook.getActiveSheet();
123
+ * const fRange = fWorksheet.getRange('A1:D10');
124
+ * fRange.setValues([
125
+ * [1, 2, 3, 4],
126
+ * [2, 3, 4, 5],
127
+ * [3, 4, 5, 6],
128
+ * [4, 5, 6, 7],
129
+ * [5, 6, 7, 8],
130
+ * [6, 7, 8, 9],
131
+ * [7, 8, 9, 10],
132
+ * [8, 9, 10, 11],
133
+ * [9, 10, 11, 12],
134
+ * [10, 11, 12, 13]
135
+ * ]);
136
+ *
137
+ * // Create a text-finder to find the text '5'.
138
+ * const textFinder = await univerAPI.createTextFinderAsync('5');
139
+ *
140
+ * // Get the current matched range.
141
+ * const currentMatch = textFinder.getCurrentMatch();
142
+ * console.log(currentMatch.getA1Notation()); // A5
63
143
  * ```
64
144
  */
65
145
  getCurrentMatch(): Nullable<FRange>;
66
146
  /**
67
- * set the match case option
68
- * @param {boolean} matchCase whether to match case
69
- * @returns text-finder instance
147
+ * Set the match case option, if true, the find operation will match case, otherwise, the find operation will ignore case.
148
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
149
+ * @param {boolean} matchCase - Whether to match case.
150
+ * @returns {Promise<IFTextFinder>} The text-finder instance.
70
151
  * @example
71
152
  * ```typescript
72
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
153
+ * // Assume the current sheet is empty sheet.
154
+ * const fWorkbook = univerAPI.getActiveWorkbook();
155
+ * const fWorksheet = fWorkbook.getActiveSheet();
156
+ * const fRange = fWorksheet.getRange('A1:D1');
157
+ * fRange.setValues([
158
+ * ['hello univer', 'hello UNIVER', 'HELLO UNIVER', 'HELLO univer'],
159
+ * ]);
160
+ *
161
+ * // Create a text-finder to find the text 'univer'.
162
+ * const textFinder = await univerAPI.createTextFinderAsync('univer');
163
+ * let matchCells = textFinder.findAll();
164
+ * matchCells.forEach((cell) => {
165
+ * console.log(cell.getA1Notation()); // A1, B1, C1, D1
166
+ * });
167
+ *
168
+ * // Set the match case.
73
169
  * await textFinder.matchCaseAsync(true);
170
+ * matchCells = textFinder.findAll();
171
+ * matchCells.forEach((cell) => {
172
+ * console.log(cell.getA1Notation()); // A1, D1
173
+ * });
74
174
  * ```
75
175
  */
76
176
  matchCaseAsync(matchCase: boolean): Promise<IFTextFinder>;
77
177
  /**
78
- * set the match entire cell option
79
- * @param {boolean} matchEntireCell whether to match entire cell
80
- * @returns text-finder instance
178
+ * Set the match entire cell option, if true, the find operation will match entire cell value, otherwise, the find operation will match part of the cell value.
179
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
180
+ * @param {boolean} matchEntireCell - Whether to match entire cell value.
181
+ * @returns {Promise<IFTextFinder>} The text-finder instance.
81
182
  * @example
82
183
  * ```typescript
83
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
184
+ * // Assume the current sheet is empty sheet.
185
+ * const fWorkbook = univerAPI.getActiveWorkbook();
186
+ * const fWorksheet = fWorkbook.getActiveSheet();
187
+ * const fRange = fWorksheet.getRange('A1:D1');
188
+ * fRange.setValues([
189
+ * ['hello univer', 'hello univer 1', 'hello univer 2', 'hello univer 3'],
190
+ * ]);
191
+ *
192
+ * // Create a text-finder to find the text 'hello univer'.
193
+ * const textFinder = await univerAPI.createTextFinderAsync('hello univer');
194
+ * let matchCells = textFinder.findAll();
195
+ * matchCells.forEach((cell) => {
196
+ * console.log(cell.getA1Notation()); // A1, B1, C1, D1
197
+ * });
198
+ *
199
+ * // Set the match entire cell.
84
200
  * await textFinder.matchEntireCellAsync(true);
201
+ * matchCells = textFinder.findAll();
202
+ * matchCells.forEach((cell) => {
203
+ * console.log(cell.getA1Notation()); // A1
204
+ * });
85
205
  * ```
86
206
  */
87
207
  matchEntireCellAsync(matchEntireCell: boolean): Promise<IFTextFinder>;
88
208
  /**
89
- * set the match formula text option
90
- * @param {boolean} matchFormulaText whether to match formula text
91
- * @returns text-finder instance
209
+ * Set the match formula text option, if true, the find operation will match formula text, otherwise, the find operation will match value.
210
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
211
+ * @param {boolean} matchFormulaText - Whether to match formula text.
212
+ * @returns {Promise<IFTextFinder>} The text-finder instance.
92
213
  * @example
93
214
  * ```typescript
94
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
215
+ * // Assume the current sheet is empty sheet.
216
+ * const fWorkbook = univerAPI.getActiveWorkbook();
217
+ * const fWorksheet = fWorkbook.getActiveSheet();
218
+ * const fRange = fWorksheet.getRange('A1:D1');
219
+ * fRange.setValues([
220
+ * ['sum', '1', '=SUM(2)', '3'],
221
+ * ]);
222
+ *
223
+ * // Create a text-finder to find the text 'sum'.
224
+ * const textFinder = await univerAPI.createTextFinderAsync('sum');
225
+ * let matchCells = textFinder.findAll();
226
+ * matchCells.forEach((cell) => {
227
+ * console.log(cell.getA1Notation()); // A1
228
+ * });
229
+ *
230
+ * // Set the match entire cell.
95
231
  * await textFinder.matchFormulaTextAsync(true);
232
+ * matchCells = textFinder.findAll();
233
+ * matchCells.forEach((cell) => {
234
+ * console.log(cell.getA1Notation()); // A1, C1
235
+ * });
96
236
  * ```
97
237
  */
98
238
  matchFormulaTextAsync(matchFormulaText: boolean): Promise<IFTextFinder>;
99
239
  /**
100
- * replace all the matched text with the given text
101
- * @param {string} replaceText the text to replace
102
- * @returns the number of replaced text
103
- * @throws if the find operation is not completed
240
+ * Replace all the matched text with the given text.
241
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
242
+ * @param {string} replaceText - The text to replace.
243
+ * @returns {Promise<number>} The count of replaced text.
244
+ * @throws If the find operation is not completed.
104
245
  * @example
105
246
  * ```typescript
247
+ * // Assume the current sheet is empty sheet.
248
+ * const fWorkbook = univerAPI.getActiveWorkbook();
249
+ * const fWorksheet = fWorkbook.getActiveSheet();
250
+ * const fRange = fWorksheet.getRange('A1:D1');
251
+ * fRange.setValues([
252
+ * ['hello', 'hello', 'hello', 'hello'],
253
+ * ]);
254
+ *
255
+ * // Create a text-finder to find the text 'hello'.
106
256
  * const textFinder = await univerAPI.createTextFinderAsync('hello');
107
- * const replacedCount = await textFinder.replaceAllWithAsync('world');
108
- * console.log(replacedCount);
257
+ *
258
+ * // Replace all the matched text with 'hello univer'.
259
+ * const count = await textFinder.replaceAllWithAsync('hello univer');
260
+ * console.log(count); // 4
261
+ * console.log(fRange.getValues()); // [['hello univer', 'hello univer', 'hello univer', 'hello univer']]
109
262
  * ```
110
263
  */
111
264
  replaceAllWithAsync(replaceText: string): Promise<number>;
112
265
  /**
113
- * replace the current matched text with the given text
114
- * @param {string} replaceText the text to replace
115
- * @returns whether the replace is successful
116
- * @throws if the find operation is not completed
266
+ * Replace the current matched text with the given text.
267
+ * If current sheet changed, use `await textFinder.ensureCompleteAsync()` to ensure the find operation is completed.
268
+ * @param {string} replaceText - The text to replace.
269
+ * @returns {Promise<boolean>} Whether the replace is successful.
270
+ * @throws If the find operation is not completed.
117
271
  * @example
118
272
  * ```typescript
273
+ * // Assume the current sheet is empty sheet.
274
+ * const fWorkbook = univerAPI.getActiveWorkbook();
275
+ * const fWorksheet = fWorkbook.getActiveSheet();
276
+ * const fRange = fWorksheet.getRange('B1:E1');
277
+ * fRange.setValues([
278
+ * ['hello', 'hello', 'hello', 'hello'],
279
+ * ]);
280
+ *
281
+ * // Create a text-finder to find the text 'hello'.
119
282
  * const textFinder = await univerAPI.createTextFinderAsync('hello');
120
- * const replaced = await textFinder.replaceWithAsync('world');
121
- * console.log(replaced);
283
+ *
284
+ * // Replace the current matched text with 'hello univer'.
285
+ * const replaced = await textFinder.replaceWithAsync('hello univer');
286
+ * console.log(replaced); // true
287
+ * console.log(fRange.getValues()); // [['hello', 'hello', 'hello', 'hello univer']]
122
288
  * ```
123
289
  */
124
290
  replaceWithAsync(replaceText: string): Promise<boolean>;
125
291
  /**
126
- * ensure the find operation is completed
127
- * @returns the find complete result
292
+ * Ensure the find operation is completed. Especially when the current sheet changed use this method to ensure the find operation is completed.
293
+ * @returns {Promise<Nullable<IFindComplete>>} The find complete result.
128
294
  * @example
129
295
  * ```typescript
130
- * const textFinder = await univerAPI.createTextFinderAsync('hello');
131
- * const complete = await textFinder.ensureCompleteAsync();
132
- * console.log(complete);
296
+ * // Create a text-finder to find the text '1'.
297
+ * const textFinder = await univerAPI.createTextFinderAsync('1');
298
+ *
299
+ * // Find all cells that contain the text '1'.
300
+ * const matchCells = textFinder.findAll();
301
+ * matchCells.forEach((cell) => {
302
+ * console.log(cell.getA1Notation());
303
+ * });
304
+ *
305
+ * const fWorkbook = univerAPI.getActiveWorkbook();
306
+ * const sheets = fWorkbook.getSheets();
307
+ *
308
+ * // Change the current sheet to the second sheet.
309
+ * sheets[1]?.activate();
310
+ *
311
+ * // Ensure the find operation is completed of the current sheet.
312
+ * await textFinder.ensureCompleteAsync();
313
+ * const matchCells2 = textFinder.findAll();
314
+ * matchCells2.forEach((cell) => {
315
+ * console.log(cell.getA1Notation());
316
+ * });
133
317
  * ```
134
318
  */
135
319
  ensureCompleteAsync(): Promise<Nullable<IFindComplete>>;
@@ -10,7 +10,31 @@ export interface IFUniverFindReplaceMixin {
10
10
  * @returns {Promise<FTextFinder | null>} A promise that resolves to the text-finder instance.
11
11
  * @example
12
12
  * ```typescript
13
- * const textFinder = await univerAPI.createTextFinderAsync('Hello');
13
+ * // Assume the current sheet is empty sheet.
14
+ * const fWorkbook = univerAPI.getActiveWorkbook();
15
+ * const fWorksheet = fWorkbook.getActiveSheet();
16
+ * const fRange = fWorksheet.getRange('A1:D10');
17
+ * fRange.setValues([
18
+ * [1, 2, 3, 4],
19
+ * [2, 3, 4, 5],
20
+ * [3, 4, 5, 6],
21
+ * [4, 5, 6, 7],
22
+ * [5, 6, 7, 8],
23
+ * [6, 7, 8, 9],
24
+ * [7, 8, 9, 10],
25
+ * [8, 9, 10, 11],
26
+ * [9, 10, 11, 12],
27
+ * [10, 11, 12, 13]
28
+ * ]);
29
+ *
30
+ * // Create a text-finder to find the text '5'.
31
+ * const textFinder = await univerAPI.createTextFinderAsync('5');
32
+ *
33
+ * // Find all cells that contain the text '5'.
34
+ * const matchCells = textFinder.findAll();
35
+ * matchCells.forEach((cell) => {
36
+ * console.log(cell.getA1Notation()); // D2, C3, B4, A5
37
+ * });
14
38
  * ```
15
39
  */
16
40
  createTextFinderAsync(text: string): Promise<FTextFinder | null>;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(i,n){typeof exports=="object"&&typeof module<"u"?n(require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace","@univerjs/sheets/facade","@univerjs/core/facade"],n):(i=typeof globalThis<"u"?globalThis:i||self,n(i.UniverCore,i.UniverFindReplace,i.UniverSheetsFacade,i.UniverCoreFacade))})(this,function(i,n,c,_){"use strict";var v=Object.defineProperty;var F=(i,n,c)=>n in i?v(i,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):i[n]=c;var u=(i,n,c)=>F(i,typeof n!="symbol"?n+"":n,c);var p=Object.getOwnPropertyDescriptor,f=(o,e,t,s)=>{for(var r=s>1?void 0:s?p(e,t):e,a=o.length-1,h;a>=0;a--)(h=o[a])&&(r=h(r)||r);return r},d=(o,e)=>(t,s)=>e(t,s,o);let l=class extends i.Disposable{constructor(e,t,s,r){super();u(this,"_state",new n.FindReplaceState);u(this,"_model");u(this,"_complete");this._injector=t,this._univerInstanceService=s,this._findReplaceService=r;const a=this._findReplaceService.getProviders();this._model=this._injector.createInstance(n.FindReplaceModel,this._state,a);const h={...n.createInitFindReplaceState(),...e};this._state.changeState(h)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var t;if(!this._state.findCompleted||!this._complete)return null;const e=(t=this._model)==null?void 0:t.moveToNextMatch();return e?this._findMatchToFRange(e):null}findPrevious(){var t;const e=(t=this._model)==null?void 0:t.moveToPreviousMatch();return e?this._findMatchToFRange(e):null}getCurrentMatch(){var t;if(!this._state.findCompleted||!this._complete)throw new Error("Find operation is not completed.");const e=(t=this._model)==null?void 0:t.currentMatch$.value;return e?this._findMatchToFRange(e):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(r=>{r.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(r=>{r.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?n.FindBy.FORMULA:n.FindBy.VALUE}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(r=>{r.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async replaceAllWithAsync(e){var s,r,a;await this._state.changeState({replaceRevealed:!0,replaceString:e});const t=(a=(r=await((s=this._model)==null?void 0:s.replaceAll()))==null?void 0:r.success)!=null?a:0;return this._state.changeState({replaceRevealed:!1}),t}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;return(!this._state.findCompleted||!this._complete)&&(this._complete=await((e=this._model)==null?void 0:e.start())),this._complete}_findMatchToFRange(e){const{unitId:t}=e,{subUnitId:s,range:r}=e.range,a=this._univerInstanceService.getUnit(t),h=a.getSheetBySheetId(s);return this._injector.createInstance(c.FRange,a,h,r)}};l=f([d(1,i.Inject(i.Injector)),d(2,i.IUniverInstanceService),d(3,n.IFindReplaceService)],l);class m extends _.FUniver{async createTextFinderAsync(e){const t={findString:e},s=this._injector.createInstance(l,t);return await s.ensureCompleteAsync(),s}}_.FUniver.extend(m)});
1
+ (function(i,n){typeof exports=="object"&&typeof module<"u"?n(require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace","@univerjs/sheets/facade","@univerjs/core/facade"],n):(i=typeof globalThis<"u"?globalThis:i||self,n(i.UniverCore,i.UniverFindReplace,i.UniverSheetsFacade,i.UniverCoreFacade))})(this,function(i,n,c,p){"use strict";var v=Object.defineProperty;var y=(i,n,c)=>n in i?v(i,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):i[n]=c;var l=(i,n,c)=>y(i,typeof n!="symbol"?n+"":n,c);var _=Object.getOwnPropertyDescriptor,f=(o,e,t,s)=>{for(var r=s>1?void 0:s?_(e,t):e,a=o.length-1,h;a>=0;a--)(h=o[a])&&(r=h(r)||r);return r},u=(o,e)=>(t,s)=>e(t,s,o);let d=class extends i.Disposable{constructor(e,t,s,r){super();l(this,"_state",new n.FindReplaceState);l(this,"_model");l(this,"_complete");this._injector=t,this._univerInstanceService=s,this._findReplaceService=r;const a=this._findReplaceService.getProviders();this._model=this._injector.createInstance(n.FindReplaceModel,this._state,a);const h={...n.createInitFindReplaceState(),...e};this._state.changeState(h)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var t;if(!this._state.findCompleted||!this._complete)return null;const e=(t=this._model)==null?void 0:t.moveToNextMatch();return e?this._findMatchToFRange(e):null}findPrevious(){var t;const e=(t=this._model)==null?void 0:t.moveToPreviousMatch();return e?this._findMatchToFRange(e):null}getCurrentMatch(){var t;if(!this._state.findCompleted||!this._complete)throw new Error("Find operation is not completed.");const e=(t=this._model)==null?void 0:t.currentMatch$.value;return e?this._findMatchToFRange(e):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e,findCompleted:!1}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(async r=>{r.findCompleted===!0&&(s.unsubscribe(),await this.ensureCompleteAsync(),t(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e,findCompleted:!1}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(async r=>{r.findCompleted===!0&&(s.unsubscribe(),await this.ensureCompleteAsync(),t(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?n.FindBy.FORMULA:n.FindBy.VALUE,findCompleted:!1}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(async r=>{r.findCompleted===!0&&(s.unsubscribe(),await this.ensureCompleteAsync(),t(this))})})}async replaceAllWithAsync(e){var s,r,a;await this._state.changeState({replaceRevealed:!0,replaceString:e});const t=(a=(r=await((s=this._model)==null?void 0:s.replaceAll()))==null?void 0:r.success)!=null?a:0;return this._state.changeState({replaceRevealed:!1}),t}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;this._complete=await((e=this._model)==null?void 0:e.start())}_findMatchToFRange(e){const{unitId:t}=e,{subUnitId:s,range:r}=e.range,a=this._univerInstanceService.getUnit(t),h=a.getSheetBySheetId(s);return this._injector.createInstance(c.FRange,a,h,r)}};d=f([u(1,i.Inject(i.Injector)),u(2,i.IUniverInstanceService),u(3,n.IFindReplaceService)],d);class m extends p.FUniver{async createTextFinderAsync(e){const t={findString:e},s=this._injector.createInstance(d,t);return await s.ensureCompleteAsync(),s}}p.FUniver.extend(m)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-find-replace",
3
- "version": "0.6.0",
3
+ "version": "0.6.1-nightly.202502221605",
4
4
  "private": false,
5
5
  "description": "UniverSheet find replace plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -58,18 +58,18 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/core": "0.6.0",
62
- "@univerjs/find-replace": "0.6.0",
63
- "@univerjs/engine-render": "0.6.0",
64
- "@univerjs/sheets-ui": "0.6.0",
65
- "@univerjs/sheets": "0.6.0"
61
+ "@univerjs/core": "0.6.1-nightly.202502221605",
62
+ "@univerjs/engine-render": "0.6.1-nightly.202502221605",
63
+ "@univerjs/find-replace": "0.6.1-nightly.202502221605",
64
+ "@univerjs/sheets": "0.6.1-nightly.202502221605",
65
+ "@univerjs/sheets-ui": "0.6.1-nightly.202502221605"
66
66
  },
67
67
  "devDependencies": {
68
68
  "rxjs": "^7.8.1",
69
69
  "typescript": "^5.7.3",
70
- "vite": "^6.1.0",
71
- "vitest": "^3.0.5",
72
- "@univerjs-infra/shared": "0.6.0"
70
+ "vite": "^6.1.1",
71
+ "vitest": "^3.0.6",
72
+ "@univerjs-infra/shared": "0.6.1"
73
73
  },
74
74
  "scripts": {
75
75
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS