mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
回退 'Pull Request !46373 : 【RichEditor】修改预上屏过程中addSpan索引不对的问题'
This commit is contained in:
parent
60f8957906
commit
92d07d98f8
@ -910,7 +910,8 @@ void RichEditorPattern::SetGestureOptions(UserGestureOptions options, RefPtr<Spa
|
||||
IF_TRUE(options.onLongPress, spanItem->SetLongPressEvent(std::move(options.onLongPress)));
|
||||
}
|
||||
|
||||
int32_t RichEditorPattern::AddImageSpan(ImageSpanOptions options, bool isPaste, int32_t index, bool updateCaret)
|
||||
int32_t RichEditorPattern::AddImageSpan(const ImageSpanOptions& options, bool isPaste, int32_t index,
|
||||
bool updateCaret)
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_RETURN(host, -1);
|
||||
@ -922,7 +923,6 @@ int32_t RichEditorPattern::AddImageSpan(ImageSpanOptions options, bool isPaste,
|
||||
auto pattern = imageNode->GetPattern<ImagePattern>();
|
||||
CHECK_NULL_RETURN(pattern, -1);
|
||||
pattern->SetSyncLoad(true);
|
||||
HandlePreviewWhenAddSpan(options.offset);
|
||||
int32_t insertIndex = options.offset.value_or(GetTextContentLength());
|
||||
insertIndex = std::min(insertIndex, GetTextContentLength());
|
||||
RichEditorChangeValue changeValue;
|
||||
@ -1021,7 +1021,7 @@ void RichEditorPattern::OnDetachFromFrameNode(FrameNode* node)
|
||||
context->RemoveWindowSizeChangeCallback(frameId_);
|
||||
}
|
||||
|
||||
int32_t RichEditorPattern::AddPlaceholderSpan(const RefPtr<UINode>& customNode, SpanOptionBase options)
|
||||
int32_t RichEditorPattern::AddPlaceholderSpan(const RefPtr<UINode>& customNode, const SpanOptionBase& options)
|
||||
{
|
||||
CHECK_NULL_RETURN(customNode, 0);
|
||||
auto host = GetHost();
|
||||
@ -1035,7 +1035,6 @@ int32_t RichEditorPattern::AddPlaceholderSpan(const RefPtr<UINode>& customNode,
|
||||
SetSelfAndChildDraggableFalse(customNode);
|
||||
auto focusHub = placeholderSpanNode->GetOrCreateFocusHub();
|
||||
focusHub->SetFocusable(false);
|
||||
HandlePreviewWhenAddSpan(options.offset);
|
||||
int32_t insertIndex = options.offset.value_or(GetTextContentLength());
|
||||
int32_t spanIndex = TextSpanSplit(insertIndex);
|
||||
if (spanIndex == -1) {
|
||||
@ -1081,20 +1080,6 @@ void RichEditorPattern::SetSelfAndChildDraggableFalse(const RefPtr<UINode>& cust
|
||||
}
|
||||
}
|
||||
|
||||
void RichEditorPattern::HandlePreviewWhenAddSpan(std::optional<int32_t>& offset)
|
||||
{
|
||||
CHECK_NULL_VOID(IsPreviewTextInputting());
|
||||
if (offset && offset.value() > previewTextRecord_.startOffset) {
|
||||
auto& targetIndex = offset.value();
|
||||
auto diff = std::min(targetIndex, previewTextRecord_.endOffset) - previewTextRecord_.startOffset;
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT,
|
||||
"addSpan, adjust index, preview range=[%{public}d,%{public}d], index=%{public}d diff=%{public}d",
|
||||
previewTextRecord_.startOffset, previewTextRecord_.endOffset, targetIndex, diff);
|
||||
targetIndex -= diff;
|
||||
}
|
||||
NotifyExitTextPreview();
|
||||
}
|
||||
|
||||
int32_t RichEditorPattern::AddTextSpan(TextSpanOptions options, bool isPaste, int32_t index)
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "options=%{private}s", options.ToString().c_str());
|
||||
@ -1194,11 +1179,11 @@ void RichEditorPattern::UpdateSpanNode(RefPtr<SpanNode> spanNode, const TextSpan
|
||||
spanNode->UpdateFontFeature(textStyle.GetFontFeatures());
|
||||
}
|
||||
|
||||
int32_t RichEditorPattern::AddSymbolSpan(SymbolSpanOptions options, bool isPaste, int32_t index)
|
||||
int32_t RichEditorPattern::AddSymbolSpan(const SymbolSpanOptions& options, bool isPaste, int32_t index)
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "options=%{public}s", options.ToString().c_str());
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "isPaste=%{public}d, index=%{public}d", isPaste, index);
|
||||
HandlePreviewWhenAddSpan(options.offset);
|
||||
|
||||
RichEditorChangeValue changeValue;
|
||||
CHECK_NULL_RETURN(BeforeAddSymbol(changeValue, options), -1);
|
||||
OperationRecord record;
|
||||
|
@ -529,15 +529,15 @@ public:
|
||||
std::vector<ParagraphInfo> GetParagraphInfo(int32_t start, int32_t end);
|
||||
void SetTypingStyle(std::optional<struct UpdateSpanStyle> typingStyle, std::optional<TextStyle> textStyle);
|
||||
std::optional<struct UpdateSpanStyle> GetTypingStyle();
|
||||
void HandlePreviewWhenAddSpan(std::optional<int32_t>& offset);
|
||||
int32_t AddImageSpan(ImageSpanOptions options, bool isPaste = false, int32_t index = -1, bool updateCaret = true);
|
||||
int32_t AddImageSpan(const ImageSpanOptions& options, bool isPaste = false, int32_t index = -1,
|
||||
bool updateCaret = true);
|
||||
int32_t AddTextSpan(TextSpanOptions options, bool isPaste = false, int32_t index = -1);
|
||||
int32_t AddTextSpanOperation(const TextSpanOptions& options, bool isPaste = false, int32_t index = -1,
|
||||
bool needLeadingMargin = false, bool updateCaretPosition = true);
|
||||
int32_t AddSymbolSpan(SymbolSpanOptions options, bool isPaste = false, int32_t index = -1);
|
||||
int32_t AddSymbolSpan(const SymbolSpanOptions& options, bool isPaste = false, int32_t index = -1);
|
||||
int32_t AddSymbolSpanOperation(const SymbolSpanOptions& options, bool isPaste = false, int32_t index = -1);
|
||||
void AddSpanItem(const RefPtr<SpanItem>& item, int32_t offset);
|
||||
int32_t AddPlaceholderSpan(const RefPtr<UINode>& customNode, SpanOptionBase options);
|
||||
int32_t AddPlaceholderSpan(const RefPtr<UINode>& customNode, const SpanOptionBase& options);
|
||||
void HandleSelectOverlayWithOptions(const SelectionOptions& options);
|
||||
void SetSelection(int32_t start, int32_t end, const std::optional<SelectionOptions>& options = std::nullopt,
|
||||
bool isForward = false) override;
|
||||
|
Loading…
Reference in New Issue
Block a user