From 5ec79398bb6b901b023a0f84d19709a41197c6b6 Mon Sep 17 00:00:00 2001 From: yao_qiaoming1 Date: Mon, 1 Sep 2025 22:34:11 +0800 Subject: [PATCH] =?UTF-8?q?[RichEditor]=E5=A2=9E=E5=8A=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yao_qiaoming1 --- api/arkui/component/richEditor.static.d.ets | 231 ++++++++++++-------- api/arkui/component/textCommon.static.d.ets | 14 +- 2 files changed, 143 insertions(+), 102 deletions(-) diff --git a/api/arkui/component/richEditor.static.d.ets b/api/arkui/component/richEditor.static.d.ets index d425043dc1..505c161698 100644 --- a/api/arkui/component/richEditor.static.d.ets +++ b/api/arkui/component/richEditor.static.d.ets @@ -136,6 +136,30 @@ export declare enum RichEditorResponseType { */ DEFAULT = 3 } +/** + * Defines undo style. + * + * @enum { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare enum UndoStyle { + /** + * Undo without style. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + CLEAR_STYLE = 0, + + /** + * Undo keep style. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + KEEP_STYLE = 1, +} /** * Defines the span position. * @@ -147,21 +171,21 @@ export declare interface RichEditorSpanPosition { /** * Define the index of span. * - * @type { number } + * @type { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - spanIndex: number; + spanIndex: int; /** * The range of span. * - * @type { [number, number] } + * @type { [int, int] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ spanRange: [ - number, - number + int, + int ]; } /** @@ -183,11 +207,11 @@ export declare interface RichEditorTextStyle { /** * font size. * - * @type { ?(Length | number) } + * @type { ?(Length | double) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontSize?: Length | number; + fontSize?: Length | double; /** * font style. * @@ -199,11 +223,11 @@ export declare interface RichEditorTextStyle { /** * font weight. * - * @type { ?(number | FontWeight | string) } + * @type { ?(int | FontWeight | string) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontWeight?: number | FontWeight | string; + fontWeight?: int | FontWeight | string; /** * font family. * @@ -231,19 +255,19 @@ export declare interface RichEditorTextStyle { /** * letter spacing. * - * @type { ?(number | string) } + * @type { ?(double | string) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - letterSpacing?: number | string; + letterSpacing?: double | string; /** * line height. * - * @type { ? (number | string | Resource) } + * @type { ? (double | string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - lineHeight?: number | string | Resource; + lineHeight?: double | string | Resource; /** * Set the text with half leading. * @@ -345,11 +369,11 @@ export declare interface RichEditorParagraphStyle { /** * Set paragraph spacing. * - * @type { ?number } + * @type { ?double } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - paragraphSpacing?: number; + paragraphSpacing?: double; } /** * Defines the paste event. @@ -362,11 +386,10 @@ export declare interface PasteEvent { /** * Override system paste event. * - * @type { ?VoidCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - preventDefault?: VoidCallback; + preventDefault(): void; } /** * Defines the text span. @@ -481,11 +504,11 @@ export declare interface RichEditorSymbolSpanStyle { /** * The font size. * - * @type { ?(number | string | Resource) } + * @type { ?(double | string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontSize?: number | string | Resource; + fontSize?: double | string | Resource; /** * The font color. * @@ -497,11 +520,11 @@ export declare interface RichEditorSymbolSpanStyle { /** * The font weight. * - * @type { ?(number | FontWeight | string) } + * @type { ?(int | FontWeight | string) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontWeight?: number | FontWeight | string; + fontWeight?: int | FontWeight | string; /** * The symbol span effect strategy. * @@ -538,11 +561,11 @@ export declare interface RichEditorTextStyleResult { /** * font size. * - * @type { number } + * @type { double } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontSize: number; + fontSize: double; /** * font style. * @@ -554,11 +577,11 @@ export declare interface RichEditorTextStyleResult { /** * font weight. * - * @type { number } + * @type { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontWeight: number; + fontWeight: int; /** * font family. * @@ -586,19 +609,19 @@ export declare interface RichEditorTextStyleResult { /** * letter spacing. * - * @type { ?number } + * @type { ?double } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - letterSpacing?: number; + letterSpacing?: double; /** * line height. * - * @type { ?number } + * @type { ?double } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - lineHeight?: number; + lineHeight?: double; /** * Set the text with half leading. * @@ -648,13 +671,13 @@ export declare interface RichEditorParagraphResult { /** * The range of paragraph based on character indices. * - * @type { [number, number] } + * @type { [int, int] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ range: [ - number, - number + int, + int ]; } /** @@ -668,11 +691,11 @@ export declare interface RichEditorSymbolSpanStyleResult { /** * The font size. * - * @type { number | string | Resource } + * @type { double | string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontSize: number | string | Resource; + fontSize: double | string | Resource; /** * The font color. * @@ -684,11 +707,11 @@ export declare interface RichEditorSymbolSpanStyleResult { /** * The font weight. * - * @type { number | FontWeight | string } + * @type { int | FontWeight | string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - fontWeight: number | FontWeight | string; + fontWeight: int | FontWeight | string; /** * The symbol span effect strategy. * @@ -741,13 +764,13 @@ export declare interface RichEditorTextSpanResult { /** * get offset in span. * - * @type { [number, number] } + * @type { [int, int] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ offsetInSpan: [ - number, - number + int, + int ]; /** * Symbol span style. @@ -801,13 +824,13 @@ export declare interface RichEditorImageSpanStyleResult { /** * image size. * - * @type { [number, number] } + * @type { [int, int] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ size: [ - number, - number + int, + int ]; /** * image vertical align. @@ -877,13 +900,13 @@ export declare interface RichEditorImageSpanResult { /** * get offset in span. * - * @type { [number, number] } + * @type { [int, int] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ offsetInSpan: [ - number, - number + int, + int ]; } /** @@ -930,21 +953,21 @@ export declare interface RichEditorRange { /** * start offset. * - * @type { ?number } + * @type { ?int } * @default 0 * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - start?: number; + start?: int; /** * end offset. * - * @type { ?number } + * @type { ?int } * @default text length * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - end?: number; + end?: int; } /** * Defines the richEditor Gestures. @@ -991,11 +1014,11 @@ export declare interface RichEditorTextSpanOptions { /** * the offset that add a text span at. * - * @type { ?number } + * @type { ?int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - offset?: number; + offset?: int; /** * text style. * @@ -1057,11 +1080,11 @@ export declare interface RichEditorImageSpanOptions { /** * the offset that add image span at. * - * @type { ?number } + * @type { ?int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - offset?: number; + offset?: int; /** * image style. * @@ -1098,11 +1121,11 @@ export declare interface RichEditorBuilderSpanOptions { /** * The offset that add custom builder span at. * - * @type { ?number } Indicates the index where the builder will be inserted + * @type { ?int } Indicates the index where the builder will be inserted * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - offset?: number; + offset?: int; /** * builder span drag background color * @@ -1248,11 +1271,11 @@ export declare interface RichEditorSymbolSpanOptions { /** * The offset that add custom symbol span at. * - * @type { ?number } + * @type { ?int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - offset?: number; + offset?: int; /** * The style that add custom symbol span at. * @@ -1273,13 +1296,13 @@ export declare interface RichEditorSelection { /** * The location info. * - * @type { [number, number] } + * @type { [int, int] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ selection: [ - number, - number + int, + int ]; /** * The selected text content. @@ -1301,11 +1324,11 @@ export declare interface RichEditorInsertValue { /** * The location info where the value will be inserted. * - * @type { number } + * @type { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - insertOffset: number; + insertOffset: int; /** * The inserted value. * @@ -1334,11 +1357,11 @@ export declare interface RichEditorDeleteValue { /** * The offset of deleting. * - * @type { number } + * @type { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - offset: number; + offset: int; /** * The deleted direction. * @@ -1350,11 +1373,11 @@ export declare interface RichEditorDeleteValue { /** * The deleted text length. * - * @type { number } + * @type { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - length: number; + length: int; /** * The deleted span object. * @@ -1524,20 +1547,20 @@ export declare class RichEditorBaseController implements TextEditControllerEx { /** * Get caret offset from controller. * - * @returns { number } + * @returns { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - getCaretOffset(): number; + getCaretOffset(): int; /** * Set caret offset. * - * @param { number } offset - caret offset. + * @param { int } offset - caret offset. * @returns { boolean } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - setCaretOffset(offset: number): boolean; + setCaretOffset(offset: int): boolean; /** * close the select menu when menu is on. * @@ -1564,13 +1587,13 @@ export declare class RichEditorBaseController implements TextEditControllerEx { /** * Specify the start and end positions to select a range of content. * - * @param { number } selectionStart - The start position of the selected text. - * @param { number } selectionEnd - The end position of the selected text. + * @param { int } selectionStart - The start position of the selected text. + * @param { int } selectionEnd - The end position of the selected text. * @param { SelectionOptions } [options] - Indicates the options of selection. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - setSelection(selectionStart: number, selectionEnd: number, options?: SelectionOptions): void; + setSelection(selectionStart: int, selectionEnd: int, options?: SelectionOptions): void; /** * Judge whether is in editing state * @@ -1624,41 +1647,41 @@ export declare class RichEditorController extends RichEditorBaseController { * * @param { ResourceStr } content - text value. * @param { RichEditorTextSpanOptions } [options] - span info. - * @returns { number } span index + * @returns { int } span index * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - addTextSpan(content: ResourceStr, options?: RichEditorTextSpanOptions): number; + addTextSpan(content: ResourceStr, options?: RichEditorTextSpanOptions): int; /** * Add a image span. * * @param { PixelMap | ResourceStr } value - image value. * @param { RichEditorImageSpanOptions } [options] - image span info. - * @returns { number } span index + * @returns { int } span index * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - addImageSpan(value: PixelMap | ResourceStr, options?: RichEditorImageSpanOptions): number; + addImageSpan(value: PixelMap | ResourceStr, options?: RichEditorImageSpanOptions): int; /** * Add a builder span. * * @param { CustomBuilder } value - Indicates the custom builder node * @param { RichEditorBuilderSpanOptions } [options] - span option. - * @returns { number } span index + * @returns { int } span index * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - addBuilderSpan(value: CustomBuilder, options?: RichEditorBuilderSpanOptions): number; + addBuilderSpan(value: CustomBuilder, options?: RichEditorBuilderSpanOptions): int; /** * Add a symbol span. * * @param { Resource } value - symbol span value * @param { RichEditorSymbolSpanOptions } [options] - symbol span option. - * @returns { number } symbol span index + * @returns { int } symbol span index * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - addSymbolSpan(value: Resource, options?: RichEditorSymbolSpanOptions): number; + addSymbolSpan(value: Resource, options?: RichEditorSymbolSpanOptions): int; /** * Modify span style. * @@ -2071,21 +2094,21 @@ export declare interface RichEditorAttribute extends CommonMethod { /** * Define the max length content of the richEditor. * - * @param { Optional } maxLength - The maximun length content of the richEditor. + * @param { int | undefined } maxLength - The maximun length content of the richEditor. * @returns { RichEditorAttribute } returns the instance of the RichEditorAttribute. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - default maxLength(maxLength: number | undefined): this; + default maxLength(maxLength: int | undefined): this; /** * Define max lines of the richEditor. * - * @param { Optional } maxLines - The maximun Lines of the richEditor. + * @param { int | undefined } maxLines - The maximun Lines of the richEditor. * @returns { RichEditorAttribute } returns the instance of the RichEditorAttribute. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - default maxLines(maxLines: number | undefined): this; + default maxLines(maxLines: int | undefined): this; /** * Set the keyboard appearance. * @@ -2114,6 +2137,26 @@ export declare interface RichEditorAttribute extends CommonMethod { */ default attributeModifier(modifier: AttributeModifier | AttributeModifier | undefined): this; + /** + * Whether to enable automatic spacing between Chinese and Latin characters. + * + * @param { boolean | undefined } enable - The default value is false, indicates the flag whether to enable + * automatic spacing. + * @returns { RichEditorAttribute } returns the instance of the RichEditorAttribute. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + default enableAutoSpacing(enable: boolean | undefined): this; + /** + * Set undo style. + * + * @param { UndoStyle | undefined } style - Default value is UndoStyle.CLEAR_STYLE. + * automatic spacing. + * @returns { RichEditorAttribute } returns the instance of the RichEditorAttribute. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + default undoStyle(style: UndoStyle | undefined): this; } /** * the callback of cut event. @@ -2125,11 +2168,10 @@ export declare interface CutEvent { /** * Prevent system cut event. * - * @type { ?VoidCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - preventDefault?: VoidCallback; + preventDefault(): void; } /** * the callback of copy event. @@ -2141,11 +2183,10 @@ export declare interface CopyEvent { /** * Prevent system cut event. * - * @type { ?VoidCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - preventDefault?: VoidCallback; + preventDefault(): void; } /** * RichEditor url style. @@ -2177,22 +2218,22 @@ export type SubmitCallback = (enterKey: EnterKeyType, event: SubmitEvent) => voi * Callback function when the selection menu appears. * * @typedef { function } MenuOnAppearCallback - * @param { number } start - Start offset of the selected content in rich editor. - * @param { number } end - End offset of the selected content in rich editor. + * @param { int } start - Start offset of the selected content in rich editor. + * @param { int } end - End offset of the selected content in rich editor. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ -export type MenuOnAppearCallback = (start: number, end: number) => void; +export type MenuOnAppearCallback = (start: int, end: int) => void; /** * Callback function when the selection menu show or hide. * * @typedef { function } MenuCallback - * @param { number } start - Start offset of the selected content in rich editor. - * @param { number } end - End offset of the selected content in rich editor. + * @param { int } start - Start offset of the selected content in rich editor. + * @param { int } end - End offset of the selected content in rich editor. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ -export type MenuCallback = (start: number, end: number) => void; +export type MenuCallback = (start: int, end: int) => void; /** * Callback function when a paste operation is performed. * diff --git a/api/arkui/component/textCommon.static.d.ets b/api/arkui/component/textCommon.static.d.ets index dd08c7621b..ba84ce639d 100644 --- a/api/arkui/component/textCommon.static.d.ets +++ b/api/arkui/component/textCommon.static.d.ets @@ -308,13 +308,13 @@ export declare interface TextBaseController { /** * Set selection to select a range of content. * - * @param { number } selectionStart - The start position of the selected text. - * @param { number } selectionEnd - The end position of the selected text. + * @param { int } selectionStart - The start position of the selected text. + * @param { int } selectionEnd - The end position of the selected text. * @param { SelectionOptions } [options] - Indicates the options of selection. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - setSelection(selectionStart: number, selectionEnd: number, options?: SelectionOptions): void; + setSelection(selectionStart: int, selectionEnd: int, options?: SelectionOptions): void; /** * Close the select menu when menu is on. * @@ -358,20 +358,20 @@ export declare interface TextEditControllerEx extends TextBaseController { /** * Set caret offset. * - * @param { number } offset - caret offset. + * @param { int } offset - caret offset. * @returns { boolean } - Return true if the caret offset was successfully set, false otherwise. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - setCaretOffset(offset: number): boolean; + setCaretOffset(offset: int): boolean; /** * Get caret offset from controller. * - * @returns { number } + * @returns { int } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 20 */ - getCaretOffset(): number; + getCaretOffset(): int; /** * Get PreviewText. * -- Gitee