• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_RICH_EDITOR_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_RICH_EDITOR_MODEL_NG_H
18 
19 #include "core/components_ng/pattern/rich_editor/rich_editor_model.h"
20 #include "core/components_ng/pattern/rich_editor/selection_info.h"
21 
22 namespace OHOS::Ace::NG {
23 class ACE_EXPORT RichEditorModelNG : public OHOS::Ace::RichEditorModel {
24 public:
25     void Create(bool isStyledStringMode = false) override;
26     RefPtr<RichEditorBaseControllerBase> GetRichEditorController() override;
27     void SetOnReady(std::function<void()>&& func) override;
28     void SetOnSelect(std::function<void(const BaseEventInfo*)>&& func) override;
29     void SetOnSelectionChange(std::function<void(const BaseEventInfo*)>&& func) override;
30     void SetAboutToIMEInput(std::function<bool(const RichEditorInsertValue&)>&& func) override;
31     void SetOnIMEInputComplete(std::function<void(const RichEditorAbstractSpanResult&)>&& func) override;
32     void SetOnDidIMEInput(std::function<void(const TextRange&)>&& func) override;
33     void SetAboutToDelete(std::function<bool(const RichEditorDeleteValue&)>&& func) override;
34     void SetOnDeleteComplete(std::function<void()>&& func) override;
35     void SetCustomKeyboard(std::function<void()>&& func, bool supportAvoidance) override;
36     void SetCopyOption(CopyOptions& copyOptions) override;
37     void BindSelectionMenu(TextSpanType& editorType, TextResponseType& responseType,
38         std::function<void()>& buildFunc, SelectMenuParam& menuParam) override;
39     void SetOnPaste(std::function<void(NG::TextCommonEvent&)>&& func) override;
40     void SetPlaceholder(PlaceholderOptions& options) override;
41     void SetTextDetectEnable(bool value) override;
42     void SetSupportPreviewText(bool value) override;
43     void SetTextDetectConfig(const TextDetectConfig& textDetectConfig) override;
44     void SetSelectedBackgroundColor(const Color& selectedColor) override;
45     void SetCaretColor(const Color& color) override;
46     void SetOnEditingChange(std::function<void(const bool&)>&& func) override;
47     void SetOnWillChange(std::function<bool(const RichEditorChangeValue&)>&& func) override;
48     void SetOnDidChange(std::function<void(const RichEditorChangeValue&)>&& func) override;
49     void SetOnCut(std::function<void(NG::TextCommonEvent&)>&& func) override;
50     void SetOnCopy(std::function<void(NG::TextCommonEvent&)>&& func) override;
51     void SetOnShare(std::function<void(NG::TextCommonEvent&)>&& func) override;
52     void SetSelectionMenuOptions(const OnCreateMenuCallback&& onCreateMenuCallback,
53         const OnMenuItemClickCallback&& onMenuItemClick) override;
54     void SetRequestKeyboardOnFocus(bool needToRequest) override;
55     void SetEnableHapticFeedback(bool isEnabled) override;
56     void SetPreviewMenuParam(TextSpanType spanType, std::function<void()>& buildFunc,
57         const SelectMenuParam& menuParam) override;
58     void SetBarState(DisplayMode mode) override;
59     void SetMaxLength(std::optional<int32_t> value) override;
60     void ResetMaxLength() override;
61     void SetMaxLines(uint32_t value) override;
62     void SetStopBackPress(bool isStopBackPress) override;
63     void SetKeyboardAppearance(KeyboardAppearance value) override;
64 
65     static void SetTextDetectEnable(FrameNode* frameNode, bool value);
66     static void SetTextDetectConfig(FrameNode* frameNode, const TextDetectConfig& textDetectConfig);
67     static void SetOnIMEInputComplete(FrameNode* frameNode,
68         std::function<void(const RichEditorAbstractSpanResult&)>&& callback);
69     static void SetOnWillChange(FrameNode* frameNode, std::function<bool(const RichEditorChangeValue&)>&& func);
70     static void SetOnDidChange(FrameNode* frameNode, std::function<void(const RichEditorChangeValue&)>&& func);
71     static void SetPlaceholder(FrameNode* frameNode, PlaceholderOptions& options);
72     static void SetAboutToDelete(FrameNode* frameNode, std::function<bool(const RichEditorDeleteValue&)>&& func);
73     static void SetOnDidIMEInput(FrameNode* frameNode, std::function<void(const TextRange&)>&& callback);
74     static void SetCopyOption(FrameNode* frameNode, CopyOptions& copyOptions);
75     static void SetOnSelectionChange(FrameNode* frameNode, std::function<void(const BaseEventInfo*)>&& callback);
76     static void SetCaretColor(FrameNode* frameNode, const Color& color);
77     static void SetOnSelect(FrameNode* frameNode, std::function<void(const BaseEventInfo*)>&& callback);
78     static void SetOnReady(FrameNode* frameNode, std::function<void()>&& callback);
79     static void SetOnDeleteComplete(FrameNode* frameNode, std::function<void()>&& callback);
80     static void SetOnEditingChange(FrameNode* frameNode, std::function<void(const bool&)>&& callback);
81     static void SetSelectedBackgroundColor(FrameNode* frameNode, const Color& selectedColor);
82     static void SetOnPaste(FrameNode* frameNode, std::function<void(NG::TextCommonEvent&)>&& func);
83     static void SetOnCut(FrameNode* frameNode, std::function<void(NG::TextCommonEvent&)>&& func);
84     static void SetOnCopy(FrameNode* frameNode, std::function<void(NG::TextCommonEvent&)>&& func);
85     void SetEnterKeyType(TextInputAction value) override;
86     static void SetEnterKeyType(FrameNode* frameNode, const TextInputAction& action);
87     void SetOnSubmit(std::function<void(int32_t, NG::TextFieldCommonEvent&)>&& func) override;
88     static void SetOnSubmit(FrameNode* frameNode, std::function<void(int32_t, NG::TextFieldCommonEvent&)>&& callback);
89     static void SetAboutToIMEInput(FrameNode* frameNode, std::function<bool(const RichEditorInsertValue&)>&& callback);
90     static void SetRequestKeyboardOnFocus(FrameNode* frameNode, bool needToRequest);
91     static void SetSupportPreviewText(FrameNode* frameNode, bool value);
92     static void SetSelectionMenuOptions(FrameNode* frameNode, const OnCreateMenuCallback&& onCreateMenuCallback,
93         const OnMenuItemClickCallback&& onMenuItemClick);
94     static void SetPreviewMenuParam(FrameNode* frameNode,
95         TextSpanType spanType, std::function<void()>& buildFunc, const SelectMenuParam& menuParam);
96     static void SetBarState(FrameNode* frameNode, DisplayMode mode);
97     static void SetMaxLength(FrameNode* frameNode, std::optional<int32_t> value);
98     static void SetMaxLines(FrameNode* frameNode, uint32_t value);
99     static void SetStopBackPress(FrameNode* frameNode, bool isStopBackPress);
100     static void SetKeyboardAppearance(FrameNode* frameNode, KeyboardAppearance value);
101 
102 private:
103     void SetDraggable(bool draggable);
104     bool isStyledStringMode_ = false;
105 };
106 } // namespace OHOS::Ace::NG
107 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_RICH_EDITOR_MODEL_NG_H
108