• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/// <reference path='./import.ts' />
17class TextEnableDataDetectorModifier extends ModifierWithKey<boolean> {
18  constructor(value: boolean) {
19    super(value);
20  }
21  static identity: Symbol = Symbol('textEnableDataDetector');
22  applyPeer(node: KNode, reset: boolean): void {
23    if (reset) {
24      getUINativeModule().text.resetEnableDataDetector(node);
25    } else {
26      getUINativeModule().text.setEnableDataDetector(node, this.value!);
27    }
28  }
29  checkObjectDiff(): boolean {
30    return !isBaseOrResourceEqual(this.stageValue, this.value);
31  }
32}
33
34class FontColorModifier extends ModifierWithKey<ResourceColor> {
35  constructor(value: ResourceColor) {
36    super(value);
37  }
38  static identity: Symbol = Symbol('textFontColor');
39  applyPeer(node: KNode, reset: boolean): void {
40    if (reset) {
41      getUINativeModule().text.resetFontColor(node);
42    } else {
43      getUINativeModule().text.setFontColor(node, this.value);
44    }
45  }
46
47  checkObjectDiff(): boolean {
48    return !isBaseOrResourceEqual(this.stageValue, this.value);
49  }
50}
51
52class TextForegroundColorModifier extends ModifierWithKey<ResourceColor | ColoringStrategy> {
53  constructor(value: ResourceColor | ColoringStrategy) {
54    super(value);
55  }
56  static identity: Symbol = Symbol('textForegroundColor');
57  applyPeer(node: KNode, reset: boolean): void {
58    if (reset) {
59      getUINativeModule().text.resetTextForegroundColor(node);
60    } else {
61      getUINativeModule().text.setTextForegroundColor(node, this.value);
62    }
63  }
64
65  checkObjectDiff(): boolean {
66    return !isBaseOrResourceEqual(this.stageValue, this.value);
67  }
68}
69
70class FontSizeModifier extends ModifierWithKey<number | string | Resource> {
71  constructor(value: number | string | Resource) {
72    super(value);
73  }
74  static identity: Symbol = Symbol('textFontSize');
75  applyPeer(node: KNode, reset: boolean): void {
76    if (reset) {
77      getUINativeModule().text.resetFontSize(node);
78    } else {
79      getUINativeModule().text.setFontSize(node, this.value);
80    }
81  }
82
83  checkObjectDiff(): boolean {
84    return !isBaseOrResourceEqual(this.stageValue, this.value);
85  }
86}
87
88class FontWeightModifier extends ModifierWithKey<string> {
89  constructor(value: string) {
90    super(value);
91  }
92  static identity: Symbol = Symbol('textFontWeight');
93  applyPeer(node: KNode, reset: boolean): void {
94    if (reset) {
95      getUINativeModule().text.resetFontWeight(node);
96    } else {
97      getUINativeModule().text.setFontWeight(node, this.value);
98    }
99  }
100}
101
102class FontStyleModifier extends ModifierWithKey<number> {
103  constructor(value: number) {
104    super(value);
105  }
106  static identity: Symbol = Symbol('textFontStyle');
107  applyPeer(node: KNode, reset: boolean): void {
108    if (reset) {
109      getUINativeModule().text.resetFontStyle(node);
110    } else {
111      getUINativeModule().text.setFontStyle(node, this.value);
112    }
113  }
114}
115
116class TextAlignModifier extends ModifierWithKey<number> {
117  constructor(value: number) {
118    super(value);
119  }
120  static identity: Symbol = Symbol('textAlign');
121  applyPeer(node: KNode, reset: boolean): void {
122    if (reset) {
123      getUINativeModule().text.resetTextAlign(node);
124    } else {
125      getUINativeModule().text.setTextAlign(node, this.value);
126    }
127  }
128}
129
130class TextHeightAdaptivePolicyModifier extends ModifierWithKey<TextHeightAdaptivePolicy> {
131  constructor(value: TextHeightAdaptivePolicy) {
132    super(value);
133  }
134  static identity: Symbol = Symbol('textHeightAdaptivePolicy');
135  applyPeer(node: KNode, reset: boolean): void {
136    if (reset) {
137      getUINativeModule().text.resetHeightAdaptivePolicy(node);
138    } else {
139      getUINativeModule().text.setHeightAdaptivePolicy(node, this.value!);
140    }
141  }
142  checkObjectDiff(): boolean {
143    return !isBaseOrResourceEqual(this.stageValue, this.value);
144  }
145}
146
147class TextDraggableModifier extends ModifierWithKey<boolean> {
148  constructor(value: boolean) {
149    super(value);
150  }
151  static identity: Symbol = Symbol('textDraggable');
152  applyPeer(node: KNode, reset: boolean): void {
153    if (reset) {
154      getUINativeModule().text.resetDraggable(node);
155    } else {
156      getUINativeModule().text.setDraggable(node, this.value!);
157    }
158  }
159  checkObjectDiff(): boolean {
160    return !isBaseOrResourceEqual(this.stageValue, this.value);
161  }
162}
163
164class TextPrivacySensitiveModifier extends ModifierWithKey<boolean> {
165  constructor(value: boolean) {
166    super(value);
167  }
168  static identity: Symbol = Symbol('textPrivacySensitive');
169  applyPeer(node: KNode, reset: boolean): void {
170    if (reset) {
171      getUINativeModule().text.resetPrivacySensitive(node);
172    } else {
173      getUINativeModule().text.setPrivacySensitive(node, this.value!);
174    }
175  }
176  checkObjectDiff(): boolean {
177    return !isBaseOrResourceEqual(this.stageValue, this.value);
178  }
179}
180
181class TextWordBreakModifier extends ModifierWithKey<WordBreak> {
182  constructor(value: WordBreak) {
183    super(value);
184  }
185  static identity: Symbol = Symbol('textWordBreak');
186  applyPeer(node: KNode, reset: boolean): void {
187    if (reset) {
188      getUINativeModule().text.resetWordBreak(node);
189    } else {
190      getUINativeModule().text.setWordBreak(node, this.value!);
191    }
192  }
193  checkObjectDiff(): boolean {
194    return !isBaseOrResourceEqual(this.stageValue, this.value);
195  }
196}
197
198class TextLineBreakStrategyModifier extends ModifierWithKey<LineBreakStrategy> {
199  constructor(value: LineBreakStrategy) {
200    super(value);
201  }
202  static identity: Symbol = Symbol('textLineBreakStrategy');
203  applyPeer(node: KNode, reset: boolean): void {
204    if (reset) {
205      getUINativeModule().text.resetLineBreakStrategy(node);
206    } else {
207      getUINativeModule().text.setLineBreakStrategy(node, this.value!);
208    }
209  }
210  checkObjectDiff(): boolean {
211    return !isBaseOrResourceEqual(this.stageValue, this.value);
212  }
213}
214class TextEllipsisModeModifier extends ModifierWithKey<EllipsisMode> {
215  constructor(value: EllipsisMode) {
216    super(value);
217  }
218  static identity: Symbol = Symbol('textEllipsisMode');
219  applyPeer(node: KNode, reset: boolean): void {
220    if (reset) {
221      getUINativeModule().text.resetEllipsisMode(node);
222    } else {
223      getUINativeModule().text.setEllipsisMode(node, this.value!);
224    }
225  }
226  checkObjectDiff(): boolean {
227    return !isBaseOrResourceEqual(this.stageValue, this.value);
228  }
229}
230
231class TextMinFontSizeModifier extends ModifierWithKey<number | string | Resource> {
232  constructor(value: number | string | Resource) {
233    super(value);
234  }
235  static identity: Symbol = Symbol('textMinFontSize');
236  applyPeer(node: KNode, reset: boolean): void {
237    if (reset) {
238      getUINativeModule().text.resetMinFontSize(node);
239    } else if (!isNumber(this.value) && !isString(this.value) && !isResource(this.value)) {
240      getUINativeModule().text.resetMinFontSize(node);
241    } else {
242      getUINativeModule().text.setMinFontSize(node, this.value!);
243    }
244  }
245
246  checkObjectDiff(): boolean {
247    return !isBaseOrResourceEqual(this.stageValue, this.value);
248  }
249}
250
251class TextMaxFontSizeModifier extends ModifierWithKey<number | string | Resource> {
252  constructor(value: number | string | Resource) {
253    super(value);
254  }
255  static identity: Symbol = Symbol('textMaxFontSize');
256  applyPeer(node: KNode, reset: boolean): void {
257    if (reset) {
258      getUINativeModule().text.resetMaxFontSize(node);
259    } else if (!isNumber(this.value) && !isString(this.value) && !isResource(this.value)) {
260      getUINativeModule().text.resetMaxFontSize(node);
261    } else {
262      getUINativeModule().text.setMaxFontSize(node, this.value!);
263    }
264  }
265
266  checkObjectDiff(): boolean {
267    return !isBaseOrResourceEqual(this.stageValue, this.value);
268  }
269}
270
271class TextMinFontScaleModifier extends ModifierWithKey<number | Resource> {
272  constructor(value: number | Resource) {
273    super(value);
274  }
275  static identity: Symbol = Symbol('textMinFontScale');
276  applyPeer(node: KNode, reset: boolean): void {
277    if (reset) {
278      getUINativeModule().text.resetMinFontScale(node);
279    } else if (!isNumber(this.value) && !isResource(this.value)) {
280      getUINativeModule().text.resetMinFontScale(node);
281    } else {
282      getUINativeModule().text.setMinFontScale(node, this.value!);
283    }
284  }
285
286  checkObjectDiff(): boolean {
287    return !isBaseOrResourceEqual(this.stageValue, this.value);
288  }
289}
290
291class TextMaxFontScaleModifier extends ModifierWithKey<number | Resource> {
292  constructor(value: number | Resource) {
293    super(value);
294  }
295  static identity: Symbol = Symbol('textMaxFontScale');
296  applyPeer(node: KNode, reset: boolean): void {
297    if (reset) {
298      getUINativeModule().text.resetMaxFontScale(node);
299    } else if (!isNumber(this.value) && !isResource(this.value)) {
300      getUINativeModule().text.resetMaxFontScale(node);
301    } else {
302      getUINativeModule().text.setMaxFontScale(node, this.value!);
303    }
304  }
305
306  checkObjectDiff(): boolean {
307    return !isBaseOrResourceEqual(this.stageValue, this.value);
308  }
309}
310
311class TextLineHeightModifier extends ModifierWithKey<number | string | Resource> {
312  constructor(value: number | string | Resource) {
313    super(value);
314  }
315  static identity: Symbol = Symbol('textLineHeight');
316  applyPeer(node: KNode, reset: boolean): void {
317    if (reset) {
318      getUINativeModule().text.resetLineHeight(node);
319    } else if (!isNumber(this.value) && !isString(this.value) && !isResource(this.value)) {
320      getUINativeModule().text.resetLineHeight(node);
321    } else {
322      getUINativeModule().text.setLineHeight(node, this.value!);
323    }
324  }
325
326  checkObjectDiff(): boolean {
327    return !isBaseOrResourceEqual(this.stageValue, this.value);
328  }
329}
330
331class TextCopyOptionModifier extends ModifierWithKey<CopyOptions> {
332  constructor(value: CopyOptions) {
333    super(value);
334  }
335  static identity: Symbol = Symbol('textCopyOption');
336  applyPeer(node: KNode, reset: boolean): void {
337    if (reset) {
338      getUINativeModule().text.resetCopyOption(node);
339    } else {
340      getUINativeModule().text.setCopyOption(node, this.value!);
341    }
342  }
343  checkObjectDiff(): boolean {
344    return !isBaseOrResourceEqual(this.stageValue, this.value);
345  }
346}
347
348class TextFontFamilyModifier extends ModifierWithKey<string | Resource> {
349  constructor(value: string | Resource) {
350    super(value);
351  }
352  static identity: Symbol = Symbol('textFontFamily');
353  applyPeer(node: KNode, reset: boolean): void {
354    if (reset) {
355      getUINativeModule().text.resetFontFamily(node);
356    } else if (!isString(this.value) && !isResource(this.value)) {
357      getUINativeModule().text.resetFontFamily(node);
358    } else {
359      getUINativeModule().text.setFontFamily(node, this.value!);
360    }
361  }
362
363  checkObjectDiff(): boolean {
364    return !isBaseOrResourceEqual(this.stageValue, this.value);
365  }
366}
367
368class TextMaxLinesModifier extends ModifierWithKey<number> {
369  constructor(value: number) {
370    super(value);
371  }
372  static identity: Symbol = Symbol('textMaxLines');
373  applyPeer(node: KNode, reset: boolean): void {
374    if (reset) {
375      getUINativeModule().text.resetMaxLines(node);
376    } else if (!isNumber(this.value)) {
377      getUINativeModule().text.resetMaxLines(node);
378    } else {
379      getUINativeModule().text.setMaxLines(node, this.value!);
380    }
381  }
382  checkObjectDiff(): boolean {
383    return !isBaseOrResourceEqual(this.stageValue, this.value);
384  }
385}
386
387class TextLetterSpacingModifier extends ModifierWithKey<number | string> {
388  constructor(value: number | string) {
389    super(value);
390  }
391  static identity: Symbol = Symbol('textLetterSpacing');
392  applyPeer(node: KNode, reset: boolean): void {
393    if (reset) {
394      getUINativeModule().text.resetLetterSpacing(node);
395    } else if (!isNumber(this.value) && !isString(this.value)) {
396      getUINativeModule().text.resetLetterSpacing(node);
397    } else {
398      getUINativeModule().text.setLetterSpacing(node, this.value!);
399    }
400  }
401  checkObjectDiff(): boolean {
402    return !isBaseOrResourceEqual(this.stageValue, this.value);
403  }
404}
405
406class TextLineSpacingModifier extends ModifierWithKey<LengthMetrics> {
407  constructor(value: LengthMetrics) {
408    super(value);
409  }
410  static identity: Symbol = Symbol('textLineSpacing');
411  applyPeer(node: KNode, reset: boolean): void {
412    if (reset) {
413      getUINativeModule().text.resetLineSpacing(node);
414    } else if (!isObject(this.value)) {
415      getUINativeModule().text.resetLineSpacing(node);
416    } else {
417      getUINativeModule().text.setLineSpacing(node, this.value.value, this.value.unit);
418    }
419  }
420
421  checkObjectDiff(): boolean {
422    return !isBaseOrResourceEqual(this.stageValue, this.value);
423  }
424}
425
426class TextTextOverflowModifier extends ModifierWithKey<{ overflow: TextOverflow }> {
427  constructor(value: { overflow: TextOverflow }) {
428    super(value);
429  }
430  static identity: Symbol = Symbol('textTextOverflow');
431  applyPeer(node: KNode, reset: boolean): void {
432    if (reset) {
433      getUINativeModule().text.resetTextOverflow(node);
434    } else {
435      getUINativeModule().text.setTextOverflow(node, this.value.overflow);
436    }
437  }
438  checkObjectDiff(): boolean {
439    return !isBaseOrResourceEqual(this.stageValue.overflow, this.value.overflow);
440  }
441}
442
443class TextBaselineOffsetModifier extends ModifierWithKey<number | string> {
444  constructor(value: number | string) {
445    super(value);
446  }
447  static identity: symbol = Symbol('textBaselineOffset');
448  applyPeer(node: KNode, reset: boolean): void {
449    if (reset) {
450      getUINativeModule().text.resetBaselineOffset(node);
451    } else if (!isNumber(this.value) && !isString(this.value)) {
452      getUINativeModule().text.resetBaselineOffset(node);
453    } else {
454      getUINativeModule().text.setBaselineOffset(node, this.value!);
455    }
456  }
457  checkObjectDiff(): boolean {
458    return !isBaseOrResourceEqual(this.stageValue, this.value);
459  }
460}
461
462class TextTextCaseModifier extends ModifierWithKey<TextCase> {
463  constructor(value: TextCase) {
464    super(value);
465  }
466  static identity: symbol = Symbol('textTextCase');
467  applyPeer(node: KNode, reset: boolean): void {
468    if (reset) {
469      getUINativeModule().text.resetTextCase(node);
470    } else {
471      getUINativeModule().text.setTextCase(node, this.value!);
472    }
473  }
474  checkObjectDiff(): boolean {
475    return !isBaseOrResourceEqual(this.stageValue, this.value);
476  }
477}
478
479class TextTextIndentModifier extends ModifierWithKey<Length> {
480  constructor(value: Length) {
481    super(value);
482  }
483  static identity: symbol = Symbol('textTextIndent');
484  applyPeer(node: KNode, reset: boolean): void {
485    if (reset) {
486      getUINativeModule().text.resetTextIndent(node);
487    } else if (!isNumber(this.value) && !isString(this.value) && !isResource(this.value)) {
488      getUINativeModule().text.resetTextIndent(node);
489    } else {
490      getUINativeModule().text.setTextIndent(node, this.value!);
491    }
492  }
493
494  checkObjectDiff(): boolean {
495    return !isBaseOrResourceEqual(this.stageValue, this.value);
496  }
497}
498
499class TextTextShadowModifier extends ModifierWithKey<ShadowOptions | Array<ShadowOptions>> {
500  constructor(value: ShadowOptions | Array<ShadowOptions>) {
501    super(value);
502  }
503  static identity: Symbol = Symbol('textTextShadow');
504  applyPeer(node: KNode, reset: boolean): void {
505    if (reset) {
506      getUINativeModule().text.resetTextShadow(node);
507    } else {
508      let shadow: ArkShadowInfoToArray = new ArkShadowInfoToArray();
509      if (!shadow.convertShadowOptions(this.value)) {
510        getUINativeModule().text.resetTextShadow(node);
511      } else {
512        getUINativeModule().text.setTextShadow(node, shadow.radius,
513          shadow.type, shadow.color, shadow.offsetX, shadow.offsetY, shadow.fill, shadow.radius.length);
514      }
515    }
516  }
517
518  checkObjectDiff(): boolean {
519    let checkDiff = true;
520    let arkShadow = new ArkShadowInfoToArray();
521    if (Object.getPrototypeOf(this.stageValue).constructor === Object &&
522      Object.getPrototypeOf(this.value).constructor === Object) {
523      checkDiff = arkShadow.checkDiff(<ShadowOptions> this.stageValue, <ShadowOptions> this.value);
524    } else if (Object.getPrototypeOf(this.stageValue).constructor === Array &&
525      Object.getPrototypeOf(this.value).constructor === Array &&
526      (<Array<ShadowOptions>> this.stageValue).length === (<Array<ShadowOptions>> this.value).length) {
527      let isDiffItem = false;
528      for (let i: number = 0; i < (<Array<ShadowOptions>> this.value).length; i++) {
529        if (arkShadow.checkDiff(this.stageValue[i], this.value[1])) {
530          isDiffItem = true;
531          break;
532        }
533      }
534      if (!isDiffItem) {
535        checkDiff = false;
536      }
537    }
538    return checkDiff;
539  }
540}
541
542class TextDecorationModifier extends ModifierWithKey<{ type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }> {
543  constructor(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }) {
544    super(value);
545  }
546  static identity: Symbol = Symbol('textDecoration');
547  applyPeer(node: KNode, reset: boolean): void {
548    if (reset) {
549      getUINativeModule().text.resetDecoration(node);
550    } else {
551      getUINativeModule().text.setDecoration(node, this.value!.type, this.value!.color, this.value!.style);
552    }
553  }
554
555  checkObjectDiff(): boolean {
556    if (this.stageValue.type !== this.value.type || this.stageValue.style !== this.value.style) {
557      return true;
558    }
559    if (isResource(this.stageValue.color) && isResource(this.value.color)) {
560      return !isResourceEqual(this.stageValue.color, this.value.color);
561    } else if (!isResource(this.stageValue.color) && !isResource(this.value.color)) {
562      return !(this.stageValue.color === this.value.color);
563    } else {
564      return true;
565    }
566  }
567}
568
569class TextFontModifier extends ModifierWithKey<Font> {
570  constructor(value: Font) {
571    super(value);
572  }
573  static identity: Symbol = Symbol('textFont');
574  applyPeer(node: KNode, reset: boolean): void {
575    if (reset) {
576      getUINativeModule().text.resetFont(node);
577    } else {
578      getUINativeModule().text.setFont(node, this.value.size, this.value.weight, this.value.family, this.value.style);
579    }
580  }
581
582  checkObjectDiff(): boolean {
583    if (this.stageValue.weight !== this.value.weight || this.stageValue.style !== this.value.style) {
584      return true;
585    }
586    if (((isResource(this.stageValue.size) && isResource(this.value.size) &&
587      isResourceEqual(this.stageValue.size, this.value.size)) ||
588      (!isResource(this.stageValue.size) && !isResource(this.value.size) &&
589        this.stageValue.size === this.value.size)) &&
590      ((isResource(this.stageValue.family) && isResource(this.value.family) &&
591        isResourceEqual(this.stageValue.family, this.value.family)) ||
592        (!isResource(this.stageValue.family) && !isResource(this.value.family) &&
593          this.stageValue.family === this.value.family))) {
594      return false;
595    } else {
596      return true;
597    }
598  }
599}
600
601class TextClipModifier extends ModifierWithKey<boolean | object> {
602  constructor(value: boolean | object) {
603    super(value);
604  }
605  static identity: Symbol = Symbol('textClip');
606  applyPeer(node: KNode, reset: boolean): void {
607    if (reset) {
608      getUINativeModule().common.resetClipWithEdge(node);
609    } else {
610      getUINativeModule().common.setClipWithEdge(node, this.value);
611    }
612  }
613
614  checkObjectDiff(): boolean {
615    return true;
616  }
617}
618
619class TextFontFeatureModifier extends ModifierWithKey<FontFeature> {
620  constructor(value: FontFeature) {
621    super(value);
622  }
623  static identity: Symbol = Symbol('textFontFeature');
624  applyPeer(node: KNode, reset: boolean): void {
625    if (reset) {
626      getUINativeModule().text.resetFontFeature(node);
627    } else {
628      getUINativeModule().text.setFontFeature(node, this.value!);
629    }
630  }
631  checkObjectDiff(): boolean {
632    return !isBaseOrResourceEqual(this.stageValue, this.value);
633  }
634}
635
636class TextContentModifier extends ModifierWithKey<string | Resource> {
637  constructor(value: string | Resource) {
638    super(value);
639  }
640  static identity: Symbol = Symbol('textContent');
641  applyPeer(node: KNode, reset: boolean): void {
642    if (reset) {
643      getUINativeModule().text.setContent(node, '');
644    }
645    else {
646      getUINativeModule().text.setContent(node, this.value);
647    }
648  }
649}
650
651class TextSelectionModifier extends ModifierWithKey<ArkSelection> {
652  constructor(value: ArkSelection) {
653    super(value);
654  }
655  static identity: Symbol = Symbol('textSelection');
656  applyPeer(node: KNode, reset: boolean): void {
657    if (reset) {
658      getUINativeModule().text.resetSelection(node);
659    } else {
660      getUINativeModule().text.setSelection(node, this.value.selectionStart, this.value.selectionEnd);
661    }
662  }
663  checkObjectDiff(): boolean {
664    return !isBaseOrResourceEqual(this.stageValue.selectionStart, this.value.selectionStart) ||
665    !isBaseOrResourceEqual(this.stageValue.selectionEnd, this.value.selectionEnd);
666  }
667}
668
669class TextSelectableModifier extends ModifierWithKey<TextSelectableMode> {
670  constructor(value: TextSelectableMode) {
671    super(value);
672  }
673  static identity: Symbol = Symbol('textTextSelectable');
674  applyPeer(node: KNode, reset: boolean): void {
675    if (reset) {
676      getUINativeModule().text.resetTextSelectableMode(node);
677    } else {
678      getUINativeModule().text.setTextSelectableMode(node, this.value!);
679    }
680  }
681  checkObjectDiff(): boolean {
682    return !isBaseOrResourceEqual(this.stageValue, this.value);
683  }
684}
685
686class TextDataDetectorConfigModifier extends ModifierWithKey<TextDataDetectorConfig> {
687  constructor(value: TextDataDetectorConfig) {
688    super(value);
689  }
690  static identity: Symbol = Symbol('textDataDetectorConfig');
691  applyPeer(node: KNode, reset: boolean): void {
692    if (reset) {
693      getUINativeModule().text.resetDataDetectorConfig(node);
694    } else {
695      getUINativeModule().text.setDataDetectorConfig(node, this.value.types, this.value.onDetectResultUpdate);
696    }
697  }
698  checkObjectDiff(): boolean {
699    return !isBaseOrResourceEqual(this.stageValue.types, this.value.types) ||
700    !isBaseOrResourceEqual(this.stageValue.onDetectResultUpdate, this.value.onDetectResultUpdate);
701  }
702}
703
704class TextOnCopyModifier extends ModifierWithKey<(value: string) => void> {
705  constructor(value: (value: string) => void) {
706    super(value);
707  }
708  static identity: Symbol = Symbol('textOnCopy');
709  applyPeer(node: KNode, reset: boolean): void {
710    if (reset) {
711      getUINativeModule().text.resetOnCopy(node);
712    } else {
713      getUINativeModule().text.setOnCopy(node, this.value);
714    }
715  }
716}
717
718class TextOnTextSelectionChangeModifier extends ModifierWithKey<(selectionStart: number,
719    selectionEnd: number) => void> {
720  constructor(value: (selectionStart: number, selectionEnd: number) => void) {
721    super(value);
722  }
723  static identity: Symbol = Symbol('textOnTextSelectionChange');
724  applyPeer(node: KNode, reset: boolean): void {
725    if (reset) {
726      getUINativeModule().text.resetOnTextSelectionChange(node);
727    } else {
728      getUINativeModule().text.setOnTextSelectionChange(node, this.value);
729    }
730  }
731}
732
733class TextControllerModifier extends ModifierWithKey<TextOptions> {
734  constructor(value: TextOptions) {
735    super(value);
736  }
737  static identity: Symbol = Symbol('textController');
738  applyPeer(node: KNode, reset: boolean): void {
739    if (reset) {
740      getUINativeModule().text.setTextController(node, '');
741    }
742    else {
743      getUINativeModule().text.setTextController(node, this.value);
744    }
745  }
746}
747
748class TextEditMenuOptionsModifier extends ModifierWithKey<EditMenuOptions> {
749  constructor(value: EditMenuOptions) {
750    super(value);
751  }
752  static identity: Symbol = Symbol('textEditMenuOptions');
753  applyPeer(node: KNode, reset: boolean): void {
754    if (reset) {
755      getUINativeModule().text.resetSelectionMenuOptions(node);
756    } else {
757      getUINativeModule().text.setSelectionMenuOptions(node, this.value);
758    }
759  }
760}
761
762class TextHalfLeadingModifier extends ModifierWithKey<boolean> {
763  constructor(value: boolean) {
764    super(value);
765  }
766  static identity: Symbol = Symbol('textHalfLeading');
767  applyPeer(node: KNode, reset: boolean): void {
768    if (reset) {
769      getUINativeModule().text.resetHalfLeading(node);
770    } else {
771      getUINativeModule().text.setHalfLeading(node, this.value!);
772    }
773  }
774  checkObjectDiff(): boolean {
775    return !isBaseOrResourceEqual(this.stageValue, this.value);
776  }
777}
778
779class ArkTextComponent extends ArkComponent implements TextAttribute {
780  constructor(nativePtr: KNode, classType?: ModifierType) {
781    super(nativePtr, classType);
782  }
783  allowChildTypes(): string[] {
784    return ['Span', 'ImageSpan', 'SymbolSpan', 'ContainerSpan'];
785  }
786  initialize(value: Object[]): void {
787    modifierWithKey(this._modifiersWithKeys, TextContentModifier.identity, TextContentModifier, value[0]);
788    modifierWithKey(this._modifiersWithKeys, TextControllerModifier.identity, TextControllerModifier, value[1]);
789    return this;
790  }
791  enableDataDetector(value: boolean): this {
792    modifierWithKey(this._modifiersWithKeys, TextEnableDataDetectorModifier.identity, TextEnableDataDetectorModifier, value);
793    return this;
794  }
795  dataDetectorConfig(config: TextDataDetectorConfig): this {
796    let detectorConfig = new TextDataDetectorConfig();
797    detectorConfig.types = config.types;
798    detectorConfig.onDetectResultUpdate = config.onDetectResultUpdate;
799    modifierWithKey(this._modifiersWithKeys, TextDataDetectorConfigModifier.identity, TextDataDetectorConfigModifier, detectorConfig);
800    return this;
801  }
802  font(value: Font): TextAttribute {
803    modifierWithKey(this._modifiersWithKeys, TextFontModifier.identity, TextFontModifier, value);
804    return this;
805  }
806  fontColor(value: ResourceColor): TextAttribute {
807    modifierWithKey(this._modifiersWithKeys, FontColorModifier.identity, FontColorModifier, value);
808    return this;
809  }
810  fontSize(value: number | string | Resource): TextAttribute {
811    modifierWithKey(this._modifiersWithKeys, FontSizeModifier.identity, FontSizeModifier, value);
812    return this;
813  }
814  minFontSize(value: number | string | Resource): TextAttribute {
815    modifierWithKey(this._modifiersWithKeys, TextMinFontSizeModifier.identity, TextMinFontSizeModifier, value);
816    return this;
817  }
818  maxFontSize(value: number | string | Resource): TextAttribute {
819    modifierWithKey(this._modifiersWithKeys, TextMaxFontSizeModifier.identity, TextMaxFontSizeModifier, value);
820    return this;
821  }
822  minFontScale(value: number | Resource): TextAttribute {
823    modifierWithKey(this._modifiersWithKeys, TextMinFontScaleModifier.identity, TextMinFontScaleModifier, value);
824    return this;
825  }
826  maxFontScale(value: number | Resource): TextAttribute {
827    modifierWithKey(this._modifiersWithKeys, TextMaxFontScaleModifier.identity, TextMaxFontScaleModifier, value);
828    return this;
829  }
830  fontStyle(value: FontStyle): TextAttribute {
831    modifierWithKey(this._modifiersWithKeys, FontStyleModifier.identity, FontStyleModifier, value);
832    return this;
833  }
834  fontWeight(value: number | FontWeight | string): TextAttribute {
835    let fontWeightStr: string = '400';
836    if (isNumber(value)) {
837      fontWeightStr = value.toString();
838    } else if (isString(value)) {
839      fontWeightStr = String(value);
840    }
841    modifierWithKey(this._modifiersWithKeys, FontWeightModifier.identity, FontWeightModifier, fontWeightStr);
842    return this;
843  }
844  textAlign(value: TextAlign): TextAttribute {
845    modifierWithKey(this._modifiersWithKeys, TextAlignModifier.identity, TextAlignModifier, value);
846    return this;
847  }
848  lineHeight(value: number | string | Resource): TextAttribute {
849    modifierWithKey(this._modifiersWithKeys, TextLineHeightModifier.identity, TextLineHeightModifier, value);
850    return this;
851  }
852  textOverflow(value: { overflow: TextOverflow }): TextAttribute {
853    modifierWithKey(this._modifiersWithKeys, TextTextOverflowModifier.identity, TextTextOverflowModifier, value);
854    return this;
855  }
856  fontFamily(value: string | Resource): TextAttribute {
857    modifierWithKey(this._modifiersWithKeys, TextFontFamilyModifier.identity, TextFontFamilyModifier, value);
858    return this;
859  }
860  maxLines(value: number): TextAttribute {
861    modifierWithKey(this._modifiersWithKeys, TextMaxLinesModifier.identity, TextMaxLinesModifier, value);
862    return this;
863  }
864  decoration(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }): TextAttribute {
865    modifierWithKey(this._modifiersWithKeys, TextDecorationModifier.identity, TextDecorationModifier, value);
866    return this;
867  }
868  letterSpacing(value: number | string): TextAttribute {
869    modifierWithKey(this._modifiersWithKeys, TextLetterSpacingModifier.identity, TextLetterSpacingModifier, value);
870    return this;
871  }
872  lineSpacing(value: LengthMetrics): TextAttribute {
873    modifierWithKey(this._modifiersWithKeys, TextLineSpacingModifier.identity, TextLineSpacingModifier, value);
874    return this;
875  }
876  textCase(value: TextCase): TextAttribute {
877    modifierWithKey(this._modifiersWithKeys, TextTextCaseModifier.identity, TextTextCaseModifier, value);
878    return this;
879  }
880  baselineOffset(value: number | string): TextAttribute {
881    modifierWithKey(this._modifiersWithKeys, TextBaselineOffsetModifier.identity, TextBaselineOffsetModifier, value);
882    return this;
883  }
884  copyOption(value: CopyOptions): TextAttribute {
885    modifierWithKey(this._modifiersWithKeys, TextCopyOptionModifier.identity, TextCopyOptionModifier, value);
886    return this;
887  }
888  draggable(value: boolean): this {
889    modifierWithKey(this._modifiersWithKeys, TextDraggableModifier.identity, TextDraggableModifier, value);
890    return this;
891  }
892  privacySensitive(value: boolean): this {
893    modifierWithKey(this._modifiersWithKeys, TextPrivacySensitiveModifier.identity, TextPrivacySensitiveModifier, value);
894    return this;
895  }
896  textShadow(value: ShadowOptions | Array<ShadowOptions>): TextAttribute {
897    modifierWithKey(this._modifiersWithKeys, TextTextShadowModifier.identity, TextTextShadowModifier, value);
898    return this;
899  }
900  heightAdaptivePolicy(value: TextHeightAdaptivePolicy): TextAttribute {
901    modifierWithKey(this._modifiersWithKeys, TextHeightAdaptivePolicyModifier.identity, TextHeightAdaptivePolicyModifier, value);
902    return this;
903  }
904  textIndent(value: Length): TextAttribute {
905    modifierWithKey(this._modifiersWithKeys, TextTextIndentModifier.identity, TextTextIndentModifier, value);
906    return this;
907  }
908  wordBreak(value: WordBreak): TextAttribute {
909    modifierWithKey(this._modifiersWithKeys, TextWordBreakModifier.identity, TextWordBreakModifier, value);
910    return this;
911  }
912  lineBreakStrategy(value: LineBreakStrategy): TextAttribute {
913    modifierWithKey(this._modifiersWithKeys, TextLineBreakStrategyModifier.identity,
914      TextLineBreakStrategyModifier, value);
915    return this;
916  }
917  onCopy(callback: (value: string) => void): TextAttribute {
918    modifierWithKey(this._modifiersWithKeys, TextOnCopyModifier.identity,
919      TextOnCopyModifier, callback);
920    return this;
921  }
922  selection(selectionStart: number, selectionEnd: number): TextAttribute {
923    let arkSelection = new ArkSelection();
924    arkSelection.selectionStart = selectionStart;
925    arkSelection.selectionEnd = selectionEnd;
926    modifierWithKey(this._modifiersWithKeys, TextSelectionModifier.identity, TextSelectionModifier, arkSelection);
927    return this;
928  }
929  textSelectable(value: TextSelectableMode): TextAttribute {
930    modifierWithKey(this._modifiersWithKeys, TextSelectableModifier.identity, TextSelectableModifier, value);
931    return this;
932  }
933  ellipsisMode(value: EllipsisMode): TextAttribute {
934    modifierWithKey(this._modifiersWithKeys, TextEllipsisModeModifier.identity, TextEllipsisModeModifier, value);
935    return this;
936  }
937  fontFeature(value: FontFeature): TextAttribute {
938    modifierWithKey(this._modifiersWithKeys, TextFontFeatureModifier.identity, TextFontFeatureModifier, value);
939    return this;
940  }
941  clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this {
942    modifierWithKey(this._modifiersWithKeys, TextClipModifier.identity, TextClipModifier, value);
943    return this;
944  }
945  foregroundColor(value: ResourceColor | ColoringStrategy): void {
946    modifierWithKey(
947      this._modifiersWithKeys, TextForegroundColorModifier.identity, TextForegroundColorModifier, value);
948    return this;
949  }
950  onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): this {
951    modifierWithKey(this._modifiersWithKeys, TextOnTextSelectionChangeModifier.identity,
952      TextOnTextSelectionChangeModifier, callback);
953    return this;
954  }
955  editMenuOptions(value: EditMenuOptions): this {
956    modifierWithKey(this._modifiersWithKeys, TextEditMenuOptionsModifier.identity,
957      TextEditMenuOptionsModifier, value);
958    return this;
959  }
960  halfLeading(value: boolean): TextAttribute {
961    modifierWithKey(this._modifiersWithKeys, TextHalfLeadingModifier.identity,
962      TextHalfLeadingModifier, value);
963    return this;
964  }
965}
966// @ts-ignore
967globalThis.Text.attributeModifier = function (modifier: ArkComponent): void {
968  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
969    return new ArkTextComponent(nativePtr);
970  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
971    return new modifierJS.TextModifier(nativePtr, classType);
972  });
973};
974