• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2025 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
16import { Resource } from "@ohos.arkui.external.resource";
17import { StyledString } from "@ohos.arkui.component.styledString";
18import { ComponentBuilder, CommonMethod } from "@ohos.arkui.component.common";
19import { ResourceColor, Length } from "@ohos.arkui.component.units";
20import { memo } from '@ohos.arkui.stateManagement.runtime';
21
22export declare class TextController {
23    closeSelectionMenu(): void;
24    setStyledString(value: StyledString): void;
25
26    // getLayoutManager(): LayoutManager;
27}
28
29export declare interface TextOptions {
30    controller: TextController;
31}
32
33export declare interface TextAttribute extends CommonMethod {
34    // @memo
35    // font(value: Font, options?: FontSettingOptions): this;
36    @memo
37    fontColor(value: ResourceColor): this;
38    @memo
39    fontSize(value: number | string | Resource): this;
40    @memo
41    minFontSize(value: number | string | Resource): this;
42    @memo
43    maxFontSize(value: number | string | Resource): this;
44    @memo
45    minFontScale(scale: number | Resource): this;
46    @memo
47    maxFontScale(scale: number | Resource): this;
48    // @memo
49    // fontStyle(value: FontStyle): this;
50    // @memo
51    // fontWeight(value: number | FontWeight | string): this;
52    // @memo
53    // fontWeight(weight: number | FontWeight | string, options?: FontSettingOptions): this;
54    // @memo
55    // lineSpacing(value: LengthMetrics): this;
56    // @memo
57    // textAlign(value: TextAlign): this;
58    @memo
59    lineHeight(value: number | string | Resource): this;
60    // @memo
61    // textOverflow(options: TextOverflowOptions): this;
62    @memo
63    fontFamily(value: string | Resource): this;
64    @memo
65    maxLines(value: number): this;
66    // @memo
67    // decoration(value: DecorationStyleInterface): this;
68    @memo
69    letterSpacing(value: number | string): this;
70    // @memo
71    // textCase(value: TextCase): this;
72    @memo
73    baselineOffset(value: number | string): this;
74    // @memo
75    // copyOption(value: CopyOptions): this;
76    @memo
77    draggable(value: boolean): this;
78    // @memo
79    // textShadow(value: ShadowOptions | Array<ShadowOptions>): this;
80    // @memo
81    // heightAdaptivePolicy(value: TextHeightAdaptivePolicy): this;
82    @memo
83    textIndent(value: Length): this;
84    // @memo
85    // wordBreak(value: WordBreak): this;
86    // @memo
87    // lineBreakStrategy(strategy: LineBreakStrategy): this;
88    @memo
89    onCopy(callback: (value: string) => void): this;
90    @memo
91    selection(selectionStart: number, selectionEnd: number): this;
92    @memo
93    caretColor(color: ResourceColor): this;
94    @memo
95    selectedBackgroundColor(color: ResourceColor): this;
96    // @memo
97    // ellipsisMode(value: EllipsisMode): this;
98    @memo
99    enableDataDetector(enable: boolean): this;
100    // @memo
101    // dataDetectorConfig(config: TextDataDetectorConfig): this;
102    // @memo
103    // bindSelectionMenu(spanType: TextSpanType, content: CustomBuilder, responseType: TextResponseType,
104    //   options?: SelectionMenuOptions): this;
105    @memo
106    onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): this;
107    @memo
108    fontFeature(value: string): this;
109    // @memo
110    // marqueeOptions(options: Optional<TextMarqueeOptions>): this;
111    // @memo
112    // onMarqueeStateChange(callback: Callback<MarqueeState>): this;
113    @memo
114    privacySensitive(supported: boolean): this;
115    // @memo
116    // textSelectable(mode: TextSelectableMode): this;
117    // @memo
118    // editMenuOptions(editMenu: EditMenuOptions): this;
119    @memo
120    halfLeading(halfLeading: boolean): this;
121    @memo
122    enableHapticFeedback(isEnabled: boolean): this;
123}
124
125@memo
126@ComponentBuilder
127export declare function Text (
128    value?: string | Resource,
129    options?: TextOptions,
130    @memo
131    content?: () => void
132): TextAttribute;
133