• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 20212022 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 #include "frameworks/bridge/declarative_frontend/jsview/js_textarea.h"
17 
18 #include <vector>
19 
20 #include "frameworks/bridge/common/utils/utils.h"
21 #include "frameworks/bridge/declarative_frontend/engine/functions/js_clipboard_function.h"
22 #include "frameworks/bridge/declarative_frontend/engine/functions/js_function.h"
23 #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
24 #include "frameworks/bridge/declarative_frontend/jsview/js_interactable_view.h"
25 #include "frameworks/bridge/declarative_frontend/jsview/js_text_editable_controller.h"
26 #include "frameworks/bridge/declarative_frontend/jsview/js_textfield.h"
27 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
28 #include "frameworks/bridge/declarative_frontend/jsview/js_view_common_def.h"
29 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
30 
31 namespace OHOS::Ace::Framework {
32 
JSBind(BindingTarget globalObj)33 void JSTextArea::JSBind(BindingTarget globalObj)
34 {
35     JSClass<JSTextArea>::Declare("TextArea");
36     MethodOptions opt = MethodOptions::NONE;
37     JSClass<JSTextArea>::StaticMethod("create", &JSTextArea::Create, opt);
38     JSClass<JSTextArea>::StaticMethod("placeholderColor", &JSTextField::SetPlaceholderColor);
39     JSClass<JSTextArea>::StaticMethod("placeholderFont", &JSTextField::SetPlaceholderFont);
40     JSClass<JSTextArea>::StaticMethod("backgroundColor", &JSTextField::SetBackgroundColor);
41     JSClass<JSTextArea>::StaticMethod("textAlign", &JSTextField::SetTextAlign);
42     JSClass<JSTextArea>::StaticMethod("caretColor", &JSTextField::SetCaretColor);
43     JSClass<JSTextArea>::StaticMethod("height", &JSTextField::JsHeight);
44     JSClass<JSTextArea>::StaticMethod("width", &JSTextField::JsWidth);
45     JSClass<JSTextArea>::StaticMethod("padding", &JSTextField::JsPadding);
46     JSClass<JSTextArea>::StaticMethod("border", &JSTextField::JsBorder);
47     JSClass<JSTextArea>::StaticMethod("borderWidth", &JSTextField::JsBorderWidth);
48     JSClass<JSTextArea>::StaticMethod("borderColor", &JSTextField::JsBorderColor);
49     JSClass<JSTextArea>::StaticMethod("borderStyle", &JSTextField::JsBorderStyle);
50     JSClass<JSTextArea>::StaticMethod("borderRadius", &JSTextField::JsBorderRadius);
51     JSClass<JSTextArea>::StaticMethod("fontSize", &JSTextField::SetFontSize);
52     JSClass<JSTextArea>::StaticMethod("fontColor", &JSTextField::SetTextColor);
53     JSClass<JSTextArea>::StaticMethod("fontWeight", &JSTextField::SetFontWeight);
54     JSClass<JSTextArea>::StaticMethod("fontStyle", &JSTextField::SetFontStyle);
55     JSClass<JSTextArea>::StaticMethod("fontFamily", &JSTextField::SetFontFamily);
56     JSClass<JSTextArea>::StaticMethod("inputFilter", &JSTextField::SetInputFilter);
57     JSClass<JSTextArea>::StaticMethod("hoverEffect", &JSTextField::JsHoverEffect);
58     JSClass<JSTextArea>::StaticMethod("maxLength", &JSTextField::SetMaxLength);
59     JSClass<JSTextArea>::StaticMethod("showCounter", &JSTextField::SetShowCounter);
60     JSClass<JSTextArea>::StaticMethod("barState", &JSTextField::SetBarState);
61     JSClass<JSTextArea>::StaticMethod("maxLines", &JSTextField::SetMaxLines);
62     JSClass<JSTextArea>::StaticMethod("style", &JSTextField::SetInputStyle);
63     JSClass<JSTextArea>::StaticMethod("onChange", &JSTextField::SetOnChange);
64     JSClass<JSTextArea>::StaticMethod("onTextSelectionChange", &JSTextField::SetOnTextSelectionChange);
65     JSClass<JSTextArea>::StaticMethod("onContentScroll", &JSTextField::SetOnContentScroll);
66     JSClass<JSTextArea>::StaticMethod("onCopy", &JSTextField::SetOnCopy);
67     JSClass<JSTextArea>::StaticMethod("onCut", &JSTextField::SetOnCut);
68     JSClass<JSTextArea>::StaticMethod("onPaste", &JSTextField::SetOnPaste);
69     JSClass<JSTextArea>::StaticMethod("onClick", &JSTextField::SetOnClick);
70     JSClass<JSTextArea>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
71     JSClass<JSTextArea>::StaticMethod("onHover", &JSInteractableView::JsOnHover);
72     JSClass<JSTextArea>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
73     JSClass<JSTextArea>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
74     JSClass<JSTextArea>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
75     JSClass<JSTextArea>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
76     JSClass<JSTextArea>::StaticMethod("onEditChange", &JSTextField::SetOnEditChanged);
77     JSClass<JSTextArea>::StaticMethod("copyOption", &JSTextField::SetCopyOption);
78     JSClass<JSTextArea>::StaticMethod("textMenuOptions", &JSTextField::JsMenuOptionsExtension);
79     JSClass<JSTextArea>::StaticMethod("foregroundColor", &JSTextField::SetForegroundColor);
80     JSClass<JSTextArea>::StaticMethod("enableKeyboardOnFocus", &JSTextField::SetEnableKeyboardOnFocus);
81     JSClass<JSTextArea>::StaticMethod("selectionMenuHidden", &JSTextField::SetSelectionMenuHidden);
82     JSClass<JSTextArea>::StaticMethod("customKeyboard", &JSTextField::SetCustomKeyboard);
83     JSClass<JSTextArea>::StaticMethod("onSubmit", &JSTextField::SetOnSubmit);
84     JSClass<JSTextArea>::StaticMethod("enterKeyType", &JSTextField::SetEnterKeyType);
85     JSClass<JSTextArea>::StaticMethod("type", &JSTextField::SetType);
86     JSClass<JSTextArea>::InheritAndBind<JSViewAbstract>(globalObj);
87 }
88 
Create(const JSCallbackInfo & info)89 void JSTextArea::Create(const JSCallbackInfo& info)
90 {
91     JSTextField::CreateTextArea(info);
92 }
93 
JSBind(BindingTarget globalObj)94 void JSTextAreaController::JSBind(BindingTarget globalObj)
95 {
96     JSClass<JSTextEditableController>::Declare("TextAreaController");
97     JSTextEditableController::JSBind(globalObj);
98 }
99 } // namespace OHOS::Ace::Framework
100