【RichEditor】修改OnWill/OnDidChange接口

Signed-off-by: carnivore233 <xuyue51@huawei.com>
This commit is contained in:
carnivore233 2024-04-24 09:44:51 +08:00
parent 6474648b4e
commit 4fc6728024
2 changed files with 70 additions and 6 deletions

View File

@ -2501,17 +2501,17 @@ declare interface RichEditorDeleteValue {
*/
declare interface RichEditorChangeValue {
/**
* Spans to be replaced.
* Range of content that will be replaced.
*
* @type { Array<RichEditorTextSpanResult> }
* @type { TextRange }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
originalSpans: Array<RichEditorTextSpanResult>;
rangeBefore: TextRange;
/**
* Spans to replace.
* Text spans to replace.
*
* @type { Array<RichEditorTextSpanResult> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
@ -2519,6 +2519,26 @@ declare interface RichEditorChangeValue {
* @since 12
*/
replacedSpans: Array<RichEditorTextSpanResult>;
/**
* Image spans to replace.
*
* @type { Array<RichEditorImageSpanResult> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
replacedImageSpans: Array<RichEditorImageSpanResult>;
/**
* Symbol spans to replace.
*
* @type { Array<RichEditorTextSpanResult> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
replacedSymbolSpans: Array<RichEditorTextSpanResult>;
}
/**
@ -3352,13 +3372,13 @@ declare class RichEditorAttribute extends CommonMethod<RichEditorAttribute> {
/**
* Called after text changed.
*
* @param { Callback<Array<RichEditorTextSpanResult>> } callback - The triggered function after text content is about to change.
* @param { OnDidChangeCallback } callback - The triggered function after content changed.
* @returns { RichEditorAttribute }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
onDidChange(callback: Callback<Array<RichEditorTextSpanResult>>) : RichEditorAttribute;
onDidChange(callback: OnDidChangeCallback) : RichEditorAttribute;
/**
* Called before the cut event.

View File

@ -145,3 +145,47 @@ declare interface TextDataDetectorConfig {
*/
onDetectResultUpdate?: (result: string) => void
}
/**
* Defines range of text type component.
*
* @interface TextRange
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
declare interface TextRange {
/**
* Start offset.
*
* @type { ?number }
* @default 0
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
start?: number;
/**
* End offset.
*
* @type { ?number }
* @default text length
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
end?: number;
}
/**
* Callback after content changed.
*
* @typedef { function } OnDidChangeCallback
* @param { TextRange } rangeBefore - Range of content that had been replaced.
* @param { TextRange } rangeAfter - Range of content that newly added.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 12
*/
declare type OnDidChangeCallback = (rangeBefore: TextRange, rangeAfter: TextRange) => void;