mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
!37976 修复网页复制文本无法粘贴到输入框
Merge pull request !37976 from kangshihui/text_dev
This commit is contained in:
commit
a57a55026b
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "adapter/ohos/capability/clipboard/clipboard_impl.h"
|
||||
#include <vector>
|
||||
|
||||
#include "adapter/ohos/osal/pixel_map_ohos.h"
|
||||
#include "adapter/ohos/capability/html/html_to_span.h"
|
||||
@ -63,14 +64,20 @@ void ClipboardImpl::HasData(const std::function<void(bool hasData)>& callback)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ClipboardImpl::HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType)
|
||||
void ClipboardImpl::HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes)
|
||||
{
|
||||
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
||||
bool hasData = false;
|
||||
CHECK_NULL_VOID(taskExecutor_);
|
||||
taskExecutor_->PostSyncTask(
|
||||
[&hasData, mimeType]() {
|
||||
hasData = OHOS::MiscServices::PasteboardClient::GetInstance()->HasDataType(mimeType);
|
||||
[&hasData, mimeTypes]() {
|
||||
for (auto mimeType = mimeTypes.begin(); mimeType != mimeTypes.end(); ++mimeType) {
|
||||
hasData = OHOS::MiscServices::PasteboardClient::GetInstance()->HasDataType(*mimeType);
|
||||
if (hasData) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
TaskExecutor::TaskType::PLATFORM, "ArkUIClipboardHasDataType");
|
||||
callback(hasData);
|
||||
|
@ -46,7 +46,8 @@ public:
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback, bool syncMode = false) override;
|
||||
RefPtr<PasteDataMix> CreatePasteDataMix() override;
|
||||
void HasData(const std::function<void(bool hasData)>& callback) override;
|
||||
void HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType) override;
|
||||
void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) override;
|
||||
void Clear() override;
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<uint8_t>&, const std::string&)>& callback, bool syncMode = false) override;
|
||||
|
@ -81,7 +81,8 @@ void ClipboardImpl::HasData(const std::function<void(bool hasData)>& callback)
|
||||
TaskExecutor::TaskType::UI, "ArkUIClipboardHasData");
|
||||
}
|
||||
|
||||
void ClipboardImpl::HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType)
|
||||
void ClipboardImpl::HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes)
|
||||
{
|
||||
HasData(callback);
|
||||
}
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
void GetPixelMapData(const std::function<void(const RefPtr<PixelMap>&)>& callback, bool syncMode = false) override;
|
||||
void Clear() override;
|
||||
void HasData(const std::function<void(bool hasData)>& callback) override;
|
||||
void HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType) override;
|
||||
void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) override;
|
||||
void RegisterCallbackSetClipboardPixmapData(CallbackSetClipboardPixmapData callback);
|
||||
void RegisterCallbackGetClipboardPixmapData(CallbackGetClipboardPixmapData callback);
|
||||
void AddPixelMapRecord(const RefPtr<PasteDataMix>& pasteData, const RefPtr<PixelMap>& pixmap) override;
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
virtual void GetPixelMapData(
|
||||
const std::function<void(const RefPtr<PixelMap>&)>& callback, bool syncMode = false) = 0;
|
||||
virtual void HasData(const std::function<void(bool hasData)>& callback) = 0;
|
||||
virtual void HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType) = 0;
|
||||
virtual void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) = 0;
|
||||
virtual void AddPixelMapRecord(const RefPtr<PasteDataMix>& pasteData, const RefPtr<PixelMap>& pixmap) = 0;
|
||||
virtual void AddImageRecord(const RefPtr<PasteDataMix>& pasteData, const std::string& uri) = 0;
|
||||
virtual void AddTextRecord(const RefPtr<PasteDataMix>& pasteData, const std::string& selectedStr) = 0;
|
||||
|
@ -42,9 +42,9 @@ void BaseTextSelectOverlay::ProcessOverlay(const OverlayRequest& request)
|
||||
CHECK_NULL_VOID(textBase);
|
||||
auto clipboard = textBase->GetClipboard();
|
||||
if (clipboard) {
|
||||
auto mimeType = GetPasteMimeType();
|
||||
if (!mimeType.empty()) {
|
||||
clipboard->HasDataType(checkClipboard, mimeType);
|
||||
auto mimeTypes = GetPasteMimeTypes();
|
||||
if (!mimeTypes.empty()) {
|
||||
clipboard->HasDataType(checkClipboard, mimeTypes);
|
||||
return;
|
||||
}
|
||||
clipboard->HasData(checkClipboard);
|
||||
|
@ -152,9 +152,9 @@ public:
|
||||
virtual RectF GetVisibleContentRect();
|
||||
virtual bool CheckHandleVisible(const RectF& paintRect) = 0;
|
||||
|
||||
virtual std::string GetPasteMimeType()
|
||||
virtual std::vector<std::string> GetPasteMimeTypes()
|
||||
{
|
||||
return "";
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
virtual void OnResetTextSelection() {}
|
||||
|
@ -37,9 +37,9 @@ public:
|
||||
bool PreProcessOverlay(const OverlayRequest& request) override;
|
||||
bool CheckHandleVisible(const RectF& paintRect) override;
|
||||
|
||||
std::string GetPasteMimeType() override
|
||||
std::vector<std::string> GetPasteMimeTypes() override
|
||||
{
|
||||
return pasteMimeType_;
|
||||
return pasteMimeTypes_;
|
||||
}
|
||||
|
||||
void OnResetTextSelection() override;
|
||||
@ -86,7 +86,7 @@ private:
|
||||
int32_t GetTextInputCaretPosition(const OffsetF& localOffset);
|
||||
void CloseMagnifier();
|
||||
SourceType lastSourceType_ = SourceType::NONE;
|
||||
std::string pasteMimeType_ = "text/plain";
|
||||
std::vector<std::string> pasteMimeTypes_ = { "text/plain", "text/html" };
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -53,7 +53,8 @@ void MockClipBoard::HasData(const std::function<void(bool hasData)>& callback)
|
||||
}
|
||||
}
|
||||
|
||||
void MockClipBoard::HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType)
|
||||
void MockClipBoard::HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes)
|
||||
{
|
||||
if (callback) {
|
||||
callback(saveData.has_value());
|
||||
|
@ -30,7 +30,8 @@ public:
|
||||
~MockClipBoard() override = default;
|
||||
|
||||
void HasData(const std::function<void(bool hasData)>& callback) override;
|
||||
void HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType) override;
|
||||
void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) override;
|
||||
void SetData(const std::string& data, CopyOptions copyOption, bool isDragData) override;
|
||||
void GetData(const std::function<void(const std::string&)>& callback, bool syncMode) override;
|
||||
|
||||
|
@ -40,7 +40,8 @@ public:
|
||||
void GetPixelMapData(
|
||||
const std::function<void(const RefPtr<PixelMap>&)>& callback, bool syncMode = false) override {};
|
||||
void HasData(const std::function<void(bool hasData)>& callback) override {};
|
||||
void HasDataType(const std::function<void(bool hasData)>& callback, const std::string& mimeType) override {};
|
||||
void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) override {};
|
||||
void AddPixelMapRecord(const RefPtr<PasteDataMix>& pasteData, const RefPtr<PixelMap>& pixmap) override {};
|
||||
void AddImageRecord(const RefPtr<PasteDataMix>& pasteData, const std::string& uri) override {};
|
||||
void AddTextRecord(const RefPtr<PasteDataMix>& pasteData, const std::string& selectedStr) override {};
|
||||
|
Loading…
Reference in New Issue
Block a user