diff --git a/adapter/ohos/capability/clipboard/clipboard_impl.cpp b/adapter/ohos/capability/clipboard/clipboard_impl.cpp index 43f01fae39d..05f0740dcc0 100644 --- a/adapter/ohos/capability/clipboard/clipboard_impl.cpp +++ b/adapter/ohos/capability/clipboard/clipboard_impl.cpp @@ -619,11 +619,12 @@ void ClipboardImpl::ProcessSpanStringData( continue; } auto hasSpanString = false; - if (pasteDataRecord->GetCustomData() != nullptr) { - auto itemData = pasteDataRecord->GetCustomData()->GetItemData(); - if (itemData.find(SPAN_STRING_TAG) != itemData.end()) { - arrays.emplace_back(itemData[SPAN_STRING_TAG]); - } + auto entryPtr = pasteDataRecord->GetEntryByMimeType(SPAN_STRING_TAG); + if (entryPtr) { + // entryValue InstanceOf OHOS::MiscServices::EntryValue. + auto entryValue = entryPtr->GetValue(); + auto spanStringBuffer = std::get_if>(&entryValue); + arrays.emplace_back(*spanStringBuffer); hasSpanString = true; } if (pasteDataRecord->GetHtmlText() != nullptr && hasSpanString) { diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp index fd61434cbae..25e6e585f49 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp @@ -4191,6 +4191,7 @@ void RichEditorPattern::InsertStyledStringByPaste(const RefPtr& span if (changeLength > 0) { DeleteForwardInStyledString(changeLength, false); } + ResetSelection(); styledString_->InsertSpanString(changeStart, spanString); SetCaretPosition(caretPosition_ + spanString->GetLength()); AfterStyledStringChange(changeStart, changeLength, spanString->GetString()); diff --git a/frameworks/core/interfaces/native/node/node_api.cpp b/frameworks/core/interfaces/native/node/node_api.cpp index 8700d301aba..55dd66ed126 100644 --- a/frameworks/core/interfaces/native/node/node_api.cpp +++ b/frameworks/core/interfaces/native/node/node_api.cpp @@ -2111,7 +2111,6 @@ ArkUI_Int32 UnmarshallStyledStringDescriptor( { TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "UnmarshallStyledStringDescriptor"); CHECK_NULL_RETURN(buffer && descriptor && bufferSize > 0, ARKUI_ERROR_CODE_PARAM_INVALID); - CHECK_NULL_RETURN(descriptor->spanString, ARKUI_ERROR_CODE_INVALID_STYLED_STRING); std::vector vec(buffer, buffer + bufferSize); SpanString* spanString = new SpanString(""); spanString->DecodeTlvExt(vec, spanString); diff --git a/interfaces/native/native_styled_string_descriptor.cpp b/interfaces/native/native_styled_string_descriptor.cpp index 171987bcfd6..90e3b59697a 100644 --- a/interfaces/native/native_styled_string_descriptor.cpp +++ b/interfaces/native/native_styled_string_descriptor.cpp @@ -23,13 +23,13 @@ extern "C" { ArkUI_StyledString_Descriptor* OH_ArkUI_StyledString_Descriptor_Create() { - CHECK_NULL_RETURN(OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), nullptr); + CHECK_NULL_RETURN(OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), nullptr); return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->createArkUIStyledStringDescriptor(); } void OH_ArkUI_StyledString_Descriptor_Destroy(ArkUI_StyledString_Descriptor* descriptor) { - CHECK_NULL_VOID(OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl()); + CHECK_NULL_VOID(OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl()); OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->destroyArkUIStyledStringDescriptor(descriptor); } @@ -37,7 +37,7 @@ int32_t OH_ArkUI_UnmarshallStyledStringDescriptor( uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor) { CHECK_NULL_RETURN( - OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID); + OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID); return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->unmarshallStyledStringDescriptor( buffer, bufferSize, descriptor); } @@ -46,7 +46,7 @@ int32_t OH_ArkUI_MarshallStyledStringDescriptor( uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor, size_t* resultSize) { CHECK_NULL_RETURN( - OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID); + OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID); return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->marshallStyledStringDescriptor( buffer, bufferSize, descriptor, resultSize); } @@ -54,7 +54,7 @@ int32_t OH_ArkUI_MarshallStyledStringDescriptor( const char* OH_ArkUI_ConvertToHtml(ArkUI_StyledString_Descriptor* descriptor) { CHECK_NULL_RETURN( - OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), ""); + OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), ""); return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->convertToHtml(descriptor); }