mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 09:12:41 +00:00
cj_frontend RichEditor component support onDidChange callback
Signed-off-by: yuzhuohao <1171326722@qq.com>
This commit is contained in:
parent
28262da379
commit
5e4462f2e6
@ -237,6 +237,7 @@
|
||||
OHOS::Ace::NG::RichEditorAbstractSpanResult::*;
|
||||
OHOS::Ace::NG::RichEditorInsertValue::*;
|
||||
OHOS::Ace::NG::RichEditorDeleteValue::*;
|
||||
OHOS::Ace::NG::RichEditorChangeValue::*;
|
||||
OHOS::Ace::TabController::*;
|
||||
OHOS::Ace::ParseFontFeatureSettings*;
|
||||
OHOS::Ace::StorageProxy::*;
|
||||
|
@ -243,4 +243,17 @@ void FfiOHOSAceFrameworkRichEditorPreventDefault(int64_t id)
|
||||
auto nativePasteEvent = FFIData::GetData<NativePasteEvent>(id);
|
||||
nativePasteEvent->PreventDefault();
|
||||
}
|
||||
|
||||
void FfiOHOSAceFrameworkRichEditorOnDidChange(void(*callback)(CJTextRange rangeBefore, CJTextRange rangeAfter))
|
||||
{
|
||||
auto onDidChange = [cjCallback = CJLambda::Create(callback)](const NG::RichEditorChangeValue& changeValue) {
|
||||
const auto& rangeBefore = changeValue.GetRangeBefore();
|
||||
const auto& rangeAfter = changeValue.GetRangeAfter();
|
||||
CJTextRange cjRangeBefore = { rangeBefore.start, rangeBefore.end };
|
||||
CJTextRange cjRangeAfter = { rangeAfter.start, rangeAfter.end };
|
||||
|
||||
cjCallback(cjRangeBefore, cjRangeAfter);
|
||||
};
|
||||
RichEditorModel::GetInstance()->SetOnDidChange(std::move(onDidChange));
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ struct NativeRichEditorInsertValue {
|
||||
const char* insertValue;
|
||||
};
|
||||
|
||||
struct CJTextRange {
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
};
|
||||
|
||||
class ACE_EXPORT NativePasteEvent : public OHOS::FFI::FFIData {
|
||||
DECL_TYPE(NativeTextCommonEvent, OHOS::FFI::FFIData)
|
||||
public:
|
||||
@ -62,6 +67,8 @@ CJ_EXPORT void FfiOHOSAceFrameworkRichEditorOnSelect(void(*callback)(NativeRichE
|
||||
CJ_EXPORT void FfiOHOSAceFrameworkRichEditorAboutToDelete(bool(*callback)(NativeRichEditorDeleteValue));
|
||||
CJ_EXPORT void FfiOHOSAceFrameworkRichEditorOnPaste(void(*callback)(int64_t));
|
||||
CJ_EXPORT void FfiOHOSAceFrameworkRichEditorPreventDefault(int64_t controller);
|
||||
CJ_EXPORT void FfiOHOSAceFrameworkRichEditorOnDidChange(
|
||||
void(*callback)(CJTextRange rangeBefore, CJTextRange rangeAfter));
|
||||
}
|
||||
|
||||
#endif // OHOS_ACE_FRAMEWORK_CJ_RICHEDITOR_FFI_H
|
||||
|
@ -217,7 +217,7 @@ private:
|
||||
std::list<RichEditorAbstractSpanResult> richEditorDeleteSpans_;
|
||||
};
|
||||
|
||||
class RichEditorChangeValue : public BaseEventInfo {
|
||||
class ACE_FORCE_EXPORT RichEditorChangeValue : public BaseEventInfo {
|
||||
DECLARE_ACE_TYPE(RichEditorChangeValue, BaseEventInfo)
|
||||
public:
|
||||
RichEditorChangeValue() : BaseEventInfo("RichEditorChangeValue") {}
|
||||
|
Loading…
Reference in New Issue
Block a user