/* * Copyright (c) 20212022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "frameworks/bridge/declarative_frontend/jsview/js_textarea.h" #include #include "frameworks/bridge/common/utils/utils.h" #include "frameworks/bridge/declarative_frontend/engine/functions/js_clipboard_function.h" #include "frameworks/bridge/declarative_frontend/engine/functions/js_function.h" #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h" #include "frameworks/bridge/declarative_frontend/jsview/js_interactable_view.h" #include "frameworks/bridge/declarative_frontend/jsview/js_textfield.h" #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h" #include "frameworks/bridge/declarative_frontend/jsview/js_view_common_def.h" #include "frameworks/bridge/declarative_frontend/view_stack_processor.h" namespace OHOS::Ace::Framework { void JSTextArea::JSBind(BindingTarget globalObj) { JSClass::Declare("TextArea"); MethodOptions opt = MethodOptions::NONE; JSClass::StaticMethod("create", &JSTextArea::Create, opt); JSClass::StaticMethod("placeholderColor", &JSTextField::SetPlaceholderColor); JSClass::StaticMethod("placeholderFont", &JSTextField::SetPlaceholderFont); JSClass::StaticMethod("backgroundColor", &JSTextField::SetBackgroundColor); JSClass::StaticMethod("textAlign", &JSTextField::SetTextAlign); JSClass::StaticMethod("caretColor", &JSTextField::SetCaretColor); JSClass::StaticMethod("height", &JSTextField::JsHeight); JSClass::StaticMethod("padding", &JSTextField::JsPadding); JSClass::StaticMethod("border", &JSTextField::JsBorder); JSClass::StaticMethod("borderWidth", &JSTextField::JsBorderWidth); JSClass::StaticMethod("borderColor", &JSTextField::JsBorderColor); JSClass::StaticMethod("borderStyle", &JSTextField::JsBorderStyle); JSClass::StaticMethod("borderRadius", &JSTextField::JsBorderRadius); JSClass::StaticMethod("fontSize", &JSTextField::SetFontSize); JSClass::StaticMethod("fontColor", &JSTextField::SetTextColor); JSClass::StaticMethod("fontWeight", &JSTextField::SetFontWeight); JSClass::StaticMethod("fontStyle", &JSTextField::SetFontStyle); JSClass::StaticMethod("fontFamily", &JSTextField::SetFontFamily); JSClass::StaticMethod("inputFilter", &JSTextField::SetInputFilter); JSClass::StaticMethod("hoverEffect", &JSTextField::JsHoverEffect); JSClass::StaticMethod("onChange", &JSTextField::SetOnChange); JSClass::StaticMethod("onCopy", &JSTextField::SetOnCopy); JSClass::StaticMethod("onCut", &JSTextField::SetOnCut); JSClass::StaticMethod("onPaste", &JSTextField::SetOnPaste); JSClass::StaticMethod("onClick", &JSTextField::SetOnClick); JSClass::StaticMethod("onTouch", &JSInteractableView::JsOnTouch); JSClass::StaticMethod("onHover", &JSInteractableView::JsOnHover); JSClass::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey); JSClass::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete); JSClass::StaticMethod("onAppear", &JSInteractableView::JsOnAppear); JSClass::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear); JSClass::StaticMethod("copyOption", &JSTextField::SetCopyOption); JSClass::Inherit(); JSClass::Bind(globalObj); } void JSTextArea::Create(const JSCallbackInfo& info) { JSTextField::CreateTextArea(info); } void JSTextAreaController::JSBind(BindingTarget globalObj) { JSClass::Declare("TextAreaController"); JSClass::Method("caretPosition", &JSTextAreaController::CaretPosition); JSClass::Bind(globalObj, JSTextAreaController::Constructor, JSTextAreaController::Destructor); } void JSTextAreaController::Constructor(const JSCallbackInfo& args) { auto scroller = Referenced::MakeRefPtr(); scroller->IncRefCount(); args.SetReturnValue(Referenced::RawPtr(scroller)); } void JSTextAreaController::Destructor(JSTextAreaController* scroller) { if (scroller != nullptr) { scroller->DecRefCount(); } } void JSTextAreaController::CaretPosition(int32_t caretPosition) { auto controller = controllerWeak_.Upgrade(); if (controller) { controller->CaretPosition(caretPosition); } } } // namespace OHOS::Ace::Framework